@onylab/common-api 0.1.234 → 1.1.0
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 +9 -5
- package/dist/common-api.node.min.js +1 -1
- package/dist/common-api.node.min.js.map +1 -1
- package/dist/data/email/element/html/fullimg.template +6 -6
- package/dist/data/email/element/html/img.template +8 -8
- package/dist/data/email/element/html/index.template +11 -11
- package/package.json +53 -57
package/dist/common-api.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="express" />
|
|
2
1
|
declare module "constant/Path" {
|
|
3
2
|
export class Path {
|
|
4
3
|
private static BASE_PATH;
|
|
@@ -189,9 +188,6 @@ declare module "tool/Logger" {
|
|
|
189
188
|
static info(message: string, extra?: any): void;
|
|
190
189
|
static warning(error: ExceptionContract, extra?: any): void;
|
|
191
190
|
static error(error: ExceptionContract, extra?: any): void;
|
|
192
|
-
static requestHandler(): any;
|
|
193
|
-
static tracingHandler(): any;
|
|
194
|
-
static errorHandler(): any;
|
|
195
191
|
}
|
|
196
192
|
}
|
|
197
193
|
declare module "http/HandlerController" {
|
|
@@ -265,7 +261,13 @@ declare module "util/ValidatorUtil" {
|
|
|
265
261
|
static isEmail(email: string): boolean;
|
|
266
262
|
static isPhone(phone: string): boolean;
|
|
267
263
|
static isIntMobilePhone(phone: string): boolean;
|
|
268
|
-
static isNumber(
|
|
264
|
+
static isNumber(num: string | number): boolean;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
declare module "util/UrlUtil" {
|
|
268
|
+
export class UrlUtil {
|
|
269
|
+
static isUTF8(charset: string): boolean;
|
|
270
|
+
static urlencode(str: string, charset: string): string;
|
|
269
271
|
}
|
|
270
272
|
}
|
|
271
273
|
declare module "service/sender/SmsSenderService" {
|
|
@@ -317,6 +319,7 @@ declare module "templating/view/email/ViewEmailElementBaseContract" {
|
|
|
317
319
|
name: string;
|
|
318
320
|
url: string;
|
|
319
321
|
logo: string;
|
|
322
|
+
email: string;
|
|
320
323
|
social: {
|
|
321
324
|
facebook: {
|
|
322
325
|
url: string;
|
|
@@ -331,6 +334,7 @@ declare module "templating/view/email/ViewEmailElementBaseContract" {
|
|
|
331
334
|
logo: string;
|
|
332
335
|
};
|
|
333
336
|
};
|
|
337
|
+
terms: string;
|
|
334
338
|
};
|
|
335
339
|
copyright?: {
|
|
336
340
|
year: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SmilePlayerCommon=e():t.SmilePlayerCommon=e()}(global,(function(){return(()=>{"use strict";var t={893:t=>{t.exports=require("emoji-regex")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{Constant:()=>t,Exception:()=>e,Http:()=>o,Service:()=>i,Template:()=>a,Tool:()=>u,Util:()=>s});var t={};n.r(t),n.d(t,{Path:()=>l});var e={};n.r(e),n.d(e,{BadParameterException:()=>d,BadRequestException:()=>v,ConflictException:()=>g,DuplicateException:()=>w,ExternalApiException:()=>S,InternalException:()=>O,MainException:()=>p,NotImplementedException:()=>_,ObjectNotFoundException:()=>P,PageNotFoundException:()=>A,UnauthorizedException:()=>j});var o={};n.r(o),n.d(o,{AuthenticationMiddleware:()=>U,AuthorizationMiddleware:()=>z,HandlerController:()=>H,Server:()=>$});var i={};n.r(i),n.d(i,{EmailSenderService:()=>Mt,SmsSenderService:()=>at});var a={};n.r(a),n.d(a,{TemplateEngine:()=>Tt});var u={};n.r(u),n.d(u,{Configuration:()=>jt,Database:()=>Lt,Displayer:()=>Ft,Downloader:()=>qt,Env:()=>L,Environment:()=>R,FileSystem:()=>mt,Logger:()=>q,Retry:()=>et});var s={};n.r(s),n.d(s,{AddressUtil:()=>Gt,DateUtil:()=>Wt,ExtractorUtil:()=>Zt,FormatterUtil:()=>zt,GeneratorUtil:()=>dt,MathUtil:()=>Bt,ObjectUtil:()=>Vt,PriceUtil:()=>Jt,StringUtil:()=>Ut,ValidatorUtil:()=>rt,asyncForEach:()=>ft,isNullOrUndefined:()=>F,wait:()=>pt});var c,l=function(){function t(){}return t.registerBasePath=function(e){void 0!==process.env.APP_HOME?t.BASE_PATH=process.env.APP_HOME+"/":t.BASE_PATH=e+(e.endsWith("/")?"":"/")},t.data=function(){return t.BASE_PATH+"data/"},t.db=function(){return t.storage()+"db/"},t.root=function(){return t.BASE_PATH},t.session=function(){return t.storage()+"session/"},t.storage=function(){return t.BASE_PATH+"storage/"},t.BASE_PATH="./",t}(),f=(c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),p=function(t){function e(n,r,o){var i=t.call(this,n)||this;return i.code=r,i.data=o,i.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,e):i.stack=new Error(n).stack,i}return f(e,t),e}(Error),h=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),d=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadParameterException",r}return h(e,t),e}(p),y=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return y(e,t),e}(p),m=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),g=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return m(e,t),e}(p),b=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),w=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="DuplicateException",r}return b(e,t),e}(p),E=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return E(e,t),e}(p),x=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),O=function(t){function e(e,n){var r=t.call(this,e,500,n)||this;return r.name="InternalException",r}return x(e,t),e}(p),T=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return T(e,t),e}(p),C=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return C(e,t),e}(p),M=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),A=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return M(e,t),e}(p),D=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),j=function(t){function e(n,r){var o=t.call(this,n,e.ERROR_CODE,r)||this;return o.name="UnauthorizedException",o}return D(e,t),e.ERROR_CODE=401,e}(p);const N=require("@sentry/node"),I=require("@sentry/tracing"),k=require("@sentry/integrations");var L;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(L||(L={}));var R=function(){function t(){}return t.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return L.DEVELOPMENT;case"prod":case"production":return L.PRODUCTION;case"test":return L.TEST}return void 0===process.env.APP_ID?L.DEVELOPMENT:L.PRODUCTION},t}(),F=function(t){return null==t},q=function(){function t(){}return t.init=function(t,e){R.getMode()===L.PRODUCTION&&N.init({dsn:t,integrations:[new k.CaptureConsole({levels:["error","warn","log"]}),new N.Integrations.Http({tracing:!0}),new I.Integrations.Express({app:e})],environment:R.getMode(),maxBreadcrumbs:50,tracesSampleRate:0,tracesSampler:function(t){var e,n;return"number"!=typeof(null===(e=t.transactionContext)||void 0===e?void 0:e.startTimestamp)||"number"!=typeof(null===(n=t.transactionContext)||void 0===n?void 0:n.endTimestamp)||(t.transactionContext.endTimestamp,t.transactionContext.startTimestamp),0}})},t.trace=function(t,e){[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.info(t):console.info(t,e):N.addBreadcrumb({category:"info",message:t,data:e,level:"info"})},t.debug=function(t,e){[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.log(t):console.log(t,e):N.addBreadcrumb({category:"debug",message:t,data:e,level:"debug"})},t.info=function(t,e){[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.info(t):console.info(t,e):N.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),N.captureMessage(t)}))},t.warning=function(t,e){F(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.warn(t):console.warn(t,e):N.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),N.captureException(t)}))},t.error=function(t,e){[j.ERROR_CODE].includes(t.code)||(F(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.error(t):console.error(t,e):N.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),N.captureException(t)})))},t.requestHandler=function(){return N.Handlers.requestHandler()},t.tracingHandler=function(){return N.Handlers.tracingHandler()},t.errorHandler=function(){return N.Handlers.errorHandler()},t}(),H=function(){function t(){}return t.error=function(t,e,n){q.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;e.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),e.json({code:n.code,message:n.message})},t}(),U=function(){function t(t){this.configuration=t}return t.prototype.handler=function(){var t=this;return function(e,n,r){try{var o=!1;if(o||void 0===t.configuration.jwt||(e.session={},o=!0),o||void 0===t.configuration.key||(o=t.authApiKey(e)),!o&&void 0!==t.configuration.session){var i=Object.keys(e.session);if(!Array.isArray(t.configuration.session.required))throw new j("session is not well formatted");t.configuration.session.required.forEach((function(t){if(!i.includes(t))throw new j("session is incomplete")})),o=!0}if(o||void 0===t.configuration.none||(o=t.authNone(e)),!o)throw new j("request is not authenticate");r()}catch(t){H.error(e,n,t)}}},t.prototype.authApiKey=function(t){if("string"!=typeof t.headers.Authorization||!t.headers.Authorization.startsWith("apiKey"))return!1;var e=t.headers.Authorization.split(" ");if(2!==e.length)throw new j("api key is not well formatted");if(e[1]!==this.configuration.key.secret)throw new j("api key is not valid");return t.session={},!0},t.prototype.authNone=function(t){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find((function(e){var n;return null===(n=t.originalUrl)||void 0===n?void 0:n.startsWith(e)}))||(t.session={},0))},t}(),z=function(){function t(){}return t.prototype.can=function(t,e){},t}();const G=require("crypto"),W=require("express"),Z=require("cors"),B=require("compression"),V=require("helmet"),J=require("connect-timeout");var $=function(){function t(){}return t.prototype.create=function(e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),q.debug("start server on "+o),this.app=W(),this.app.set("trust proxy",!0),this.app.use(B({level:-1})),this.app.use(J("300s")),this.app.use(W.json({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(W.urlencoded({limit:"10mb"})),this.app.use(Z({origin:[o].concat(e),credentials:!0})),this.app.use(V()),this.app.use(W.json()),this.app.listen(r,(function(){q.debug("server is running on "+o)}))),[2,this.app]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{s(a.next(t))}catch(t){e(t)}}function u(t){try{s(a.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}s((a=a.apply(r,o||[])).next())}));var r,o,i,a},t.prototype.getSessionSecret=function(e){return G.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const Y=require("axios");var X=n.n(Y);const K=require("luxon"),Q=require("querystring"),tt=require("retry");var et=function(){function t(){}return t.request=function(t,e,n){return void 0===e&&(e=2),r=this,o=void 0,a=function(){var r;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(o){return r=tt.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,o){r.attempt((function(){t().then(e).catch((function(t){r.retry(t)?"function"==typeof n&&n(t):o(t)}))}))}))]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{s(a.next(t))}catch(t){e(t)}}function u(t){try{s(a.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}s((a=a.apply(r,o||[])).next())}));var r,o,i,a},t}();const nt=require("urlencode");var rt=function(){function t(){}return t.isEmail=function(t){return"string"==typeof t&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(t)},t.isPhone=function(t){return"string"==typeof t&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(t)},t.isIntMobilePhone=function(t){var e=new RegExp("^\\+1[0-9]{10}$","i"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return e.test(t)||n.test(t)||r.test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}(),ot=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},it=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},at=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r,o,i){return void 0===o&&(o=!0),ot(this,void 0,void 0,(function(){var a,u=this;return it(this,(function(s){switch(s.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(q.warning(new d("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*t.MESSAGE_MAX_LENGTH?n=n.substring(0,2*t.MESSAGE_MAX_LENGTH):n.length>t.MESSAGE_MAX_LENGTH&&n.length<=1.33*t.MESSAGE_MAX_LENGTH&&(n=n.substring(0,t.MESSAGE_MAX_LENGTH))),[4,et.request((function(){return ot(u,void 0,void 0,(function(){var r,u,s;return it(this,(function(c){switch(c.label){case 0:return r={accessToken:this.token,emetteur:e,message:nt(n,"ISO-8859-15"),numero:a.map((function(t){return t.replace("+","")})).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/t.MESSAGE_MAX_LENGTH)},o&&(r.stop=1),void 0!==i&&(r.date_envoi=K.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),u=K.DateTime.fromISO(null!=i?i:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),o?u.hour>=21?r.date_envoi=u.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):u.hour<9&&(r.date_envoi=u.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):u.hour<8&&(r.date_envoi=u.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode!==L.TEST?[3,1]:(q.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===L.DEVELOPMENT&&(a=["+15145705214"]),[4,X().post(t.BASE_API_URL+"sendSMS.do",Q.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((s=c.sent()).data.length>0&&"0"!==s.data.trim().substring(0,1))throw new S("Error: "+s.data,r);c.label=3;case 3:return[2]}}))}))}),0,q.error.bind(q))]);case 1:return s.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return rt.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const ut=require("path"),st=require("mustache"),ct=require("lodash"),lt=require("fs");var ft=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(r){switch(r.label){case 0:n=0,r.label=1;case 1:return n<t.length?[4,e(t[n])]:[3,4];case 2:r.sent(),r.label=3;case 3:return n++,[3,1];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{s(i.next(t))}catch(t){e(t)}}function u(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}s((i=i.apply(n,r||[])).next())}));var n,r,o,i},pt=function(t){return new Promise((function(e){return setTimeout(e,t)}))};const ht=require("color-name");var dt=function(){function t(){}return t.code=function(e){null==e&&(e=6);for(var n="";n.length<e;)n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];return n},t.color=function(e){void 0===e&&(e=1);var n=t.rgbToHex(Math.round(255*e)),r="#000000"+n,o=Object.values(ht);if(0===o.length)return r;var i=o[t.int(0,o.length-1)];return 3!==i.length?r:"#"+t.rgbToHex(i[0])+t.rgbToHex(i[1])+t.rgbToHex(i[2])+n},t.rgbToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},t.int=function(t,e){return null==t&&(t=0),null==e&&(e=Number.POSITIVE_INFINITY),t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},t.password=function(e){null==e&&(e=8);for(var n="";n.length<e;)switch(t.int(1,3)){case 1:n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];break;case 2:n+=t.symbolLowerCases[t.int(0,t.symbolLowerCases.length-1)];break;default:n+=String(t.int(0,9))}return n},t.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],t.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"],t}(),yt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},vt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},mt=function(){function t(){}return t.prototype.dirPath=function(t){var e=ut.resolve(t).lastIndexOf(ut.sep);return e<0?t:ut.resolve(ut.resolve(t).substr(0,e+1))+ut.sep},t.prototype.listFiles=function(t){return yt(this,void 0,void 0,(function(){var e,n,r,o=this;return vt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new d(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=lt.readdirSync(t),r=[],[4,ft(n,(function(n){return yt(o,void 0,void 0,(function(){return vt(this,(function(o){return this.isFile(t+e+n)&&r.push(t+e+n),[2]}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.randomFile=function(t,e){return yt(this,void 0,void 0,(function(){var n,r;return vt(this,(function(o){switch(o.label){case 0:return[4,this.listFiles(t)];case 1:return 0===(n=o.sent()).length?[2,void 0]:(r=void 0!==e?Math.max(e,0)%n.length:dt.int(0,n.length-1),[2,n[r]])}}))}))},t.prototype.move=function(t,e){return yt(this,void 0,void 0,(function(){return vt(this,(function(n){if(!this.isFile(t))throw new d(String(t)+" does not exist or is not a file");if(lt.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new d(String(e)+" does not exist or is not a directory");return[2,lt.renameSync(t,e+ut.basename(t))]}))}))},t.prototype.read=function(t){return yt(this,void 0,void 0,(function(){return vt(this,(function(e){if(!this.isFile(t))throw new d(String(t)+" does not exist or is not a file");return[2,lt.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return yt(this,void 0,void 0,(function(){var e;return vt(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new d(String(t)+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.readJsonFiles=function(t){return yt(this,void 0,void 0,(function(){var e,n,r,o=this;return vt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new d(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=lt.readdirSync(t),r=[],[4,ft(n,(function(n){return yt(o,void 0,void 0,(function(){var o,i,a;return vt(this,(function(u){switch(u.label){case 0:return this.isFile(t+e+n)&&n.endsWith(".json")?(i=(o=r).push,a={name:n},[4,this.readJson(t+e+n)]):[3,2];case 1:i.apply(o,[(a.data=u.sent(),a)]),u.label=2;case 2:return[2]}}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.write=function(t,e){return yt(this,void 0,void 0,(function(){var n;return vt(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),lt.mkdirSync(this.dirPath(t),{recursive:!0}),lt.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return yt(this,void 0,void 0,(function(){return vt(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return lt.existsSync(t)&<.statSync(t).isDirectory()},t.prototype.isFile=function(t){return lt.existsSync(t)&<.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}();const gt=require("clean-css"),bt=require("html-minifier-terser");var wt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Et=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},St=function(){function t(){}return t.prototype.css=function(t){return wt(this,void 0,void 0,(function(){return Et(this,(function(e){return[2,new gt({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(t).styles]}))}))},t.prototype.html=function(t){return wt(this,void 0,void 0,(function(){return Et(this,(function(e){switch(e.label){case 0:return[4,(0,bt.minify)(t,{collapseBooleanAttributes:!0,collapseInlineTagWhitespace:!0,collapseWhitespace:!0,continueOnParseError:!1,decodeEntities:!1,html5:!0,minifyCSS:!0,minifyJS:!0,noNewlinesBeforeTagClose:!0,preserveLineBreaks:!1,preventAttributesEscaping:!1,processConditionalComments:!1,quoteCharacter:'"',removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeEmptyElements:!0,removeOptionalTags:!1,removeRedundantAttributes:!0,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeTagWhitespace:!1})];case 1:return[2,e.sent()]}}))}))},t}(),xt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Ot=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},Tt=function(){function t(){this.minifier=new St}return t.prototype.render=function(t,e,n){return xt(this,void 0,void 0,(function(){var r,o,i,a,u,s=this;return Ot(this,(function(c){switch(c.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,ct.cloneDeep)(e),o=ut.isAbsolute(t)?"":__dirname+ut.sep,[4,(new mt).read(o+t)];case 1:return i=c.sent(),a=[],(0,st.parse)(i).forEach((function(t){t.length>=4&&"&"===t[0]&&t[1].startsWith("include:")&&a.push(t[1])})),a.length>0?(void 0===n?n=ut.dirname(o+t)+ut.sep:ut.isAbsolute(n)||(n=o+n),[4,ft(a,(function(t){return xt(s,void 0,void 0,(function(){var e,o,i,a;return Ot(this,(function(u){switch(u.label){case 0:return 3!==(e=t.split(":")).length||void 0===r[t]?[3,2]:(o=e[2],n.includes("/html")&&Object.keys(r[t]).forEach((function(e){r[t][e]=Array.isArray(r[t][e])?r[t][e].map((function(t){return t.replace(/(?:\r\n|\r|\n)/g,"<br>")})):r[t][e].replace(/(?:\r\n|\r|\n)/g,"<br>")})),i=r,a=t,[4,this.render(ut.resolve(n,o),r[t])]);case 1:i[a]=u.sent(),u.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:c.sent(),c.label=3;case 3:if((u=(0,st.render)(i,r)).includes("{{")||u.includes("}}"))throw new g("template: missing data to render template",{templatePath:t,data:e});return[2,t.includes("html")?this.minifier.html(u):u]}}))}))},t}();const _t=require("node-mailjet");var Ct=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Pt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},Mt=function(){function t(t,e,n){this.templateEngine=new Tt,this.mailjet=_t.connect(t,e),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return Ct(this,void 0,void 0,(function(){var r=this;return Pt(this,(function(o){switch(o.label){case 0:return[4,et.request((function(){return Ct(r,void 0,void 0,(function(){var r,o;return Pt(this,(function(i){switch(i.label){case 0:return void 0===n.base.copyright&&(n.base.copyright={year:String((new Date).getUTCFullYear())}),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/text")];case 1:return r=i.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return o=i.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:r,html:o}],!1)];case 3:return[2,i.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return Ct(this,void 0,void 0,(function(){var r=this;return Pt(this,(function(o){switch(o.label){case 0:return[4,et.request((function(){return Ct(r,void 0,void 0,(function(){var r,o,i,a;return Pt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=u.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=u.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:o,html:a}],!1)];case 5:return[2,u.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n,r,o){return void 0===r&&(r=!0),Ct(this,void 0,void 0,(function(){var i=this;return Pt(this,(function(a){switch(a.label){case 0:return[4,et.request((function(){return Ct(i,void 0,void 0,(function(){var i,a,u,s;return Pt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return u=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return s=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:s}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendUsersNotifications=function(t,e,n,r){return Ct(this,void 0,void 0,(function(){var o=this;return Pt(this,(function(i){switch(i.label){case 0:return[4,et.request((function(){return Ct(o,void 0,void 0,(function(){var o,i=this;return Pt(this,(function(a){switch(a.label){case 0:return o=[],[4,ft(e,(function(t){return Ct(i,void 0,void 0,(function(){var e,r,i,a;return Pt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n,r,o){return void 0===r&&(r=!0),Ct(this,void 0,void 0,(function(){var i=this;return Pt(this,(function(a){switch(a.label){case 0:return[4,et.request((function(){return Ct(i,void 0,void 0,(function(){var i,a,u,s;return Pt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return u=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return s=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:s}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendDiscounts=function(t,e,n,r){return void 0===n&&(n=!0),Ct(this,void 0,void 0,(function(){var o=this;return Pt(this,(function(i){switch(i.label){case 0:return[4,et.request((function(){return Ct(o,void 0,void 0,(function(){var o,i=this;return Pt(this,(function(a){switch(a.label){case 0:return o=[],[4,ft(e,(function(t){return Ct(i,void 0,void 0,(function(){var e,r,i,a;return Pt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendNotification=function(t,e,n,r){return void 0===n&&(n=!1),Ct(this,void 0,void 0,(function(){var o,i,a=this;return Pt(this,(function(u){switch(u.label){case 0:if(0===e.length)throw new d("email: missing messages");u.label=1;case 1:return u.trys.push([1,6,,7]),this.mode!==L.TEST?[3,2]:(q.info("Simulation Mode: Email has been sent",{sender:t,recipients:e.map((function(t){return t.recipient}))}),[3,5]);case 2:return o=[],[4,ft(e,(function(e){return Ct(a,void 0,void 0,(function(){return Pt(this,(function(i){return this.mode===L.DEVELOPMENT&&(e.recipient.contact="developer@onylab.com"),o.push({From:{Name:t.name,Email:t.contact},To:[{Name:e.recipient.name,Email:e.recipient.contact}],Subject:e.subject,TextPart:e.text,HTMLPart:e.html,Priority:n?0:2,customID:void 0===r?void 0:String(r)}),[2]}))}))}))];case 3:return u.sent(),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:o})];case 4:u.sent(),u.label=5;case 5:return[3,7];case 6:throw i=u.sent(),new p(i.message,Number(i.statusCode));case 7:return[2]}}))}))},t}(),At=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Dt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},jt=function(){function t(e,n){this.filesystem=new mt,void 0!==t.root&&t.root===e||(t.root=e,t.config=void 0);var r=void 0===n?R.getMode():n;void 0!==t.environment&&t.environment===r||(t.environment=void 0===n?R.getMode():n,t.config=void 0)}return t.prototype.full=function(){return At(this,void 0,void 0,(function(){return Dt(this,(function(e){switch(e.label){case 0:return[4,this.init()];case 1:return e.sent(),[2,t.config]}}))}))},t.prototype.init=function(){return At(this,void 0,void 0,(function(){var e,n,r,o;return Dt(this,(function(i){switch(i.label){case 0:return void 0!==t.config?[3,6]:void 0!==t.root?[3,1]:(t.config={},[3,6]);case 1:return e=t,[4,this.filesystem.readJson(t.root+"data/config.json")];case 2:if(e.config=i.sent(),![L.DEVELOPMENT,L.TEST].includes(t.environment))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),n=t,r=ct.merge,o=[t.config],[4,this.filesystem.readJson(t.root+"data/config_"+String(t.environment)+".json")];case 4:return n.config=r.apply(void 0,o.concat([i.sent()])),[3,6];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))},t}();const Nt=require("typeorm");var It=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},kt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},Lt=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return It(this,void 0,void 0,(function(){var n,r;return kt(this,(function(o){switch(o.label){case 0:return void 0!==this.db?[3,2]:[4,this.init()];case 1:o.sent(),o.label=2;case 2:return void 0===(n=this.db[t])?[3,4]:(n.entities=e,n.logging=["error"],n.logger=!0,n.bigNumberStrings=!1,void 0===n.timezone&&(n.timezone="Z"),void 0===n.charset&&(n.charset="UTF8_GENERAL_CI"),r=this,[4,(0,Nt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:q.error(new d("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return It(this,void 0,void 0,(function(){return kt(this,(function(t){switch(t.label){case 0:return void 0===this.connection?[3,2]:[4,this.connection.synchronize()];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.close=function(){return It(this,void 0,void 0,(function(){return kt(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return It(this,void 0,void 0,(function(){var t,e;return kt(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new mt,e=this,[4,t.readJson(this.root+"data/db.json")];case 2:e.db=n.sent(),n.label=3;case 3:return[2]}}))}))},t}();const Rt=require("prettyjson");var Ft=function(){function t(){}return t.prototype.error=function(t){q.error(t)},t.prototype.info=function(t){q.trace(t)},t.prototype.json=function(t){q.trace(Rt.render(t,{}))},t.prototype.success=function(t){q.trace(t)},t}(),qt=function(){function t(){this.fileSystem=new mt}return t.prototype.image=function(t,e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(i){switch(i.label){case 0:return void 0===n&&(n=G.randomBytes(20).toString("hex")+ut.extname(t)),[4,this.fileSystem.write(e+ut.sep+n,"")];case 1:return i.sent(),r=ut.resolve(e+ut.sep+n),o=lt.createWriteStream(r),[4,X()({url:t,method:"GET",responseType:"stream"})];case 2:return i.sent().data.pipe(o),[2,new Promise((function(t,e){o.on("finish",(function(){return t(r)})),o.on("error",e)}))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{s(a.next(t))}catch(t){e(t)}}function u(t){try{s(a.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}s((a=a.apply(r,o||[])).next())}));var r,o,i,a},t}();const Ht=require("fast-diff");var Ut=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.hash=function(t,e){void 0===e&&(e=0);for(var n=3735928559^e,r=1103547991^e,o=0,i=void 0;o<t.length;o++)i=t.charCodeAt(o),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),((r^=Math.imul(n^n>>>13,3266489909))>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")},t.nullable=function(t){return F(t)||"string"==typeof t&&0===t.length?null:t},t.removeMultiSpaces=function(t){return"string"!=typeof t?t:t.replace(/\s{2,}/g," ")},t.removeText=function(e,n){if("string"!=typeof e||"string"!=typeof n||0===n.length)return e;try{e=(e=e.replace(new RegExp(t.escapeRegExp(n),"ig"),"")).replace(new RegExp(t.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(t){}return e},t.replace=function(e,n,r){if("string"!=typeof e)return e;if(n.length!==r.length)return e;var o=e;return n.forEach((function(e,n){o=o.replace(new RegExp(t.escapeRegExp(e),"ig"),r[n])})),o},t.slugify=function(t,e){return void 0===e&&(e=""),void 0===t?"":(0,ct.toLower)((0,ct.trim)((0,ct.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return F(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),zt=function(){function t(){}return t.trim=function(t){return"string"==typeof t?t.trim():t},t.capitalize=function(e){var n=t.lower(e);return"string"==typeof n?n.split(" ").map((function(t){return t.charAt(0).toUpperCase()+t.slice(1)})).join(" "):e},t.ucfirst=function(e){var n=t.lower(e);return"string"==typeof n?n.charAt(0).toUpperCase()+n.slice(1):e},t.lower=function(t){return"string"==typeof t?t.toLocaleLowerCase():t},t.upper=function(t){return"string"==typeof t?t.toLocaleUpperCase():t},t.phone=function(e,n,r){if(void 0===r&&(r="nat"),"string"==typeof e)switch(e=t.preformatPhone(e,n),r){case"nat":return t.phoneNat(e,n);case"int":return t.phoneInt(e,n)}return e},t.stripEmoji=function(t){var e=t;if("string"==typeof e)for(var r=n(893),o=void 0;null!==(o=r().exec(e));)try{e=(e=(e=e.replace(new RegExp(Ut.escapeRegExp(o[0]),"g"),"")).replace(new RegExp("\\s+","g")," ")).trim()}catch(t){}return e},t.stripExoticCharacters=function(t){return"string"==typeof t?t.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):t},t.preformatPhone=function(t,e){return t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e&&new RegExp("^[1-9]").test(t)&&9===t.length?"0"+t:t},t.phoneNat=function(t,e){if("fr"===e){if(t.startsWith("+330")?t=t.substring(3):t.startsWith("+33")?t="0"+t.substring(3):t.startsWith("0033")?t="0"+t.substring(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substring(2)),10===t.length){var n=0;t=t.split("").map((function(t){return t+(++n%2==0?" ":"")})).join("").trim()}return t}return t},t.phoneInt=function(t,e){return t.startsWith("+")?t:"fr"===e?(t.startsWith("0")&&(t=t.substring(1)),"+33"+t):t},t}(),Gt=function(){function t(){}return t.autoCorrectCity=function(e){if(F(e)||"string"!=typeof e||0===e.length)return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));var n=t.CITIES.find((function(t){return t.toLowerCase()===e.toLowerCase()}));if(void 0!==n)return n;var r=t.CITIES.find((function(n){var r=t.countDiff(e,n);return r.add<=2&&r.remove<=2}));if(void 0!==r)return r;var o=t.CITIES.find((function(t){return t.replace(/-/g," ").toLowerCase()===e.toLowerCase()}));if(void 0!==o)return o;var i=t.CITIES.find((function(n){var r=t.countDiff(e,n.replace(/-/g," "));return r.add<=2&&r.remove<=2}));if(void 0!==i)return i;var a=t.CITIES.find((function(t){return t.toLowerCase().startsWith(e.toLowerCase())}));if(void 0!==a)return a;var u=t.CITIES.find((function(t){return e.toLowerCase().includes(t.toLowerCase())}));return void 0!==u?u:e},t.autoCorrectStreet=function(e){if(F(e)||"string"!=typeof e||0===e.length)return e;t.STREET_TYPE.forEach((function(t){t.short.length<t.long.length&&(e=(e=e.replace(new RegExp("(\\s"+String(t.short)+"\\.?\\s)","ig")," "+String(t.long)+" ")).replace(new RegExp("(\\s"+String(t.short)+"\\.\\s)","ig")," "+String(t.long)+" "))}));var n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==n&&2===n.length&&(e=e.substring(n[1].length)),t.STREET_TYPE.forEach((function(t){e=(e=e.replace(new RegExp("([0-9]+)("+String(t.long)+"\\s)","ig"),"$1 $2")).replace(new RegExp("([0-9]+)("+String(t.short)+"\\.?\\s)","ig"),"$1 "+String(t.long)+" ")})),e},t.getZipCodeFromCity=function(e){if(!F(e))return Object.keys(t.ZIPCODE_CITY).reduce((function(n,r){return void 0!==t.ZIPCODE_CITY[r].find((function(t){return t.toLowerCase()===e.toLowerCase()}))?r:n}),void 0)},t.getCityFromZipCode=function(e,n){if(void 0!==e&&void 0!==n){var r,o=t.ZIPCODE_CITY[e];if(void 0!==o)return 1===o.length?o[0]:(n.split(",").forEach((function(t){r=o.find((function(e){return t.trim().toLowerCase()===e.trim().toLowerCase()}))})),void 0!==r?r:o[0])}},t.isZipCode=function(e){return"string"==typeof e&&(!!t.ZIPCODES.includes(e)||rt.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!F(e)){var o=e.split(",");if(o.length>=3&&n){void 0===t.COUNTRIES.find((function(t){return e.toLowerCase().includes(" "+t.toLowerCase())}))&&o.push("France");var i=o.length-1;if(r.country=o[i].trim(),o.splice(i--,1),void 0!==o[i]&&o[i].trim().includes(" ")){var a=o[i].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),o.splice(i--,1)}else isNaN(Number(o[i].trim()))?isNaN(Number(o[i-1].trim()))?(r.city=o[i].trim(),o.splice(i--,1)):(r.city=o[i].trim(),o.splice(i--,1),r.zip=o[i].trim(),o.splice(i--,1)):(r.zip=o[i].trim(),o.splice(i--,1),i>=2&&(r.city=o[i].trim(),o.splice(i--,1)));r.street=o.map((function(t){return t.trim()})).join(" ").trim()}else{var u=e.toLowerCase();t.ZIPCODES.forEach((function(t){if(u.includes(t)){r.zip=t;try{u=u.replace(new RegExp(Ut.escapeRegExp(t),"ig"),"")}catch(t){}}})),t.CITIES.forEach((function(e){var n;if(u.includes(e.toLowerCase())&&(void 0===r.zip||(null===(n=t.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find((function(t){return t.toLowerCase()===e.toLowerCase()}))))){r.city=e;try{u=u.replace(new RegExp(Ut.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(u.includes(" "+t.toLowerCase())&&!u.includes("de "+t.toLowerCase())&&!u.includes("de la "+t.toLowerCase())){r.country=t;try{u=u.replace(new RegExp(Ut.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=(0,ct.trim)(u.split(",").map((function(t){return t.trim()})).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=zt.lower(zt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=zt.upper(zt.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(zt.capitalize(zt.trim(String(r.city))))),void 0!==r.country&&(r.country=zt.capitalize(zt.trim(String(r.country)))),t.complete(r)},t.complete=function(e){if(void 0===e.city||0===e.city.length){var n=t.getCityFromZipCode(e.zip,e.street);void 0!==n&&(e.city=n)}return"string"==typeof e.street&&t.REGIONS.forEach((function(t){e.street=Ut.removeText(e.street,t).trim()})),"fr"===zt.lower(e.country)&&(e.country="France"),e},t.removeDuplicates=function(t){if("string"!=typeof t)return t;var e=[];return t.split(",").forEach((function(t){void 0===e.find((function(e){return e.trim().toLowerCase().includes(t.trim().toLowerCase())}))&&e.push(t)})),e.join(",")},t.countDiff=function(t,e){var n={add:0,remove:0};return Ht(t.toLowerCase(),e.toLowerCase()).forEach((function(t){switch(t[0]){case-1:n.remove+=t[1].length;break;case 1:n.add+=t[1].length}})),n},t.ZIPCODES=["78500","78600","78800","95240","95530","78630","78670","78240","78580","78300","78955","78260","95150","95250","95480","95320","95550","95370","95740","95220","95870","78420","78400","78110","78360","78290","78230","78540","78920","95600"],t.CITIES=["Sartrouville","Cormeilles-en-Parisis","Houilles","Maisons-Laffitte","La Frette-sur-Seine","Argenteuil","Montesson","Le Mesnil-le-Roi","Bezons","Orgeval","Poissy","Morainvilliers","Villennes-sur-Seine","Medan","Chambourcy","Aigremont","Les Alluets-le-Roi","Carrières-sous-Poissy","Achères","Taverny","Beauchamp","Pierrelaye","Saint-Leu-la-Forêt","Bessancourt","Montigny-lès-Cormeilles","Herblay","Méry-sur-Oise","Carrières-sur-Seine","Bezons","Chatou","Le Vésinet","Montesson","Croissy","Croissy-sur-Seine","Le Pecq","Vernouillet","Ecquevilly"],t.ZIPCODE_CITY={78500:["Sartrouville"],78600:["Maisons-Laffitte","Le Mesnil-le-Roi"],78800:["Houilles"],95240:["Cormeilles-en-Parisis"],95530:["La Frette-sur-Seine"],78100:["Saint-Germain-en-Laye"],95100:["Argenteuil"],78630:["Orgeval","Morainvilliers"],78670:["Villennes-sur-Seine","Medan"],78240:["Chambourcy","Aigremont"],78300:["Poissy"],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-les-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"],78230:["Le Pecq"],95600:["Eaubonne"]},t.REGIONS=["île-de-france"],t.COUNTRIES=["France","FR"],t.STREET_TYPE=[{short:"av",long:"avenue"},{short:"rue",long:"rue"},{short:"bd",long:"boulevard"},{short:"chau",long:"chaussée"},{short:"trav",long:"traverse"},{short:"pl",long:"place"},{short:"pass",long:"passage"},{short:"sent",long:"sentier"},{short:"imp",long:"impasse"},{short:"all",long:"allée"},{short:"chem",long:"chemin"},{short:"ham",long:"hameau"},{short:"dom",long:"domaine"}],t}(),Wt=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=K.DateTime.fromISO(t.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return t;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===e?K.DateTime.fromISO(t).toFormat("yyyy-LL"):K.DateTime.fromISO(t).toISODate()},t.displayWeekDay=function(e){var n="";return void 0!==t.WEEK_DAYS[e]&&(n=t.WEEK_DAYS[e]),n},t.generatePeriod=function(e,n,r,o,i,a){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES),void 0===a&&(a="daily");for(var u={daily:{day:1},weekly:{week:1},monthly:{month:1}}[a],s=K.DateTime.fromISO(e,{setZone:!0}).toISODate(),c=K.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};s<=c&&l<i;){var p=t.getCycleDateFromFullDate(s,a);f[p]=(0,ct.cloneDeep)(r),o&&(f[p].date=p),s=K.DateTime.fromISO(s,{setZone:!0}).plus(u).toISODate(),l++}return f},t.getOpenPeriods=function(t,e){var n=[];return t.forEach((function(t){for(var r=[t],o=function(){var t=r[0];if(void 0===e.find((function(e){return e.from<=t.from&&t.to<=e.to}))){var o=e.find((function(e){return e.from<=t.from&&t.from<e.to&&e.to<t.to}));if(void 0!==o)r.push({from:o.to,to:t.to});else{var i=e.find((function(e){return t.from<e.from&&t.to>e.from&&t.to<=e.to}));if(void 0!==i)r.push({from:t.from,to:i.from});else{var a=e.find((function(e){return t.from<e.from&&e.to<t.to}));void 0!==a?(r.push({from:t.from,to:a.from}),r.push({from:a.to,to:t.to})):n.push(t)}}}r.shift()};r.length>0;)o()})),n},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=K.DateTime.fromISO(t,{setZone:!0}).toISO(),o=K.DateTime.fromISO(e,{setZone:!0}).plus({seconds:n}).toISO();return r>o?o:r}},t.localeToISO=function(t){var e,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),o=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(t))e=(i=t.split("/"))[2]+"-"+i[1]+"-"+i[0];else if(r.test(t)){var i;e=(i=t.split("-"))[2]+"-"+i[1]+"-"+i[0]}else o.test(t)&&(e=t);return e},t.slotToTime=function(t){var e,n=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),r=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");return t=t.trim(),n.test(t)?e=t.trim()+":00":r.test(t)&&(e=t.split("-")[0].trim()+":00"),e},t.delay=function(t,e,n){return F(t)||F(e)?0:Math.round(Math.abs(K.DateTime.fromISO(t,{setZone:!0}).toUTC().diff(K.DateTime.fromISO(e,{setZone:!0}).toUTC(),[n])[n]))},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=K.DateTime.fromISO(t,{setZone:!0});return K.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.min=function(t){return t.reduce((function(t,e){return"string"!=typeof t||t>e?e:t}),void 0)},t.max=function(t){return t.reduce((function(t,e){return void 0===t||t<e?e:t}),void 0)},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Zt=function(){function t(){}return t.phone=function(t,e){if("string"==typeof t&&(t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(t);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},t}(),Bt=function(){function t(){}return t.avg=function(e){if(0===e.length)return 0;var n=e.reduce((function(t,e){return t+e}),0);return t.round(n/e.length,2)},t.applyVariation=function(t,e){return t*(t>=0?1+e/100:1-e/100)},t.median=function(e){if(0===e.length)return 0;if(1===e.length)return e[0];var n=e.sort((function(t,e){return t-e}));return n.length%2==0?t.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.length/2)]},t.percentage=function(t,e){if("number"==typeof t&&"number"==typeof e)return 0===e?0:t/e*100},t.round=function(t,e){return"number"!=typeof t?t:0===e?Math.round(t):Math.round(t*Math.pow(10,e))/Math.pow(10,e)},t.variation=function(t,e){var n=0;return 0!==e?n=0!==t?(e-t)/Math.abs(t)*100:100*(e>0?1:-1):0!==t&&(n=-100*(t>0?1:-1)),Math.floor(n)},t}(),Vt=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,ct.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,ct.isArray)(e)&&e.length>0||(0,ct.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,ct.isArray)(e)&&!(0,ct.isObject)(e))&&r.push(e)})),r}if((0,ct.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,ct.isArray)(i)||(0,ct.isObject)(i)?(i=t.compact(i,n),((0,ct.isArray)(i)&&i.length>0||(0,ct.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,ct.isArray)(i)&&!(0,ct.isObject)(i))&&(o[r]=i)):null!=i&&("string"!=typeof i||!1===n.removeEmptyString||i.length>0)&&(o[r]=i)})),o}return"string"!=typeof e||!1===n.removeEmptyString||e.length>0?e:void 0},t}(),Jt=function(){function t(){}return t.applyTaxes=function(t,e,n){void 0===n&&(n=2);var r=Number(t);return e.forEach((function(e){r+=Number(t)*e})),String(Bt.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),Bt.round(n,2)},t.displayWithCurrency=function(e,n){if(null==e)return e;var r=t.currencies[n],o=e+" "+n;if(void 0!==r)switch(r.position){case"before":o=r.symbol+e;break;case"after":o=e+r.symbol}return o},t.format=function(t,e,n){if(void 0===n&&(n=2),null==t)return t;var r=Number(t.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:n,maximumFractionDigits:n});switch(e){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}},t.round=function(t,e){void 0===e&&(e=.1);var n=100*Number(t),r=100*e,o=n%r;return String(Bt.round(n-o+(o<Math.ceil(r/2)?0:r),2)/100)},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}()})(),r})()}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SmilePlayerCommon=e():t.SmilePlayerCommon=e()}(global,(()=>(()=>{"use strict";var t={16:t=>{t.exports=require("emoji-regex")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};n.r(r),n.d(r,{Constant:()=>o,Exception:()=>i,Http:()=>a,Service:()=>u,Template:()=>s,Tool:()=>c,Util:()=>l});var o={};n.r(o),n.d(o,{Path:()=>p});var i={};n.r(i),n.d(i,{BadParameterException:()=>v,BadRequestException:()=>b,ConflictException:()=>w,DuplicateException:()=>S,ExternalApiException:()=>O,InternalException:()=>_,MainException:()=>d,NotImplementedException:()=>P,ObjectNotFoundException:()=>I,PageNotFoundException:()=>A,UnauthorizedException:()=>N});var a={};n.r(a),n.d(a,{AuthenticationMiddleware:()=>z,AuthorizationMiddleware:()=>G,HandlerController:()=>H,Server:()=>X});var u={};n.r(u),n.d(u,{EmailSenderService:()=>At,SmsSenderService:()=>ct});var s={};n.r(s),n.d(s,{TemplateEngine:()=>Pt});var c={};n.r(c),n.d(c,{Configuration:()=>Lt,Database:()=>Ut,Displayer:()=>Ht,Downloader:()=>zt,Env:()=>R,Environment:()=>F,FileSystem:()=>wt,Logger:()=>q,Retry:()=>rt});var l={};n.r(l),n.d(l,{AddressUtil:()=>Bt,DateUtil:()=>Vt,ExtractorUtil:()=>Jt,FormatterUtil:()=>Zt,GeneratorUtil:()=>mt,MathUtil:()=>$t,ObjectUtil:()=>Yt,PriceUtil:()=>Xt,StringUtil:()=>Wt,ValidatorUtil:()=>ot,asyncForEach:()=>dt,isNullOrUndefined:()=>U,wait:()=>yt});var f,p=function(){function t(){}return t.registerBasePath=function(e){void 0!==process.env.APP_HOME?t.BASE_PATH=process.env.APP_HOME+"/":t.BASE_PATH=e+(e.endsWith("/")?"":"/")},t.data=function(){return t.BASE_PATH+"data/"},t.db=function(){return t.storage()+"db/"},t.root=function(){return t.BASE_PATH},t.session=function(){return t.storage()+"session/"},t.storage=function(){return t.BASE_PATH+"storage/"},t.BASE_PATH="./",t}(),h=(f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},f(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),d=function(t){function e(n,r,o){var i=t.call(this,n)||this;return i.code=r,i.data=o,i.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,e):i.stack=new Error(n).stack,i}return h(e,t),e}(Error),y=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadParameterException",r}return y(e,t),e}(d),m=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),b=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return m(e,t),e}(d),g=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),w=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return g(e,t),e}(d),E=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="DuplicateException",r}return E(e,t),e}(d),x=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),O=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return x(e,t),e}(d),T=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_=function(t){function e(e,n){var r=t.call(this,e,500,n)||this;return r.name="InternalException",r}return T(e,t),e}(d),C=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return C(e,t),e}(d),j=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),I=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return j(e,t),e}(d),M=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),A=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return M(e,t),e}(d),D=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),N=function(t){function e(n,r){var o=t.call(this,n,e.ERROR_CODE,r)||this;return o.name="UnauthorizedException",o}return D(e,t),e.ERROR_CODE=401,e}(d);const L=require("@sentry/node"),k=require("@sentry/profiling-node");var R;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(R||(R={}));var F=function(){function t(){}return t.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return R.DEVELOPMENT;case"prod":case"production":return R.PRODUCTION;case"test":return R.TEST}return void 0===process.env.APP_ID?R.DEVELOPMENT:R.PRODUCTION},t}(),U=function(t){return null==t},q=function(){function t(){}return t.init=function(t,e){F.getMode()===R.PRODUCTION&&(L.init({dsn:t,integrations:[L.captureConsoleIntegration({levels:["error","warn","log"]}),(0,k.nodeProfilingIntegration)()],environment:F.getMode(),maxBreadcrumbs:50,tracesSampleRate:0,profilesSampleRate:0}),L.setupExpressErrorHandler(e))},t.trace=function(t,e){[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.info(t):console.info(t,e):L.addBreadcrumb({category:"info",message:t,data:e,level:"info"})},t.debug=function(t,e){[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.log(t):console.log(t,e):L.addBreadcrumb({category:"debug",message:t,data:e,level:"debug"})},t.info=function(t,e){[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.info(t):console.info(t,e):L.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),L.captureMessage(t)}))},t.warning=function(t,e){U(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.warn(t):console.warn(t,e):L.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),L.captureException(t)}))},t.error=function(t,e){[N.ERROR_CODE].includes(t.code)||(U(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.error(t):console.error(t,e):L.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),L.captureException(t)})))},t}(),H=function(){function t(){}return t.error=function(t,e,n){q.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;e.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),e.json({code:n.code,message:n.message})},t}(),z=function(){function t(t){this.configuration=t}return t.prototype.handler=function(){var t=this;return function(e,n,r){try{var o=!1;if(o||void 0===t.configuration.jwt||(e.session={},o=!0),o||void 0===t.configuration.key||(o=t.authApiKey(e)),!o&&void 0!==t.configuration.session){var i=Object.keys(e.session);if(!Array.isArray(t.configuration.session.required))throw new N("session is not well formatted");t.configuration.session.required.forEach((function(t){if(!i.includes(t))throw new N("session is incomplete")})),o=!0}if(o||void 0===t.configuration.none||(o=t.authNone(e)),!o)throw new N("request is not authenticate");r()}catch(t){H.error(e,n,t)}}},t.prototype.authApiKey=function(t){if("string"!=typeof t.headers.Authorization||!t.headers.Authorization.startsWith("apiKey"))return!1;var e=t.headers.Authorization.split(" ");if(2!==e.length)throw new N("api key is not well formatted");if(e[1]!==this.configuration.key.secret)throw new N("api key is not valid");return t.session={},!0},t.prototype.authNone=function(t){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find((function(e){var n;return null===(n=t.originalUrl)||void 0===n?void 0:n.startsWith(e)}))||(t.session={},0))},t}(),G=function(){function t(){}return t.prototype.can=function(t,e){},t}();const W=require("crypto"),Z=require("express"),B=require("cors"),V=require("compression"),J=require("helmet");var $=n.n(J);const Y=require("connect-timeout");var X=function(){function t(){}return t.prototype.create=function(e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),q.debug("start server on "+o),this.app=Z(),this.app.set("trust proxy",!0),this.app.use(V({level:-1})),this.app.use(Y("300s")),this.app.use(Z.json({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(Z.urlencoded({limit:"10mb"})),this.app.use(B({origin:[o].concat(e),credentials:!0})),this.app.use($()()),this.app.use(Z.json()),this.app.listen(r,(function(){q.debug("server is running on "+o)}))),[2,this.app]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{s(a.next(t))}catch(t){e(t)}}function u(t){try{s(a.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}s((a=a.apply(r,o||[])).next())}));var r,o,i,a},t.prototype.getSessionSecret=function(e){return W.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const K=require("axios");var Q=n.n(K);const tt=require("luxon"),et=require("querystring"),nt=require("retry");var rt=function(){function t(){}return t.request=function(t){return e=this,n=arguments,o=function(t,e,n){var r;return void 0===e&&(e=2),function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(o){return r=nt.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,o){r.attempt((function(){t().then(e).catch((function(t){r.retry(t)?"function"==typeof n&&n(t):o(t)}))}))}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{s(o.next(t))}catch(t){i(t)}}function u(t){try{s(o.throw(t))}catch(t){i(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,u)}s((o=o.apply(e,n||[])).next())}));var e,n,r,o},t}(),ot=function(){function t(){}return t.isEmail=function(t){return"string"==typeof t&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(t)},t.isPhone=function(t){return"string"==typeof t&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(t)},t.isIntMobilePhone=function(t){var e=new RegExp("^\\+1[0-9]{10}$","i"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return e.test(t)||n.test(t)||r.test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}();const it=require("iconv-lite");var at=function(){function t(){}return t.isUTF8=function(t){return!t||"utf8"===(t=t.toLowerCase())||"utf-8"===t},t.urlencode=function(e,n){if(!n||t.isUTF8(n))return encodeURIComponent(e);for(var r=(0,it.encode)(e,n),o="",i="",a=0;a<r.length;a++)1===(i=r[a].toString(16)).length&&(i="0"+i),o+="%"+i;return o.toUpperCase()},t}(),ut=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},st=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},ct=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r){return ut(this,arguments,void 0,(function(e,n,r,o,i){var a,u=this;return void 0===o&&(o=!0),st(this,(function(s){switch(s.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(q.warning(new v("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*t.MESSAGE_MAX_LENGTH?n=n.substring(0,2*t.MESSAGE_MAX_LENGTH):n.length>t.MESSAGE_MAX_LENGTH&&n.length<=1.33*t.MESSAGE_MAX_LENGTH&&(n=n.substring(0,t.MESSAGE_MAX_LENGTH))),[4,rt.request((function(){return ut(u,void 0,void 0,(function(){var r,u,s;return st(this,(function(c){switch(c.label){case 0:return r={accessToken:this.token,emetteur:e,message:at.urlencode(n,"ISO-8859-15"),numero:a.map((function(t){return t.replace("+","")})).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/t.MESSAGE_MAX_LENGTH)},o&&(r.stop=1),void 0!==i&&(r.date_envoi=tt.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),u=tt.DateTime.fromISO(null!=i?i:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),o?u.hour>=21?r.date_envoi=u.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):u.hour<9&&(r.date_envoi=u.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):u.hour<8&&(r.date_envoi=u.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode!==R.TEST?[3,1]:(q.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===R.DEVELOPMENT&&(a=["+15145705214"]),[4,Q().post(t.BASE_API_URL+"sendSMS.do",et.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((s=c.sent()).data.length>0&&"0"!==s.data.trim().substring(0,1))throw new O("Error: "+s.data,r);c.label=3;case 3:return[2]}}))}))}),0,q.error.bind(q))]);case 1:return s.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return ot.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const lt=require("path"),ft=require("mustache"),pt=require("lodash"),ht=require("fs");var dt=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(r){switch(r.label){case 0:n=0,r.label=1;case 1:return n<t.length?[4,e(t[n])]:[3,4];case 2:r.sent(),r.label=3;case 3:return n++,[3,1];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{s(i.next(t))}catch(t){e(t)}}function u(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}s((i=i.apply(n,r||[])).next())}));var n,r,o,i},yt=function(t){return new Promise((function(e){return setTimeout(e,t)}))};const vt=require("color-name");var mt=function(){function t(){}return t.code=function(e){null==e&&(e=6);for(var n="";n.length<e;)n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];return n},t.color=function(e){void 0===e&&(e=1);var n=t.rgbToHex(Math.round(255*e)),r="#000000"+n,o=Object.values(vt);if(0===o.length)return r;var i=o[t.int(0,o.length-1)];return 3!==i.length?r:"#"+t.rgbToHex(i[0])+t.rgbToHex(i[1])+t.rgbToHex(i[2])+n},t.rgbToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},t.int=function(t,e){return null==t&&(t=0),null==e&&(e=Number.POSITIVE_INFINITY),t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},t.password=function(e){null==e&&(e=8);for(var n="";n.length<e;)switch(t.int(1,3)){case 1:n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];break;case 2:n+=t.symbolLowerCases[t.int(0,t.symbolLowerCases.length-1)];break;default:n+=String(t.int(0,9))}return n},t.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],t.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"],t}(),bt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},gt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},wt=function(){function t(){}return t.prototype.dirPath=function(t){var e=lt.resolve(t).lastIndexOf(lt.sep);return e<0?t:lt.resolve(lt.resolve(t).substr(0,e+1))+lt.sep},t.prototype.listFiles=function(t){return bt(this,void 0,void 0,(function(){var e,n,r,o=this;return gt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new v(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=ht.readdirSync(t),r=[],[4,dt(n,(function(n){return bt(o,void 0,void 0,(function(){return gt(this,(function(o){return this.isFile(t+e+n)&&r.push(t+e+n),[2]}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.randomFile=function(t,e){return bt(this,void 0,void 0,(function(){var n,r;return gt(this,(function(o){switch(o.label){case 0:return[4,this.listFiles(t)];case 1:return 0===(n=o.sent()).length?[2,void 0]:(r=void 0!==e?Math.max(e,0)%n.length:mt.int(0,n.length-1),[2,n[r]])}}))}))},t.prototype.move=function(t,e){return bt(this,void 0,void 0,(function(){return gt(this,(function(n){if(!this.isFile(t))throw new v(String(t)+" does not exist or is not a file");if(ht.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new v(String(e)+" does not exist or is not a directory");return[2,ht.renameSync(t,e+lt.basename(t))]}))}))},t.prototype.read=function(t){return bt(this,void 0,void 0,(function(){return gt(this,(function(e){if(!this.isFile(t))throw new v(String(t)+" does not exist or is not a file");return[2,ht.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return bt(this,void 0,void 0,(function(){var e;return gt(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new v(String(t)+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.readJsonFiles=function(t){return bt(this,void 0,void 0,(function(){var e,n,r,o=this;return gt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new v(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=ht.readdirSync(t),r=[],[4,dt(n,(function(n){return bt(o,void 0,void 0,(function(){var o,i,a;return gt(this,(function(u){switch(u.label){case 0:return this.isFile(t+e+n)&&n.endsWith(".json")?(i=(o=r).push,a={name:n},[4,this.readJson(t+e+n)]):[3,2];case 1:i.apply(o,[(a.data=u.sent(),a)]),u.label=2;case 2:return[2]}}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.write=function(t,e){return bt(this,void 0,void 0,(function(){var n;return gt(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),ht.mkdirSync(this.dirPath(t),{recursive:!0}),ht.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return bt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return ht.existsSync(t)&&ht.statSync(t).isDirectory()},t.prototype.isFile=function(t){return ht.existsSync(t)&&ht.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}();const Et=require("clean-css"),St=require("html-minifier-terser");var xt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Ot=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Tt=function(){function t(){}return t.prototype.css=function(t){return xt(this,void 0,void 0,(function(){return Ot(this,(function(e){return[2,new Et({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(t).styles]}))}))},t.prototype.html=function(t){return xt(this,void 0,void 0,(function(){return Ot(this,(function(e){switch(e.label){case 0:return[4,(0,St.minify)(t,{collapseBooleanAttributes:!0,collapseInlineTagWhitespace:!0,collapseWhitespace:!0,continueOnParseError:!1,decodeEntities:!1,html5:!0,minifyCSS:!0,minifyJS:!0,noNewlinesBeforeTagClose:!0,preserveLineBreaks:!1,preventAttributesEscaping:!1,processConditionalComments:!1,quoteCharacter:'"',removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeEmptyElements:!0,removeOptionalTags:!1,removeRedundantAttributes:!0,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeTagWhitespace:!1})];case 1:return[2,e.sent()]}}))}))},t}(),_t=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Ct=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Pt=function(){function t(){this.minifier=new Tt}return t.prototype.render=function(t,e,n){return _t(this,void 0,void 0,(function(){var r,o,i,a,u,s=this;return Ct(this,(function(c){switch(c.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,pt.cloneDeep)(e),o=lt.isAbsolute(t)?"":__dirname+lt.sep,[4,(new wt).read(o+t)];case 1:return i=c.sent(),a=[],(0,ft.parse)(i).forEach((function(t){t.length>=4&&"&"===t[0]&&t[1].startsWith("include:")&&a.push(t[1])})),a.length>0?(void 0===n?n=lt.dirname(o+t)+lt.sep:lt.isAbsolute(n)||(n=o+n),[4,dt(a,(function(t){return _t(s,void 0,void 0,(function(){var e,o,i,a;return Ct(this,(function(u){switch(u.label){case 0:return 3!==(e=t.split(":")).length||void 0===r[t]?[3,2]:(o=e[2],n.includes("/html")&&Object.keys(r[t]).forEach((function(e){r[t][e]=Array.isArray(r[t][e])?r[t][e].map((function(t){return t.replace(/(?:\r\n|\r|\n)/g,"<br>")})):r[t][e].replace(/(?:\r\n|\r|\n)/g,"<br>")})),i=r,a=t,[4,this.render(lt.resolve(n,o),r[t])]);case 1:i[a]=u.sent(),u.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:c.sent(),c.label=3;case 3:if((u=(0,ft.render)(i,r)).includes("{{")||u.includes("}}"))throw new w("template: missing data to render template",{templatePath:t,data:e});return[2,t.includes("html")?this.minifier.html(u):u]}}))}))},t}();const jt=require("node-mailjet");var It=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Mt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},At=function(){function t(t,e,n){this.templateEngine=new Pt,this.mailjet=new jt.Client({apiKey:t,apiSecret:e}),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return It(this,void 0,void 0,(function(){var r=this;return Mt(this,(function(o){switch(o.label){case 0:return[4,rt.request((function(){return It(r,void 0,void 0,(function(){var r,o;return Mt(this,(function(i){switch(i.label){case 0:return void 0===n.base.copyright&&(n.base.copyright={year:String((new Date).getUTCFullYear())}),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/text")];case 1:return r=i.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return o=i.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:r,html:o}],!1)];case 3:return[2,i.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return It(this,void 0,void 0,(function(){var r=this;return Mt(this,(function(o){switch(o.label){case 0:return[4,rt.request((function(){return It(r,void 0,void 0,(function(){var r,o,i,a;return Mt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=u.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=u.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:o,html:a}],!1)];case 5:return[2,u.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return It(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),Mt(this,(function(a){switch(a.label){case 0:return[4,rt.request((function(){return It(i,void 0,void 0,(function(){var i,a,u,s;return Mt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return u=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return s=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:s}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendUsersNotifications=function(t,e,n,r){return It(this,void 0,void 0,(function(){var o=this;return Mt(this,(function(i){switch(i.label){case 0:return[4,rt.request((function(){return It(o,void 0,void 0,(function(){var o,i=this;return Mt(this,(function(a){switch(a.label){case 0:return o=[],[4,dt(e,(function(t){return It(i,void 0,void 0,(function(){var e,r,i,a;return Mt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n){return It(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),Mt(this,(function(a){switch(a.label){case 0:return[4,rt.request((function(){return It(i,void 0,void 0,(function(){var i,a,u,s;return Mt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return u=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return s=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:s}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendDiscounts=function(t,e){return It(this,arguments,void 0,(function(t,e,n,r){var o=this;return void 0===n&&(n=!0),Mt(this,(function(i){switch(i.label){case 0:return[4,rt.request((function(){return It(o,void 0,void 0,(function(){var o,i=this;return Mt(this,(function(a){switch(a.label){case 0:return o=[],[4,dt(e,(function(t){return It(i,void 0,void 0,(function(){var e,r,i,a;return Mt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendNotification=function(t,e){return It(this,arguments,void 0,(function(t,e,n,r){var o,i,a=this;return void 0===n&&(n=!1),Mt(this,(function(u){switch(u.label){case 0:if(0===e.length)throw new v("email: missing messages");u.label=1;case 1:return u.trys.push([1,6,,7]),this.mode!==R.TEST?[3,2]:(q.info("Simulation Mode: Email has been sent",{sender:t,recipients:e.map((function(t){return t.recipient}))}),[3,5]);case 2:return o=[],[4,dt(e,(function(e){return It(a,void 0,void 0,(function(){return Mt(this,(function(i){return this.mode===R.DEVELOPMENT&&(e.recipient.contact="developer@onylab.com"),o.push({From:{Name:t.name,Email:t.contact},To:[{Name:e.recipient.name,Email:e.recipient.contact}],Subject:e.subject,TextPart:e.text,HTMLPart:e.html,Priority:n?0:2,customID:void 0===r?void 0:String(r)}),[2]}))}))}))];case 3:return u.sent(),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:o})];case 4:u.sent(),u.label=5;case 5:return[3,7];case 6:throw i=u.sent(),new d(i.message,Number(i.statusCode));case 7:return[2]}}))}))},t}(),Dt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Nt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Lt=function(){function t(e,n){this.filesystem=new wt,void 0!==t.root&&t.root===e||(t.root=e,t.config=void 0);var r=void 0===n?F.getMode():n;void 0!==t.environment&&t.environment===r||(t.environment=void 0===n?F.getMode():n,t.config=void 0)}return t.prototype.full=function(){return Dt(this,void 0,void 0,(function(){return Nt(this,(function(e){switch(e.label){case 0:return[4,this.init()];case 1:return e.sent(),[2,t.config]}}))}))},t.prototype.init=function(){return Dt(this,void 0,void 0,(function(){var e,n,r,o;return Nt(this,(function(i){switch(i.label){case 0:return void 0!==t.config?[3,6]:void 0!==t.root?[3,1]:(t.config={},[3,6]);case 1:return e=t,[4,this.filesystem.readJson(t.root+"data/config.json")];case 2:if(e.config=i.sent(),![R.DEVELOPMENT,R.TEST].includes(t.environment))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),n=t,r=pt.merge,o=[t.config],[4,this.filesystem.readJson(t.root+"data/config_"+String(t.environment)+".json")];case 4:return n.config=r.apply(void 0,o.concat([i.sent()])),[3,6];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))},t}();const kt=require("typeorm");var Rt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Ft=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Ut=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return Rt(this,void 0,void 0,(function(){var n,r;return Ft(this,(function(o){switch(o.label){case 0:return void 0!==this.db?[3,2]:[4,this.init()];case 1:o.sent(),o.label=2;case 2:return void 0===(n=this.db[t])?[3,4]:(n.entities=e,n.logging=["error"],n.logger=!0,n.bigNumberStrings=!1,void 0===n.timezone&&(n.timezone="Z"),void 0===n.charset&&(n.charset="UTF8_GENERAL_CI"),r=this,[4,(0,kt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:q.error(new v("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return Rt(this,void 0,void 0,(function(){return Ft(this,(function(t){switch(t.label){case 0:return void 0===this.connection?[3,2]:[4,this.connection.synchronize()];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.close=function(){return Rt(this,void 0,void 0,(function(){return Ft(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return Rt(this,void 0,void 0,(function(){var t,e;return Ft(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new wt,e=this,[4,t.readJson(this.root+"data/db.json")];case 2:e.db=n.sent(),n.label=3;case 3:return[2]}}))}))},t}();const qt=require("prettyjson");var Ht=function(){function t(){}return t.prototype.error=function(t){q.error(t)},t.prototype.info=function(t){q.trace(t)},t.prototype.json=function(t){q.trace(qt.render(t,{}))},t.prototype.success=function(t){q.trace(t)},t}(),zt=function(){function t(){this.fileSystem=new wt}return t.prototype.image=function(t,e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(i){switch(i.label){case 0:return void 0===n&&(n=W.randomBytes(20).toString("hex")+lt.extname(t)),[4,this.fileSystem.write(e+lt.sep+n,"")];case 1:return i.sent(),r=lt.resolve(e+lt.sep+n),o=ht.createWriteStream(r),[4,Q()({url:t,method:"GET",responseType:"stream"})];case 2:return i.sent().data.pipe(o),[2,new Promise((function(t,e){o.on("finish",(function(){return t(r)})),o.on("error",e)}))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{s(a.next(t))}catch(t){e(t)}}function u(t){try{s(a.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}s((a=a.apply(r,o||[])).next())}));var r,o,i,a},t}();const Gt=require("fast-diff");var Wt=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.hash=function(t,e){void 0===e&&(e=0);for(var n=3735928559^e,r=1103547991^e,o=0,i=void 0;o<t.length;o++)i=t.charCodeAt(o),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),((r^=Math.imul(n^n>>>13,3266489909))>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")},t.nullable=function(t){return U(t)||"string"==typeof t&&0===t.length?null:t},t.removeMultiSpaces=function(t){return"string"!=typeof t?t:t.replace(/\s{2,}/g," ")},t.removeText=function(e,n){if("string"!=typeof e||"string"!=typeof n||0===n.length)return e;try{e=(e=e.replace(new RegExp(t.escapeRegExp(n),"ig"),"")).replace(new RegExp(t.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(t){}return e},t.replace=function(e,n,r){if("string"!=typeof e)return e;if(n.length!==r.length)return e;var o=e;return n.forEach((function(e,n){o=o.replace(new RegExp(t.escapeRegExp(e),"ig"),r[n])})),o},t.slugify=function(t,e){return void 0===e&&(e=""),void 0===t?"":(0,pt.toLower)((0,pt.trim)((0,pt.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return U(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),Zt=function(){function t(){}return t.trim=function(t){return"string"==typeof t?t.trim():t},t.capitalize=function(e){var n=t.lower(e);return"string"==typeof n?n.split(" ").map((function(t){return t.charAt(0).toUpperCase()+t.slice(1)})).join(" "):e},t.ucfirst=function(e){var n=t.lower(e);return"string"==typeof n?n.charAt(0).toUpperCase()+n.slice(1):e},t.lower=function(t){return"string"==typeof t?t.toLocaleLowerCase():t},t.upper=function(t){return"string"==typeof t?t.toLocaleUpperCase():t},t.phone=function(e,n,r){if(void 0===r&&(r="nat"),"string"==typeof e)switch(e=t.preformatPhone(e,n),r){case"nat":return t.phoneNat(e,n);case"int":return t.phoneInt(e,n)}return e},t.stripEmoji=function(t){var e=t;if("string"==typeof e)for(var r=n(16),o=void 0;null!==(o=r().exec(e));)try{e=(e=(e=e.replace(new RegExp(Wt.escapeRegExp(o[0]),"g"),"")).replace(new RegExp("\\s+","g")," ")).trim()}catch(t){}return e},t.stripExoticCharacters=function(t){return"string"==typeof t?t.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):t},t.preformatPhone=function(t,e){return t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e&&new RegExp("^[1-9]").test(t)&&9===t.length?"0"+t:t},t.phoneNat=function(t,e){if("fr"===e){if(t.startsWith("+330")?t=t.substring(3):t.startsWith("+33")?t="0"+t.substring(3):t.startsWith("0033")?t="0"+t.substring(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substring(2)),10===t.length){var n=0;t=t.split("").map((function(t){return t+(++n%2==0?" ":"")})).join("").trim()}return t}return t},t.phoneInt=function(t,e){return t.startsWith("+")?t:"fr"===e?(t.startsWith("0")&&(t=t.substring(1)),"+33"+t):t},t}(),Bt=function(){function t(){}return t.autoCorrectCity=function(e){if(U(e)||"string"!=typeof e||0===e.length)return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));var n=t.CITIES.find((function(t){return t.toLowerCase()===e.toLowerCase()}));if(void 0!==n)return n;var r=t.CITIES.find((function(n){var r=t.countDiff(e,n);return r.add<=2&&r.remove<=2}));if(void 0!==r)return r;var o=t.CITIES.find((function(t){return t.replace(/-/g," ").toLowerCase()===e.toLowerCase()}));if(void 0!==o)return o;var i=t.CITIES.find((function(n){var r=t.countDiff(e,n.replace(/-/g," "));return r.add<=2&&r.remove<=2}));if(void 0!==i)return i;var a=t.CITIES.find((function(t){return t.toLowerCase().startsWith(e.toLowerCase())}));if(void 0!==a)return a;var u=t.CITIES.find((function(t){return e.toLowerCase().includes(t.toLowerCase())}));return void 0!==u?u:e},t.autoCorrectStreet=function(e){if(U(e)||"string"!=typeof e||0===e.length)return e;t.STREET_TYPE.forEach((function(t){t.short.length<t.long.length&&(e=(e=e.replace(new RegExp("(\\s"+String(t.short)+"\\.?\\s)","ig")," "+String(t.long)+" ")).replace(new RegExp("(\\s"+String(t.short)+"\\.\\s)","ig")," "+String(t.long)+" "))}));var n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==n&&2===n.length&&(e=e.substring(n[1].length)),t.STREET_TYPE.forEach((function(t){e=(e=e.replace(new RegExp("([0-9]+)("+String(t.long)+"\\s)","ig"),"$1 $2")).replace(new RegExp("([0-9]+)("+String(t.short)+"\\.?\\s)","ig"),"$1 "+String(t.long)+" ")})),e},t.getZipCodeFromCity=function(e){if(!U(e))return Object.keys(t.ZIPCODE_CITY).reduce((function(n,r){return void 0!==t.ZIPCODE_CITY[r].find((function(t){return t.toLowerCase()===e.toLowerCase()}))?r:n}),void 0)},t.getCityFromZipCode=function(e,n){if(void 0!==e&&void 0!==n){var r,o=t.ZIPCODE_CITY[e];if(void 0!==o)return 1===o.length?o[0]:(n.split(",").forEach((function(t){r=o.find((function(e){return t.trim().toLowerCase()===e.trim().toLowerCase()}))})),void 0!==r?r:o[0])}},t.isZipCode=function(e){return"string"==typeof e&&(!!t.ZIPCODES.includes(e)||ot.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!U(e)){var o=e.split(",");if(o.length>=3&&n){void 0===t.COUNTRIES.find((function(t){return e.toLowerCase().includes(" "+t.toLowerCase())}))&&o.push("France");var i=o.length-1;if(r.country=o[i].trim(),o.splice(i--,1),void 0!==o[i]&&o[i].trim().includes(" ")){var a=o[i].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),o.splice(i--,1)}else isNaN(Number(o[i].trim()))?isNaN(Number(o[i-1].trim()))?(r.city=o[i].trim(),o.splice(i--,1)):(r.city=o[i].trim(),o.splice(i--,1),r.zip=o[i].trim(),o.splice(i--,1)):(r.zip=o[i].trim(),o.splice(i--,1),i>=2&&(r.city=o[i].trim(),o.splice(i--,1)));r.street=o.map((function(t){return t.trim()})).join(" ").trim()}else{var u=e.toLowerCase();t.ZIPCODES.forEach((function(t){if(u.includes(t)){r.zip=t;try{u=u.replace(new RegExp(Wt.escapeRegExp(t),"ig"),"")}catch(t){}}})),t.CITIES.forEach((function(e){var n;if(u.includes(e.toLowerCase())&&(void 0===r.zip||(null===(n=t.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find((function(t){return t.toLowerCase()===e.toLowerCase()}))))){r.city=e;try{u=u.replace(new RegExp(Wt.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(u.includes(" "+t.toLowerCase())&&!u.includes("de "+t.toLowerCase())&&!u.includes("de la "+t.toLowerCase())){r.country=t;try{u=u.replace(new RegExp(Wt.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=(0,pt.trim)(u.split(",").map((function(t){return t.trim()})).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=Zt.lower(Zt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=Zt.upper(Zt.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(Zt.capitalize(Zt.trim(String(r.city))))),void 0!==r.country&&(r.country=Zt.capitalize(Zt.trim(String(r.country)))),t.complete(r)},t.complete=function(e){if(void 0===e.city||0===e.city.length){var n=t.getCityFromZipCode(e.zip,e.street);void 0!==n&&(e.city=n)}return"string"==typeof e.street&&t.REGIONS.forEach((function(t){e.street=Wt.removeText(e.street,t).trim()})),"fr"===Zt.lower(e.country)&&(e.country="France"),e},t.removeDuplicates=function(t){if("string"!=typeof t)return t;var e=[];return t.split(",").forEach((function(t){void 0===e.find((function(e){return e.trim().toLowerCase().includes(t.trim().toLowerCase())}))&&e.push(t)})),e.join(",")},t.countDiff=function(t,e){var n={add:0,remove:0};return Gt(t.toLowerCase(),e.toLowerCase()).forEach((function(t){switch(t[0]){case-1:n.remove+=t[1].length;break;case 1:n.add+=t[1].length}})),n},t.ZIPCODES=["78500","78600","78800","95240","95530","78630","78670","78240","78580","78300","78955","78260","95150","95250","95480","95320","95550","95370","95740","95220","95870","78420","78400","78110","78360","78290","78230","78540","78920","95600"],t.CITIES=["Sartrouville","Cormeilles-en-Parisis","Houilles","Maisons-Laffitte","La Frette-sur-Seine","Argenteuil","Montesson","Le Mesnil-le-Roi","Bezons","Orgeval","Poissy","Morainvilliers","Villennes-sur-Seine","Medan","Chambourcy","Aigremont","Les Alluets-le-Roi","Carrières-sous-Poissy","Achères","Taverny","Beauchamp","Pierrelaye","Saint-Leu-la-Forêt","Bessancourt","Montigny-lès-Cormeilles","Herblay","Méry-sur-Oise","Carrières-sur-Seine","Bezons","Chatou","Le Vésinet","Montesson","Croissy","Croissy-sur-Seine","Le Pecq","Vernouillet","Ecquevilly"],t.ZIPCODE_CITY={78500:["Sartrouville"],78600:["Maisons-Laffitte","Le Mesnil-le-Roi"],78800:["Houilles"],95240:["Cormeilles-en-Parisis"],95530:["La Frette-sur-Seine"],78100:["Saint-Germain-en-Laye"],95100:["Argenteuil"],78630:["Orgeval","Morainvilliers"],78670:["Villennes-sur-Seine","Medan"],78240:["Chambourcy","Aigremont"],78300:["Poissy"],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-les-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"],78230:["Le Pecq"],95600:["Eaubonne"]},t.REGIONS=["île-de-france"],t.COUNTRIES=["France","FR"],t.STREET_TYPE=[{short:"av",long:"avenue"},{short:"rue",long:"rue"},{short:"bd",long:"boulevard"},{short:"chau",long:"chaussée"},{short:"trav",long:"traverse"},{short:"pl",long:"place"},{short:"pass",long:"passage"},{short:"sent",long:"sentier"},{short:"imp",long:"impasse"},{short:"all",long:"allée"},{short:"chem",long:"chemin"},{short:"ham",long:"hameau"},{short:"dom",long:"domaine"}],t}(),Vt=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=tt.DateTime.fromISO(t.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return t;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===e?tt.DateTime.fromISO(t).toFormat("yyyy-LL"):tt.DateTime.fromISO(t).toISODate()},t.displayWeekDay=function(e){var n="";return void 0!==t.WEEK_DAYS[e]&&(n=t.WEEK_DAYS[e]),n},t.generatePeriod=function(e,n,r,o,i,a){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES),void 0===a&&(a="daily");for(var u={daily:{day:1},weekly:{week:1},monthly:{month:1}}[a],s=tt.DateTime.fromISO(e,{setZone:!0}).toISODate(),c=tt.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};s<=c&&l<i;){var p=t.getCycleDateFromFullDate(s,a);f[p]=(0,pt.cloneDeep)(r),o&&(f[p].date=p),s=tt.DateTime.fromISO(s,{setZone:!0}).plus(u).toISODate(),l++}return f},t.getOpenPeriods=function(t,e){var n=[];return t.forEach((function(t){for(var r=[t],o=function(){var t=r[0];if(void 0===e.find((function(e){return e.from<=t.from&&t.to<=e.to}))){var o=e.find((function(e){return e.from<=t.from&&t.from<e.to&&e.to<t.to}));if(void 0!==o)r.push({from:o.to,to:t.to});else{var i=e.find((function(e){return t.from<e.from&&t.to>e.from&&t.to<=e.to}));if(void 0!==i)r.push({from:t.from,to:i.from});else{var a=e.find((function(e){return t.from<e.from&&e.to<t.to}));void 0!==a?(r.push({from:t.from,to:a.from}),r.push({from:a.to,to:t.to})):n.push(t)}}}r.shift()};r.length>0;)o()})),n},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=tt.DateTime.fromISO(t,{setZone:!0}).toISO(),o=tt.DateTime.fromISO(e,{setZone:!0}).plus({seconds:n}).toISO();return r>o?o:r}},t.localeToISO=function(t){var e,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),o=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(t))e=(i=t.split("/"))[2]+"-"+i[1]+"-"+i[0];else if(r.test(t)){var i;e=(i=t.split("-"))[2]+"-"+i[1]+"-"+i[0]}else o.test(t)&&(e=t);return e},t.slotToTime=function(t){var e,n=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),r=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");return t=t.trim(),n.test(t)?e=t.trim()+":00":r.test(t)&&(e=t.split("-")[0].trim()+":00"),e},t.delay=function(t,e,n){return U(t)||U(e)?0:Math.round(Math.abs(tt.DateTime.fromISO(t,{setZone:!0}).toUTC().diff(tt.DateTime.fromISO(e,{setZone:!0}).toUTC(),[n])[n]))},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=tt.DateTime.fromISO(t,{setZone:!0});return tt.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.min=function(t){return t.reduce((function(t,e){return"string"!=typeof t||t>e?e:t}),void 0)},t.max=function(t){return t.reduce((function(t,e){return void 0===t||t<e?e:t}),void 0)},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Jt=function(){function t(){}return t.phone=function(t,e){if("string"==typeof t&&(t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(t);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},t}(),$t=function(){function t(){}return t.avg=function(e){if(0===e.length)return 0;var n=e.reduce((function(t,e){return t+e}),0);return t.round(n/e.length,2)},t.applyVariation=function(t,e){return t*(t>=0?1+e/100:1-e/100)},t.median=function(e){if(0===e.length)return 0;if(1===e.length)return e[0];var n=e.sort((function(t,e){return t-e}));return n.length%2==0?t.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.length/2)]},t.percentage=function(t,e){if("number"==typeof t&&"number"==typeof e)return 0===e?0:t/e*100},t.round=function(t,e){return"number"!=typeof t?t:0===e?Math.round(t):Math.round(t*Math.pow(10,e))/Math.pow(10,e)},t.variation=function(t,e){var n=0;return 0!==e?n=0!==t?(e-t)/Math.abs(t)*100:100*(e>0?1:-1):0!==t&&(n=-100*(t>0?1:-1)),Math.floor(n)},t}(),Yt=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,pt.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,pt.isArray)(e)&&e.length>0||(0,pt.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,pt.isArray)(e)&&!(0,pt.isObject)(e))&&r.push(e)})),r}if((0,pt.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,pt.isArray)(i)||(0,pt.isObject)(i)?(i=t.compact(i,n),((0,pt.isArray)(i)&&i.length>0||(0,pt.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,pt.isArray)(i)&&!(0,pt.isObject)(i))&&(o[r]=i)):null!=i&&("string"!=typeof i||!1===n.removeEmptyString||i.length>0)&&(o[r]=i)})),o}return"string"!=typeof e||!1===n.removeEmptyString||e.length>0?e:void 0},t}(),Xt=function(){function t(){}return t.applyTaxes=function(t,e,n){void 0===n&&(n=2);var r=Number(t);return e.forEach((function(e){r+=Number(t)*e})),String($t.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),$t.round(n,2)},t.displayWithCurrency=function(e,n){if(null==e)return e;var r=t.currencies[n],o=e+" "+n;if(void 0!==r)switch(r.position){case"before":o=r.symbol+e;break;case"after":o=e+r.symbol}return o},t.format=function(t,e,n){if(void 0===n&&(n=2),null==t)return t;var r=Number(t.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:n,maximumFractionDigits:n});switch(e){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}},t.round=function(t,e){void 0===e&&(e=.1);var n=100*Number(t),r=100*e,o=n%r;return String($t.round(n-o+(o<Math.ceil(r/2)?0:r),2)/100)},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}();return r})()));
|
|
2
2
|
//# sourceMappingURL=common-api.node.min.js.map
|