reslib 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/build/auth/errors.js +2 -2
  2. package/build/auth/index.js +2 -2
  3. package/build/countries/index.js +1 -1
  4. package/build/currency/index.d.ts +157 -29
  5. package/build/currency/index.js +2 -2
  6. package/build/currency/session.js +1 -1
  7. package/build/currency/utils.d.ts +2 -2
  8. package/build/currency/utils.js +1 -1
  9. package/build/exception/index.js +2 -2
  10. package/build/i18n/index.js +1 -1
  11. package/build/inputFormatter/index.d.ts +5 -5
  12. package/build/inputFormatter/index.js +2 -2
  13. package/build/logger/index.js +1 -1
  14. package/build/resources/index.js +3 -3
  15. package/build/session/index.js +1 -1
  16. package/build/utils/date/dateHelper.js +1 -1
  17. package/build/utils/date/index.js +1 -1
  18. package/build/utils/index.js +3 -3
  19. package/build/utils/isPromise.d.ts +3 -2
  20. package/build/utils/isPromise.js +1 -1
  21. package/build/utils/numbers.js +2 -2
  22. package/build/validator/index.js +3 -3
  23. package/build/validator/rules/array.js +2 -2
  24. package/build/validator/rules/boolean.js +2 -2
  25. package/build/validator/rules/date.js +2 -2
  26. package/build/validator/rules/default.js +2 -2
  27. package/build/validator/rules/enum.js +2 -2
  28. package/build/validator/rules/file.js +2 -2
  29. package/build/validator/rules/format.js +3 -3
  30. package/build/validator/rules/ifRule.js +2 -2
  31. package/build/validator/rules/index.js +3 -3
  32. package/build/validator/rules/multiRules.js +2 -2
  33. package/build/validator/rules/numeric.js +2 -2
  34. package/build/validator/rules/object.js +2 -2
  35. package/build/validator/rules/string.js +2 -2
  36. package/build/validator/rules/target.js +2 -2
  37. package/build/validator/validator.d.ts +1 -1
  38. package/build/validator/validator.js +2 -2
  39. package/package.json +15 -14
@@ -2,4 +2,4 @@
2
2
  %{failedRulesErrors}`,oneOf:`The field %{fieldName} must match at least one of the following validation rules:
3
3
  %{failedRulesErrors}`,allOf:`The field %{fieldName} must match all of the following validation rules:
4
4
  %{failedRulesErrors}`,validateNested:`The field %{fieldName} must be a valid nested object. Errors:
5
- %{nestedErrors}`,validateNestedInvalidType:"The field %{fieldName} must be an object, but received %{receivedType}",dateAfter:"This field must be after %{date}",dateBefore:"This field must be before %{date}",dateBetween:"This field must be between %{startDate} and %{endDate}",dateEquals:"This field must be equal to %{date}",futureDate:"This field must be a date in the future",pastDate:"This field must be a date in the past",file:"This field must be a valid file",fileSize:"This field must not exceed %{maxSize} bytes",fileType:"This field must be one of the following types: %{allowedTypes}",image:"This field must be a valid image file",fileExtension:"This field must have one of the following extensions: %{allowedExtensions}",minFileSize:"This field must be at least %{minSize} bytes",uuid:"This field must be a valid UUID",json:"This field must be valid JSON",base64:"This field must be valid Base64 encoded data",hexColor:"This field must be a valid hexadecimal color code",creditCard:"This field must be a valid credit card number",ip:"This field must be a valid IP address (version %{version})",macAddress:"This field must be a valid MAC address",matches:"This field must match the pattern %{pattern}",mongoId:"This field must be a valid MongoDB ObjectId",hexadecimal:"This field must be a valid hexadecimal value",object:"This field must be an object",isObject:"This field must be an object",invalidBulkData:"Invalid bulk data: an array is required",bulkValidationFailed:{one:"Bulk validation failed: 1 of %{totalCount} items failed",other:"Bulk validation failed: %{failureCount} of %{totalCount} items failed"},bulkValidationAllFailed:{one:"Validation failed for the single item",other:"All %{totalCount} items failed validation"},bulkValidationPartialFailure:"%{failureCount} items failed validation",separators:{multiple:", ",single:", "},nestedErrors:{separator:"; ",prefix:"",suffix:""},tests:{entity:{name:"Name",id:"Id",email:"Email",aString:"A String",url:"Url",note:"Note",createdAt:"Created At",updatedAt:"Updated At"}}};var De={auth:Q,currencies:q,countries:w,dates:X,resources:_,validator:ee};function l(t){return !!(t&&typeof t=="string")}function f(...t){for(var e in t){let i=t[e];if(l(i))return i}return ""}function W(t){return !!(t==null||typeof t=="undefined"||typeof t=="string"&&t===""||Array.isArray(t)&&!t.length)}function p(t){return typeof t=="number"&&!isNaN(t)&&isFinite(t)}function I(t){return !t||typeof t!="object"?false:t instanceof Date?true:typeof t.getTime!="function"?false:!(Object.prototype.toString.call(t)!=="[object Date]"||isNaN(t.getTime()))}var s=class s{static parseString(e,i){if(l(e)&&l(i))try{let a=Y__default.default(e,i,!0);if(a.isValid())return {date:a.toDate(),matchedFormat:i,isValid:!0}}catch(a){}try{if(Array.isArray(i)&&(i!=null&&i.length))for(let a of i){let r=te(e,a);if(r)return r}for(let a of s.DATE_FORMATS){let r=te(e,a);if(r)return r}return {date:null,matchedFormat:null,isValid:!1,error:"Unable to parse date string with any known format"}}catch(a){return {date:null,matchedFormat:null,isValid:false,error:a instanceof Error?a.message:"Unknown error occurred while parsing date"}}}static toIsoString(e){let i=e?s.parseDate(e):new Date;return i?i.toISOString():""}static isoStringToDate(e){return new Date(e)}static parseDate(e,i){if(s.isDateObj(e))return e;if(!l(i)){let a=s.parseString(e);return a!=null&&a.isValid?a.date:null}if(W(e))return null;try{let a=Y__default.default(e,i,!0);if(a!=null&&a.isValid())return a.toDate()}catch(a){console.error(a," parsing date with moment : ",e," format is : ",i);}return null}static toSQLDateTimeFormat(e){if(!s.isDateObj(e))return "";let i=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return `${i}-${a}-${r} ${o}:${n}:${c}`}static getI18n(e){return P.isI18nInstance(e)?e:P.getInstance()}static getDefaultDateTimeFormat(e){return f(this.getI18n(e).get("dates.defaultDateTimeFormat"),"YYYY-MM-DD HH:mm")}static getDefaultDateFormat(e){return f(this.getI18n(e).get("dates.defaultDateFormat"),"YYYY-MM-DD")}static toSQLDateFormat(e){if(!s.isDateObj(e))return "";let i=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return `${i}-${a}-${r}`}static toSQLTimeFormat(e){if(!s.isDateObj(e))return "";let i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),r=String(e.getSeconds()).padStart(2,"0");return `${i}:${a}:${r}`}static getDefaultTimeFormat(e){return f(this.getI18n(e).get("dates.defaultTimeFormat"),"HH:mm")}static isValidDate(e,i){if(e==null||typeof e=="boolean")return false;if(s.isDateObj(e))return true;if(p(e)){let r=new Date(e);return r&&!isNaN(r.getTime())}if(l(e))return !!s.parseDate(e,i);if(e!=null&&e.toString&&(e==null?void 0:e.toString())==parseInt(e).toString())return false;let a=new Date(e);return s.isDateObj(a)}static addToDate(e,i,a){if(p(e)||(e=0),W(i)&&(i=new Date),s.isValidDate(i)&&l(i)&&(i=new Date(i)),s.isValidDate(i)||(i=l(i)?new Date(i):new Date),l(a)&&typeof i["set"+a]=="function"&&typeof i["get"+a]=="function"){let r="set"+a,o="get"+a;i=new Date(i[r](i[o]()+e));}return i}static addDays(e,i){return s.addToDate(e,i,"Date")}static addMilliseconds(e,i){return p(e)||(e=0),s.isDateObj(i)||(i=new Date),i=i||new Date,new Date(i.getTime()+e)}static addSeconds(e,i){return p(e)||(e=0),s.addMilliseconds(e*1e3,i)}static addMinutes(e,i){return p(e)||(e=0),s.addMilliseconds(e*6e4,i)}static addHours(e,i){return p(e)||(e=0),s.addMilliseconds(e*36e5,i)}static addMonths(e,i,a){return s.addToDate(e,i,"Month")}static addWeeks(e,i){return e=(p(e)?e:0)*7,s.addToDate(e,i,"Date")}static addYears(e,i){p(e)||(e=0);let a=new Date(s.addToDate(0,i)),r=a.getFullYear();return r+e<0?e=0:e+=r,a.setFullYear(e),new Date(a)}static formatDate(e,i){try{let a=Y__default.default(e);if(a.isValid())return a.format(f(i,s.getDefaultDateTimeFormat()))}catch(a){}return f(s.isValidDate(e)?e==null?void 0:e.toString():"")}static getUTCDateTimeDetails(e){let i=e?Y__default.default.utc(e):Y__default.default.utc();return {year:i.year(),day:i.day(),month:i.month(),monthString:i.format("MM"),hours:i.hours(),date:i.date(),minutes:i.minutes(),seconds:i.seconds(),monthName:i.format("MMMM"),dayName:i.format("dddd"),dayNameShort:i.format("ddd")}}};s.DATE_FORMATS=["YYYY-MM-DD","YYYY-MM-DDTHH:mm:ss","YYYY-MM-DDTHH:mm:ssZ","YYYY-MM-DDTHH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss[Z]","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DDTHH:mm:ss.SSSZ ","YYYY-MM-DDTHH:mm:ss.SSS","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DD HH:mm:ssZ","YYYY-MM-DD HH:mmZ","MM/DD/YYYY","MM-DD-YYYY","MM.DD.YYYY","MM/DD/YY","MMMM DD, YYYY","MMM DD, YYYY","DD/MM/YYYY","DD-MM-YYYY","DD.MM.YYYY","DD/MM/YY","DD MMMM YYYY","DD MMM YYYY","HH:mm:ss.SSSZ","HH:mm:ssZ","HH:mmZ","YYYYMMDD","YYYYMMDDTHHMM","YYYYMMDDTHHMMSS","HH:mm:ss","HH:mm","hh:mm A","h:mm A","HH:mm:ss.SSS","YYYY-DDD","YYYY-Www","YYYY-Www-D","YYYY/MM/DD","YYYY.MM.DD","MMM D, YYYY","MMMM D, YYYY","D MMM YYYY","D MMMM YYYY","MMM D YYYY","ddd, DD MMM YYYY HH:mm:ss ZZ","ddd, DD MMM YYYY HH:mm:ss","dddd, MMMM D, YYYY","dddd, D MMMM YYYY","hh:mm:ss A","H:mm:ss","YYYY-[W]WW","YYYY-[W]WW-E","YYYY-MM-DDTHH:mm:ss.SSS","DD-MM-YYYY HH:mm:ss","YYYY/MM/DD HH:mm:ss","YYYY.MM.DD HH:mm:ss","DD/MM/YYYY HH:mm:ss","MMM D YYYY, h:mm a","MMMM D YYYY, h:mm a","h:mm A MMM D, YYYY","MMMM D, YYYY","YY-MM-DD","DD-MM-YY","MM/DD/YY","MMM DD, YY","D MMM YY","D MMMM YY","YYYY MMM D","YYYY-MM-DD HH:mm","YYYY-MM-DD HH:mm:ss.SSS"],s.SQL_DATE_FORMAT="YYYY-MM-DD",s.SQL_DATE_TIME_FORMAT="YYYY-MM-DD HH:mm:ss",s.SQL_TIME_FORMAT="HH:mm:ss",s.getCurrentMonthDaysRange=e=>{let i=s.isValidDate(e)?new Date(e):new Date().resetHours2Minutes2Seconds(),a=new Date(i.getFullYear(),i.getMonth(),1),r=new Date(i.getFullYear(),i.getMonth()+1,0);return {first:a,last:r}},s.getPreviousWeekDaysRange=e=>{let i=s.isValidDate(e)?new Date(e):new Date().resetHours2Minutes2Seconds(),a=new Date(i.getTime()-3600*24*7*1e3),r=new Date(a),o=a.getDay(),n=a.getDate()-o+(o===0?-6:1),c=new Date(a.setDate(n)),d=new Date(r.setDate(n+6));return {first:c,last:d}},s.getCurrentWeekDaysRange=e=>{let i=s.isValidDate(e)?new Date(e):new Date().resetHours2Minutes2Seconds(),a=i.getDay(),r=i.getDate()-a+(a==0?-6:1),o=new Date(i),n=new Date(i.setDate(r));return o.setDate(o.getDate()+6),{first:n,last:o}},s.isDateObj=I;var C=s,te=(t,e)=>{let i=Y__default.default(t,e,true);try{if(i.isValid()&&i.format(e)===t||Y__default.default.utc(i,!0).format(e)===t)return {date:i.toDate(),matchedFormat:e,isValid:!0}}catch(a){}return null};Date.prototype.toSQLDateTimeFormat=function(){return C.toSQLDateTimeFormat(this)};Date.prototype.toSQLDateFormat=function(){return C.toSQLDateFormat(this)};Date.prototype.toSQLTimeFormat=function(){return C.toSQLTimeFormat(this)};Date.prototype.resetHours=function(){return this.setHours(0),this};Date.prototype.resetMinutes=function(){return this.setMinutes(0),this};Date.prototype.resetSeconds=function(){return this.setSeconds(0),this};Date.prototype.resetMilliseconds=function(){return this.setMilliseconds(0),this};Date.prototype.resetHours2Minutes2Seconds=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this};Date.prototype.toFormat=function(t){return C.formatDate(this,t)};Date.prototype.addYears=function(t){return C.addYears(t,this)};Date.prototype.addMonths=function(t){return C.addMonths(t,this)};Date.prototype.addMinutes=function(t){return C.addMinutes(t,this)};Date.prototype.addSeconds=function(t){return C.addSeconds(t,this)};Date.prototype.addDays=function(t){return C.addDays(t,this)};Date.prototype.addWeeks=function(t){return C.addWeeks(t,this)};Date.prototype.addHours=function(t){return C.addHours(t,this)};var T=class T{static get logger(){let e=Reflect.getMetadata(T.loggerMetaData,T);return ie(e)&&(this._logger=e),this._logger?this._logger:console}static set logger(e){ie(e)&&Reflect.defineMetadata(T.loggerMetaData,e,T);}static _log(e,...i){let a=T.logger;e=f(e),e&&typeof a[e]=="function"?a[e](T.getDateTimeString(),...i):console.log("Logger level not found : [",e,"]",...i);}static getDateTimeString(){let{day:e,year:i,hours:a,minutes:r,seconds:o,dayNameShort:n,monthName:c}=C.getUTCDateTimeDetails(),d=e<10?"0"+e:e,u=a<10?"0"+a:a,M=r<10?"0"+r:r,S=o<10?"0"+o:o;return "["+[n,d,c,i].join(" ")+" "+[u,M,S].join(":")+"]"}static log(...e){this._log("log",...e);}static info(...e){this._log("info",...e);}static debug(...e){this._log("debug",...e);}static warn(...e){this._log("warn",...e);}static error(...e){this._log("error",...e);}};T.loggerMetaData=Symbol("logger-meta-data");var N=T,ie=t=>{if(!t)return false;try{return ["warn","info","error"].every(e=>typeof t[e]=="function")}catch(e){return false}};function Me(t){return typeof t=="boolean"||!t||typeof t=="number"||typeof t=="string"||typeof t=="symbol"?false:Object(t).constructor===Promise||t.constructor&&(t.constructor.name==="Promise"||t.constructor.name==="AsyncFunction")||t instanceof Promise||typeof(t==null?void 0:t.then)=="function"&&typeof(t==null?void 0:t.catch)=="function"&&typeof(t==null?void 0:t.finally)=="function"?true:t&&typeof t.constructor=="function"&&Function.prototype.toString.call(t.constructor).replace(/\(.*\)/,"()")===Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()")}function ae(t){return t&&Object.prototype.toString.call(t)==="[object Promise]"?true:Me(t)}function re(){return typeof window!="undefined"&&(window==null?void 0:window.document)!==void 0&&typeof document!="undefined"&&typeof navigator!="undefined"}var E=()=>{var t;try{if(typeof process!="undefined"&&(process!=null&&process.versions)&&((t=process==null?void 0:process.versions)!=null&&t.node)||typeof global=="object"&&(global==null?void 0:global.toString.call(global))==="[object global]")return !0}catch(e){}return false},Pe=()=>{var t,e;return !!(typeof window!="undefined"&&window&&typeof(window==null?void 0:window.process)=="object"&&((t=window==null?void 0:window.process)==null?void 0:t.type)==="renderer"||typeof process!="undefined"&&typeof(process==null?void 0:process.versions)=="object"&&((e=process.versions)!=null&&e.electron)||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&String(navigator==null?void 0:navigator.userAgent).toLowerCase().indexOf("electron")>=0)},Te=()=>{if(typeof document!="undefined"&&document)try{return document.createEvent("TouchEvent"),!0}catch(t){try{return "ontouchstart"in window||"onmsgesturechange"in window}catch(e){}}return false},be=()=>typeof window=="undefined"&&typeof process!="undefined",oe=()=>!!(typeof window!="undefined"&&typeof window=="object"&&window),Se=()=>{if(!re()||typeof navigator!="object"||!navigator||typeof navigator.userAgent!="string")return false;let t=navigator.userAgent.toLowerCase();return /android/i.test(t)},Ye=()=>{var t;return !oe()||!(window!=null&&window.ReactNativeWebView)?false:typeof((t=window==null?void 0:window.ReactNativeWebView)==null?void 0:t.postMessage)=="function"},we=()=>E()&&process.platform==="darwin",Ae=()=>E()&&process.platform==="win32",Ie=()=>E()&&process.platform==="linux",ne={isWeb:re,isLinux:Ie,isDarwin:we,isWin32:Ae,isNode:E,isElectron:Pe,isTouchDevice:Te,isServerSide:be,isClientSide:oe,isAndroidMobileBrowser:Se,isReactNativeWebview:Ye};var A=class t{static decycle(e,i=[]){if(typeof e=="function")return;if(!e||typeof e!="object")return e;if(i.includes(e))return null;let a=i.concat([e]);return Array.isArray(e)?e.map(r=>t.decycle(r,a)):Object.fromEntries(Object.entries(e).map(([r,o])=>[r,t.decycle(o,a)]))}static stringify(e,i=false,a,r){return typeof e=="string"?e:JSON.stringify(i!==false?t.decycle(e):e,a,r)}static isJSON(e){if(typeof e!="string")return false;let i=e.trim();if(i.length===0)return false;try{let a=JSON.parse(i);return a!==null&&typeof a=="object"}catch(a){return false}}static parse(e,i){if(typeof e=="string")try{e=JSON.parse(e,i);}catch(a){return e}if(e&&typeof e=="object")for(let a in e){let r=e[a];t.isJSON(r)&&(e[a]=t.parse(r,i));}return e}};var b=class b{static get storage(){var i;let e=Reflect.getMetadata(b.sessionStorageMetaData,b);return j(e)&&(this._storage=e),this._storage?this._storage:(ne.isClientSide()&&typeof window!="undefined"&&window.localStorage&&((i=window.localStorage)!=null&&i.getItem)?this._storage={get:a=>window.localStorage.getItem(a),set:(a,r)=>window.localStorage.setItem(a,r),remove:a=>window.localStorage.removeItem(a),removeAll:()=>window.localStorage.clear()}:this._storage={get:a=>this.__inMemoryStorage[a],set:(a,r)=>this.__inMemoryStorage[a]=r,remove:a=>{delete this.__inMemoryStorage[a];},removeAll:()=>this.__inMemoryStorage={}},this._storage)}static set storage(e){j(e)&&Reflect.defineMetadata(b.sessionStorageMetaData,e,b);}static get keyNamespace(){return l(this._keyNamespace)?this._keyNamespace:""}static set keyNamespace(e){l(e)&&(this._keyNamespace=e.trim().replace(/\s+/g,"-"));}static sanitizeKey(e){if(!e||!l(e))return "";e=e.trim().replace(/\s+/g,"-");let i=this.keyNamespace;return i?`${i}-${e}`:e}};b.sessionStorageMetaData=Symbol("sessionStorage"),b._keyNamespace=void 0,b.__inMemoryStorage={};var h=b;function H(t){return h.sanitizeKey(t)}var de=(t,e)=>(t=t&&A.stringify(t,e),t==null&&(t=""),t),se=t=>{if(ae(t))return new Promise((e,i)=>{t.then(a=>{e(A.parse(a));}).catch(a=>{i(a);});});if(t!=null)return A.parse(t)},Ne=t=>{if(t=H(t),h.storage&&t&&typeof t=="string"){let e=h.storage.get(t);return se(e)}},ve=t=>{if(t=H(t),h.storage&&t&&typeof t=="string")return h.storage.remove(t)},Le=()=>{if(h.storage)return h.storage.removeAll()},j=t=>{if(!t)return false;try{return ["get","set","remove","removeAll"].every(e=>typeof t[e]=="function")}catch(e){return false}},U={get:Ne,set:(t,e,i=true)=>(t=H(t),h.storage.set(t,de(e,i))),remove:ve,handleGetValue:se,sanitizeKey:H,handleSetValue:de,isValidStorage:j,Manager:h,removeAll:Le};function v(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function L(t){if(t instanceof RegExp)return true;if(!t||typeof t!="object"||!Object.prototype.toString.call(t).includes("RegExp"))return false;try{return new RegExp(t),!0}catch(e){return false}}function Z(t){return typeof window!="object"||!window||typeof document=="undefined"||typeof HTMLElement=="undefined"||!HTMLElement?false:t===document?true:"HTMLElement"in window?!!t&&t instanceof HTMLElement:!!t&&typeof t=="object"&&t.nodeType===1&&!!t.nodeName}function m(t){if(t===null||typeof t!="object"||Z(t)||I(t)||L(t)||v(t))return false;let e=Object.getPrototypeOf(t);if(e===null)return true;let i=e.constructor;if(typeof i!="function")return false;if(i===Object)return true;let a=i.prototype;return typeof a!="object"?false:a===Object.prototype?true:typeof e.hasOwnProperty=="function"&&Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")&&typeof e.isPrototypeOf=="function"}function z(t){if(Array.isArray(t)){let a=[];for(var e=0;e<t.length;e++)a[e]=z(t[e]);return a}else if(m(t)&&t){let a={};for(var i in t)t.hasOwnProperty(i)&&(a[i]=z(t[i]));return a}else return t}Object.getSize=function(t,e=false){if(!t||typeof t!="object")return 0;if(Array.isArray(t))return t.length;typeof e!="boolean"&&(e=false);let i=0;for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a)&&(i++,e===true))return i;return i};function D(t,...e){let i=Array.isArray(t),a=m(t);(t==null||!i&&!a)&&(t={});for(let r=0;r<e.length;r++){let o=e[r];if(o==null)continue;let n=m(o),c=Array.isArray(o);if(!(!n&&!c)){if(i){c&&le(t,o);continue}else if(c)continue;for(let d in o){let u=o[d];if(u==null)continue;if(u===o){t[d]=t;continue}let M=t[d],S=Array.isArray(M),R=Array.isArray(u);if(S){R?le(t[d],u):t[d]=u;continue}else if(!m(M)){t[d]=u;continue}if(R||!m(u)){t[d]=u;continue}t[d]=D({},M,u);}}}return t}var le=(t,e)=>{let i=e.length,a=0;for(let r=0;r<t.length;r++){let o=t[r],n=e[r];if(r<i){let c=Array.isArray(o),d=Array.isArray(n),u=m(o),M=m(n);c&&d||u&&M?(t[a]=D(c?[]:{},o,n),a++):n!=null?(t[a]=n,a++):o!=null&&(t[a]=o,a++);}}for(let r=t.length;r<i;r++)e[r]!==void 0&&e[r]!==null&&t.push(e[r]);return t};function k(t,e){return F(t,"",{},e)}function F(t,e="",i={},a){if(i=m(i)?i:{},v(t)||I(t)||L(t)||Array.isArray(t)&&(a!=null&&a.skipArrays))return e&&(i[e]=t),i;if(typeof t=="function"||typeof t=="object"&&!m(t)&&!Oe(t))return i;if(t instanceof Map||t instanceof WeakMap)return Array.from(t.entries()).forEach(([r,o])=>{let n=e?`${e}[${String(r)}]`:String(r);F(o,n,i,a);}),i;if(Array.isArray(t)||t instanceof Set||t instanceof WeakSet)return (Array.isArray(t)?t:Array.from(t)).forEach((o,n)=>{let c=e?`${e}[${n}]`:String(n);F(o,c,i,a);}),i;if(m(t))for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;let o=t[r],n=e?e.endsWith("]")?`${e}.${r}`:`${e}.${r}`:r;F(o,n,i,a);}return i}function Oe(t){return Array.isArray(t)||t instanceof Set||t instanceof Map||t instanceof WeakMap||t instanceof WeakSet}function Re(t){return Object.entries(t)}Object.typedEntries=Re;Object.flatten=k;Object.clone=z;function O(t,e){if(t==null)return "";if(typeof t=="string")return t;if((typeof t=="number"||typeof t=="object"&&t instanceof Number)&&typeof t.formatNumber=="function")return t.formatNumber();if(t instanceof Date||typeof t=="object"&&t!==null&&t.constructor===Date)return typeof t.toFormat=="function"?t.toFormat():t.toISOString();if(t instanceof Error)return `Error: ${t.message}`;if(L(t))return t.toString();if(v(t))return String(t);if(Array.isArray(t))return JSON.stringify(t);if(typeof t=="object"&&t!==null){if(typeof t.toString=="function"&&t.toString!==Object.prototype.toString)return t.toString();if(typeof t.toString=="function"){let i=t.toString();if(i!=="[object Object]")return i}return JSON.stringify(t)}return typeof(t==null?void 0:t.toString)=="function"?t.toString():String(t)}function ce(t,e,i){let a=(i==null?void 0:i.valueFormatter)||O,r=f(t);if(!m(e)||!e)return r;let o=(i==null?void 0:i.tagRegex)||/%\{([^}]+)\}/g,n=new Set,c,d=f(t);for(;(c=o.exec(d))!==null;){let u=c[1];u!==void 0&&n.add(u);}return n.forEach(u=>{if(i!=null&&i.tagRegex){let J=new RegExp(i.tagRegex.source,i.tagRegex.flags);[...d.matchAll(J)].forEach(G=>{let ye=G[0];if(!G[1])return;let x=G[1],B=Object.prototype.hasOwnProperty.call(e,x)?e[x]:void 0,Ce=B===void 0?"":(()=>{try{return a(B,x,O)}catch(Fe){return O(B)}})(),ge=ye.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");r=r.replace(new RegExp(ge,"g"),Ce);});return}let M=`%{${u}}`,S=Object.prototype.hasOwnProperty.call(e,u)?e[u]:void 0,R=S===void 0?"":(()=>{try{return a(S,u,O)}catch(J){return O(S)}})(),fe=M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");r=r.replace(new RegExp(fe,"g"),R);}),r}var g=class g{constructor(e={},i={}){this.locale="en";this._locales=["en"];this._fallbackLocale="en";this._translations={};this.namespaceResolvers={};this._namespacesLoaded={};this._hasDefaultTranslations=false;l(i.locale)&&(this.locale=i.locale),l(i.fallbackLocale)&&(this._fallbackLocale=i.fallbackLocale),typeof i.interpolate=="function"&&(this.interpolateFunc=i.interpolate),this._hasDefaultTranslations||(this.registerTranslations(V),this._hasDefaultTranslations=true),e&&this.registerTranslations(e),this.loadNamespaces();}static[Symbol.hasInstance](e){return this.isI18nInstance(e)}static isI18nInstance(e){return !e||typeof e!="object"?false:e.constructor&&e.constructor.name==="I18n"?true:typeof e.getLocale=="function"&&typeof e.translate=="function"&&typeof e.translateClass=="function"&&typeof e.registerTranslations=="function"&&typeof e.loadNamespace=="function"&&typeof e.registerNamespaceResolver=="function"}static getInstance(e){if(!g.instance||!g.isI18nInstance(g.instance)){let i=g.getLocaleFromSession(),a=Object.assign({locale:i||"en"},e);g.instance=new g({},a);}return g.instance}static createInstance(e={},i={}){return new g(e,i)}static flattenObject(e){return m(e)?k(e):e}static getLocaleFromSession(){let e=U.get("i18n.locale");return l(e)?e:void 0}static registerMomentLocale(e,i){return l(e)&&m(i)&&Array.isArray(i.months)&&(this.momentLocales[e]=D({},this.momentLocales[e],i)),this.momentLocales}static getClassTanslationKeys(e){return $(e,ue)}translate(e,i){var n;i=i||{};let a=f(i==null?void 0:i.locale,this.getLocale()),r=Array.isArray(e)?e:[e],o;for(let c of r){if(!l(c))continue;let d=this.lookup(c,a);if(d===void 0&&a!==this._fallbackLocale&&(d=this.lookup(c,this._fallbackLocale)),d!==void 0){o=d;break}}if(o===void 0)return i.defaultValue!==void 0?i.defaultValue:this.missingTranslation(e,i);if(typeof i.count=="number"&&m(o)){let c=i.count,d="other";c===0&&o.zero!==void 0?d="zero":c===1&&o.one!==void 0&&(d="one"),o[d]!==void 0?o=o[d]:o.other&&(o=o.other);}return typeof o=="string"&&(p(i.count)&&!i.countStr&&(i.countStr=typeof((n=i.count)==null?void 0:n.formatNumber)=="function"?i.count.formatNumber():i.count.toString()),o=this.performInterpolation(o,i)),o}t(e,i){return this.translate(e,i)}has(e,i){let a=i||this.getLocale(),r=Array.isArray(e)?e:[e];for(let o of r)if(this.lookup(o,a)!==void 0)return true;return false}getLocale(){return this.locale}setLocale(e,i=false){return K(this,null,function*(){return this.locale===e&&i!==true&&this._namespacesLoaded[e]?this.locale:(yield this.loadNamespaces(e),this.locale=e,this.isDefaultInstance()&&g.setLocaleToSession(e),this.setMomentLocale(e),this.locale)})}setLocales(e){return this._locales=Array.isArray(e)?e:["en"],this._locales.includes("en")||this._locales.push("en"),this.getLocales()}getLocales(){let e=Object.keys(this._translations),i=Array.isArray(this._locales)?this._locales:["en"],a=[...e,...i.filter(r=>!e.includes(r))];return Array.from(new Set(a))}hasLocale(e){return l(e)&&this.getLocales().includes(e)}isDefaultInstance(){return this===g.instance}registerTranslations(e){return this._translations=D({},this._translations,e),this._translations}getTranslations(e){return l(e)?this._translations[e]||{}:this._translations}registerNamespaceResolver(e,i){if(!l(e)||typeof i!="function"){console.warn("Invalid arguments for registerNamespaceResolver.");return}this.namespaceResolvers[e]=i;}loadNamespace(e,i,a=true){return !l(e)||!this.namespaceResolvers[e]?Promise.reject(new Error(`Invalid namespace or resolver for namespace "${e}".`)):(i=f(i,this.getLocale()),l(i)?this.namespaceResolvers[e](i).then(r=>{let o={};return o[i]=Object.assign({},r),m(r)&&a!==false&&this.registerTranslations(o),o}):Promise.reject(new Error(`Locale is not set. Cannot load namespace "${e}".`)))}loadNamespaces(e,i=true){return K(this,null,function*(){e=f(e,this.getLocale());let a=[],r={};for(let n in this.namespaceResolvers)Object.prototype.hasOwnProperty.call(this.namespaceResolvers,n)&&a.push(this.namespaceResolvers[n](e).then(c=>{D(r,c);}));yield Promise.all(a);let o={};return o[e]=r,i!==false&&this.registerTranslations(o),this._namespacesLoaded[e]=true,o})}get(e,i){i=f(i,this.getLocale());let a=(l(e)?e.trim().split("."):Array.isArray(e)?e:[]).filter(l);if(!a.length)return;let r=this.getTranslations(i);for(let o of a)if(m(r))r=r[o];else return;return r}translateClass(e,i){let a=g.getClassTanslationKeys(e);for(let r in a)l(a[r])&&(a[r]=this.translate(a[r],i));return a}translateObject(e,i){if(!m(e))return {};let a={};for(let r in e){let o=e[r];l(o)&&(a[r]=this.translate(o,i));}return a}applyTranslations(e){try{let i=Object.getOwnPropertyNames(e);for(let a of i){let r=Reflect.getMetadata(ue,e,a);if(r)try{e[a]=this.translate(r);}catch(o){N.error(o," resolving translation for key : ",r," on object : ",e);}}}catch(i){N.error(i," resolving translations for object : ",e);}}missingTranslation(e,i){let a=f(Array.isArray(e)?e.filter(l)[0]:f(e));return typeof this.missingPlaceholder=="function"?this.missingPlaceholder(this,a,f(i==null?void 0:i.defaultValue),i):a}lookup(e,i){let a=this._translations[i];if(!a)return;if(Object.prototype.hasOwnProperty.call(a,e))return a[e];let r=e.split("."),o=a;for(let n of r)if(m(o)&&Object.prototype.hasOwnProperty.call(o,n))o=o[n];else return;return o}performInterpolation(e,i){let a=k(i);return this.interpolateFunc?this.interpolateFunc(this,e,i):this.defaultInterpolator(e,a)}defaultInterpolator(e,i){return ce(e,i,{tagRegex:/%\{([^}]+)\}/g})}static setLocaleToSession(e){U.set("i18n.locale",e);}getMomentLocale(e){return g.momentLocales[e]}setMomentLocale(e){try{return Y__default.default.updateLocale(e,this.getMomentLocale(e)),!0}catch(i){console.error(i," setting moment locale : ",e);}return false}};g.momentLocales={};var P=g;P.getInstance();var ue=Symbol("TRANSLATION_KEY");var Ee={};Object.keys(w).map(t=>{let e=w[t];Ee[e.dialCode]=e.code;});var y=class y{static get registry(){return Object.assign({},Reflect.getMetadata(y.registryMetaData,y))}static set registry(e){Reflect.defineMetadata(y.registryMetaData,e,y);}static isValid(e){return m(e)&&l(e.code)}static getPhoneNumberExample(e){var i;return f((i=y.getCountry(e))==null?void 0:i.phoneNumberExample)}static getFlag(e){var i;return f((i=y.getCountry(e))==null?void 0:i.flag)}static getCurrency(e){var i;return (i=y.getCountry(e))==null?void 0:i.currency}static setCountry(e){if(y.isValid(e)){let i=y.registry;i[e.code]=e,y.registry=i;}}static getCountry(e){if(!l(e))return;let i=P.getInstance().get(`countries.${e}`),a=y.registry[e];if(!(!m(i)&&!m(a)))return D({},i,a)}static getCountries(){let e=P.getInstance().get("countries");return D({},w,m(e)?e:{},y.registry)}static setCountries(e){if(!m(e))return;let i=y.registry;for(let a in e){let r=e[a];y.isValid(r)&&(i[a]=D({},i[a],r));}y.registry=i;}};y.registryMetaData=Symbol("countries:registry");var me=y;exports.CountryRegistry=me;
5
+ %{nestedErrors}`,validateNestedInvalidType:"The field %{fieldName} must be an object, but received %{receivedType}",dateAfter:"This field must be after %{date}",dateBefore:"This field must be before %{date}",dateBetween:"This field must be between %{startDate} and %{endDate}",dateEquals:"This field must be equal to %{date}",futureDate:"This field must be a date in the future",pastDate:"This field must be a date in the past",file:"This field must be a valid file",fileSize:"This field must not exceed %{maxSize} bytes",fileType:"This field must be one of the following types: %{allowedTypes}",image:"This field must be a valid image file",fileExtension:"This field must have one of the following extensions: %{allowedExtensions}",minFileSize:"This field must be at least %{minSize} bytes",uuid:"This field must be a valid UUID",json:"This field must be valid JSON",base64:"This field must be valid Base64 encoded data",hexColor:"This field must be a valid hexadecimal color code",creditCard:"This field must be a valid credit card number",ip:"This field must be a valid IP address (version %{version})",macAddress:"This field must be a valid MAC address",matches:"This field must match the pattern %{pattern}",mongoId:"This field must be a valid MongoDB ObjectId",hexadecimal:"This field must be a valid hexadecimal value",object:"This field must be an object",isObject:"This field must be an object",invalidBulkData:"Invalid bulk data: an array is required",bulkValidationFailed:{one:"Bulk validation failed: 1 of %{totalCount} items failed",other:"Bulk validation failed: %{failureCount} of %{totalCount} items failed"},bulkValidationAllFailed:{one:"Validation failed for the single item",other:"All %{totalCount} items failed validation"},bulkValidationPartialFailure:"%{failureCount} items failed validation",separators:{multiple:", ",single:", "},nestedErrors:{separator:"; ",prefix:"",suffix:""},tests:{entity:{name:"Name",id:"Id",email:"Email",aString:"A String",url:"Url",note:"Note",createdAt:"Created At",updatedAt:"Updated At"}}};var De={auth:Q,currencies:q,countries:w,dates:X,resources:_,validator:ee};function l(t){return !!(t&&typeof t=="string")}function f(...t){for(var e in t){let i=t[e];if(l(i))return i}return ""}function W(t){return !!(t==null||typeof t=="undefined"||typeof t=="string"&&t===""||Array.isArray(t)&&!t.length)}function p(t){return typeof t=="number"&&!isNaN(t)&&isFinite(t)}function I(t){return !t||typeof t!="object"?false:t instanceof Date?true:typeof t.getTime!="function"?false:!(Object.prototype.toString.call(t)!=="[object Date]"||isNaN(t.getTime()))}var s=class s{static parseString(e,i){if(l(e)&&l(i))try{let a=Y__default.default(e,i,!0);if(a.isValid())return {date:a.toDate(),matchedFormat:i,isValid:!0}}catch(a){}try{if(Array.isArray(i)&&(i!=null&&i.length))for(let a of i){let r=te(e,a);if(r)return r}for(let a of s.DATE_FORMATS){let r=te(e,a);if(r)return r}return {date:null,matchedFormat:null,isValid:!1,error:"Unable to parse date string with any known format"}}catch(a){return {date:null,matchedFormat:null,isValid:false,error:a instanceof Error?a.message:"Unknown error occurred while parsing date"}}}static toIsoString(e){let i=e?s.parseDate(e):new Date;return i?i.toISOString():""}static isoStringToDate(e){return new Date(e)}static parseDate(e,i){if(s.isDateObj(e))return e;if(!l(i)){let a=s.parseString(e);return a!=null&&a.isValid?a.date:null}if(W(e))return null;try{let a=Y__default.default(e,i,!0);if(a!=null&&a.isValid())return a.toDate()}catch(a){console.error(a," parsing date with moment : ",e," format is : ",i);}return null}static toSQLDateTimeFormat(e){if(!s.isDateObj(e))return "";let i=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return `${i}-${a}-${r} ${o}:${n}:${c}`}static getI18n(e){return P.isI18nInstance(e)?e:P.getInstance()}static getDefaultDateTimeFormat(e){return f(this.getI18n(e).get("dates.defaultDateTimeFormat"),"YYYY-MM-DD HH:mm")}static getDefaultDateFormat(e){return f(this.getI18n(e).get("dates.defaultDateFormat"),"YYYY-MM-DD")}static toSQLDateFormat(e){if(!s.isDateObj(e))return "";let i=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return `${i}-${a}-${r}`}static toSQLTimeFormat(e){if(!s.isDateObj(e))return "";let i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),r=String(e.getSeconds()).padStart(2,"0");return `${i}:${a}:${r}`}static getDefaultTimeFormat(e){return f(this.getI18n(e).get("dates.defaultTimeFormat"),"HH:mm")}static isValidDate(e,i){if(e==null||typeof e=="boolean")return false;if(s.isDateObj(e))return true;if(p(e)){let r=new Date(e);return r&&!isNaN(r.getTime())}if(l(e))return !!s.parseDate(e,i);if(e!=null&&e.toString&&(e==null?void 0:e.toString())==parseInt(e).toString())return false;let a=new Date(e);return s.isDateObj(a)}static addToDate(e,i,a){if(p(e)||(e=0),W(i)&&(i=new Date),s.isValidDate(i)&&l(i)&&(i=new Date(i)),s.isValidDate(i)||(i=l(i)?new Date(i):new Date),l(a)&&typeof i["set"+a]=="function"&&typeof i["get"+a]=="function"){let r="set"+a,o="get"+a;i=new Date(i[r](i[o]()+e));}return i}static addDays(e,i){return s.addToDate(e,i,"Date")}static addMilliseconds(e,i){return p(e)||(e=0),s.isDateObj(i)||(i=new Date),i=i||new Date,new Date(i.getTime()+e)}static addSeconds(e,i){return p(e)||(e=0),s.addMilliseconds(e*1e3,i)}static addMinutes(e,i){return p(e)||(e=0),s.addMilliseconds(e*6e4,i)}static addHours(e,i){return p(e)||(e=0),s.addMilliseconds(e*36e5,i)}static addMonths(e,i,a){return s.addToDate(e,i,"Month")}static addWeeks(e,i){return e=(p(e)?e:0)*7,s.addToDate(e,i,"Date")}static addYears(e,i){p(e)||(e=0);let a=new Date(s.addToDate(0,i)),r=a.getFullYear();return r+e<0?e=0:e+=r,a.setFullYear(e),new Date(a)}static formatDate(e,i){try{let a=Y__default.default(e);if(a.isValid())return a.format(f(i,s.getDefaultDateTimeFormat()))}catch(a){}return f(s.isValidDate(e)?e==null?void 0:e.toString():"")}static getUTCDateTimeDetails(e){let i=e?Y__default.default.utc(e):Y__default.default.utc();return {year:i.year(),day:i.day(),month:i.month(),monthString:i.format("MM"),hours:i.hours(),date:i.date(),minutes:i.minutes(),seconds:i.seconds(),monthName:i.format("MMMM"),dayName:i.format("dddd"),dayNameShort:i.format("ddd")}}};s.DATE_FORMATS=["YYYY-MM-DD","YYYY-MM-DDTHH:mm:ss","YYYY-MM-DDTHH:mm:ssZ","YYYY-MM-DDTHH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss[Z]","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DDTHH:mm:ss.SSSZ ","YYYY-MM-DDTHH:mm:ss.SSS","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DD HH:mm:ssZ","YYYY-MM-DD HH:mmZ","MM/DD/YYYY","MM-DD-YYYY","MM.DD.YYYY","MM/DD/YY","MMMM DD, YYYY","MMM DD, YYYY","DD/MM/YYYY","DD-MM-YYYY","DD.MM.YYYY","DD/MM/YY","DD MMMM YYYY","DD MMM YYYY","HH:mm:ss.SSSZ","HH:mm:ssZ","HH:mmZ","YYYYMMDD","YYYYMMDDTHHMM","YYYYMMDDTHHMMSS","HH:mm:ss","HH:mm","hh:mm A","h:mm A","HH:mm:ss.SSS","YYYY-DDD","YYYY-Www","YYYY-Www-D","YYYY/MM/DD","YYYY.MM.DD","MMM D, YYYY","MMMM D, YYYY","D MMM YYYY","D MMMM YYYY","MMM D YYYY","ddd, DD MMM YYYY HH:mm:ss ZZ","ddd, DD MMM YYYY HH:mm:ss","dddd, MMMM D, YYYY","dddd, D MMMM YYYY","hh:mm:ss A","H:mm:ss","YYYY-[W]WW","YYYY-[W]WW-E","YYYY-MM-DDTHH:mm:ss.SSS","DD-MM-YYYY HH:mm:ss","YYYY/MM/DD HH:mm:ss","YYYY.MM.DD HH:mm:ss","DD/MM/YYYY HH:mm:ss","MMM D YYYY, h:mm a","MMMM D YYYY, h:mm a","h:mm A MMM D, YYYY","MMMM D, YYYY","YY-MM-DD","DD-MM-YY","MM/DD/YY","MMM DD, YY","D MMM YY","D MMMM YY","YYYY MMM D","YYYY-MM-DD HH:mm","YYYY-MM-DD HH:mm:ss.SSS"],s.SQL_DATE_FORMAT="YYYY-MM-DD",s.SQL_DATE_TIME_FORMAT="YYYY-MM-DD HH:mm:ss",s.SQL_TIME_FORMAT="HH:mm:ss",s.getCurrentMonthDaysRange=e=>{let i=s.isValidDate(e)?new Date(e):new Date().resetHours2Minutes2Seconds(),a=new Date(i.getFullYear(),i.getMonth(),1),r=new Date(i.getFullYear(),i.getMonth()+1,0);return {first:a,last:r}},s.getPreviousWeekDaysRange=e=>{let i=s.isValidDate(e)?new Date(e):new Date().resetHours2Minutes2Seconds(),a=new Date(i.getTime()-3600*24*7*1e3),r=new Date(a),o=a.getDay(),n=a.getDate()-o+(o===0?-6:1),c=new Date(a.setDate(n)),d=new Date(r.setDate(n+6));return {first:c,last:d}},s.getCurrentWeekDaysRange=e=>{let i=s.isValidDate(e)?new Date(e):new Date().resetHours2Minutes2Seconds(),a=i.getDay(),r=i.getDate()-a+(a==0?-6:1),o=new Date(i),n=new Date(i.setDate(r));return o.setDate(o.getDate()+6),{first:n,last:o}},s.isDateObj=I;var C=s,te=(t,e)=>{let i=Y__default.default(t,e,true);try{if(i.isValid()&&i.format(e)===t||Y__default.default.utc(i,!0).format(e)===t)return {date:i.toDate(),matchedFormat:e,isValid:!0}}catch(a){}return null};Date.prototype.toSQLDateTimeFormat=function(){return C.toSQLDateTimeFormat(this)};Date.prototype.toSQLDateFormat=function(){return C.toSQLDateFormat(this)};Date.prototype.toSQLTimeFormat=function(){return C.toSQLTimeFormat(this)};Date.prototype.resetHours=function(){return this.setHours(0),this};Date.prototype.resetMinutes=function(){return this.setMinutes(0),this};Date.prototype.resetSeconds=function(){return this.setSeconds(0),this};Date.prototype.resetMilliseconds=function(){return this.setMilliseconds(0),this};Date.prototype.resetHours2Minutes2Seconds=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this};Date.prototype.toFormat=function(t){return C.formatDate(this,t)};Date.prototype.addYears=function(t){return C.addYears(t,this)};Date.prototype.addMonths=function(t){return C.addMonths(t,this)};Date.prototype.addMinutes=function(t){return C.addMinutes(t,this)};Date.prototype.addSeconds=function(t){return C.addSeconds(t,this)};Date.prototype.addDays=function(t){return C.addDays(t,this)};Date.prototype.addWeeks=function(t){return C.addWeeks(t,this)};Date.prototype.addHours=function(t){return C.addHours(t,this)};var T=class T{static get logger(){let e=Reflect.getMetadata(T.loggerMetaData,T);return ie(e)&&(this._logger=e),this._logger?this._logger:console}static set logger(e){ie(e)&&Reflect.defineMetadata(T.loggerMetaData,e,T);}static _log(e,...i){let a=T.logger;e=f(e),e&&typeof a[e]=="function"?a[e](T.getDateTimeString(),...i):console.log("Logger level not found : [",e,"]",...i);}static getDateTimeString(){let{day:e,year:i,hours:a,minutes:r,seconds:o,dayNameShort:n,monthName:c}=C.getUTCDateTimeDetails(),d=e<10?"0"+e:e,u=a<10?"0"+a:a,M=r<10?"0"+r:r,S=o<10?"0"+o:o;return "["+[n,d,c,i].join(" ")+" "+[u,M,S].join(":")+"]"}static log(...e){this._log("log",...e);}static info(...e){this._log("info",...e);}static debug(...e){this._log("debug",...e);}static warn(...e){this._log("warn",...e);}static error(...e){this._log("error",...e);}};T.loggerMetaData=Symbol("logger-meta-data");var N=T,ie=t=>{if(!t)return false;try{return ["warn","info","error"].every(e=>typeof t[e]=="function")}catch(e){return false}};function Me(t){return typeof t=="boolean"||!t||typeof t=="number"||typeof t=="string"||typeof t=="symbol"?false:Object(t).constructor===Promise||t.constructor&&(t.constructor.name==="Promise"||t.constructor.name==="AsyncFunction")||t instanceof Promise||typeof(t==null?void 0:t.then)=="function"&&typeof(t==null?void 0:t.catch)=="function"&&typeof(t==null?void 0:t.finally)=="function"?true:t&&typeof t.constructor=="function"&&Function.prototype.toString.call(t.constructor).replace(/\(.*\)/,"()")===Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()")}function ae(t){return t instanceof Promise||t&&Object.prototype.toString.call(t)==="[object Promise]"?true:Me(t)}function re(){return typeof window!="undefined"&&(window==null?void 0:window.document)!==void 0&&typeof document!="undefined"&&typeof navigator!="undefined"}var E=()=>{var t;try{if(typeof process!="undefined"&&(process!=null&&process.versions)&&((t=process==null?void 0:process.versions)!=null&&t.node)||typeof global=="object"&&(global==null?void 0:global.toString.call(global))==="[object global]")return !0}catch(e){}return false},Pe=()=>{var t,e;return !!(typeof window!="undefined"&&window&&typeof(window==null?void 0:window.process)=="object"&&((t=window==null?void 0:window.process)==null?void 0:t.type)==="renderer"||typeof process!="undefined"&&typeof(process==null?void 0:process.versions)=="object"&&((e=process.versions)!=null&&e.electron)||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&String(navigator==null?void 0:navigator.userAgent).toLowerCase().indexOf("electron")>=0)},Te=()=>{if(typeof document!="undefined"&&document)try{return document.createEvent("TouchEvent"),!0}catch(t){try{return "ontouchstart"in window||"onmsgesturechange"in window}catch(e){}}return false},be=()=>typeof window=="undefined"&&typeof process!="undefined",oe=()=>!!(typeof window!="undefined"&&typeof window=="object"&&window),Se=()=>{if(!re()||typeof navigator!="object"||!navigator||typeof navigator.userAgent!="string")return false;let t=navigator.userAgent.toLowerCase();return /android/i.test(t)},Ye=()=>{var t;return !oe()||!(window!=null&&window.ReactNativeWebView)?false:typeof((t=window==null?void 0:window.ReactNativeWebView)==null?void 0:t.postMessage)=="function"},we=()=>E()&&process.platform==="darwin",Ae=()=>E()&&process.platform==="win32",Ie=()=>E()&&process.platform==="linux",ne={isWeb:re,isLinux:Ie,isDarwin:we,isWin32:Ae,isNode:E,isElectron:Pe,isTouchDevice:Te,isServerSide:be,isClientSide:oe,isAndroidMobileBrowser:Se,isReactNativeWebview:Ye};var A=class t{static decycle(e,i=[]){if(typeof e=="function")return;if(!e||typeof e!="object")return e;if(i.includes(e))return null;let a=i.concat([e]);return Array.isArray(e)?e.map(r=>t.decycle(r,a)):Object.fromEntries(Object.entries(e).map(([r,o])=>[r,t.decycle(o,a)]))}static stringify(e,i=false,a,r){return typeof e=="string"?e:JSON.stringify(i!==false?t.decycle(e):e,a,r)}static isJSON(e){if(typeof e!="string")return false;let i=e.trim();if(i.length===0)return false;try{let a=JSON.parse(i);return a!==null&&typeof a=="object"}catch(a){return false}}static parse(e,i){if(typeof e=="string")try{e=JSON.parse(e,i);}catch(a){return e}if(e&&typeof e=="object")for(let a in e){let r=e[a];t.isJSON(r)&&(e[a]=t.parse(r,i));}return e}};var b=class b{static get storage(){var i;let e=Reflect.getMetadata(b.sessionStorageMetaData,b);return j(e)&&(this._storage=e),this._storage?this._storage:(ne.isClientSide()&&typeof window!="undefined"&&window.localStorage&&((i=window.localStorage)!=null&&i.getItem)?this._storage={get:a=>window.localStorage.getItem(a),set:(a,r)=>window.localStorage.setItem(a,r),remove:a=>window.localStorage.removeItem(a),removeAll:()=>window.localStorage.clear()}:this._storage={get:a=>this.__inMemoryStorage[a],set:(a,r)=>this.__inMemoryStorage[a]=r,remove:a=>{delete this.__inMemoryStorage[a];},removeAll:()=>this.__inMemoryStorage={}},this._storage)}static set storage(e){j(e)&&Reflect.defineMetadata(b.sessionStorageMetaData,e,b);}static get keyNamespace(){return l(this._keyNamespace)?this._keyNamespace:""}static set keyNamespace(e){l(e)&&(this._keyNamespace=e.trim().replace(/\s+/g,"-"));}static sanitizeKey(e){if(!e||!l(e))return "";e=e.trim().replace(/\s+/g,"-");let i=this.keyNamespace;return i?`${i}-${e}`:e}};b.sessionStorageMetaData=Symbol("sessionStorage"),b._keyNamespace=void 0,b.__inMemoryStorage={};var h=b;function H(t){return h.sanitizeKey(t)}var de=(t,e)=>(t=t&&A.stringify(t,e),t==null&&(t=""),t),se=t=>{if(ae(t))return new Promise((e,i)=>{t.then(a=>{e(A.parse(a));}).catch(a=>{i(a);});});if(t!=null)return A.parse(t)},Ne=t=>{if(t=H(t),h.storage&&t&&typeof t=="string"){let e=h.storage.get(t);return se(e)}},ve=t=>{if(t=H(t),h.storage&&t&&typeof t=="string")return h.storage.remove(t)},Le=()=>{if(h.storage)return h.storage.removeAll()},j=t=>{if(!t)return false;try{return ["get","set","remove","removeAll"].every(e=>typeof t[e]=="function")}catch(e){return false}},U={get:Ne,set:(t,e,i=true)=>(t=H(t),h.storage.set(t,de(e,i))),remove:ve,handleGetValue:se,sanitizeKey:H,handleSetValue:de,isValidStorage:j,Manager:h,removeAll:Le};function v(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function L(t){if(t instanceof RegExp)return true;if(!t||typeof t!="object"||!Object.prototype.toString.call(t).includes("RegExp"))return false;try{return new RegExp(t),!0}catch(e){return false}}function Z(t){return typeof window!="object"||!window||typeof document=="undefined"||typeof HTMLElement=="undefined"||!HTMLElement?false:t===document?true:"HTMLElement"in window?!!t&&t instanceof HTMLElement:!!t&&typeof t=="object"&&t.nodeType===1&&!!t.nodeName}function m(t){if(t===null||typeof t!="object"||Z(t)||I(t)||L(t)||v(t))return false;let e=Object.getPrototypeOf(t);if(e===null)return true;let i=e.constructor;if(typeof i!="function")return false;if(i===Object)return true;let a=i.prototype;return typeof a!="object"?false:a===Object.prototype?true:typeof e.hasOwnProperty=="function"&&Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")&&typeof e.isPrototypeOf=="function"}function z(t){if(Array.isArray(t)){let a=[];for(var e=0;e<t.length;e++)a[e]=z(t[e]);return a}else if(m(t)&&t){let a={};for(var i in t)t.hasOwnProperty(i)&&(a[i]=z(t[i]));return a}else return t}Object.getSize=function(t,e=false){if(!t||typeof t!="object")return 0;if(Array.isArray(t))return t.length;typeof e!="boolean"&&(e=false);let i=0;for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a)&&(i++,e===true))return i;return i};function D(t,...e){let i=Array.isArray(t),a=m(t);(t==null||!i&&!a)&&(t={});for(let r=0;r<e.length;r++){let o=e[r];if(o==null)continue;let n=m(o),c=Array.isArray(o);if(!(!n&&!c)){if(i){c&&le(t,o);continue}else if(c)continue;for(let d in o){let u=o[d];if(u==null)continue;if(u===o){t[d]=t;continue}let M=t[d],S=Array.isArray(M),R=Array.isArray(u);if(S){R?le(t[d],u):t[d]=u;continue}else if(!m(M)){t[d]=u;continue}if(R||!m(u)){t[d]=u;continue}t[d]=D({},M,u);}}}return t}var le=(t,e)=>{let i=e.length,a=0;for(let r=0;r<t.length;r++){let o=t[r],n=e[r];if(r<i){let c=Array.isArray(o),d=Array.isArray(n),u=m(o),M=m(n);c&&d||u&&M?(t[a]=D(c?[]:{},o,n),a++):n!=null?(t[a]=n,a++):o!=null&&(t[a]=o,a++);}}for(let r=t.length;r<i;r++)e[r]!==void 0&&e[r]!==null&&t.push(e[r]);return t};function F(t,e){return k(t,"",{},e)}function k(t,e="",i={},a){if(i=m(i)?i:{},v(t)||I(t)||L(t)||Array.isArray(t)&&(a!=null&&a.skipArrays))return e&&(i[e]=t),i;if(typeof t=="function"||typeof t=="object"&&!m(t)&&!Oe(t))return i;if(t instanceof Map||t instanceof WeakMap)return Array.from(t.entries()).forEach(([r,o])=>{let n=e?`${e}[${String(r)}]`:String(r);k(o,n,i,a);}),i;if(Array.isArray(t)||t instanceof Set||t instanceof WeakSet)return (Array.isArray(t)?t:Array.from(t)).forEach((o,n)=>{let c=e?`${e}[${n}]`:String(n);k(o,c,i,a);}),i;if(m(t))for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;let o=t[r],n=e?e.endsWith("]")?`${e}.${r}`:`${e}.${r}`:r;k(o,n,i,a);}return i}function Oe(t){return Array.isArray(t)||t instanceof Set||t instanceof Map||t instanceof WeakMap||t instanceof WeakSet}function Re(t){return Object.entries(t)}Object.typedEntries=Re;Object.flatten=F;Object.clone=z;function O(t,e){if(t==null)return "";if(typeof t=="string")return t;if((typeof t=="number"||typeof t=="object"&&t instanceof Number)&&typeof t.formatNumber=="function")return t.formatNumber();if(t instanceof Date||typeof t=="object"&&t!==null&&t.constructor===Date)return typeof t.toFormat=="function"?t.toFormat():t.toISOString();if(t instanceof Error)return `Error: ${t.message}`;if(L(t))return t.toString();if(v(t))return String(t);if(Array.isArray(t))return JSON.stringify(t);if(typeof t=="object"&&t!==null){if(typeof t.toString=="function"&&t.toString!==Object.prototype.toString)return t.toString();if(typeof t.toString=="function"){let i=t.toString();if(i!=="[object Object]")return i}return JSON.stringify(t)}return typeof(t==null?void 0:t.toString)=="function"?t.toString():String(t)}function ce(t,e,i){let a=(i==null?void 0:i.valueFormatter)||O,r=f(t);if(!m(e)||!e)return r;let o=(i==null?void 0:i.tagRegex)||/%\{([^}]+)\}/g,n=new Set,c,d=f(t);for(;(c=o.exec(d))!==null;){let u=c[1];u!==void 0&&n.add(u);}return n.forEach(u=>{if(i!=null&&i.tagRegex){let J=new RegExp(i.tagRegex.source,i.tagRegex.flags);[...d.matchAll(J)].forEach(G=>{let ye=G[0];if(!G[1])return;let x=G[1],B=Object.prototype.hasOwnProperty.call(e,x)?e[x]:void 0,Ce=B===void 0?"":(()=>{try{return a(B,x,O)}catch(ke){return O(B)}})(),ge=ye.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");r=r.replace(new RegExp(ge,"g"),Ce);});return}let M=`%{${u}}`,S=Object.prototype.hasOwnProperty.call(e,u)?e[u]:void 0,R=S===void 0?"":(()=>{try{return a(S,u,O)}catch(J){return O(S)}})(),fe=M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");r=r.replace(new RegExp(fe,"g"),R);}),r}var g=class g{constructor(e={},i={}){this.locale="en";this._locales=["en"];this._fallbackLocale="en";this._translations={};this.namespaceResolvers={};this._namespacesLoaded={};this._hasDefaultTranslations=false;l(i.locale)&&(this.locale=i.locale),l(i.fallbackLocale)&&(this._fallbackLocale=i.fallbackLocale),typeof i.interpolate=="function"&&(this.interpolateFunc=i.interpolate),this._hasDefaultTranslations||(this.registerTranslations(V),this._hasDefaultTranslations=true),e&&this.registerTranslations(e),this.loadNamespaces();}static[Symbol.hasInstance](e){return this.isI18nInstance(e)}static isI18nInstance(e){return !e||typeof e!="object"?false:e.constructor&&e.constructor.name==="I18n"?true:typeof e.getLocale=="function"&&typeof e.translate=="function"&&typeof e.translateClass=="function"&&typeof e.registerTranslations=="function"&&typeof e.loadNamespace=="function"&&typeof e.registerNamespaceResolver=="function"}static getInstance(e){if(!g.instance||!g.isI18nInstance(g.instance)){let i=g.getLocaleFromSession(),a=Object.assign({locale:i||"en"},e);g.instance=new g({},a);}return g.instance}static createInstance(e={},i={}){return new g(e,i)}static flattenObject(e){return m(e)?F(e):e}static getLocaleFromSession(){let e=U.get("i18n.locale");return l(e)?e:void 0}static registerMomentLocale(e,i){return l(e)&&m(i)&&Array.isArray(i.months)&&(this.momentLocales[e]=D({},this.momentLocales[e],i)),this.momentLocales}static getClassTanslationKeys(e){return $(e,ue)}translate(e,i){var n;i=i||{};let a=f(i==null?void 0:i.locale,this.getLocale()),r=Array.isArray(e)?e:[e],o;for(let c of r){if(!l(c))continue;let d=this.lookup(c,a);if(d===void 0&&a!==this._fallbackLocale&&(d=this.lookup(c,this._fallbackLocale)),d!==void 0){o=d;break}}if(o===void 0)return i.defaultValue!==void 0?i.defaultValue:this.missingTranslation(e,i);if(typeof i.count=="number"&&m(o)){let c=i.count,d="other";c===0&&o.zero!==void 0?d="zero":c===1&&o.one!==void 0&&(d="one"),o[d]!==void 0?o=o[d]:o.other&&(o=o.other);}return typeof o=="string"&&(p(i.count)&&!i.countStr&&(i.countStr=typeof((n=i.count)==null?void 0:n.formatNumber)=="function"?i.count.formatNumber():i.count.toString()),o=this.performInterpolation(o,i)),o}t(e,i){return this.translate(e,i)}has(e,i){let a=i||this.getLocale(),r=Array.isArray(e)?e:[e];for(let o of r)if(this.lookup(o,a)!==void 0)return true;return false}getLocale(){return this.locale}setLocale(e,i=false){return K(this,null,function*(){return this.locale===e&&i!==true&&this._namespacesLoaded[e]?this.locale:(yield this.loadNamespaces(e),this.locale=e,this.isDefaultInstance()&&g.setLocaleToSession(e),this.setMomentLocale(e),this.locale)})}setLocales(e){return this._locales=Array.isArray(e)?e:["en"],this._locales.includes("en")||this._locales.push("en"),this.getLocales()}getLocales(){let e=Object.keys(this._translations),i=Array.isArray(this._locales)?this._locales:["en"],a=[...e,...i.filter(r=>!e.includes(r))];return Array.from(new Set(a))}hasLocale(e){return l(e)&&this.getLocales().includes(e)}isDefaultInstance(){return this===g.instance}registerTranslations(e){return this._translations=D({},this._translations,e),this._translations}getTranslations(e){return l(e)?this._translations[e]||{}:this._translations}registerNamespaceResolver(e,i){if(!l(e)||typeof i!="function"){console.warn("Invalid arguments for registerNamespaceResolver.");return}this.namespaceResolvers[e]=i;}loadNamespace(e,i,a=true){return !l(e)||!this.namespaceResolvers[e]?Promise.reject(new Error(`Invalid namespace or resolver for namespace "${e}".`)):(i=f(i,this.getLocale()),l(i)?this.namespaceResolvers[e](i).then(r=>{let o={};return o[i]=Object.assign({},r),m(r)&&a!==false&&this.registerTranslations(o),o}):Promise.reject(new Error(`Locale is not set. Cannot load namespace "${e}".`)))}loadNamespaces(e,i=true){return K(this,null,function*(){e=f(e,this.getLocale());let a=[],r={};for(let n in this.namespaceResolvers)Object.prototype.hasOwnProperty.call(this.namespaceResolvers,n)&&a.push(this.namespaceResolvers[n](e).then(c=>{D(r,c);}));yield Promise.all(a);let o={};return o[e]=r,i!==false&&this.registerTranslations(o),this._namespacesLoaded[e]=true,o})}get(e,i){i=f(i,this.getLocale());let a=(l(e)?e.trim().split("."):Array.isArray(e)?e:[]).filter(l);if(!a.length)return;let r=this.getTranslations(i);for(let o of a)if(m(r))r=r[o];else return;return r}translateClass(e,i){let a=g.getClassTanslationKeys(e);for(let r in a)l(a[r])&&(a[r]=this.translate(a[r],i));return a}translateObject(e,i){if(!m(e))return {};let a={};for(let r in e){let o=e[r];l(o)&&(a[r]=this.translate(o,i));}return a}applyTranslations(e){try{let i=Object.getOwnPropertyNames(e);for(let a of i){let r=Reflect.getMetadata(ue,e,a);if(r)try{e[a]=this.translate(r);}catch(o){N.error(o," resolving translation for key : ",r," on object : ",e);}}}catch(i){N.error(i," resolving translations for object : ",e);}}missingTranslation(e,i){let a=f(Array.isArray(e)?e.filter(l)[0]:f(e));return typeof this.missingPlaceholder=="function"?this.missingPlaceholder(this,a,f(i==null?void 0:i.defaultValue),i):a}lookup(e,i){let a=this._translations[i];if(!a)return;if(Object.prototype.hasOwnProperty.call(a,e))return a[e];let r=e.split("."),o=a;for(let n of r)if(m(o)&&Object.prototype.hasOwnProperty.call(o,n))o=o[n];else return;return o}performInterpolation(e,i){let a=F(i);return this.interpolateFunc?this.interpolateFunc(this,e,i):this.defaultInterpolator(e,a)}defaultInterpolator(e,i){return ce(e,i,{tagRegex:/%\{([^}]+)\}/g})}static setLocaleToSession(e){U.set("i18n.locale",e);}getMomentLocale(e){return g.momentLocales[e]}setMomentLocale(e){try{return Y__default.default.updateLocale(e,this.getMomentLocale(e)),!0}catch(i){console.error(i," setting moment locale : ",e);}return false}};g.momentLocales={};var P=g;P.getInstance();var ue=Symbol("TRANSLATION_KEY");var Ee={};Object.keys(w).map(t=>{let e=w[t];Ee[e.dialCode]=e.code;});var y=class y{static get registry(){return Object.assign({},Reflect.getMetadata(y.registryMetaData,y))}static set registry(e){Reflect.defineMetadata(y.registryMetaData,e,y);}static isValid(e){return m(e)&&l(e.code)}static getPhoneNumberExample(e){var i;return f((i=y.getCountry(e))==null?void 0:i.phoneNumberExample)}static getFlag(e){var i;return f((i=y.getCountry(e))==null?void 0:i.flag)}static getCurrency(e){var i;return (i=y.getCountry(e))==null?void 0:i.currency}static setCountry(e){if(y.isValid(e)){let i=y.registry;i[e.code]=e,y.registry=i;}}static getCountry(e){if(!l(e))return;let i=P.getInstance().get(`countries.${e}`),a=y.registry[e];if(!(!m(i)&&!m(a)))return D({},i,a)}static getCountries(){let e=P.getInstance().get("countries");return D({},w,m(e)?e:{},y.registry)}static setCountries(e){if(!m(e))return;let i=y.registry;for(let a in e){let r=e[a];y.isValid(r)&&(i[a]=D({},i[a],r));}y.registry=i;}};y.registryMetaData=Symbol("countries:registry");var me=y;exports.CountryRegistry=me;
@@ -1,31 +1,26 @@
1
1
  import 'reflect-metadata';
2
2
  import { Currency, CurrencySymbol } from './types';
3
- /**
4
- *
5
- * Extends the default options with the provided Currency object to initialize default values.
6
- it sets up default values for currency formatting, merging them with any user-provided options. This ensures that all necessary settings are available for the formatting process.
7
- *
8
- * @param options The Currency object to merge with the default options.
9
- * @returns The merged Currency object with default values.
10
- */
11
- declare function prepareOptions(options?: Currency): Currency;
12
- /**
13
- *
14
- * @description
15
- * Description of the format for displaying numeric values.
16
- *
17
- * The format is a string consisting of the letters %v and %s, where:
18
- * - %v represents the value of the amount,
19
- * - %s represents the currency.
20
- * For example, %s%v => $10 and %v %s => 10 $.
21
- *
22
- * To define the decimal places, use the pattern [.][#{0,n}], for example:
23
- * - .### for display with 3 decimal places,
24
- * - . for no decimal places in the display.
25
- * For example, the format %v %s .## returns: 12.35 $ for the value 12.357777 converted to dollars.
26
- */
27
- export declare const CurrencyUtils: {
28
- parse: (value: any, decimalSeparator?: string) => number;
3
+ export declare const CurrencyFormatter: {
4
+ /**
5
+ *
6
+ * Takes a string or array of strings, removes all formatting/cruft, and returns the raw float value.
7
+ The unformat function takes a formatted currency string and converts it back to a raw number. This is useful when you need to perform calculations on currency values that may have been stored or input as formatted strings.
8
+ *
9
+ * Alias: `accounting.unformat(string)`
10
+ *
11
+ * Decimal must be included in the regular expression to match floats (default options to
12
+ * accounting.settings.number.decimalSeparator), so if the number uses a non-standard decimalSeparator
13
+ * separator, provide it as the second argument.
14
+ *
15
+ * Also matches bracketed negatives (eg. "$ (1.99)" => -1.99)
16
+ *
17
+ * Doesn't throw any errors (`NaN`s become 0) but this may change in future
18
+ *
19
+ * @param {string | string[]} value The string or array of strings to unformat.
20
+ * @param {string} [decimalSeparator] The decimal separator to use (defaults to accounting.settings.number.decimalSeparator).
21
+ * @returns {number} The unformatted float value.
22
+ */
23
+ unformat: (value: any, decimalSeparator?: string) => number;
29
24
  session: {
30
25
  getFormat: (force?: boolean) => string;
31
26
  setFormat: (format: string) => void | Promise<void>;
@@ -33,19 +28,152 @@ export declare const CurrencyUtils: {
33
28
  getCurrency: () => Currency;
34
29
  defaultCurrencyFormat: string;
35
30
  };
31
+ /**
32
+ *
33
+ * Format a number into currency.
34
+ *
35
+ * The symbol can be an object, in which case the other properties can be null.
36
+ * Usage: accounting.formatMoney(number, symbol, decimalDigits, thousandsSep, decimalSep, format)
37
+ * prepareOptions: (0, "$", 2, ",", ".", "%s%v")
38
+ *
39
+ * Localise by overriding the symbol, decimalDigits, thousandSeparator / decimalSeparator separators and format
40
+ * Second param can be an object matching `settings.currency` which is the easiest way.
41
+ *
42
+ * To do: tidy up the parameters
43
+ *
44
+ * @param {number} [number] The number to format.
45
+ * @param {Currency | CurrencySymbol} [symbol] The symbol or options object.
46
+ * @param {number} [decimalDigits] The decimal digits to use.
47
+ * @param {string} [thousandSeparator] The thousand separator to use.
48
+ * @param {string} [decimalSeparator] The decimal separator to use.
49
+ * @param {string} [format] The format to use.
50
+ * @returns {string} The formatted number as a string.
51
+ */
36
52
  formatMoney: (number?: number, symbol?: Currency | CurrencySymbol, decimalDigits?: number, thousandSeparator?: string, decimalSeparator?: string, format?: string) => string;
37
53
  currencies: import("./types").Currencies;
38
- isCurrency: (obj: any) => obj is Currency;
54
+ isCurrency: (obj: unknown) => obj is Currency;
55
+ /**
56
+ *
57
+ * Format a number, with comma-separated thousands and custom decimalDigits/decimalSeparator places.
58
+ * The formatNumber function takes a number and formats it with the appropriate thousand separators and decimal places, based on the provided options.
59
+ *
60
+ * Alias: `accounting.format()`
61
+ *
62
+ * Localise by overriding the decimalDigits and thousandSeparator / decimalSeparator separators
63
+ * 2nd parameter `decimalDigits` can be an object matching `settings.number`
64
+ *
65
+ * @param {number} number The number to format.
66
+ * @param {Currency | number} [optionsOrDecimalDigits] The options object or decimal digits to use.
67
+ * @param {string} [thousandSeparator] The thousand separator to use.
68
+ * @param {string} [decimalSeparator] The decimal separator to use.
69
+ * @returns {string} The formatted number as a string.
70
+ */
39
71
  formatNumber: (number: number, optionsOrDecimalDigits?: Currency | number, thousandSeparator?: string, decimalSeparator?: string) => string;
72
+ /**
73
+ *
74
+ * Format a number into currency.
75
+ * The formatMoney and formatMoneyAsObject functions are the main workhorses of the module. They take a number and format it as a currency string, applying the appropriate symbol, decimal places, and formatting style. The formatMoneyAsObject version provides more detailed information about the formatting process.
76
+ *
77
+ * The symbol can be an object, in which case the other properties can be null.
78
+ * Usage: accounting.formatMoney(number, symbol, decimalDigits, thousandsSep, decimalSep, format)
79
+ * prepareOptions: (0, "$", 2, ",", ".", "%s%v")
80
+ *
81
+ * Localise by overriding the symbol, decimalDigits, thousandSeparator / decimalSeparator separators and format
82
+ * Second param can be an object matching `settings.currency` which is the easiest way.
83
+ *
84
+ * To do: tidy up the parameters
85
+ *
86
+ * @param {number} [number] The number to format.
87
+ * @param {Currency | CurrencySymbol} [symbol] The symbol or options object.
88
+ * @param {number} [decimalDigits] The decimal digits to use.
89
+ * @param {string} [thousandSeparator] The thousand separator to use.
90
+ * @param {string} [decimalSeparator] The decimal separator to use.
91
+ * @param {string} [format] The format to use.
92
+ * @returns {Currency & {
93
+ * formattedValue: string,
94
+ * formattedNumber: string,
95
+ * usedFormat: string,
96
+ * result: string,
97
+ * }}
98
+ */
40
99
  formatMoneyAsObject: (number?: number, symbol?: Currency | CurrencySymbol, decimalDigits?: number, thousandSeparator?: string, decimalSeparator?: string, format?: string) => Currency & {
41
100
  formattedValue: string;
42
101
  formattedNumber: string;
43
102
  usedFormat: string;
44
103
  result: string;
45
104
  };
46
- unformat: (value: any, decimalSeparator?: string) => number;
105
+ /**
106
+ *
107
+ * Implementation of toFixed() that treats floats more like decimals.
108
+ The toFixed function addresses issues with floating-point precision in JavaScript, ensuring that decimal places are rounded correctly for currency display.
109
+ *
110
+ * Fixes binary rounding issues (eg. (0.615).toFixed(2) === "0.61") that present
111
+ * problems for accounting- and finance-related software.
112
+ *
113
+ * @param {number} value The number to format.
114
+ * @param {number} [decimalDigits] The number of decimal digits to round to (defaults to accounting.settings.decimalDigits).
115
+ * @returns {string} The formatted number as a string.
116
+ */
47
117
  toFixed: (value: number, decimalDigits?: number) => string;
48
- prepareOptions: typeof prepareOptions;
118
+ /**
119
+ *
120
+ * Extends the default options with the provided Currency object to initialize default values.
121
+ it sets up default values for currency formatting, merging them with any user-provided options. This ensures that all necessary settings are available for the formatting process.
122
+ *
123
+ * @param options The Currency object to merge with the default options.
124
+ * @returns The merged Currency object with default values.
125
+ */
126
+ prepareOptions: (options?: Currency) => Currency;
127
+ /**
128
+ *
129
+ * Parse the currency format and return an object containing the parsed format and decimal digits.
130
+ * The parseFormat function helps interpret custom format strings, allowing users to specify how they want their currency displayed (e.g., where the symbol should appear, how many decimal places to show).
131
+ *
132
+ * @param {string} [format] The currency format, a string combining the characters %s, %v, and .#{0,n}, where:
133
+ * - %s represents the currency symbol,
134
+ * - %v represents the value to be formatted,
135
+ * - .#{0,n} represents the number of decimal digits to use, with n being the number of decimal digits.
136
+ * For example, the format %v %s .### formats the number 12555.6893300244 as $12555.689, with 3 decimal digits.
137
+ * If no decimal digits are desired, simply omit the # characters after the dot (e.g., %s %v .).
138
+ *
139
+ * @returns {Currency} An object containing the parsed format and decimal digits.
140
+ */
49
141
  parseFormat: (format?: string) => Currency;
142
+ /**
143
+ *
144
+ * Parses a format string or object and returns a format object for use in rendering.
145
+ *
146
+ * @param {string | { pos: string, neg?: string, zero?: string } | (() => string | { pos: string, neg?: string, zero?: string })} format
147
+ * Either a string with the default (positive) format, or an object containing `pos` (required), `neg` and `zero` values (or a function returning either a string or object)
148
+ * @returns {{ pos: string, neg: string, zero: string }} A format object containing positive, negative, and zero formats.
149
+ */
150
+ checkCurrencyFormat: (format: string | {
151
+ pos: string;
152
+ neg?: string;
153
+ zero?: string;
154
+ } | (() => string | {
155
+ pos: string;
156
+ neg?: string;
157
+ zero?: string;
158
+ })) => {
159
+ pos: string;
160
+ neg: string;
161
+ zero: string;
162
+ };
50
163
  };
164
+ /**
165
+ *
166
+ * @description
167
+ * Description of the format for displaying numeric values.
168
+ *
169
+ * The format is a string consisting of the letters %v and %s, where:
170
+ * - %v represents the value of the amount,
171
+ * - %s represents the currency.
172
+ * For example, %s%v => $10 and %v %s => 10 $.
173
+ *
174
+ * To define the decimal places, use the pattern [.][#{0,n}], for example:
175
+ * - .### for display with 3 decimal places,
176
+ * - . for no decimal places in the display.
177
+ * For example, the format %v %s .## returns: 12.35 $ for the value 12.357777 converted to dollars.
178
+ */
51
179
  export * from './types';