csv-sort 6.1.2 → 6.1.3

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,11 +1,11 @@
1
1
  /**
2
2
  * @name csv-sort
3
3
  * @fileoverview Sort double-entry bookkeeping CSV from internet banking
4
- * @version 6.1.2
4
+ * @version 6.1.3
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/csv-sort/}
8
8
  */
9
9
 
10
- import B from"lodash.pull";import{splitEasy as O}from"csv-split-easy";import R from"currency.js";function E(i){return typeof i=="number"&&!isNaN(i)?!0:(i=(i||"").toString().trim(),i?!isNaN(+i):!1)}var N=["\u062F.\u0625","\u060B","L","\u058F","\u0192","Kz","$","\u0192","\u20BC","KM","\u09F3","\u043B\u0432",".\u062F.\u0628","FBu","$b","R$","\u0E3F","Nu.","P","p.","BZ$","FC","CHF","\xA5","\u20A1","\u20B1","K\u010D","Fdj","kr","RD$","\u062F\u062C","kr","Nfk","Br","\u039E","\u20AC","\u20BE","\u20B5","GH\u20B5","D","FG","Q","L","kn","G","Ft","Rp","\u20AA","\u20B9","\u0639.\u062F","\uFDFC","kr","J$","JD","\xA5","KSh","\u043B\u0432","\u17DB","CF","\u20A9","\u20A9","KD","\u043B\u0432","\u20AD","\u20A8","M","\u0141","Lt","Ls","LD","MAD","lei","Ar","\u0434\u0435\u043D","K","\u20AE","MOP$","UM","\u20A8","Rf","MK","RM","MT","\u20A6","C$","kr","\u20A8","\uFDFC","B/.","S/.","K","\u20B1","\u20A8","z\u0142","Gs","\uFDFC","\uFFE5","lei","\u0414\u0438\u043D.","\u20BD","R\u20A3","\uFDFC","\u20A8","\u062C.\u0633.","kr","\xA3","Le","S","Db","E","\u0E3F","SM","T","\u062F.\u062A","T$","\u20A4","\u20BA","TT$","NT$","TSh","\u20B4","USh","$U","\u043B\u0432","Bs","\u20AB","VT","WS$","FCFA","\u0243","CFA","\u20A3","\uFDFC","R","Z$"];function f(i){return E(i)||N.some(b=>E(i.replace(b,"").replace(/[,.]/g,"")))?"numeric":i.trim()?"text":"empty"}var T="6.1.2";var K=T;function _(i){let b=null,C=null;if(typeof i!="string")throw new TypeError(`csv-sort/csvSort(): [THROW_ID_01] The input is of a wrong type! We accept either string of array of arrays. We got instead: ${typeof i}, equal to:
10
+ import B from"lodash.pull";import{splitEasy as O}from"csv-split-easy";import R from"currency.js";function E(i){return typeof i=="number"&&!isNaN(i)?!0:(i=(i||"").toString().trim(),i?!isNaN(+i):!1)}var N=["\u062F.\u0625","\u060B","L","\u058F","\u0192","Kz","$","\u0192","\u20BC","KM","\u09F3","\u043B\u0432",".\u062F.\u0628","FBu","$b","R$","\u0E3F","Nu.","P","p.","BZ$","FC","CHF","\xA5","\u20A1","\u20B1","K\u010D","Fdj","kr","RD$","\u062F\u062C","kr","Nfk","Br","\u039E","\u20AC","\u20BE","\u20B5","GH\u20B5","D","FG","Q","L","kn","G","Ft","Rp","\u20AA","\u20B9","\u0639.\u062F","\uFDFC","kr","J$","JD","\xA5","KSh","\u043B\u0432","\u17DB","CF","\u20A9","\u20A9","KD","\u043B\u0432","\u20AD","\u20A8","M","\u0141","Lt","Ls","LD","MAD","lei","Ar","\u0434\u0435\u043D","K","\u20AE","MOP$","UM","\u20A8","Rf","MK","RM","MT","\u20A6","C$","kr","\u20A8","\uFDFC","B/.","S/.","K","\u20B1","\u20A8","z\u0142","Gs","\uFDFC","\uFFE5","lei","\u0414\u0438\u043D.","\u20BD","R\u20A3","\uFDFC","\u20A8","\u062C.\u0633.","kr","\xA3","Le","S","Db","E","\u0E3F","SM","T","\u062F.\u062A","T$","\u20A4","\u20BA","TT$","NT$","TSh","\u20B4","USh","$U","\u043B\u0432","Bs","\u20AB","VT","WS$","FCFA","\u0243","CFA","\u20A3","\uFDFC","R","Z$"];function f(i){return E(i)||N.some(b=>E(i.replace(b,"").replace(/[,.]/g,"")))?"numeric":i.trim()?"text":"empty"}var T="6.1.3";var K=T;function _(i){let b=null,C=null;if(typeof i!="string")throw new TypeError(`csv-sort/csvSort(): [THROW_ID_01] The input is of a wrong type! We accept either string of array of arrays. We got instead: ${typeof i}, equal to:
11
11
  ${JSON.stringify(i,null,4)}`);if(!i.trim())return{res:[[""]],msgContent:b,msgType:C};let n=O(i),s=[],d=!1,S=!0,v=[],r=null;for(let t=n.length-1;t>=0;t--)if(s.length){t===0&&(d=n[t].every(l=>f(l)==="text"||f(l)==="empty")),!d&&s.length!==n[t].length&&(S=!1);let e=null;for(let l=0,p=n[t].length;l<p;l++)if(e===null&&f(n[t][l].trim())==="empty"&&(e=l),e!==null&&f(n[t][l].trim())!=="empty"&&(e=null),f(n[t][l].trim())!==s[l]&&!d){let a=f(n[t][l].trim());if(Array.isArray(s[l]))s[l].includes(a)||s[l].push(f(n[t][l].trim()));else if(s[l]!==a){let u=s[l];s[l]=[],s[l].push(u),s[l].push(a)}}r!==null&&e!==null&&e>r&&(!d||d&&t!==0)&&(r=e)}else if(n[t].length!==1||n[t][0]!=="")for(let e=0,l=n[t].length;e<l;e++)s.push(f(n[t][e].trim())),r===null&&f(n[t][e].trim())==="empty"&&(r=e),r!==null&&f(n[t][e].trim())!=="empty"&&(r=null);r||(r=s.length);let w=0;for(let t=0,e=s.length;t<e&&s[t]==="empty";t++)w=t;w!==0&&(n=n.map(t=>t.slice(w+1,r)),s=s.slice(w+1,r));let V=[],m;s.forEach((t,e)=>{t==="numeric"&&V.push(e)});let k=d?1:0;if(V.length===1)m=V[0];else{if(V.length===0)throw new Error('csv-sort/csvSort(): [THROW_ID_03] Your CSV file does not contain numeric-only columns and computer was not able to detect the "Balance" column!');{let t=Array.from(V),e=[];for(let l=0,p=t.length;l<p;l++){let a=t[l],u,g=!0,y,h=!0;for(let c=k,I=n.length;c<I&&(g&&(u==null?u=n[c][a]:u===n[c][a]?(e.push(a),g=!1):u=n[c][a]),h&&(y==null?y=n[c][a]:n[c][a]!==y&&(h=!1)),!!g);c++);h&&v.push(a)}if(t=B(t,...e),t.length===1)m=t[0];else if(t.length===0)throw new Error(`csv-sort/csvSort(): [THROW_ID_04] The computer can't find the "Balance" column! It saw some numeric-only columns, but they all seem to have certain rows with the same values as rows right below/above them!`)}}if(!m)throw new Error("csv-sort/csvSort(): [THROW_ID_05] Sadly computer couldn't find its way in this CSV and had to stop working on it.");let D=B(Array.from(s.reduce((t,e,l)=>((typeof e=="string"&&e==="numeric"||Array.isArray(e)&&e.includes("numeric"))&&t.push(l),t),[])),m,...v),o=[];o.push(n[n.length-1].slice(0,r));let $=[],x=d?1:0;for(let t=n.length-2;t>=x;t--)for(let e=n.length-2;e>=x;e--)if(!$.includes(e)){let l=!1;for(let p=0,a=D.length;p<a;p++){let u=null;n[e][D[p]]!==""&&(u=R(n[e][D[p]]));let g=null;n[e][m]!==""&&(g=R(n[e][m]));let y=null;o[0][m]!==""&&(y=R(o[0][m]).format());let h=null;o[o.length-1][D[p]]!==""&&(h=R(o[o.length-1][D[p]]).format());let c=null;if(o[o.length-1][m]!==""&&(c=R(o[o.length-1][m])),u&&g.add(u).format()===y){o.unshift(n[e].slice(0,r)),$.push(e),l=!0;break}else if(u&&g.subtract(u).format()===y){o.unshift(n[e].slice(0,r)),$.push(e),l=!0;break}else if(h&&c.add(h).format()===g.format()){o.push(n[e].slice(0,r)),$.push(e),l=!0;break}else if(h&&c.subtract(h).format()===g.format()){o.push(n[e].slice(0,r)),$.push(e),l=!0;break}}if(l){l=!1;break}}return d&&(S&&n[0].length>s.length&&(n[0].length=s.length),o.unshift(n[0].slice(0,r))),n.length-(d?2:1)!==$.length&&(b="Not all rows were recognised!",C="alert"),{res:o,msgContent:b,msgType:C}}export{f as findType,E as isNumeric,_ as sort,K as version};
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @name csv-sort
3
3
  * @fileoverview Sort double-entry bookkeeping CSV from internet banking
4
- * @version 6.1.2
4
+ * @version 6.1.3
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/csv-sort/}
8
8
  */
9
9
 
10
- "use strict";var csvSort=(()=>{var xe=Object.create;var x=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames,z=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var W=(e,r,s)=>r in e?x(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,b=(e,r)=>{for(var s in r||(r={}))Y.call(r,s)&&W(e,s,r[s]);if(z)for(var s of z(r))_e.call(r,s)&&W(e,s,r[s]);return e};var J=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),je=(e,r)=>{for(var s in r)x(e,s,{get:r[s],enumerable:!0})},Z=(e,r,s,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ce(r))!Y.call(e,a)&&a!==s&&x(e,a,{get:()=>r[a],enumerable:!(n=Ve(r,a))||n.enumerable});return e};var k=(e,r,s)=>(s=e!=null?xe(Fe(e)):{},Z(r||!e||!e.__esModule?x(s,"default",{value:e,enumerable:!0}):s,e)),We=e=>Z(x({},"__esModule",{value:!0}),e);var H=(e,r,s)=>(W(e,typeof r!="symbol"?r+"":r,s),s);var te=J((Jt,ee)=>{function Je(e,r,s){switch(s.length){case 0:return e.call(r);case 1:return e.call(r,s[0]);case 2:return e.call(r,s[0],s[1]);case 3:return e.call(r,s[0],s[1],s[2])}return e.apply(r,s)}function ke(e,r){for(var s=-1,n=e?e.length:0,a=Array(n);++s<n;)a[s]=r(e[s],s,e);return a}function He(e,r,s,n){for(var a=e.length,t=s+(n?1:-1);n?t--:++t<a;)if(r(e[t],t,e))return t;return-1}function Me(e,r,s){if(r!==r)return He(e,qe,s);for(var n=s-1,a=e.length;++n<a;)if(e[n]===r)return n;return-1}function Be(e,r,s,n){for(var a=s-1,t=e.length;++a<t;)if(n(e[a],r))return a;return-1}function qe(e){return e!==e}function Pe(e){return function(r){return e(r)}}var Ue=Array.prototype,Q=Ue.splice,X=Math.max;function Ke(e,r,s,n){var a=n?Be:Me,t=-1,i=r.length,u=e;for(e===r&&(r=Ge(r)),s&&(u=ke(e,Pe(s)));++t<i;)for(var l=0,o=r[t],f=s?s(o):o;(l=a(u,f,l,n))>-1;)u!==e&&Q.call(u,l,1),Q.call(e,l,1);return e}function Le(e,r){return r=X(r===void 0?e.length-1:r,0),function(){for(var s=arguments,n=-1,a=X(s.length-r,0),t=Array(a);++n<a;)t[n]=s[r+n];n=-1;for(var i=Array(r+1);++n<r;)i[n]=s[n];return i[r]=t,Je(e,this,i)}}function Ge(e,r){var s=-1,n=e.length;for(r||(r=Array(n));++s<n;)r[s]=e[s];return r}var ze=Le(Ye);function Ye(e,r){return e&&e.length&&r&&r.length?Ke(e,r):e}ee.exports=ze});var Oe=J((Yt,Re)=>{var rt=1/0,nt="[object Symbol]",st=/^\s+|\s+$/g,U="\\ud800-\\udfff",ce="\\u0300-\\u036f\\ufe20-\\ufe23",he="\\u20d0-\\u20f0",me="\\ufe0e\\ufe0f",ot="["+U+"]",q="["+ce+he+"]",P="\\ud83c[\\udffb-\\udfff]",it="(?:"+q+"|"+P+")",ye="[^"+U+"]",de="(?:\\ud83c[\\udde6-\\uddff]){2}",be="[\\ud800-\\udbff][\\udc00-\\udfff]",$e="\\u200d",Te=it+"?",we="["+me+"]?",lt="(?:"+$e+"(?:"+[ye,de,be].join("|")+")"+we+Te+")*",at=we+Te+lt,ut="(?:"+[ye+q+"?",q,de,be,ot].join("|")+")",ft=RegExp(P+"(?="+P+")|"+ut+at,"g"),gt=RegExp("["+$e+U+ce+he+me+"]"),pt=typeof global=="object"&&global&&global.Object===Object&&global,ct=typeof self=="object"&&self&&self.Object===Object&&self,ht=pt||ct||Function("return this")();function mt(e){return e.split("")}function yt(e,r,s,n){for(var a=e.length,t=s+(n?1:-1);n?t--:++t<a;)if(r(e[t],t,e))return t;return-1}function ve(e,r,s){if(r!==r)return yt(e,dt,s);for(var n=s-1,a=e.length;++n<a;)if(e[n]===r)return n;return-1}function dt(e){return e!==e}function bt(e,r){for(var s=-1,n=e.length;++s<n&&ve(r,e[s],0)>-1;);return s}function $t(e,r){for(var s=e.length;s--&&ve(r,e[s],0)>-1;);return s}function Tt(e){return gt.test(e)}function ue(e){return Tt(e)?wt(e):mt(e)}function wt(e){return e.match(ft)||[]}var vt=Object.prototype,St=vt.toString,fe=ht.Symbol,ge=fe?fe.prototype:void 0,pe=ge?ge.toString:void 0;function Rt(e,r,s){var n=-1,a=e.length;r<0&&(r=-r>a?0:a+r),s=s>a?a:s,s<0&&(s+=a),a=r>s?0:s-r>>>0,r>>>=0;for(var t=Array(a);++n<a;)t[n]=e[n+r];return t}function Se(e){if(typeof e=="string")return e;if(Nt(e))return pe?pe.call(e):"";var r=e+"";return r=="0"&&1/e==-rt?"-0":r}function Ot(e,r,s){var n=e.length;return s=s===void 0?n:s,!r&&s>=n?e:Rt(e,r,s)}function Et(e){return!!e&&typeof e=="object"}function Nt(e){return typeof e=="symbol"||Et(e)&&St.call(e)==nt}function Dt(e){return e==null?"":Se(e)}function It(e,r,s){if(e=Dt(e),e&&(s||r===void 0))return e.replace(st,"");if(!e||!(r=Se(r)))return e;var n=ue(e),a=ue(r),t=bt(n,a),i=$t(n,a)+1;return Ot(n,t,i).join("")}Re.exports=It});var De=J((K,L)=>{(function(e,r){typeof K=="object"&&typeof L<"u"?L.exports=r():typeof define=="function"&&define.amd?define(r):(e=e||self,e.currency=r())})(K,function(){function e(t,i){if(!(this instanceof e))return new e(t,i);i=Object.assign({},s,i);var u=Math.pow(10,i.precision);this.intValue=t=r(t,i),this.value=t/u,i.increment=i.increment||1/u,i.groups=i.useVedic?a:n,this.s=i,this.p=u}function r(t,i){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:!0,l=i.decimal,o=i.errorOnInvalid,f=i.fromCents,g=Math.pow(10,i.precision),y=t instanceof e;if(y&&f)return t.intValue;if(typeof t=="number"||y)l=y?t.value:t;else if(typeof t=="string")o=new RegExp("[^-\\d"+l+"]","g"),l=new RegExp("\\"+l,"g"),l=(l=t.replace(/\((.*)\)/,"-$1").replace(o,"").replace(l,"."))||0;else{if(o)throw Error("Invalid Input");l=0}return f||(l=(l*g).toFixed(4)),u?Math.round(l):l}var s={symbol:"$",separator:",",decimal:".",errorOnInvalid:!1,precision:2,pattern:"!#",negativePattern:"-!#",format:function(t,i){var u=i.pattern,l=i.negativePattern,o=i.symbol,f=i.separator,g=i.decimal;i=i.groups;var y=(""+t).replace(/^-/,"").split("."),m=y[0];return y=y[1],(0<=t.value?u:l).replace("!",o).replace("#",m.replace(i,"$1"+f)+(y?g+y:""))},fromCents:!1},n=/(\d)(?=(\d{3})+\b)/g,a=/(\d)(?=(\d\d)+\d\b)/g;return e.prototype={add:function(t){var i=this.s,u=this.p;return e((this.intValue+r(t,i))/(i.fromCents?1:u),i)},subtract:function(t){var i=this.s,u=this.p;return e((this.intValue-r(t,i))/(i.fromCents?1:u),i)},multiply:function(t){var i=this.s;return e(this.intValue*t/(i.fromCents?1:Math.pow(10,i.precision)),i)},divide:function(t){var i=this.s;return e(this.intValue/r(t,i,!1),i)},distribute:function(t){var i=this.intValue,u=this.p,l=this.s,o=[],f=Math[0<=i?"floor":"ceil"](i/t),g=Math.abs(i-f*t);for(u=l.fromCents?1:u;t!==0;t--){var y=e(f/u,l);0<g--&&(y=y[0<=i?"add":"subtract"](1/u)),o.push(y)}return o},dollars:function(){return~~this.value},cents:function(){return~~(this.intValue%this.p)},format:function(t){var i=this.s;return typeof t=="function"?t(this,i):i.format(this,Object.assign({},i,t))},toString:function(){var t=this.s,i=t.increment;return(Math.round(this.intValue/this.p/i)*i).toFixed(t.precision)},toJSON:function(){return this.value}},e})});var jt={};je(jt,{findType:()=>w,isNumeric:()=>j,sort:()=>_t,version:()=>Ft});var G=k(te(),1);var Ze={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function M(e,r){if(!Array.isArray(e)||!e.length)return e;let s=b(b({},Ze),r),n,a;if(s.strictlyTwoElementsInRangeArrays&&!e.every((u,l)=>!Array.isArray(u)||u.length!==2?(n=l,a=u.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${a} elements!`);if(!e.every((u,l)=>!Array.isArray(u)||!Number.isInteger(u[0])||u[0]<0||!Number.isInteger(u[1])||u[1]<0?(n=l,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let t=e.length**2,i=0;return Array.from(e).sort((u,l)=>(s.progressFn&&(i+=1,s.progressFn(Math.floor(i*100/t))),u[0]===l[0]?u[1]<l[1]?-1:u[1]>l[1]?1:0:u[0]<l[0]?-1:1))}var re={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function ne(e,r){function s(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}if(!Array.isArray(e)||!e.length)return null;let n;if(r)if(s(r)){if(n=b(b({},re),r),n.progressFn&&s(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
11
- ${JSON.stringify(r,null,4)} (type ${typeof r})`);else n=b({},re);let a=e.filter(o=>Array.isArray(o)).map(o=>[...o]).filter(o=>o[2]!==void 0||o[0]!==o[1]),t,i,u;n.progressFn?t=M(a,{progressFn:o=>{u=Math.floor(o/5),u!==i&&(i=u,n.progressFn(u))}}):t=M(a);let l=t.length-1;for(let o=l;o>0;o--)n.progressFn&&(u=Math.floor((1-o/l)*78)+21,u!==i&&u>i&&(i=u,n.progressFn(u))),(t[o][0]<=t[o-1][0]||!n.joinRangesThatTouchEdges&&t[o][0]<t[o-1][1]||n.joinRangesThatTouchEdges&&t[o][0]<=t[o-1][1])&&(t[o-1][0]=Math.min(t[o][0],t[o-1][0]),t[o-1][1]=Math.max(t[o][1],t[o-1][1]),t[o][2]!==void 0&&(t[o-1][0]>=t[o][0]||t[o-1][1]<=t[o][1])&&t[o-1][2]!==null&&(t[o][2]===null&&t[o-1][2]!==null?t[o-1][2]=null:t[o-1][2]!=null?+n.mergeType==2&&t[o-1][0]===t[o][0]?t[o-1][2]=t[o][2]:t[o-1][2]+=t[o][2]:t[o-1][2]=t[o][2]),t.splice(o,1),o=t.length);return t.length?t:null}var Qe=!0,B="Invariant failed";function se(e,r){if(!e){if(Qe)throw new Error(B);var s=typeof r=="function"?r():r,n=s?B+": "+s:B;throw new Error(n)}}function oe(e,r,s){let n=0,a=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(r&&!Array.isArray(r))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(s&&typeof s!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof s}, equal to: ${JSON.stringify(s,null,4)}`);if(!r||!r.filter(f=>f).length)return e;let t;Array.isArray(r)&&Number.isInteger(r[0])&&Number.isInteger(r[1])?t=[Array.from(r)]:t=Array.from(r);let i=t.length,u=0;t.filter(f=>f).forEach((f,g)=>{if(s&&(n=Math.floor(u/i*10),n!==a&&(a=n,s(n))),!Array.isArray(f))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${g}th element not an array: ${JSON.stringify(f,null,4)}, which is ${typeof f}`);if(!Number.isInteger(f[0])){if(!Number.isInteger(+f[0])||+f[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(f,null,0)}. Its first element is not an integer, string index, but ${typeof f[0]}, equal to: ${JSON.stringify(f[0],null,4)}.`);t[g][0]=+t[g][0]}if(!Number.isInteger(f[1])){if(!Number.isInteger(+f[1])||+f[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(f,null,0)}. Its second element is not an integer, string index, but ${typeof f[1]}, equal to: ${JSON.stringify(f[1],null,4)}.`);t[g][1]=+t[g][1]}u+=1});let l=ne(t,{progressFn:f=>{s&&(n=10+Math.floor(f/10),n!==a&&(a=n,s(n)))}});se(l);let o=l.length;if(o>0){let f=e.slice(l[o-1][1]);e=l.reduce((g,y,m,d)=>{s&&(n=20+Math.floor(m/o*80),n!==a&&(a=n,s(n)));let E=m===0?0:d[m-1][1],F=d[m][0];return`${g}${e.slice(E,F)}${d[m][2]||""}`},""),e+=f}return e}function _(e,r=1){let s="\xA0";function n(t){return Array.from(t).reverse().join("")}function a(t,i,u){let l=u?`
10
+ "use strict";var csvSort=(()=>{var xe=Object.create;var x=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames,z=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var W=(e,r,s)=>r in e?x(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,b=(e,r)=>{for(var s in r||(r={}))Y.call(r,s)&&W(e,s,r[s]);if(z)for(var s of z(r))_e.call(r,s)&&W(e,s,r[s]);return e};var J=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),je=(e,r)=>{for(var s in r)x(e,s,{get:r[s],enumerable:!0})},Z=(e,r,s,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ce(r))!Y.call(e,a)&&a!==s&&x(e,a,{get:()=>r[a],enumerable:!(n=Ve(r,a))||n.enumerable});return e};var k=(e,r,s)=>(s=e!=null?xe(Fe(e)):{},Z(r||!e||!e.__esModule?x(s,"default",{value:e,enumerable:!0}):s,e)),We=e=>Z(x({},"__esModule",{value:!0}),e);var H=(e,r,s)=>(W(e,typeof r!="symbol"?r+"":r,s),s);var te=J((Jt,ee)=>{function Je(e,r,s){switch(s.length){case 0:return e.call(r);case 1:return e.call(r,s[0]);case 2:return e.call(r,s[0],s[1]);case 3:return e.call(r,s[0],s[1],s[2])}return e.apply(r,s)}function ke(e,r){for(var s=-1,n=e?e.length:0,a=Array(n);++s<n;)a[s]=r(e[s],s,e);return a}function He(e,r,s,n){for(var a=e.length,t=s+(n?1:-1);n?t--:++t<a;)if(r(e[t],t,e))return t;return-1}function Me(e,r,s){if(r!==r)return He(e,qe,s);for(var n=s-1,a=e.length;++n<a;)if(e[n]===r)return n;return-1}function Be(e,r,s,n){for(var a=s-1,t=e.length;++a<t;)if(n(e[a],r))return a;return-1}function qe(e){return e!==e}function Pe(e){return function(r){return e(r)}}var Ue=Array.prototype,Q=Ue.splice,X=Math.max;function Ke(e,r,s,n){var a=n?Be:Me,t=-1,i=r.length,u=e;for(e===r&&(r=Ge(r)),s&&(u=ke(e,Pe(s)));++t<i;)for(var l=0,o=r[t],f=s?s(o):o;(l=a(u,f,l,n))>-1;)u!==e&&Q.call(u,l,1),Q.call(e,l,1);return e}function Le(e,r){return r=X(r===void 0?e.length-1:r,0),function(){for(var s=arguments,n=-1,a=X(s.length-r,0),t=Array(a);++n<a;)t[n]=s[r+n];n=-1;for(var i=Array(r+1);++n<r;)i[n]=s[n];return i[r]=t,Je(e,this,i)}}function Ge(e,r){var s=-1,n=e.length;for(r||(r=Array(n));++s<n;)r[s]=e[s];return r}var ze=Le(Ye);function Ye(e,r){return e&&e.length&&r&&r.length?Ke(e,r):e}ee.exports=ze});var Oe=J((Xt,Re)=>{var rt=1/0,nt="[object Symbol]",st=/^\s+|\s+$/g,U="\\ud800-\\udfff",pe="\\u0300-\\u036f\\ufe20-\\ufe23",he="\\u20d0-\\u20f0",me="\\ufe0e\\ufe0f",ot="["+U+"]",q="["+pe+he+"]",P="\\ud83c[\\udffb-\\udfff]",it="(?:"+q+"|"+P+")",ye="[^"+U+"]",de="(?:\\ud83c[\\udde6-\\uddff]){2}",be="[\\ud800-\\udbff][\\udc00-\\udfff]",$e="\\u200d",Te=it+"?",we="["+me+"]?",lt="(?:"+$e+"(?:"+[ye,de,be].join("|")+")"+we+Te+")*",at=we+Te+lt,ut="(?:"+[ye+q+"?",q,de,be,ot].join("|")+")",ft=RegExp(P+"(?="+P+")|"+ut+at,"g"),gt=RegExp("["+$e+U+pe+he+me+"]"),ct=typeof global=="object"&&global&&global.Object===Object&&global,pt=typeof self=="object"&&self&&self.Object===Object&&self,ht=ct||pt||Function("return this")();function mt(e){return e.split("")}function yt(e,r,s,n){for(var a=e.length,t=s+(n?1:-1);n?t--:++t<a;)if(r(e[t],t,e))return t;return-1}function ve(e,r,s){if(r!==r)return yt(e,dt,s);for(var n=s-1,a=e.length;++n<a;)if(e[n]===r)return n;return-1}function dt(e){return e!==e}function bt(e,r){for(var s=-1,n=e.length;++s<n&&ve(r,e[s],0)>-1;);return s}function $t(e,r){for(var s=e.length;s--&&ve(r,e[s],0)>-1;);return s}function Tt(e){return gt.test(e)}function ue(e){return Tt(e)?wt(e):mt(e)}function wt(e){return e.match(ft)||[]}var vt=Object.prototype,St=vt.toString,fe=ht.Symbol,ge=fe?fe.prototype:void 0,ce=ge?ge.toString:void 0;function Rt(e,r,s){var n=-1,a=e.length;r<0&&(r=-r>a?0:a+r),s=s>a?a:s,s<0&&(s+=a),a=r>s?0:s-r>>>0,r>>>=0;for(var t=Array(a);++n<a;)t[n]=e[n+r];return t}function Se(e){if(typeof e=="string")return e;if(Nt(e))return ce?ce.call(e):"";var r=e+"";return r=="0"&&1/e==-rt?"-0":r}function Ot(e,r,s){var n=e.length;return s=s===void 0?n:s,!r&&s>=n?e:Rt(e,r,s)}function Et(e){return!!e&&typeof e=="object"}function Nt(e){return typeof e=="symbol"||Et(e)&&St.call(e)==nt}function Dt(e){return e==null?"":Se(e)}function It(e,r,s){if(e=Dt(e),e&&(s||r===void 0))return e.replace(st,"");if(!e||!(r=Se(r)))return e;var n=ue(e),a=ue(r),t=bt(n,a),i=$t(n,a)+1;return Ot(n,t,i).join("")}Re.exports=It});var De=J((K,L)=>{(function(e,r){typeof K=="object"&&typeof L<"u"?L.exports=r():typeof define=="function"&&define.amd?define(r):(e=e||self,e.currency=r())})(K,function(){function e(t,i){if(!(this instanceof e))return new e(t,i);i=Object.assign({},s,i);var u=Math.pow(10,i.precision);this.intValue=t=r(t,i),this.value=t/u,i.increment=i.increment||1/u,i.groups=i.useVedic?a:n,this.s=i,this.p=u}function r(t,i){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:!0,l=i.decimal,o=i.errorOnInvalid,f=i.fromCents,g=Math.pow(10,i.precision),y=t instanceof e;if(y&&f)return t.intValue;if(typeof t=="number"||y)l=y?t.value:t;else if(typeof t=="string")o=new RegExp("[^-\\d"+l+"]","g"),l=new RegExp("\\"+l,"g"),l=(l=t.replace(/\((.*)\)/,"-$1").replace(o,"").replace(l,"."))||0;else{if(o)throw Error("Invalid Input");l=0}return f||(l=(l*g).toFixed(4)),u?Math.round(l):l}var s={symbol:"$",separator:",",decimal:".",errorOnInvalid:!1,precision:2,pattern:"!#",negativePattern:"-!#",format:function(t,i){var u=i.pattern,l=i.negativePattern,o=i.symbol,f=i.separator,g=i.decimal;i=i.groups;var y=(""+t).replace(/^-/,"").split("."),m=y[0];return y=y[1],(0<=t.value?u:l).replace("!",o).replace("#",m.replace(i,"$1"+f)+(y?g+y:""))},fromCents:!1},n=/(\d)(?=(\d{3})+\b)/g,a=/(\d)(?=(\d\d)+\d\b)/g;return e.prototype={add:function(t){var i=this.s,u=this.p;return e((this.intValue+r(t,i))/(i.fromCents?1:u),i)},subtract:function(t){var i=this.s,u=this.p;return e((this.intValue-r(t,i))/(i.fromCents?1:u),i)},multiply:function(t){var i=this.s;return e(this.intValue*t/(i.fromCents?1:Math.pow(10,i.precision)),i)},divide:function(t){var i=this.s;return e(this.intValue/r(t,i,!1),i)},distribute:function(t){var i=this.intValue,u=this.p,l=this.s,o=[],f=Math[0<=i?"floor":"ceil"](i/t),g=Math.abs(i-f*t);for(u=l.fromCents?1:u;t!==0;t--){var y=e(f/u,l);0<g--&&(y=y[0<=i?"add":"subtract"](1/u)),o.push(y)}return o},dollars:function(){return~~this.value},cents:function(){return~~(this.intValue%this.p)},format:function(t){var i=this.s;return typeof t=="function"?t(this,i):i.format(this,Object.assign({},i,t))},toString:function(){var t=this.s,i=t.increment;return(Math.round(this.intValue/this.p/i)*i).toFixed(t.precision)},toJSON:function(){return this.value}},e})});var jt={};je(jt,{findType:()=>w,isNumeric:()=>j,sort:()=>_t,version:()=>Ft});var G=k(te(),1);var Ze={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function M(e,r){if(!Array.isArray(e)||!e.length)return e;let s=b(b({},Ze),r),n,a;if(s.strictlyTwoElementsInRangeArrays&&!e.every((u,l)=>!Array.isArray(u)||u.length!==2?(n=l,a=u.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${a} elements!`);if(!e.every((u,l)=>!Array.isArray(u)||!Number.isInteger(u[0])||u[0]<0||!Number.isInteger(u[1])||u[1]<0?(n=l,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let t=e.length**2,i=0;return Array.from(e).sort((u,l)=>(s.progressFn&&(i+=1,s.progressFn(Math.floor(i*100/t))),u[0]===l[0]?u[1]<l[1]?-1:u[1]>l[1]?1:0:u[0]<l[0]?-1:1))}var re={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function ne(e,r){function s(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}if(!Array.isArray(e)||!e.length)return null;let n;if(r)if(s(r)){if(n=b(b({},re),r),n.progressFn&&s(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
11
+ ${JSON.stringify(r,null,4)} (type ${typeof r})`);else n=b({},re);let a=e.filter(o=>Array.isArray(o)).map(o=>[...o]).filter(o=>o[2]!==void 0||o[0]!==o[1]),t,i,u;n.progressFn?t=M(a,{progressFn:o=>{u=Math.floor(o/5),u!==i&&(i=u,n.progressFn(u))}}):t=M(a);let l=t.length-1;for(let o=l;o>0;o--)n.progressFn&&(u=Math.floor((1-o/l)*78)+21,u!==i&&u>i&&(i=u,n.progressFn(u))),(t[o][0]<=t[o-1][0]||!n.joinRangesThatTouchEdges&&t[o][0]<t[o-1][1]||n.joinRangesThatTouchEdges&&t[o][0]<=t[o-1][1])&&(t[o-1][0]=Math.min(t[o][0],t[o-1][0]),t[o-1][1]=Math.max(t[o][1],t[o-1][1]),t[o][2]!==void 0&&(t[o-1][0]>=t[o][0]||t[o-1][1]<=t[o][1])&&t[o-1][2]!==null&&(t[o][2]===null&&t[o-1][2]!==null?t[o-1][2]=null:t[o-1][2]!=null?+n.mergeType==2&&t[o-1][0]===t[o][0]?t[o-1][2]=t[o][2]:t[o-1][2]+=t[o][2]:t[o-1][2]=t[o][2]),t.splice(o,1),o=t.length);return t.length?t:null}var Qe=!0,B="Invariant failed";function se(e,r){if(!e){if(Qe)throw new Error(B);var s=typeof r=="function"?r():r,n=s?"".concat(B,": ").concat(s):B;throw new Error(n)}}function oe(e,r,s){let n=0,a=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(r&&!Array.isArray(r))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(s&&typeof s!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof s}, equal to: ${JSON.stringify(s,null,4)}`);if(!r||!r.filter(f=>f).length)return e;let t;Array.isArray(r)&&Number.isInteger(r[0])&&Number.isInteger(r[1])?t=[Array.from(r)]:t=Array.from(r);let i=t.length,u=0;t.filter(f=>f).forEach((f,g)=>{if(s&&(n=Math.floor(u/i*10),n!==a&&(a=n,s(n))),!Array.isArray(f))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${g}th element not an array: ${JSON.stringify(f,null,4)}, which is ${typeof f}`);if(!Number.isInteger(f[0])){if(!Number.isInteger(+f[0])||+f[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(f,null,0)}. Its first element is not an integer, string index, but ${typeof f[0]}, equal to: ${JSON.stringify(f[0],null,4)}.`);t[g][0]=+t[g][0]}if(!Number.isInteger(f[1])){if(!Number.isInteger(+f[1])||+f[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(f,null,0)}. Its second element is not an integer, string index, but ${typeof f[1]}, equal to: ${JSON.stringify(f[1],null,4)}.`);t[g][1]=+t[g][1]}u+=1});let l=ne(t,{progressFn:f=>{s&&(n=10+Math.floor(f/10),n!==a&&(a=n,s(n)))}});se(l);let o=l.length;if(o>0){let f=e.slice(l[o-1][1]);e=l.reduce((g,y,m,d)=>{s&&(n=20+Math.floor(m/o*80),n!==a&&(a=n,s(n)));let E=m===0?0:d[m-1][1],F=d[m][0];return`${g}${e.slice(E,F)}${d[m][2]||""}`},""),e+=f}return e}function _(e,r=1){let s="\xA0";function n(t){return Array.from(t).reverse().join("")}function a(t,i,u){let l=u?`
12
12
  `:"\r",o=u?"\r":`
13
13
  `;if(!t)return t;let f=0,g=0,y="";for(let m=0,d=t.length;m<d;m++)(t[m]===l||t[m]===o&&t[m-1]!==l)&&g++,`\r
14
14
  `.includes(t[m])||t[m]===s?(f=0,t[m]===s?y+=t[m]:t[m]===l?g<=i&&(y+=t[m],t[m+1]===o&&(y+=t[m+1],m++)):t[m]===o&&(t==null?void 0:t[m-1])!==l&&g<=i&&(y+=t[m])):(f++,!t[m+1]&&!g&&(y+=" "));return y}if(typeof e=="string"&&e.length){let t=1;typeof+r=="number"&&Number.isInteger(+r)&&+r>=0&&(t=+r);let i="",u="";if(!e.trim())i=e;else if(!e[0].trim()){for(let l=0,o=e.length;l<o;l++)if(e[l].trim()){i=e.slice(0,l);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===s)){for(let l=e.length;l--;)if(e[l].trim()){u=e.slice(l+1);break}}return`${a(i,t,!1)}${e.trim()}${n(a(n(u),t,!0))}`}return e}var Xe={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function ie(e,r){if(!Array.isArray(e)||!e.length)return e;let s=b(b({},Xe),r),n,a;if(s.strictlyTwoElementsInRangeArrays&&!e.every((u,l)=>!Array.isArray(u)||u.length!==2?(n=l,a=u.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${a} elements!`);if(!e.every((u,l)=>!Array.isArray(u)||!Number.isInteger(u[0])||u[0]<0||!Number.isInteger(u[1])||u[1]<0?(n=l,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let t=e.length**2,i=0;return Array.from(e).sort((u,l)=>(s.progressFn&&(i+=1,s.progressFn(Math.floor(i*100/t))),u[0]===l[0]?u[1]<l[1]?-1:u[1]>l[1]?1:0:u[0]<l[0]?-1:1))}var le={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function et(e,r){function s(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}if(!Array.isArray(e)||!e.length)return null;let n;if(r)if(s(r)){if(n=b(b({},le),r),n.progressFn&&s(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
@@ -17,12 +17,12 @@ ${JSON.stringify(s,null,4)}`);if(N(this.ranges)&&Array.isArray(this.last())&&n==
17
17
  ${JSON.stringify(e,null,4)}`);if(r&&typeof r!="object")throw new TypeError(`string-remove-thousand-separators/remSep(): [THROW_ID_02] Options object must be a plain object! Currently it's: ${typeof r}, equal to:
18
18
  ${JSON.stringify(r,null,4)}`);let t=b(b({},At),r),i=(0,Ee.default)(e.trim(),'"');if(i==="")return i;if(+e>0&&+e<1)return e;let u=new ae;for(let l=0,o=i.length;l<o;l++){if(t.removeThousandSeparatorsFromNumbers&&i[l].trim()===""&&u.add(l,l+1),t.removeThousandSeparatorsFromNumbers&&i[l]==="'"&&(u.add(l,l+1),i[l+1]==="'")){s=!1;break}if(n.includes(i[l])){if(i[l+1]!==void 0&&/^\d$/.test(i[l+1]))if(i[l+2]!==void 0)if(/^\d$/.test(i[l+2]))if(i[l+3]!==void 0)if(/^\d$/.test(i[l+3])){if(i[l+4]!==void 0&&/^\d$/.test(i[l+4])){s=!1;break}else if(t.removeThousandSeparatorsFromNumbers&&u.add(l,l+1),!a)a=i[l];else if(i[l]!==a){s=!1;break}}else{s=!1;break}else t.removeThousandSeparatorsFromNumbers&&t.forceUKStyle&&i[l]===","&&u.add(l,l+1,".");else{s=!1;break}else t.forceUKStyle&&i[l]===","&&u.add(l,l+1,"."),t.padSingleDecimalPlaceNumbers&&u.add(l+2,l+2,"0")}else if(!/^\d$/.test(i[l])){s=!1;break}}return s&&u.current()?oe(i,u.current()):i}var xt={removeThousandSeparatorsFromNumbers:!0,padSingleDecimalPlaceNumbers:!0,forceUKStyle:!1};function Ne(e,r){let s=0,n=0,a=[],t=[],i=!1,u=!0;if(r&&typeof r!="object")throw new Error(`csv-split-easy/split(): [THROW_ID_02] Options object must be a plain object! Currently it's of a type ${typeof r} equal to:
19
19
  ${JSON.stringify(r,null,4)}`);let l=b(b({},xt),r);if(typeof e!="string")throw new TypeError(`csv-split-easy/split(): [THROW_ID_04] input must be string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(e==="")return[[""]];e=e.trim();for(let o=0,f=e.length;o<f;o++){if(u&&e[o]!=='"'&&e[o]!==","&&e[o].trim()!==""&&(u=!1),e[o]==='"')if(i&&e[o+1]==='"')o+=1;else if(i){i=!1;let g=e.slice(s,o);g.trim()!==""&&(u=!1);let y=/""/.test(g)?g.replace(/""/g,'"'):C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle});a.push(y)}else i=!0,s=o+1;else if(!i&&e[o]===","){if(e[o-1]!=='"'&&!i){let g=e.slice(s,o);g.trim()!==""&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}s=o+1,n&&(n=0)}else if(e[o]===`
20
- `||e[o]==="\r"){if(!n){if(n=o,!i&&e[o-1]!=='"'){let g=e.slice(s,o);g.trim()!==""&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}u?a.length=0:t.push(a),u=!0,a=[]}s=o+1}else n&&(n=0,s=o);if(o+1===f){if(e[o]!=='"'){let g=e.slice(s,o+1);g.trim()&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}u?a=[]:t.push(a),u=!0}}return t.length===0?[[""]]:t}var A=k(De(),1);function j(e){return typeof e=="number"&&!isNaN(e)?!0:(e=(e||"").toString().trim(),e?!isNaN(+e):!1)}var Vt=["\u062F.\u0625","\u060B","L","\u058F","\u0192","Kz","$","\u0192","\u20BC","KM","\u09F3","\u043B\u0432",".\u062F.\u0628","FBu","$b","R$","\u0E3F","Nu.","P","p.","BZ$","FC","CHF","\xA5","\u20A1","\u20B1","K\u010D","Fdj","kr","RD$","\u062F\u062C","kr","Nfk","Br","\u039E","\u20AC","\u20BE","\u20B5","GH\u20B5","D","FG","Q","L","kn","G","Ft","Rp","\u20AA","\u20B9","\u0639.\u062F","\uFDFC","kr","J$","JD","\xA5","KSh","\u043B\u0432","\u17DB","CF","\u20A9","\u20A9","KD","\u043B\u0432","\u20AD","\u20A8","M","\u0141","Lt","Ls","LD","MAD","lei","Ar","\u0434\u0435\u043D","K","\u20AE","MOP$","UM","\u20A8","Rf","MK","RM","MT","\u20A6","C$","kr","\u20A8","\uFDFC","B/.","S/.","K","\u20B1","\u20A8","z\u0142","Gs","\uFDFC","\uFFE5","lei","\u0414\u0438\u043D.","\u20BD","R\u20A3","\uFDFC","\u20A8","\u062C.\u0633.","kr","\xA3","Le","S","Db","E","\u0E3F","SM","T","\u062F.\u062A","T$","\u20A4","\u20BA","TT$","NT$","TSh","\u20B4","USh","$U","\u043B\u0432","Bs","\u20AB","VT","WS$","FCFA","\u0243","CFA","\u20A3","\uFDFC","R","Z$"];function w(e){return j(e)||Vt.some(r=>j(e.replace(r,"").replace(/[,.]/g,"")))?"numeric":e.trim()?"text":"empty"}var Ie="6.1.2";var Ft=Ie;function _t(e){let r=null,s=null;if(typeof e!="string")throw new TypeError(`csv-sort/csvSort(): [THROW_ID_01] The input is of a wrong type! We accept either string of array of arrays. We got instead: ${typeof e}, equal to:
21
- ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgType:s};let n=Ne(e),a=[],t=!1,i=!0,u=[],l=null;for(let c=n.length-1;c>=0;c--)if(a.length){c===0&&(t=n[c].every(h=>w(h)==="text"||w(h)==="empty")),!t&&a.length!==n[c].length&&(i=!1);let p=null;for(let h=0,S=n[c].length;h<S;h++)if(p===null&&w(n[c][h].trim())==="empty"&&(p=h),p!==null&&w(n[c][h].trim())!=="empty"&&(p=null),w(n[c][h].trim())!==a[h]&&!t){let $=w(n[c][h].trim());if(Array.isArray(a[h]))a[h].includes($)||a[h].push(w(n[c][h].trim()));else if(a[h]!==$){let T=a[h];a[h]=[],a[h].push(T),a[h].push($)}}l!==null&&p!==null&&p>l&&(!t||t&&c!==0)&&(l=p)}else if(n[c].length!==1||n[c][0]!=="")for(let p=0,h=n[c].length;p<h;p++)a.push(w(n[c][p].trim())),l===null&&w(n[c][p].trim())==="empty"&&(l=p),l!==null&&w(n[c][p].trim())!=="empty"&&(l=null);l||(l=a.length);let o=0;for(let c=0,p=a.length;c<p&&a[c]==="empty";c++)o=c;o!==0&&(n=n.map(c=>c.slice(o+1,l)),a=a.slice(o+1,l));let f=[],g;a.forEach((c,p)=>{c==="numeric"&&f.push(p)});let y=t?1:0;if(f.length===1)g=f[0];else{if(f.length===0)throw new Error('csv-sort/csvSort(): [THROW_ID_03] Your CSV file does not contain numeric-only columns and computer was not able to detect the "Balance" column!');{let c=Array.from(f),p=[];for(let h=0,S=c.length;h<S;h++){let $=c[h],T,R=!0,I,O=!0;for(let v=y,Ae=n.length;v<Ae&&(R&&(T==null?T=n[v][$]:T===n[v][$]?(p.push($),R=!1):T=n[v][$]),O&&(I==null?I=n[v][$]:n[v][$]!==I&&(O=!1)),!!R);v++);O&&u.push($)}if(c=(0,G.default)(c,...p),c.length===1)g=c[0];else if(c.length===0)throw new Error(`csv-sort/csvSort(): [THROW_ID_04] The computer can't find the "Balance" column! It saw some numeric-only columns, but they all seem to have certain rows with the same values as rows right below/above them!`)}}if(!g)throw new Error("csv-sort/csvSort(): [THROW_ID_05] Sadly computer couldn't find its way in this CSV and had to stop working on it.");let m=(0,G.default)(Array.from(a.reduce((c,p,h)=>((typeof p=="string"&&p==="numeric"||Array.isArray(p)&&p.includes("numeric"))&&c.push(h),c),[])),g,...u),d=[];d.push(n[n.length-1].slice(0,l));let E=[],F=t?1:0;for(let c=n.length-2;c>=F;c--)for(let p=n.length-2;p>=F;p--)if(!E.includes(p)){let h=!1;for(let S=0,$=m.length;S<$;S++){let T=null;n[p][m[S]]!==""&&(T=(0,A.default)(n[p][m[S]]));let R=null;n[p][g]!==""&&(R=(0,A.default)(n[p][g]));let I=null;d[0][g]!==""&&(I=(0,A.default)(d[0][g]).format());let O=null;d[d.length-1][m[S]]!==""&&(O=(0,A.default)(d[d.length-1][m[S]]).format());let v=null;if(d[d.length-1][g]!==""&&(v=(0,A.default)(d[d.length-1][g])),T&&R.add(T).format()===I){d.unshift(n[p].slice(0,l)),E.push(p),h=!0;break}else if(T&&R.subtract(T).format()===I){d.unshift(n[p].slice(0,l)),E.push(p),h=!0;break}else if(O&&v.add(O).format()===R.format()){d.push(n[p].slice(0,l)),E.push(p),h=!0;break}else if(O&&v.subtract(O).format()===R.format()){d.push(n[p].slice(0,l)),E.push(p),h=!0;break}}if(h){h=!1;break}}return t&&(i&&n[0].length>a.length&&(n[0].length=a.length),d.unshift(n[0].slice(0,l))),n.length-(t?2:1)!==E.length&&(r="Not all rows were recognised!",s="alert"),{res:d,msgContent:r,msgType:s}}return We(jt);})();
20
+ `||e[o]==="\r"){if(!n){if(n=o,!i&&e[o-1]!=='"'){let g=e.slice(s,o);g.trim()!==""&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}u?a.length=0:t.push(a),u=!0,a=[]}s=o+1}else n&&(n=0,s=o);if(o+1===f){if(e[o]!=='"'){let g=e.slice(s,o+1);g.trim()&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}u?a=[]:t.push(a),u=!0}}return t.length===0?[[""]]:t}var A=k(De(),1);function j(e){return typeof e=="number"&&!isNaN(e)?!0:(e=(e||"").toString().trim(),e?!isNaN(+e):!1)}var Vt=["\u062F.\u0625","\u060B","L","\u058F","\u0192","Kz","$","\u0192","\u20BC","KM","\u09F3","\u043B\u0432",".\u062F.\u0628","FBu","$b","R$","\u0E3F","Nu.","P","p.","BZ$","FC","CHF","\xA5","\u20A1","\u20B1","K\u010D","Fdj","kr","RD$","\u062F\u062C","kr","Nfk","Br","\u039E","\u20AC","\u20BE","\u20B5","GH\u20B5","D","FG","Q","L","kn","G","Ft","Rp","\u20AA","\u20B9","\u0639.\u062F","\uFDFC","kr","J$","JD","\xA5","KSh","\u043B\u0432","\u17DB","CF","\u20A9","\u20A9","KD","\u043B\u0432","\u20AD","\u20A8","M","\u0141","Lt","Ls","LD","MAD","lei","Ar","\u0434\u0435\u043D","K","\u20AE","MOP$","UM","\u20A8","Rf","MK","RM","MT","\u20A6","C$","kr","\u20A8","\uFDFC","B/.","S/.","K","\u20B1","\u20A8","z\u0142","Gs","\uFDFC","\uFFE5","lei","\u0414\u0438\u043D.","\u20BD","R\u20A3","\uFDFC","\u20A8","\u062C.\u0633.","kr","\xA3","Le","S","Db","E","\u0E3F","SM","T","\u062F.\u062A","T$","\u20A4","\u20BA","TT$","NT$","TSh","\u20B4","USh","$U","\u043B\u0432","Bs","\u20AB","VT","WS$","FCFA","\u0243","CFA","\u20A3","\uFDFC","R","Z$"];function w(e){return j(e)||Vt.some(r=>j(e.replace(r,"").replace(/[,.]/g,"")))?"numeric":e.trim()?"text":"empty"}var Ie="6.1.3";var Ft=Ie;function _t(e){let r=null,s=null;if(typeof e!="string")throw new TypeError(`csv-sort/csvSort(): [THROW_ID_01] The input is of a wrong type! We accept either string of array of arrays. We got instead: ${typeof e}, equal to:
21
+ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgType:s};let n=Ne(e),a=[],t=!1,i=!0,u=[],l=null;for(let p=n.length-1;p>=0;p--)if(a.length){p===0&&(t=n[p].every(h=>w(h)==="text"||w(h)==="empty")),!t&&a.length!==n[p].length&&(i=!1);let c=null;for(let h=0,S=n[p].length;h<S;h++)if(c===null&&w(n[p][h].trim())==="empty"&&(c=h),c!==null&&w(n[p][h].trim())!=="empty"&&(c=null),w(n[p][h].trim())!==a[h]&&!t){let $=w(n[p][h].trim());if(Array.isArray(a[h]))a[h].includes($)||a[h].push(w(n[p][h].trim()));else if(a[h]!==$){let T=a[h];a[h]=[],a[h].push(T),a[h].push($)}}l!==null&&c!==null&&c>l&&(!t||t&&p!==0)&&(l=c)}else if(n[p].length!==1||n[p][0]!=="")for(let c=0,h=n[p].length;c<h;c++)a.push(w(n[p][c].trim())),l===null&&w(n[p][c].trim())==="empty"&&(l=c),l!==null&&w(n[p][c].trim())!=="empty"&&(l=null);l||(l=a.length);let o=0;for(let p=0,c=a.length;p<c&&a[p]==="empty";p++)o=p;o!==0&&(n=n.map(p=>p.slice(o+1,l)),a=a.slice(o+1,l));let f=[],g;a.forEach((p,c)=>{p==="numeric"&&f.push(c)});let y=t?1:0;if(f.length===1)g=f[0];else{if(f.length===0)throw new Error('csv-sort/csvSort(): [THROW_ID_03] Your CSV file does not contain numeric-only columns and computer was not able to detect the "Balance" column!');{let p=Array.from(f),c=[];for(let h=0,S=p.length;h<S;h++){let $=p[h],T,R=!0,I,O=!0;for(let v=y,Ae=n.length;v<Ae&&(R&&(T==null?T=n[v][$]:T===n[v][$]?(c.push($),R=!1):T=n[v][$]),O&&(I==null?I=n[v][$]:n[v][$]!==I&&(O=!1)),!!R);v++);O&&u.push($)}if(p=(0,G.default)(p,...c),p.length===1)g=p[0];else if(p.length===0)throw new Error(`csv-sort/csvSort(): [THROW_ID_04] The computer can't find the "Balance" column! It saw some numeric-only columns, but they all seem to have certain rows with the same values as rows right below/above them!`)}}if(!g)throw new Error("csv-sort/csvSort(): [THROW_ID_05] Sadly computer couldn't find its way in this CSV and had to stop working on it.");let m=(0,G.default)(Array.from(a.reduce((p,c,h)=>((typeof c=="string"&&c==="numeric"||Array.isArray(c)&&c.includes("numeric"))&&p.push(h),p),[])),g,...u),d=[];d.push(n[n.length-1].slice(0,l));let E=[],F=t?1:0;for(let p=n.length-2;p>=F;p--)for(let c=n.length-2;c>=F;c--)if(!E.includes(c)){let h=!1;for(let S=0,$=m.length;S<$;S++){let T=null;n[c][m[S]]!==""&&(T=(0,A.default)(n[c][m[S]]));let R=null;n[c][g]!==""&&(R=(0,A.default)(n[c][g]));let I=null;d[0][g]!==""&&(I=(0,A.default)(d[0][g]).format());let O=null;d[d.length-1][m[S]]!==""&&(O=(0,A.default)(d[d.length-1][m[S]]).format());let v=null;if(d[d.length-1][g]!==""&&(v=(0,A.default)(d[d.length-1][g])),T&&R.add(T).format()===I){d.unshift(n[c].slice(0,l)),E.push(c),h=!0;break}else if(T&&R.subtract(T).format()===I){d.unshift(n[c].slice(0,l)),E.push(c),h=!0;break}else if(O&&v.add(O).format()===R.format()){d.push(n[c].slice(0,l)),E.push(c),h=!0;break}else if(O&&v.subtract(O).format()===R.format()){d.push(n[c].slice(0,l)),E.push(c),h=!0;break}}if(h){h=!1;break}}return t&&(i&&n[0].length>a.length&&(n[0].length=a.length),d.unshift(n[0].slice(0,l))),n.length-(t?2:1)!==E.length&&(r="Not all rows were recognised!",s="alert"),{res:d,msgContent:r,msgType:s}}return We(jt);})();
22
22
  /**
23
23
  * @name csv-split-easy
24
24
  * @fileoverview Splits the CSV string into array of arrays, each representing a row of columns
25
- * @version 6.1.2
25
+ * @version 6.1.3
26
26
  * @author Roy Revelt, Codsen Ltd
27
27
  * @license MIT
28
28
  * {@link https://codsen.com/os/csv-split-easy/}
@@ -30,7 +30,7 @@ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgTyp
30
30
  /**
31
31
  * @name ranges-apply
32
32
  * @fileoverview Take an array of string index ranges, delete/replace the string according to them
33
- * @version 6.2.2
33
+ * @version 6.2.3
34
34
  * @author Roy Revelt, Codsen Ltd
35
35
  * @license MIT
36
36
  * {@link https://codsen.com/os/ranges-apply/}
@@ -70,7 +70,7 @@ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgTyp
70
70
  /**
71
71
  * @name string-remove-thousand-separators
72
72
  * @fileoverview Detects and removes thousand separators (dot/comma/quote/space) from string-type digits
73
- * @version 6.2.2
73
+ * @version 6.2.3
74
74
  * @author Roy Revelt, Codsen Ltd
75
75
  * @license MIT
76
76
  * {@link https://codsen.com/os/string-remove-thousand-separators/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "csv-sort",
3
- "version": "6.1.2",
3
+ "version": "6.1.3",
4
4
  "description": "Sort double-entry bookkeeping CSV from internet banking",
5
5
  "keywords": [
6
6
  "accountancy",
@@ -74,7 +74,7 @@
74
74
  }
75
75
  },
76
76
  "dependencies": {
77
- "csv-split-easy": "^6.1.2",
77
+ "csv-split-easy": "^6.1.3",
78
78
  "currency.js": "^2.0.4",
79
79
  "lodash.pull": "^4.1.0"
80
80
  },