@onylab/common-api 1.1.4 → 1.1.6

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.
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SmilePlayerCommon=e():t.SmilePlayerCommon=e()}(global,(()=>(()=>{"use strict";var t={16:t=>{t.exports=require("emoji-regex")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};n.r(r),n.d(r,{Constant:()=>o,Exception:()=>i,Http:()=>a,Service:()=>u,Template:()=>c,Tool:()=>s,Util:()=>l});var o={};n.r(o),n.d(o,{Path:()=>p});var i={};n.r(i),n.d(i,{BadParameterException:()=>v,BadRequestException:()=>b,ConflictException:()=>w,DuplicateException:()=>S,ExternalApiException:()=>O,InternalException:()=>_,MainException:()=>d,NotImplementedException:()=>j,ObjectNotFoundException:()=>M,PageNotFoundException:()=>D,UnauthorizedException:()=>N});var a={};n.r(a),n.d(a,{AuthenticationMiddleware:()=>G,AuthorizationMiddleware:()=>z,HandlerController:()=>H,Server:()=>X});var u={};n.r(u),n.d(u,{EmailSenderService:()=>Dt,SmsSenderService:()=>st});var c={};n.r(c),n.d(c,{TemplateEngine:()=>jt});var s={};n.r(s),n.d(s,{Configuration:()=>kt,Database:()=>Ut,Displayer:()=>Ht,Downloader:()=>Gt,Env:()=>L,Environment:()=>F,FileSystem:()=>wt,Logger:()=>q,Retry:()=>rt});var l={};n.r(l),n.d(l,{AddressUtil:()=>Bt,DateUtil:()=>Vt,ExtractorUtil:()=>Jt,FormatterUtil:()=>Zt,GeneratorUtil:()=>mt,MathUtil:()=>Yt,ObjectUtil:()=>$t,PriceUtil:()=>Xt,StringUtil:()=>Wt,ValidatorUtil:()=>ot,asyncForEach:()=>dt,isNullOrUndefined:()=>U,wait:()=>yt});var f,p=function(){function t(){}return t.registerBasePath=function(e){void 0!==process.env.APP_HOME?t.BASE_PATH=process.env.APP_HOME+"/":t.BASE_PATH=e+(e.endsWith("/")?"":"/")},t.data=function(){return t.BASE_PATH+"data/"},t.db=function(){return t.storage()+"db/"},t.root=function(){return t.BASE_PATH},t.session=function(){return t.storage()+"session/"},t.storage=function(){return t.BASE_PATH+"storage/"},t.BASE_PATH="./",t}(),h=(f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},f(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),d=function(t){function e(n,r,o){var i=t.call(this,n)||this;return i.code=r,i.data=o,i.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,e):i.stack=new Error(n).stack,i}return h(e,t),e}(Error),y=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadParameterException",r}return y(e,t),e}(d),m=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),b=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return m(e,t),e}(d),g=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),w=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return g(e,t),e}(d),E=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="DuplicateException",r}return E(e,t),e}(d),x=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),O=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return x(e,t),e}(d),T=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_=function(t){function e(e,n){var r=t.call(this,e,500,n)||this;return r.name="InternalException",r}return T(e,t),e}(d),C=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),j=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return C(e,t),e}(d),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)}}(),M=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return P(e,t),e}(d),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}(d),I=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 I(e,t),e.ERROR_CODE=401,e}(d);const k=require("@sentry/node"),R=require("@sentry/profiling-node");var L;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(L||(L={}));var F=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}(),U=function(t){return null==t},q=function(){function t(){}return t.init=function(t,e){F.getMode()===L.PRODUCTION&&(k.init({dsn:t,integrations:[k.captureConsoleIntegration({levels:["error","warn","log"]}),(0,R.nodeProfilingIntegration)()],environment:F.getMode(),maxBreadcrumbs:50,tracesSampleRate:0,profilesSampleRate:0}),k.setupExpressErrorHandler(e))},t.trace=function(t,e){[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.info(t):console.info(t,e):k.addBreadcrumb({category:"info",message:t,data:e,level:"info"})},t.debug=function(t,e){[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.log(t):console.log(t,e):k.addBreadcrumb({category:"debug",message:t,data:e,level:"debug"})},t.info=function(t,e){[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.info(t):console.info(t,e):k.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),k.captureMessage(t)}))},t.warning=function(t,e){U(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.warn(t):console.warn(t,e):k.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),k.captureException(t)}))},t.error=function(t,e){[N.ERROR_CODE].includes(t.code)||(U(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.error(t):console.error(t,e):k.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),k.captureException(t)})))},t}(),H=function(){function t(){}return t.error=function(t,e,n){q.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;e.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),e.json({code:n.code,message:n.message})},t}(),G=function(){function t(t){this.configuration=t}return t.prototype.handler=function(){var t=this;return function(e,n,r){try{var o=!1;if(o||void 0===t.configuration.jwt||(e.session={},o=!0),o||void 0===t.configuration.key||(o=t.authApiKey(e)),!o&&void 0!==t.configuration.session){var i=Object.keys(e.session);if(!Array.isArray(t.configuration.session.required))throw new N("session is not well formatted");t.configuration.session.required.forEach((function(t){if(!i.includes(t))throw new N("session is incomplete")})),o=!0}if(o||void 0===t.configuration.none||(o=t.authNone(e)),!o)throw new N("request is not authenticate");r()}catch(t){H.error(e,n,t)}}},t.prototype.authApiKey=function(t){if("string"!=typeof t.headers.Authorization||!t.headers.Authorization.startsWith("apiKey"))return!1;var e=t.headers.Authorization.split(" ");if(2!==e.length)throw new N("api key is not well formatted");if(e[1]!==this.configuration.key.secret)throw new N("api key is not valid");return t.session={},!0},t.prototype.authNone=function(t){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find((function(e){var n;return null===(n=t.originalUrl)||void 0===n?void 0:n.startsWith(e)}))||(t.session={},0))},t}(),z=function(){function t(){}return t.prototype.can=function(t,e){},t}();const W=require("crypto"),Z=require("express"),B=require("cors"),V=require("compression"),J=require("helmet");var Y=n.n(J);const $=require("connect-timeout");var X=function(){function t(){}return t.prototype.create=function(e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),q.debug("start server on "+o),this.app=Z(),this.app.set("trust proxy",!0),this.app.use(V({level:-1})),this.app.use($("300s")),this.app.use(Z.json({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(Z.urlencoded({limit:"10mb"})),this.app.use(B({origin:[o].concat(e),credentials:!0})),this.app.use(Y()()),this.app.use(Z.json()),this.app.listen(r,(function(){q.debug("server is running on "+o)}))),[2,this.app]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{c(a.next(t))}catch(t){e(t)}}function u(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}c((a=a.apply(r,o||[])).next())}));var r,o,i,a},t.prototype.getSessionSecret=function(e){return W.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const K=require("axios");var Q=n.n(K);const tt=require("luxon"),et=require("querystring"),nt=require("retry");var rt=function(){function t(){}return t.request=function(t){return e=this,n=arguments,o=function(t,e,n){var r;return void 0===e&&(e=2),function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}(this,(function(o){return r=nt.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,o){r.attempt((function(){t().then(e).catch((function(t){r.retry(t)?"function"==typeof n&&n(t):o(t)}))}))}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function u(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,u)}c((o=o.apply(e,n||[])).next())}));var e,n,r,o},t}(),ot=function(){function t(){}return t.isEmail=function(t){return"string"==typeof t&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(t)},t.isPhone=function(t){return"string"==typeof t&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(t)},t.isIntMobilePhone=function(t){var e=new RegExp("^\\+1[0-9]{10}$","i"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return e.test(t)||n.test(t)||r.test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}();const it=require("iconv-lite");var at=function(){function t(){}return t.isUTF8=function(t){return!t||"utf8"===(t=t.toLowerCase())||"utf-8"===t},t.urlencode=function(e,n){if(!n||t.isUTF8(n))return encodeURIComponent(e);for(var r=(0,it.encode)(e,n),o="",i="",a=0;a<r.length;a++)1===(i=r[a].toString(16)).length&&(i="0"+i),o+="%"+i;return o.toUpperCase()},t}(),ut=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},ct=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},st=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r){return ut(this,arguments,void 0,(function(e,n,r,o,i){var a,u=this;return void 0===o&&(o=!0),ct(this,(function(c){switch(c.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(q.warning(new v("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*t.MESSAGE_MAX_LENGTH?n=n.substring(0,2*t.MESSAGE_MAX_LENGTH):n.length>t.MESSAGE_MAX_LENGTH&&n.length<=1.33*t.MESSAGE_MAX_LENGTH&&(n=n.substring(0,t.MESSAGE_MAX_LENGTH))),[4,rt.request((function(){return ut(u,void 0,void 0,(function(){var r,u,c;return ct(this,(function(s){switch(s.label){case 0:return r={accessToken:this.token,emetteur:e,message:at.urlencode(n,"ISO-8859-15"),numero:a.map((function(t){return t.replace("+","")})).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/t.MESSAGE_MAX_LENGTH)},o&&(r.stop=1),void 0!==i&&(r.date_envoi=tt.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),u=tt.DateTime.fromISO(null!=i?i:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),o?u.hour>=21?r.date_envoi=u.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):u.hour<9&&(r.date_envoi=u.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):u.hour<8&&(r.date_envoi=u.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode!==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,Q().post(t.BASE_API_URL+"sendSMS.do",et.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((c=s.sent()).data.length>0&&"0"!==c.data.trim().substring(0,1))throw new O("Error: "+c.data,r);s.label=3;case 3:return[2]}}))}))}),0,q.error.bind(q))]);case 1:return c.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return ot.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const lt=require("path"),ft=require("mustache"),pt=require("lodash"),ht=require("fs");var dt=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}(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{c(i.next(t))}catch(t){e(t)}}function u(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},yt=function(t){return new Promise((function(e){return setTimeout(e,t)}))};const vt=require("color-name");var mt=function(){function t(){}return t.code=function(e){null==e&&(e=6);for(var n="";n.length<e;)n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];return n},t.color=function(e){void 0===e&&(e=1);var n=t.rgbToHex(Math.round(255*e)),r="#000000"+n,o=Object.values(vt);if(0===o.length)return r;var i=o[t.int(0,o.length-1)];return 3!==i.length?r:"#"+t.rgbToHex(i[0])+t.rgbToHex(i[1])+t.rgbToHex(i[2])+n},t.rgbToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},t.int=function(t,e){return null==t&&(t=0),null==e&&(e=Number.POSITIVE_INFINITY),t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},t.password=function(e){null==e&&(e=8);for(var n="";n.length<e;)switch(t.int(1,3)){case 1:n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];break;case 2:n+=t.symbolLowerCases[t.int(0,t.symbolLowerCases.length-1)];break;default:n+=String(t.int(0,9))}return n},t.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],t.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"],t}(),bt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},gt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},wt=function(){function t(){}return t.prototype.dirPath=function(t){var e=lt.resolve(t).lastIndexOf(lt.sep);return e<0?t:lt.resolve(lt.resolve(t).substr(0,e+1))+lt.sep},t.prototype.listFiles=function(t){return bt(this,void 0,void 0,(function(){var e,n,r,o=this;return gt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new v(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=ht.readdirSync(t),r=[],[4,dt(n,(function(n){return bt(o,void 0,void 0,(function(){return gt(this,(function(o){return this.isFile(t+e+n)&&r.push(t+e+n),[2]}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.randomFile=function(t,e){return bt(this,void 0,void 0,(function(){var n,r;return gt(this,(function(o){switch(o.label){case 0:return[4,this.listFiles(t)];case 1:return 0===(n=o.sent()).length?[2,void 0]:(r=void 0!==e?Math.max(e,0)%n.length:mt.int(0,n.length-1),[2,n[r]])}}))}))},t.prototype.move=function(t,e){return bt(this,void 0,void 0,(function(){return gt(this,(function(n){if(!this.isFile(t))throw new v(String(t)+" does not exist or is not a file");if(ht.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new v(String(e)+" does not exist or is not a directory");return[2,ht.renameSync(t,e+lt.basename(t))]}))}))},t.prototype.read=function(t){return bt(this,void 0,void 0,(function(){return gt(this,(function(e){if(!this.isFile(t))throw new v(String(t)+" does not exist or is not a file");return[2,ht.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return bt(this,void 0,void 0,(function(){var e;return gt(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new v(String(t)+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.readJsonFiles=function(t){return bt(this,void 0,void 0,(function(){var e,n,r,o=this;return gt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new v(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=ht.readdirSync(t),r=[],[4,dt(n,(function(n){return bt(o,void 0,void 0,(function(){var o,i,a;return gt(this,(function(u){switch(u.label){case 0:return this.isFile(t+e+n)&&n.endsWith(".json")?(i=(o=r).push,a={name:n},[4,this.readJson(t+e+n)]):[3,2];case 1:i.apply(o,[(a.data=u.sent(),a)]),u.label=2;case 2:return[2]}}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.write=function(t,e){return bt(this,void 0,void 0,(function(){var n;return gt(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),ht.mkdirSync(this.dirPath(t),{recursive:!0}),ht.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return bt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return ht.existsSync(t)&&ht.statSync(t).isDirectory()},t.prototype.isFile=function(t){return ht.existsSync(t)&&ht.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}();const Et=require("clean-css"),St=require("html-minifier-terser");var xt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},Ot=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},Tt=function(){function t(){}return t.prototype.css=function(t){return xt(this,void 0,void 0,(function(){return Ot(this,(function(e){return[2,new Et({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(t).styles]}))}))},t.prototype.html=function(t){return xt(this,void 0,void 0,(function(){return Ot(this,(function(e){switch(e.label){case 0:return[4,(0,St.minify)(t,{collapseBooleanAttributes:!0,collapseInlineTagWhitespace:!0,collapseWhitespace:!0,continueOnParseError:!1,decodeEntities:!1,html5:!0,minifyCSS:!0,minifyJS:!0,noNewlinesBeforeTagClose:!0,preserveLineBreaks:!1,preventAttributesEscaping:!1,processConditionalComments:!1,quoteCharacter:'"',removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeEmptyElements:!0,removeOptionalTags:!1,removeRedundantAttributes:!0,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeTagWhitespace:!1})];case 1:return[2,e.sent()]}}))}))},t}(),_t=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},Ct=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},jt=function(){function t(){this.minifier=new Tt}return t.prototype.render=function(t,e,n){return _t(this,void 0,void 0,(function(){var r,o,i,a,u,c=this;return Ct(this,(function(s){switch(s.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,pt.cloneDeep)(e),o=lt.isAbsolute(t)?"":__dirname+lt.sep,[4,(new wt).read(o+t)];case 1:return i=s.sent(),a=[],(0,ft.parse)(i).forEach((function(t){t.length>=4&&"&"===t[0]&&t[1].startsWith("include:")&&a.push(t[1])})),a.length>0?(void 0===n?n=lt.dirname(o+t)+lt.sep:lt.isAbsolute(n)||(n=o+n),[4,dt(a,(function(t){return _t(c,void 0,void 0,(function(){var e,o,i,a;return Ct(this,(function(u){switch(u.label){case 0:return 3!==(e=t.split(":")).length||void 0===r[t]?[3,2]:(o=e[2],n.includes("/html")&&Object.keys(r[t]).forEach((function(e){r[t][e]=Array.isArray(r[t][e])?r[t][e].map((function(t){return t.replace(/(?:\r\n|\r|\n)/g,"<br>")})):r[t][e].replace(/(?:\r\n|\r|\n)/g,"<br>")})),i=r,a=t,[4,this.render(lt.resolve(n,o),r[t])]);case 1:i[a]=u.sent(),u.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:s.sent(),s.label=3;case 3:if((u=(0,ft.render)(i,r)).includes("{{")||u.includes("}}"))throw new w("template: missing data to render template",{templatePath:t,data:e});return[2,t.includes("html")?this.minifier.html(u):u]}}))}))},t}();const Pt=require("node-mailjet");var Mt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},At=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},Dt=function(){function t(t,e,n){this.templateEngine=new jt,this.mailjet=new Pt.Client({apiKey:t,apiSecret:e}),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return Mt(this,void 0,void 0,(function(){var r=this;return At(this,(function(o){switch(o.label){case 0:return[4,rt.request((function(){return Mt(r,void 0,void 0,(function(){var r,o;return At(this,(function(i){switch(i.label){case 0:return void 0===n.base.copyright&&(n.base.copyright={year:String((new Date).getUTCFullYear())}),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/text")];case 1:return r=i.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return o=i.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:r,html:o}],!1)];case 3:return[2,i.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return Mt(this,void 0,void 0,(function(){var r=this;return At(this,(function(o){switch(o.label){case 0:return[4,rt.request((function(){return Mt(r,void 0,void 0,(function(){var r,o,i,a;return At(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=u.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=u.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:o,html:a}],!1)];case 5:return[2,u.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return Mt(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),At(this,(function(a){switch(a.label){case 0:return[4,rt.request((function(){return Mt(i,void 0,void 0,(function(){var i,a,u,c;return At(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return i=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=s.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return u=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return c=s.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:c}],r,o)];case 5:return[2,s.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendUsersNotifications=function(t,e,n,r){return Mt(this,void 0,void 0,(function(){var o=this;return At(this,(function(i){switch(i.label){case 0:return[4,rt.request((function(){return Mt(o,void 0,void 0,(function(){var o,i=this;return At(this,(function(a){switch(a.label){case 0:return o=[],[4,dt(e,(function(t){return Mt(i,void 0,void 0,(function(){var e,r,i,a;return At(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n){return Mt(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),At(this,(function(a){switch(a.label){case 0:return[4,rt.request((function(){return Mt(i,void 0,void 0,(function(){var i,a,u,c;return At(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return i=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=s.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return u=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return c=s.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:c}],r,o)];case 5:return[2,s.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendDiscounts=function(t,e){return Mt(this,arguments,void 0,(function(t,e,n,r){var o=this;return void 0===n&&(n=!0),At(this,(function(i){switch(i.label){case 0:return[4,rt.request((function(){return Mt(o,void 0,void 0,(function(){var o,i=this;return At(this,(function(a){switch(a.label){case 0:return o=[],[4,dt(e,(function(t){return Mt(i,void 0,void 0,(function(){var e,r,i,a;return At(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendNotification=function(t,e){return Mt(this,arguments,void 0,(function(t,e,n,r){var o,i,a=this;return void 0===n&&(n=!1),At(this,(function(u){switch(u.label){case 0:if(0===e.length)throw new v("email: missing messages");u.label=1;case 1:return u.trys.push([1,6,,7]),this.mode!==L.TEST?[3,2]:(q.info("Simulation Mode: Email has been sent",{sender:t,recipients:e.map((function(t){return t.recipient}))}),[3,5]);case 2:return o=[],[4,dt(e,(function(e){return Mt(a,void 0,void 0,(function(){return At(this,(function(i){return this.mode===L.DEVELOPMENT&&(e.recipient.contact="developer@onylab.com"),o.push({From:{Name:t.name,Email:t.contact},To:[{Name:e.recipient.name,Email:e.recipient.contact}],Subject:e.subject,TextPart:e.text,HTMLPart:e.html,Priority:n?0:2,customID:void 0===r?void 0:String(r)}),[2]}))}))}))];case 3:return u.sent(),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:o})];case 4:u.sent(),u.label=5;case 5:return[3,7];case 6:throw i=u.sent(),new d(i.message,Number(i.statusCode));case 7:return[2]}}))}))},t}(),It=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},Nt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},kt=function(){function t(e,n){this.filesystem=new wt,void 0!==t.root&&t.root===e||(t.root=e,t.config=void 0);var r=void 0===n?F.getMode():n;void 0!==t.environment&&t.environment===r||(t.environment=void 0===n?F.getMode():n,t.config=void 0)}return t.prototype.full=function(){return It(this,void 0,void 0,(function(){return Nt(this,(function(e){switch(e.label){case 0:return[4,this.init()];case 1:return e.sent(),[2,t.config]}}))}))},t.prototype.init=function(){return It(this,void 0,void 0,(function(){var e,n,r,o;return Nt(this,(function(i){switch(i.label){case 0:return void 0!==t.config?[3,6]:void 0!==t.root?[3,1]:(t.config={},[3,6]);case 1:return e=t,[4,this.filesystem.readJson(t.root+"data/config.json")];case 2:if(e.config=i.sent(),![L.DEVELOPMENT,L.TEST].includes(t.environment))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),n=t,r=pt.merge,o=[t.config],[4,this.filesystem.readJson(t.root+"data/config_"+String(t.environment)+".json")];case 4:return n.config=r.apply(void 0,o.concat([i.sent()])),[3,6];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))},t}();const Rt=require("typeorm");var Lt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},Ft=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},Ut=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return Lt(this,void 0,void 0,(function(){var n,r;return Ft(this,(function(o){switch(o.label){case 0:return void 0!==this.db?[3,2]:[4,this.init()];case 1:o.sent(),o.label=2;case 2:return void 0===(n=this.db[t])?[3,4]:(n.entities=e,n.logging=["error"],n.logger=!0,n.bigNumberStrings=!1,void 0===n.timezone&&(n.timezone="Z"),void 0===n.charset&&(n.charset="UTF8_GENERAL_CI"),r=this,[4,(0,Rt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:q.error(new v("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return Lt(this,void 0,void 0,(function(){return Ft(this,(function(t){switch(t.label){case 0:return void 0===this.connection?[3,2]:[4,this.connection.synchronize()];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.close=function(){return Lt(this,void 0,void 0,(function(){return Ft(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return Lt(this,void 0,void 0,(function(){var t,e;return Ft(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new wt,e=this,[4,t.readJson(this.root+"data/db.json")];case 2:e.db=n.sent(),n.label=3;case 3:return[2]}}))}))},t}();const qt=require("prettyjson");var Ht=function(){function t(){}return t.prototype.error=function(t){q.error(t)},t.prototype.info=function(t){q.trace(t)},t.prototype.json=function(t){q.trace(qt.render(t,{}))},t.prototype.success=function(t){q.trace(t)},t}(),Gt=function(){function t(){this.fileSystem=new wt}return t.prototype.image=function(t,e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}(this,(function(i){switch(i.label){case 0:return void 0===n&&(n=W.randomBytes(20).toString("hex")+lt.extname(t)),[4,this.fileSystem.write(e+lt.sep+n,"")];case 1:return i.sent(),r=lt.resolve(e+lt.sep+n),o=ht.createWriteStream(r),[4,Q()({url:t,method:"GET",responseType:"stream"})];case 2:return i.sent().data.pipe(o),[2,new Promise((function(t,e){o.on("finish",(function(){return t(r)})),o.on("error",e)}))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{c(a.next(t))}catch(t){e(t)}}function u(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}c((a=a.apply(r,o||[])).next())}));var r,o,i,a},t}();const zt=require("fast-diff");var Wt=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.hash=function(t,e){void 0===e&&(e=0);for(var n=3735928559^e,r=1103547991^e,o=0,i=void 0;o<t.length;o++)i=t.charCodeAt(o),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),((r^=Math.imul(n^n>>>13,3266489909))>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")},t.nullable=function(t){return U(t)||"string"==typeof t&&0===t.length?null:t},t.removeMultiSpaces=function(t){return"string"!=typeof t?t:t.replace(/\s{2,}/g," ")},t.removeText=function(e,n){if("string"!=typeof e||"string"!=typeof n||0===n.length)return e;try{e=(e=e.replace(new RegExp(t.escapeRegExp(n),"ig"),"")).replace(new RegExp(t.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(t){}return e},t.replace=function(e,n,r){if("string"!=typeof e)return e;if(n.length!==r.length)return e;var o=e;return n.forEach((function(e,n){o=o.replace(new RegExp(t.escapeRegExp(e),"ig"),r[n])})),o},t.slugify=function(t,e){return void 0===e&&(e=""),void 0===t?"":(0,pt.toLower)((0,pt.trim)((0,pt.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return U(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),Zt=function(){function t(){}return t.trim=function(t){return"string"==typeof t?t.trim():t},t.capitalize=function(e){var n=t.lower(e);return"string"==typeof n?n.split(" ").map((function(t){return t.charAt(0).toUpperCase()+t.slice(1)})).join(" "):e},t.ucfirst=function(e){var n=t.lower(e);return"string"==typeof n?n.charAt(0).toUpperCase()+n.slice(1):e},t.lower=function(t){return"string"==typeof t?t.toLocaleLowerCase():t},t.upper=function(t){return"string"==typeof t?t.toLocaleUpperCase():t},t.phone=function(e,n,r){if(void 0===r&&(r="nat"),"string"==typeof e)switch(e=t.preformatPhone(e,n),r){case"nat":return t.phoneNat(e,n);case"int":return t.phoneInt(e,n)}return e},t.stripEmoji=function(t){var e=t;if("string"==typeof e)for(var r=n(16),o=void 0;null!==(o=r().exec(e));)try{e=(e=(e=e.replace(new RegExp(Wt.escapeRegExp(o[0]),"g"),"")).replace(new RegExp("\\s+","g")," ")).trim()}catch(t){}return e},t.stripExoticCharacters=function(t){return"string"==typeof t?t.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):t},t.preformatPhone=function(t,e){return t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e&&new RegExp("^[1-9]").test(t)&&9===t.length?"0"+t:t},t.phoneNat=function(t,e){if("fr"===e){if(t.startsWith("+330")?t=t.substring(3):t.startsWith("+33")?t="0"+t.substring(3):t.startsWith("0033")?t="0"+t.substring(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substring(2)),10===t.length){var n=0;t=t.split("").map((function(t){return t+(++n%2==0?" ":"")})).join("").trim()}return t}return t},t.phoneInt=function(t,e){return t.startsWith("+")?t:"fr"===e?(t.startsWith("0")&&(t=t.substring(1)),"+33"+t):t},t}(),Bt=function(){function t(){}return t.autoCorrectCity=function(e){if(U(e)||"string"!=typeof e||0===e.length)return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));var n=Object.values(t.ZIPCODE_CITY).flat(),r=n.find((function(t){return t.toLowerCase()===e.toLowerCase()}));if(void 0!==r)return r;var o=n.find((function(n){var r=t.countDiff(e,n);return r.add<=2&&r.remove<=2}));if(void 0!==o)return o;var i=n.find((function(t){return t.replace(/-/g," ").toLowerCase()===e.toLowerCase()}));if(void 0!==i)return i;var a=n.find((function(n){var r=t.countDiff(e,n.replace(/-/g," "));return r.add<=2&&r.remove<=2}));if(void 0!==a)return a;var u=n.find((function(t){return t.toLowerCase().startsWith(e.toLowerCase())}));if(void 0!==u)return u;var c=n.find((function(t){return e.toLowerCase().includes(t.toLowerCase())}));return void 0!==c?c:e},t.autoCorrectStreet=function(e){if(U(e)||"string"!=typeof e||0===e.length)return e;t.STREET_TYPE.forEach((function(t){t.short.length<t.long.length&&(e=(e=e.replace(new RegExp("(\\s"+String(t.short)+"\\.?\\s)","ig")," "+String(t.long)+" ")).replace(new RegExp("(\\s"+String(t.short)+"\\.\\s)","ig")," "+String(t.long)+" "))}));var n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==n&&2===n.length&&(e=e.substring(n[1].length)),t.STREET_TYPE.forEach((function(t){e=(e=e.replace(new RegExp("([0-9]+)("+String(t.long)+"\\s)","ig"),"$1 $2")).replace(new RegExp("([0-9]+)("+String(t.short)+"\\.?\\s)","ig"),"$1 "+String(t.long)+" ")})),e},t.getZipCodeFromCity=function(e){if(!U(e))return Object.keys(t.ZIPCODE_CITY).reduce((function(n,r){return void 0!==t.ZIPCODE_CITY[r].find((function(t){return t.toLowerCase()===e.toLowerCase()}))?r:n}),void 0)},t.getCityFromZipCode=function(e,n){if(void 0!==e&&void 0!==n){var r,o=t.ZIPCODE_CITY[e];if(void 0!==o)return 1===o.length?o[0]:(n.split(",").forEach((function(t){r=o.find((function(e){return t.trim().toLowerCase()===e.trim().toLowerCase()}))})),void 0!==r?r:o[0])}},t.isZipCode=function(e){return"string"==typeof e&&(!!Object.keys(t.ZIPCODE_CITY).includes(e)||ot.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!U(e)){var o=e.split(",");if(o.length>=3&&n){void 0===t.COUNTRIES.find((function(t){return e.toLowerCase().includes(" "+t.toLowerCase())}))&&o.push("France");var i=o.length-1;if(r.country=o[i].trim(),o.splice(i--,1),void 0!==o[i]&&o[i].trim().includes(" ")){var a=o[i].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),o.splice(i--,1)}else isNaN(Number(o[i].trim()))?isNaN(Number(o[i-1].trim()))?(r.city=o[i].trim(),o.splice(i--,1)):(r.city=o[i].trim(),o.splice(i--,1),r.zip=o[i].trim(),o.splice(i--,1)):(r.zip=o[i].trim(),o.splice(i--,1),i>=2&&(r.city=o[i].trim(),o.splice(i--,1)));r.street=o.map((function(t){return t.trim()})).join(" ").trim()}else{var u=e.toLowerCase();Object.keys(t.ZIPCODE_CITY).forEach((function(t){if(u.includes(t)){r.zip=t;try{u=u.replace(new RegExp(Wt.escapeRegExp(t),"ig"),"")}catch(t){}}})),Object.values(t.ZIPCODE_CITY).flat().forEach((function(e){var n;if(u.includes(e.toLowerCase())&&(void 0===r.zip||(null===(n=t.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find((function(t){return t.toLowerCase()===e.toLowerCase()}))))){r.city=e;try{u=u.replace(new RegExp(Wt.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(u.includes(" "+t.toLowerCase())&&!u.includes("de "+t.toLowerCase())&&!u.includes("de la "+t.toLowerCase())){r.country=t;try{u=u.replace(new RegExp(Wt.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=(0,pt.trim)(u.split(",").map((function(t){return t.trim()})).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=Zt.lower(Zt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=Zt.upper(Zt.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(Zt.capitalize(Zt.trim(String(r.city))))),void 0!==r.country&&(r.country=Zt.capitalize(Zt.trim(String(r.country)))),t.complete(r)},t.complete=function(e){if(void 0===e.city||0===e.city.length){var n=t.getCityFromZipCode(e.zip,e.street);void 0!==n&&(e.city=n)}return"string"==typeof e.street&&t.REGIONS.forEach((function(t){e.street=Wt.removeText(e.street,t).trim()})),"fr"===Zt.lower(e.country)&&(e.country="France"),e},t.removeDuplicates=function(t){if("string"!=typeof t)return t;var e=[];return t.split(",").forEach((function(t){void 0===e.find((function(e){return e.trim().toLowerCase().includes(t.trim().toLowerCase())}))&&e.push(t)})),e.join(",")},t.countDiff=function(t,e){var n={add:0,remove:0};return zt(t.toLowerCase(),e.toLowerCase()).forEach((function(t){switch(t[0]){case-1:n.remove+=t[1].length;break;case 1:n.add+=t[1].length}})),n},t.ZIPCODE_CITY={78500:["Sartrouville"],78600:["Maisons-Laffitte","Le Mesnil-le-Roi"],78800:["Houilles"],95240:["Cormeilles-en-Parisis"],95530:["La Frette-sur-Seine"],78100:["Saint-Germain-en-Laye"],95100:["Argenteuil"],78630:["Orgeval","Morainvilliers"],78670:["Villennes-sur-Seine","Medan"],78240:["Chambourcy","Aigremont"],78300:["Poissy"],78510:["Triel-sur-Seine"],78570:["Andrésy","Chanteloup-les-Vignes"],78700:["Conflans-Sainte-Honorine"],78480:["Verneuil-sur-Seine"],78750:["Mareil-Marly"],78620:["L'Étang-la-Ville"],78160:["Marly-le-Roi"],78580:["Les Alluets-le-Roi"],78955:["Carrières-sous-Poissy"],78260:["Achères"],78540:["Vernouillet"],78920:["Ecquevilly"],95150:["Taverny"],95250:["Beauchamp"],95480:["Pierrelaye"],95320:["Saint-Leu-la-Forêt"],95550:["Bessancourt"],95370:["Montigny-lès-Cormeilles"],95220:["Herblay"],95740:["Frépillon"],95540:["Méry-sur-Oise"],95870:["Bezons"],78420:["Carrières-sur-Seine"],78400:["Chatou"],78110:["Le Vésinet"],78360:["Montesson"],78290:["Croissy-sur-Seine","Croissy"],78230:["Le Pecq"],95600:["Eaubonne"]},t.REGIONS=["île-de-france"],t.COUNTRIES=["France","FR"],t.STREET_TYPE=[{short:"av",long:"avenue"},{short:"rue",long:"rue"},{short:"bd",long:"boulevard"},{short:"chau",long:"chaussée"},{short:"trav",long:"traverse"},{short:"pl",long:"place"},{short:"pass",long:"passage"},{short:"sent",long:"sentier"},{short:"imp",long:"impasse"},{short:"all",long:"allée"},{short:"chem",long:"chemin"},{short:"ham",long:"hameau"},{short:"dom",long:"domaine"}],t}(),Vt=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=tt.DateTime.fromISO(t.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return t;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===e?tt.DateTime.fromISO(t).toFormat("yyyy-LL"):tt.DateTime.fromISO(t).toISODate()},t.displayWeekDay=function(e){var n="";return void 0!==t.WEEK_DAYS[e]&&(n=t.WEEK_DAYS[e]),n},t.generatePeriod=function(e,n,r,o,i,a){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES),void 0===a&&(a="daily");for(var u={daily:{day:1},weekly:{week:1},monthly:{month:1}}[a],c=tt.DateTime.fromISO(e,{setZone:!0}).toISODate(),s=tt.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};c<=s&&l<i;){var p=t.getCycleDateFromFullDate(c,a);f[p]=(0,pt.cloneDeep)(r),o&&(f[p].date=p),c=tt.DateTime.fromISO(c,{setZone:!0}).plus(u).toISODate(),l++}return f},t.getOpenPeriods=function(t,e){var n=[];return t.forEach((function(t){for(var r=[t],o=function(){var t=r[0];if(void 0===e.find((function(e){return e.from<=t.from&&t.to<=e.to}))){var o=e.find((function(e){return e.from<=t.from&&t.from<e.to&&e.to<t.to}));if(void 0!==o)r.push({from:o.to,to:t.to});else{var i=e.find((function(e){return t.from<e.from&&t.to>e.from&&t.to<=e.to}));if(void 0!==i)r.push({from:t.from,to:i.from});else{var a=e.find((function(e){return t.from<e.from&&e.to<t.to}));void 0!==a?(r.push({from:t.from,to:a.from}),r.push({from:a.to,to:t.to})):n.push(t)}}}r.shift()};r.length>0;)o()})),n},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=tt.DateTime.fromISO(t,{setZone:!0}).toISO(),o=tt.DateTime.fromISO(e,{setZone:!0}).plus({seconds:n}).toISO();return r>o?o:r}},t.localeToISO=function(t){var e,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),o=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(t))e=(i=t.split("/"))[2]+"-"+i[1]+"-"+i[0];else if(r.test(t)){var i;e=(i=t.split("-"))[2]+"-"+i[1]+"-"+i[0]}else o.test(t)&&(e=t);return e},t.slotToTime=function(t){var e,n=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),r=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");return t=t.trim(),n.test(t)?e=t.trim()+":00":r.test(t)&&(e=t.split("-")[0].trim()+":00"),e},t.delay=function(t,e,n){return U(t)||U(e)?0:Math.round(Math.abs(tt.DateTime.fromISO(t,{setZone:!0}).toUTC().diff(tt.DateTime.fromISO(e,{setZone:!0}).toUTC(),[n])[n]))},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=tt.DateTime.fromISO(t,{setZone:!0});return tt.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.min=function(t){return t.reduce((function(t,e){return"string"!=typeof t||t>e?e:t}),void 0)},t.max=function(t){return t.reduce((function(t,e){return void 0===t||t<e?e:t}),void 0)},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Jt=function(){function t(){}return t.phone=function(t,e){if("string"==typeof t&&(t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(t);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},t}(),Yt=function(){function t(){}return t.avg=function(e){if(0===e.length)return 0;var n=e.reduce((function(t,e){return t+e}),0);return t.round(n/e.length,2)},t.applyVariation=function(t,e){return t*(t>=0?1+e/100:1-e/100)},t.median=function(e){if(0===e.length)return 0;if(1===e.length)return e[0];var n=e.sort((function(t,e){return t-e}));return n.length%2==0?t.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.length/2)]},t.percentage=function(t,e){if("number"==typeof t&&"number"==typeof e)return 0===e?0:t/e*100},t.round=function(t,e){return"number"!=typeof t?t:0===e?Math.round(t):Math.round(t*Math.pow(10,e))/Math.pow(10,e)},t.variation=function(t,e){var n=0;return 0!==e?n=0!==t?(e-t)/Math.abs(t)*100:100*(e>0?1:-1):0!==t&&(n=-100*(t>0?1:-1)),Math.floor(n)},t}(),$t=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,pt.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,pt.isArray)(e)&&e.length>0||(0,pt.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,pt.isArray)(e)&&!(0,pt.isObject)(e))&&r.push(e)})),r}if((0,pt.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,pt.isArray)(i)||(0,pt.isObject)(i)?(i=t.compact(i,n),((0,pt.isArray)(i)&&i.length>0||(0,pt.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,pt.isArray)(i)&&!(0,pt.isObject)(i))&&(o[r]=i)):null!=i&&("string"!=typeof i||!1===n.removeEmptyString||i.length>0)&&(o[r]=i)})),o}return"string"!=typeof e||!1===n.removeEmptyString||e.length>0?e:void 0},t}(),Xt=function(){function t(){}return t.applyTaxes=function(t,e,n){void 0===n&&(n=2);var r=Number(t);return e.forEach((function(e){r+=Number(t)*e})),String(Yt.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),Yt.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(Yt.round(n-o+(o<Math.ceil(r/2)?0:r),2)/100)},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}();return r})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SmilePlayerCommon=e():t.SmilePlayerCommon=e()}(global,(()=>(()=>{"use strict";var t={16:t=>{t.exports=require("emoji-regex")},270:t=>{t.exports=JSON.parse('{"id":"87yu4","location_id":"3r4s3-1","name":"Web","created_at":"2020-06-25T11:43:51+02:00","data":{"variants":[],"categories":[],"products":[],"options_lists":[],"deals":[],"discounts":[],"charges":[]}}')},835:t=>{t.exports=JSON.parse('[{"id":"87yu4","name":"Web","created_at":"2020-06-25T11:43:51+02:00"},{"id":"sdm3b","name":"Common menu","created_at":"2020-05-19T13:23:10+02:00"}]')},851:t=>{t.exports=JSON.parse('{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}')},329:t=>{t.exports=JSON.parse('[{"id":"apm3s","name":"Online customers","created_at":"2020-06-25T11:43:51+02:00"},{"id":"s7ma5","name":"POS customers","created_at":"2020-05-19T13:23:10+02:00"}]')},616:t=>{t.exports=JSON.parse('[{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}},{"id":"asdf2","customer_list_id":"ag8u4","anonymised":false,"email":"charles.moore@dummy-mail.org","first_name":"Charles","last_name":"Moore","phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}]')},69:t=>{t.exports=JSON.parse('[{"id":"3r4s3-1","name":"Paris","account":{"id":"3r4s3","name":"Bella Pizza","currency":"EUR"},"preparation_time":15,"order_acceptance":{"mode":"normal"}}]')},133:t=>{t.exports=JSON.parse('{"status":"new","private_ref":"fr:1679f128-4ff6-4a60-9fc2-7fe38af4f84d","service_type":"delivery","service_type_ref":null,"expected_time":"2021-11-07T17:17:22Z","customer_notes":"PAS DE COUVERTS","collection_code":"5645","items":[{"product_name":"LIP15","sku_ref":"LIP15","price":"3.50 EUR","quantity":1,"options":[]},{"product_name":"5VANI","sku_ref":"5VANI","price":"6.90 EUR","quantity":1,"options":[]},{"product_name":"TSQ2","sku_ref":"TSQ2","price":"13.50 EUR","quantity":1,"options":[{"option_list_name":"Options","name":"SUPP RACLETTE","ref":"SUPP RACLETTE","price":"1.00 EUR"}]},{"product_name":"SCES","sku_ref":"SCES","price":"10.50 EUR","quantity":1,"options":[]}],"deals":{},"discounts":[],"charges":[{"type":"delivery","name":"Delivery charge","ref":null,"price":"0.99 EUR"}],"payments":[{"type":"online","name":"Paid online","ref":null,"amount":"36.39 EUR"}],"customer":{"address_1":"6a Rue du Tire Pesseau, 21000 Dijon, France","city":"Dijon","postal_code":"21000","phone":"+33175858334","delivery_notes":"Phone access code: 151081499","first_name":"Benoit","last_name":"B.","email":"orders@deliveroo.com","latitude":"47.3166297697847","longitude":"5.00251594930887"}}')},660:t=>{t.exports=JSON.parse('{"id":"v6ap7","first_name":"Tom","last_name":"Jones","email":"tom.jones@dummy-mail.org","timezone":{"name":"Europe/Paris"},"locales":["fr-FR","en-US"]}')}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};n.r(r),n.d(r,{Api:()=>o,Constant:()=>i,Exception:()=>a,Http:()=>s,Service:()=>u,Template:()=>c,Tool:()=>l,Util:()=>f});var o={};n.r(o),n.d(o,{HubriseApi:()=>D,HubriseApiMockup:()=>y});var i={};n.r(i),n.d(i,{Path:()=>N});var a={};n.r(a),n.d(a,{BadParameterException:()=>B,BadRequestException:()=>H,ConflictException:()=>z,DuplicateException:()=>J,ExternalApiException:()=>S,InternalException:()=>V,MainException:()=>E,NotImplementedException:()=>Y,ObjectNotFoundException:()=>K,PageNotFoundException:()=>tt,UnauthorizedException:()=>P});var s={};n.r(s),n.d(s,{AuthenticationMiddleware:()=>nt,AuthorizationMiddleware:()=>rt,HandlerController:()=>et,Server:()=>ft});var u={};n.r(u),n.d(u,{EmailSenderService:()=>Bt,SmsSenderService:()=>gt});var c={};n.r(c),n.d(c,{TemplateEngine:()=>Ut});var l={};n.r(l),n.d(l,{Configuration:()=>Gt,Database:()=>Zt,Displayer:()=>Xt,Downloader:()=>Yt,Env:()=>x,Environment:()=>C,FileSystem:()=>At,Logger:()=>k,Retry:()=>L});var f={};n.r(f),n.d(f,{AddressUtil:()=>te,DateUtil:()=>ee,ExtractorUtil:()=>ne,FormatterUtil:()=>Qt,GeneratorUtil:()=>Tt,MathUtil:()=>re,ObjectUtil:()=>oe,PriceUtil:()=>ie,StringUtil:()=>Kt,ValidatorUtil:()=>dt,asyncForEach:()=>_t,isNullOrUndefined:()=>j,wait:()=>St});const p=require("nock");var d=function(){function t(){}return t.isDone=function(){return p.isActive()&&p.isDone()},t.pending=function(){return"pending: "+JSON.stringify(p.pendingMocks())},t.reset=function(){p.cleanAll()},t}();const h=require("lodash");var m,v=(m=function(t,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},m(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}m(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e.getUser=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/user")?"/user":t})).get("/user").times(t).reply(200,(0,h.cloneDeep)(n(660)))},e.getLocations=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/locations")?"/locations":t})).get("/locations").times(t).reply(200,(0,h.cloneDeep)(n(69)))},e.createCustomer=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/customer")?"/customer":t})).post("/customer").times(t).reply(200,(0,h.cloneDeep)(n(851)))},e.getCustomer=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/customer_lists")&&t.includes("/customers")?"/customer":t})).get("/customer").times(t).reply(200,(0,h.cloneDeep)(n(851)))},e.getCustomers=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/customers")?"/customers":t})).get("/customers").times(t).reply(200,(0,h.cloneDeep)(n(616)))},e.getCustomerLists=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/customer_lists")?"/customerLists":t})).get("/customerLists").times(t).reply(200,(0,h.cloneDeep)(n(329)))},e.createOrder=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/order")?"/order":t})).post("/order").times(t).reply(200,(0,h.cloneDeep)(n(133)))},e.getOrder=function(t,r){void 0===t&&(t=1),void 0===r&&(r=!1);var o=(0,h.cloneDeep)(n(133));r&&(o.id=String(Date.now())),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/orders/")?"/order":t})).get("/order").times(t).reply(200,o)},e.setOrderStatus=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/orders/")?"/status":t})).patch("/status").times(t).reply(204)},e.getCatalog=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/catalog")?"/catalog":t})).get("/catalog").times(t).reply(200,(0,h.cloneDeep)(n(270)))},e.getCatalogs=function(t){void 0===t&&(t=1),p(e.BASE_URL,{allowUnmocked:!1}).filteringPath((function(t){return t.includes("/catalogs")?"/catalogs":t})).get("/catalogs").times(t).reply(200,(0,h.cloneDeep)(n(835)))},e.BASE_URL="http://api.hubrise.com",e}(d);const g=require("axios");var b=n.n(g),w=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),E=function(t){function e(n,r,o){var i=t.call(this,n)||this;return i.code=r,i.data=o,i.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,e):i.stack=new Error(n).stack,i}return w(e,t),e}(Error),_=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return _(e,t),e}(E);const O=require("@sentry/node"),T=require("@sentry/profiling-node");var x;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(x||(x={}));var C=function(){function t(){}return t.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return x.DEVELOPMENT;case"prod":case"production":return x.PRODUCTION;case"test":return x.TEST}return void 0===process.env.APP_ID?x.DEVELOPMENT:x.PRODUCTION},t}(),A=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=function(t){function e(n,r){var o=t.call(this,n,e.ERROR_CODE,r)||this;return o.name="UnauthorizedException",o}return A(e,t),e.ERROR_CODE=401,e}(E),j=function(t){return null==t},k=function(){function t(){}return t.init=function(t,e){C.getMode()===x.PRODUCTION&&(O.init({dsn:t,integrations:[O.captureConsoleIntegration({levels:["error","warn","log"]}),(0,T.nodeProfilingIntegration)()],environment:C.getMode(),maxBreadcrumbs:50,tracesSampleRate:0,profilesSampleRate:0}),O.setupExpressErrorHandler(e))},t.trace=function(t,e){[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.info(t):console.info(t,e):O.addBreadcrumb({category:"info",message:t,data:e,level:"info"})},t.debug=function(t,e){[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.log(t):console.log(t,e):O.addBreadcrumb({category:"debug",message:t,data:e,level:"debug"})},t.info=function(t,e){[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.info(t):console.info(t,e):O.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),O.captureMessage(t)}))},t.warning=function(t,e){j(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.warn(t):console.warn(t,e):O.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),O.captureException(t)}))},t.error=function(t,e){[P.ERROR_CODE].includes(t.code)||(j(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[x.DEVELOPMENT,x.TEST].includes(C.getMode())?void 0===e?console.error(t):console.error(t,e):O.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),O.captureException(t)})))},t}();const R=require("retry");var L=function(){function t(){}return t.request=function(t){return e=this,n=arguments,o=function(t,e,n){var r;return void 0===e&&(e=2),function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}(this,(function(o){return r=R.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,o){r.attempt((function(){t().then(e).catch((function(t){r.retry(t)?"function"==typeof n&&n(t):o(t)}))}))}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function s(t){try{u(o.throw(t))}catch(t){i(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}u((o=o.apply(e,n||[])).next())}));var e,n,r,o},t}();const M=require("querystring");var I=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},U=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},D=function(){function t(t){this.token=t}return t.prototype.authorize=function(e,n){return I(this,void 0,void 0,(function(){return U(this,(function(r){return[2,t.BASE_AUTH_URL+"authorize?redirect_uri="+String(n)+"&client_id="+e+"&scope=account[orders.write,all_customer_lists.write,all_catalogs.write,inventory.write],profile_with_email"]}))}))},t.prototype.getToken=function(e,n,r){return I(this,void 0,void 0,(function(){var o,i=this;return U(this,(function(a){switch(a.label){case 0:return[4,L.request((function(){return I(i,void 0,void 0,(function(){var i;return U(this,(function(a){switch(a.label){case 0:return[4,b().post(t.BASE_AUTH_URL+"token",M.stringify({code:r,client_id:e,client_secret:n}),{headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:t.TIMEOUT})];case 1:if(void 0===(i=a.sent())||void 0===i.data)throw new S("failed to get hubrise token");return o=i.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return a.sent(),[2,o]}}))}))},t.prototype.getUser=function(){return I(this,void 0,void 0,(function(){var e,n=this;return U(this,(function(r){switch(r.label){case 0:return[4,L.request((function(){return I(n,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return[4,b().get(t.BASE_URL+"user",{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise user");return e=n.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return r.sent(),[2,e]}}))}))},t.prototype.getLocations=function(){return I(this,void 0,void 0,(function(){var e,n=this;return U(this,(function(r){switch(r.label){case 0:return[4,L.request((function(){return I(n,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return[4,b().get(t.BASE_URL+"locations",{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise locations");return e=n.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return r.sent(),[2,e]}}))}))},t.prototype.createCustomer=function(e,n){return I(this,void 0,void 0,(function(){var r=this;return U(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().post(t.BASE_URL+"customer_lists/"+String(e)+"/customers",n,{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to create hubrise customer");return[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2]}}))}))},t.prototype.getCustomer=function(e,n){return I(this,void 0,void 0,(function(){var r,o=this;return U(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return I(o,void 0,void 0,(function(){var o;return U(this,(function(i){switch(i.label){case 0:return[4,b().get(t.BASE_URL+"customer_lists/"+String(e)+"/customers/"+String(n),{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(o=i.sent())||void 0===o.data)throw new S("failed to retrieve hubrise customer");return r=o.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.getCustomers=function(e,n,r,o){return I(this,void 0,void 0,(function(){var i,a,s=this;return U(this,(function(u){switch(u.label){case 0:return(i=new URLSearchParams).append("private_ref",n),i.append("email",r),i.append("phone",o),[4,L.request((function(){return I(s,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return[4,b().get(t.BASE_URL+"customer_lists/"+String(e)+"/customers?"+i.toString(),{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(n=r.sent())||void 0===n.data)throw new S("failed to retrieve hubrise customers");return a=n.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return u.sent(),[2,a]}}))}))},t.prototype.getCustomerLists=function(e){return I(this,void 0,void 0,(function(){var n,r=this;return U(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().get(t.BASE_URL+"locations/"+String(e)+"/customer_lists",{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to retrieve hubrise customer lists");return n=r.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2,n]}}))}))},t.prototype.createOrder=function(e,n){return I(this,void 0,void 0,(function(){var r=this;return U(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().post(t.BASE_URL+"locations/"+String(e)+"/orders",n,{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to create hubrise order");return[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2]}}))}))},t.prototype.getOrder=function(e,n){return I(this,void 0,void 0,(function(){var r,o=this;return U(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return I(o,void 0,void 0,(function(){var o;return U(this,(function(i){switch(i.label){case 0:return[4,b().get(t.BASE_URL+"locations/"+String(e)+"/orders/"+String(n),{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(o=i.sent())||void 0===o.data)throw new S("failed to retrieve hubrise order");return r=o.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.setOrderStatus=function(e,n,r){return I(this,void 0,void 0,(function(){var o=this;return U(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return I(o,void 0,void 0,(function(){var o;return U(this,(function(i){switch(i.label){case 0:return[4,b().patch(t.BASE_URL+"locations/"+String(e)+"/orders/"+String(n),{status:r},{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(o=i.sent())||void 0===o.data)throw new S("failed to update hubrise order status");return[2]}}))}))}),1,k.error.bind(k))];case 1:return i.sent(),[2]}}))}))},t.prototype.getCatalog=function(e){return I(this,void 0,void 0,(function(){var n,r=this;return U(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().get(t.BASE_URL+"catalogs/"+String(e),{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to retrieve hubrise catalogs");return n=r.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2,n]}}))}))},t.prototype.getCatalogs=function(e){return I(this,void 0,void 0,(function(){var n,r=this;return U(this,(function(o){switch(o.label){case 0:return n=[],[4,L.request((function(){return I(r,void 0,void 0,(function(){var r;return U(this,(function(o){switch(o.label){case 0:return[4,b().get(t.BASE_URL+"locations/"+String(e)+"/catalogs",{headers:{"X-Access-Token":this.token},timeout:t.TIMEOUT})];case 1:if(void 0===(r=o.sent())||void 0===r.data)throw new S("failed to retrieve hubrise catalogs");return n=r.data,[2]}}))}))}),1,k.error.bind(k))];case 1:return o.sent(),[2,n]}}))}))},t.BASE_URL="http://api.hubrise.com/v1/",t.BASE_AUTH_URL="https://manager.hubrise.com/oauth2/v1/",t.TIMEOUT=15e3,t}(),N=function(){function t(){}return t.registerBasePath=function(e){void 0!==process.env.APP_HOME?t.BASE_PATH=process.env.APP_HOME+"/":t.BASE_PATH=e+(e.endsWith("/")?"":"/")},t.data=function(){return t.BASE_PATH+"data/"},t.db=function(){return t.storage()+"db/"},t.root=function(){return t.BASE_PATH},t.session=function(){return t.storage()+"session/"},t.storage=function(){return t.BASE_PATH+"storage/"},t.BASE_PATH="./",t}(),q=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),B=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadParameterException",r}return q(e,t),e}(E),F=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),H=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return F(e,t),e}(E),G=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),z=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return G(e,t),e}(E),W=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),J=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="DuplicateException",r}return W(e,t),e}(E),Z=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),V=function(t){function e(e,n){var r=t.call(this,e,500,n)||this;return r.name="InternalException",r}return Z(e,t),e}(E),X=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Y=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return X(e,t),e}(E),$=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),K=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return $(e,t),e}(E),Q=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),tt=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return Q(e,t),e}(E),et=function(){function t(){}return t.error=function(t,e,n){k.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;e.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),e.json({code:n.code,message:n.message})},t}(),nt=function(){function t(t){this.configuration=t}return t.prototype.handler=function(){var t=this;return function(e,n,r){try{var o=!1;if(o||void 0===t.configuration.jwt||(e.session={},o=!0),o||void 0===t.configuration.key||(o=t.authApiKey(e)),!o&&void 0!==t.configuration.session){var i=Object.keys(e.session);if(!Array.isArray(t.configuration.session.required))throw new P("session is not well formatted");t.configuration.session.required.forEach((function(t){if(!i.includes(t))throw new P("session is incomplete")})),o=!0}if(o||void 0===t.configuration.none||(o=t.authNone(e)),!o)throw new P("request is not authenticate");r()}catch(t){et.error(e,n,t)}}},t.prototype.authApiKey=function(t){if("string"!=typeof t.headers.Authorization||!t.headers.Authorization.startsWith("apiKey"))return!1;var e=t.headers.Authorization.split(" ");if(2!==e.length)throw new P("api key is not well formatted");if(e[1]!==this.configuration.key.secret)throw new P("api key is not valid");return t.session={},!0},t.prototype.authNone=function(t){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find((function(e){var n;return null===(n=t.originalUrl)||void 0===n?void 0:n.startsWith(e)}))||(t.session={},0))},t}(),rt=function(){function t(){}return t.prototype.can=function(t,e){},t}();const ot=require("crypto"),it=require("express"),at=require("cors"),st=require("compression"),ut=require("helmet");var ct=n.n(ut);const lt=require("connect-timeout");var ft=function(){function t(){}return t.prototype.create=function(e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),k.debug("start server on "+o),this.app=it(),this.app.set("trust proxy",!0),this.app.use(st({level:-1})),this.app.use(lt("300s")),this.app.use(it.json({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(it.urlencoded({limit:"10mb"})),this.app.use(at({origin:[o].concat(e),credentials:!0})),this.app.use(ct()()),this.app.use(it.json()),this.app.listen(r,(function(){k.debug("server is running on "+o)}))),[2,this.app]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{u(a.next(t))}catch(t){e(t)}}function s(t){try{u(a.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,s)}u((a=a.apply(r,o||[])).next())}));var r,o,i,a},t.prototype.getSessionSecret=function(e){return ot.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const pt=require("luxon");var dt=function(){function t(){}return t.isEmail=function(t){return"string"==typeof t&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(t)},t.isPhone=function(t){return"string"==typeof t&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(t)},t.isIntMobilePhone=function(t){var e=new RegExp("^\\+1[0-9]{10}$","i"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return e.test(t)||n.test(t)||r.test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}();const ht=require("iconv-lite");var mt=function(){function t(){}return t.isUTF8=function(t){return!t||"utf8"===(t=t.toLowerCase())||"utf-8"===t},t.urlencode=function(e,n){if(!n||t.isUTF8(n))return encodeURIComponent(e);for(var r=(0,ht.encode)(e,n),o="",i="",a=0;a<r.length;a++)1===(i=r[a].toString(16)).length&&(i="0"+i),o+="%"+i;return o.toUpperCase()},t}(),vt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},yt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},gt=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r){return vt(this,arguments,void 0,(function(e,n,r,o,i){var a,s=this;return void 0===o&&(o=!0),yt(this,(function(u){switch(u.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(k.warning(new B("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*t.MESSAGE_MAX_LENGTH?n=n.substring(0,2*t.MESSAGE_MAX_LENGTH):n.length>t.MESSAGE_MAX_LENGTH&&n.length<=1.33*t.MESSAGE_MAX_LENGTH&&(n=n.substring(0,t.MESSAGE_MAX_LENGTH))),[4,L.request((function(){return vt(s,void 0,void 0,(function(){var r,s,u;return yt(this,(function(c){switch(c.label){case 0:return r={accessToken:this.token,emetteur:e,message:mt.urlencode(n,"ISO-8859-15"),numero:a.map((function(t){return t.replace("+","")})).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/t.MESSAGE_MAX_LENGTH)},o&&(r.stop=1),void 0!==i&&(r.date_envoi=pt.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),s=pt.DateTime.fromISO(null!=i?i:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),o?s.hour>=21?r.date_envoi=s.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):s.hour<9&&(r.date_envoi=s.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):s.hour<8&&(r.date_envoi=s.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode!==x.TEST?[3,1]:(k.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===x.DEVELOPMENT&&(a=["+15145705214"]),[4,b().post(t.BASE_API_URL+"sendSMS.do",M.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((u=c.sent()).data.length>0&&"0"!==u.data.trim().substring(0,1))throw new S("Error: "+u.data,r);c.label=3;case 3:return[2]}}))}))}),0,k.error.bind(k))]);case 1:return u.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return dt.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const bt=require("path"),wt=require("mustache"),Et=require("fs");var _t=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}(this,(function(r){switch(r.label){case 0:n=0,r.label=1;case 1:return n<t.length?[4,e(t[n])]:[3,4];case 2:r.sent(),r.label=3;case 3:return n++,[3,1];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{u(i.next(t))}catch(t){e(t)}}function s(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,s)}u((i=i.apply(n,r||[])).next())}));var n,r,o,i},St=function(t){return new Promise((function(e){return setTimeout(e,t)}))};const Ot=require("color-name");var Tt=function(){function t(){}return t.code=function(e){null==e&&(e=6);for(var n="";n.length<e;)n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];return n},t.color=function(e){void 0===e&&(e=1);var n=t.rgbToHex(Math.round(255*e)),r="#000000"+n,o=Object.values(Ot);if(0===o.length)return r;var i=o[t.int(0,o.length-1)];return 3!==i.length?r:"#"+t.rgbToHex(i[0])+t.rgbToHex(i[1])+t.rgbToHex(i[2])+n},t.rgbToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},t.int=function(t,e){return null==t&&(t=0),null==e&&(e=Number.POSITIVE_INFINITY),t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},t.password=function(e){null==e&&(e=8);for(var n="";n.length<e;)switch(t.int(1,3)){case 1:n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];break;case 2:n+=t.symbolLowerCases[t.int(0,t.symbolLowerCases.length-1)];break;default:n+=String(t.int(0,9))}return n},t.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],t.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"],t}(),xt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Ct=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},At=function(){function t(){}return t.prototype.dirPath=function(t){var e=bt.resolve(t).lastIndexOf(bt.sep);return e<0?t:bt.resolve(bt.resolve(t).substr(0,e+1))+bt.sep},t.prototype.listFiles=function(t){return xt(this,void 0,void 0,(function(){var e,n,r,o=this;return Ct(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new B(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=Et.readdirSync(t),r=[],[4,_t(n,(function(n){return xt(o,void 0,void 0,(function(){return Ct(this,(function(o){return this.isFile(t+e+n)&&r.push(t+e+n),[2]}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.randomFile=function(t,e){return xt(this,void 0,void 0,(function(){var n,r;return Ct(this,(function(o){switch(o.label){case 0:return[4,this.listFiles(t)];case 1:return 0===(n=o.sent()).length?[2,void 0]:(r=void 0!==e?Math.max(e,0)%n.length:Tt.int(0,n.length-1),[2,n[r]])}}))}))},t.prototype.move=function(t,e){return xt(this,void 0,void 0,(function(){return Ct(this,(function(n){if(!this.isFile(t))throw new B(String(t)+" does not exist or is not a file");if(Et.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new B(String(e)+" does not exist or is not a directory");return[2,Et.renameSync(t,e+bt.basename(t))]}))}))},t.prototype.read=function(t){return xt(this,void 0,void 0,(function(){return Ct(this,(function(e){if(!this.isFile(t))throw new B(String(t)+" does not exist or is not a file");return[2,Et.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return xt(this,void 0,void 0,(function(){var e;return Ct(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new B(String(t)+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.readJsonFiles=function(t){return xt(this,void 0,void 0,(function(){var e,n,r,o=this;return Ct(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new B(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=Et.readdirSync(t),r=[],[4,_t(n,(function(n){return xt(o,void 0,void 0,(function(){var o,i,a;return Ct(this,(function(s){switch(s.label){case 0:return this.isFile(t+e+n)&&n.endsWith(".json")?(i=(o=r).push,a={name:n},[4,this.readJson(t+e+n)]):[3,2];case 1:i.apply(o,[(a.data=s.sent(),a)]),s.label=2;case 2:return[2]}}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.write=function(t,e){return xt(this,void 0,void 0,(function(){var n;return Ct(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),Et.mkdirSync(this.dirPath(t),{recursive:!0}),Et.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return xt(this,void 0,void 0,(function(){return Ct(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return Et.existsSync(t)&&Et.statSync(t).isDirectory()},t.prototype.isFile=function(t){return Et.existsSync(t)&&Et.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}();const Pt=require("clean-css"),jt=require("html-minifier-terser");var kt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Rt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Lt=function(){function t(){}return t.prototype.css=function(t){return kt(this,void 0,void 0,(function(){return Rt(this,(function(e){return[2,new Pt({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(t).styles]}))}))},t.prototype.html=function(t){return kt(this,void 0,void 0,(function(){return Rt(this,(function(e){switch(e.label){case 0:return[4,(0,jt.minify)(t,{collapseBooleanAttributes:!0,collapseInlineTagWhitespace:!0,collapseWhitespace:!0,continueOnParseError:!1,decodeEntities:!1,html5:!0,minifyCSS:!0,minifyJS:!0,noNewlinesBeforeTagClose:!0,preserveLineBreaks:!1,preventAttributesEscaping:!1,processConditionalComments:!1,quoteCharacter:'"',removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeEmptyElements:!0,removeOptionalTags:!1,removeRedundantAttributes:!0,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeTagWhitespace:!1})];case 1:return[2,e.sent()]}}))}))},t}(),Mt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},It=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Ut=function(){function t(){this.minifier=new Lt}return t.prototype.render=function(t,e,n){return Mt(this,void 0,void 0,(function(){var r,o,i,a,s,u=this;return It(this,(function(c){switch(c.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,h.cloneDeep)(e),o=bt.isAbsolute(t)?"":__dirname+bt.sep,[4,(new At).read(o+t)];case 1:return i=c.sent(),a=[],(0,wt.parse)(i).forEach((function(t){t.length>=4&&"&"===t[0]&&t[1].startsWith("include:")&&a.push(t[1])})),a.length>0?(void 0===n?n=bt.dirname(o+t)+bt.sep:bt.isAbsolute(n)||(n=o+n),[4,_t(a,(function(t){return Mt(u,void 0,void 0,(function(){var e,o,i,a;return It(this,(function(s){switch(s.label){case 0:return 3!==(e=t.split(":")).length||void 0===r[t]?[3,2]:(o=e[2],n.includes("/html")&&Object.keys(r[t]).forEach((function(e){r[t][e]=Array.isArray(r[t][e])?r[t][e].map((function(t){return t.replace(/(?:\r\n|\r|\n)/g,"<br>")})):r[t][e].replace(/(?:\r\n|\r|\n)/g,"<br>")})),i=r,a=t,[4,this.render(bt.resolve(n,o),r[t])]);case 1:i[a]=s.sent(),s.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:c.sent(),c.label=3;case 3:if((s=(0,wt.render)(i,r)).includes("{{")||s.includes("}}"))throw new z("template: missing data to render template",{templatePath:t,data:e});return[2,t.includes("html")?this.minifier.html(s):s]}}))}))},t}();const Dt=require("node-mailjet");var Nt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},qt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Bt=function(){function t(t,e,n){this.templateEngine=new Ut,this.mailjet=new Dt.Client({apiKey:t,apiSecret:e}),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return Nt(this,void 0,void 0,(function(){var r=this;return qt(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return Nt(r,void 0,void 0,(function(){var r,o;return qt(this,(function(i){switch(i.label){case 0:return void 0===n.base.copyright&&(n.base.copyright={year:String((new Date).getUTCFullYear())}),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/text")];case 1:return r=i.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return o=i.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:r,html:o}],!1)];case 3:return[2,i.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return Nt(this,void 0,void 0,(function(){var r=this;return qt(this,(function(o){switch(o.label){case 0:return[4,L.request((function(){return Nt(r,void 0,void 0,(function(){var r,o,i,a;return qt(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=s.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return i=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=s.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:o,html:a}],!1)];case 5:return[2,s.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return Nt(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),qt(this,(function(a){switch(a.label){case 0:return[4,L.request((function(){return Nt(i,void 0,void 0,(function(){var i,a,s,u;return qt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return s=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:s,base:n.base,isCommercial:r})];case 4:return u=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:u}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendUsersNotifications=function(t,e,n,r){return Nt(this,void 0,void 0,(function(){var o=this;return qt(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return Nt(o,void 0,void 0,(function(){var o,i=this;return qt(this,(function(a){switch(a.label){case 0:return o=[],[4,_t(e,(function(t){return Nt(i,void 0,void 0,(function(){var e,r,i,a;return qt(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/text")];case 1:return e=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=s.sent(),[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/html")];case 3:return i=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=s.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n){return Nt(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),qt(this,(function(a){switch(a.label){case 0:return[4,L.request((function(){return Nt(i,void 0,void 0,(function(){var i,a,s,u;return qt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return s=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:s,base:n.base,isCommercial:r})];case 4:return u=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:u}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendDiscounts=function(t,e){return Nt(this,arguments,void 0,(function(t,e,n,r){var o=this;return void 0===n&&(n=!0),qt(this,(function(i){switch(i.label){case 0:return[4,L.request((function(){return Nt(o,void 0,void 0,(function(){var o,i=this;return qt(this,(function(a){switch(a.label){case 0:return o=[],[4,_t(e,(function(t){return Nt(i,void 0,void 0,(function(){var e,r,i,a;return qt(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/text")];case 1:return e=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=s.sent(),[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/html")];case 3:return i=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=s.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,k.error.bind(k))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendNotification=function(t,e){return Nt(this,arguments,void 0,(function(t,e,n,r){var o,i,a=this;return void 0===n&&(n=!1),qt(this,(function(s){switch(s.label){case 0:if(0===e.length)throw new B("email: missing messages");s.label=1;case 1:return s.trys.push([1,6,,7]),this.mode!==x.TEST?[3,2]:(k.info("Simulation Mode: Email has been sent",{sender:t,recipients:e.map((function(t){return t.recipient}))}),[3,5]);case 2:return o=[],[4,_t(e,(function(e){return Nt(a,void 0,void 0,(function(){return qt(this,(function(i){return this.mode===x.DEVELOPMENT&&(e.recipient.contact="developer@onylab.com"),o.push({From:{Name:t.name,Email:t.contact},To:[{Name:e.recipient.name,Email:e.recipient.contact}],Subject:e.subject,TextPart:e.text,HTMLPart:e.html,Priority:n?0:2,customID:void 0===r?void 0:String(r)}),[2]}))}))}))];case 3:return s.sent(),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:o})];case 4:s.sent(),s.label=5;case 5:return[3,7];case 6:throw i=s.sent(),new E(i.message,Number(i.statusCode));case 7:return[2]}}))}))},t}(),Ft=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Ht=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Gt=function(){function t(e,n){this.filesystem=new At,void 0!==t.root&&t.root===e||(t.root=e,t.config=void 0);var r=void 0===n?C.getMode():n;void 0!==t.environment&&t.environment===r||(t.environment=void 0===n?C.getMode():n,t.config=void 0)}return t.prototype.full=function(){return Ft(this,void 0,void 0,(function(){return Ht(this,(function(e){switch(e.label){case 0:return[4,this.init()];case 1:return e.sent(),[2,t.config]}}))}))},t.prototype.init=function(){return Ft(this,void 0,void 0,(function(){var e,n,r,o;return Ht(this,(function(i){switch(i.label){case 0:return void 0!==t.config?[3,6]:void 0!==t.root?[3,1]:(t.config={},[3,6]);case 1:return e=t,[4,this.filesystem.readJson(t.root+"data/config.json")];case 2:if(e.config=i.sent(),![x.DEVELOPMENT,x.TEST].includes(t.environment))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),n=t,r=h.merge,o=[t.config],[4,this.filesystem.readJson(t.root+"data/config_"+String(t.environment)+".json")];case 4:return n.config=r.apply(void 0,o.concat([i.sent()])),[3,6];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))},t}();const zt=require("typeorm");var Wt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Jt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},Zt=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return Wt(this,void 0,void 0,(function(){var n,r;return Jt(this,(function(o){switch(o.label){case 0:return void 0!==this.db?[3,2]:[4,this.init()];case 1:o.sent(),o.label=2;case 2:return void 0===(n=this.db[t])?[3,4]:(n.entities=e,n.logging=["error"],n.logger=!0,n.bigNumberStrings=!1,void 0===n.timezone&&(n.timezone="Z"),void 0===n.charset&&(n.charset="UTF8_GENERAL_CI"),r=this,[4,(0,zt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:k.error(new B("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return Wt(this,void 0,void 0,(function(){return Jt(this,(function(t){switch(t.label){case 0:return void 0===this.connection?[3,2]:[4,this.connection.synchronize()];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.close=function(){return Wt(this,void 0,void 0,(function(){return Jt(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return Wt(this,void 0,void 0,(function(){var t,e;return Jt(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new At,e=this,[4,t.readJson(this.root+"data/db.json")];case 2:e.db=n.sent(),n.label=3;case 3:return[2]}}))}))},t}();const Vt=require("prettyjson");var Xt=function(){function t(){}return t.prototype.error=function(t){k.error(t)},t.prototype.info=function(t){k.trace(t)},t.prototype.json=function(t){k.trace(Vt.render(t,{}))},t.prototype.success=function(t){k.trace(t)},t}(),Yt=function(){function t(){this.fileSystem=new At}return t.prototype.image=function(t,e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}(this,(function(i){switch(i.label){case 0:return void 0===n&&(n=ot.randomBytes(20).toString("hex")+bt.extname(t)),[4,this.fileSystem.write(e+bt.sep+n,"")];case 1:return i.sent(),r=bt.resolve(e+bt.sep+n),o=Et.createWriteStream(r),[4,b()({url:t,method:"GET",responseType:"stream"})];case 2:return i.sent().data.pipe(o),[2,new Promise((function(t,e){o.on("finish",(function(){return t(r)})),o.on("error",e)}))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{u(a.next(t))}catch(t){e(t)}}function s(t){try{u(a.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,s)}u((a=a.apply(r,o||[])).next())}));var r,o,i,a},t}();const $t=require("fast-diff");var Kt=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.hash=function(t,e){void 0===e&&(e=0);for(var n=3735928559^e,r=1103547991^e,o=0,i=void 0;o<t.length;o++)i=t.charCodeAt(o),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),((r^=Math.imul(n^n>>>13,3266489909))>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")},t.nullable=function(t){return j(t)||"string"==typeof t&&0===t.length?null:t},t.removeMultiSpaces=function(t){return"string"!=typeof t?t:t.replace(/\s{2,}/g," ")},t.removeText=function(e,n){if("string"!=typeof e||"string"!=typeof n||0===n.length)return e;try{e=(e=e.replace(new RegExp(t.escapeRegExp(n),"ig"),"")).replace(new RegExp(t.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(t){}return e},t.replace=function(e,n,r){if("string"!=typeof e)return e;if(n.length!==r.length)return e;var o=e;return n.forEach((function(e,n){o=o.replace(new RegExp(t.escapeRegExp(e),"ig"),r[n])})),o},t.slugify=function(t,e){return void 0===e&&(e=""),void 0===t?"":(0,h.toLower)((0,h.trim)((0,h.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return j(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),Qt=function(){function t(){}return t.trim=function(t){return"string"==typeof t?t.trim():t},t.capitalize=function(e){var n=t.lower(e);return"string"==typeof n?n.split(" ").map((function(t){return t.charAt(0).toUpperCase()+t.slice(1)})).join(" "):e},t.ucfirst=function(e){var n=t.lower(e);return"string"==typeof n?n.charAt(0).toUpperCase()+n.slice(1):e},t.lower=function(t){return"string"==typeof t?t.toLocaleLowerCase():t},t.upper=function(t){return"string"==typeof t?t.toLocaleUpperCase():t},t.phone=function(e,n,r){if(void 0===r&&(r="nat"),"string"==typeof e)switch(e=t.preformatPhone(e,n),r){case"nat":return t.phoneNat(e,n);case"int":return t.phoneInt(e,n)}return e},t.stripEmoji=function(t){var e=t;if("string"==typeof e)for(var r=n(16),o=void 0;null!==(o=r().exec(e));)try{e=(e=(e=e.replace(new RegExp(Kt.escapeRegExp(o[0]),"g"),"")).replace(new RegExp("\\s+","g")," ")).trim()}catch(t){}return e},t.stripExoticCharacters=function(t){return"string"==typeof t?t.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):t},t.preformatPhone=function(t,e){return t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e&&new RegExp("^[1-9]").test(t)&&9===t.length?"0"+t:t},t.phoneNat=function(t,e){if("fr"===e){if(t.startsWith("+330")?t=t.substring(3):t.startsWith("+33")?t="0"+t.substring(3):t.startsWith("0033")?t="0"+t.substring(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substring(2)),10===t.length){var n=0;t=t.split("").map((function(t){return t+(++n%2==0?" ":"")})).join("").trim()}return t}return t},t.phoneInt=function(t,e){return t.startsWith("+")?t:"fr"===e?(t.startsWith("0")&&(t=t.substring(1)),"+33"+t):t},t}(),te=function(){function t(){}return t.autoCorrectCity=function(e){if(j(e)||"string"!=typeof e||0===e.length)return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));var n=Object.values(t.ZIPCODE_CITY).flat(),r=n.find((function(t){return t.toLowerCase()===e.toLowerCase()}));if(void 0!==r)return r;var o=n.find((function(n){var r=t.countDiff(e,n);return r.add<=2&&r.remove<=2}));if(void 0!==o)return o;var i=n.find((function(t){return t.replace(/-/g," ").toLowerCase()===e.toLowerCase()}));if(void 0!==i)return i;var a=n.find((function(n){var r=t.countDiff(e,n.replace(/-/g," "));return r.add<=2&&r.remove<=2}));if(void 0!==a)return a;var s=n.find((function(t){return t.toLowerCase().startsWith(e.toLowerCase())}));if(void 0!==s)return s;var u=n.find((function(t){return e.toLowerCase().includes(t.toLowerCase())}));return void 0!==u?u:e},t.autoCorrectStreet=function(e){if(j(e)||"string"!=typeof e||0===e.length)return e;t.STREET_TYPE.forEach((function(t){t.short.length<t.long.length&&(e=(e=e.replace(new RegExp("(\\s"+String(t.short)+"\\.?\\s)","ig")," "+String(t.long)+" ")).replace(new RegExp("(\\s"+String(t.short)+"\\.\\s)","ig")," "+String(t.long)+" "))}));var n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==n&&2===n.length&&(e=e.substring(n[1].length)),t.STREET_TYPE.forEach((function(t){e=(e=e.replace(new RegExp("([0-9]+)("+String(t.long)+"\\s)","ig"),"$1 $2")).replace(new RegExp("([0-9]+)("+String(t.short)+"\\.?\\s)","ig"),"$1 "+String(t.long)+" ")})),e},t.getZipCodeFromCity=function(e){if(!j(e))return Object.keys(t.ZIPCODE_CITY).reduce((function(n,r){return void 0!==t.ZIPCODE_CITY[r].find((function(t){return t.toLowerCase()===e.toLowerCase()}))?r:n}),void 0)},t.getCityFromZipCode=function(e,n){if(void 0!==e&&void 0!==n){var r,o=t.ZIPCODE_CITY[e];if(void 0!==o)return 1===o.length?o[0]:(n.split(",").forEach((function(t){r=o.find((function(e){return t.trim().toLowerCase()===e.trim().toLowerCase()}))})),void 0!==r?r:o[0])}},t.isZipCode=function(e){return"string"==typeof e&&(!!Object.keys(t.ZIPCODE_CITY).includes(e)||dt.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!j(e)){var o=e.split(",");if(o.length>=3&&n){void 0===t.COUNTRIES.find((function(t){return e.toLowerCase().includes(" "+t.toLowerCase())}))&&o.push("France");var i=o.length-1;if(r.country=o[i].trim(),o.splice(i--,1),void 0!==o[i]&&o[i].trim().includes(" ")){var a=o[i].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),o.splice(i--,1)}else isNaN(Number(o[i].trim()))?isNaN(Number(o[i-1].trim()))?(r.city=o[i].trim(),o.splice(i--,1)):(r.city=o[i].trim(),o.splice(i--,1),r.zip=o[i].trim(),o.splice(i--,1)):(r.zip=o[i].trim(),o.splice(i--,1),i>=2&&(r.city=o[i].trim(),o.splice(i--,1)));r.street=o.map((function(t){return t.trim()})).join(" ").trim()}else{var s=e.toLowerCase();Object.keys(t.ZIPCODE_CITY).forEach((function(t){if(s.includes(t)){r.zip=t;try{s=s.replace(new RegExp(Kt.escapeRegExp(t),"ig"),"")}catch(t){}}})),Object.values(t.ZIPCODE_CITY).flat().forEach((function(e){var n;if(s.includes(e.toLowerCase())&&(void 0===r.zip||(null===(n=t.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find((function(t){return t.toLowerCase()===e.toLowerCase()}))))){r.city=e;try{s=s.replace(new RegExp(Kt.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(s.includes(" "+t.toLowerCase())&&!s.includes("de "+t.toLowerCase())&&!s.includes("de la "+t.toLowerCase())){r.country=t;try{s=s.replace(new RegExp(Kt.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=(0,h.trim)(s.split(",").map((function(t){return t.trim()})).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=Qt.lower(Qt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=Qt.upper(Qt.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(Qt.capitalize(Qt.trim(String(r.city))))),void 0!==r.country&&(r.country=Qt.capitalize(Qt.trim(String(r.country)))),t.complete(r)},t.complete=function(e){if(void 0===e.city||0===e.city.length){var n=t.getCityFromZipCode(e.zip,e.street);void 0!==n&&(e.city=n)}return"string"==typeof e.street&&t.REGIONS.forEach((function(t){e.street=Kt.removeText(e.street,t).trim()})),"fr"===Qt.lower(e.country)&&(e.country="France"),e},t.removeDuplicates=function(t){if("string"!=typeof t)return t;var e=[];return t.split(",").forEach((function(t){void 0===e.find((function(e){return e.trim().toLowerCase().includes(t.trim().toLowerCase())}))&&e.push(t)})),e.join(",")},t.countDiff=function(t,e){var n={add:0,remove:0};return $t(t.toLowerCase(),e.toLowerCase()).forEach((function(t){switch(t[0]){case-1:n.remove+=t[1].length;break;case 1:n.add+=t[1].length}})),n},t.ZIPCODE_CITY={78500:["Sartrouville"],78600:["Maisons-Laffitte","Le Mesnil-le-Roi"],78800:["Houilles"],95240:["Cormeilles-en-Parisis"],95530:["La Frette-sur-Seine"],78100:["Saint-Germain-en-Laye"],95100:["Argenteuil"],78630:["Orgeval","Morainvilliers"],78670:["Villennes-sur-Seine","Medan"],78240:["Chambourcy","Aigremont"],78300:["Poissy"],78510:["Triel-sur-Seine"],78570:["Andrésy","Chanteloup-les-Vignes"],78700:["Conflans-Sainte-Honorine"],78480:["Verneuil-sur-Seine"],78750:["Mareil-Marly"],78620:["L'Étang-la-Ville"],78160:["Marly-le-Roi"],78580:["Les Alluets-le-Roi"],78955:["Carrières-sous-Poissy"],78260:["Achères"],78540:["Vernouillet"],78920:["Ecquevilly"],95150:["Taverny"],95250:["Beauchamp"],95480:["Pierrelaye"],95320:["Saint-Leu-la-Forêt"],95550:["Bessancourt"],95370:["Montigny-lès-Cormeilles"],95220:["Herblay"],95740:["Frépillon"],95540:["Méry-sur-Oise"],95870:["Bezons"],78420:["Carrières-sur-Seine"],78400:["Chatou"],78110:["Le Vésinet"],78360:["Montesson"],78290:["Croissy-sur-Seine","Croissy"],78230:["Le Pecq"],95600:["Eaubonne"]},t.REGIONS=["île-de-france"],t.COUNTRIES=["France","FR"],t.STREET_TYPE=[{short:"av",long:"avenue"},{short:"rue",long:"rue"},{short:"bd",long:"boulevard"},{short:"chau",long:"chaussée"},{short:"trav",long:"traverse"},{short:"pl",long:"place"},{short:"pass",long:"passage"},{short:"sent",long:"sentier"},{short:"imp",long:"impasse"},{short:"all",long:"allée"},{short:"chem",long:"chemin"},{short:"ham",long:"hameau"},{short:"dom",long:"domaine"}],t}(),ee=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=pt.DateTime.fromISO(t.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return t;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===e?pt.DateTime.fromISO(t).toFormat("yyyy-LL"):pt.DateTime.fromISO(t).toISODate()},t.displayWeekDay=function(e){var n="";return void 0!==t.WEEK_DAYS[e]&&(n=t.WEEK_DAYS[e]),n},t.generatePeriod=function(e,n,r,o,i,a){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES),void 0===a&&(a="daily");for(var s={daily:{day:1},weekly:{week:1},monthly:{month:1}}[a],u=pt.DateTime.fromISO(e,{setZone:!0}).toISODate(),c=pt.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};u<=c&&l<i;){var p=t.getCycleDateFromFullDate(u,a);f[p]=(0,h.cloneDeep)(r),o&&(f[p].date=p),u=pt.DateTime.fromISO(u,{setZone:!0}).plus(s).toISODate(),l++}return f},t.getOpenPeriods=function(t,e){var n=[];return t.forEach((function(t){for(var r=[t],o=function(){var t=r[0];if(void 0===e.find((function(e){return e.from<=t.from&&t.to<=e.to}))){var o=e.find((function(e){return e.from<=t.from&&t.from<e.to&&e.to<t.to}));if(void 0!==o)r.push({from:o.to,to:t.to});else{var i=e.find((function(e){return t.from<e.from&&t.to>e.from&&t.to<=e.to}));if(void 0!==i)r.push({from:t.from,to:i.from});else{var a=e.find((function(e){return t.from<e.from&&e.to<t.to}));void 0!==a?(r.push({from:t.from,to:a.from}),r.push({from:a.to,to:t.to})):n.push(t)}}}r.shift()};r.length>0;)o()})),n},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=pt.DateTime.fromISO(t,{setZone:!0}).toISO(),o=pt.DateTime.fromISO(e,{setZone:!0}).plus({seconds:n}).toISO();return r>o?o:r}},t.localeToISO=function(t){var e,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),o=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(t))e=(i=t.split("/"))[2]+"-"+i[1]+"-"+i[0];else if(r.test(t)){var i;e=(i=t.split("-"))[2]+"-"+i[1]+"-"+i[0]}else o.test(t)&&(e=t);return e},t.slotToTime=function(t){var e,n=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),r=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");return t=t.trim(),n.test(t)?e=t.trim()+":00":r.test(t)&&(e=t.split("-")[0].trim()+":00"),e},t.delay=function(t,e,n){return j(t)||j(e)?0:Math.round(Math.abs(pt.DateTime.fromISO(t,{setZone:!0}).toUTC().diff(pt.DateTime.fromISO(e,{setZone:!0}).toUTC(),[n])[n]))},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=pt.DateTime.fromISO(t,{setZone:!0});return pt.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.min=function(t){return t.reduce((function(t,e){return"string"!=typeof t||t>e?e:t}),void 0)},t.max=function(t){return t.reduce((function(t,e){return void 0===t||t<e?e:t}),void 0)},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),ne=function(){function t(){}return t.phone=function(t,e){if("string"==typeof t&&(t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(t);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},t}(),re=function(){function t(){}return t.avg=function(e){if(0===e.length)return 0;var n=e.reduce((function(t,e){return t+e}),0);return t.round(n/e.length,2)},t.applyVariation=function(t,e){return t*(t>=0?1+e/100:1-e/100)},t.median=function(e){if(0===e.length)return 0;if(1===e.length)return e[0];var n=e.sort((function(t,e){return t-e}));return n.length%2==0?t.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.length/2)]},t.percentage=function(t,e){if("number"==typeof t&&"number"==typeof e)return 0===e?0:t/e*100},t.round=function(t,e){return"number"!=typeof t?t:0===e?Math.round(t):Math.round(t*Math.pow(10,e))/Math.pow(10,e)},t.variation=function(t,e){var n=0;return 0!==e?n=0!==t?(e-t)/Math.abs(t)*100:100*(e>0?1:-1):0!==t&&(n=-100*(t>0?1:-1)),Math.floor(n)},t}(),oe=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,h.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,h.isArray)(e)&&e.length>0||(0,h.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,h.isArray)(e)&&!(0,h.isObject)(e))&&r.push(e)})),r}if((0,h.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,h.isArray)(i)||(0,h.isObject)(i)?(i=t.compact(i,n),((0,h.isArray)(i)&&i.length>0||(0,h.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,h.isArray)(i)&&!(0,h.isObject)(i))&&(o[r]=i)):null!=i&&("string"!=typeof i||!1===n.removeEmptyString||i.length>0)&&(o[r]=i)})),o}return"string"!=typeof e||!1===n.removeEmptyString||e.length>0?e:void 0},t}(),ie=function(){function t(){}return t.applyTaxes=function(t,e,n){void 0===n&&(n=2);var r=Number(t);return e.forEach((function(e){r+=Number(t)*e})),String(re.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),re.round(n,2)},t.displayWithCurrency=function(e,n){if(null==e)return e;var r=t.currencies[n],o=e+" "+n;if(void 0!==r)switch(r.position){case"before":o=r.symbol+e;break;case"after":o=e+r.symbol}return o},t.format=function(t,e,n){if(void 0===n&&(n=2),null==t)return t;var r=Number(t.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:n,maximumFractionDigits:n});switch(e){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}},t.round=function(t,e){void 0===e&&(e=.1);var n=100*Number(t),r=100*e,o=n%r;return String(re.round(n-o+(o<Math.ceil(r/2)?0:r),2)/100)},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}();return r})()));
2
2
  //# sourceMappingURL=common-api.node.min.js.map