@onylab/common-api 2.0.6 → 2.0.8
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.
package/dist/common-api.d.ts
CHANGED
|
@@ -1929,6 +1929,7 @@ declare module "util/ExtractorUtil" {
|
|
|
1929
1929
|
}
|
|
1930
1930
|
declare module "util/MathUtil" {
|
|
1931
1931
|
export class MathUtil {
|
|
1932
|
+
static sum(values: number[]): number;
|
|
1932
1933
|
static avg(values: number[]): number;
|
|
1933
1934
|
static applyVariation(value: number, variation: number): number;
|
|
1934
1935
|
static median(values: number[]): number;
|
|
@@ -1,2 +1,2 @@
|
|
|
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 n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};n.r(r),n.d(r,{Api:()=>i,Constant:()=>o,Exception:()=>a,Http:()=>c,Service:()=>s,Template:()=>u,Tool:()=>l,Util:()=>f});var i={};n.r(i),n.d(i,{HubriseApi:()=>W,HubriseApiMockup:()=>v,HubriseAuthResource:()=>I,HubriseCurrencyCode:()=>B,HubriseEventType:()=>H,HubriseLocale:()=>G,HubriseOrderStatus:()=>F,HubriseResourceType:()=>K,HubriseRightAccess:()=>U,HubriseTimezoneId:()=>j});var o={};n.r(o),n.d(o,{Path:()=>Z});var a={};n.r(a),n.d(a,{BadParameterException:()=>z,BadRequestException:()=>X,ConflictException:()=>Q,DuplicateException:()=>te,ExternalApiException:()=>S,InternalException:()=>re,MainException:()=>E,NotImplementedException:()=>oe,ObjectNotFoundException:()=>ce,PageNotFoundException:()=>ue,UnauthorizedException:()=>R});var c={};n.r(c),n.d(c,{AuthenticationMiddleware:()=>fe,AuthorizationMiddleware:()=>pe,HandlerController:()=>le,Server:()=>Se});var s={};n.r(s),n.d(s,{EmailSenderService:()=>et,SmsSenderService:()=>De});var u={};n.r(u),n.d(u,{TemplateEngine:()=>Ye});var l={};n.r(l),n.d(l,{Configuration:()=>rt,Database:()=>ct,Displayer:()=>ut,Downloader:()=>lt,Env:()=>M,Environment:()=>C,FileSystem:()=>He,Logger:()=>k,Retry:()=>N});var f={};n.r(f),n.d(f,{AddressUtil:()=>ht,DateUtil:()=>_t,ExtractorUtil:()=>At,FormatterUtil:()=>mt,GeneratorUtil:()=>Be,MathUtil:()=>vt,ObjectUtil:()=>yt,PriceUtil:()=>gt,StringUtil:()=>dt,ValidatorUtil:()=>Pe,asyncForEach:()=>Le,isNullOrUndefined:()=>D,wait:()=>Ie});const p=require("nock");var d=n.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 n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},_(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 n(){this.constructor=e}_(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),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)(n(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)(n(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)(n(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)(n(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)(n(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)(n(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)(n(133)))},t.getOrder=function(e,r){void 0===e&&(e=1),void 0===r&&(r=!1);var i=(0,h.cloneDeep)(n(133));r&&(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)(n(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)(n(835)))},t.createWebhook=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/callback")?"/webhook":e}).post("/webhook").times(e).reply(200)},t.BASE_URL="http://api.hubrise.com",t}(m);const y=require("axios");var g=n.n(y),b=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),E=function(e){function t(n,r,i){var o=e.call(this,n)||this;return o.code=r,o.data=i,o.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,t):o.stack=new Error(n).stack,o}return b(t,e),t}(Error),w=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(e){function t(t,n){var r=e.call(this,t,502,n)||this;return r.name="ExternalApiException",r}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,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),R=function(e){function t(n,r){var i=e.call(this,n,t.ERROR_CODE,r)||this;return i.name="UnauthorizedException",i}return O(t,e),t.ERROR_CODE=401,t}(E),D=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(n){void 0!==t&&n.setExtra("extra",JSON.stringify(t)),T.captureMessage(e)})},e.warning=function(e,t){D(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(n){void 0!==t&&n.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&n.setExtra("data",JSON.stringify(e.data)),T.captureException(e)})},e.error=function(e,t){[R.ERROR_CODE].includes(e.code)||(D(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(n){void 0!==t&&n.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&n.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,n=arguments,i=function(e,t,n){var r;return void 0===t&&(t=2),function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=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 r=x.operation({retries:t,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise(function(t,i){r.attempt(function(){e().then(t).catch(function(e){r.retry(e)?"function"==typeof n&&n(e):i(e)})})})]})},new((r=void 0)||(r=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 n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,c)}s((i=i.apply(t,n||[])).next())});var t,n,r,i},e}();const L=require("querystring");var I,U,B,G,j,H,K,F,q=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},V=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},W=function(){function e(e){this.token=e}return e.prototype.authorize=function(t,n,r,i){return q(this,void 0,void 0,function(){return V(this,function(o){return[2,e.BASE_AUTH_URL+"authorize?redirect_uri="+String(i)+"&client_id="+t+"&scope="+String(n)+"["+String(Object.keys(r).reduce(function(e,t){return e.concat(t+"."+String(r[t]))},[]).join(","))+"],profile_with_email"]})})},e.prototype.getToken=function(t,n,r){return q(this,void 0,void 0,function(){var i,o=this;return V(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return q(o,void 0,void 0,function(){var o;return V(this,function(a){switch(a.label){case 0:return[4,g().post(e.BASE_AUTH_URL+"token",L.stringify({code:r,client_id:t,client_secret:n}),{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 q(this,void 0,void 0,function(){var t,n=this;return V(this,function(r){switch(r.label){case 0:return[4,N.request(function(){return q(n,void 0,void 0,function(){var n;return V(this,function(r){switch(r.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===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise user");return t=n.data,[2]}})})},1,k.error.bind(k))];case 1:return r.sent(),[2,t]}})})},e.prototype.getLocations=function(){return q(this,void 0,void 0,function(){var t,n=this;return V(this,function(r){switch(r.label){case 0:return[4,N.request(function(){return q(n,void 0,void 0,function(){var n;return V(this,function(r){switch(r.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===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise locations");return t=n.data,[2]}})})},1,k.error.bind(k))];case 1:return r.sent(),[2,t]}})})},e.prototype.createCustomer=function(t,n){return q(this,void 0,void 0,function(){var r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(this,function(i){switch(i.label){case 0:return[4,g().post(e.BASE_URL+"customer_lists/"+String(t)+"/customers",n,{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=i.sent())||void 0===r.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,n){return q(this,void 0,void 0,function(){var r,i=this;return V(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return q(i,void 0,void 0,function(){var i;return V(this,function(o){switch(o.label){case 0:return[4,g().get(e.BASE_URL+"customer_lists/"+String(t)+"/customers/"+String(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 retrieve hubrise customer");return r=i.data,[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2,r]}})})},e.prototype.getCustomers=function(t,n,r,i){return q(this,void 0,void 0,function(){var o,a,c=this;return V(this,function(s){switch(s.label){case 0:return(o=new URLSearchParams).append("private_ref",n),o.append("email",r),o.append("phone",i),[4,N.request(function(){return q(c,void 0,void 0,function(){var n;return V(this,function(r){switch(r.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===(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 s.sent(),[2,a]}})})},e.prototype.getCustomerLists=function(t){return q(this,void 0,void 0,function(){var n,r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(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===(r=i.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 i.sent(),[2,n]}})})},e.prototype.createOrder=function(t,n){return q(this,void 0,void 0,function(){var r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(this,function(i){switch(i.label){case 0:return[4,g().post(e.BASE_URL+"locations/"+String(t)+"/orders",n,{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=i.sent())||void 0===r.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,n){return q(this,void 0,void 0,function(){var r,i=this;return V(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return q(i,void 0,void 0,function(){var i;return V(this,function(o){switch(o.label){case 0:return[4,g().get(e.BASE_URL+"locations/"+String(t)+"/orders/"+String(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 retrieve hubrise order");return r=i.data,[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2,r]}})})},e.prototype.setOrderStatus=function(t,n,r){return q(this,void 0,void 0,function(){var i=this;return V(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return q(i,void 0,void 0,function(){var i;return V(this,function(o){switch(o.label){case 0:return[4,g().patch(e.BASE_URL+"locations/"+String(t)+"/orders/"+String(n),{status: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 update hubrise order status");return[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2]}})})},e.prototype.getCatalog=function(t){return q(this,void 0,void 0,function(){var n,r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(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===(r=i.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 i.sent(),[2,n]}})})},e.prototype.getCatalogs=function(t){return q(this,void 0,void 0,function(){var n,r=this;return V(this,function(i){switch(i.label){case 0:return n=[],[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(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===(r=i.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 i.sent(),[2,n]}})})},e.prototype.createWebhook=function(t,n){return q(this,void 0,void 0,function(){var r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(this,function(i){switch(i.label){case 0:return[4,g().post(e.BASE_URL+"/callback",{url:t,events:n},{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=i.sent())||void 0===r.data)throw new S("failed to create hubrise webhook");return[2]}})})},1,k.error.bind(k))];case 1:return i.sent(),[2]}})})},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.ORDERS="orders",e.CUSTOMER_LIST="customer_list",e.CATALOG="catalog",e.INVENTORY="inventory",e.ALL_CUSTOMER_LISTS="all_customer_lists",e.ALL_CATALOG_LISTS="all_catalogs"}(I||(I={})),function(e){e.READ="read",e.WRITE="write"}(U||(U={})),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"}(B||(B={})),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"}(G||(G={})),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"}(j||(j={})),function(e){e.CREATE="create",e.DELETE="delete",e.PATCH="patch",e.UPDATE="update"}(H||(H={})),function(e){e.CATALOG="catalog",e.CUSTOMER="customer",e.DELIVERY="delivery",e.INVENTORY="inventory",e.LOCATION="location",e.ORDER="order"}(K||(K={})),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"}(F||(F={}));var Z=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}(),J=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),z=function(e){function t(t,n){var r=e.call(this,t,400,n)||this;return r.name="BadParameterException",r}return J(t,e),t}(E),Y=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),X=function(e){function t(t,n){var r=e.call(this,t,400,n)||this;return r.name="BadRequestException",r}return Y(t,e),t}(E),$=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Q=function(e){function t(t,n){var r=e.call(this,t,409,n)||this;return r.name="ConflictException",r}return $(t,e),t}(E),ee=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),te=function(e){function t(t,n){var r=e.call(this,t,409,n)||this;return r.name="DuplicateException",r}return ee(t,e),t}(E),ne=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),re=function(e){function t(t,n){var r=e.call(this,t,500,n)||this;return r.name="InternalException",r}return ne(t,e),t}(E),ie=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),oe=function(e){function t(t,n){var r=e.call(this,t,501,n)||this;return r.name="NotImplementedException",r}return ie(t,e),t}(E),ae=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ce=function(e){function t(t,n){var r=e.call(this,t,404,n)||this;return r.name="ObjectNotFoundException",r}return ae(t,e),t}(E),se=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ue=function(e){function t(t,n){var r=e.call(this,t,404,n)||this;return r.name="PageNotFoundException",r}return se(t,e),t}(E),le=function(){function e(){}return e.error=function(e,t,n){k.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;t.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),t.json({code:n.code,message:n.message})},e}(),fe=function(){function e(e){this.configuration=e}return e.prototype.handler=function(){var e=this;return function(t,n,r){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 R("session is not well formatted");e.configuration.session.required.forEach(function(e){if(!o.includes(e))throw new R("session is incomplete")}),i=!0}if(i||void 0===e.configuration.none||(i=e.authNone(t)),!i)throw new R("request is not authenticate");r()}catch(e){le.error(t,n,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 R("api key is not well formatted");if(t[1]!==this.configuration.key.secret)throw new R("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 n;return null===(n=e.originalUrl)||void 0===n?void 0:n.startsWith(t)})||(e.session={},0))},e}(),pe=function(){function e(){}return e.prototype.can=function(e,t){},e}();const de=require("crypto"),me=require("express");var he=n.n(me);const _e=require("cors");var Ae=n.n(_e);const ve=require("compression");var ye=n.n(ve);const ge=require("helmet");var be=n.n(ge);const Ee=require("connect-timeout");var we=n.n(Ee),Se=function(){function e(){}return e.prototype.create=function(t,n){return r=this,i=void 0,a=function(){var r,i;return function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=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&&(r=n||e.DEFAULT_PORT,i="http://localhost:"+String(r),k.debug("start server on "+i),this.app=he()(),this.app.set("trust proxy",!0),this.app.use(ye()({level:-1})),this.app.use(we()("300s")),this.app.use((0,me.json)({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use((0,me.urlencoded)({limit:"10mb"})),this.app.use(Ae()({origin:[i].concat(t),credentials:!0})),this.app.use(be()()),this.app.use((0,me.json)()),this.app.listen(r,function(){k.debug("server is running on "+i)})),[2,this.app]})},new((o=void 0)||(o=Promise))(function(e,t){function n(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 r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o(function(e){e(r)})).then(n,c)}s((a=a.apply(r,i||[])).next())});var r,i,o,a},e.prototype.getSessionSecret=function(t){return de.createHash("sha1").update(t+e.SALT).digest("hex")},e.DEFAULT_PORT=8080,e.SALT="03561b4a0fe7f125025",e}();const Te=require("luxon");var Pe=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"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return t.test(e)||n.test(e)||r.test(e)},e.isNumber=function(e){return"number"==typeof e||"string"==typeof e&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(e)},e.isISODate=function(e){return!!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?([+-]\d{2}:\d{2}|Z)$/.test(e)&&!isNaN(new Date(e).getTime())},e}();const Me=require("iconv-lite");var Ce=function(){function e(){}return e.isUTF8=function(e){return!e||"utf8"===(e=e.toLowerCase())||"utf-8"===e},e.urlencode=function(t,n){if(!n||e.isUTF8(n))return encodeURIComponent(t);for(var r=(0,Me.encode)(t,n),i="",o="",a=0;a<r.length;a++)1===(o=r[a].toString(16)).length&&(o="0"+o),i+="%"+o;return i.toUpperCase()},e}(),Oe=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},Re=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},De=function(){function e(e,t){this.token=e,this.mode=t}return e.prototype.send=function(t,n,r){return Oe(this,arguments,void 0,function(t,n,r,i,o){var a,c=this;return void 0===i&&(i=!0),Re(this,function(s){switch(s.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(k.warning(new z("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*e.MESSAGE_MAX_LENGTH?n=n.substring(0,2*e.MESSAGE_MAX_LENGTH):n.length>e.MESSAGE_MAX_LENGTH&&n.length<=1.33*e.MESSAGE_MAX_LENGTH&&(n=n.substring(0,e.MESSAGE_MAX_LENGTH))),[4,N.request(function(){return Oe(c,void 0,void 0,function(){var r,c,s;return Re(this,function(u){switch(u.label){case 0:return r={accessToken:this.token,emetteur:t,message:Ce.urlencode(n,"ISO-8859-15"),numero:a.map(function(e){return e.replace("+","")}).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/e.MESSAGE_MAX_LENGTH)},i&&(r.stop=1),void 0!==o&&(r.date_envoi=Te.DateTime.fromISO(o,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),c=Te.DateTime.fromISO(null!=o?o:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),i?c.hour>=21?r.date_envoi=c.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):c.hour<9&&(r.date_envoi=c.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):c.hour<8&&(r.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:r}),[3,3]);case 1:return this.mode===M.DEVELOPMENT&&(a=["+15145705214"]),[4,g().post(e.BASE_API_URL+"sendSMS.do",L.stringify(r,"&","=",{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,r);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 Pe.isIntMobilePhone(e)})},e.BASE_API_URL="https://api.smsmode.com/http/1.6/",e.MESSAGE_MAX_LENGTH=150,e}();const ke=require("path"),xe=require("mustache"),Ne=require("fs");var Le=function(e,t){return n=void 0,r=void 0,o=function(){var n;return function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}(this,function(r){switch(r.label){case 0:n=0,r.label=1;case 1:return n<e.length?[4,t(e[n])]:[3,4];case 2:r.sent(),r.label=3;case 3:return n++,[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 n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,c)}s((o=o.apply(n,r||[])).next())});var n,r,i,o},Ie=function(e){return new Promise(function(t){return setTimeout(t,e)})};const Ue=require("color-name");var Be=function(){function e(){}return e.code=function(t){null==t&&(t=6);for(var n="";n.length<t;)n+=e.symbolUpperCases[e.int(0,e.symbolUpperCases.length-1)];return n},e.color=function(t){void 0===t&&(t=1);var n=e.rgbToHex(Math.round(255*t)),r="#000000"+n,i=Object.values(Ue);if(0===i.length)return r;var o=i[e.int(0,i.length-1)];return 3!==o.length?r:"#"+e.rgbToHex(o[0])+e.rgbToHex(o[1])+e.rgbToHex(o[2])+n},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 n="";n.length<t;)switch(e.int(1,3)){case 1:n+=e.symbolUpperCases[e.int(0,e.symbolUpperCases.length-1)];break;case 2:n+=e.symbolLowerCases[e.int(0,e.symbolLowerCases.length-1)];break;default:n+=String(e.int(0,9))}return n},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}(),Ge=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},je=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},He=function(){function e(){}return e.prototype.dirPath=function(e){var t=ke.resolve(e).lastIndexOf(ke.sep);return t<0?e:ke.resolve(ke.resolve(e).substr(0,t+1))+ke.sep},e.prototype.listFiles=function(e){return Ge(this,void 0,void 0,function(){var t,n,r,i=this;return je(this,function(o){switch(o.label){case 0:if(!this.isDir(e))throw new z(String(e)+" does not exist or is not a directory");return t=e.endsWith("/")?"":"/",n=Ne.readdirSync(e),r=[],[4,Le(n,function(n){return Ge(i,void 0,void 0,function(){return je(this,function(i){return this.isFile(e+t+n)&&r.push(e+t+n),[2]})})})];case 1:return o.sent(),[2,r]}})})},e.prototype.randomFile=function(e,t){return Ge(this,void 0,void 0,function(){var n,r;return je(this,function(i){switch(i.label){case 0:return[4,this.listFiles(e)];case 1:return 0===(n=i.sent()).length?[2,void 0]:(r=void 0!==t?Math.max(t,0)%n.length:Be.int(0,n.length-1),[2,n[r]])}})})},e.prototype.move=function(e,t){return Ge(this,void 0,void 0,function(){return je(this,function(n){if(!this.isFile(e))throw new z(String(e)+" does not exist or is not a file");if(Ne.mkdirSync(t,{recursive:!0}),!this.isDir(t))throw new z(String(t)+" does not exist or is not a directory");return[2,Ne.renameSync(e,t+ke.basename(e))]})})},e.prototype.read=function(e){return Ge(this,void 0,void 0,function(){return je(this,function(t){if(!this.isFile(e))throw new z(String(e)+" does not exist or is not a file");return[2,Ne.readFileSync(e,"utf8")]})})},e.prototype.readJson=function(e){return Ge(this,void 0,void 0,function(){var t;return je(this,function(n){switch(n.label){case 0:return[4,this.read(e)];case 1:if(t=n.sent(),!this.isJson(t))throw new z(String(e)+" does not contain JSON");return[2,JSON.parse(t)]}})})},e.prototype.readJsonFiles=function(e){return Ge(this,void 0,void 0,function(){var t,n,r,i=this;return je(this,function(o){switch(o.label){case 0:if(!this.isDir(e))throw new z(String(e)+" does not exist or is not a directory");return t=e.endsWith("/")?"":"/",n=Ne.readdirSync(e),r=[],[4,Le(n,function(n){return Ge(i,void 0,void 0,function(){var i,o,a;return je(this,function(c){switch(c.label){case 0:return this.isFile(e+t+n)&&n.endsWith(".json")?(o=(i=r).push,a={name:n},[4,this.readJson(e+t+n)]):[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,r]}})})},e.prototype.write=function(e,t){return Ge(this,void 0,void 0,function(){var n;return je(this,function(r){return"",n="string"==typeof t||"number"==typeof t?String(t):JSON.stringify(t),Ne.mkdirSync(this.dirPath(e),{recursive:!0}),Ne.writeFileSync(e,n,{encoding:"utf8"}),[2,Promise.resolve()]})})},e.prototype.writeJson=function(e,t){return Ge(this,void 0,void 0,function(){return je(this,function(n){return[2,this.write(e,JSON.stringify(t))]})})},e.prototype.isDir=function(e){return Ne.existsSync(e)&&Ne.statSync(e).isDirectory()},e.prototype.isFile=function(e){return Ne.existsSync(e)&&Ne.statSync(e).isFile()},e.prototype.isJson=function(e){try{return JSON.parse(e),!0}catch(e){return!1}},e}();const Ke=require("clean-css");var Fe=n.n(Ke);const qe=require("html-minifier-terser");var Ve=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},We=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},Ze=function(){function e(){}return e.prototype.css=function(e){return Ve(this,void 0,void 0,function(){return We(this,function(t){return[2,new(Fe())({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(e).styles]})})},e.prototype.html=function(e){return Ve(this,void 0,void 0,function(){return We(this,function(t){switch(t.label){case 0:return[4,(0,qe.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}(),Je=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},ze=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=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(){this.minifier=new Ze}return e.prototype.render=function(e,t,n){return Je(this,void 0,void 0,function(){var r,i,o,a,c,s=this;return ze(this,function(u){switch(u.label){case 0:return e.endsWith(".template")||(e+=".template"),r=(0,h.cloneDeep)(t),i=ke.isAbsolute(e)?"":__dirname+ke.sep,[4,(new He).read(i+e)];case 1:return o=u.sent(),a=[],(0,xe.parse)(o).forEach(function(e){e.length>=4&&"&"===e[0]&&e[1].startsWith("include:")&&a.push(e[1])}),a.length>0?(void 0===n?n=ke.dirname(i+e)+ke.sep:ke.isAbsolute(n)||(n=i+n),[4,Le(a,function(e){return Je(s,void 0,void 0,function(){var t,i,o,a;return ze(this,function(c){switch(c.label){case 0:return 3!==(t=e.split(":")).length||void 0===r[e]?[3,2]:(i=t[2],n.includes("/html")&&Object.keys(r[e]).forEach(function(t){r[e][t]=Array.isArray(r[e][t])?r[e][t].map(function(e){return e.replace(/(?:\r\n|\r|\n)/g,"<br>")}):r[e][t].replace(/(?:\r\n|\r|\n)/g,"<br>")}),o=r,a=e,[4,this.render(ke.resolve(n,i),r[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,xe.render)(o,r)).includes("{{")||c.includes("}}"))throw new Q("template: missing data to render template",{templatePath:e,data:t});return[2,e.includes("html")?this.minifier.html(c):c]}})})},e}();const Xe=require("node-mailjet");var $e=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},Qe=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},et=function(){function e(e,t,n){this.templateEngine=new Ye,this.mailjet=new Xe.Client({apiKey:e,apiSecret:t}),this.mode=n}return e.prototype.sendDeliveryDelay=function(e,t,n){return $e(this,void 0,void 0,function(){var r=this;return Qe(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return $e(r,void 0,void 0,function(){var r,i;return Qe(this,function(o){switch(o.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=o.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return i=o.sent(),[4,this.sendNotification(e,[{recipient:t,subject:n.base.subject,text:r,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,n){return $e(this,void 0,void 0,function(){var r=this;return Qe(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return $e(r,void 0,void 0,function(){var r,i,o,a;return Qe(this,function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return i=c.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return o=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:o,base:n.base})];case 4:return a=c.sent(),[4,this.sendNotification(e,[{recipient:t,subject:n.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,n){return $e(this,arguments,void 0,function(e,t,n,r,i){var o=this;return void 0===r&&(r=!0),Qe(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return $e(o,void 0,void 0,function(){var o,a,c,s;return Qe(this,function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return o=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:o,base:n.base,isCommercial:r})];case 2:return a=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return c=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:c,base:n.base,isCommercial:r})];case 4:return s=u.sent(),[4,this.sendNotification(e,[{recipient:t,subject:n.base.subject,text:a,html:s}],r,i)];case 5:return[2,u.sent()]}})})},0,k.error.bind(k))];case 1:return[2,a.sent()]}})})},e.prototype.sendUsersNotifications=function(e,t,n,r){return $e(this,void 0,void 0,function(){var i=this;return Qe(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return $e(i,void 0,void 0,function(){var i,o=this;return Qe(this,function(a){switch(a.label){case 0:return i=[],[4,Le(t,function(e){return $e(o,void 0,void 0,function(){var t,r,o,a;return Qe(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:n})];case 2:return r=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:n})];case 4:return a=c.sent(),i.push({recipient:e.recipient,subject:e.data.base.subject,text:r,html:a}),[2]}})})})];case 1:return a.sent(),[4,this.sendNotification(e,i,n,r)];case 2:return[2,a.sent()]}})})},0,k.error.bind(k))];case 1:return[2,o.sent()]}})})},e.prototype.sendDiscount=function(e,t,n){return $e(this,arguments,void 0,function(e,t,n,r,i){var o=this;return void 0===r&&(r=!0),Qe(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return $e(o,void 0,void 0,function(){var o,a,c,s;return Qe(this,function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return o=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:o,base:n.base,isCommercial:r})];case 2:return a=u.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return c=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:c,base:n.base,isCommercial:r})];case 4:return s=u.sent(),[4,this.sendNotification(e,[{recipient:t,subject:n.base.subject,text:a,html:s}],r,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 $e(this,arguments,void 0,function(e,t,n,r){var i=this;return void 0===n&&(n=!0),Qe(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return $e(i,void 0,void 0,function(){var i,o=this;return Qe(this,function(a){switch(a.label){case 0:return i=[],[4,Le(t,function(e){return $e(o,void 0,void 0,function(){var t,r,o,a;return Qe(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:n})];case 2:return r=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:n})];case 4:return a=c.sent(),i.push({recipient:e.recipient,subject:e.data.base.subject,text:r,html:a}),[2]}})})})];case 1:return a.sent(),[4,this.sendNotification(e,i,n,r)];case 2:return[2,a.sent()]}})})},0,k.error.bind(k))];case 1:return[2,o.sent()]}})})},e.prototype.sendNotification=function(e,t){return $e(this,arguments,void 0,function(e,t,n,r){var i,o,a=this;return void 0===n&&(n=!1),Qe(this,function(c){switch(c.label){case 0:if(0===t.length)throw new z("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,Le(t,function(t){return $e(a,void 0,void 0,function(){return Qe(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:n?0:2,customID:void 0===r?void 0:String(r)}),[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}(),tt=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},nt=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},rt=function(){function e(t,n){this.filesystem=new He,void 0!==e.root&&e.root===t||(e.root=t,e.config=void 0);var r=void 0===n?C.getMode():n;void 0!==e.environment&&e.environment===r||(e.environment=void 0===n?C.getMode():n,e.config=void 0)}return e.prototype.full=function(){return tt(this,void 0,void 0,function(){return nt(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 tt(this,void 0,void 0,function(){var t,n,r,i;return nt(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]),n=e,r=h.merge,i=[e.config],[4,this.filesystem.readJson(e.root+"data/config_"+String(e.environment)+".json")];case 4:return n.config=r.apply(void 0,i.concat([o.sent()])),[3,6];case 5:return o.sent(),[3,6];case 6:return[2]}})})},e}();const it=require("typeorm");var ot=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},at=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},ct=function(){function e(e){this.root=e}return e.prototype.connect=function(e,t){return ot(this,void 0,void 0,function(){var n,r;return at(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===(n=this.db[e])?[3,4]:(n.entities=t,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,it.createConnection)(n)]);case 3:return r.connection=i.sent(),[3,5];case 4:k.error(new z("bad connection name")),i.label=5;case 5:return[2]}})})},e.prototype.synchronize=function(){return ot(this,void 0,void 0,function(){return at(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 ot(this,void 0,void 0,function(){return at(this,function(e){return[2,this.connection.close()]})})},e.prototype.init=function(){return ot(this,void 0,void 0,function(){var e,t;return at(this,function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return e=new He,t=this,[4,e.readJson(this.root+"data/db.json")];case 2:t.db=n.sent(),n.label=3;case 3:return[2]}})})},e}();const st=require("prettyjson");var ut=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(st.render(e,{}))},e.prototype.success=function(e){k.trace(e)},e}(),lt=function(){function e(){this.fileSystem=new He}return e.prototype.image=function(e,t,n){return r=this,i=void 0,a=function(){var r,i;return function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=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===n&&(n=de.randomBytes(20).toString("hex")+ke.extname(e)),[4,this.fileSystem.write(t+ke.sep+n,"")];case 1:return o.sent(),r=ke.resolve(t+ke.sep+n),i=Ne.createWriteStream(r),[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(r)}),i.on("error",t)})]}})},new((o=void 0)||(o=Promise))(function(e,t){function n(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 r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o(function(e){e(r)})).then(n,c)}s((a=a.apply(r,i||[])).next())});var r,i,o,a},e}();const ft=require("fast-diff");var pt=n.n(ft),dt=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 n=3735928559^t,r=1103547991^t,i=0,o=void 0;i<e.length;i++)o=e.charCodeAt(i),n=Math.imul(n^o,2654435761),r=Math.imul(r^o,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")},e.nullable=function(e){return D(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,n){if("string"!=typeof t||"string"!=typeof n||0===n.length)return t;try{t=(t=t.replace(new RegExp(e.escapeRegExp(n),"ig"),"")).replace(new RegExp(e.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(e){}return t},e.replace=function(t,n,r){if("string"!=typeof t)return t;if(n.length!==r.length)return t;var i=t;return n.forEach(function(t,n){i=i.replace(new RegExp(e.escapeRegExp(t),"ig"),r[n])}),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 D(e)||e.length<=t?e:t<=3?"":e.slice(0,t-3)+"..."},e}(),mt=function(){function e(){}return e.trim=function(e){return"string"==typeof e?e.trim():e},e.capitalize=function(t){var n=e.lower(t);return"string"==typeof n?n.split(" ").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" "):t},e.ucfirst=function(t){var n=e.lower(t);return"string"==typeof n?n.charAt(0).toUpperCase()+n.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,n,r){if(void 0===r&&(r="int"),"string"==typeof t)switch(t=e.preformatPhone(t,n),r){case"nat":return e.phoneNat(t,n);case"int":return e.phoneInt(t,n)}return t},e.stripEmoji=function(e){var t=e;if("string"==typeof t)for(var r=n(16),i=void 0;null!==(i=r().exec(t));)try{t=(t=(t=t.replace(new RegExp(dt.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 n=0;e=e.split("").map(function(e){return e+(++n%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}(),ht=function(){function e(){}return e.autoCorrectCity=function(t){if(D(t)||"string"!=typeof t||0===t.length)return t;(t.toLowerCase().startsWith("st-")||t.toLowerCase().startsWith("st "))&&(t="Saint "+t.substring(3));var n=Object.values(e.ZIPCODE_CITY).flat(),r=n.find(function(e){return e.toLowerCase()===t.toLowerCase()});if(void 0!==r)return r;var i=n.find(function(n){var r=e.countDiff(t,n);return r.add<=2&&r.remove<=2});if(void 0!==i)return i;var o=n.find(function(e){return e.replace(/-/g," ").toLowerCase()===t.toLowerCase()});if(void 0!==o)return o;var a=n.find(function(n){var r=e.countDiff(t,n.replace(/-/g," "));return r.add<=2&&r.remove<=2});if(void 0!==a)return a;var c=n.find(function(e){return e.toLowerCase().startsWith(t.toLowerCase())});if(void 0!==c)return c;var s=n.find(function(e){return t.toLowerCase().includes(e.toLowerCase())});return void 0!==s?s:t},e.autoCorrectStreet=function(t){if(D(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 n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(t);return null!==n&&2===n.length&&(t=t.substring(n[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(!D(t))return Object.keys(e.ZIPCODE_CITY).reduce(function(n,r){return void 0!==e.ZIPCODE_CITY[r].find(function(e){return e.toLowerCase()===t.toLowerCase()})?r:n},void 0)},e.getCityFromZipCode=function(t,n){if(void 0!==t&&void 0!==n){var r,i=e.ZIPCODE_CITY[t];if(void 0!==i)return 1===i.length?i[0]:(n.split(",").forEach(function(e){r=i.find(function(t){return e.trim().toLowerCase()===t.trim().toLowerCase()})}),void 0!==r?r:i[0])}},e.isZipCode=function(t){return"string"==typeof t&&(!!Object.keys(e.ZIPCODE_CITY).includes(t)||Pe.isNumber(t)&&5===t.length&&!t.includes(".")&&!t.includes("-"))},e.parse=function(t,n){void 0===n&&(n=!0);var r={};if(!D(t)){var i=t.split(",");if(i.length>=3&&n){void 0===e.COUNTRIES.find(function(e){return t.toLowerCase().includes(" "+e.toLowerCase())})&&i.push("France");var o=i.length-1;if(r.country=i[o].trim(),i.splice(o--,1),void 0!==i[o]&&i[o].trim().includes(" ")){var a=i[o].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),i.splice(o--,1)}else isNaN(Number(i[o].trim()))?isNaN(Number(i[o-1].trim()))?(r.city=i[o].trim(),i.splice(o--,1)):(r.city=i[o].trim(),i.splice(o--,1),r.zip=i[o].trim(),i.splice(o--,1)):(r.zip=i[o].trim(),i.splice(o--,1),o>=2&&(r.city=i[o].trim(),i.splice(o--,1)));r.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)){r.zip=e;try{c=c.replace(new RegExp(dt.escapeRegExp(e),"ig"),"")}catch(e){}}}),Object.values(e.ZIPCODE_CITY).flat().forEach(function(t){var n;if(c.includes(t.toLowerCase())&&(void 0===r.zip||(null===(n=e.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find(function(e){return e.toLowerCase()===t.toLowerCase()})))){r.city=t;try{c=c.replace(new RegExp(dt.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())){r.country=e;try{c=c.replace(new RegExp(dt.escapeRegExp(" "+e),"ig"),"")}catch(e){}}}),void 0===r.street&&(r.street=(0,h.trim)(c.split(",").map(function(e){return e.trim()}).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=mt.lower(mt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=mt.upper(mt.trim(String(r.zip)))),void 0!==r.city&&(r.city=e.autoCorrectCity(mt.capitalize(mt.trim(String(r.city))))),void 0!==r.country&&(r.country=mt.capitalize(mt.trim(String(r.country)))),e.complete(r)},e.complete=function(t){if(void 0===t.city||0===t.city.length){var n=e.getCityFromZipCode(t.zip,t.street);void 0!==n&&(t.city=n)}return"string"==typeof t.street&&e.REGIONS.forEach(function(e){t.street=dt.removeText(t.street,e).trim()}),"fr"===mt.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 n={add:0,remove:0};return pt()(e.toLowerCase(),t.toLowerCase()).forEach(function(e){switch(e[0]){case-1:n.remove+=e[1].length;break;case 1:n.add+=e[1].length}}),n},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}(),_t=function(){function e(){}return e.getCycleDateFromFullDate=function(e,t){if("weekly"===t){var n=Te.DateTime.fromISO(e.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return e;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===t?Te.DateTime.fromISO(e).toFormat("yyyy-LL"):Te.DateTime.fromISO(e).toISODate()},e.displayWeekDay=function(t){var n="";return void 0!==e.WEEK_DAYS[t]&&(n=e.WEEK_DAYS[t]),n},e.generatePeriod=function(t,n,r,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=Te.DateTime.fromISO(t,{setZone:!0}).toISODate(),u=Te.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};s<=u&&l<o;){var p=e.getCycleDateFromFullDate(s,a);f[p]=(0,h.cloneDeep)(r),i&&(f[p].date=p),s=Te.DateTime.fromISO(s,{setZone:!0}).plus(c).toISODate(),l++}return f},e.getOpenPeriods=function(e,t){var n=[];return e.forEach(function(e){for(var r=[e],i=function(){var e=r[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)r.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)r.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?(r.push({from:e.from,to:a.from}),r.push({from:a.to,to:e.to})):n.push(e)}}}r.shift()};r.length>0;)i()}),n},e.limitDate=function(e,t,n){if(void 0===n&&(n=0),void 0!==e&&void 0!==t){var r=Te.DateTime.fromISO(e,{setZone:!0}).toISO(),i=Te.DateTime.fromISO(t,{setZone:!0}).plus({seconds:n}).toISO();return r>i?i:r}},e.localeToISO=function(e){var t,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),i=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(e))t=(o=e.split("/"))[2]+"-"+o[1]+"-"+o[0];else if(r.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,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 e=e.trim(),n.test(e)?t=e.trim()+":00":r.test(e)&&(t=e.split("-")[0].trim()+":00"),t},e.delay=function(e,t,n){return D(e)||D(t)?0:Math.round(Math.abs(Te.DateTime.fromISO(e,{setZone:!0}).toUTC().diff(Te.DateTime.fromISO(t,{setZone:!0}).toUTC(),[n])[n]))},e.round=function(e,t){if(void 0===t&&(t=0),"string"!=typeof e)return e;var n=Te.DateTime.fromISO(e,{setZone:!0});return Te.DateTime.fromMillis(Math.round(+n.toMillis()/t)*t).setZone(n.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}(),At=function(){function e(){}return e.phone=function(e,t){if("string"==typeof e&&(e=e.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===t)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(e);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},e}(),vt=function(){function e(){}return e.avg=function(t){if(0===t.length)return 0;var n=t.reduce(function(e,t){return e+t},0);return e.round(n/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 n=t.sort(function(e,t){return e-t});return n.length%2==0?e.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.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 n=0;return 0!==t?n=0!==e?(t-e)/Math.abs(e)*100:100*(t>0?1:-1):0!==e&&(n=-100*(e>0?1:-1)),Math.floor(n)},e}(),yt=function(){function e(){}return e.compact=function(t,n){if(void 0===n&&(n={}),(0,h.isArray)(t)){var r=[];return t.forEach(function(t){t=e.compact(t,n),((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))&&r.push(t)}),r}if((0,h.isObject)(t)){var i={};return Object.keys(t).forEach(function(r){var o=t[r];(0,h.isArray)(o)||(0,h.isObject)(o)?(o=e.compact(o,n),((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[r]=o)):null!=o&&("string"!=typeof o||!1===n.removeEmptyString||o.length>0)&&(i[r]=o)}),i}return"string"!=typeof t||!1===n.removeEmptyString||t.length>0?t:void 0},e}(),gt=function(){function e(){}return e.applyTaxes=function(e,t,n){void 0===n&&(n=2);var r=Number(e);return t.forEach(function(t){r+=Number(e)*t}),String(vt.round(r,n))},e.calculateTaxes=function(e,t){var n=0;return t.forEach(function(t){n+=e*t}),vt.round(n,2)},e.displayWithCurrency=function(t,n){if(null==t)return t;var r=e.currencies[n],i=t+" "+n;if(void 0!==r)switch(r.position){case"before":i=r.symbol+t;break;case"after":i=t+r.symbol}return i},e.format=function(e,t,n){if(void 0===n&&(n=2),null==e)return e;var r=Number(e.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:n,maximumFractionDigits:n});switch(t){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}},e.round=function(e,t){void 0===t&&(t=.1);var n=100*Number(e),r=100*t,i=n%r;return String(vt.round(n-i+(i<Math.ceil(r/2)?0:r),2)/100)},e.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},e}();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 n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};n.r(r),n.d(r,{Api:()=>i,Constant:()=>o,Exception:()=>a,Http:()=>c,Service:()=>s,Template:()=>u,Tool:()=>l,Util:()=>f});var i={};n.r(i),n.d(i,{HubriseApi:()=>W,HubriseApiMockup:()=>v,HubriseAuthResource:()=>I,HubriseCurrencyCode:()=>B,HubriseEventType:()=>H,HubriseLocale:()=>G,HubriseOrderStatus:()=>F,HubriseResourceType:()=>K,HubriseRightAccess:()=>U,HubriseTimezoneId:()=>j});var o={};n.r(o),n.d(o,{Path:()=>Z});var a={};n.r(a),n.d(a,{BadParameterException:()=>z,BadRequestException:()=>X,ConflictException:()=>Q,DuplicateException:()=>te,ExternalApiException:()=>S,InternalException:()=>re,MainException:()=>E,NotImplementedException:()=>oe,ObjectNotFoundException:()=>ce,PageNotFoundException:()=>ue,UnauthorizedException:()=>R});var c={};n.r(c),n.d(c,{AuthenticationMiddleware:()=>fe,AuthorizationMiddleware:()=>pe,HandlerController:()=>le,Server:()=>Se});var s={};n.r(s),n.d(s,{EmailSenderService:()=>et,SmsSenderService:()=>De});var u={};n.r(u),n.d(u,{TemplateEngine:()=>Ye});var l={};n.r(l),n.d(l,{Configuration:()=>rt,Database:()=>ct,Displayer:()=>ut,Downloader:()=>lt,Env:()=>M,Environment:()=>C,FileSystem:()=>He,Logger:()=>k,Retry:()=>N});var f={};n.r(f),n.d(f,{AddressUtil:()=>ht,DateUtil:()=>_t,ExtractorUtil:()=>At,FormatterUtil:()=>mt,GeneratorUtil:()=>Be,MathUtil:()=>vt,ObjectUtil:()=>yt,PriceUtil:()=>gt,StringUtil:()=>dt,ValidatorUtil:()=>Pe,asyncForEach:()=>Le,isNullOrUndefined:()=>D,wait:()=>Ie});const p=require("nock");var d=n.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 n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},_(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 n(){this.constructor=e}_(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),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)(n(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)(n(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)(n(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)(n(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)(n(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)(n(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)(n(133)))},t.getOrder=function(e,r){void 0===e&&(e=1),void 0===r&&(r=!1);var i=(0,h.cloneDeep)(n(133));r&&(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)(n(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)(n(835)))},t.createWebhook=function(e){void 0===e&&(e=1),d()(t.BASE_URL,{allowUnmocked:!1}).filteringPath(function(e){return e.includes("/callback")?"/webhook":e}).post("/webhook").times(e).reply(200)},t.BASE_URL="http://api.hubrise.com",t}(m);const y=require("axios");var g=n.n(y),b=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),E=function(e){function t(n,r,i){var o=e.call(this,n)||this;return o.code=r,o.data=i,o.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,t):o.stack=new Error(n).stack,o}return b(t,e),t}(Error),w=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(e){function t(t,n){var r=e.call(this,t,502,n)||this;return r.name="ExternalApiException",r}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,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),R=function(e){function t(n,r){var i=e.call(this,n,t.ERROR_CODE,r)||this;return i.name="UnauthorizedException",i}return O(t,e),t.ERROR_CODE=401,t}(E),D=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(n){void 0!==t&&n.setExtra("extra",JSON.stringify(t)),T.captureMessage(e)})},e.warning=function(e,t){D(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(n){void 0!==t&&n.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&n.setExtra("data",JSON.stringify(e.data)),T.captureException(e)})},e.error=function(e,t){[R.ERROR_CODE].includes(e.code)||(D(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(n){void 0!==t&&n.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&n.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,n=arguments,i=function(e,t,n){var r;return void 0===t&&(t=2),function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=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 r=x.operation({retries:t,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise(function(t,i){r.attempt(function(){e().then(t).catch(function(e){r.retry(e)?"function"==typeof n&&n(e):i(e)})})})]})},new((r=void 0)||(r=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 n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,c)}s((i=i.apply(t,n||[])).next())});var t,n,r,i},e}();const L=require("querystring");var I,U,B,G,j,H,K,F,q=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},V=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},W=function(){function e(e){this.token=e}return e.prototype.authorize=function(t,n,r,i){return q(this,void 0,void 0,function(){return V(this,function(o){return[2,e.BASE_AUTH_URL+"authorize?redirect_uri="+String(i)+"&client_id="+t+"&scope="+String(n)+"["+String(Object.keys(r).reduce(function(e,t){return e.concat(t+"."+String(r[t]))},[]).join(","))+"],profile_with_email"]})})},e.prototype.getToken=function(t,n,r){return q(this,void 0,void 0,function(){var i,o=this;return V(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return q(o,void 0,void 0,function(){var o;return V(this,function(a){switch(a.label){case 0:return[4,g().post(e.BASE_AUTH_URL+"token",L.stringify({code:r,client_id:t,client_secret:n}),{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 q(this,void 0,void 0,function(){var t,n=this;return V(this,function(r){switch(r.label){case 0:return[4,N.request(function(){return q(n,void 0,void 0,function(){var n;return V(this,function(r){switch(r.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===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise user");return t=n.data,[2]}})})},1,k.error.bind(k))];case 1:return r.sent(),[2,t]}})})},e.prototype.getLocations=function(){return q(this,void 0,void 0,function(){var t,n=this;return V(this,function(r){switch(r.label){case 0:return[4,N.request(function(){return q(n,void 0,void 0,function(){var n;return V(this,function(r){switch(r.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===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise locations");return t=n.data,[2]}})})},1,k.error.bind(k))];case 1:return r.sent(),[2,t]}})})},e.prototype.createCustomer=function(t,n){return q(this,void 0,void 0,function(){var r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(this,function(i){switch(i.label){case 0:return[4,g().post(e.BASE_URL+"customer_lists/"+String(t)+"/customers",n,{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=i.sent())||void 0===r.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,n){return q(this,void 0,void 0,function(){var r,i=this;return V(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return q(i,void 0,void 0,function(){var i;return V(this,function(o){switch(o.label){case 0:return[4,g().get(e.BASE_URL+"customer_lists/"+String(t)+"/customers/"+String(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 retrieve hubrise customer");return r=i.data,[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2,r]}})})},e.prototype.getCustomers=function(t,n,r,i){return q(this,void 0,void 0,function(){var o,a,c=this;return V(this,function(s){switch(s.label){case 0:return(o=new URLSearchParams).append("private_ref",n),o.append("email",r),o.append("phone",i),[4,N.request(function(){return q(c,void 0,void 0,function(){var n;return V(this,function(r){switch(r.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===(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 s.sent(),[2,a]}})})},e.prototype.getCustomerLists=function(t){return q(this,void 0,void 0,function(){var n,r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(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===(r=i.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 i.sent(),[2,n]}})})},e.prototype.createOrder=function(t,n){return q(this,void 0,void 0,function(){var r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(this,function(i){switch(i.label){case 0:return[4,g().post(e.BASE_URL+"locations/"+String(t)+"/orders",n,{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=i.sent())||void 0===r.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,n){return q(this,void 0,void 0,function(){var r,i=this;return V(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return q(i,void 0,void 0,function(){var i;return V(this,function(o){switch(o.label){case 0:return[4,g().get(e.BASE_URL+"locations/"+String(t)+"/orders/"+String(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 retrieve hubrise order");return r=i.data,[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2,r]}})})},e.prototype.setOrderStatus=function(t,n,r){return q(this,void 0,void 0,function(){var i=this;return V(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return q(i,void 0,void 0,function(){var i;return V(this,function(o){switch(o.label){case 0:return[4,g().patch(e.BASE_URL+"locations/"+String(t)+"/orders/"+String(n),{status: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 update hubrise order status");return[2]}})})},1,k.error.bind(k))];case 1:return o.sent(),[2]}})})},e.prototype.getCatalog=function(t){return q(this,void 0,void 0,function(){var n,r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(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===(r=i.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 i.sent(),[2,n]}})})},e.prototype.getCatalogs=function(t){return q(this,void 0,void 0,function(){var n,r=this;return V(this,function(i){switch(i.label){case 0:return n=[],[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(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===(r=i.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 i.sent(),[2,n]}})})},e.prototype.createWebhook=function(t,n){return q(this,void 0,void 0,function(){var r=this;return V(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return q(r,void 0,void 0,function(){var r;return V(this,function(i){switch(i.label){case 0:return[4,g().post(e.BASE_URL+"/callback",{url:t,events:n},{headers:{"X-Access-Token":this.token},timeout:e.TIMEOUT})];case 1:if(void 0===(r=i.sent())||void 0===r.data)throw new S("failed to create hubrise webhook");return[2]}})})},1,k.error.bind(k))];case 1:return i.sent(),[2]}})})},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.ORDERS="orders",e.CUSTOMER_LIST="customer_list",e.CATALOG="catalog",e.INVENTORY="inventory",e.ALL_CUSTOMER_LISTS="all_customer_lists",e.ALL_CATALOG_LISTS="all_catalogs"}(I||(I={})),function(e){e.READ="read",e.WRITE="write"}(U||(U={})),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"}(B||(B={})),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"}(G||(G={})),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"}(j||(j={})),function(e){e.CREATE="create",e.DELETE="delete",e.PATCH="patch",e.UPDATE="update"}(H||(H={})),function(e){e.CATALOG="catalog",e.CUSTOMER="customer",e.DELIVERY="delivery",e.INVENTORY="inventory",e.LOCATION="location",e.ORDER="order"}(K||(K={})),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"}(F||(F={}));var Z=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}(),J=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),z=function(e){function t(t,n){var r=e.call(this,t,400,n)||this;return r.name="BadParameterException",r}return J(t,e),t}(E),Y=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),X=function(e){function t(t,n){var r=e.call(this,t,400,n)||this;return r.name="BadRequestException",r}return Y(t,e),t}(E),$=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Q=function(e){function t(t,n){var r=e.call(this,t,409,n)||this;return r.name="ConflictException",r}return $(t,e),t}(E),ee=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),te=function(e){function t(t,n){var r=e.call(this,t,409,n)||this;return r.name="DuplicateException",r}return ee(t,e),t}(E),ne=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),re=function(e){function t(t,n){var r=e.call(this,t,500,n)||this;return r.name="InternalException",r}return ne(t,e),t}(E),ie=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),oe=function(e){function t(t,n){var r=e.call(this,t,501,n)||this;return r.name="NotImplementedException",r}return ie(t,e),t}(E),ae=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ce=function(e){function t(t,n){var r=e.call(this,t,404,n)||this;return r.name="ObjectNotFoundException",r}return ae(t,e),t}(E),se=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,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=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ue=function(e){function t(t,n){var r=e.call(this,t,404,n)||this;return r.name="PageNotFoundException",r}return se(t,e),t}(E),le=function(){function e(){}return e.error=function(e,t,n){k.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;t.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),t.json({code:n.code,message:n.message})},e}(),fe=function(){function e(e){this.configuration=e}return e.prototype.handler=function(){var e=this;return function(t,n,r){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 R("session is not well formatted");e.configuration.session.required.forEach(function(e){if(!o.includes(e))throw new R("session is incomplete")}),i=!0}if(i||void 0===e.configuration.none||(i=e.authNone(t)),!i)throw new R("request is not authenticate");r()}catch(e){le.error(t,n,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 R("api key is not well formatted");if(t[1]!==this.configuration.key.secret)throw new R("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 n;return null===(n=e.originalUrl)||void 0===n?void 0:n.startsWith(t)})||(e.session={},0))},e}(),pe=function(){function e(){}return e.prototype.can=function(e,t){},e}();const de=require("crypto"),me=require("express");var he=n.n(me);const _e=require("cors");var Ae=n.n(_e);const ve=require("compression");var ye=n.n(ve);const ge=require("helmet");var be=n.n(ge);const Ee=require("connect-timeout");var we=n.n(Ee),Se=function(){function e(){}return e.prototype.create=function(t,n){return r=this,i=void 0,a=function(){var r,i;return function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=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&&(r=n||e.DEFAULT_PORT,i="http://localhost:"+String(r),k.debug("start server on "+i),this.app=he()(),this.app.set("trust proxy",!0),this.app.use(ye()({level:-1})),this.app.use(we()("300s")),this.app.use((0,me.json)({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use((0,me.urlencoded)({limit:"10mb"})),this.app.use(Ae()({origin:[i].concat(t),credentials:!0})),this.app.use(be()()),this.app.use((0,me.json)()),this.app.listen(r,function(){k.debug("server is running on "+i)})),[2,this.app]})},new((o=void 0)||(o=Promise))(function(e,t){function n(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 r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o(function(e){e(r)})).then(n,c)}s((a=a.apply(r,i||[])).next())});var r,i,o,a},e.prototype.getSessionSecret=function(t){return de.createHash("sha1").update(t+e.SALT).digest("hex")},e.DEFAULT_PORT=8080,e.SALT="03561b4a0fe7f125025",e}();const Te=require("luxon");var Pe=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"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return t.test(e)||n.test(e)||r.test(e)},e.isNumber=function(e){return"number"==typeof e||"string"==typeof e&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(e)},e.isISODate=function(e){return!!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?([+-]\d{2}:\d{2}|Z)$/.test(e)&&!isNaN(new Date(e).getTime())},e}();const Me=require("iconv-lite");var Ce=function(){function e(){}return e.isUTF8=function(e){return!e||"utf8"===(e=e.toLowerCase())||"utf-8"===e},e.urlencode=function(t,n){if(!n||e.isUTF8(n))return encodeURIComponent(t);for(var r=(0,Me.encode)(t,n),i="",o="",a=0;a<r.length;a++)1===(o=r[a].toString(16)).length&&(o="0"+o),i+="%"+o;return i.toUpperCase()},e}(),Oe=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},Re=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},De=function(){function e(e,t){this.token=e,this.mode=t}return e.prototype.send=function(t,n,r){return Oe(this,arguments,void 0,function(t,n,r,i,o){var a,c=this;return void 0===i&&(i=!0),Re(this,function(s){switch(s.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(k.warning(new z("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*e.MESSAGE_MAX_LENGTH?n=n.substring(0,2*e.MESSAGE_MAX_LENGTH):n.length>e.MESSAGE_MAX_LENGTH&&n.length<=1.33*e.MESSAGE_MAX_LENGTH&&(n=n.substring(0,e.MESSAGE_MAX_LENGTH))),[4,N.request(function(){return Oe(c,void 0,void 0,function(){var r,c,s;return Re(this,function(u){switch(u.label){case 0:return r={accessToken:this.token,emetteur:t,message:Ce.urlencode(n,"ISO-8859-15"),numero:a.map(function(e){return e.replace("+","")}).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/e.MESSAGE_MAX_LENGTH)},i&&(r.stop=1),void 0!==o&&(r.date_envoi=Te.DateTime.fromISO(o,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),c=Te.DateTime.fromISO(null!=o?o:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),i?c.hour>=21?r.date_envoi=c.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):c.hour<9&&(r.date_envoi=c.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):c.hour<8&&(r.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:r}),[3,3]);case 1:return this.mode===M.DEVELOPMENT&&(a=["+15145705214"]),[4,g().post(e.BASE_API_URL+"sendSMS.do",L.stringify(r,"&","=",{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,r);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 Pe.isIntMobilePhone(e)})},e.BASE_API_URL="https://api.smsmode.com/http/1.6/",e.MESSAGE_MAX_LENGTH=150,e}();const ke=require("path"),xe=require("mustache"),Ne=require("fs");var Le=function(e,t){return n=void 0,r=void 0,o=function(){var n;return function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}(this,function(r){switch(r.label){case 0:n=0,r.label=1;case 1:return n<e.length?[4,t(e[n])]:[3,4];case 2:r.sent(),r.label=3;case 3:return n++,[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 n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,c)}s((o=o.apply(n,r||[])).next())});var n,r,i,o},Ie=function(e){return new Promise(function(t){return setTimeout(t,e)})};const Ue=require("color-name");var Be=function(){function e(){}return e.code=function(t){null==t&&(t=6);for(var n="";n.length<t;)n+=e.symbolUpperCases[e.int(0,e.symbolUpperCases.length-1)];return n},e.color=function(t){void 0===t&&(t=1);var n=e.rgbToHex(Math.round(255*t)),r="#000000"+n,i=Object.values(Ue);if(0===i.length)return r;var o=i[e.int(0,i.length-1)];return 3!==o.length?r:"#"+e.rgbToHex(o[0])+e.rgbToHex(o[1])+e.rgbToHex(o[2])+n},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 n="";n.length<t;)switch(e.int(1,3)){case 1:n+=e.symbolUpperCases[e.int(0,e.symbolUpperCases.length-1)];break;case 2:n+=e.symbolLowerCases[e.int(0,e.symbolLowerCases.length-1)];break;default:n+=String(e.int(0,9))}return n},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}(),Ge=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},je=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},He=function(){function e(){}return e.prototype.dirPath=function(e){var t=ke.resolve(e).lastIndexOf(ke.sep);return t<0?e:ke.resolve(ke.resolve(e).substr(0,t+1))+ke.sep},e.prototype.listFiles=function(e){return Ge(this,void 0,void 0,function(){var t,n,r,i=this;return je(this,function(o){switch(o.label){case 0:if(!this.isDir(e))throw new z(String(e)+" does not exist or is not a directory");return t=e.endsWith("/")?"":"/",n=Ne.readdirSync(e),r=[],[4,Le(n,function(n){return Ge(i,void 0,void 0,function(){return je(this,function(i){return this.isFile(e+t+n)&&r.push(e+t+n),[2]})})})];case 1:return o.sent(),[2,r]}})})},e.prototype.randomFile=function(e,t){return Ge(this,void 0,void 0,function(){var n,r;return je(this,function(i){switch(i.label){case 0:return[4,this.listFiles(e)];case 1:return 0===(n=i.sent()).length?[2,void 0]:(r=void 0!==t?Math.max(t,0)%n.length:Be.int(0,n.length-1),[2,n[r]])}})})},e.prototype.move=function(e,t){return Ge(this,void 0,void 0,function(){return je(this,function(n){if(!this.isFile(e))throw new z(String(e)+" does not exist or is not a file");if(Ne.mkdirSync(t,{recursive:!0}),!this.isDir(t))throw new z(String(t)+" does not exist or is not a directory");return[2,Ne.renameSync(e,t+ke.basename(e))]})})},e.prototype.read=function(e){return Ge(this,void 0,void 0,function(){return je(this,function(t){if(!this.isFile(e))throw new z(String(e)+" does not exist or is not a file");return[2,Ne.readFileSync(e,"utf8")]})})},e.prototype.readJson=function(e){return Ge(this,void 0,void 0,function(){var t;return je(this,function(n){switch(n.label){case 0:return[4,this.read(e)];case 1:if(t=n.sent(),!this.isJson(t))throw new z(String(e)+" does not contain JSON");return[2,JSON.parse(t)]}})})},e.prototype.readJsonFiles=function(e){return Ge(this,void 0,void 0,function(){var t,n,r,i=this;return je(this,function(o){switch(o.label){case 0:if(!this.isDir(e))throw new z(String(e)+" does not exist or is not a directory");return t=e.endsWith("/")?"":"/",n=Ne.readdirSync(e),r=[],[4,Le(n,function(n){return Ge(i,void 0,void 0,function(){var i,o,a;return je(this,function(c){switch(c.label){case 0:return this.isFile(e+t+n)&&n.endsWith(".json")?(o=(i=r).push,a={name:n},[4,this.readJson(e+t+n)]):[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,r]}})})},e.prototype.write=function(e,t){return Ge(this,void 0,void 0,function(){var n;return je(this,function(r){return"",n="string"==typeof t||"number"==typeof t?String(t):JSON.stringify(t),Ne.mkdirSync(this.dirPath(e),{recursive:!0}),Ne.writeFileSync(e,n,{encoding:"utf8"}),[2,Promise.resolve()]})})},e.prototype.writeJson=function(e,t){return Ge(this,void 0,void 0,function(){return je(this,function(n){return[2,this.write(e,JSON.stringify(t))]})})},e.prototype.isDir=function(e){return Ne.existsSync(e)&&Ne.statSync(e).isDirectory()},e.prototype.isFile=function(e){return Ne.existsSync(e)&&Ne.statSync(e).isFile()},e.prototype.isJson=function(e){try{return JSON.parse(e),!0}catch(e){return!1}},e}();const Ke=require("clean-css");var Fe=n.n(Ke);const qe=require("html-minifier-terser");var Ve=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},We=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},Ze=function(){function e(){}return e.prototype.css=function(e){return Ve(this,void 0,void 0,function(){return We(this,function(t){return[2,new(Fe())({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(e).styles]})})},e.prototype.html=function(e){return Ve(this,void 0,void 0,function(){return We(this,function(t){switch(t.label){case 0:return[4,(0,qe.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}(),Je=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},ze=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=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(){this.minifier=new Ze}return e.prototype.render=function(e,t,n){return Je(this,void 0,void 0,function(){var r,i,o,a,c,s=this;return ze(this,function(u){switch(u.label){case 0:return e.endsWith(".template")||(e+=".template"),r=(0,h.cloneDeep)(t),i=ke.isAbsolute(e)?"":__dirname+ke.sep,[4,(new He).read(i+e)];case 1:return o=u.sent(),a=[],(0,xe.parse)(o).forEach(function(e){e.length>=4&&"&"===e[0]&&e[1].startsWith("include:")&&a.push(e[1])}),a.length>0?(void 0===n?n=ke.dirname(i+e)+ke.sep:ke.isAbsolute(n)||(n=i+n),[4,Le(a,function(e){return Je(s,void 0,void 0,function(){var t,i,o,a;return ze(this,function(c){switch(c.label){case 0:return 3!==(t=e.split(":")).length||void 0===r[e]?[3,2]:(i=t[2],n.includes("/html")&&Object.keys(r[e]).forEach(function(t){r[e][t]=Array.isArray(r[e][t])?r[e][t].map(function(e){return e.replace(/(?:\r\n|\r|\n)/g,"<br>")}):r[e][t].replace(/(?:\r\n|\r|\n)/g,"<br>")}),o=r,a=e,[4,this.render(ke.resolve(n,i),r[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,xe.render)(o,r)).includes("{{")||c.includes("}}"))throw new Q("template: missing data to render template",{templatePath:e,data:t});return[2,e.includes("html")?this.minifier.html(c):c]}})})},e}();const Xe=require("node-mailjet");var $e=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},Qe=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},et=function(){function e(e,t,n){this.templateEngine=new Ye,this.mailjet=new Xe.Client({apiKey:e,apiSecret:t}),this.mode=n}return e.prototype.sendDeliveryDelay=function(e,t,n){return $e(this,void 0,void 0,function(){var r=this;return Qe(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return $e(r,void 0,void 0,function(){var r,i;return Qe(this,function(o){switch(o.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=o.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return i=o.sent(),[4,this.sendNotification(e,[{recipient:t,subject:n.base.subject,text:r,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,n){return $e(this,void 0,void 0,function(){var r=this;return Qe(this,function(i){switch(i.label){case 0:return[4,N.request(function(){return $e(r,void 0,void 0,function(){var r,i,o,a;return Qe(this,function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return i=c.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return o=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:o,base:n.base})];case 4:return a=c.sent(),[4,this.sendNotification(e,[{recipient:t,subject:n.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,n){return $e(this,arguments,void 0,function(e,t,n,r,i){var o=this;return void 0===r&&(r=!0),Qe(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return $e(o,void 0,void 0,function(){var o,a,c,s;return Qe(this,function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return o=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:o,base:n.base,isCommercial:r})];case 2:return a=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return c=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:c,base:n.base,isCommercial:r})];case 4:return s=u.sent(),[4,this.sendNotification(e,[{recipient:t,subject:n.base.subject,text:a,html:s}],r,i)];case 5:return[2,u.sent()]}})})},0,k.error.bind(k))];case 1:return[2,a.sent()]}})})},e.prototype.sendUsersNotifications=function(e,t,n,r){return $e(this,void 0,void 0,function(){var i=this;return Qe(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return $e(i,void 0,void 0,function(){var i,o=this;return Qe(this,function(a){switch(a.label){case 0:return i=[],[4,Le(t,function(e){return $e(o,void 0,void 0,function(){var t,r,o,a;return Qe(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:n})];case 2:return r=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:n})];case 4:return a=c.sent(),i.push({recipient:e.recipient,subject:e.data.base.subject,text:r,html:a}),[2]}})})})];case 1:return a.sent(),[4,this.sendNotification(e,i,n,r)];case 2:return[2,a.sent()]}})})},0,k.error.bind(k))];case 1:return[2,o.sent()]}})})},e.prototype.sendDiscount=function(e,t,n){return $e(this,arguments,void 0,function(e,t,n,r,i){var o=this;return void 0===r&&(r=!0),Qe(this,function(a){switch(a.label){case 0:return[4,N.request(function(){return $e(o,void 0,void 0,function(){var o,a,c,s;return Qe(this,function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return o=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:o,base:n.base,isCommercial:r})];case 2:return a=u.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return c=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:c,base:n.base,isCommercial:r})];case 4:return s=u.sent(),[4,this.sendNotification(e,[{recipient:t,subject:n.base.subject,text:a,html:s}],r,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 $e(this,arguments,void 0,function(e,t,n,r){var i=this;return void 0===n&&(n=!0),Qe(this,function(o){switch(o.label){case 0:return[4,N.request(function(){return $e(i,void 0,void 0,function(){var i,o=this;return Qe(this,function(a){switch(a.label){case 0:return i=[],[4,Le(t,function(e){return $e(o,void 0,void 0,function(){var t,r,o,a;return Qe(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:n})];case 2:return r=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:n})];case 4:return a=c.sent(),i.push({recipient:e.recipient,subject:e.data.base.subject,text:r,html:a}),[2]}})})})];case 1:return a.sent(),[4,this.sendNotification(e,i,n,r)];case 2:return[2,a.sent()]}})})},0,k.error.bind(k))];case 1:return[2,o.sent()]}})})},e.prototype.sendNotification=function(e,t){return $e(this,arguments,void 0,function(e,t,n,r){var i,o,a=this;return void 0===n&&(n=!1),Qe(this,function(c){switch(c.label){case 0:if(0===t.length)throw new z("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,Le(t,function(t){return $e(a,void 0,void 0,function(){return Qe(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:n?0:2,customID:void 0===r?void 0:String(r)}),[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}(),tt=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},nt=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},rt=function(){function e(t,n){this.filesystem=new He,void 0!==e.root&&e.root===t||(e.root=t,e.config=void 0);var r=void 0===n?C.getMode():n;void 0!==e.environment&&e.environment===r||(e.environment=void 0===n?C.getMode():n,e.config=void 0)}return e.prototype.full=function(){return tt(this,void 0,void 0,function(){return nt(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 tt(this,void 0,void 0,function(){var t,n,r,i;return nt(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]),n=e,r=h.merge,i=[e.config],[4,this.filesystem.readJson(e.root+"data/config_"+String(e.environment)+".json")];case 4:return n.config=r.apply(void 0,i.concat([o.sent()])),[3,6];case 5:return o.sent(),[3,6];case 6:return[2]}})})},e}();const it=require("typeorm");var ot=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},at=function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},ct=function(){function e(e){this.root=e}return e.prototype.connect=function(e,t){return ot(this,void 0,void 0,function(){var n,r;return at(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===(n=this.db[e])?[3,4]:(n.entities=t,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,it.createConnection)(n)]);case 3:return r.connection=i.sent(),[3,5];case 4:k.error(new z("bad connection name")),i.label=5;case 5:return[2]}})})},e.prototype.synchronize=function(){return ot(this,void 0,void 0,function(){return at(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 ot(this,void 0,void 0,function(){return at(this,function(e){return[2,this.connection.close()]})})},e.prototype.init=function(){return ot(this,void 0,void 0,function(){var e,t;return at(this,function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return e=new He,t=this,[4,e.readJson(this.root+"data/db.json")];case 2:t.db=n.sent(),n.label=3;case 3:return[2]}})})},e}();const st=require("prettyjson");var ut=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(st.render(e,{}))},e.prototype.success=function(e){k.trace(e)},e}(),lt=function(){function e(){this.fileSystem=new He}return e.prototype.image=function(e,t,n){return r=this,i=void 0,a=function(){var r,i;return function(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=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===n&&(n=de.randomBytes(20).toString("hex")+ke.extname(e)),[4,this.fileSystem.write(t+ke.sep+n,"")];case 1:return o.sent(),r=ke.resolve(t+ke.sep+n),i=Ne.createWriteStream(r),[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(r)}),i.on("error",t)})]}})},new((o=void 0)||(o=Promise))(function(e,t){function n(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 r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o(function(e){e(r)})).then(n,c)}s((a=a.apply(r,i||[])).next())});var r,i,o,a},e}();const ft=require("fast-diff");var pt=n.n(ft),dt=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 n=3735928559^t,r=1103547991^t,i=0,o=void 0;i<e.length;i++)o=e.charCodeAt(i),n=Math.imul(n^o,2654435761),r=Math.imul(r^o,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")},e.nullable=function(e){return D(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,n){if("string"!=typeof t||"string"!=typeof n||0===n.length)return t;try{t=(t=t.replace(new RegExp(e.escapeRegExp(n),"ig"),"")).replace(new RegExp(e.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(e){}return t},e.replace=function(t,n,r){if("string"!=typeof t)return t;if(n.length!==r.length)return t;var i=t;return n.forEach(function(t,n){i=i.replace(new RegExp(e.escapeRegExp(t),"ig"),r[n])}),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 D(e)||e.length<=t?e:t<=3?"":e.slice(0,t-3)+"..."},e}(),mt=function(){function e(){}return e.trim=function(e){return"string"==typeof e?e.trim():e},e.capitalize=function(t){var n=e.lower(t);return"string"==typeof n?n.split(" ").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" "):t},e.ucfirst=function(t){var n=e.lower(t);return"string"==typeof n?n.charAt(0).toUpperCase()+n.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,n,r){if(void 0===r&&(r="int"),"string"==typeof t)switch(t=e.preformatPhone(t,n),r){case"nat":return e.phoneNat(t,n);case"int":return e.phoneInt(t,n)}return t},e.stripEmoji=function(e){var t=e;if("string"==typeof t)for(var r=n(16),i=void 0;null!==(i=r().exec(t));)try{t=(t=(t=t.replace(new RegExp(dt.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 n=0;e=e.split("").map(function(e){return e+(++n%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}(),ht=function(){function e(){}return e.autoCorrectCity=function(t){if(D(t)||"string"!=typeof t||0===t.length)return t;(t.toLowerCase().startsWith("st-")||t.toLowerCase().startsWith("st "))&&(t="Saint "+t.substring(3));var n=Object.values(e.ZIPCODE_CITY).flat(),r=n.find(function(e){return e.toLowerCase()===t.toLowerCase()});if(void 0!==r)return r;var i=n.find(function(n){var r=e.countDiff(t,n);return r.add<=2&&r.remove<=2});if(void 0!==i)return i;var o=n.find(function(e){return e.replace(/-/g," ").toLowerCase()===t.toLowerCase()});if(void 0!==o)return o;var a=n.find(function(n){var r=e.countDiff(t,n.replace(/-/g," "));return r.add<=2&&r.remove<=2});if(void 0!==a)return a;var c=n.find(function(e){return e.toLowerCase().startsWith(t.toLowerCase())});if(void 0!==c)return c;var s=n.find(function(e){return t.toLowerCase().includes(e.toLowerCase())});return void 0!==s?s:t},e.autoCorrectStreet=function(t){if(D(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 n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(t);return null!==n&&2===n.length&&(t=t.substring(n[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(!D(t))return Object.keys(e.ZIPCODE_CITY).reduce(function(n,r){return void 0!==e.ZIPCODE_CITY[r].find(function(e){return e.toLowerCase()===t.toLowerCase()})?r:n},void 0)},e.getCityFromZipCode=function(t,n){if(void 0!==t&&void 0!==n){var r,i=e.ZIPCODE_CITY[t];if(void 0!==i)return 1===i.length?i[0]:(n.split(",").forEach(function(e){r=i.find(function(t){return e.trim().toLowerCase()===t.trim().toLowerCase()})}),void 0!==r?r:i[0])}},e.isZipCode=function(t){return"string"==typeof t&&(!!Object.keys(e.ZIPCODE_CITY).includes(t)||Pe.isNumber(t)&&5===t.length&&!t.includes(".")&&!t.includes("-"))},e.parse=function(t,n){void 0===n&&(n=!0);var r={};if(!D(t)){var i=t.split(",");if(i.length>=3&&n){void 0===e.COUNTRIES.find(function(e){return t.toLowerCase().includes(" "+e.toLowerCase())})&&i.push("France");var o=i.length-1;if(r.country=i[o].trim(),i.splice(o--,1),void 0!==i[o]&&i[o].trim().includes(" ")){var a=i[o].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),i.splice(o--,1)}else isNaN(Number(i[o].trim()))?isNaN(Number(i[o-1].trim()))?(r.city=i[o].trim(),i.splice(o--,1)):(r.city=i[o].trim(),i.splice(o--,1),r.zip=i[o].trim(),i.splice(o--,1)):(r.zip=i[o].trim(),i.splice(o--,1),o>=2&&(r.city=i[o].trim(),i.splice(o--,1)));r.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)){r.zip=e;try{c=c.replace(new RegExp(dt.escapeRegExp(e),"ig"),"")}catch(e){}}}),Object.values(e.ZIPCODE_CITY).flat().forEach(function(t){var n;if(c.includes(t.toLowerCase())&&(void 0===r.zip||(null===(n=e.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find(function(e){return e.toLowerCase()===t.toLowerCase()})))){r.city=t;try{c=c.replace(new RegExp(dt.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())){r.country=e;try{c=c.replace(new RegExp(dt.escapeRegExp(" "+e),"ig"),"")}catch(e){}}}),void 0===r.street&&(r.street=(0,h.trim)(c.split(",").map(function(e){return e.trim()}).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=mt.lower(mt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=mt.upper(mt.trim(String(r.zip)))),void 0!==r.city&&(r.city=e.autoCorrectCity(mt.capitalize(mt.trim(String(r.city))))),void 0!==r.country&&(r.country=mt.capitalize(mt.trim(String(r.country)))),e.complete(r)},e.complete=function(t){if(void 0===t.city||0===t.city.length){var n=e.getCityFromZipCode(t.zip,t.street);void 0!==n&&(t.city=n)}return"string"==typeof t.street&&e.REGIONS.forEach(function(e){t.street=dt.removeText(t.street,e).trim()}),"fr"===mt.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 n={add:0,remove:0};return pt()(e.toLowerCase(),t.toLowerCase()).forEach(function(e){switch(e[0]){case-1:n.remove+=e[1].length;break;case 1:n.add+=e[1].length}}),n},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}(),_t=function(){function e(){}return e.getCycleDateFromFullDate=function(e,t){if("weekly"===t){var n=Te.DateTime.fromISO(e.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return e;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===t?Te.DateTime.fromISO(e).toFormat("yyyy-LL"):Te.DateTime.fromISO(e).toISODate()},e.displayWeekDay=function(t){var n="";return void 0!==e.WEEK_DAYS[t]&&(n=e.WEEK_DAYS[t]),n},e.generatePeriod=function(t,n,r,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=Te.DateTime.fromISO(t,{setZone:!0}).toISODate(),u=Te.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};s<=u&&l<o;){var p=e.getCycleDateFromFullDate(s,a);f[p]=(0,h.cloneDeep)(r),i&&(f[p].date=p),s=Te.DateTime.fromISO(s,{setZone:!0}).plus(c).toISODate(),l++}return f},e.getOpenPeriods=function(e,t){var n=[];return e.forEach(function(e){for(var r=[e],i=function(){var e=r[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)r.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)r.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?(r.push({from:e.from,to:a.from}),r.push({from:a.to,to:e.to})):n.push(e)}}}r.shift()};r.length>0;)i()}),n},e.limitDate=function(e,t,n){if(void 0===n&&(n=0),void 0!==e&&void 0!==t){var r=Te.DateTime.fromISO(e,{setZone:!0}).toISO(),i=Te.DateTime.fromISO(t,{setZone:!0}).plus({seconds:n}).toISO();return r>i?i:r}},e.localeToISO=function(e){var t,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),i=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(e))t=(o=e.split("/"))[2]+"-"+o[1]+"-"+o[0];else if(r.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,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 e=e.trim(),n.test(e)?t=e.trim()+":00":r.test(e)&&(t=e.split("-")[0].trim()+":00"),t},e.delay=function(e,t,n){return D(e)||D(t)?0:Math.round(Math.abs(Te.DateTime.fromISO(e,{setZone:!0}).toUTC().diff(Te.DateTime.fromISO(t,{setZone:!0}).toUTC(),[n])[n]))},e.round=function(e,t){if(void 0===t&&(t=0),"string"!=typeof e)return e;var n=Te.DateTime.fromISO(e,{setZone:!0});return Te.DateTime.fromMillis(Math.round(+n.toMillis()/t)*t).setZone(n.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}(),At=function(){function e(){}return e.phone=function(e,t){if("string"==typeof e&&(e=e.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===t)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(e);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},e}(),vt=function(){function e(){}return e.sum=function(e){return 0===e.length?0:e.reduce(function(e,t){return e+t},0)},e.avg=function(t){var n=e.sum(t);return 0===n?0:e.round(n/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 n=t.sort(function(e,t){return e-t});return n.length%2==0?e.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.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 n=0;return 0!==t?n=0!==e?(t-e)/Math.abs(e)*100:100*(t>0?1:-1):0!==e&&(n=-100*(e>0?1:-1)),Math.floor(n)},e}(),yt=function(){function e(){}return e.compact=function(t,n){if(void 0===n&&(n={}),(0,h.isArray)(t)){var r=[];return t.forEach(function(t){t=e.compact(t,n),((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))&&r.push(t)}),r}if((0,h.isObject)(t)){var i={};return Object.keys(t).forEach(function(r){var o=t[r];(0,h.isArray)(o)||(0,h.isObject)(o)?(o=e.compact(o,n),((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[r]=o)):null!=o&&("string"!=typeof o||!1===n.removeEmptyString||o.length>0)&&(i[r]=o)}),i}return"string"!=typeof t||!1===n.removeEmptyString||t.length>0?t:void 0},e}(),gt=function(){function e(){}return e.applyTaxes=function(e,t,n){void 0===n&&(n=2);var r=Number(e);return t.forEach(function(t){r+=Number(e)*t}),String(vt.round(r,n))},e.calculateTaxes=function(e,t){var n=0;return t.forEach(function(t){n+=e*t}),vt.round(n,2)},e.displayWithCurrency=function(t,n){if(null==t)return t;var r=e.currencies[n],i=t+" "+n;if(void 0!==r)switch(r.position){case"before":i=r.symbol+t;break;case"after":i=t+r.symbol}return i},e.format=function(e,t,n){if(void 0===n&&(n=2),null==e)return e;var r=Number(e.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:n,maximumFractionDigits:n});switch(t){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}},e.round=function(e,t){void 0===t&&(t=.1);var n=100*Number(e),r=100*t,i=n%r;return String(vt.round(n-i+(i<Math.ceil(r/2)?0:r),2)/100)},e.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},e}();return r})());
|
|
2
2
|
//# sourceMappingURL=common-api.node.min.js.map
|