@onylab/common-api 1.1.6 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1157,9 +1157,54 @@ declare module "api/hubrise/service/HubriseApi" {
1157
1157
  getCatalogs(hubriseLocationId: string): Promise<HubriseMenuCatalogContract[]>;
1158
1158
  }
1159
1159
  }
1160
+ declare module "api/hubrise/model/menu/HubriseMenuImageContract" {
1161
+ export interface HubriseMenuImageContract {
1162
+ id: string;
1163
+ type: string;
1164
+ size: string;
1165
+ md5: string;
1166
+ seconds_before_removal: number;
1167
+ }
1168
+ }
1160
1169
  declare module "api/index" {
1161
1170
  export * from "api/hubrise/mockup/HubriseApiMockup";
1171
+ export * from "api/hubrise/service/HubriseApiContract";
1162
1172
  export * from "api/hubrise/service/HubriseApi";
1173
+ export * from "api/hubrise/model/account/HubriseAccountContract";
1174
+ export * from "api/hubrise/model/account/HubriseAuthContract";
1175
+ export * from "api/hubrise/model/common/HubriseCurrencyCode";
1176
+ export * from "api/hubrise/model/common/HubriseCustomFieldsContract";
1177
+ export * from "api/hubrise/model/common/HubriseLocale";
1178
+ export * from "api/hubrise/model/common/HubriseTimezoneContract";
1179
+ export * from "api/hubrise/model/common/HubriseTimezoneId";
1180
+ export * from "api/hubrise/model/customer/HubriseCustomerContract";
1181
+ export * from "api/hubrise/model/customer/HubriseCustomerListContract";
1182
+ export * from "api/hubrise/model/location/HubriseLocationContract";
1183
+ export * from "api/hubrise/model/location/HubriseOpeningHoursContract";
1184
+ export * from "api/hubrise/model/location/HubriseOrderAcceptanceContract";
1185
+ export * from "api/hubrise/model/menu/HubriseMenuCatalogContract";
1186
+ export * from "api/hubrise/model/menu/HubriseMenuCategoryContract";
1187
+ export * from "api/hubrise/model/menu/HubriseMenuChargeContract";
1188
+ export * from "api/hubrise/model/menu/HubriseMenuDealContract";
1189
+ export * from "api/hubrise/model/menu/HubriseMenuDealLineContract";
1190
+ export * from "api/hubrise/model/menu/HubriseMenuDiscountContract";
1191
+ export * from "api/hubrise/model/menu/HubriseMenuImageContract";
1192
+ export * from "api/hubrise/model/menu/HubriseMenuPriceOverrideContract";
1193
+ export * from "api/hubrise/model/menu/HubriseMenuProductContract";
1194
+ export * from "api/hubrise/model/menu/HubriseMenuProductOptionContract";
1195
+ export * from "api/hubrise/model/menu/HubriseMenuProductOptionListContract";
1196
+ export * from "api/hubrise/model/menu/HubriseMenuRestrictionsContract";
1197
+ export * from "api/hubrise/model/menu/HubriseMenuSkuContract";
1198
+ export * from "api/hubrise/model/order/HubriseOrderChargeContract";
1199
+ export * from "api/hubrise/model/order/HubriseOrderContract";
1200
+ export * from "api/hubrise/model/order/HubriseOrderDealContract";
1201
+ export * from "api/hubrise/model/order/HubriseOrderDiscountContract";
1202
+ export * from "api/hubrise/model/order/HubriseOrderItemContract";
1203
+ export * from "api/hubrise/model/order/HubriseOrderLoyaltyOperationContract";
1204
+ export * from "api/hubrise/model/order/HubriseOrderOptionContract";
1205
+ export * from "api/hubrise/model/order/HubriseOrderPaymentContract";
1206
+ export * from "api/hubrise/model/order/HubriseOrderStatus";
1207
+ export * from "api/hubrise/model/user/HubriseUserContract";
1163
1208
  }
1164
1209
  declare module "constant/Path" {
1165
1210
  export class Path {
@@ -1320,13 +1365,13 @@ declare module "http/ServerContract" {
1320
1365
  }
1321
1366
  }
1322
1367
  declare module "http/Server" {
1323
- import * as express from 'express';
1368
+ import { Express } from 'express';
1324
1369
  import { ServerContract } from "http/ServerContract";
1325
1370
  export class Server implements ServerContract {
1326
1371
  static readonly DEFAULT_PORT: number;
1327
1372
  static readonly SALT: string;
1328
1373
  private app;
1329
- create(origins: string[], port?: number): Promise<express.Express>;
1374
+ create(origins: string[], port?: number): Promise<Express>;
1330
1375
  getSessionSecret(sessionCookieName: string): string;
1331
1376
  }
1332
1377
  }
@@ -1884,15 +1929,6 @@ declare module "@onylab/common-api" {
1884
1929
  import * as Util from "util/index";
1885
1930
  export { Api, Constant, Exception, Http, Service, Template, Tool, Util };
1886
1931
  }
1887
- declare module "api/hubrise/model/menu/HubriseMenuImageContract" {
1888
- export interface HubriseMenuImageContract {
1889
- id: string;
1890
- type: string;
1891
- size: string;
1892
- md5: string;
1893
- seconds_before_removal: number;
1894
- }
1895
- }
1896
1932
  declare module "exception/ForbiddenException" {
1897
1933
  import { MainException } from "exception/MainException";
1898
1934
  import { ExceptionContract } from "exception/ExceptionContract";
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SmilePlayerCommon=e():t.SmilePlayerCommon=e()}(global,(()=>(()=>{"use strict";var t={16:t=>{t.exports=require("emoji-regex")},270:t=>{t.exports=JSON.parse('{"id":"87yu4","location_id":"3r4s3-1","name":"Web","created_at":"2020-06-25T11:43:51+02:00","data":{"variants":[],"categories":[],"products":[],"options_lists":[],"deals":[],"discounts":[],"charges":[]}}')},835:t=>{t.exports=JSON.parse('[{"id":"87yu4","name":"Web","created_at":"2020-06-25T11:43:51+02:00"},{"id":"sdm3b","name":"Common menu","created_at":"2020-05-19T13:23:10+02:00"}]')},851:t=>{t.exports=JSON.parse('{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}')},329:t=>{t.exports=JSON.parse('[{"id":"apm3s","name":"Online customers","created_at":"2020-06-25T11:43:51+02:00"},{"id":"s7ma5","name":"POS customers","created_at":"2020-05-19T13:23:10+02:00"}]')},616:t=>{t.exports=JSON.parse('[{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}},{"id":"asdf2","customer_list_id":"ag8u4","anonymised":false,"email":"charles.moore@dummy-mail.org","first_name":"Charles","last_name":"Moore","phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}]')},69:t=>{t.exports=JSON.parse('[{"id":"3r4s3-1","name":"Paris","account":{"id":"3r4s3","name":"Bella Pizza","currency":"EUR"},"preparation_time":15,"order_acceptance":{"mode":"normal"}}]')},133:t=>{t.exports=JSON.parse('{"status":"new","private_ref":"fr:1679f128-4ff6-4a60-9fc2-7fe38af4f84d","service_type":"delivery","service_type_ref":null,"expected_time":"2021-11-07T17:17:22Z","customer_notes":"PAS DE COUVERTS","collection_code":"5645","items":[{"product_name":"LIP15","sku_ref":"LIP15","price":"3.50 EUR","quantity":1,"options":[]},{"product_name":"5VANI","sku_ref":"5VANI","price":"6.90 EUR","quantity":1,"options":[]},{"product_name":"TSQ2","sku_ref":"TSQ2","price":"13.50 EUR","quantity":1,"options":[{"option_list_name":"Options","name":"SUPP RACLETTE","ref":"SUPP RACLETTE","price":"1.00 EUR"}]},{"product_name":"SCES","sku_ref":"SCES","price":"10.50 EUR","quantity":1,"options":[]}],"deals":{},"discounts":[],"charges":[{"type":"delivery","name":"Delivery charge","ref":null,"price":"0.99 EUR"}],"payments":[{"type":"online","name":"Paid online","ref":null,"amount":"36.39 EUR"}],"customer":{"address_1":"6a Rue du Tire Pesseau, 21000 Dijon, France","city":"Dijon","postal_code":"21000","phone":"+33175858334","delivery_notes":"Phone access code: 151081499","first_name":"Benoit","last_name":"B.","email":"orders@deliveroo.com","latitude":"47.3166297697847","longitude":"5.00251594930887"}}')},660:t=>{t.exports=JSON.parse('{"id":"v6ap7","first_name":"Tom","last_name":"Jones","email":"tom.jones@dummy-mail.org","timezone":{"name":"Europe/Paris"},"locales":["fr-FR","en-US"]}')}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};n.r(r),n.d(r,{Api:()=>o,Constant:()=>i,Exception:()=>a,Http:()=>s,Service:()=>u,Template:()=>c,Tool:()=>l,Util:()=>f});var o={};n.r(o),n.d(o,{HubriseApi:()=>D,HubriseApiMockup:()=>y});var i={};n.r(i),n.d(i,{Path:()=>N});var a={};n.r(a),n.d(a,{BadParameterException:()=>B,BadRequestException:()=>H,ConflictException:()=>z,DuplicateException:()=>J,ExternalApiException:()=>S,InternalException:()=>V,MainException:()=>E,NotImplementedException:()=>Y,ObjectNotFoundException:()=>K,PageNotFoundException:()=>tt,UnauthorizedException:()=>P});var s={};n.r(s),n.d(s,{AuthenticationMiddleware:()=>nt,AuthorizationMiddleware:()=>rt,HandlerController:()=>et,Server:()=>ft});var u={};n.r(u),n.d(u,{EmailSenderService:()=>Bt,SmsSenderService:()=>gt});var c={};n.r(c),n.d(c,{TemplateEngine:()=>Ut});var l={};n.r(l),n.d(l,{Configuration:()=>Gt,Database:()=>Zt,Displayer:()=>Xt,Downloader:()=>Yt,Env:()=>x,Environment:()=>C,FileSystem:()=>At,Logger:()=>k,Retry:()=>L});var f={};n.r(f),n.d(f,{AddressUtil:()=>te,DateUtil:()=>ee,ExtractorUtil:()=>ne,FormatterUtil:()=>Qt,GeneratorUtil:()=>Tt,MathUtil:()=>re,ObjectUtil:()=>oe,PriceUtil:()=>ie,StringUtil:()=>Kt,ValidatorUtil:()=>dt,asyncForEach:()=>_t,isNullOrUndefined:()=>j,wait:()=>St});const p=require("nock");var d=function(){function t(){}return t.isDone=function(){return p.isActive()&&p.isDone()},t.pending=function(){return"pending: "+JSON.stringify(p.pendingMocks())},t.reset=function(){p.cleanAll()},t}();const h=require("lodash");var m,v=(m=function(t,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},m(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}m(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e.getUser=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/user")?"/user":t})).get("/user").times(t).reply(200,(0,h.cloneDeep)(n(660)))},e.getLocations=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/locations")?"/locations":t})).get("/locations").times(t).reply(200,(0,h.cloneDeep)(n(69)))},e.createCustomer=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/customer")?"/customer":t})).post("/customer").times(t).reply(200,(0,h.cloneDeep)(n(851)))},e.getCustomer=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/customer_lists")&&t.includes("/customers")?"/customer":t})).get("/customer").times(t).reply(200,(0,h.cloneDeep)(n(851)))},e.getCustomers=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/customers")?"/customers":t})).get("/customers").times(t).reply(200,(0,h.cloneDeep)(n(616)))},e.getCustomerLists=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/customer_lists")?"/customerLists":t})).get("/customerLists").times(t).reply(200,(0,h.cloneDeep)(n(329)))},e.createOrder=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/order")?"/order":t})).post("/order").times(t).reply(200,(0,h.cloneDeep)(n(133)))},e.getOrder=function(t,r){void 0===t&&(t=1),void 0===r&&(r=!1);var o=(0,h.cloneDeep)(n(133));r&&(o.id=String(Date.now())),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/orders/")?"/order":t})).get("/order").times(t).reply(200,o)},e.setOrderStatus=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/orders/")?"/status":t})).patch("/status").times(t).reply(204)},e.getCatalog=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/catalog")?"/catalog":t})).get("/catalog").times(t).reply(200,(0,h.cloneDeep)(n(270)))},e.getCatalogs=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/catalogs")?"/catalogs":t})).get("/catalogs").times(t).reply(200,(0,h.cloneDeep)(n(835)))},e.BASE_URL="http://api.hubrise.com",e}(d);const g=require("axios");var b=n.n(g),w=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),E=function(t){function e(n,r,o){var i=t.call(this,n)||this;return i.code=r,i.data=o,i.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,e):i.stack=new Error(n).stack,i}return w(e,t),e}(Error),_=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return _(e,t),e}(E);const O=require("@sentry/node"),T=require("@sentry/profiling-node");var x;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(x||(x={}));var C=function(){function t(){}return t.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return x.DEVELOPMENT;case"prod":case"production":return x.PRODUCTION;case"test":return x.TEST}return void 0===process.env.APP_ID?x.DEVELOPMENT:x.PRODUCTION},t}(),A=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=function(t){function e(n,r){var o=t.call(this,n,e.ERROR_CODE,r)||this;return o.name="UnauthorizedException",o}return A(e,t),e.ERROR_CODE=401,e}(E),j=function(t){return null==t},k=function(){function t(){}return t.init=function(t,e){C.getMode()===x.PRODUCTION&&(O.init({dsn:t,integrations:[O.captureConsoleIntegration({levels:["error","warn","log"]}),(0,T.nodeProfilingIntegration)()],environment:C.getMode(),maxBreadcrumbs:50,tracesSampleRate:0,profilesSampleRate:0}),O.setupExpressErrorHandler(e))},t.trace=function(t,e){[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.info(t):console.info(t,e):O.addBreadcrumb({category:"info",message:t,data:e,level:"info"})},t.debug=function(t,e){[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.log(t):console.log(t,e):O.addBreadcrumb({category:"debug",message:t,data:e,level:"debug"})},t.info=function(t,e){[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.info(t):console.info(t,e):O.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),O.captureMessage(t)}))},t.warning=function(t,e){j(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.warn(t):console.warn(t,e):O.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),O.captureException(t)}))},t.error=function(t,e){[P.ERROR_CODE].includes(t.code)||(j(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.error(t):console.error(t,e):O.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),O.captureException(t)})))},t}();const R=require("retry");var L=function(){function t(){}return t.request=function(t){return e=this,n=arguments,o=function(t,e,n){var r;return void 0===e&&(e=2),function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}(this,(function(o){return r=R.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,o){r.attempt((function(){t().then(e).catch((function(t){r.retry(t)?"function"==typeof n&&n(t):o(t)}))}))}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function s(t){try{u(o.throw(t))}catch(t){i(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}u((o=o.apply(e,n||[])).next())}));var e,n,r,o},t}();const M=require("querystring");var I=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},U=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},D=function(){function t(t){this.token=t}return t.prototype.authorize=function(e,n){return I(this,void 0,void 0,(function(){return U(this,(function(r){return[2,t.BASE_AUTH_URL+"authorize?redirect_uri="+String(n)+"&client_id="+e+"&scope=account[orders.write,all_customer_lists.write,all_catalogs.write,inventory.write],profile_with_email"]}))}))},t.prototype.getToken=function(e,n,r){return I(this,void 0,void 0,(function(){var o,i=this;return U(this,(function(a){switch(a.label){case 0:return[4,L.request((function(){return I(i,void 0,void 0,(function(){var i;return U(this,(function(a){switch(a.label){case 0:return[4,b().post(t.BASE_AUTH_URL+"token",M.stringify({code:r,client_id:e,client_secret:n}),{headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:t.TIMEOUT})];case 1:if(void 0===(i=a.sent())||void 0===i.data)throw new S("failed to get hubrise token");return o=i.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return a.sent(),[2,o]}}))}))},t.prototype.getUser=function(){return I(this,void 0,void 0,(function(){var e,n=this;return U(this,(function(r){switch(r.label){case 0:return[4,L.request((function(){return I(n,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return[4,b().get(t.BASE_URL+"user",{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise user");return e=n.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return r.sent(),[2,e]}}))}))},t.prototype.getLocations=function(){return I(this,void 0,void 0,(function(){var e,n=this;return U(this,(function(r){switch(r.label){case 0:return[4,L.request((function(){return I(n,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return[4,b().get(t.BASE_URL+"locations",{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise locations");return e=n.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return r.sent(),[2,e]}}))}))},t.prototype.createCustomer=function(e,n){return I(this,void 0,void 0,(function(){var r=this;return U(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().post(t.BASE_URL+"customer_lists/"+String(e)+"/customers",n,{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to create hubrise customer");return[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2]}}))}))},t.prototype.getCustomer=function(e,n){return I(this,void 0,void 0,(function(){var r,o=this;return U(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return I(o,void 0,void 0,(function(){var o;return U(this,(function(i){switch(i.label){case 0:return[4,b().get(t.BASE_URL+"customer_lists/"+String(e)+"/customers/"+String(n),{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(o=i.sent())||void 0===o.data)throw new S("failed to retrieve hubrise customer");return r=o.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.getCustomers=function(e,n,r,o){return I(this,void 0,void 0,(function(){var i,a,s=this;return U(this,(function(u){switch(u.label){case 0:return(i=new URLSearchParams).append("private_ref",n),i.append("email",r),i.append("phone",o),[4,L.request((function(){return I(s,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return[4,b().get(t.BASE_URL+"customer_lists/"+String(e)+"/customers?"+i.toString(),{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise customers");return a=n.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return u.sent(),[2,a]}}))}))},t.prototype.getCustomerLists=function(e){return I(this,void 0,void 0,(function(){var n,r=this;return U(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().get(t.BASE_URL+"locations/"+String(e)+"/customer_lists",{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to retrieve hubrise customer lists");return n=r.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2,n]}}))}))},t.prototype.createOrder=function(e,n){return I(this,void 0,void 0,(function(){var r=this;return U(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().post(t.BASE_URL+"locations/"+String(e)+"/orders",n,{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to create hubrise order");return[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2]}}))}))},t.prototype.getOrder=function(e,n){return I(this,void 0,void 0,(function(){var r,o=this;return U(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return I(o,void 0,void 0,(function(){var o;return U(this,(function(i){switch(i.label){case 0:return[4,b().get(t.BASE_URL+"locations/"+String(e)+"/orders/"+String(n),{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(o=i.sent())||void 0===o.data)throw new S("failed to retrieve hubrise order");return r=o.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.setOrderStatus=function(e,n,r){return I(this,void 0,void 0,(function(){var o=this;return U(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return I(o,void 0,void 0,(function(){var o;return U(this,(function(i){switch(i.label){case 0:return[4,b().patch(t.BASE_URL+"locations/"+String(e)+"/orders/"+String(n),{status:r},{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(o=i.sent())||void 0===o.data)throw new S("failed to update hubrise order status");return[2]}}))}))}),1,k.error.bind(k))];case 1:return i.sent(),[2]}}))}))},t.prototype.getCatalog=function(e){return I(this,void 0,void 0,(function(){var n,r=this;return U(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().get(t.BASE_URL+"catalogs/"+String(e),{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to retrieve hubrise catalogs");return n=r.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2,n]}}))}))},t.prototype.getCatalogs=function(e){return I(this,void 0,void 0,(function(){var n,r=this;return U(this,(function(o){switch(o.label){case 0:return n=[],[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().get(t.BASE_URL+"locations/"+String(e)+"/catalogs",{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to retrieve hubrise catalogs");return n=r.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2,n]}}))}))},t.BASE_URL="http://api.hubrise.com/v1/",t.BASE_AUTH_URL="https://manager.hubrise.com/oauth2/v1/",t.TIMEOUT=15e3,t}(),N=function(){function t(){}return t.registerBasePath=function(e){void 0!==process.env.APP_HOME?t.BASE_PATH=process.env.APP_HOME+"/":t.BASE_PATH=e+(e.endsWith("/")?"":"/")},t.data=function(){return t.BASE_PATH+"data/"},t.db=function(){return t.storage()+"db/"},t.root=function(){return t.BASE_PATH},t.session=function(){return t.storage()+"session/"},t.storage=function(){return t.BASE_PATH+"storage/"},t.BASE_PATH="./",t}(),q=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),B=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadParameterException",r}return q(e,t),e}(E),F=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),H=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return F(e,t),e}(E),G=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),z=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return G(e,t),e}(E),W=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),J=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="DuplicateException",r}return W(e,t),e}(E),Z=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),V=function(t){function e(e,n){var r=t.call(this,e,500,n)||this;return r.name="InternalException",r}return Z(e,t),e}(E),X=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Y=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return X(e,t),e}(E),$=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),K=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return $(e,t),e}(E),Q=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),tt=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return Q(e,t),e}(E),et=function(){function t(){}return t.error=function(t,e,n){k.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;e.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),e.json({code:n.code,message:n.message})},t}(),nt=function(){function t(t){this.configuration=t}return t.prototype.handler=function(){var t=this;return function(e,n,r){try{var o=!1;if(o||void 0===t.configuration.jwt||(e.session={},o=!0),o||void 0===t.configuration.key||(o=t.authApiKey(e)),!o&&void 0!==t.configuration.session){var i=Object.keys(e.session);if(!Array.isArray(t.configuration.session.required))throw new P("session is not well formatted");t.configuration.session.required.forEach((function(t){if(!i.includes(t))throw new P("session is incomplete")})),o=!0}if(o||void 0===t.configuration.none||(o=t.authNone(e)),!o)throw new P("request is not authenticate");r()}catch(t){et.error(e,n,t)}}},t.prototype.authApiKey=function(t){if("string"!=typeof t.headers.Authorization||!t.headers.Authorization.startsWith("apiKey"))return!1;var e=t.headers.Authorization.split(" ");if(2!==e.length)throw new P("api key is not well formatted");if(e[1]!==this.configuration.key.secret)throw new P("api key is not valid");return t.session={},!0},t.prototype.authNone=function(t){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find((function(e){var n;return null===(n=t.originalUrl)||void 0===n?void 0:n.startsWith(e)}))||(t.session={},0))},t}(),rt=function(){function t(){}return t.prototype.can=function(t,e){},t}();const ot=require("crypto"),it=require("express"),at=require("cors"),st=require("compression"),ut=require("helmet");var ct=n.n(ut);const lt=require("connect-timeout");var ft=function(){function t(){}return t.prototype.create=function(e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),k.debug("start server on "+o),this.app=it(),this.app.set("trust proxy",!0),this.app.use(st({level:-1})),this.app.use(lt("300s")),this.app.use(it.json({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(it.urlencoded({limit:"10mb"})),this.app.use(at({origin:[o].concat(e),credentials:!0})),this.app.use(ct()()),this.app.use(it.json()),this.app.listen(r,(function(){k.debug("server is running on "+o)}))),[2,this.app]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{u(a.next(t))}catch(t){e(t)}}function s(t){try{u(a.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,s)}u((a=a.apply(r,o||[])).next())}));var r,o,i,a},t.prototype.getSessionSecret=function(e){return ot.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const pt=require("luxon");var dt=function(){function t(){}return t.isEmail=function(t){return"string"==typeof t&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(t)},t.isPhone=function(t){return"string"==typeof t&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(t)},t.isIntMobilePhone=function(t){var e=new RegExp("^\\+1[0-9]{10}$","i"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return e.test(t)||n.test(t)||r.test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}();const ht=require("iconv-lite");var mt=function(){function t(){}return t.isUTF8=function(t){return!t||"utf8"===(t=t.toLowerCase())||"utf-8"===t},t.urlencode=function(e,n){if(!n||t.isUTF8(n))return encodeURIComponent(e);for(var r=(0,ht.encode)(e,n),o="",i="",a=0;a<r.length;a++)1===(i=r[a].toString(16)).length&&(i="0"+i),o+="%"+i;return o.toUpperCase()},t}(),vt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},yt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},gt=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r){return vt(this,arguments,void 0,(function(e,n,r,o,i){var a,s=this;return void 0===o&&(o=!0),yt(this,(function(u){switch(u.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(k.warning(new B("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*t.MESSAGE_MAX_LENGTH?n=n.substring(0,2*t.MESSAGE_MAX_LENGTH):n.length>t.MESSAGE_MAX_LENGTH&&n.length<=1.33*t.MESSAGE_MAX_LENGTH&&(n=n.substring(0,t.MESSAGE_MAX_LENGTH))),[4,L.request((function(){return vt(s,void 0,void 0,(function(){var r,s,u;return yt(this,(function(c){switch(c.label){case 0:return r={accessToken:this.token,emetteur:e,message:mt.urlencode(n,"ISO-8859-15"),numero:a.map((function(t){return t.replace("+","")})).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/t.MESSAGE_MAX_LENGTH)},o&&(r.stop=1),void 0!==i&&(r.date_envoi=pt.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),s=pt.DateTime.fromISO(null!=i?i:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),o?s.hour>=21?r.date_envoi=s.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):s.hour<9&&(r.date_envoi=s.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):s.hour<8&&(r.date_envoi=s.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode!==x.TEST?[3,1]:(k.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===x.DEVELOPMENT&&(a=["+15145705214"]),[4,b().post(t.BASE_API_URL+"sendSMS.do",M.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((u=c.sent()).data.length>0&&"0"!==u.data.trim().substring(0,1))throw new S("Error: "+u.data,r);c.label=3;case 3:return[2]}}))}))}),0,k.error.bind(k))]);case 1:return u.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return dt.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const bt=require("path"),wt=require("mustache"),Et=require("fs");var _t=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}(this,(function(r){switch(r.label){case 0:n=0,r.label=1;case 1:return n<t.length?[4,e(t[n])]:[3,4];case 2:r.sent(),r.label=3;case 3:return n++,[3,1];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{u(i.next(t))}catch(t){e(t)}}function s(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,s)}u((i=i.apply(n,r||[])).next())}));var n,r,o,i},St=function(t){return new Promise((function(e){return setTimeout(e,t)}))};const Ot=require("color-name");var Tt=function(){function t(){}return t.code=function(e){null==e&&(e=6);for(var n="";n.length<e;)n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];return n},t.color=function(e){void 0===e&&(e=1);var n=t.rgbToHex(Math.round(255*e)),r="#000000"+n,o=Object.values(Ot);if(0===o.length)return r;var i=o[t.int(0,o.length-1)];return 3!==i.length?r:"#"+t.rgbToHex(i[0])+t.rgbToHex(i[1])+t.rgbToHex(i[2])+n},t.rgbToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},t.int=function(t,e){return null==t&&(t=0),null==e&&(e=Number.POSITIVE_INFINITY),t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},t.password=function(e){null==e&&(e=8);for(var n="";n.length<e;)switch(t.int(1,3)){case 1:n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];break;case 2:n+=t.symbolLowerCases[t.int(0,t.symbolLowerCases.length-1)];break;default:n+=String(t.int(0,9))}return n},t.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],t.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"],t}(),xt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Ct=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},At=function(){function t(){}return t.prototype.dirPath=function(t){var e=bt.resolve(t).lastIndexOf(bt.sep);return e<0?t:bt.resolve(bt.resolve(t).substr(0,e+1))+bt.sep},t.prototype.listFiles=function(t){return xt(this,void 0,void 0,(function(){var e,n,r,o=this;return Ct(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new B(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=Et.readdirSync(t),r=[],[4,_t(n,(function(n){return xt(o,void 0,void 0,(function(){return Ct(this,(function(o){return this.isFile(t+e+n)&&r.push(t+e+n),[2]}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.randomFile=function(t,e){return xt(this,void 0,void 0,(function(){var n,r;return Ct(this,(function(o){switch(o.label){case 0:return[4,this.listFiles(t)];case 1:return 0===(n=o.sent()).length?[2,void 0]:(r=void 0!==e?Math.max(e,0)%n.length:Tt.int(0,n.length-1),[2,n[r]])}}))}))},t.prototype.move=function(t,e){return xt(this,void 0,void 0,(function(){return Ct(this,(function(n){if(!this.isFile(t))throw new B(String(t)+" does not exist or is not a file");if(Et.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new B(String(e)+" does not exist or is not a directory");return[2,Et.renameSync(t,e+bt.basename(t))]}))}))},t.prototype.read=function(t){return xt(this,void 0,void 0,(function(){return Ct(this,(function(e){if(!this.isFile(t))throw new B(String(t)+" does not exist or is not a file");return[2,Et.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return xt(this,void 0,void 0,(function(){var e;return Ct(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new B(String(t)+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.readJsonFiles=function(t){return xt(this,void 0,void 0,(function(){var e,n,r,o=this;return Ct(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new B(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=Et.readdirSync(t),r=[],[4,_t(n,(function(n){return xt(o,void 0,void 0,(function(){var o,i,a;return Ct(this,(function(s){switch(s.label){case 0:return this.isFile(t+e+n)&&n.endsWith(".json")?(i=(o=r).push,a={name:n},[4,this.readJson(t+e+n)]):[3,2];case 1:i.apply(o,[(a.data=s.sent(),a)]),s.label=2;case 2:return[2]}}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.write=function(t,e){return xt(this,void 0,void 0,(function(){var n;return Ct(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),Et.mkdirSync(this.dirPath(t),{recursive:!0}),Et.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return xt(this,void 0,void 0,(function(){return Ct(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return Et.existsSync(t)&&Et.statSync(t).isDirectory()},t.prototype.isFile=function(t){return Et.existsSync(t)&&Et.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}();const Pt=require("clean-css"),jt=require("html-minifier-terser");var kt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Rt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Lt=function(){function t(){}return t.prototype.css=function(t){return kt(this,void 0,void 0,(function(){return Rt(this,(function(e){return[2,new Pt({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(t).styles]}))}))},t.prototype.html=function(t){return kt(this,void 0,void 0,(function(){return Rt(this,(function(e){switch(e.label){case 0:return[4,(0,jt.minify)(t,{collapseBooleanAttributes:!0,collapseInlineTagWhitespace:!0,collapseWhitespace:!0,continueOnParseError:!1,decodeEntities:!1,html5:!0,minifyCSS:!0,minifyJS:!0,noNewlinesBeforeTagClose:!0,preserveLineBreaks:!1,preventAttributesEscaping:!1,processConditionalComments:!1,quoteCharacter:'"',removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeEmptyElements:!0,removeOptionalTags:!1,removeRedundantAttributes:!0,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeTagWhitespace:!1})];case 1:return[2,e.sent()]}}))}))},t}(),Mt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},It=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Ut=function(){function t(){this.minifier=new Lt}return t.prototype.render=function(t,e,n){return Mt(this,void 0,void 0,(function(){var r,o,i,a,s,u=this;return It(this,(function(c){switch(c.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,h.cloneDeep)(e),o=bt.isAbsolute(t)?"":__dirname+bt.sep,[4,(new At).read(o+t)];case 1:return i=c.sent(),a=[],(0,wt.parse)(i).forEach((function(t){t.length>=4&&"&"===t[0]&&t[1].startsWith("include:")&&a.push(t[1])})),a.length>0?(void 0===n?n=bt.dirname(o+t)+bt.sep:bt.isAbsolute(n)||(n=o+n),[4,_t(a,(function(t){return Mt(u,void 0,void 0,(function(){var e,o,i,a;return It(this,(function(s){switch(s.label){case 0:return 3!==(e=t.split(":")).length||void 0===r[t]?[3,2]:(o=e[2],n.includes("/html")&&Object.keys(r[t]).forEach((function(e){r[t][e]=Array.isArray(r[t][e])?r[t][e].map((function(t){return t.replace(/(?:\r\n|\r|\n)/g,"<br>")})):r[t][e].replace(/(?:\r\n|\r|\n)/g,"<br>")})),i=r,a=t,[4,this.render(bt.resolve(n,o),r[t])]);case 1:i[a]=s.sent(),s.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:c.sent(),c.label=3;case 3:if((s=(0,wt.render)(i,r)).includes("{{")||s.includes("}}"))throw new z("template: missing data to render template",{templatePath:t,data:e});return[2,t.includes("html")?this.minifier.html(s):s]}}))}))},t}();const Dt=require("node-mailjet");var Nt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},qt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Bt=function(){function t(t,e,n){this.templateEngine=new Ut,this.mailjet=new Dt.Client({apiKey:t,apiSecret:e}),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return Nt(this,void 0,void 0,(function(){var r=this;return qt(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return Nt(r,void 0,void 0,(function(){var r,o;return qt(this,(function(i){switch(i.label){case 0:return void 0===n.base.copyright&&(n.base.copyright={year:String((new Date).getUTCFullYear())}),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/text")];case 1:return r=i.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return o=i.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:r,html:o}],!1)];case 3:return[2,i.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return Nt(this,void 0,void 0,(function(){var r=this;return qt(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return Nt(r,void 0,void 0,(function(){var r,o,i,a;return qt(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=s.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return i=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=s.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:o,html:a}],!1)];case 5:return[2,s.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return Nt(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),qt(this,(function(a){switch(a.label){case 0:return[4,L.request((function(){return Nt(i,void 0,void 0,(function(){var i,a,s,u;return qt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return s=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:s,base:n.base,isCommercial:r})];case 4:return u=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:u}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendUsersNotifications=function(t,e,n,r){return Nt(this,void 0,void 0,(function(){var o=this;return qt(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return Nt(o,void 0,void 0,(function(){var o,i=this;return qt(this,(function(a){switch(a.label){case 0:return o=[],[4,_t(e,(function(t){return Nt(i,void 0,void 0,(function(){var e,r,i,a;return qt(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/text")];case 1:return e=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=s.sent(),[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/html")];case 3:return i=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=s.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n){return Nt(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),qt(this,(function(a){switch(a.label){case 0:return[4,L.request((function(){return Nt(i,void 0,void 0,(function(){var i,a,s,u;return qt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return s=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:s,base:n.base,isCommercial:r})];case 4:return u=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:u}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendDiscounts=function(t,e){return Nt(this,arguments,void 0,(function(t,e,n,r){var o=this;return void 0===n&&(n=!0),qt(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return Nt(o,void 0,void 0,(function(){var o,i=this;return qt(this,(function(a){switch(a.label){case 0:return o=[],[4,_t(e,(function(t){return Nt(i,void 0,void 0,(function(){var e,r,i,a;return qt(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/text")];case 1:return e=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=s.sent(),[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/html")];case 3:return i=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=s.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendNotification=function(t,e){return Nt(this,arguments,void 0,(function(t,e,n,r){var o,i,a=this;return void 0===n&&(n=!1),qt(this,(function(s){switch(s.label){case 0:if(0===e.length)throw new B("email: missing messages");s.label=1;case 1:return s.trys.push([1,6,,7]),this.mode!==x.TEST?[3,2]:(k.info("Simulation Mode: Email has been sent",{sender:t,recipients:e.map((function(t){return t.recipient}))}),[3,5]);case 2:return o=[],[4,_t(e,(function(e){return Nt(a,void 0,void 0,(function(){return qt(this,(function(i){return this.mode===x.DEVELOPMENT&&(e.recipient.contact="developer@onylab.com"),o.push({From:{Name:t.name,Email:t.contact},To:[{Name:e.recipient.name,Email:e.recipient.contact}],Subject:e.subject,TextPart:e.text,HTMLPart:e.html,Priority:n?0:2,customID:void 0===r?void 0:String(r)}),[2]}))}))}))];case 3:return s.sent(),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:o})];case 4:s.sent(),s.label=5;case 5:return[3,7];case 6:throw i=s.sent(),new E(i.message,Number(i.statusCode));case 7:return[2]}}))}))},t}(),Ft=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Ht=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Gt=function(){function t(e,n){this.filesystem=new At,void 0!==t.root&&t.root===e||(t.root=e,t.config=void 0);var r=void 0===n?C.getMode():n;void 0!==t.environment&&t.environment===r||(t.environment=void 0===n?C.getMode():n,t.config=void 0)}return t.prototype.full=function(){return Ft(this,void 0,void 0,(function(){return Ht(this,(function(e){switch(e.label){case 0:return[4,this.init()];case 1:return e.sent(),[2,t.config]}}))}))},t.prototype.init=function(){return Ft(this,void 0,void 0,(function(){var e,n,r,o;return Ht(this,(function(i){switch(i.label){case 0:return void 0!==t.config?[3,6]:void 0!==t.root?[3,1]:(t.config={},[3,6]);case 1:return e=t,[4,this.filesystem.readJson(t.root+"data/config.json")];case 2:if(e.config=i.sent(),![x.DEVELOPMENT,x.TEST].includes(t.environment))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),n=t,r=h.merge,o=[t.config],[4,this.filesystem.readJson(t.root+"data/config_"+String(t.environment)+".json")];case 4:return n.config=r.apply(void 0,o.concat([i.sent()])),[3,6];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))},t}();const zt=require("typeorm");var Wt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Jt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Zt=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return Wt(this,void 0,void 0,(function(){var n,r;return Jt(this,(function(o){switch(o.label){case 0:return void 0!==this.db?[3,2]:[4,this.init()];case 1:o.sent(),o.label=2;case 2:return void 0===(n=this.db[t])?[3,4]:(n.entities=e,n.logging=["error"],n.logger=!0,n.bigNumberStrings=!1,void 0===n.timezone&&(n.timezone="Z"),void 0===n.charset&&(n.charset="UTF8_GENERAL_CI"),r=this,[4,(0,zt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:k.error(new B("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return Wt(this,void 0,void 0,(function(){return Jt(this,(function(t){switch(t.label){case 0:return void 0===this.connection?[3,2]:[4,this.connection.synchronize()];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.close=function(){return Wt(this,void 0,void 0,(function(){return Jt(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return Wt(this,void 0,void 0,(function(){var t,e;return Jt(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new At,e=this,[4,t.readJson(this.root+"data/db.json")];case 2:e.db=n.sent(),n.label=3;case 3:return[2]}}))}))},t}();const Vt=require("prettyjson");var Xt=function(){function t(){}return t.prototype.error=function(t){k.error(t)},t.prototype.info=function(t){k.trace(t)},t.prototype.json=function(t){k.trace(Vt.render(t,{}))},t.prototype.success=function(t){k.trace(t)},t}(),Yt=function(){function t(){this.fileSystem=new At}return t.prototype.image=function(t,e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}(this,(function(i){switch(i.label){case 0:return void 0===n&&(n=ot.randomBytes(20).toString("hex")+bt.extname(t)),[4,this.fileSystem.write(e+bt.sep+n,"")];case 1:return i.sent(),r=bt.resolve(e+bt.sep+n),o=Et.createWriteStream(r),[4,b()({url:t,method:"GET",responseType:"stream"})];case 2:return i.sent().data.pipe(o),[2,new Promise((function(t,e){o.on("finish",(function(){return t(r)})),o.on("error",e)}))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{u(a.next(t))}catch(t){e(t)}}function s(t){try{u(a.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,s)}u((a=a.apply(r,o||[])).next())}));var r,o,i,a},t}();const $t=require("fast-diff");var Kt=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.hash=function(t,e){void 0===e&&(e=0);for(var n=3735928559^e,r=1103547991^e,o=0,i=void 0;o<t.length;o++)i=t.charCodeAt(o),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),((r^=Math.imul(n^n>>>13,3266489909))>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")},t.nullable=function(t){return j(t)||"string"==typeof t&&0===t.length?null:t},t.removeMultiSpaces=function(t){return"string"!=typeof t?t:t.replace(/\s{2,}/g," ")},t.removeText=function(e,n){if("string"!=typeof e||"string"!=typeof n||0===n.length)return e;try{e=(e=e.replace(new RegExp(t.escapeRegExp(n),"ig"),"")).replace(new RegExp(t.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(t){}return e},t.replace=function(e,n,r){if("string"!=typeof e)return e;if(n.length!==r.length)return e;var o=e;return n.forEach((function(e,n){o=o.replace(new RegExp(t.escapeRegExp(e),"ig"),r[n])})),o},t.slugify=function(t,e){return void 0===e&&(e=""),void 0===t?"":(0,h.toLower)((0,h.trim)((0,h.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return j(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),Qt=function(){function t(){}return t.trim=function(t){return"string"==typeof t?t.trim():t},t.capitalize=function(e){var n=t.lower(e);return"string"==typeof n?n.split(" ").map((function(t){return t.charAt(0).toUpperCase()+t.slice(1)})).join(" "):e},t.ucfirst=function(e){var n=t.lower(e);return"string"==typeof n?n.charAt(0).toUpperCase()+n.slice(1):e},t.lower=function(t){return"string"==typeof t?t.toLocaleLowerCase():t},t.upper=function(t){return"string"==typeof t?t.toLocaleUpperCase():t},t.phone=function(e,n,r){if(void 0===r&&(r="nat"),"string"==typeof e)switch(e=t.preformatPhone(e,n),r){case"nat":return t.phoneNat(e,n);case"int":return t.phoneInt(e,n)}return e},t.stripEmoji=function(t){var e=t;if("string"==typeof e)for(var r=n(16),o=void 0;null!==(o=r().exec(e));)try{e=(e=(e=e.replace(new RegExp(Kt.escapeRegExp(o[0]),"g"),"")).replace(new RegExp("\\s+","g")," ")).trim()}catch(t){}return e},t.stripExoticCharacters=function(t){return"string"==typeof t?t.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):t},t.preformatPhone=function(t,e){return t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e&&new RegExp("^[1-9]").test(t)&&9===t.length?"0"+t:t},t.phoneNat=function(t,e){if("fr"===e){if(t.startsWith("+330")?t=t.substring(3):t.startsWith("+33")?t="0"+t.substring(3):t.startsWith("0033")?t="0"+t.substring(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substring(2)),10===t.length){var n=0;t=t.split("").map((function(t){return t+(++n%2==0?" ":"")})).join("").trim()}return t}return t},t.phoneInt=function(t,e){return t.startsWith("+")?t:"fr"===e?(t.startsWith("0")&&(t=t.substring(1)),"+33"+t):t},t}(),te=function(){function t(){}return t.autoCorrectCity=function(e){if(j(e)||"string"!=typeof e||0===e.length)return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));var n=Object.values(t.ZIPCODE_CITY).flat(),r=n.find((function(t){return t.toLowerCase()===e.toLowerCase()}));if(void 0!==r)return r;var o=n.find((function(n){var r=t.countDiff(e,n);return r.add<=2&&r.remove<=2}));if(void 0!==o)return o;var i=n.find((function(t){return t.replace(/-/g," ").toLowerCase()===e.toLowerCase()}));if(void 0!==i)return i;var a=n.find((function(n){var r=t.countDiff(e,n.replace(/-/g," "));return r.add<=2&&r.remove<=2}));if(void 0!==a)return a;var s=n.find((function(t){return t.toLowerCase().startsWith(e.toLowerCase())}));if(void 0!==s)return s;var u=n.find((function(t){return e.toLowerCase().includes(t.toLowerCase())}));return void 0!==u?u:e},t.autoCorrectStreet=function(e){if(j(e)||"string"!=typeof e||0===e.length)return e;t.STREET_TYPE.forEach((function(t){t.short.length<t.long.length&&(e=(e=e.replace(new RegExp("(\\s"+String(t.short)+"\\.?\\s)","ig")," "+String(t.long)+" ")).replace(new RegExp("(\\s"+String(t.short)+"\\.\\s)","ig")," "+String(t.long)+" "))}));var n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==n&&2===n.length&&(e=e.substring(n[1].length)),t.STREET_TYPE.forEach((function(t){e=(e=e.replace(new RegExp("([0-9]+)("+String(t.long)+"\\s)","ig"),"$1 $2")).replace(new RegExp("([0-9]+)("+String(t.short)+"\\.?\\s)","ig"),"$1 "+String(t.long)+" ")})),e},t.getZipCodeFromCity=function(e){if(!j(e))return Object.keys(t.ZIPCODE_CITY).reduce((function(n,r){return void 0!==t.ZIPCODE_CITY[r].find((function(t){return t.toLowerCase()===e.toLowerCase()}))?r:n}),void 0)},t.getCityFromZipCode=function(e,n){if(void 0!==e&&void 0!==n){var r,o=t.ZIPCODE_CITY[e];if(void 0!==o)return 1===o.length?o[0]:(n.split(",").forEach((function(t){r=o.find((function(e){return t.trim().toLowerCase()===e.trim().toLowerCase()}))})),void 0!==r?r:o[0])}},t.isZipCode=function(e){return"string"==typeof e&&(!!Object.keys(t.ZIPCODE_CITY).includes(e)||dt.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!j(e)){var o=e.split(",");if(o.length>=3&&n){void 0===t.COUNTRIES.find((function(t){return e.toLowerCase().includes(" "+t.toLowerCase())}))&&o.push("France");var i=o.length-1;if(r.country=o[i].trim(),o.splice(i--,1),void 0!==o[i]&&o[i].trim().includes(" ")){var a=o[i].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),o.splice(i--,1)}else isNaN(Number(o[i].trim()))?isNaN(Number(o[i-1].trim()))?(r.city=o[i].trim(),o.splice(i--,1)):(r.city=o[i].trim(),o.splice(i--,1),r.zip=o[i].trim(),o.splice(i--,1)):(r.zip=o[i].trim(),o.splice(i--,1),i>=2&&(r.city=o[i].trim(),o.splice(i--,1)));r.street=o.map((function(t){return t.trim()})).join(" ").trim()}else{var s=e.toLowerCase();Object.keys(t.ZIPCODE_CITY).forEach((function(t){if(s.includes(t)){r.zip=t;try{s=s.replace(new RegExp(Kt.escapeRegExp(t),"ig"),"")}catch(t){}}})),Object.values(t.ZIPCODE_CITY).flat().forEach((function(e){var n;if(s.includes(e.toLowerCase())&&(void 0===r.zip||(null===(n=t.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find((function(t){return t.toLowerCase()===e.toLowerCase()}))))){r.city=e;try{s=s.replace(new RegExp(Kt.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(s.includes(" "+t.toLowerCase())&&!s.includes("de "+t.toLowerCase())&&!s.includes("de la "+t.toLowerCase())){r.country=t;try{s=s.replace(new RegExp(Kt.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=(0,h.trim)(s.split(",").map((function(t){return t.trim()})).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=Qt.lower(Qt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=Qt.upper(Qt.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(Qt.capitalize(Qt.trim(String(r.city))))),void 0!==r.country&&(r.country=Qt.capitalize(Qt.trim(String(r.country)))),t.complete(r)},t.complete=function(e){if(void 0===e.city||0===e.city.length){var n=t.getCityFromZipCode(e.zip,e.street);void 0!==n&&(e.city=n)}return"string"==typeof e.street&&t.REGIONS.forEach((function(t){e.street=Kt.removeText(e.street,t).trim()})),"fr"===Qt.lower(e.country)&&(e.country="France"),e},t.removeDuplicates=function(t){if("string"!=typeof t)return t;var e=[];return t.split(",").forEach((function(t){void 0===e.find((function(e){return e.trim().toLowerCase().includes(t.trim().toLowerCase())}))&&e.push(t)})),e.join(",")},t.countDiff=function(t,e){var n={add:0,remove:0};return $t(t.toLowerCase(),e.toLowerCase()).forEach((function(t){switch(t[0]){case-1:n.remove+=t[1].length;break;case 1:n.add+=t[1].length}})),n},t.ZIPCODE_CITY={78500:["Sartrouville"],78600:["Maisons-Laffitte","Le Mesnil-le-Roi"],78800:["Houilles"],95240:["Cormeilles-en-Parisis"],95530:["La Frette-sur-Seine"],78100:["Saint-Germain-en-Laye"],95100:["Argenteuil"],78630:["Orgeval","Morainvilliers"],78670:["Villennes-sur-Seine","Medan"],78240:["Chambourcy","Aigremont"],78300:["Poissy"],78510:["Triel-sur-Seine"],78570:["Andrésy","Chanteloup-les-Vignes"],78700:["Conflans-Sainte-Honorine"],78480:["Verneuil-sur-Seine"],78750:["Mareil-Marly"],78620:["L'Étang-la-Ville"],78160:["Marly-le-Roi"],78580:["Les Alluets-le-Roi"],78955:["Carrières-sous-Poissy"],78260:["Achères"],78540:["Vernouillet"],78920:["Ecquevilly"],95150:["Taverny"],95250:["Beauchamp"],95480:["Pierrelaye"],95320:["Saint-Leu-la-Forêt"],95550:["Bessancourt"],95370:["Montigny-lès-Cormeilles"],95220:["Herblay"],95740:["Frépillon"],95540:["Méry-sur-Oise"],95870:["Bezons"],78420:["Carrières-sur-Seine"],78400:["Chatou"],78110:["Le Vésinet"],78360:["Montesson"],78290:["Croissy-sur-Seine","Croissy"],78230:["Le Pecq"],95600:["Eaubonne"]},t.REGIONS=["île-de-france"],t.COUNTRIES=["France","FR"],t.STREET_TYPE=[{short:"av",long:"avenue"},{short:"rue",long:"rue"},{short:"bd",long:"boulevard"},{short:"chau",long:"chaussée"},{short:"trav",long:"traverse"},{short:"pl",long:"place"},{short:"pass",long:"passage"},{short:"sent",long:"sentier"},{short:"imp",long:"impasse"},{short:"all",long:"allée"},{short:"chem",long:"chemin"},{short:"ham",long:"hameau"},{short:"dom",long:"domaine"}],t}(),ee=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=pt.DateTime.fromISO(t.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return t;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===e?pt.DateTime.fromISO(t).toFormat("yyyy-LL"):pt.DateTime.fromISO(t).toISODate()},t.displayWeekDay=function(e){var n="";return void 0!==t.WEEK_DAYS[e]&&(n=t.WEEK_DAYS[e]),n},t.generatePeriod=function(e,n,r,o,i,a){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES),void 0===a&&(a="daily");for(var s={daily:{day:1},weekly:{week:1},monthly:{month:1}}[a],u=pt.DateTime.fromISO(e,{setZone:!0}).toISODate(),c=pt.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};u<=c&&l<i;){var p=t.getCycleDateFromFullDate(u,a);f[p]=(0,h.cloneDeep)(r),o&&(f[p].date=p),u=pt.DateTime.fromISO(u,{setZone:!0}).plus(s).toISODate(),l++}return f},t.getOpenPeriods=function(t,e){var n=[];return t.forEach((function(t){for(var r=[t],o=function(){var t=r[0];if(void 0===e.find((function(e){return e.from<=t.from&&t.to<=e.to}))){var o=e.find((function(e){return e.from<=t.from&&t.from<e.to&&e.to<t.to}));if(void 0!==o)r.push({from:o.to,to:t.to});else{var i=e.find((function(e){return t.from<e.from&&t.to>e.from&&t.to<=e.to}));if(void 0!==i)r.push({from:t.from,to:i.from});else{var a=e.find((function(e){return t.from<e.from&&e.to<t.to}));void 0!==a?(r.push({from:t.from,to:a.from}),r.push({from:a.to,to:t.to})):n.push(t)}}}r.shift()};r.length>0;)o()})),n},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=pt.DateTime.fromISO(t,{setZone:!0}).toISO(),o=pt.DateTime.fromISO(e,{setZone:!0}).plus({seconds:n}).toISO();return r>o?o:r}},t.localeToISO=function(t){var e,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),o=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(t))e=(i=t.split("/"))[2]+"-"+i[1]+"-"+i[0];else if(r.test(t)){var i;e=(i=t.split("-"))[2]+"-"+i[1]+"-"+i[0]}else o.test(t)&&(e=t);return e},t.slotToTime=function(t){var e,n=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),r=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");return t=t.trim(),n.test(t)?e=t.trim()+":00":r.test(t)&&(e=t.split("-")[0].trim()+":00"),e},t.delay=function(t,e,n){return j(t)||j(e)?0:Math.round(Math.abs(pt.DateTime.fromISO(t,{setZone:!0}).toUTC().diff(pt.DateTime.fromISO(e,{setZone:!0}).toUTC(),[n])[n]))},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=pt.DateTime.fromISO(t,{setZone:!0});return pt.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.min=function(t){return t.reduce((function(t,e){return"string"!=typeof t||t>e?e:t}),void 0)},t.max=function(t){return t.reduce((function(t,e){return void 0===t||t<e?e:t}),void 0)},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),ne=function(){function t(){}return t.phone=function(t,e){if("string"==typeof t&&(t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(t);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},t}(),re=function(){function t(){}return t.avg=function(e){if(0===e.length)return 0;var n=e.reduce((function(t,e){return t+e}),0);return t.round(n/e.length,2)},t.applyVariation=function(t,e){return t*(t>=0?1+e/100:1-e/100)},t.median=function(e){if(0===e.length)return 0;if(1===e.length)return e[0];var n=e.sort((function(t,e){return t-e}));return n.length%2==0?t.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.length/2)]},t.percentage=function(t,e){if("number"==typeof t&&"number"==typeof e)return 0===e?0:t/e*100},t.round=function(t,e){return"number"!=typeof t?t:0===e?Math.round(t):Math.round(t*Math.pow(10,e))/Math.pow(10,e)},t.variation=function(t,e){var n=0;return 0!==e?n=0!==t?(e-t)/Math.abs(t)*100:100*(e>0?1:-1):0!==t&&(n=-100*(t>0?1:-1)),Math.floor(n)},t}(),oe=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,h.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,h.isArray)(e)&&e.length>0||(0,h.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,h.isArray)(e)&&!(0,h.isObject)(e))&&r.push(e)})),r}if((0,h.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,h.isArray)(i)||(0,h.isObject)(i)?(i=t.compact(i,n),((0,h.isArray)(i)&&i.length>0||(0,h.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,h.isArray)(i)&&!(0,h.isObject)(i))&&(o[r]=i)):null!=i&&("string"!=typeof i||!1===n.removeEmptyString||i.length>0)&&(o[r]=i)})),o}return"string"!=typeof e||!1===n.removeEmptyString||e.length>0?e:void 0},t}(),ie=function(){function t(){}return t.applyTaxes=function(t,e,n){void 0===n&&(n=2);var r=Number(t);return e.forEach((function(e){r+=Number(t)*e})),String(re.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),re.round(n,2)},t.displayWithCurrency=function(e,n){if(null==e)return e;var r=t.currencies[n],o=e+" "+n;if(void 0!==r)switch(r.position){case"before":o=r.symbol+e;break;case"after":o=e+r.symbol}return o},t.format=function(t,e,n){if(void 0===n&&(n=2),null==t)return t;var r=Number(t.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:n,maximumFractionDigits:n});switch(e){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}},t.round=function(t,e){void 0===e&&(e=.1);var n=100*Number(t),r=100*e,o=n%r;return String(re.round(n-o+(o<Math.ceil(r/2)?0:r),2)/100)},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}();return r})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SmilePlayerCommon=t():e.SmilePlayerCommon=t()}(global,()=>(()=>{"use strict";var e={16:e=>{e.exports=require("emoji-regex")},69:e=>{e.exports=JSON.parse('[{"id":"3r4s3-1","name":"Paris","account":{"id":"3r4s3","name":"Bella Pizza","currency":"EUR"},"preparation_time":15,"order_acceptance":{"mode":"normal"}}]')},133:e=>{e.exports=JSON.parse('{"status":"new","private_ref":"fr:1679f128-4ff6-4a60-9fc2-7fe38af4f84d","service_type":"delivery","service_type_ref":null,"expected_time":"2021-11-07T17:17:22Z","customer_notes":"PAS DE COUVERTS","collection_code":"5645","items":[{"product_name":"LIP15","sku_ref":"LIP15","price":"3.50 EUR","quantity":1,"options":[]},{"product_name":"5VANI","sku_ref":"5VANI","price":"6.90 EUR","quantity":1,"options":[]},{"product_name":"TSQ2","sku_ref":"TSQ2","price":"13.50 EUR","quantity":1,"options":[{"option_list_name":"Options","name":"SUPP RACLETTE","ref":"SUPP RACLETTE","price":"1.00 EUR"}]},{"product_name":"SCES","sku_ref":"SCES","price":"10.50 EUR","quantity":1,"options":[]}],"deals":{},"discounts":[],"charges":[{"type":"delivery","name":"Delivery charge","ref":null,"price":"0.99 EUR"}],"payments":[{"type":"online","name":"Paid online","ref":null,"amount":"36.39 EUR"}],"customer":{"address_1":"6a Rue du Tire Pesseau, 21000 Dijon, France","city":"Dijon","postal_code":"21000","phone":"+33175858334","delivery_notes":"Phone access code: 151081499","first_name":"Benoit","last_name":"B.","email":"orders@deliveroo.com","latitude":"47.3166297697847","longitude":"5.00251594930887"}}')},270:e=>{e.exports=JSON.parse('{"id":"87yu4","location_id":"3r4s3-1","name":"Web","created_at":"2020-06-25T11:43:51+02:00","data":{"variants":[],"categories":[],"products":[],"options_lists":[],"deals":[],"discounts":[],"charges":[]}}')},329:e=>{e.exports=JSON.parse('[{"id":"apm3s","name":"Online customers","created_at":"2020-06-25T11:43:51+02:00"},{"id":"s7ma5","name":"POS customers","created_at":"2020-05-19T13:23:10+02:00"}]')},616:e=>{e.exports=JSON.parse('[{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}},{"id":"asdf2","customer_list_id":"ag8u4","anonymised":false,"email":"charles.moore@dummy-mail.org","first_name":"Charles","last_name":"Moore","phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}]')},660:e=>{e.exports=JSON.parse('{"id":"v6ap7","first_name":"Tom","last_name":"Jones","email":"tom.jones@dummy-mail.org","timezone":{"name":"Europe/Paris"},"locales":["fr-FR","en-US"]}')},835:e=>{e.exports=JSON.parse('[{"id":"87yu4","name":"Web","created_at":"2020-06-25T11:43:51+02:00"},{"id":"sdm3b","name":"Common menu","created_at":"2020-05-19T13:23:10+02:00"}]')},851:e=>{e.exports=JSON.parse('{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}')}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{Api:()=>i,Constant:()=>o,Exception:()=>a,Http:()=>c,Service:()=>s,Template:()=>u,Tool:()=>l,Util:()=>f});var i={};r.r(i),r.d(i,{HubriseApi:()=>K,HubriseApiMockup:()=>v,HubriseCurrencyCode:()=>I,HubriseLocale:()=>B,HubriseOrderStatus:()=>G,HubriseTimezoneId:()=>U});var o={};r.r(o),r.d(o,{Path:()=>F});var a={};r.r(a),r.d(a,{BadParameterException:()=>V,BadRequestException:()=>Z,ConflictException:()=>z,DuplicateException:()=>X,ExternalApiException:()=>S,InternalException:()=>Q,MainException:()=>E,NotImplementedException:()=>te,ObjectNotFoundException:()=>ne,PageNotFoundException:()=>oe,UnauthorizedException:()=>D});var c={};r.r(c),r.d(c,{AuthenticationMiddleware:()=>ce,AuthorizationMiddleware:()=>se,HandlerController:()=>ae,Server:()=>ge});var s={};r.r(s),r.d(s,{EmailSenderService:()=>Ye,SmsSenderService:()=>Me});var u={};r.r(u),r.d(u,{TemplateEngine:()=>We});var l={};r.r(l),r.d(l,{Configuration:()=>Qe,Database:()=>nt,Displayer:()=>ot,Downloader:()=>at,Env:()=>M,Environment:()=>C,FileSystem:()=>Be,Logger:()=>k,Retry:()=>N});var f={};r.r(f),r.d(f,{AddressUtil:()=>ft,DateUtil:()=>pt,ExtractorUtil:()=>dt,FormatterUtil:()=>lt,GeneratorUtil:()=>Ne,MathUtil:()=>mt,ObjectUtil:()=>ht,PriceUtil:()=>_t,StringUtil:()=>ut,ValidatorUtil:()=>Ee,asyncForEach:()=>Re,isNullOrUndefined:()=>R,wait:()=>ke});const p=require("nock");var d=r.n(p),m=function(){function e(){}return e.isDone=function(){return(0,p.isActive)()&&(0,p.isDone)()},e.pending=function(){return"pending: "+JSON.stringify((0,p.pendingMocks)())},e.reset=function(){(0,p.cleanAll)()},e}();const h=require("lodash");var _,A=(_=function(e,t){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},_(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}_(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return A(t,e),t.getUser=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/user")?"/user":e}).get("/user").times(e).reply(200,(0,h.cloneDeep)(r(660)))},t.getLocations=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/locations")?"/locations":e}).get("/locations").times(e).reply(200,(0,h.cloneDeep)(r(69)))},t.createCustomer=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/customer")?"/customer":e}).post("/customer").times(e).reply(200,(0,h.cloneDeep)(r(851)))},t.getCustomer=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/customer_lists")&&e.includes("/customers")?"/customer":e}).get("/customer").times(e).reply(200,(0,h.cloneDeep)(r(851)))},t.getCustomers=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/customers")?"/customers":e}).get("/customers").times(e).reply(200,(0,h.cloneDeep)(r(616)))},t.getCustomerLists=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/customer_lists")?"/customerLists":e}).get("/customerLists").times(e).reply(200,(0,h.cloneDeep)(r(329)))},t.createOrder=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/order")?"/order":e}).post("/order").times(e).reply(200,(0,h.cloneDeep)(r(133)))},t.getOrder=function(e,n){void 0===e&&(e=1),void 0===n&&(n=!1);var i=(0,h.cloneDeep)(r(133));n&&(i.id=String(Date.now())),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/orders/")?"/order":e}).get("/order").times(e).reply(200,i)},t.setOrderStatus=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/orders/")?"/status":e}).patch("/status").times(e).reply(204)},t.getCatalog=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/catalog")?"/catalog":e}).get("/catalog").times(e).reply(200,(0,h.cloneDeep)(r(270)))},t.getCatalogs=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/catalogs")?"/catalogs":e}).get("/catalogs").times(e).reply(200,(0,h.cloneDeep)(r(835)))},t.BASE_URL="http://api.hubrise.com",t}(m);const y=require("axios");var g=r.n(y),b=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),E=function(e){function t(r,n,i){var o=e.call(this,r)||this;return o.code=n,o.data=i,o.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,t):o.stack=new Error(r).stack,o}return b(t,e),t}(Error),w=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),S=function(e){function t(t,r){var n=e.call(this,t,502,r)||this;return n.name="ExternalApiException",n}return w(t,e),t}(E);const T=require("@sentry/node"),P=require("@sentry/profiling-node");var M;!function(e){e.PRODUCTION="prod",e.DEVELOPMENT="dev",e.TEST="test"}(M||(M={}));var C=function(){function e(){}return e.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return M.DEVELOPMENT;case"prod":case"production":return M.PRODUCTION;case"test":return M.TEST}return void 0===process.env.APP_ID?M.DEVELOPMENT:M.PRODUCTION},e}(),O=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),D=function(e){function t(r,n){var i=e.call(this,r,t.ERROR_CODE,n)||this;return i.name="UnauthorizedException",i}return O(t,e),t.ERROR_CODE=401,t}(E),R=function(e){return null==e},k=function(){function e(){}return e.init=function(e,t){C.getMode()===M.PRODUCTION&&(T.init({dsn:e,integrations:[T.captureConsoleIntegration({levels:["error","warn","log"]}),(0,P.nodeProfilingIntegration)()],environment:C.getMode(),maxBreadcrumbs:50,tracesSampleRate:0,profilesSampleRate:0}),T.setupExpressErrorHandler(t))},e.trace=function(e,t){[M.DEVELOPMENT,M.TEST].includes(C.getMode())?void 0===t?console.info(e):console.info(e,t):T.addBreadcrumb({category:"info",message:e,data:t,level:"info"})},e.debug=function(e,t){[M.DEVELOPMENT,M.TEST].includes(C.getMode())?void 0===t?console.log(e):console.log(e,t):T.addBreadcrumb({category:"debug",message:e,data:t,level:"debug"})},e.info=function(e,t){[M.DEVELOPMENT,M.TEST].includes(C.getMode())?void 0===t?console.info(e):console.info(e,t):T.withScope(function(r){void 0!==t&&r.setExtra("extra",JSON.stringify(t)),T.captureMessage(e)})},e.warning=function(e,t){R(e.response)||("object"!=typeof t&&(t={}),t.requestErrorData=e.response.data),[M.DEVELOPMENT,M.TEST].includes(C.getMode())?void 0===t?console.warn(e):console.warn(e,t):T.withScope(function(r){void 0!==t&&r.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&r.setExtra("data",JSON.stringify(e.data)),T.captureException(e)})},e.error=function(e,t){[D.ERROR_CODE].includes(e.code)||(R(e.response)||("object"!=typeof t&&(t={}),t.requestErrorData=e.response.data),[M.DEVELOPMENT,M.TEST].includes(C.getMode())?void 0===t?console.error(e):console.error(e,t):T.withScope(function(r){void 0!==t&&r.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&r.setExtra("data",JSON.stringify(e.data)),T.captureException(e)}))},e}();const x=require("retry");var N=function(){function e(){}return e.request=function(e){return t=this,r=arguments,i=function(e,t,r){var n;return void 0===t&&(t=2),function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}(this,function(i){return n=x.operation({retries:t,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise(function(t,i){n.attempt(function(){e().then(t).catch(function(e){n.retry(e)?"function"==typeof r&&r(e):i(e)})})})]})},new((n=void 0)||(n=Promise))(function(e,o){function a(e){try{s(i.next(e))}catch(e){o(e)}}function c(e){try{s(i.throw(e))}catch(e){o(e)}}function s(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(e){e(r)})).then(a,c)}s((i=i.apply(t,r||[])).next())});var t,r,n,i},e}();const L=require("querystring");var I,B,U,G,j=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})},H=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},K=function(){function e(e){this.token=e}return e.prototype.authorize=function(t,r){return j(this,void 0,void 0,function(){return H(this,function(n){return[2,e.BASE_AUTH_URL+"authorize?redirect_uri="+String(r)+"&client_id="+t+"&scope=account[orders.write,all_customer_lists.write,all_catalogs.write,inventory.write],profile_with_email"]})})},e.prototype.getToken=function(t,r,n){return j(this,void 0,void 0,function(){var i,o=this;return H(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return j(o,void 0,void 0,function(){var o;return H(this,function(a){switch(a.label){case 0:return[4,g().post(e.BASE_AUTH_URL+"token",L.stringify({code:n,client_id:t,client_secret:r}),{headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:e.TIMEOUT})];case 1:if(void 0===(o=a.sent())||void 0===o.data)throw new S("failed to get hubrise token");return i=o.data,[2]}})})},1,k.error.bind(k))];case 1:return a.sent(),[2,i]}})})},e.prototype.getUser=function(){return j(this,void 0,void 0,function(){var t,r=this;return H(this,function(n){switch(n.label){case 0:return[4,N.request(function(){return j(r,void 0,void 0,function(){var r;return H(this,function(n){switch(n.label){case 0:return[4,g().get(e.BASE_URL+"user",{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=n.sent())||void 0===r.data)throw new S("failed to retrieve hubrise user");return t=r.data,[2]}})})},1,k.error.bind(k))];case 1:return n.sent(),[2,t]}})})},e.prototype.getLocations=function(){return j(this,void 0,void 0,function(){var t,r=this;return H(this,function(n){switch(n.label){case 0:return[4,N.request(function(){return j(r,void 0,void 0,function(){var r;return H(this,function(n){switch(n.label){case 0:return[4,g().get(e.BASE_URL+"locations",{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=n.sent())||void 0===r.data)throw new S("failed to retrieve hubrise locations");return t=r.data,[2]}})})},1,k.error.bind(k))];case 1:return n.sent(),[2,t]}})})},e.prototype.createCustomer=function(t,r){return j(this,void 0,void 0,function(){var n=this;return H(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return j(n,void 0,void 0,function(){var n;return H(this,function(i){switch(i.label){case 0:return[4,g().post(e.BASE_URL+"customer_lists/"+String(t)+"/customers",r,{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(n=i.sent())||void 0===n.data)throw new S("failed to create hubrise customer");return[2]}})})},1,k.error.bind(k))];case 1:return i.sent(),[2]}})})},e.prototype.getCustomer=function(t,r){return j(this,void 0,void 0,function(){var n,i=this;return H(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return j(i,void 0,void 0,function(){var i;return H(this,function(o){switch(o.label){case 0:return[4,g().get(e.BASE_URL+"customer_lists/"+String(t)+"/customers/"+String(r),{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(i=o.sent())||void 0===i.data)throw new S("failed to retrieve hubrise customer");return n=i.data,[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2,n]}})})},e.prototype.getCustomers=function(t,r,n,i){return j(this,void 0,void 0,function(){var o,a,c=this;return H(this,function(s){switch(s.label){case 0:return(o=new URLSearchParams).append("private_ref",r),o.append("email",n),o.append("phone",i),[4,N.request(function(){return j(c,void 0,void 0,function(){var r;return H(this,function(n){switch(n.label){case 0:return[4,g().get(e.BASE_URL+"customer_lists/"+String(t)+"/customers?"+o.toString(),{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=n.sent())||void 0===r.data)throw new S("failed to retrieve hubrise customers");return a=r.data,[2]}})})},1,k.error.bind(k))];case 1:return s.sent(),[2,a]}})})},e.prototype.getCustomerLists=function(t){return j(this,void 0,void 0,function(){var r,n=this;return H(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return j(n,void 0,void 0,function(){var n;return H(this,function(i){switch(i.label){case 0:return[4,g().get(e.BASE_URL+"locations/"+String(t)+"/customer_lists",{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(n=i.sent())||void 0===n.data)throw new S("failed to retrieve hubrise customer lists");return r=n.data,[2]}})})},1,k.error.bind(k))];case 1:return i.sent(),[2,r]}})})},e.prototype.createOrder=function(t,r){return j(this,void 0,void 0,function(){var n=this;return H(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return j(n,void 0,void 0,function(){var n;return H(this,function(i){switch(i.label){case 0:return[4,g().post(e.BASE_URL+"locations/"+String(t)+"/orders",r,{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(n=i.sent())||void 0===n.data)throw new S("failed to create hubrise order");return[2]}})})},1,k.error.bind(k))];case 1:return i.sent(),[2]}})})},e.prototype.getOrder=function(t,r){return j(this,void 0,void 0,function(){var n,i=this;return H(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return j(i,void 0,void 0,function(){var i;return H(this,function(o){switch(o.label){case 0:return[4,g().get(e.BASE_URL+"locations/"+String(t)+"/orders/"+String(r),{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(i=o.sent())||void 0===i.data)throw new S("failed to retrieve hubrise order");return n=i.data,[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2,n]}})})},e.prototype.setOrderStatus=function(t,r,n){return j(this,void 0,void 0,function(){var i=this;return H(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return j(i,void 0,void 0,function(){var i;return H(this,function(o){switch(o.label){case 0:return[4,g().patch(e.BASE_URL+"locations/"+String(t)+"/orders/"+String(r),{status:n},{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(i=o.sent())||void 0===i.data)throw new S("failed to update hubrise order status");return[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2]}})})},e.prototype.getCatalog=function(t){return j(this,void 0,void 0,function(){var r,n=this;return H(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return j(n,void 0,void 0,function(){var n;return H(this,function(i){switch(i.label){case 0:return[4,g().get(e.BASE_URL+"catalogs/"+String(t),{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(n=i.sent())||void 0===n.data)throw new S("failed to retrieve hubrise catalogs");return r=n.data,[2]}})})},1,k.error.bind(k))];case 1:return i.sent(),[2,r]}})})},e.prototype.getCatalogs=function(t){return j(this,void 0,void 0,function(){var r,n=this;return H(this,function(i){switch(i.label){case 0:return r=[],[4,N.request(function(){return j(n,void 0,void 0,function(){var n;return H(this,function(i){switch(i.label){case 0:return[4,g().get(e.BASE_URL+"locations/"+String(t)+"/catalogs",{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(n=i.sent())||void 0===n.data)throw new S("failed to retrieve hubrise catalogs");return r=n.data,[2]}})})},1,k.error.bind(k))];case 1:return i.sent(),[2,r]}})})},e.BASE_URL="http://api.hubrise.com/v1/",e.BASE_AUTH_URL="https://manager.hubrise.com/oauth2/v1/",e.TIMEOUT=15e3,e}();!function(e){e.AED="AED",e.AFN="AFN",e.ALL="ALL",e.AMD="AMD",e.ANG="ANG",e.AOA="AOA",e.ARS="ARS",e.AUD="AUD",e.AWG="AWG",e.AZN="AZN",e.BAM="BAM",e.BBD="BBD",e.BDT="BDT",e.BGN="BGN",e.BHD="BHD",e.BIF="BIF",e.BMD="BMD",e.BND="BND",e.BOB="BOB",e.BOV="BOV",e.BRL="BRL",e.BSD="BSD",e.BTN="BTN",e.BWP="BWP",e.BYN="BYN",e.BZD="BZD",e.CAD="CAD",e.CDF="CDF",e.CHE="CHE",e.CHF="CHF",e.CHW="CHW",e.CLF="CLF",e.CLP="CLP",e.CNY="CNY",e.COP="COP",e.COU="COU",e.CRC="CRC",e.CUC="CUC",e.CUP="CUP",e.CVE="CVE",e.CZK="CZK",e.DJF="DJF",e.DKK="DKK",e.DOP="DOP",e.DZD="DZD",e.EGP="EGP",e.ERN="ERN",e.ETB="ETB",e.EUR="EUR",e.FJD="FJD",e.FKP="FKP",e.GBP="GBP",e.GEL="GEL",e.GHS="GHS",e.GIP="GIP",e.GMD="GMD",e.GNF="GNF",e.GTQ="GTQ",e.GYD="GYD",e.HKD="HKD",e.HNL="HNL",e.HRK="HRK",e.HTG="HTG",e.HUF="HUF",e.IDR="IDR",e.ILS="ILS",e.INR="INR",e.IQD="IQD",e.IRR="IRR",e.ISK="ISK",e.JMD="JMD",e.JOD="JOD",e.JPY="JPY",e.KES="KES",e.KGS="KGS",e.KHR="KHR",e.KMF="KMF",e.KPW="KPW",e.KRW="KRW",e.KWD="KWD",e.KYD="KYD",e.KZT="KZT",e.LAK="LAK",e.LBP="LBP",e.LKR="LKR",e.LRD="LRD",e.LSL="LSL",e.LYD="LYD",e.MAD="MAD",e.MDL="MDL",e.MGA="MGA",e.MKD="MKD",e.MMK="MMK",e.MNT="MNT",e.MOP="MOP",e.MRU="MRU",e.MUR="MUR",e.MVR="MVR",e.MWK="MWK",e.MXN="MXN",e.MXV="MXV",e.MYR="MYR",e.MZN="MZN",e.NAD="NAD",e.NGN="NGN",e.NIO="NIO",e.NOK="NOK",e.NPR="NPR",e.NZD="NZD",e.OMR="OMR",e.PAB="PAB",e.PEN="PEN",e.PGK="PGK",e.PHP="PHP",e.PKR="PKR",e.PLN="PLN",e.PYG="PYG",e.QAR="QAR",e.RON="RON",e.RSD="RSD",e.RUB="RUB",e.RWF="RWF",e.SAR="SAR",e.SBD="SBD",e.SCR="SCR",e.SDG="SDG",e.SEK="SEK",e.SGD="SGD",e.SHP="SHP",e.SLE="SLE",e.SOS="SOS",e.SRD="SRD",e.SSP="SSP",e.STN="STN",e.SVC="SVC",e.SYP="SYP",e.SZL="SZL",e.THB="THB",e.TJS="TJS",e.TMT="TMT",e.TND="TND",e.TOP="TOP",e.TRY="TRY",e.TTD="TTD",e.TWD="TWD",e.TZS="TZS",e.UAH="UAH",e.UGX="UGX",e.USD="USD",e.USN="USN",e.UYI="UYI",e.UYU="UYU",e.UZS="UZS",e.VED="VED",e.VEF="VEF",e.VND="VND",e.VUV="VUV",e.WST="WST",e.XAF="XAF",e.XCD="XCD",e.XDR="XDR",e.XOF="XOF",e.XPF="XPF",e.XSU="XSU",e.XUA="XUA",e.YER="YER",e.ZAR="ZAR",e.ZMW="ZMW",e.ZWL="ZWL"}(I||(I={})),function(e){e.EN_US="en-US",e.EN_GB="en-GB",e.EN_CA="en-CA",e.EN_AU="en-AU",e.EN_NZ="en-NZ",e.EN_ZA="en-ZA",e.FR_FR="fr-FR",e.FR_CA="fr-CA",e.FR_BE="fr-BE",e.FR_CH="fr-CH",e.ES_ES="es-ES",e.ES_MX="es-MX",e.ES_AR="es-AR",e.ES_CO="es-CO",e.ES_CL="es-CL",e.DE_DE="de-DE",e.DE_AT="de-AT",e.DE_CH="de-CH",e.IT_IT="it-IT",e.IT_CH="it-CH",e.PT_PT="pt-PT",e.PT_BR="pt-BR",e.NL_NL="nl-NL",e.NL_BE="nl-BE",e.SV_SE="sv-SE",e.NO_NO="no-NO",e.DA_DK="da-DK",e.FI_FI="fi-FI",e.IS_IS="is-IS",e.RU_RU="ru-RU",e.PL_PL="pl-PL",e.CS_CZ="cs-CZ",e.SK_SK="sk-SK",e.HR_HR="hr-HR",e.SR_RS="sr-RS",e.BG_BG="bg-BG",e.UK_UA="uk-UA",e.JA_JP="ja-JP",e.KO_KR="ko-KR",e.ZH_CN="zh-CN",e.ZH_TW="zh-TW",e.ZH_HK="zh-HK",e.TH_TH="th-TH",e.VI_VN="vi-VN",e.ID_ID="id-ID",e.MS_MY="ms-MY",e.AR_SA="ar-SA",e.AR_EG="ar-EG",e.AR_AE="ar-AE",e.HE_IL="he-IL",e.FA_IR="fa-IR",e.TR_TR="tr-TR",e.HI_IN="hi-IN",e.BN_BD="bn-BD",e.TA_IN="ta-IN",e.TE_IN="te-IN",e.UR_PK="ur-PK",e.EL_GR="el-GR",e.HU_HU="hu-HU",e.RO_RO="ro-RO",e.LT_LT="lt-LT",e.LV_LV="lv-LV",e.ET_EE="et-EE",e.SL_SI="sl-SI",e.MT_MT="mt-MT",e.SW_KE="sw-KE",e.AF_ZA="af-ZA",e.AM_ET="am-ET"}(B||(B={})),function(e){e.Africa_Abidjan="Africa/Abidjan",e.Africa_Algiers="Africa/Algiers",e.Africa_Bissau="Africa/Bissau",e.Africa_Cairo="Africa/Cairo",e.Africa_Casablanca="Africa/Casablanca",e.Africa_Ceuta="Africa/Ceuta",e.Africa_El_Aaiun="Africa/El_Aaiun",e.Africa_Johannesburg="Africa/Johannesburg",e.Africa_Juba="Africa/Juba",e.Africa_Khartoum="Africa/Khartoum",e.Africa_Lagos="Africa/Lagos",e.Africa_Maputo="Africa/Maputo",e.Africa_Monrovia="Africa/Monrovia",e.Africa_Nairobi="Africa/Nairobi",e.Africa_Ndjamena="Africa/Ndjamena",e.Africa_Sao_Tome="Africa/Sao_Tome",e.Africa_Tripoli="Africa/Tripoli",e.Africa_Tunis="Africa/Tunis",e.Africa_Windhoek="Africa/Windhoek",e.America_Adak="America/Adak",e.America_Anchorage="America/Anchorage",e.America_Araguaina="America/Araguaina",e.America_Argentina_Buenos_Aires="America/Argentina/Buenos_Aires",e.America_Argentina_Catamarca="America/Argentina/Catamarca",e.America_Argentina_Cordoba="America/Argentina/Cordoba",e.America_Argentina_Jujuy="America/Argentina/Jujuy",e.America_Argentina_La_Rioja="America/Argentina/La_Rioja",e.America_Argentina_Mendoza="America/Argentina/Mendoza",e.America_Argentina_Rio_Gallegos="America/Argentina/Rio_Gallegos",e.America_Argentina_Salta="America/Argentina/Salta",e.America_Argentina_San_Juan="America/Argentina/San_Juan",e.America_Argentina_San_Luis="America/Argentina/San_Luis",e.America_Argentina_Tucuman="America/Argentina/Tucuman",e.America_Argentina_Ushuaia="America/Argentina/Ushuaia",e.America_Asuncion="America/Asuncion",e.America_Bahia="America/Bahia",e.America_Bahia_Banderas="America/Bahia_Banderas",e.America_Barbados="America/Barbados",e.America_Belem="America/Belem",e.America_Belize="America/Belize",e.America_Boa_Vista="America/Boa_Vista",e.America_Bogota="America/Bogota",e.America_Boise="America/Boise",e.America_Cambridge_Bay="America/Cambridge_Bay",e.America_Campo_Grande="America/Campo_Grande",e.America_Cancun="America/Cancun",e.America_Caracas="America/Caracas",e.America_Cayenne="America/Cayenne",e.America_Chicago="America/Chicago",e.America_Chihuahua="America/Chihuahua",e.America_Ciudad_Juarez="America/Ciudad_Juarez",e.America_Costa_Rica="America/Costa_Rica",e.America_Coyhaique="America/Coyhaique",e.America_Cuiaba="America/Cuiaba",e.America_Danmarkshavn="America/Danmarkshavn",e.America_Dawson="America/Dawson",e.America_Dawson_Creek="America/Dawson_Creek",e.America_Denver="America/Denver",e.America_Detroit="America/Detroit",e.America_Edmonton="America/Edmonton",e.America_Eirunepe="America/Eirunepe",e.America_El_Salvador="America/El_Salvador",e.America_Fort_Nelson="America/Fort_Nelson",e.America_Fortaleza="America/Fortaleza",e.America_Glace_Bay="America/Glace_Bay",e.America_Goose_Bay="America/Goose_Bay",e.America_Grand_Turk="America/Grand_Turk",e.America_Guatemala="America/Guatemala",e.America_Guayaquil="America/Guayaquil",e.America_Guyana="America/Guyana",e.America_Halifax="America/Halifax",e.America_Havana="America/Havana",e.America_Hermosillo="America/Hermosillo",e.America_Indiana_Indianapolis="America/Indiana/Indianapolis",e.America_Indiana_Knox="America/Indiana/Knox",e.America_Indiana_Marengo="America/Indiana/Marengo",e.America_Indiana_Petersburg="America/Indiana/Petersburg",e.America_Indiana_Tell_City="America/Indiana/Tell_City",e.America_Indiana_Vevay="America/Indiana/Vevay",e.America_Indiana_Vincennes="America/Indiana/Vincennes",e.America_Indiana_Winamac="America/Indiana/Winamac",e.America_Inuvik="America/Inuvik",e.America_Iqaluit="America/Iqaluit",e.America_Jamaica="America/Jamaica",e.America_Juneau="America/Juneau",e.America_Kentucky_Louisville="America/Kentucky/Louisville",e.America_Kentucky_Monticello="America/Kentucky/Monticello",e.America_La_Paz="America/La_Paz",e.America_Lima="America/Lima",e.America_Los_Angeles="America/Los_Angeles",e.America_Maceio="America/Maceio",e.America_Managua="America/Managua",e.America_Manaus="America/Manaus",e.America_Martinique="America/Martinique",e.America_Matamoros="America/Matamoros",e.America_Mazatlan="America/Mazatlan",e.America_Menominee="America/Menominee",e.America_Merida="America/Merida",e.America_Metlakatla="America/Metlakatla",e.America_Mexico_City="America/Mexico_City",e.America_Miquelon="America/Miquelon",e.America_Moncton="America/Moncton",e.America_Monterrey="America/Monterrey",e.America_Montevideo="America/Montevideo",e.America_New_York="America/New_York",e.America_Nome="America/Nome",e.America_Noronha="America/Noronha",e.America_North_Dakota_Beulah="America/North_Dakota/Beulah",e.America_North_Dakota_Center="America/North_Dakota/Center",e.America_North_Dakota_New_Salem="America/North_Dakota/New_Salem",e.America_Nuuk="America/Nuuk",e.America_Ojinaga="America/Ojinaga",e.America_Panama="America/Panama",e.America_Paramaribo="America/Paramaribo",e.America_Phoenix="America/Phoenix",e.America_Port_au_Prince="America/Port-au-Prince",e.America_Porto_Velho="America/Porto_Velho",e.America_Puerto_Rico="America/Puerto_Rico",e.America_Punta_Arenas="America/Punta_Arenas",e.America_Rankin_Inlet="America/Rankin_Inlet",e.America_Recife="America/Recife",e.America_Regina="America/Regina",e.America_Resolute="America/Resolute",e.America_Rio_Branco="America/Rio_Branco",e.America_Santarem="America/Santarem",e.America_Santiago="America/Santiago",e.America_Santo_Domingo="America/Santo_Domingo",e.America_Sao_Paulo="America/Sao_Paulo",e.America_Scoresbysund="America/Scoresbysund",e.America_Sitka="America/Sitka",e.America_St_Johns="America/St_Johns",e.America_Swift_Current="America/Swift_Current",e.America_Tegucigalpa="America/Tegucigalpa",e.America_Thule="America/Thule",e.America_Tijuana="America/Tijuana",e.America_Toronto="America/Toronto",e.America_Vancouver="America/Vancouver",e.America_Whitehorse="America/Whitehorse",e.America_Winnipeg="America/Winnipeg",e.America_Yakutat="America/Yakutat",e.Antarctica_Casey="Antarctica/Casey",e.Antarctica_Davis="Antarctica/Davis",e.Antarctica_Macquarie="Antarctica/Macquarie",e.Antarctica_Mawson="Antarctica/Mawson",e.Antarctica_Palmer="Antarctica/Palmer",e.Antarctica_Rothera="Antarctica/Rothera",e.Antarctica_Troll="Antarctica/Troll",e.Antarctica_Vostok="Antarctica/Vostok",e.Asia_Almaty="Asia/Almaty",e.Asia_Amman="Asia/Amman",e.Asia_Anadyr="Asia/Anadyr",e.Asia_Aqtau="Asia/Aqtau",e.Asia_Aqtobe="Asia/Aqtobe",e.Asia_Ashgabat="Asia/Ashgabat",e.Asia_Atyrau="Asia/Atyrau",e.Asia_Baghdad="Asia/Baghdad",e.Asia_Baku="Asia/Baku",e.Asia_Bangkok="Asia/Bangkok",e.Asia_Barnaul="Asia/Barnaul",e.Asia_Beirut="Asia/Beirut",e.Asia_Bishkek="Asia/Bishkek",e.Asia_Chita="Asia/Chita",e.Asia_Colombo="Asia/Colombo",e.Asia_Damascus="Asia/Damascus",e.Asia_Dhaka="Asia/Dhaka",e.Asia_Dili="Asia/Dili",e.Asia_Dubai="Asia/Dubai",e.Asia_Dushanbe="Asia/Dushanbe",e.Asia_Famagusta="Asia/Famagusta",e.Asia_Gaza="Asia/Gaza",e.Asia_Hebron="Asia/Hebron",e.Asia_Ho_Chi_Minh="Asia/Ho_Chi_Minh",e.Asia_Hong_Kong="Asia/Hong_Kong",e.Asia_Hovd="Asia/Hovd",e.Asia_Irkutsk="Asia/Irkutsk",e.Asia_Jakarta="Asia/Jakarta",e.Asia_Jayapura="Asia/Jayapura",e.Asia_Jerusalem="Asia/Jerusalem",e.Asia_Kabul="Asia/Kabul",e.Asia_Kamchatka="Asia/Kamchatka",e.Asia_Karachi="Asia/Karachi",e.Asia_Kathmandu="Asia/Kathmandu",e.Asia_Khandyga="Asia/Khandyga",e.Asia_Kolkata="Asia/Kolkata",e.Asia_Krasnoyarsk="Asia/Krasnoyarsk",e.Asia_Kuching="Asia/Kuching",e.Asia_Macau="Asia/Macau",e.Asia_Magadan="Asia/Magadan",e.Asia_Makassar="Asia/Makassar",e.Asia_Manila="Asia/Manila",e.Asia_Nicosia="Asia/Nicosia",e.Asia_Novokuznetsk="Asia/Novokuznetsk",e.Asia_Novosibirsk="Asia/Novosibirsk",e.Asia_Omsk="Asia/Omsk",e.Asia_Oral="Asia/Oral",e.Asia_Pontianak="Asia/Pontianak",e.Asia_Pyongyang="Asia/Pyongyang",e.Asia_Qatar="Asia/Qatar",e.Asia_Qostanay="Asia/Qostanay",e.Asia_Qyzylorda="Asia/Qyzylorda",e.Asia_Riyadh="Asia/Riyadh",e.Asia_Sakhalin="Asia/Sakhalin",e.Asia_Samarkand="Asia/Samarkand",e.Asia_Seoul="Asia/Seoul",e.Asia_Shanghai="Asia/Shanghai",e.Asia_Singapore="Asia/Singapore",e.Asia_Srednekolymsk="Asia/Srednekolymsk",e.Asia_Taipei="Asia/Taipei",e.Asia_Tashkent="Asia/Tashkent",e.Asia_Tbilisi="Asia/Tbilisi",e.Asia_Tehran="Asia/Tehran",e.Asia_Thimphu="Asia/Thimphu",e.Asia_Tokyo="Asia/Tokyo",e.Asia_Tomsk="Asia/Tomsk",e.Asia_Ulaanbaatar="Asia/Ulaanbaatar",e.Asia_Urumqi="Asia/Urumqi",e.Asia_Ust_Nera="Asia/Ust-Nera",e.Asia_Vladivostok="Asia/Vladivostok",e.Asia_Yakutsk="Asia/Yakutsk",e.Asia_Yangon="Asia/Yangon",e.Asia_Yekaterinburg="Asia/Yekaterinburg",e.Asia_Yerevan="Asia/Yerevan",e.Atlantic_Azores="Atlantic/Azores",e.Atlantic_Bermuda="Atlantic/Bermuda",e.Atlantic_Canary="Atlantic/Canary",e.Atlantic_Cape_Verde="Atlantic/Cape_Verde",e.Atlantic_Faroe="Atlantic/Faroe",e.Atlantic_Madeira="Atlantic/Madeira",e.Atlantic_South_Georgia="Atlantic/South_Georgia",e.Atlantic_Stanley="Atlantic/Stanley",e.Australia_Adelaide="Australia/Adelaide",e.Australia_Brisbane="Australia/Brisbane",e.Australia_Broken_Hill="Australia/Broken_Hill",e.Australia_Darwin="Australia/Darwin",e.Australia_Eucla="Australia/Eucla",e.Australia_Hobart="Australia/Hobart",e.Australia_Lindeman="Australia/Lindeman",e.Australia_Lord_Howe="Australia/Lord_Howe",e.Australia_Melbourne="Australia/Melbourne",e.Australia_Perth="Australia/Perth",e.Australia_Sydney="Australia/Sydney",e.Etc_GMT="Etc/GMT",e.Etc_GMT_Minus_1="Etc/GMT-1",e.Etc_GMT_Minus_10="Etc/GMT-10",e.Etc_GMT_Minus_11="Etc/GMT-11",e.Etc_GMT_Minus_12="Etc/GMT-12",e.Etc_GMT_Minus_13="Etc/GMT-13",e.Etc_GMT_Minus_14="Etc/GMT-14",e.Etc_GMT_Minus_2="Etc/GMT-2",e.Etc_GMT_Minus_3="Etc/GMT-3",e.Etc_GMT_Minus_4="Etc/GMT-4",e.Etc_GMT_Minus_5="Etc/GMT-5",e.Etc_GMT_Minus_6="Etc/GMT-6",e.Etc_GMT_Minus_7="Etc/GMT-7",e.Etc_GMT_Minus_8="Etc/GMT-8",e.Etc_GMT_Minus_9="Etc/GMT-9",e.Etc_GMT_Plus_1="Etc/GMT+1",e.Etc_GMT_Plus_10="Etc/GMT+10",e.Etc_GMT_Plus_11="Etc/GMT+11",e.Etc_GMT_Plus_12="Etc/GMT+12",e.Etc_GMT_Plus_2="Etc/GMT+2",e.Etc_GMT_Plus_3="Etc/GMT+3",e.Etc_GMT_Plus_4="Etc/GMT+4",e.Etc_GMT_Plus_5="Etc/GMT+5",e.Etc_GMT_Plus_6="Etc/GMT+6",e.Etc_GMT_Plus_7="Etc/GMT+7",e.Etc_GMT_Plus_8="Etc/GMT+8",e.Etc_GMT_Plus_9="Etc/GMT+9",e.Etc_UTC="Etc/UTC",e.Europe_Andorra="Europe/Andorra",e.Europe_Astrakhan="Europe/Astrakhan",e.Europe_Athens="Europe/Athens",e.Europe_Belgrade="Europe/Belgrade",e.Europe_Berlin="Europe/Berlin",e.Europe_Brussels="Europe/Brussels",e.Europe_Bucharest="Europe/Bucharest",e.Europe_Budapest="Europe/Budapest",e.Europe_Chisinau="Europe/Chisinau",e.Europe_Dublin="Europe/Dublin",e.Europe_Gibraltar="Europe/Gibraltar",e.Europe_Helsinki="Europe/Helsinki",e.Europe_Istanbul="Europe/Istanbul",e.Europe_Kaliningrad="Europe/Kaliningrad",e.Europe_Kirov="Europe/Kirov",e.Europe_Kyiv="Europe/Kyiv",e.Europe_Lisbon="Europe/Lisbon",e.Europe_London="Europe/London",e.Europe_Madrid="Europe/Madrid",e.Europe_Malta="Europe/Malta",e.Europe_Minsk="Europe/Minsk",e.Europe_Moscow="Europe/Moscow",e.Europe_Paris="Europe/Paris",e.Europe_Prague="Europe/Prague",e.Europe_Riga="Europe/Riga",e.Europe_Rome="Europe/Rome",e.Europe_Samara="Europe/Samara",e.Europe_Saratov="Europe/Saratov",e.Europe_Simferopol="Europe/Simferopol",e.Europe_Sofia="Europe/Sofia",e.Europe_Tallinn="Europe/Tallinn",e.Europe_Tirane="Europe/Tirane",e.Europe_Ulyanovsk="Europe/Ulyanovsk",e.Europe_Vienna="Europe/Vienna",e.Europe_Vilnius="Europe/Vilnius",e.Europe_Volgograd="Europe/Volgograd",e.Europe_Warsaw="Europe/Warsaw",e.Europe_Zurich="Europe/Zurich",e.Indian_Chagos="Indian/Chagos",e.Indian_Maldives="Indian/Maldives",e.Indian_Mauritius="Indian/Mauritius",e.Pacific_Apia="Pacific/Apia",e.Pacific_Auckland="Pacific/Auckland",e.Pacific_Bougainville="Pacific/Bougainville",e.Pacific_Chatham="Pacific/Chatham",e.Pacific_Easter="Pacific/Easter",e.Pacific_Efate="Pacific/Efate",e.Pacific_Fakaofo="Pacific/Fakaofo",e.Pacific_Fiji="Pacific/Fiji",e.Pacific_Galapagos="Pacific/Galapagos",e.Pacific_Gambier="Pacific/Gambier",e.Pacific_Guadalcanal="Pacific/Guadalcanal",e.Pacific_Guam="Pacific/Guam",e.Pacific_Honolulu="Pacific/Honolulu",e.Pacific_Kanton="Pacific/Kanton",e.Pacific_Kiritimati="Pacific/Kiritimati",e.Pacific_Kosrae="Pacific/Kosrae",e.Pacific_Kwajalein="Pacific/Kwajalein",e.Pacific_Marquesas="Pacific/Marquesas",e.Pacific_Nauru="Pacific/Nauru",e.Pacific_Niue="Pacific/Niue",e.Pacific_Norfolk="Pacific/Norfolk",e.Pacific_Noumea="Pacific/Noumea",e.Pacific_Pago_Pago="Pacific/Pago_Pago",e.Pacific_Palau="Pacific/Palau",e.Pacific_Pitcairn="Pacific/Pitcairn",e.Pacific_Port_Moresby="Pacific/Port_Moresby",e.Pacific_Rarotonga="Pacific/Rarotonga",e.Pacific_Tahiti="Pacific/Tahiti",e.Pacific_Tarawa="Pacific/Tarawa",e.Pacific_Tongatapu="Pacific/Tongatapu"}(U||(U={})),function(e){e.new="new",e.received="received",e.accepted="accepted",e.in_preparation="in_preparation",e.awaiting_shipment="awaiting_shipment",e.awaiting_collection="awaiting_collection",e.in_delivery="in_delivery",e.completed="completed",e.rejected="rejected",e.cancelled="cancelled",e.delivery_failed="delivery_failed"}(G||(G={}));var F=function(){function e(){}return e.registerBasePath=function(t){void 0!==process.env.APP_HOME?e.BASE_PATH=process.env.APP_HOME+"/":e.BASE_PATH=t+(t.endsWith("/")?"":"/")},e.data=function(){return e.BASE_PATH+"data/"},e.db=function(){return e.storage()+"db/"},e.root=function(){return e.BASE_PATH},e.session=function(){return e.storage()+"session/"},e.storage=function(){return e.BASE_PATH+"storage/"},e.BASE_PATH="./",e}(),q=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),V=function(e){function t(t,r){var n=e.call(this,t,400,r)||this;return n.name="BadParameterException",n}return q(t,e),t}(E),W=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Z=function(e){function t(t,r){var n=e.call(this,t,400,r)||this;return n.name="BadRequestException",n}return W(t,e),t}(E),J=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),z=function(e){function t(t,r){var n=e.call(this,t,409,r)||this;return n.name="ConflictException",n}return J(t,e),t}(E),Y=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),X=function(e){function t(t,r){var n=e.call(this,t,409,r)||this;return n.name="DuplicateException",n}return Y(t,e),t}(E),$=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Q=function(e){function t(t,r){var n=e.call(this,t,500,r)||this;return n.name="InternalException",n}return $(t,e),t}(E),ee=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),te=function(e){function t(t,r){var n=e.call(this,t,501,r)||this;return n.name="NotImplementedException",n}return ee(t,e),t}(E),re=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ne=function(e){function t(t,r){var n=e.call(this,t,404,r)||this;return n.name="ObjectNotFoundException",n}return re(t,e),t}(E),ie=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),oe=function(e){function t(t,r){var n=e.call(this,t,404,r)||this;return n.name="PageNotFoundException",n}return ie(t,e),t}(E),ae=function(){function e(){}return e.error=function(e,t,r){k.error(r);var n=void 0!==r.code&&null!==r.code?Number(r.code):500;t.status(!isNaN(n)&&Number(r.code)>=400&&Number(r.code)<=599?Number(r.code):500),t.json({code:r.code,message:r.message})},e}(),ce=function(){function e(e){this.configuration=e}return e.prototype.handler=function(){var e=this;return function(t,r,n){try{var i=!1;if(i||void 0===e.configuration.jwt||(t.session={},i=!0),i||void 0===e.configuration.key||(i=e.authApiKey(t)),!i&&void 0!==e.configuration.session){var o=Object.keys(t.session);if(!Array.isArray(e.configuration.session.required))throw new D("session is not well formatted");e.configuration.session.required.forEach(function(e){if(!o.includes(e))throw new D("session is incomplete")}),i=!0}if(i||void 0===e.configuration.none||(i=e.authNone(t)),!i)throw new D("request is not authenticate");n()}catch(e){ae.error(t,r,e)}}},e.prototype.authApiKey=function(e){if("string"!=typeof e.headers.Authorization||!e.headers.Authorization.startsWith("apiKey"))return!1;var t=e.headers.Authorization.split(" ");if(2!==t.length)throw new D("api key is not well formatted");if(t[1]!==this.configuration.key.secret)throw new D("api key is not valid");return e.session={},!0},e.prototype.authNone=function(e){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find(function(t){var r;return null===(r=e.originalUrl)||void 0===r?void 0:r.startsWith(t)})||(e.session={},0))},e}(),se=function(){function e(){}return e.prototype.can=function(e,t){},e}();const ue=require("crypto"),le=require("express");var fe=r.n(le);const pe=require("cors");var de=r.n(pe);const me=require("compression");var he=r.n(me);const _e=require("helmet");var Ae=r.n(_e);const ve=require("connect-timeout");var ye=r.n(ve),ge=function(){function e(){}return e.prototype.create=function(t,r){return n=this,i=void 0,a=function(){var n,i;return function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}(this,function(o){return void 0===this.app&&(n=r||e.DEFAULT_PORT,i="http://localhost:"+String(n),k.debug("start server on "+i),this.app=fe()(),this.app.set("trust proxy",!0),this.app.use(he()({level:-1})),this.app.use(ye()("300s")),this.app.use((0,le.json)({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use((0,le.urlencoded)({limit:"10mb"})),this.app.use(de()({origin:[i].concat(t),credentials:!0})),this.app.use(Ae()()),this.app.use((0,le.json)()),this.app.listen(n,function(){k.debug("server is running on "+i)})),[2,this.app]})},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{s(a.next(e))}catch(e){t(e)}}function c(e){try{s(a.throw(e))}catch(e){t(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,c)}s((a=a.apply(n,i||[])).next())});var n,i,o,a},e.prototype.getSessionSecret=function(t){return ue.createHash("sha1").update(t+e.SALT).digest("hex")},e.DEFAULT_PORT=8080,e.SALT="03561b4a0fe7f125025",e}();const be=require("luxon");var Ee=function(){function e(){}return e.isEmail=function(e){return"string"==typeof e&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(e)},e.isPhone=function(e){return"string"==typeof e&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(e)},e.isIntMobilePhone=function(e){var t=new RegExp("^\\+1[0-9]{10}$","i"),r=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),n=new RegExp("^\\+1[0-9]{10}$","i");return t.test(e)||r.test(e)||n.test(e)},e.isNumber=function(e){return"number"==typeof e||"string"==typeof e&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(e)},e}();const we=require("iconv-lite");var Se=function(){function e(){}return e.isUTF8=function(e){return!e||"utf8"===(e=e.toLowerCase())||"utf-8"===e},e.urlencode=function(t,r){if(!r||e.isUTF8(r))return encodeURIComponent(t);for(var n=(0,we.encode)(t,r),i="",o="",a=0;a<n.length;a++)1===(o=n[a].toString(16)).length&&(o="0"+o),i+="%"+o;return i.toUpperCase()},e}(),Te=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})},Pe=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},Me=function(){function e(e,t){this.token=e,this.mode=t}return e.prototype.send=function(t,r,n){return Te(this,arguments,void 0,function(t,r,n,i,o){var a,c=this;return void 0===i&&(i=!0),Pe(this,function(s){switch(s.label){case 0:return 0===(a=this.checkPhoneFormat(n)).length?(k.warning(new V("no valid phone",{phones:n})),[2,Promise.resolve()]):(a.length>1&&(r.length>2*e.MESSAGE_MAX_LENGTH?r=r.substring(0,2*e.MESSAGE_MAX_LENGTH):r.length>e.MESSAGE_MAX_LENGTH&&r.length<=1.33*e.MESSAGE_MAX_LENGTH&&(r=r.substring(0,e.MESSAGE_MAX_LENGTH))),[4,N.request(function(){return Te(c,void 0,void 0,function(){var n,c,s;return Pe(this,function(u){switch(u.label){case 0:return n={accessToken:this.token,emetteur:t,message:Se.urlencode(r,"ISO-8859-15"),numero:a.map(function(e){return e.replace("+","")}).join(","),classe_msg:2,nbr_msg:Math.ceil(r.length/e.MESSAGE_MAX_LENGTH)},i&&(n.stop=1),void 0!==o&&(n.date_envoi=be.DateTime.fromISO(o,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),c=be.DateTime.fromISO(null!=o?o:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),i?c.hour>=21?n.date_envoi=c.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):c.hour<9&&(n.date_envoi=c.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):c.hour<8&&(n.date_envoi=c.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode!==M.TEST?[3,1]:(k.info("Simulation Mode: SMS has been sent",{params:n}),[3,3]);case 1:return this.mode===M.DEVELOPMENT&&(a=["+15145705214"]),[4,g().post(e.BASE_API_URL+"sendSMS.do",L.stringify(n,"&","=",{encodeURIComponent:function(e){return e}}),{timeout:3e4})];case 2:if((s=u.sent()).data.length>0&&"0"!==s.data.trim().substring(0,1))throw new S("Error: "+s.data,n);u.label=3;case 3:return[2]}})})},0,k.error.bind(k))]);case 1:return s.sent(),[2]}})})},e.prototype.checkPhoneFormat=function(e){return e.filter(function(e){return Ee.isIntMobilePhone(e)})},e.BASE_API_URL="https://api.smsmode.com/http/1.6/",e.MESSAGE_MAX_LENGTH=150,e}();const Ce=require("path"),Oe=require("mustache"),De=require("fs");var Re=function(e,t){return r=void 0,n=void 0,o=function(){var r;return function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}(this,function(n){switch(n.label){case 0:r=0,n.label=1;case 1:return r<e.length?[4,t(e[r])]:[3,4];case 2:n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return[2]}})},new((i=void 0)||(i=Promise))(function(e,t){function a(e){try{s(o.next(e))}catch(e){t(e)}}function c(e){try{s(o.throw(e))}catch(e){t(e)}}function s(t){var r;t.done?e(t.value):(r=t.value,r instanceof i?r:new i(function(e){e(r)})).then(a,c)}s((o=o.apply(r,n||[])).next())});var r,n,i,o},ke=function(e){return new Promise(function(t){return setTimeout(t,e)})};const xe=require("color-name");var Ne=function(){function e(){}return e.code=function(t){null==t&&(t=6);for(var r="";r.length<t;)r+=e.symbolUpperCases[e.int(0,e.symbolUpperCases.length-1)];return r},e.color=function(t){void 0===t&&(t=1);var r=e.rgbToHex(Math.round(255*t)),n="#000000"+r,i=Object.values(xe);if(0===i.length)return n;var o=i[e.int(0,i.length-1)];return 3!==o.length?n:"#"+e.rgbToHex(o[0])+e.rgbToHex(o[1])+e.rgbToHex(o[2])+r},e.rgbToHex=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},e.int=function(e,t){return null==e&&(e=0),null==t&&(t=Number.POSITIVE_INFINITY),e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e},e.password=function(t){null==t&&(t=8);for(var r="";r.length<t;)switch(e.int(1,3)){case 1:r+=e.symbolUpperCases[e.int(0,e.symbolUpperCases.length-1)];break;case 2:r+=e.symbolLowerCases[e.int(0,e.symbolLowerCases.length-1)];break;default:r+=String(e.int(0,9))}return r},e.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],e.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"],e}(),Le=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})},Ie=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},Be=function(){function e(){}return e.prototype.dirPath=function(e){var t=Ce.resolve(e).lastIndexOf(Ce.sep);return t<0?e:Ce.resolve(Ce.resolve(e).substr(0,t+1))+Ce.sep},e.prototype.listFiles=function(e){return Le(this,void 0,void 0,function(){var t,r,n,i=this;return Ie(this,function(o){switch(o.label){case 0:if(!this.isDir(e))throw new V(String(e)+" does not exist or is not a directory");return t=e.endsWith("/")?"":"/",r=De.readdirSync(e),n=[],[4,Re(r,function(r){return Le(i,void 0,void 0,function(){return Ie(this,function(i){return this.isFile(e+t+r)&&n.push(e+t+r),[2]})})})];case 1:return o.sent(),[2,n]}})})},e.prototype.randomFile=function(e,t){return Le(this,void 0,void 0,function(){var r,n;return Ie(this,function(i){switch(i.label){case 0:return[4,this.listFiles(e)];case 1:return 0===(r=i.sent()).length?[2,void 0]:(n=void 0!==t?Math.max(t,0)%r.length:Ne.int(0,r.length-1),[2,r[n]])}})})},e.prototype.move=function(e,t){return Le(this,void 0,void 0,function(){return Ie(this,function(r){if(!this.isFile(e))throw new V(String(e)+" does not exist or is not a file");if(De.mkdirSync(t,{recursive:!0}),!this.isDir(t))throw new V(String(t)+" does not exist or is not a directory");return[2,De.renameSync(e,t+Ce.basename(e))]})})},e.prototype.read=function(e){return Le(this,void 0,void 0,function(){return Ie(this,function(t){if(!this.isFile(e))throw new V(String(e)+" does not exist or is not a file");return[2,De.readFileSync(e,"utf8")]})})},e.prototype.readJson=function(e){return Le(this,void 0,void 0,function(){var t;return Ie(this,function(r){switch(r.label){case 0:return[4,this.read(e)];case 1:if(t=r.sent(),!this.isJson(t))throw new V(String(e)+" does not contain JSON");return[2,JSON.parse(t)]}})})},e.prototype.readJsonFiles=function(e){return Le(this,void 0,void 0,function(){var t,r,n,i=this;return Ie(this,function(o){switch(o.label){case 0:if(!this.isDir(e))throw new V(String(e)+" does not exist or is not a directory");return t=e.endsWith("/")?"":"/",r=De.readdirSync(e),n=[],[4,Re(r,function(r){return Le(i,void 0,void 0,function(){var i,o,a;return Ie(this,function(c){switch(c.label){case 0:return this.isFile(e+t+r)&&r.endsWith(".json")?(o=(i=n).push,a={name:r},[4,this.readJson(e+t+r)]):[3,2];case 1:o.apply(i,[(a.data=c.sent(),a)]),c.label=2;case 2:return[2]}})})})];case 1:return o.sent(),[2,n]}})})},e.prototype.write=function(e,t){return Le(this,void 0,void 0,function(){var r;return Ie(this,function(n){return"",r="string"==typeof t||"number"==typeof t?String(t):JSON.stringify(t),De.mkdirSync(this.dirPath(e),{recursive:!0}),De.writeFileSync(e,r,{encoding:"utf8"}),[2,Promise.resolve()]})})},e.prototype.writeJson=function(e,t){return Le(this,void 0,void 0,function(){return Ie(this,function(r){return[2,this.write(e,JSON.stringify(t))]})})},e.prototype.isDir=function(e){return De.existsSync(e)&&De.statSync(e).isDirectory()},e.prototype.isFile=function(e){return De.existsSync(e)&&De.statSync(e).isFile()},e.prototype.isJson=function(e){try{return JSON.parse(e),!0}catch(e){return!1}},e}();const Ue=require("clean-css");var Ge=r.n(Ue);const je=require("html-minifier-terser");var He=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})},Ke=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},Fe=function(){function e(){}return e.prototype.css=function(e){return He(this,void 0,void 0,function(){return Ke(this,function(t){return[2,new(Ge())({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(e).styles]})})},e.prototype.html=function(e){return He(this,void 0,void 0,function(){return Ke(this,function(t){switch(t.label){case 0:return[4,(0,je.minify)(e,{collapseBooleanAttributes:!0,collapseInlineTagWhitespace:!0,collapseWhitespace:!0,continueOnParseError:!1,decodeEntities:!1,html5:!0,minifyCSS:!0,minifyJS:!0,noNewlinesBeforeTagClose:!0,preserveLineBreaks:!1,preventAttributesEscaping:!1,processConditionalComments:!1,quoteCharacter:'"',removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeEmptyElements:!0,removeOptionalTags:!1,removeRedundantAttributes:!0,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeTagWhitespace:!1})];case 1:return[2,t.sent()]}})})},e}(),qe=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})},Ve=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},We=function(){function e(){this.minifier=new Fe}return e.prototype.render=function(e,t,r){return qe(this,void 0,void 0,function(){var n,i,o,a,c,s=this;return Ve(this,function(u){switch(u.label){case 0:return e.endsWith(".template")||(e+=".template"),n=(0,h.cloneDeep)(t),i=Ce.isAbsolute(e)?"":__dirname+Ce.sep,[4,(new Be).read(i+e)];case 1:return o=u.sent(),a=[],(0,Oe.parse)(o).forEach(function(e){e.length>=4&&"&"===e[0]&&e[1].startsWith("include:")&&a.push(e[1])}),a.length>0?(void 0===r?r=Ce.dirname(i+e)+Ce.sep:Ce.isAbsolute(r)||(r=i+r),[4,Re(a,function(e){return qe(s,void 0,void 0,function(){var t,i,o,a;return Ve(this,function(c){switch(c.label){case 0:return 3!==(t=e.split(":")).length||void 0===n[e]?[3,2]:(i=t[2],r.includes("/html")&&Object.keys(n[e]).forEach(function(t){n[e][t]=Array.isArray(n[e][t])?n[e][t].map(function(e){return e.replace(/(?:\r\n|\r|\n)/g,"<br>")}):n[e][t].replace(/(?:\r\n|\r|\n)/g,"<br>")}),o=n,a=e,[4,this.render(Ce.resolve(r,i),n[e])]);case 1:o[a]=c.sent(),c.label=2;case 2:return[2]}})})})]):[3,3];case 2:u.sent(),u.label=3;case 3:if((c=(0,Oe.render)(o,n)).includes("{{")||c.includes("}}"))throw new z("template: missing data to render template",{templatePath:e,data:t});return[2,e.includes("html")?this.minifier.html(c):c]}})})},e}();const Ze=require("node-mailjet");var Je=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})},ze=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},Ye=function(){function e(e,t,r){this.templateEngine=new We,this.mailjet=new Ze.Client({apiKey:e,apiSecret:t}),this.mode=r}return e.prototype.sendDeliveryDelay=function(e,t,r){return Je(this,void 0,void 0,function(){var n=this;return ze(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return Je(n,void 0,void 0,function(){var n,i;return ze(this,function(o){switch(o.label){case 0:return void 0===r.base.copyright&&(r.base.copyright={year:String((new Date).getUTCFullYear())}),[4,this.templateEngine.render("data/email/template/deliveryDelay",r,"data/email/element/text")];case 1:return n=o.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",r,"data/email/element/html")];case 2:return i=o.sent(),[4,this.sendNotification(e,[{recipient:t,subject:r.base.subject,text:n,html:i}],!1)];case 3:return[2,o.sent()]}})})},0,k.error.bind(k))];case 1:return[2,i.sent()]}})})},e.prototype.sendTrackDelivery=function(e,t,r){return Je(this,void 0,void 0,function(){var n=this;return ze(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return Je(n,void 0,void 0,function(){var n,i,o,a;return ze(this,function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",r,"data/email/element/text")];case 1:return n=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:n,base:r.base})];case 2:return i=c.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",r,"data/email/element/html")];case 3:return o=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:o,base:r.base})];case 4:return a=c.sent(),[4,this.sendNotification(e,[{recipient:t,subject:r.base.subject,text:i,html:a}],!1)];case 5:return[2,c.sent()]}})})},0,k.error.bind(k))];case 1:return[2,i.sent()]}})})},e.prototype.sendUserNotification=function(e,t,r){return Je(this,arguments,void 0,function(e,t,r,n,i){var o=this;return void 0===n&&(n=!0),ze(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return Je(o,void 0,void 0,function(){var o,a,c,s;return ze(this,function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",r,"data/email/element/text")];case 1:return o=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:o,base:r.base,isCommercial:n})];case 2:return a=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",r,"data/email/element/html")];case 3:return c=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:c,base:r.base,isCommercial:n})];case 4:return s=u.sent(),[4,this.sendNotification(e,[{recipient:t,subject:r.base.subject,text:a,html:s}],n,i)];case 5:return[2,u.sent()]}})})},0,k.error.bind(k))];case 1:return[2,a.sent()]}})})},e.prototype.sendUsersNotifications=function(e,t,r,n){return Je(this,void 0,void 0,function(){var i=this;return ze(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return Je(i,void 0,void 0,function(){var i,o=this;return ze(this,function(a){switch(a.label){case 0:return i=[],[4,Re(t,function(e){return Je(o,void 0,void 0,function(){var t,n,o,a;return ze(this,function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",e.data,"data/email/element/text")];case 1:return t=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:t,base:e.data.base,isCommercial:r})];case 2:return n=c.sent(),[4,this.templateEngine.render("data/email/template/userNotification",e.data,"data/email/element/html")];case 3:return o=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:o,base:e.data.base,isCommercial:r})];case 4:return a=c.sent(),i.push({recipient:e.recipient,subject:e.data.base.subject,text:n,html:a}),[2]}})})})];case 1:return a.sent(),[4,this.sendNotification(e,i,r,n)];case 2:return[2,a.sent()]}})})},0,k.error.bind(k))];case 1:return[2,o.sent()]}})})},e.prototype.sendDiscount=function(e,t,r){return Je(this,arguments,void 0,function(e,t,r,n,i){var o=this;return void 0===n&&(n=!0),ze(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return Je(o,void 0,void 0,function(){var o,a,c,s;return ze(this,function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",r,"data/email/element/text")];case 1:return o=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:o,base:r.base,isCommercial:n})];case 2:return a=u.sent(),[4,this.templateEngine.render("data/email/template/discount",r,"data/email/element/html")];case 3:return c=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:c,base:r.base,isCommercial:n})];case 4:return s=u.sent(),[4,this.sendNotification(e,[{recipient:t,subject:r.base.subject,text:a,html:s}],n,i)];case 5:return[2,u.sent()]}})})},0,k.error.bind(k))];case 1:return[2,a.sent()]}})})},e.prototype.sendDiscounts=function(e,t){return Je(this,arguments,void 0,function(e,t,r,n){var i=this;return void 0===r&&(r=!0),ze(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return Je(i,void 0,void 0,function(){var i,o=this;return ze(this,function(a){switch(a.label){case 0:return i=[],[4,Re(t,function(e){return Je(o,void 0,void 0,function(){var t,n,o,a;return ze(this,function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",e.data,"data/email/element/text")];case 1:return t=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:t,base:e.data.base,isCommercial:r})];case 2:return n=c.sent(),[4,this.templateEngine.render("data/email/template/discount",e.data,"data/email/element/html")];case 3:return o=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:o,base:e.data.base,isCommercial:r})];case 4:return a=c.sent(),i.push({recipient:e.recipient,subject:e.data.base.subject,text:n,html:a}),[2]}})})})];case 1:return a.sent(),[4,this.sendNotification(e,i,r,n)];case 2:return[2,a.sent()]}})})},0,k.error.bind(k))];case 1:return[2,o.sent()]}})})},e.prototype.sendNotification=function(e,t){return Je(this,arguments,void 0,function(e,t,r,n){var i,o,a=this;return void 0===r&&(r=!1),ze(this,function(c){switch(c.label){case 0:if(0===t.length)throw new V("email: missing messages");c.label=1;case 1:return c.trys.push([1,6,,7]),this.mode!==M.TEST?[3,2]:(k.info("Simulation Mode: Email has been sent",{sender:e,recipients:t.map(function(e){return e.recipient})}),[3,5]);case 2:return i=[],[4,Re(t,function(t){return Je(a,void 0,void 0,function(){return ze(this,function(o){return this.mode===M.DEVELOPMENT&&(t.recipient.contact="developer@onylab.com"),i.push({From:{Name:e.name,Email:e.contact},To:[{Name:t.recipient.name,Email:t.recipient.contact}],Subject:t.subject,TextPart:t.text,HTMLPart:t.html,Priority:r?0:2,customID:void 0===n?void 0:String(n)}),[2]})})})];case 3:return c.sent(),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:i})];case 4:c.sent(),c.label=5;case 5:return[3,7];case 6:throw o=c.sent(),new E(o.message,Number(o.statusCode));case 7:return[2]}})})},e}(),Xe=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})},$e=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},Qe=function(){function e(t,r){this.filesystem=new Be,void 0!==e.root&&e.root===t||(e.root=t,e.config=void 0);var n=void 0===r?C.getMode():r;void 0!==e.environment&&e.environment===n||(e.environment=void 0===r?C.getMode():r,e.config=void 0)}return e.prototype.full=function(){return Xe(this,void 0,void 0,function(){return $e(this,function(t){switch(t.label){case 0:return[4,this.init()];case 1:return t.sent(),[2,e.config]}})})},e.prototype.init=function(){return Xe(this,void 0,void 0,function(){var t,r,n,i;return $e(this,function(o){switch(o.label){case 0:return void 0!==e.config?[3,6]:void 0!==e.root?[3,1]:(e.config={},[3,6]);case 1:return t=e,[4,this.filesystem.readJson(e.root+"data/config.json")];case 2:if(t.config=o.sent(),![M.DEVELOPMENT,M.TEST].includes(e.environment))return[3,6];o.label=3;case 3:return o.trys.push([3,5,,6]),r=e,n=h.merge,i=[e.config],[4,this.filesystem.readJson(e.root+"data/config_"+String(e.environment)+".json")];case 4:return r.config=n.apply(void 0,i.concat([o.sent()])),[3,6];case 5:return o.sent(),[3,6];case 6:return[2]}})})},e}();const et=require("typeorm");var tt=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})},rt=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},nt=function(){function e(e){this.root=e}return e.prototype.connect=function(e,t){return tt(this,void 0,void 0,function(){var r,n;return rt(this,function(i){switch(i.label){case 0:return void 0!==this.db?[3,2]:[4,this.init()];case 1:i.sent(),i.label=2;case 2:return void 0===(r=this.db[e])?[3,4]:(r.entities=t,r.logging=["error"],r.logger=!0,r.bigNumberStrings=!1,void 0===r.timezone&&(r.timezone="Z"),void 0===r.charset&&(r.charset="UTF8_GENERAL_CI"),n=this,[4,(0,et.createConnection)(r)]);case 3:return n.connection=i.sent(),[3,5];case 4:k.error(new V("bad connection name")),i.label=5;case 5:return[2]}})})},e.prototype.synchronize=function(){return tt(this,void 0,void 0,function(){return rt(this,function(e){switch(e.label){case 0:return void 0===this.connection?[3,2]:[4,this.connection.synchronize()];case 1:e.sent(),e.label=2;case 2:return[2]}})})},e.prototype.close=function(){return tt(this,void 0,void 0,function(){return rt(this,function(e){return[2,this.connection.close()]})})},e.prototype.init=function(){return tt(this,void 0,void 0,function(){var e,t;return rt(this,function(r){switch(r.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return e=new Be,t=this,[4,e.readJson(this.root+"data/db.json")];case 2:t.db=r.sent(),r.label=3;case 3:return[2]}})})},e}();const it=require("prettyjson");var ot=function(){function e(){}return e.prototype.error=function(e){k.error(e)},e.prototype.info=function(e){k.trace(e)},e.prototype.json=function(e){k.trace(it.render(e,{}))},e.prototype.success=function(e){k.trace(e)},e}(),at=function(){function e(){this.fileSystem=new Be}return e.prototype.image=function(e,t,r){return n=this,i=void 0,a=function(){var n,i;return function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}(this,function(o){switch(o.label){case 0:return void 0===r&&(r=ue.randomBytes(20).toString("hex")+Ce.extname(e)),[4,this.fileSystem.write(t+Ce.sep+r,"")];case 1:return o.sent(),n=Ce.resolve(t+Ce.sep+r),i=De.createWriteStream(n),[4,g()({url:e,method:"GET",responseType:"stream"})];case 2:return o.sent().data.pipe(i),[2,new Promise(function(e,t){i.on("finish",function(){return e(n)}),i.on("error",t)})]}})},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{s(a.next(e))}catch(e){t(e)}}function c(e){try{s(a.throw(e))}catch(e){t(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,c)}s((a=a.apply(n,i||[])).next())});var n,i,o,a},e}();const ct=require("fast-diff");var st=r.n(ct),ut=function(){function e(){}return e.escapeRegExp=function(e){return"string"!=typeof e?e:e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},e.hash=function(e,t){void 0===t&&(t=0);for(var r=3735928559^t,n=1103547991^t,i=0,o=void 0;i<e.length;i++)o=e.charCodeAt(i),r=Math.imul(r^o,2654435761),n=Math.imul(n^o,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),((n^=Math.imul(r^r>>>13,3266489909))>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")},e.nullable=function(e){return R(e)||"string"==typeof e&&0===e.length?null:e},e.removeMultiSpaces=function(e){return"string"!=typeof e?e:e.replace(/\s{2,}/g," ")},e.removeText=function(t,r){if("string"!=typeof t||"string"!=typeof r||0===r.length)return t;try{t=(t=t.replace(new RegExp(e.escapeRegExp(r),"ig"),"")).replace(new RegExp(e.escapeRegExp(r).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(e){}return t},e.replace=function(t,r,n){if("string"!=typeof t)return t;if(r.length!==n.length)return t;var i=t;return r.forEach(function(t,r){i=i.replace(new RegExp(e.escapeRegExp(t),"ig"),n[r])}),i},e.slugify=function(e,t){return void 0===t&&(t=""),void 0===e?"":(0,h.toLower)((0,h.trim)((0,h.deburr)(e)).replace(/[^0-9a-z\-\_]/gi,t))},e.truncate=function(e,t){return R(e)||e.length<=t?e:t<=3?"":e.slice(0,t-3)+"..."},e}(),lt=function(){function e(){}return e.trim=function(e){return"string"==typeof e?e.trim():e},e.capitalize=function(t){var r=e.lower(t);return"string"==typeof r?r.split(" ").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" "):t},e.ucfirst=function(t){var r=e.lower(t);return"string"==typeof r?r.charAt(0).toUpperCase()+r.slice(1):t},e.lower=function(e){return"string"==typeof e?e.toLocaleLowerCase():e},e.upper=function(e){return"string"==typeof e?e.toLocaleUpperCase():e},e.phone=function(t,r,n){if(void 0===n&&(n="int"),"string"==typeof t)switch(t=e.preformatPhone(t,r),n){case"nat":return e.phoneNat(t,r);case"int":return e.phoneInt(t,r)}return t},e.stripEmoji=function(e){var t=e;if("string"==typeof t)for(var n=r(16),i=void 0;null!==(i=n().exec(t));)try{t=(t=(t=t.replace(new RegExp(ut.escapeRegExp(i[0]),"g"),"")).replace(new RegExp("\\s+","g")," ")).trim()}catch(e){}return t},e.stripExoticCharacters=function(e){return"string"==typeof e?e.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):e},e.preformatPhone=function(e,t){return e=e.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===t&&new RegExp("^[1-9]").test(e)&&9===e.length?"0"+e:e},e.phoneNat=function(e,t){if("fr"===t){if(e.startsWith("+330")?e=e.substring(3):e.startsWith("+33")?e="0"+e.substring(3):e.startsWith("0033")?e="0"+e.substring(4):e.startsWith("33")&&11===e.length&&(e="0"+e.substring(2)),10===e.length){var r=0;e=e.split("").map(function(e){return e+(++r%2==0?" ":"")}).join("").trim()}return e}return e},e.phoneInt=function(e,t){return e.startsWith("+")?e:"fr"===t?(e.startsWith("0")&&(e=e.substring(1)),"+33"+e):e},e}(),ft=function(){function e(){}return e.autoCorrectCity=function(t){if(R(t)||"string"!=typeof t||0===t.length)return t;(t.toLowerCase().startsWith("st-")||t.toLowerCase().startsWith("st "))&&(t="Saint "+t.substring(3));var r=Object.values(e.ZIPCODE_CITY).flat(),n=r.find(function(e){return e.toLowerCase()===t.toLowerCase()});if(void 0!==n)return n;var i=r.find(function(r){var n=e.countDiff(t,r);return n.add<=2&&n.remove<=2});if(void 0!==i)return i;var o=r.find(function(e){return e.replace(/-/g," ").toLowerCase()===t.toLowerCase()});if(void 0!==o)return o;var a=r.find(function(r){var n=e.countDiff(t,r.replace(/-/g," "));return n.add<=2&&n.remove<=2});if(void 0!==a)return a;var c=r.find(function(e){return e.toLowerCase().startsWith(t.toLowerCase())});if(void 0!==c)return c;var s=r.find(function(e){return t.toLowerCase().includes(e.toLowerCase())});return void 0!==s?s:t},e.autoCorrectStreet=function(t){if(R(t)||"string"!=typeof t||0===t.length)return t;e.STREET_TYPE.forEach(function(e){e.short.length<e.long.length&&(t=(t=t.replace(new RegExp("(\\s"+String(e.short)+"\\.?\\s)","ig")," "+String(e.long)+" ")).replace(new RegExp("(\\s"+String(e.short)+"\\.\\s)","ig")," "+String(e.long)+" "))});var r=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(t);return null!==r&&2===r.length&&(t=t.substring(r[1].length)),e.STREET_TYPE.forEach(function(e){t=(t=t.replace(new RegExp("([0-9]+)("+String(e.long)+"\\s)","ig"),"$1 $2")).replace(new RegExp("([0-9]+)("+String(e.short)+"\\.?\\s)","ig"),"$1 "+String(e.long)+" ")}),t},e.getZipCodeFromCity=function(t){if(!R(t))return Object.keys(e.ZIPCODE_CITY).reduce(function(r,n){return void 0!==e.ZIPCODE_CITY[n].find(function(e){return e.toLowerCase()===t.toLowerCase()})?n:r},void 0)},e.getCityFromZipCode=function(t,r){if(void 0!==t&&void 0!==r){var n,i=e.ZIPCODE_CITY[t];if(void 0!==i)return 1===i.length?i[0]:(r.split(",").forEach(function(e){n=i.find(function(t){return e.trim().toLowerCase()===t.trim().toLowerCase()})}),void 0!==n?n:i[0])}},e.isZipCode=function(t){return"string"==typeof t&&(!!Object.keys(e.ZIPCODE_CITY).includes(t)||Ee.isNumber(t)&&5===t.length&&!t.includes(".")&&!t.includes("-"))},e.parse=function(t,r){void 0===r&&(r=!0);var n={};if(!R(t)){var i=t.split(",");if(i.length>=3&&r){void 0===e.COUNTRIES.find(function(e){return t.toLowerCase().includes(" "+e.toLowerCase())})&&i.push("France");var o=i.length-1;if(n.country=i[o].trim(),i.splice(o--,1),void 0!==i[o]&&i[o].trim().includes(" ")){var a=i[o].trim().split(" ");n.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),n.city=a.join(" ").trim(),i.splice(o--,1)}else isNaN(Number(i[o].trim()))?isNaN(Number(i[o-1].trim()))?(n.city=i[o].trim(),i.splice(o--,1)):(n.city=i[o].trim(),i.splice(o--,1),n.zip=i[o].trim(),i.splice(o--,1)):(n.zip=i[o].trim(),i.splice(o--,1),o>=2&&(n.city=i[o].trim(),i.splice(o--,1)));n.street=i.map(function(e){return e.trim()}).join(" ").trim()}else{var c=t.toLowerCase();Object.keys(e.ZIPCODE_CITY).forEach(function(e){if(c.includes(e)){n.zip=e;try{c=c.replace(new RegExp(ut.escapeRegExp(e),"ig"),"")}catch(e){}}}),Object.values(e.ZIPCODE_CITY).flat().forEach(function(t){var r;if(c.includes(t.toLowerCase())&&(void 0===n.zip||(null===(r=e.ZIPCODE_CITY[n.zip])||void 0===r?void 0:r.find(function(e){return e.toLowerCase()===t.toLowerCase()})))){n.city=t;try{c=c.replace(new RegExp(ut.escapeRegExp(t),"ig"),"")}catch(e){}}}),e.COUNTRIES.forEach(function(e){if(c.includes(" "+e.toLowerCase())&&!c.includes("de "+e.toLowerCase())&&!c.includes("de la "+e.toLowerCase())){n.country=e;try{c=c.replace(new RegExp(ut.escapeRegExp(" "+e),"ig"),"")}catch(e){}}}),void 0===n.street&&(n.street=(0,h.trim)(c.split(",").map(function(e){return e.trim()}).join(" "),"-").trim())}void 0===n.country&&(n.country="France")}return void 0!==n.street&&(n.street=lt.lower(lt.trim(String(n.street)))),void 0!==n.zip&&(n.zip=lt.upper(lt.trim(String(n.zip)))),void 0!==n.city&&(n.city=e.autoCorrectCity(lt.capitalize(lt.trim(String(n.city))))),void 0!==n.country&&(n.country=lt.capitalize(lt.trim(String(n.country)))),e.complete(n)},e.complete=function(t){if(void 0===t.city||0===t.city.length){var r=e.getCityFromZipCode(t.zip,t.street);void 0!==r&&(t.city=r)}return"string"==typeof t.street&&e.REGIONS.forEach(function(e){t.street=ut.removeText(t.street,e).trim()}),"fr"===lt.lower(t.country)&&(t.country="France"),t},e.removeDuplicates=function(e){if("string"!=typeof e)return e;var t=[];return e.split(",").forEach(function(e){void 0===t.find(function(t){return t.trim().toLowerCase().includes(e.trim().toLowerCase())})&&t.push(e)}),t.join(",")},e.countDiff=function(e,t){var r={add:0,remove:0};return st()(e.toLowerCase(),t.toLowerCase()).forEach(function(e){switch(e[0]){case-1:r.remove+=e[1].length;break;case 1:r.add+=e[1].length}}),r},e.ZIPCODE_CITY={78500:["Sartrouville"],78600:["Maisons-Laffitte","Le Mesnil-le-Roi"],78800:["Houilles"],95240:["Cormeilles-en-Parisis"],95530:["La Frette-sur-Seine"],78100:["Saint-Germain-en-Laye"],95100:["Argenteuil"],78630:["Orgeval","Morainvilliers"],78670:["Villennes-sur-Seine","Medan"],78240:["Chambourcy","Aigremont"],78300:["Poissy"],78510:["Triel-sur-Seine"],78570:["Andrésy","Chanteloup-les-Vignes"],78700:["Conflans-Sainte-Honorine"],78480:["Verneuil-sur-Seine"],78750:["Mareil-Marly"],78620:["L'Étang-la-Ville"],78160:["Marly-le-Roi"],78580:["Les Alluets-le-Roi"],78955:["Carrières-sous-Poissy"],78260:["Achères"],78540:["Vernouillet"],78920:["Ecquevilly"],95150:["Taverny"],95250:["Beauchamp"],95480:["Pierrelaye"],95320:["Saint-Leu-la-Forêt"],95550:["Bessancourt"],95370:["Montigny-lès-Cormeilles"],95220:["Herblay"],95740:["Frépillon"],95540:["Méry-sur-Oise"],95870:["Bezons"],78420:["Carrières-sur-Seine"],78400:["Chatou"],78110:["Le Vésinet"],78360:["Montesson"],78290:["Croissy-sur-Seine","Croissy"],78230:["Le Pecq"],95600:["Eaubonne"]},e.REGIONS=["île-de-france"],e.COUNTRIES=["France","FR"],e.STREET_TYPE=[{short:"av",long:"avenue"},{short:"rue",long:"rue"},{short:"bd",long:"boulevard"},{short:"chau",long:"chaussée"},{short:"trav",long:"traverse"},{short:"pl",long:"place"},{short:"pass",long:"passage"},{short:"sent",long:"sentier"},{short:"imp",long:"impasse"},{short:"all",long:"allée"},{short:"chem",long:"chemin"},{short:"ham",long:"hameau"},{short:"dom",long:"domaine"}],e}(),pt=function(){function e(){}return e.getCycleDateFromFullDate=function(e,t){if("weekly"===t){var r=be.DateTime.fromISO(e.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===r)return e;var n=r.split("-");return n.length>2?n[0]+"-"+n[1]:n.join("-")}return"monthly"===t?be.DateTime.fromISO(e).toFormat("yyyy-LL"):be.DateTime.fromISO(e).toISODate()},e.displayWeekDay=function(t){var r="";return void 0!==e.WEEK_DAYS[t]&&(r=e.WEEK_DAYS[t]),r},e.generatePeriod=function(t,r,n,i,o,a){void 0===i&&(i=!0),void 0===o&&(o=e.PERIOD_MAX_DATES),void 0===a&&(a="daily");for(var c={daily:{day:1},weekly:{week:1},monthly:{month:1}}[a],s=be.DateTime.fromISO(t,{setZone:!0}).toISODate(),u=be.DateTime.fromISO(r,{setZone:!0}).toISODate(),l=0,f={};s<=u&&l<o;){var p=e.getCycleDateFromFullDate(s,a);f[p]=(0,h.cloneDeep)(n),i&&(f[p].date=p),s=be.DateTime.fromISO(s,{setZone:!0}).plus(c).toISODate(),l++}return f},e.getOpenPeriods=function(e,t){var r=[];return e.forEach(function(e){for(var n=[e],i=function(){var e=n[0];if(void 0===t.find(function(t){return t.from<=e.from&&e.to<=t.to})){var i=t.find(function(t){return t.from<=e.from&&e.from<t.to&&t.to<e.to});if(void 0!==i)n.push({from:i.to,to:e.to});else{var o=t.find(function(t){return e.from<t.from&&e.to>t.from&&e.to<=t.to});if(void 0!==o)n.push({from:e.from,to:o.from});else{var a=t.find(function(t){return e.from<t.from&&t.to<e.to});void 0!==a?(n.push({from:e.from,to:a.from}),n.push({from:a.to,to:e.to})):r.push(e)}}}n.shift()};n.length>0;)i()}),r},e.limitDate=function(e,t,r){if(void 0===r&&(r=0),void 0!==e&&void 0!==t){var n=be.DateTime.fromISO(e,{setZone:!0}).toISO(),i=be.DateTime.fromISO(t,{setZone:!0}).plus({seconds:r}).toISO();return n>i?i:n}},e.localeToISO=function(e){var t,r=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),n=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),i=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(r.test(e))t=(o=e.split("/"))[2]+"-"+o[1]+"-"+o[0];else if(n.test(e)){var o;t=(o=e.split("-"))[2]+"-"+o[1]+"-"+o[0]}else i.test(e)&&(t=e);return t},e.slotToTime=function(e){var t,r=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),n=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");return e=e.trim(),r.test(e)?t=e.trim()+":00":n.test(e)&&(t=e.split("-")[0].trim()+":00"),t},e.delay=function(e,t,r){return R(e)||R(t)?0:Math.round(Math.abs(be.DateTime.fromISO(e,{setZone:!0}).toUTC().diff(be.DateTime.fromISO(t,{setZone:!0}).toUTC(),[r])[r]))},e.round=function(e,t){if(void 0===t&&(t=0),"string"!=typeof e)return e;var r=be.DateTime.fromISO(e,{setZone:!0});return be.DateTime.fromMillis(Math.round(+r.toMillis()/t)*t).setZone(r.zone).toISO()},e.min=function(e){return e.reduce(function(e,t){return"string"!=typeof e||e>t?t:e},void 0)},e.max=function(e){return e.reduce(function(e,t){return void 0===e||e<t?t:e},void 0)},e.PERIOD_MAX_DATES=90,e.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},e}(),dt=function(){function e(){}return e.phone=function(e,t){if("string"==typeof e&&(e=e.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===t)){var r=new RegExp("(0[6-7][0-9]{8})","i").exec(e);if(null!==r&&r.length>0&&null!==r[0])return r[0]}},e}(),mt=function(){function e(){}return e.avg=function(t){if(0===t.length)return 0;var r=t.reduce(function(e,t){return e+t},0);return e.round(r/t.length,2)},e.applyVariation=function(e,t){return e*(e>=0?1+t/100:1-t/100)},e.median=function(t){if(0===t.length)return 0;if(1===t.length)return t[0];var r=t.sort(function(e,t){return e-t});return r.length%2==0?e.avg([r[r.length/2-1],r[r.length/2]]):r[Math.floor(r.length/2)]},e.percentage=function(e,t){if("number"==typeof e&&"number"==typeof t)return 0===t?0:e/t*100},e.round=function(e,t){return"number"!=typeof e?e:0===t?Math.round(e):Math.round(e*Math.pow(10,t))/Math.pow(10,t)},e.variation=function(e,t){var r=0;return 0!==t?r=0!==e?(t-e)/Math.abs(e)*100:100*(t>0?1:-1):0!==e&&(r=-100*(e>0?1:-1)),Math.floor(r)},e}(),ht=function(){function e(){}return e.compact=function(t,r){if(void 0===r&&(r={}),(0,h.isArray)(t)){var n=[];return t.forEach(function(t){t=e.compact(t,r),((0,h.isArray)(t)&&t.length>0||(0,h.isObject)(t)&&Object.keys(t).length>0||null!=t&&!(0,h.isArray)(t)&&!(0,h.isObject)(t))&&n.push(t)}),n}if((0,h.isObject)(t)){var i={};return Object.keys(t).forEach(function(n){var o=t[n];(0,h.isArray)(o)||(0,h.isObject)(o)?(o=e.compact(o,r),((0,h.isArray)(o)&&o.length>0||(0,h.isObject)(o)&&Object.keys(o).length>0||null!=o&&!(0,h.isArray)(o)&&!(0,h.isObject)(o))&&(i[n]=o)):null!=o&&("string"!=typeof o||!1===r.removeEmptyString||o.length>0)&&(i[n]=o)}),i}return"string"!=typeof t||!1===r.removeEmptyString||t.length>0?t:void 0},e}(),_t=function(){function e(){}return e.applyTaxes=function(e,t,r){void 0===r&&(r=2);var n=Number(e);return t.forEach(function(t){n+=Number(e)*t}),String(mt.round(n,r))},e.calculateTaxes=function(e,t){var r=0;return t.forEach(function(t){r+=e*t}),mt.round(r,2)},e.displayWithCurrency=function(t,r){if(null==t)return t;var n=e.currencies[r],i=t+" "+r;if(void 0!==n)switch(n.position){case"before":i=n.symbol+t;break;case"after":i=t+n.symbol}return i},e.format=function(e,t,r){if(void 0===r&&(r=2),null==e)return e;var n=Number(e.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:r,maximumFractionDigits:r});switch(t){case"fr":return n.replace(/\,/gi," ").replace(/\./gi,",");case"us":return n}},e.round=function(e,t){void 0===t&&(t=.1);var r=100*Number(e),n=100*t,i=r%n;return String(mt.round(r-i+(i<Math.ceil(n/2)?0:n),2)/100)},e.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},e}();return n})());
2
2
  //# sourceMappingURL=common-api.node.min.js.map