@onylab/common-api 0.1.196 → 0.1.199

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.
@@ -457,9 +457,24 @@ declare module "tool/FileSystem" {
457
457
  private isJson;
458
458
  }
459
459
  }
460
+ declare module "templating/MinifierEngineContract" {
461
+ export interface MinifierEngineContract {
462
+ css(content: string): Promise<string>;
463
+ html(content: string): Promise<string>;
464
+ }
465
+ }
466
+ declare module "templating/MinifierEngine" {
467
+ import { MinifierEngineContract } from "templating/MinifierEngineContract";
468
+ export class MinifierEngine implements MinifierEngineContract {
469
+ css(content: string): Promise<string>;
470
+ html(content: string): Promise<string>;
471
+ }
472
+ }
460
473
  declare module "templating/TemplateEngine" {
461
474
  import { TemplateEngineContract } from "templating/TemplateEngineContract";
462
475
  export class TemplateEngine implements TemplateEngineContract {
476
+ private minifier;
477
+ constructor();
463
478
  render(templatePath: string, data: {
464
479
  [key: string]: any;
465
480
  }, baseIncludePath?: string): Promise<string>;
@@ -681,6 +696,7 @@ declare module "util/GeneratorUtil" {
681
696
  private static readonly symbolUpperCases;
682
697
  private static readonly symbolLowerCases;
683
698
  static code(size: number): string;
699
+ static color(alpha?: number): string;
684
700
  static int(min: number, max: number): number;
685
701
  static password(size: number): string;
686
702
  }
@@ -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:()=>T,ObjectNotFoundException:()=>P,PageNotFoundException:()=>D,UnauthorizedException:()=>N});var o={};n.r(o),n.d(o,{AuthenticationMiddleware:()=>U,AuthorizationMiddleware:()=>H,HandlerController:()=>q,Server:()=>J});var i={};n.r(i),n.d(i,{EmailSenderService:()=>Et,SmsSenderService:()=>it});var a={};n.r(a),n.d(a,{TemplateEngine:()=>mt});var u={};n.r(u),n.d(u,{Configuration:()=>Ot,Database:()=>Pt,Displayer:()=>Dt,Downloader:()=>Mt,Env:()=>L,Environment:()=>R,FileSystem:()=>dt,Logger:()=>F,Retry:()=>tt});var s={};n.r(s),n.d(s,{AddressUtil:()=>Lt,DateUtil:()=>Rt,ExtractorUtil:()=>Ft,FormatterUtil:()=>kt,GeneratorUtil:()=>qt,MathUtil:()=>Ut,ObjectUtil:()=>Ht,PriceUtil:()=>zt,StringUtil:()=>It,ValidatorUtil:()=>nt,asyncForEach:()=>lt,isNullOrUndefined:()=>Nt,wait:()=>ft});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),_=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)}}(),T=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return _(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),A=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),D=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return A(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)}}(),N=function(t){function e(n,r){var o=t.call(this,n,e.ERROR_CODE,r)||this;return o.name="UnauthorizedException",o}return M(e,t),e.ERROR_CODE=401,e}(p);const j=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(){function t(){}return t.init=function(t,e){R.getMode()===L.PRODUCTION&&j.init({dsn:t,integrations:[new k.CaptureConsole({levels:["error","warn","log"]}),new j.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):j.addBreadcrumb({category:"info",message:t,data:e,level:j.Severity.Info})},t.debug=function(t,e){[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.log(t):console.log(t,e):j.addBreadcrumb({category:"debug",message:t,data:e,level:j.Severity.Debug})},t.info=function(t,e){[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.info(t):console.info(t,e):j.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),j.captureMessage(t)}))},t.warning=function(t,e){[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.warn(t):console.warn(t,e):j.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),j.captureException(t)}))},t.error=function(t,e){[N.ERROR_CODE].includes(t.code)||([L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.error(t):console.error(t,e):j.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),j.captureException(t)})))},t.requestHandler=function(){return j.Handlers.requestHandler()},t.tracingHandler=function(){return j.Handlers.tracingHandler()},t.errorHandler=function(){return j.Handlers.errorHandler()},t}(),q=function(){function t(){}return t.error=function(t,e,n){F.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 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){q.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}(),H=function(){function t(){}return t.prototype.can=function(t,e){},t}();const z=require("crypto"),G=require("express"),W=require("cors"),B=require("compression"),Z=require("helmet"),V=require("connect-timeout");var J=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),F.debug("start server on "+o),this.app=G(),this.app.set("trust proxy",!0),this.app.use(B({level:-1})),this.app.use(V("300s")),this.app.use(G.json({inflate:!0,limit:"100kb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(W({origin:[o].concat(e),credentials:!0})),this.app.use(Z()),this.app.use(G.json()),this.app.listen(r,(function(){F.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 z.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const $=require("axios");var Y=n.n($);const X=require("luxon"),K=require("querystring"),Q=require("retry");var tt=function(){function t(){}return t.request=function(t,e){return void 0===e&&(e=2),n=this,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){return n=Q.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,r){n.attempt((function(){t().then(e).catch((function(t){n.retry(t)||(F.error(t),r(t))}))}))}))]}))},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},t}();const et=require("urlencode");var nt=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}(),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())}))},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])}}},it=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),rt(this,void 0,void 0,(function(){var a,u=this;return ot(this,(function(s){switch(s.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(F.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,tt.request((function(){return rt(u,void 0,void 0,(function(){var r,u;return ot(this,(function(s){switch(s.label){case 0:return r={accessToken:this.token,emetteur:e,message:et(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=X.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),this.mode!==L.TEST?[3,1]:(F.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===L.DEVELOPMENT&&(a=["+15145705214"]),[4,Y().post(t.BASE_API_URL+"sendSMS.do",K.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((u=s.sent()).data.length>0&&"0"!==u.data.trim().substring(0,1))throw new S("Error: "+u.data,r);s.label=3;case 3:return[2]}}))}))}),0)]);case 1:return s.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return nt.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const at=require("path"),ut=require("mustache"),st=require("lodash"),ct=require("fs");var lt=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},ft=function(t){return new Promise((function(e){return setTimeout(e,t)}))},pt=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())}))},ht=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])}}},dt=function(){function t(){}return t.prototype.dirPath=function(t){var e=at.resolve(t).lastIndexOf(at.sep);return e<0?t:at.resolve(at.resolve(t).substr(0,e+1))+at.sep},t.prototype.move=function(t,e){return pt(this,void 0,void 0,(function(){return ht(this,(function(n){if(!this.isFile(t))throw new d(String(t)+" does not exist or is not a file");if(ct.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new d(String(e)+" does not exist or is not a directory");return[2,ct.renameSync(t,e+at.basename(t))]}))}))},t.prototype.read=function(t){return pt(this,void 0,void 0,(function(){return ht(this,(function(e){if(!this.isFile(t))throw new d(String(t)+" does not exist or is not a file");return[2,ct.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return pt(this,void 0,void 0,(function(){var e;return ht(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 pt(this,void 0,void 0,(function(){var e,n,r,o=this;return ht(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=ct.readdirSync(t),r=[],[4,lt(n,(function(n){return pt(o,void 0,void 0,(function(){var o,i,a;return ht(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 pt(this,void 0,void 0,(function(){var n;return ht(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),ct.mkdirSync(this.dirPath(t),{recursive:!0}),ct.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return pt(this,void 0,void 0,(function(){return ht(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return ct.existsSync(t)&&ct.statSync(t).isDirectory()},t.prototype.isFile=function(t){return ct.existsSync(t)&&ct.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},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.render=function(t,e,n){return yt(this,void 0,void 0,(function(){var r,o,i,a,u=this;return vt(this,(function(s){switch(s.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,st.cloneDeep)(e),o=at.isAbsolute(t)?"":__dirname+at.sep,[4,(new dt).read(o+t)];case 1:return i=s.sent(),a=[],(0,ut.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=at.dirname(o+t)+at.sep:at.isAbsolute(n)||(n=o+n),[4,lt(a,(function(t){return yt(u,void 0,void 0,(function(){var e,o,i,a;return vt(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(at.resolve(n,o),r[t])]);case 1:i[a]=u.sent(),u.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:s.sent(),s.label=3;case 3:return[2,(0,ut.render)(i,r)]}}))}))},t}();const gt=require("node-mailjet");var 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())}))},wt=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])}}},Et=function(){function t(t,e,n){this.templateEngine=new mt,this.mailjet=gt.connect(t,e),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return bt(this,void 0,void 0,(function(){var r=this;return wt(this,(function(o){switch(o.label){case 0:return[4,tt.request((function(){return bt(r,void 0,void 0,(function(){var r,o;return wt(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,e,n.base.subject,r,o)];case 3:return[2,i.sent()]}}))}))}),0)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return bt(this,void 0,void 0,(function(){var r=this;return wt(this,(function(o){switch(o.label){case 0:return[4,tt.request((function(){return bt(r,void 0,void 0,(function(){var r,o,i,a;return wt(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,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),0)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return bt(this,void 0,void 0,(function(){var r=this;return wt(this,(function(o){switch(o.label){case 0:return[4,tt.request((function(){return bt(r,void 0,void 0,(function(){var r,o,i,a;return wt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return 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/userNotification",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,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),0)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n){return bt(this,void 0,void 0,(function(){var r=this;return wt(this,(function(o){switch(o.label){case 0:return[4,tt.request((function(){return bt(r,void 0,void 0,(function(){var r,o,i,a;return wt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return 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/discount",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,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),0)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendNotification=function(t,e,n,r,o){return bt(this,void 0,void 0,(function(){var i;return wt(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),this.mode!==L.TEST?[3,1]:(F.info("Simulation Mode: Email has been sent",{sender:t,recipient:e}),[3,3]);case 1:return this.mode===L.DEVELOPMENT&&(e.contact="developer@onylab.com"),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:[{From:{Name:t.name,Email:t.contact},To:[{Name:e.name,Email:e.contact}],Subject:n,TextPart:r,HTMLPart:o}]})];case 2:a.sent(),a.label=3;case 3:return[3,5];case 4:throw i=a.sent(),new p(i.message,Number(i.statusCode));case 5:return[2]}}))}))},t}(),St=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())}))},xt=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])}}},Ot=function(){function t(t,e){this.filesystem=new dt,this.root=t,this.environment=void 0===e?R.getMode():e}return t.prototype.full=function(){return St(this,void 0,void 0,(function(){return xt(this,(function(t){switch(t.label){case 0:return[4,this.init()];case 1:return t.sent(),[2,this.config]}}))}))},t.prototype.init=function(){return St(this,void 0,void 0,(function(){var t,e,n,r;return xt(this,(function(o){switch(o.label){case 0:return void 0!==this.config?[3,6]:void 0!==this.root?[3,1]:(this.config={},[3,6]);case 1:return t=this,[4,this.filesystem.readJson(this.root+"data/config.json")];case 2:if(t.config=o.sent(),![L.DEVELOPMENT,L.TEST].includes(this.environment))return[3,6];o.label=3;case 3:return o.trys.push([3,5,,6]),e=this,n=st.merge,r=[this.config],[4,this.filesystem.readJson(this.root+"data/config_"+String(this.environment)+".json")];case 4:return e.config=n.apply(void 0,r.concat([o.sent()])),[3,6];case 5:return o.sent(),[3,6];case 6:return[2]}}))}))},t}();const _t=require("typeorm");var Tt=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,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])}}},Pt=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return Tt(this,void 0,void 0,(function(){var n,r;return Ct(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,_t.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:F.error(new d("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return Tt(this,void 0,void 0,(function(){return Ct(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 Tt(this,void 0,void 0,(function(){return Ct(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return Tt(this,void 0,void 0,(function(){var t,e;return Ct(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new dt,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 At=require("prettyjson");var Dt=function(){function t(){}return t.prototype.error=function(t){F.error(t)},t.prototype.info=function(t){F.trace(t)},t.prototype.json=function(t){F.trace(At.render(t,{}))},t.prototype.success=function(t){F.trace(t)},t}(),Mt=function(){function t(){this.fileSystem=new dt}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=z.randomBytes(20).toString("hex")+at.extname(t)),[4,this.fileSystem.write(e+at.sep+n,"")];case 1:return i.sent(),r=at.resolve(e+at.sep+n),o=ct.createWriteStream(r),[4,Y()({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}(),Nt=function(t){return null==t};const jt=require("fast-diff");var It=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.nullable=function(t){return Nt(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===t?"":(0,st.toLower)((0,st.trim)((0,st.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return Nt(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),kt=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("\\s"+It.escapeRegExp(o[0]),"g"),"")).replace(new RegExp(It.escapeRegExp(o[0])+"\\s","g"),"")).replace(new RegExp(It.escapeRegExp(o[0]),"g"),"")}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.substr(3):t.startsWith("+33")?t="0"+t.substr(3):t.startsWith("0033")?t="0"+t.substr(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substr(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.substr(1)),"+33"+t):t},t}(),Lt=function(){function t(){}return t.autoCorrectCity=function(e){if(Nt(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(t){return Nt(t)||"string"!=typeof t||0===t.length?t:t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/(\sav\s)/gi," avenue ")).replace(/(\sav\.\s)/gi," avenue ")).replace(/(\sbd\s)/gi," boulevard ")).replace(/(\sbd\.\s)/gi," boulevard ")).replace(/(\schau\.\s)/gi," chaussée ")).replace(/(\strav\.\s)/gi," traverse ")).replace(/(\spl\.\s)/gi," place ")).replace(/(\spass\.\s)/gi," passage ")).replace(/(\ssent\.\s)/gi," sentier ")).replace(/(\simp\.\s)/gi," impasse ")).replace(/(\sall\.\s)/gi," allée ")).replace(/(\schem\.\s)/gi," chemin ")},t.getZipCodeFromCity=function(e){if(!Nt(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)||nt.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!Nt(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(It.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(It.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(u.includes(" "+t.toLowerCase())){r.country=t;try{u=u.replace(new RegExp(It.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=u.split(",").map((function(t){return t.trim()})).join(" ").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=kt.lower(kt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=kt.upper(kt.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(kt.capitalize(kt.trim(String(r.city))))),void 0!==r.country&&(r.country=kt.capitalize(kt.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=It.removeText(e.street,t).trim()})),"fr"===kt.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 jt(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"],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}(),Rt=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=X.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?X.DateTime.fromISO(t).toFormat("yyyy-LL"):X.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=X.DateTime.fromISO(e,{setZone:!0}).toISODate(),c=X.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};s<=c&&l<i;){var p=t.getCycleDateFromFullDate(s,a);f[p]=(0,st.cloneDeep)(r),o&&(f[p].date=p),s=X.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=X.DateTime.fromISO(t,{setZone:!0}).toISO(),o=X.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.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=X.DateTime.fromISO(t,{setZone:!0});return X.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Ft=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}(),qt=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.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}(),Ut=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){return 0===e?0:t/e*100},t.round=function(t,e){return 0===e?Math.round(t):Number(t.toFixed(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}(),Ht=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,st.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,st.isArray)(e)&&e.length>0||(0,st.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,st.isArray)(e)&&!(0,st.isObject)(e))&&r.push(e)})),r}if((0,st.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,st.isArray)(i)||(0,st.isObject)(i)?(i=t.compact(i,n),((0,st.isArray)(i)&&i.length>0||(0,st.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,st.isArray)(i)&&!(0,st.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}(),zt=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(Ut.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),Ut.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(Ut.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,(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:()=>b,DuplicateException:()=>w,ExternalApiException:()=>S,InternalException:()=>O,MainException:()=>p,NotImplementedException:()=>T,ObjectNotFoundException:()=>P,PageNotFoundException:()=>D,UnauthorizedException:()=>N});var o={};n.r(o),n.d(o,{AuthenticationMiddleware:()=>U,AuthorizationMiddleware:()=>H,HandlerController:()=>F,Server:()=>J});var i={};n.r(i),n.d(i,{EmailSenderService:()=>Tt,SmsSenderService:()=>it});var a={};n.r(a),n.d(a,{TemplateEngine:()=>St});var u={};n.r(u),n.d(u,{Configuration:()=>At,Database:()=>jt,Displayer:()=>kt,Downloader:()=>Lt,Env:()=>L,Environment:()=>R,FileSystem:()=>dt,Logger:()=>q,Retry:()=>tt});var s={};n.r(s),n.d(s,{AddressUtil:()=>Ht,DateUtil:()=>zt,ExtractorUtil:()=>Gt,FormatterUtil:()=>Ut,GeneratorUtil:()=>Bt,MathUtil:()=>Zt,ObjectUtil:()=>Vt,PriceUtil:()=>Jt,StringUtil:()=>Ft,ValidatorUtil:()=>nt,asyncForEach:()=>lt,isNullOrUndefined:()=>Rt,wait:()=>ft});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)}}(),b=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),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="DuplicateException",r}return g(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),_=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)}}(),T=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return _(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),A=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),D=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return A(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)}}(),N=function(t){function e(n,r){var o=t.call(this,n,e.ERROR_CODE,r)||this;return o.name="UnauthorizedException",o}return M(e,t),e.ERROR_CODE=401,e}(p);const j=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}(),q=function(){function t(){}return t.init=function(t,e){R.getMode()===L.PRODUCTION&&j.init({dsn:t,integrations:[new k.CaptureConsole({levels:["error","warn","log"]}),new j.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):j.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):j.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):j.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),j.captureMessage(t)}))},t.warning=function(t,e){[L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.warn(t):console.warn(t,e):j.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),j.captureException(t)}))},t.error=function(t,e){[N.ERROR_CODE].includes(t.code)||([L.DEVELOPMENT,L.TEST].includes(R.getMode())?void 0===e?console.error(t):console.error(t,e):j.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),j.captureException(t)})))},t.requestHandler=function(){return j.Handlers.requestHandler()},t.tracingHandler=function(){return j.Handlers.tracingHandler()},t.errorHandler=function(){return j.Handlers.errorHandler()},t}(),F=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 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){F.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}(),H=function(){function t(){}return t.prototype.can=function(t,e){},t}();const z=require("crypto"),G=require("express"),W=require("cors"),B=require("compression"),Z=require("helmet"),V=require("connect-timeout");var J=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=G(),this.app.set("trust proxy",!0),this.app.use(B({level:-1})),this.app.use(V("300s")),this.app.use(G.json({inflate:!0,limit:"100kb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(W({origin:[o].concat(e),credentials:!0})),this.app.use(Z()),this.app.use(G.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 z.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const $=require("axios");var Y=n.n($);const X=require("luxon"),K=require("querystring"),Q=require("retry");var tt=function(){function t(){}return t.request=function(t,e){return void 0===e&&(e=2),n=this,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){return n=Q.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,r){n.attempt((function(){t().then(e).catch((function(t){n.retry(t)||(q.error(t),r(t))}))}))}))]}))},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},t}();const et=require("urlencode");var nt=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}(),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())}))},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])}}},it=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),rt(this,void 0,void 0,(function(){var a,u=this;return ot(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,tt.request((function(){return rt(u,void 0,void 0,(function(){var r,u;return ot(this,(function(s){switch(s.label){case 0:return r={accessToken:this.token,emetteur:e,message:et(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=X.DateTime.fromISO(i,{setZone:!0}).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,Y().post(t.BASE_API_URL+"sendSMS.do",K.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((u=s.sent()).data.length>0&&"0"!==u.data.trim().substring(0,1))throw new S("Error: "+u.data,r);s.label=3;case 3:return[2]}}))}))}),0)]);case 1:return s.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return nt.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const at=require("path"),ut=require("mustache"),st=require("lodash"),ct=require("fs");var lt=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},ft=function(t){return new Promise((function(e){return setTimeout(e,t)}))},pt=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())}))},ht=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])}}},dt=function(){function t(){}return t.prototype.dirPath=function(t){var e=at.resolve(t).lastIndexOf(at.sep);return e<0?t:at.resolve(at.resolve(t).substr(0,e+1))+at.sep},t.prototype.move=function(t,e){return pt(this,void 0,void 0,(function(){return ht(this,(function(n){if(!this.isFile(t))throw new d(String(t)+" does not exist or is not a file");if(ct.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new d(String(e)+" does not exist or is not a directory");return[2,ct.renameSync(t,e+at.basename(t))]}))}))},t.prototype.read=function(t){return pt(this,void 0,void 0,(function(){return ht(this,(function(e){if(!this.isFile(t))throw new d(String(t)+" does not exist or is not a file");return[2,ct.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return pt(this,void 0,void 0,(function(){var e;return ht(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 pt(this,void 0,void 0,(function(){var e,n,r,o=this;return ht(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=ct.readdirSync(t),r=[],[4,lt(n,(function(n){return pt(o,void 0,void 0,(function(){var o,i,a;return ht(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 pt(this,void 0,void 0,(function(){var n;return ht(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),ct.mkdirSync(this.dirPath(t),{recursive:!0}),ct.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return pt(this,void 0,void 0,(function(){return ht(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return ct.existsSync(t)&&ct.statSync(t).isDirectory()},t.prototype.isFile=function(t){return ct.existsSync(t)&&ct.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}();const yt=require("clean-css"),vt=require("html-minifier-terser");var mt=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())}))},bt=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])}}},gt=function(){function t(){}return t.prototype.css=function(t){return mt(this,void 0,void 0,(function(){return bt(this,(function(e){return[2,new yt({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(t).styles]}))}))},t.prototype.html=function(t){return mt(this,void 0,void 0,(function(){return bt(this,(function(e){switch(e.label){case 0:return[4,(0,vt.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}(),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(){this.minifier=new gt}return t.prototype.render=function(t,e,n){return wt(this,void 0,void 0,(function(){var r,o,i,a,u,s=this;return Et(this,(function(c){switch(c.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,st.cloneDeep)(e),o=at.isAbsolute(t)?"":__dirname+at.sep,[4,(new dt).read(o+t)];case 1:return i=c.sent(),a=[],(0,ut.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=at.dirname(o+t)+at.sep:at.isAbsolute(n)||(n=o+n),[4,lt(a,(function(t){return wt(s,void 0,void 0,(function(){var e,o,i,a;return Et(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(at.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:return u=(0,ut.render)(i,r),[2,t.includes("html")?this.minifier.html(u):u]}}))}))},t}();const xt=require("node-mailjet");var 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())}))},_t=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(t,e,n){this.templateEngine=new St,this.mailjet=xt.connect(t,e),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return Ot(this,void 0,void 0,(function(){var r=this;return _t(this,(function(o){switch(o.label){case 0:return[4,tt.request((function(){return Ot(r,void 0,void 0,(function(){var r,o;return _t(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,e,n.base.subject,r,o)];case 3:return[2,i.sent()]}}))}))}),0)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return Ot(this,void 0,void 0,(function(){var r=this;return _t(this,(function(o){switch(o.label){case 0:return[4,tt.request((function(){return Ot(r,void 0,void 0,(function(){var r,o,i,a;return _t(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,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),0)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return Ot(this,void 0,void 0,(function(){var r=this;return _t(this,(function(o){switch(o.label){case 0:return[4,tt.request((function(){return Ot(r,void 0,void 0,(function(){var r,o,i,a;return _t(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return 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/userNotification",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,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),0)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n){return Ot(this,void 0,void 0,(function(){var r=this;return _t(this,(function(o){switch(o.label){case 0:return[4,tt.request((function(){return Ot(r,void 0,void 0,(function(){var r,o,i,a;return _t(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return 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/discount",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,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),0)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendNotification=function(t,e,n,r,o){return Ot(this,void 0,void 0,(function(){var i;return _t(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),this.mode!==L.TEST?[3,1]:(q.info("Simulation Mode: Email has been sent",{sender:t,recipient:e}),[3,3]);case 1:return this.mode===L.DEVELOPMENT&&(e.contact="developer@onylab.com"),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:[{From:{Name:t.name,Email:t.contact},To:[{Name:e.name,Email:e.contact}],Subject:n,TextPart:r,HTMLPart:o}]})];case 2:a.sent(),a.label=3;case 3:return[3,5];case 4:throw i=a.sent(),new p(i.message,Number(i.statusCode));case 5:return[2]}}))}))},t}(),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])}}},At=function(){function t(t,e){this.filesystem=new dt,this.root=t,this.environment=void 0===e?R.getMode():e}return t.prototype.full=function(){return Ct(this,void 0,void 0,(function(){return Pt(this,(function(t){switch(t.label){case 0:return[4,this.init()];case 1:return t.sent(),[2,this.config]}}))}))},t.prototype.init=function(){return Ct(this,void 0,void 0,(function(){var t,e,n,r;return Pt(this,(function(o){switch(o.label){case 0:return void 0!==this.config?[3,6]:void 0!==this.root?[3,1]:(this.config={},[3,6]);case 1:return t=this,[4,this.filesystem.readJson(this.root+"data/config.json")];case 2:if(t.config=o.sent(),![L.DEVELOPMENT,L.TEST].includes(this.environment))return[3,6];o.label=3;case 3:return o.trys.push([3,5,,6]),e=this,n=st.merge,r=[this.config],[4,this.filesystem.readJson(this.root+"data/config_"+String(this.environment)+".json")];case 4:return e.config=n.apply(void 0,r.concat([o.sent()])),[3,6];case 5:return o.sent(),[3,6];case 6:return[2]}}))}))},t}();const Dt=require("typeorm");var Mt=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,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(t){this.root=t}return t.prototype.connect=function(t,e){return Mt(this,void 0,void 0,(function(){var n,r;return Nt(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,Dt.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 Mt(this,void 0,void 0,(function(){return Nt(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 Mt(this,void 0,void 0,(function(){return Nt(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return Mt(this,void 0,void 0,(function(){var t,e;return Nt(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new dt,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 It=require("prettyjson");var kt=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(It.render(t,{}))},t.prototype.success=function(t){q.trace(t)},t}(),Lt=function(){function t(){this.fileSystem=new dt}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=z.randomBytes(20).toString("hex")+at.extname(t)),[4,this.fileSystem.write(e+at.sep+n,"")];case 1:return i.sent(),r=at.resolve(e+at.sep+n),o=ct.createWriteStream(r),[4,Y()({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}(),Rt=function(t){return null==t};const qt=require("fast-diff");var Ft=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.nullable=function(t){return Rt(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===t?"":(0,st.toLower)((0,st.trim)((0,st.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return Rt(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),Ut=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("\\s"+Ft.escapeRegExp(o[0]),"g"),"")).replace(new RegExp(Ft.escapeRegExp(o[0])+"\\s","g"),"")).replace(new RegExp(Ft.escapeRegExp(o[0]),"g"),"")}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.substr(3):t.startsWith("+33")?t="0"+t.substr(3):t.startsWith("0033")?t="0"+t.substr(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substr(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.substr(1)),"+33"+t):t},t}(),Ht=function(){function t(){}return t.autoCorrectCity=function(e){if(Rt(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(t){return Rt(t)||"string"!=typeof t||0===t.length?t:t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/(\sav\s)/gi," avenue ")).replace(/(\sav\.\s)/gi," avenue ")).replace(/(\sbd\s)/gi," boulevard ")).replace(/(\sbd\.\s)/gi," boulevard ")).replace(/(\schau\.\s)/gi," chaussée ")).replace(/(\strav\.\s)/gi," traverse ")).replace(/(\spl\.\s)/gi," place ")).replace(/(\spass\.\s)/gi," passage ")).replace(/(\ssent\.\s)/gi," sentier ")).replace(/(\simp\.\s)/gi," impasse ")).replace(/(\sall\.\s)/gi," allée ")).replace(/(\schem\.\s)/gi," chemin ")},t.getZipCodeFromCity=function(e){if(!Rt(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)||nt.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!Rt(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(Ft.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(Ft.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(u.includes(" "+t.toLowerCase())){r.country=t;try{u=u.replace(new RegExp(Ft.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=u.split(",").map((function(t){return t.trim()})).join(" ").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=Ut.lower(Ut.trim(String(r.street)))),void 0!==r.zip&&(r.zip=Ut.upper(Ut.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(Ut.capitalize(Ut.trim(String(r.city))))),void 0!==r.country&&(r.country=Ut.capitalize(Ut.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=Ft.removeText(e.street,t).trim()})),"fr"===Ut.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 qt(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"],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}(),zt=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=X.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?X.DateTime.fromISO(t).toFormat("yyyy-LL"):X.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=X.DateTime.fromISO(e,{setZone:!0}).toISODate(),c=X.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};s<=c&&l<i;){var p=t.getCycleDateFromFullDate(s,a);f[p]=(0,st.cloneDeep)(r),o&&(f[p].date=p),s=X.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=X.DateTime.fromISO(t,{setZone:!0}).toISO(),o=X.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.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=X.DateTime.fromISO(t,{setZone:!0});return X.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Gt=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}();const Wt=require("color-name");var Bt=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="rgba(0, 0, 0, 1)",r=Object.values(Wt);if(0===r.length)return n;var o=r[t.int(0,r.length-1)];return 3!==o.length?n:"rgba("+String(o[0])+","+String(o[1])+","+String(o[2])+","+String(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}(),Zt=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){return 0===e?0:t/e*100},t.round=function(t,e){return 0===e?Math.round(t):Number(t.toFixed(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,st.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,st.isArray)(e)&&e.length>0||(0,st.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,st.isArray)(e)&&!(0,st.isObject)(e))&&r.push(e)})),r}if((0,st.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,st.isArray)(i)||(0,st.isObject)(i)?(i=t.compact(i,n),((0,st.isArray)(i)&&i.length>0||(0,st.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,st.isArray)(i)&&!(0,st.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(Zt.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),Zt.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(Zt.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})()}));
2
2
  //# sourceMappingURL=common-api.node.min.js.map