@borgar/fx 4.6.0 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fx.d.ts +0 -33
- package/dist/fx.js +1 -1
- package/docs/API.md +4 -80
- package/docs/Prefixes.md +1 -1
- package/lib/a1.js +2 -0
- package/lib/fixRanges.spec.js +9 -1
- package/lib/index.spec.js +67 -0
- package/lib/rc.js +2 -0
- package/lib/sr.js +3 -3
- package/lib/sr.spec.js +12 -4
- package/package.json +12 -11
package/dist/fx.d.ts
CHANGED
|
@@ -111,15 +111,6 @@ export declare function fixRanges(formula: (string | Array<Token>), options?: {
|
|
|
111
111
|
xlsx?: boolean;
|
|
112
112
|
}): (string | Array<Token>);
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
* Parse a simple string reference to an A1 range into a range object.
|
|
116
|
-
* Will accept `A1`, `A2`, `A:A`, or `1:1`.
|
|
117
|
-
*
|
|
118
|
-
* @param rangeString A range string
|
|
119
|
-
* @returns An object representing a valid range or null if it is invalid.
|
|
120
|
-
*/
|
|
121
|
-
declare function fromA1(rangeString: string): (RangeA1 | null);
|
|
122
|
-
|
|
123
114
|
/**
|
|
124
115
|
* Convert a column string representation to a 0 based
|
|
125
116
|
* offset number (`"C"` = `2`).
|
|
@@ -132,14 +123,6 @@ declare function fromA1(rangeString: string): (RangeA1 | null);
|
|
|
132
123
|
*/
|
|
133
124
|
export declare function fromCol(columnString: string): number;
|
|
134
125
|
|
|
135
|
-
/**
|
|
136
|
-
* Parse a simple string reference to an R1C1 range into a range object.
|
|
137
|
-
*
|
|
138
|
-
* @param rangeString A range string
|
|
139
|
-
* @returns An object representing a valid reference or null if it is invalid.
|
|
140
|
-
*/
|
|
141
|
-
declare function fromR1C1(rangeString: string): (RangeR1C1 | null);
|
|
142
|
-
|
|
143
126
|
/**
|
|
144
127
|
* Determines whether the specified token is an error.
|
|
145
128
|
* Returns `true` if the input is a token of type ERROR (`#VALUE!`). In all
|
|
@@ -447,14 +430,6 @@ export declare function stringifyStructRef(refObject: ReferenceStruct, options?:
|
|
|
447
430
|
xlsx?: boolean;
|
|
448
431
|
}): string;
|
|
449
432
|
|
|
450
|
-
/**
|
|
451
|
-
* Stringify a range object into A1 syntax.
|
|
452
|
-
*
|
|
453
|
-
* @param range A range object
|
|
454
|
-
* @returns An A1-style string represenation of a range
|
|
455
|
-
*/
|
|
456
|
-
declare function toA1(range: RangeA1): string;
|
|
457
|
-
|
|
458
433
|
/**
|
|
459
434
|
* Convert a 0 based offset number to a column string
|
|
460
435
|
* representation (`2` = `"C"`).
|
|
@@ -466,14 +441,6 @@ declare function toA1(range: RangeA1): string;
|
|
|
466
441
|
*/
|
|
467
442
|
export declare function toCol(columnIndex: number): string;
|
|
468
443
|
|
|
469
|
-
/**
|
|
470
|
-
* Stringify a range object into R1C1 syntax.
|
|
471
|
-
*
|
|
472
|
-
* @param range A range object
|
|
473
|
-
* @returns An R1C1-style string represenation of a range
|
|
474
|
-
*/
|
|
475
|
-
declare function toR1C1(range: RangeR1C1): string;
|
|
476
|
-
|
|
477
444
|
/**
|
|
478
445
|
* Breaks a string formula into a list of tokens.
|
|
479
446
|
* The returned output will be an array of objects representing the tokens:
|
package/dist/fx.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e="operator",t="error",n="range_beam",l="range_ternary",r="range_named",o="structured",u="unknown",s="UnaryExpression",c="BinaryExpression",i="ReferenceIdentifier",a="CallExpression";function f(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!1,l="";const r=[],o=()=>{l&&r.push(t?l:{value:l,braced:n}),l=""};for(let t=0;t<e.length;t++){const r=e[t];"["===r?(o(),n=!0):"]"===r?(o(),n=!1):l+=r}return o(),r}function p(e){return{context:f(e,!0)}}function h(e){const t={},n=f(e);if(n.length>1)t.workbookName=n[n.length-2].value,t.sheetName=n[n.length-1].value;else if(1===n.length){const e=n[0];e.braced?t.workbookName=e.value:t.sheetName=e.value}return t}const g=e=>e&&":"===e.value&&{},x=e=>e&&"range"===e.type&&{r0:e.value},d=e=>e&&e.type===l&&{r0:e.value},$=e=>e&&"range"===e.type&&{r1:e.value},y=t=>t&&t.type===e&&"!"===t.value&&{},m=e=>e&&e.type===n&&{r0:e.value},v=e=>e&&e.type===o&&{struct:e.value},E=(e,t)=>{const n=t.xlsx?h:p;return e&&"context"===e.type?n(e.value):e&&"context_quote"===e.type?n(e.value.slice(1,-1).replace(/''/g,"'")):void 0},R=e=>e&&e.type===r&&{name:e.value},w=[[d],[x,g,$],[x],[m],[E,y,d],[E,y,x,g,$],[E,y,x],[E,y,m]],N=w.concat([[R],[E,y,R],[v],[R,v],[E,y,R,v]]);function b(e,t){const n={withLocation:!1,mergeRefs:!1,allowTernary:!1,allowNamed:!0,r1c1:!1,xlsx:!1,...t},l=Fe(e,Ae,n),r=n.xlsx?{workbookName:"",sheetName:"",r0:"",r1:"",name:""}:{context:[],r0:"",r1:"",name:""};l.length&&"fx_prefix"===l[0].type&&l.shift();const o=n.allowNamed?N:w;for(let e=0;e<o.length;e++){const t={...r};if(o[e].length===l.length){const r=o[e].every(((e,r)=>{const o=e(l[r],n);return Object.assign(t,o),o}));if(r)return t}}return null}const A=/[^0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]/;function C(e){let t="",n=0,l=0;const r=e.context||[];for(let e=r.length;e>-1;e--){const o=r[e];if(o){t=(l%2?"["+o+"]":o)+t,n+=A.test(o),l++}}return n&&(t="'"+t.replace(/'/g,"''")+"'"),t?t+"!":t}function T(e){let t="",n=0;const{workbookName:l,sheetName:r}=e;return l&&(t+="["+l+"]",n+=A.test(l)),r&&(t+=r,n+=A.test(r)),n&&(t="'"+t.replace(/'/g,"''")+"'"),t?t+"!":t}const I=(e,t,n)=>Math.min(Math.max(t,e),n),L=(e,t)=>(t?"$":"")+U(e),k=(e,t)=>(t?"$":"")+String(e+1),O=String.fromCharCode;function _(e){const t=e||"",n=t.length;let l=0;if(n>2){const e=t.charCodeAt(n-3);l+=676*(1+e-(e>95?32:0)-65)}if(n>1){const e=t.charCodeAt(n-2);l+=26*(1+e-(e>95?32:0)-65)}if(n){const e=t.charCodeAt(n-1);l+=e-(e>95?32:0)-65}return l}function U(e){return(e>=702?O(((e-702)/676-0)%26+65):"")+(e>=26?O((e/26-1)%26+65):"")+O(e%26+65)}function F(e){let{top:t,left:n,bottom:l,right:r}=e;const{$left:o,$right:u,$top:s,$bottom:c}=e,i=null==n,a=null==r,f=null==t,p=null==l;t=I(0,0|t,1048575),n=I(0,0|n,16383),!i&&!f&&a&&p?(l=t,r=n):(l=I(0,0|l,1048575),r=I(0,0|r,16383));if(0===t&&l>=1048575&&!i&&!a&&(!(o&&!i||u&&!a)||n===r)||f&&p)return L(n,o)+":"+L(r,u);return 0===n&&r>=16383&&!f&&!p&&(!(s&&!f||c&&!p)||t===l)||i&&a?k(t,s)+":"+k(l,c):i||f||a||!p?i||!f||a||p?i||f||!a||p?!i||f||a||p?r!==n||l!==t||u!==o||c!==s?L(n,o)+k(t,s)+":"+L(r,u)+k(l,c):L(n,o)+k(t,s):L(r,u)+k(t,s)+":"+k(l,c):L(n,o)+k(t,s)+":"+k(l,c):L(n,o)+k(l,c)+":"+L(r,u):L(n,o)+k(t,s)+":"+L(r,u)}function S(e){const t=/^(?=.)(\$(?=\D))?([A-Za-z]{0,3})?(\$)?([1-9][0-9]{0,6})?$/.exec(e);return t&&(t[2]||t[4])?[t[4]?(n=t[4],+n-1):null,t[2]?_(t[2]):null,!!t[3],!!t[1]]:null;var n}function M(e){let t=null,n=null,l=null,r=null,o=!1,u=!1,s=!1,c=!1;const[i,a,f]=e.split(":");if(f)return null;const p=S(i),h=a?S(a):null;if(!p||a&&!h)return null;if(null!=p[0]&&null!=p[1]?[t,n,o,u]=p:null==p[0]&&null!=p[1]?[,n,,u]=p:null!=p[0]&&null==p[1]&&([t,,o]=p),a)null!=h[0]&&null!=h[1]?[l,r,s,c]=h:null==h[0]&&null!=h[1]?[,r,,c]=h:null!=h[0]&&null==h[1]&&([l,,s]=h);else{if(null==t||null==n)return null;l=t,r=n,s=o,c=u}return null!=r&&(null==n||null!=n&&r<n)&&([n,r,u,c]=[r,n,c,u]),null!=l&&(null==t||null!=t&&l<t)&&([t,l,o,s]=[l,t,s,o]),{top:t,left:n,bottom:l,right:r,$top:o,$left:u,$bottom:s,$right:c}}function z(e){let{allowNamed:t=!0,allowTernary:n=!1,xlsx:l=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=b(e,{allowNamed:t,allowTernary:n,xlsx:l,r1c1:!1});if(r&&(r.r0||r.name)){let e=null;return r.r0&&(e=M(r.r1?r.r0+":"+r.r1:r.r0)),r.name||e?(r.range=e,delete r.r0,delete r.r1,r):null}return null}function D(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t?T(e):C(e);return n+(e.name?e.name:F(e.range))}function j(e){return null==e.top&&(e.top=0,e.$top=!1),null==e.bottom&&(e.bottom=1048575,e.$bottom=!1),null==e.left&&(e.left=0,e.$left=!1),null==e.right&&(e.right=16383,e.$right=!1),e}const Z=/^\[('['#@[\]]|[^'#@[\]])+\]/i,q=/^([^#@[\]:]+)/i,B={headers:1,data:2,totals:4,all:8,"this row":16,"@":16},P=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Object.freeze(t)},X={0:P(),1:P("headers"),2:P("data"),4:P("totals"),8:P("all"),16:P("this row"),3:P("headers","data"),6:P("data","totals")},W=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=Z.exec(e);if(n){const e=n[0].slice(1,-1).replace(/'(['#@[\]])/g,"$1");return[n[0],e]}return t&&(n=q.exec(e),n)?[n[0],n[0]]:null};function H(e){const t=[];let n,l,r=0,o=e,u=0;if(!(n=/^(\[\s*)/.exec(o)))return null;if(l=/^\[#([a-z ]+)\]/i.exec(o)){const e=l[1].toLowerCase();if(r+=l[0].length,!B[e])return null;u|=B[e]}else if(l=W(o,!1))r+=l[0].length,t.push(l[1].trim());else{let l=!0;for(o=o.slice(n[1].length),r+=n[1].length;l&&(n=/^\[#([a-z ]+)\](\s*,\s*)?/i.exec(o));){const e=n[1].toLowerCase();if(!B[e])return null;u|=B[e],o=o.slice(n[0].length),r+=n[0].length,l=!!n[2]}if(l&&(n=/^@/.exec(o))&&(u|=B["@"],o=o.slice(1),r+=1,l="]"!==o[0]),!(u in X))return null;const s=l?W(e.slice(r)):null;if(s){if(r+=s[0].length,t.push(s[1].trim()),o=e.slice(r),":"===o[0]){o=o.slice(1),r++;const e=W(o);if(!e)return null;r+=e[0].length,t.push(e[1].trim())}l=!1}for(;" "===e[r];)r++;if(l||"]"!==e[r])return null;r++}const s=X[u];return{columns:t,sections:s?s.concat():s,length:r,token:e.slice(0,r)}}function Y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{xlsx:!1};const n=b(e,t);if(n&&n.struct){const e=H(n.struct);if(e&&e.length===n.struct.length)return t.xlsx?{workbookName:n.workbookName,sheetName:n.sheetName,table:n.name,columns:e.columns,sections:e.sections}:{context:n.context,table:n.name,columns:e.columns,sections:e.sections}}return null}function G(e){return e.replace(/([[\]#'@])/g,"'$1")}function K(e){return!/^[a-zA-Z0-9\u00a1-\uffff]+$/.test(e)}function V(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Q(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t?T(e):C(e);e.table&&(n+=e.table);const l=e.columns?.length??0,r=e.sections?.length??0;if(1!==r||l)if(r||1!==l){n+="[";const t=1===r&&"this row"===e.sections[0].toLowerCase();t?n+="@":r&&(n+=e.sections.map((e=>`[#${V(e)}]`)).join(","),l&&(n+=",")),t&&1===e.columns.length&&!K(e.columns[0])?n+=G(e.columns[0]):l&&(n+=e.columns.slice(0,2).map((e=>`[${G(e)}]`)).join(":")),n+="]"}else n+=`[${G(e.columns[0])}]`;else n+=`[#${V(e.sections[0])}]`;return n}const J=/^(?!!)(\[(?:[^\]])+\])?([0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]+)?(?=!)/,ee=/^'(?:''|[^'])*('|$)(?=!)/,te="\\$?[A-Z]{1,3}\\$?[1-9][0-9]{0,6}",ne="\\$?[A-Z]{1,3}",le="\\$?[1-9][0-9]{0,6}",re="(?![a-z0-9_\\u00a1-\\uffff])",oe=new RegExp(`^${ne}:${ne}${re}`,"i"),ue=new RegExp(`^${le}:${le}${re}`,"i"),se=new RegExp(`^${te}${re}`,"i"),ce=new RegExp(`^((${ne}|${le}):${te}|${te}:(${ne}|${le}))(?![\\w($.])`,"i"),ie="(?:R(?:\\[[+-]?\\d+\\]|[1-9][0-9]{0,6})?)",ae="(?:C(?:\\[[+-]?\\d+\\]|[1-9][0-9]{0,4})?)",fe=new RegExp(`^${ae}(:${ae})?${re}`,"i"),pe=new RegExp(`^${ie}(:${ie})?${re}`,"i"),he=new RegExp(`^(?:(?=[RC])${ie}${ae})${re}`,"i"),ge=new RegExp(`^(${ie}${ae}(:${ae}|:${ie})(?![[\\d])|(${ie}|${ae})(:${ie}${ae}))${re}`,"i"),xe=/^[a-zA-Z\\_\u00a1-\uffff][a-zA-Z0-9\\_.?\u00a1-\uffff]{0,254}/i;function de(e,t){return n=>{const l=t.exec(n);if(l)return{type:e,value:l[0]}}}function $e(e){const t=xe.exec(e);if(t){const e=t[0].toLowerCase();return"r"===e||"c"===e?null:{type:r,value:t[0]}}}const ye=/^'(?:[^[\]]+?)?(?:\[(.+?)\])?(?:[^[\]]+?)'$/,me=/^'\[(.+?)\]'$/;function ve(e,t){const n=ee.exec(e);if(n){const e=n[0];if(t.xlsx&&me.test(e)||ye.test(e))return{type:"context_quote",value:e}}const l=J.exec(e);if(l){const[,e,n]=l;if(e&&n||n||e&&!n&&t.xlsx)return{type:"context",value:l[0]}}}function Ee(e){const t=H(e);if(t){let n=t.length;for(;" "===e[n];)n++;if("!"!==e[n])return{type:o,value:t.token}}return null}const Re=/([RC])(\[?)(-?\d+)/gi,we=/(\d+|[a-zA-Z]+)/gi;function Ne(e,t){let r,o;if(t.r1c1){if(t.allowTernary&&(r=ge.exec(e))?o={type:l,value:r[0]}:(r=he.exec(e))?o={type:"range",value:r[0]}:((r=pe.exec(e))||(r=fe.exec(e)))&&(o={type:n,value:r[0]}),o){for(Re.lastIndex=0;null!==(r=Re.exec(o.value));){const e=("R"===r[1]?1048575:16383)+(r[2]?0:1),t=parseInt(r[3],10);if(t>e||t<-e)return null}return o}}else if(t.allowTernary&&(r=ce.exec(e))?o={type:l,value:r[0]}:(r=oe.exec(e))||(r=ue.exec(e))?o={type:n,value:r[0]}:(r=se.exec(e))&&(o={type:"range",value:r[0]}),o){for(we.lastIndex=0;null!==(r=we.exec(o.value));)if(/^\d/.test(r[1])){if(parseInt(r[1],10)-1>1048575)return null}else if(_(r[1])>16383)return null;return o}}const be=[de(t,/^#(NAME\?|FIELD!|CALC!|VALUE!|REF!|DIV\/0!|NULL!|NUM!|N\/A|GETTING_DATA\b|SPILL!|UNKNOWN!|FIELD\b|CALC\b|SYNTAX\?|ERROR!|CONNECT!|BLOCKED!|EXTERNAL!)/i),de(e,/^(<=|>=|<>|[-+/*^%&<>=]|[{},;]|[()]|@|:|!|#)/),de("func",/^[A-Z_]+[A-Z\d_.]*(?=\()/i),de("bool",/^(TRUE|FALSE)\b/i),de("newline",/^\n+/),de("whitespace",/^[ \f\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/),de("string",/^"(?:""|[^"])*("|$)/),ve,Ne,Ee,de("number",/^(?:\d+(\.\d+)?(?:[eE][+-]?\d+)?|\d+)/),$e],Ae=[function(t,n){return n.r1c1?"!"===t[0]?{type:e,value:t[0]}:null:"!"===t[0]||":"===t[0]?{type:e,value:t[0]}:null},ve,Ne,Ee,$e],Ce={};function Te(e,t){if(e.length){const n=e[0];t[n]=t[n]||{},Te(e.slice(1),t[n])}else t.$=!0}[["range",":","range"],["range"],[n],[l],["context","!","range",":","range"],["context","!","range"],["context","!",n],["context","!",l],["context_quote","!","range",":","range"],["context_quote","!","range"],["context_quote","!",n],["context_quote","!",l],[r],["context","!",r],["context_quote","!",r],[o],[r,o],["context","!",r,o],["context_quote","!",r,o]].forEach((e=>Te(e.concat().reverse(),Ce)));const Ie=function(t,n,l){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const o=t[l-r];if(o){const u=o.type===e?o.value:o.type;if(u in n)return Ie(t,n[u],l,r+1)}return n.$?r:0};function Le(e){const t=[];for(let n=e.length-1;n>=0;n--){let l=e[n];const r=Ie(e,Ce,n);if(r){const t=e.slice(n-r+1,n+1);l={...l},l.value=t.map((e=>e.value)).join(""),l.loc&&t[0].loc&&(l.loc[0]=t[0].loc[0]),n-=r-1}t.unshift(l)}return t}const ke=(e,t)=>e&&e.type===t,Oe={withLocation:!1,mergeRefs:!0,allowTernary:!1,negativeNumbers:!0,r1c1:!1},_e=e=>e.type===r||"func"===e.type,Ue=t=>!ke(t,e)||"%"===t.value||"}"===t.value||")"===t.value||"#"===t.value;function Fe(t,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=Object.assign({},Oe,l),{withLocation:o,mergeRefs:s,negativeNumbers:c}=r,i=[];let a=0,f=null,p=null,h=null;const g=e=>{const t=e.type===u,n=h&&h.type===u;h&&(t&&n||t&&_e(h)||n&&_e(e))?(h.value+=e.value,h.type=u,o&&(h.loc[1]=e.loc[1])):(i.push(e),h=e,"whitespace"!==e.type&&"newline"!==e.type&&(p=f,f=e))};if(/^=/.test(t)){a++,g({type:"fx_prefix",value:"=",...o?{loc:[0,1]}:{}})}for(;a<t.length;){const l=a,s=t.slice(a);let x="",d="";for(let e=0;e<n.length;e++){const t=n[e](s,r);if(t){x=t.type,d=t.value,a+=d.length;break}}x||(x=u,d=t[a],a++);const $={type:x,value:d,...o?{loc:[l,a]}:{}};if("string"===x){const e=d.length;if('""'===d);else if('"'===d||'"'!==d[e-1])$.unterminated=!0;else if('""'!==d&&'"'===d[e-2]){let t=e-1;for(;'"'===d[t];)t--;!(t+1)^(e-t+1)%2==0&&($.unterminated=!0)}}if(c&&"number"===x){const t=h;if(t&&ke(t,e)&&"-"===t.value&&(!p||ke(p,"fx_prefix")||!Ue(p))){const e=i.pop();$.value="-"+d,o&&($.loc[0]=e.loc[0]),f=p,h=i[i.length-1]}}g($)}return s?Le(i):i}function Se(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Fe(e,be,t)}function Me(e){return!!e&&("range"===e.type||e.type===n||e.type===l)}function ze(e){return!!e&&("range"===e.type||e.type===n||e.type===l||e.type===o||e.type===r)}function De(e){return!!e&&("bool"===e.type||e.type===t||"number"===e.type||"string"===e.type)}function je(e){return!!e&&e.type===t}function Ze(e){return!!e&&("whitespace"===e.type||"newline"===e.type)}function qe(e){return!!e&&"func"===e.type}function Be(e){return!!e&&"fx_prefix"===e.type}function Pe(t){return!!t&&t.type===e}const Xe="(END)",We=["ANCHORARRAY","CHOOSE","DROP","IF","IFS","INDEX","INDIRECT","LAMBDA","LET","OFFSET","REDUCE","SINGLE","SWITCH","TAKE","XLOOKUP"],He=e=>!!e&&(e.type===i||("ErrorLiteral"===e.type||e.type===t)&&"#REF!"===e.value||e.type===c&&(":"===e.operator||" "===e.operator||","===e.operator)||e.type===a&&We.includes(e.callee.name.toUpperCase())),Ye={};let Ge,Ke,Ve,Qe=!1,Je=!1;function et(e){const t=new Error(e);throw t.source=Ke.map((e=>e.value)).join(""),t.sourceOffset=Ke.slice(0,Ve).reduce(((e,t)=>e+t.value),"").length,t}function tt(){let e,t=Ve;do{e=Ke[++t]}while(e&&(Ze(e)||Pe(e)&&"("===e.value));return(e=>{const t=(e&&e.value)+"";return!(!ze(e)&&(!Pe(e)||":"!==t&&","!==t&&t.trim())&&(!qe(e)||!We.includes(t.toUpperCase()))&&(!je(e)||"#REF!"!==t))})(e)}function nt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e&&e!==Ge.id&&et(`Expected ${e} but got ${Ge.id}`),Ze(Ke[Ve])){if(!(He(t)&&tt()))for(;Ze(Ke[Ve]);)Ve++}if(Ve>=Ke.length)return void(Ge=Ye[Xe]);const n=Ke[Ve];let l;Ve+=1,n.unterminated&&et("Encountered an unterminated token");let r=n.type;return Pe(n)?(l=Ye[n.value],l||et(`Unknown operator ${n.value}`)):Ze(n)?l=Ye["(WHITESPACE)"]:De(n)?l=Ye.Literal:ze(n)?(l=Ye[i],r=i):qe(n)?l=Ye["(FUNCTION)"]:et(`Unexpected ${n.type} token: ${n.value}`),Ge=Object.create(l),Ge.type=r,Ge.value=n.value,n.loc&&(Ge.loc=[...n.loc]),Ge}function lt(e){let t=Ge;nt(null,t);let n=t.nud();for(;e<Ge.lbp;)t=Ge,nt(null,t),n=t.led(n);return n}const rt={nud:()=>et("Invalid syntax"),led:()=>et("Missing operator")};function ot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Ye[e];return n?t>=n.lbp&&(n.lbp=t):(n={...rt},n.id=e,n.value=e,n.lbp=t,Ye[e]=n),n}function ut(e,t,n){const l=ot(e,t);return l.led=n||function(e){this.type=c,this.operator=this.value,delete this.value;const n=lt(t);return this.arguments=[e,n],this.loc&&(this.loc=[e.loc[0],n.loc[1]]),this},l}function st(e,t){const n=ot(e,0);return n.lbp=70,n.led=t||function(e){return this.type=s,this.operator=this.value,delete this.value,this.arguments=[e],this.loc&&(this.loc[0]=e.loc[0]),this},n}function ct(e,t){const n=ot(e);return n.nud=t||function(){this.type=s,this.operator=this.value,delete this.value;const e=lt(70);return this.arguments=[e],this.loc&&(this.loc[1]=e.loc[1]),this},n}function it(e,t){return ut(e,t,(function(n){He(n)||et(`Unexpected ${e} operator`);const l=lt(t);return He(l)||et(`Unexpected ${Ge.type} following ${this.id}`),this.type=c,this.operator=this.value.trim()?this.value:" ",delete this.value,this.arguments=[n,l],this.loc&&(this.loc=[n.loc[0],l.loc[1]]),this}))}ot(Xe),it(":",80);const at=it(",",80);it("(WHITESPACE)",80);const ft=e=>{const t=at.lbp>0;return null!=e&&(at.lbp=e?80:0),t};function pt(){let e=1;return()=>"fxg"+e++}function ht(e,t){return null==e&&null==t||e===t}function gt(e,t){if(Array.isArray(e)!==Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!ht(e[n],t[n]))return!1;return!0}function xt(e,t){return!e&&!t||String(e).toLowerCase()===String(t).toLowerCase()}function dt(e,t){if((e.name||t.name)&&e.name!==t.name)return!1;if(e.columns||t.columns){if(e.table!==t.table)return!1;if(!gt(e.columns,t.columns))return!1;if(!gt(e.sections,t.sections))return!1}return!!(!e.range&&!t.range||ht(e.range.top,t.range.top)&&ht(e.range.bottom,t.range.bottom)&&ht(e.range.left,t.range.left)&&ht(e.range.right,t.range.right))&&!(!xt(e.workbookName,t.workbookName)||!xt(e.sheetName,t.sheetName))}function $t(e,t,n){return e.sheetName||(e.sheetName=t),e.workbookName||(e.workbookName=n),e}st("%"),st("#",(function(e){return He(e)||et("# expects a reference"),this.type=s,this.operator=this.value,delete this.value,this.arguments=[e],this})),ct("+"),ct("-"),ct("@"),ut("^",50),ut("*",40),ut("/",40),ut("+",30),ut("-",30),ut("&",20),ut("=",10),ut("<",10),ut(">",10),ut("<=",10),ut(">=",10),ut("<>",10),ot("Literal").nud=function(){const{type:e,value:n}=this;if(this.type="Literal",this.raw=n,"number"===e)this.value=+n;else if("bool"===e)this.value="TRUE"===n.toUpperCase();else if(e===t)this.type="ErrorLiteral",this.value=n.toUpperCase();else{if("string"!==e)throw new Error("Unsupported literal type: "+e);this.value=n.slice(1,-1).replace(/""/g,'"')}return this},ot(i).nud=function(){return this.type=i,this},ot(")"),ct("(",(function(){const e=ft(!0),t=lt(0);return nt(")",t),ft(e),t})),ot("(FUNCTION)").nud=function(){return this},ut("(",90,(function(e){"(FUNCTION)"!==e.id&&et("Cannot call a "+e.type);const t=[];let n=!1;if(")"!==Ge.id){const e=ft(!1);for(;")"!==Ge.id;)if(Ze(Ge)&&nt(),","===Ge.id)t.push(null),n=!0,nt();else{const e=lt(0);t.push(e),n=!1,","===Ge.id&&(nt(","),n=!0)}ft(e)}n&&t.push(null);const l=Ge;return delete this.value,this.type=a,this.callee={type:"Identifier",name:e.value},e.loc&&(this.callee.loc=[...e.loc]),this.arguments=t,e.loc&&(this.loc=[e.loc[0],l.loc[1]]),nt(")",this),this})),ot("}"),ot(";"),ct("{",(function(){"}"===Ge.id&&et("Unexpected empty array");let e=[],t=!1;const n=[e],l=ft(!1);for(;!t;){if(Ze(Ge)&&nt(),De(Ge))e.push(Ye.Literal.nud.call(Ge)),nt();else if(Qe&&He(Ge))e.push(Ye[i].nud.call(Ge)),nt();else if(Je&&qe(Ge)){const t=lt(0);e.push(t)}else et(`Unexpected ${Ge.type} in array: ${Ge.value}`);","===Ge.id?nt(","):";"===Ge.id?(nt(";"),e=[],n.push(e)):t=!0}const r=Ge;return nt("}"),ft(l),this.type="ArrayExpression",this.elements=n,this.loc&&(this.loc[1]=r.loc[1]),delete this.value,this}));const yt=(e,t,n)=>Math.min(Math.max(t,e),n);function mt(e,t){return t?String(e+1):e?"["+e+"]":""}function vt(e){let{r0:t,c0:n,r1:l,c1:r}=e;const{$c0:o,$c1:u,$r0:s,$r1:c}=e,i=null==t,a=null==n;let f=null==l,p=null==r;t=yt(s?0:-1048575,0|t,1048575),n=yt(o?0:-16383,0|n,16383),!i&&f&&!a&&p?(l=t,f=!1,r=n,p=!1):(l=yt(c?0:-1048575,0|l,1048575),r=yt(u?0:-16383,0|r,16383));if(0===t&&l>=1048575&&!a&&!p||i&&f){const e=mt(n,o),t=mt(r,u);return"C"+(e===t?e:e+":C"+t)}if(0===n&&r>=16383&&!i&&!f||a&&p){const e=mt(t,s),n=mt(l,c);return"R"+(e===n?e:e+":R"+n)}const h=mt(t,s),g=mt(l,c),x=mt(n,o),d=mt(r,u);return i||f||a||p?(i?"":"R"+h)+(a?"":"C"+x)+":"+(f?"":"R"+g)+(p?"":"C"+d):h!==g||x!==d?"R"+h+"C"+x+":R"+g+"C"+d:"R"+h+"C"+x}function Et(e){let t=null,n=null,l=null,r=null;const o=/^R(?:\[([+-]?\d+)\]|(\d+))?/.exec(e);o&&(o[1]?(t=parseInt(o[1],10),l=!1):o[2]?(t=parseInt(o[2],10)-1,l=!0):(t=0,l=!1),e=e.slice(o[0].length));const u=/^C(?:\[([+-]?\d+)\]|(\d+))?/.exec(e);return u&&(u[1]?(n=parseInt(u[1],10),r=!1):u[2]?(n=parseInt(u[2],10)-1,r=!0):(n=0,r=!1),e=e.slice(u[0].length)),!o&&!u||e.length?null:[t,n,l,r]}function Rt(e){let t=null;const[n,l]=e.split(":",2),r=Et(n);if(r){const[e,n,o,u]=r;if(!l)return null!=e&&null==n?{r0:e,c0:null,r1:e,c1:null,$r0:o,$c0:!1,$r1:o,$c1:!1}:null==e&&null!=n?{r0:null,c0:n,r1:null,c1:n,$r0:!1,$c0:u,$r1:!1,$c1:u}:{r0:e||0,c0:n||0,r1:e||0,c1:n||0,$r0:o||!1,$c0:u||!1,$r1:o||!1,$c1:u||!1};{const r=Et(l);if(!r)return null;{t={};const[l,s,c,i]=r;null!=e&&null!=l?(t.r0=o===c?Math.min(e,l):e,t.$r0=o,t.r1=o===c?Math.max(e,l):l,t.$r1=c):null!=e&&null==l?(t.r0=e,t.$r0=o,t.r1=null,t.$r1=o):null==e&&null!=l?(t.r0=l,t.$r0=c,t.r1=null,t.$r1=c):null==e&&null==l&&(t.r0=null,t.$r0=!1,t.r1=null,t.$r1=!1),null!=n&&null!=s?(t.c0=u===i?Math.min(n,s):n,t.$c0=u,t.c1=u===i?Math.max(n,s):s,t.$c1=i):null!=n&&null==s?(t.c0=n,t.$c0=u,t.c1=null,t.$c1=u):null==n&&null!=s?(t.c0=s,t.$c0=i,t.c1=null,t.$c1=i):null==n&&null==s&&(t.c0=null,t.$c0=!1,t.c1=null,t.$c1=!1)}}}return t}function wt(e){let{allowNamed:t=!0,allowTernary:n=!1,xlsx:l=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=b(e,{allowNamed:t,allowTernary:n,xlsx:l,r1c1:!0});if(r&&(r.r0||r.name)){const e=r.r1?Rt(r.r0+":"+r.r1):Rt(r.r0);return r.name||e?(r.range=e,delete r.r0,delete r.r1,r):null}return null}function Nt(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t?T(e):C(e);return n+(e.name?e.name:vt(e.range))}const bt=(e,t,n)=>null==t?null:e?t:t-n,At={withLocation:!1,mergeRefs:!1,allowTernary:!0,r1c1:!1};function Ct(e,t,n,l){let r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=e;if(null!=o&&!t){if(o=n+e,o<0){if(!r)return NaN;o=l+o+1}if(o>l){if(!r)return NaN;o-=l+1}}return o}const Tt={wrapEdges:!0,mergeRefs:!0,allowTernary:!0,xlsx:!1};const It=Object.freeze({OPERATOR:e,BOOLEAN:"bool",ERROR:t,NUMBER:"number",FUNCTION:"func",NEWLINE:"newline",WHITESPACE:"whitespace",STRING:"string",CONTEXT:"context",CONTEXT_QUOTE:"context_quote",REF_RANGE:"range",REF_BEAM:n,REF_TERNARY:l,REF_NAMED:r,REF_STRUCT:o,FX_PREFIX:"fx_prefix",UNKNOWN:u}),Lt=Object.freeze({UNARY:s,BINARY:c,REFERENCE:i,LITERAL:"Literal",ERROR:"ErrorLiteral",CALL:a,ARRAY:"ArrayExpression",IDENTIFIER:"Identifier"});exports.MAX_COLS=16383,exports.MAX_ROWS=1048575,exports.addA1RangeBounds=j,exports.addTokenMeta=function(e){let{sheetName:t="",workbookName:r=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=[];let c=null;const i=pt(),a=[],f=()=>s.length+(c?1:0);return e.forEach(((e,p)=>{if(e.index=p,e.depth=f(),"("===e.value)s.push(e),e.depth=f();else if(")"===e.value){const t=s.pop();if(t){const n=i();e.groupId=n,e.depth=t.depth,t.groupId=n}else e.error=!0}else if("{"===e.value)c?e.error=!0:(c=e,e.depth=f());else if("}"===e.value){if(c){const t=i();e.groupId=t,e.depth=c.depth,c.groupId=t}else e.error=!0;c=null}else if("range"===e.type||e.type===n||e.type===l||e.type===o){const n=e.type===o?Y(e.value,{allowTernary:!0,xlsx:!0}):z(e.value,{allowTernary:!0,xlsx:!0});if(n&&(n.range||n.columns)){n.source=e.value,$t(n,t,r);const l=a.find((e=>dt(e,n)));l?e.groupId=l.groupId:(n.groupId=i(),e.groupId=n.groupId,a.push(n))}}else e.type===u&&(e.error=!0)})),e},exports.fixRanges=function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{addBounds:!1};if("string"==typeof t)return e(Se(t,n),n).map((e=>e.value)).join("");if(!Array.isArray(t))throw new Error("fixRanges expects an array of tokens");const{addBounds:l,r1c1:r,xlsx:u}=n;if(r)throw new Error("fixRanges does not have an R1C1 mode");let s=0;return t.map((e=>{const t={...e};e.loc&&(t.loc=[...e.loc]);let n=0;if(t.type===o){const e=Q(Y(t.value,{xlsx:u}),{xlsx:u});n=e.length-t.value.length,t.value=e}else if(Me(t)){const e=z(t.value,{xlsx:u,allowTernary:!0}),r=e.range;l&&j(r);const o=D(e,{xlsx:u});n=o.length-t.value.length,t.value=o}return s||n?(t.loc&&(t.loc[0]+=s),s+=n,t.loc&&(t.loc[1]+=s)):s+=n,t}))},exports.fromCol=_,exports.isError=je,exports.isFunction=qe,exports.isFxPrefix=Be,exports.isLiteral=De,exports.isOperator=Pe,exports.isRange=Me,exports.isReference=ze,exports.isWhitespace=Ze,exports.mergeRefTokens=Le,exports.nodeTypes=Lt,exports.parse=function(e,t){if("string"==typeof e)Ke=Se(e,{withLocation:!1,...t,mergeRefs:!0});else{if(!Array.isArray(e))throw new Error("Parse requires a string or array of tokens.");Ke=e}for(Qe=t?.permitArrayRanges,Je=t?.permitArrayCalls,Ve=0;Ze(Ke[Ve])||Be(Ke[Ve]);)Ve++;nt(),ft(!0);const n=lt(0);return nt(Xe),n},exports.parseA1Ref=z,exports.parseR1C1Ref=wt,exports.parseStructRef=Y,exports.stringifyA1Ref=D,exports.stringifyR1C1Ref=Nt,exports.stringifyStructRef=Q,exports.toCol=U,exports.tokenTypes=It,exports.tokenize=Se,exports.translateToA1=function(e,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Tt;const r=M(n),o="string"==typeof e,u={...Tt,...l},s=o?Se(e,{withLocation:!1,mergeRefs:u.mergeRefs,xlsx:u.xlsx,allowTernary:u.allowTernary,r1c1:!0}):e;let c=0;const i={xlsx:u.xlsx,allowTernary:u.allowTernary};return s.forEach((e=>{if(Me(e)){const n=e.value,l=wt(n,i),o=l.range,s={},a=Ct(o.r0,o.$r0,r.top,1048575,u.wrapEdges),f=Ct(o.r1,o.$r1,r.top,1048575,u.wrapEdges);a>f?(s.top=f,s.$top=o.$r1,s.bottom=a,s.$bottom=o.$r0):(s.top=a,s.$top=o.$r0,s.bottom=f,s.$bottom=o.$r1);const p=Ct(o.c0,o.$c0,r.left,16383,u.wrapEdges),h=Ct(o.c1,o.$c1,r.left,16383,u.wrapEdges);p>h?(s.left=h,s.$left=o.$c1,s.right=p,s.$right=o.$c0):(s.left=p,s.$left=o.$c0,s.right=h,s.$right=o.$c1),isNaN(a)||isNaN(f)||isNaN(p)||isNaN(h)?(e.type=t,e.value="#REF!",delete e.groupId):(l.range=s,e.value=D(l,i)),e.loc&&(e.loc[0]+=c,c+=e.value.length-n.length,e.loc[1]+=c)}else c&&e.loc&&(e.loc[0]+=c,e.loc[1]+=c)})),o?s.map((e=>e.value)).join(""):s},exports.translateToR1C1=function(e,t){let{xlsx:n=!1,allowTernary:l=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{top:r,left:o}=M(t),u="string"==typeof e,s=u?Se(e,{...At,xlsx:n,allowTernary:l}):e;let c=0;const i={xlsx:n,allowTernary:l};return s.forEach((e=>{if(Me(e)){const t=e.value,n=z(t,i),l=n.range,u={};u.r0=bt(l.$top,l.top,r),u.r1=bt(l.$bottom,l.bottom,r),u.c0=bt(l.$left,l.left,o),u.c1=bt(l.$right,l.right,o),u.$r0=l.$top,u.$r1=l.$bottom,u.$c0=l.$left,u.$c1=l.$right,n.range=u,e.value=Nt(n,i),e.loc&&(e.loc[0]+=c,c+=e.value.length-t.length,e.loc[1]+=c)}else c&&e.loc&&(e.loc[0]+=c,e.loc[1]+=c)})),u?s.map((e=>e.value)).join(""):s};
|
|
1
|
+
"use strict";const e="operator",t="error",n="range_beam",l="range_ternary",r="range_named",o="structured",u="unknown",s="UnaryExpression",c="BinaryExpression",i="ReferenceIdentifier",a="CallExpression";function f(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!1,l="";const r=[],o=()=>{l&&r.push(t?l:{value:l,braced:n}),l=""};for(let t=0;t<e.length;t++){const r=e[t];"["===r?(o(),n=!0):"]"===r?(o(),n=!1):l+=r}return o(),r}function p(e){return{context:f(e,!0)}}function h(e){const t={},n=f(e);if(n.length>1)t.workbookName=n[n.length-2].value,t.sheetName=n[n.length-1].value;else if(1===n.length){const e=n[0];e.braced?t.workbookName=e.value:t.sheetName=e.value}return t}const g=e=>e&&":"===e.value&&{},x=e=>e&&"range"===e.type&&{r0:e.value},d=e=>e&&e.type===l&&{r0:e.value},$=e=>e&&"range"===e.type&&{r1:e.value},y=t=>t&&t.type===e&&"!"===t.value&&{},m=e=>e&&e.type===n&&{r0:e.value},v=e=>e&&e.type===o&&{struct:e.value},E=(e,t)=>{const n=t.xlsx?h:p;return e&&"context"===e.type?n(e.value):e&&"context_quote"===e.type?n(e.value.slice(1,-1).replace(/''/g,"'")):void 0},R=e=>e&&e.type===r&&{name:e.value},w=[[d],[x,g,$],[x],[m],[E,y,d],[E,y,x,g,$],[E,y,x],[E,y,m]],N=w.concat([[R],[E,y,R],[v],[R,v],[E,y,R,v]]);function b(e,t){const n={withLocation:!1,mergeRefs:!1,allowTernary:!1,allowNamed:!0,r1c1:!1,xlsx:!1,...t},l=Fe(e,Ae,n),r=n.xlsx?{workbookName:"",sheetName:"",r0:"",r1:"",name:""}:{context:[],r0:"",r1:"",name:""};l.length&&"fx_prefix"===l[0].type&&l.shift();const o=n.allowNamed?N:w;for(let e=0;e<o.length;e++){const t={...r};if(o[e].length===l.length){const r=o[e].every(((e,r)=>{const o=e(l[r],n);return Object.assign(t,o),o}));if(r)return t}}return null}const A=/[^0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]/;function C(e){let t="",n=0,l=0;const r=e.context||[];for(let e=r.length;e>-1;e--){const o=r[e];if(o){t=(l%2?"["+o+"]":o)+t,n+=A.test(o),l++}}return n&&(t="'"+t.replace(/'/g,"''")+"'"),t?t+"!":t}function T(e){let t="",n=0;const{workbookName:l,sheetName:r}=e;return l&&(t+="["+l+"]",n+=A.test(l)),r&&(t+=r,n+=A.test(r)),n&&(t="'"+t.replace(/'/g,"''")+"'"),t?t+"!":t}const I=(e,t,n)=>Math.min(Math.max(t,e),n),L=(e,t)=>(t?"$":"")+U(e),k=(e,t)=>(t?"$":"")+String(e+1),O=String.fromCharCode;function _(e){const t=e||"",n=t.length;let l=0;if(n>2){const e=t.charCodeAt(n-3);l+=676*(1+e-(e>95?32:0)-65)}if(n>1){const e=t.charCodeAt(n-2);l+=26*(1+e-(e>95?32:0)-65)}if(n){const e=t.charCodeAt(n-1);l+=e-(e>95?32:0)-65}return l}function U(e){return(e>=702?O(((e-702)/676-0)%26+65):"")+(e>=26?O((e/26-1)%26+65):"")+O(e%26+65)}function F(e){let{top:t,left:n,bottom:l,right:r}=e;const{$left:o,$right:u,$top:s,$bottom:c}=e,i=null==n,a=null==r,f=null==t,p=null==l;t=I(0,0|t,1048575),n=I(0,0|n,16383),!i&&!f&&a&&p?(l=t,r=n):(l=I(0,0|l,1048575),r=I(0,0|r,16383));if(0===t&&l>=1048575&&!i&&!a&&(!(o&&!i||u&&!a)||n===r)||f&&p)return L(n,o)+":"+L(r,u);return 0===n&&r>=16383&&!f&&!p&&(!(s&&!f||c&&!p)||t===l)||i&&a?k(t,s)+":"+k(l,c):i||f||a||!p?i||!f||a||p?i||f||!a||p?!i||f||a||p?r!==n||l!==t||u!==o||c!==s?L(n,o)+k(t,s)+":"+L(r,u)+k(l,c):L(n,o)+k(t,s):L(r,u)+k(t,s)+":"+k(l,c):L(n,o)+k(t,s)+":"+k(l,c):L(n,o)+k(l,c)+":"+L(r,u):L(n,o)+k(t,s)+":"+L(r,u)}function S(e){const t=/^(?=.)(\$(?=\D))?([A-Za-z]{0,3})?(\$)?([1-9][0-9]{0,6})?$/.exec(e);return t&&(t[2]||t[4])?[t[4]?(n=t[4],+n-1):null,t[2]?_(t[2]):null,!!t[3],!!t[1]]:null;var n}function M(e){let t=null,n=null,l=null,r=null,o=!1,u=!1,s=!1,c=!1;const[i,a,f]=e.split(":");if(f)return null;const p=S(i),h=a?S(a):null;if(!p||a&&!h)return null;if(null!=p[0]&&null!=p[1]?[t,n,o,u]=p:null==p[0]&&null!=p[1]?[,n,,u]=p:null!=p[0]&&null==p[1]&&([t,,o]=p),a)null!=h[0]&&null!=h[1]?[l,r,s,c]=h:null==h[0]&&null!=h[1]?[,r,,c]=h:null!=h[0]&&null==h[1]&&([l,,s]=h);else{if(null==t||null==n)return null;l=t,r=n,s=o,c=u}return null!=r&&(null==n||null!=n&&r<n)&&([n,r,u,c]=[r,n,c,u]),null!=l&&(null==t||null!=t&&l<t)&&([t,l,o,s]=[l,t,s,o]),{top:t,left:n,bottom:l,right:r,$top:o,$left:u,$bottom:s,$right:c}}function z(e){let{allowNamed:t=!0,allowTernary:n=!1,xlsx:l=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=b(e,{allowNamed:t,allowTernary:n,xlsx:l,r1c1:!1});if(r&&(r.r0||r.name)){let e=null;return r.r0&&(e=M(r.r1?r.r0+":"+r.r1:r.r0)),r.name||e?(r.range=e,delete r.r0,delete r.r1,r):null}return null}function D(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t?T(e):C(e);return n+(e.name?e.name:F(e.range))}function j(e){return null==e.top&&(e.top=0,e.$top=!1),null==e.bottom&&(e.bottom=1048575,e.$bottom=!1),null==e.left&&(e.left=0,e.$left=!1),null==e.right&&(e.right=16383,e.$right=!1),e}const Z=/^\[('['#@[\]]|[^'#@[\]])+\]/i,q=/^([^#@[\]:]+)/i,B={headers:1,data:2,totals:4,all:8,"this row":16,"@":16},P=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Object.freeze(t)},X={0:P(),1:P("headers"),2:P("data"),4:P("totals"),8:P("all"),16:P("this row"),3:P("headers","data"),6:P("data","totals")},W=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=Z.exec(e);if(n){const e=n[0].slice(1,-1).replace(/'(['#@[\]])/g,"$1");return[n[0],e]}return t&&(n=q.exec(e),n)?[n[0],n[0]]:null};function H(e){const t=[];let n,l,r=0,o=e,u=0;if(!(n=/^(\[\s*)/.exec(o)))return null;if(l=/^\[#([a-z ]+)\]/i.exec(o)){const e=l[1].toLowerCase();if(r+=l[0].length,!B[e])return null;u|=B[e]}else if(l=W(o,!1))r+=l[0].length,t.push(l[1]);else{let l=!0;for(o=o.slice(n[1].length),r+=n[1].length;l&&(n=/^\[#([a-z ]+)\](\s*,\s*)?/i.exec(o));){const e=n[1].toLowerCase();if(!B[e])return null;u|=B[e],o=o.slice(n[0].length),r+=n[0].length,l=!!n[2]}if(l&&(n=/^@/.exec(o))&&(u|=B["@"],o=o.slice(1),r+=1,l="]"!==o[0]),!(u in X))return null;const s=l?W(e.slice(r)):null;if(s){if(r+=s[0].length,t.push(s[1]),o=e.slice(r),":"===o[0]){o=o.slice(1),r++;const e=W(o);if(!e)return null;r+=e[0].length,t.push(e[1])}l=!1}for(;" "===e[r];)r++;if(l||"]"!==e[r])return null;r++}const s=X[u];return{columns:t,sections:s?s.concat():s,length:r,token:e.slice(0,r)}}function Y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{xlsx:!1};const n=b(e,t);if(n&&n.struct){const e=H(n.struct);if(e&&e.length===n.struct.length)return t.xlsx?{workbookName:n.workbookName,sheetName:n.sheetName,table:n.name,columns:e.columns,sections:e.sections}:{context:n.context,table:n.name,columns:e.columns,sections:e.sections}}return null}function G(e){return e.replace(/([[\]#'@])/g,"'$1")}function K(e){return!/^[a-zA-Z0-9\u00a1-\uffff]+$/.test(e)}function V(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Q(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t?T(e):C(e);e.table&&(n+=e.table);const l=e.columns?.length??0,r=e.sections?.length??0;if(1!==r||l)if(r||1!==l){n+="[";const t=1===r&&"this row"===e.sections[0].toLowerCase();t?n+="@":r&&(n+=e.sections.map((e=>`[#${V(e)}]`)).join(","),l&&(n+=",")),t&&1===e.columns.length&&!K(e.columns[0])?n+=G(e.columns[0]):l&&(n+=e.columns.slice(0,2).map((e=>`[${G(e)}]`)).join(":")),n+="]"}else n+=`[${G(e.columns[0])}]`;else n+=`[#${V(e.sections[0])}]`;return n}const J=/^(?!!)(\[(?:[^\]])+\])?([0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]+)?(?=!)/,ee=/^'(?:''|[^'])*('|$)(?=!)/,te="\\$?[A-Z]{1,3}\\$?[1-9][0-9]{0,6}",ne="\\$?[A-Z]{1,3}",le="\\$?[1-9][0-9]{0,6}",re="(?![a-z0-9_\\u00a1-\\uffff])",oe=new RegExp(`^${ne}:${ne}${re}`,"i"),ue=new RegExp(`^${le}:${le}${re}`,"i"),se=new RegExp(`^${te}${re}`,"i"),ce=new RegExp(`^((${ne}|${le}):${te}|${te}:(${ne}|${le}))(?![\\w($.])`,"i"),ie="(?:R(?:\\[[+-]?\\d+\\]|[1-9][0-9]{0,6})?)",ae="(?:C(?:\\[[+-]?\\d+\\]|[1-9][0-9]{0,4})?)",fe=new RegExp(`^${ae}(:${ae})?${re}`,"i"),pe=new RegExp(`^${ie}(:${ie})?${re}`,"i"),he=new RegExp(`^(?:(?=[RC])${ie}${ae})${re}`,"i"),ge=new RegExp(`^(${ie}${ae}(:${ae}|:${ie})(?![[\\d])|(${ie}|${ae})(:${ie}${ae}))${re}`,"i"),xe=/^[a-zA-Z\\_\u00a1-\uffff][a-zA-Z0-9\\_.?\u00a1-\uffff]{0,254}/i;function de(e,t){return n=>{const l=t.exec(n);if(l)return{type:e,value:l[0]}}}function $e(e){const t=xe.exec(e);if(t){const e=t[0].toLowerCase();return"r"===e||"c"===e?null:{type:r,value:t[0]}}}const ye=/^'(?:[^[\]]+?)?(?:\[(.+?)\])?(?:[^[\]]+?)'$/,me=/^'\[(.+?)\]'$/;function ve(e,t){const n=ee.exec(e);if(n){const e=n[0];if(t.xlsx&&me.test(e)||ye.test(e))return{type:"context_quote",value:e}}const l=J.exec(e);if(l){const[,e,n]=l;if(e&&n||n||e&&!n&&t.xlsx)return{type:"context",value:l[0]}}}function Ee(e){const t=H(e);if(t){let n=t.length;for(;" "===e[n];)n++;if("!"!==e[n])return{type:o,value:t.token}}return null}const Re=/([RC])(\[?)(-?\d+)/gi,we=/(\d+|[a-zA-Z]+)/gi;function Ne(e,t){let r,o;if(t.r1c1){if(t.allowTernary&&(r=ge.exec(e))?o={type:l,value:r[0]}:(r=he.exec(e))?o={type:"range",value:r[0]}:((r=pe.exec(e))||(r=fe.exec(e)))&&(o={type:n,value:r[0]}),o){for(Re.lastIndex=0;null!==(r=Re.exec(o.value));){const e=("R"===r[1]?1048575:16383)+(r[2]?0:1),t=parseInt(r[3],10);if(t>e||t<-e)return null}return o}}else if(t.allowTernary&&(r=ce.exec(e))?o={type:l,value:r[0]}:(r=oe.exec(e))||(r=ue.exec(e))?o={type:n,value:r[0]}:(r=se.exec(e))&&(o={type:"range",value:r[0]}),o){for(we.lastIndex=0;null!==(r=we.exec(o.value));)if(/^\d/.test(r[1])){if(parseInt(r[1],10)-1>1048575)return null}else if(_(r[1])>16383)return null;return o}}const be=[de(t,/^#(NAME\?|FIELD!|CALC!|VALUE!|REF!|DIV\/0!|NULL!|NUM!|N\/A|GETTING_DATA\b|SPILL!|UNKNOWN!|FIELD\b|CALC\b|SYNTAX\?|ERROR!|CONNECT!|BLOCKED!|EXTERNAL!)/i),de(e,/^(<=|>=|<>|[-+/*^%&<>=]|[{},;]|[()]|@|:|!|#)/),de("func",/^[A-Z_]+[A-Z\d_.]*(?=\()/i),de("bool",/^(TRUE|FALSE)\b/i),de("newline",/^\n+/),de("whitespace",/^[ \f\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/),de("string",/^"(?:""|[^"])*("|$)/),ve,Ne,Ee,de("number",/^(?:\d+(\.\d+)?(?:[eE][+-]?\d+)?|\d+)/),$e],Ae=[function(t,n){return n.r1c1?"!"===t[0]?{type:e,value:t[0]}:null:"!"===t[0]||":"===t[0]?{type:e,value:t[0]}:null},ve,Ne,Ee,$e],Ce={};function Te(e,t){if(e.length){const n=e[0];t[n]=t[n]||{},Te(e.slice(1),t[n])}else t.$=!0}[["range",":","range"],["range"],[n],[l],["context","!","range",":","range"],["context","!","range"],["context","!",n],["context","!",l],["context_quote","!","range",":","range"],["context_quote","!","range"],["context_quote","!",n],["context_quote","!",l],[r],["context","!",r],["context_quote","!",r],[o],[r,o],["context","!",r,o],["context_quote","!",r,o]].forEach((e=>Te(e.concat().reverse(),Ce)));const Ie=function(t,n,l){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const o=t[l-r];if(o){const u=o.type===e?o.value:o.type;if(u in n)return Ie(t,n[u],l,r+1)}return n.$?r:0};function Le(e){const t=[];for(let n=e.length-1;n>=0;n--){let l=e[n];const r=Ie(e,Ce,n);if(r){const t=e.slice(n-r+1,n+1);l={...l},l.value=t.map((e=>e.value)).join(""),l.loc&&t[0].loc&&(l.loc[0]=t[0].loc[0]),n-=r-1}t.unshift(l)}return t}const ke=(e,t)=>e&&e.type===t,Oe={withLocation:!1,mergeRefs:!0,allowTernary:!1,negativeNumbers:!0,r1c1:!1},_e=e=>e.type===r||"func"===e.type,Ue=t=>!ke(t,e)||"%"===t.value||"}"===t.value||")"===t.value||"#"===t.value;function Fe(t,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=Object.assign({},Oe,l),{withLocation:o,mergeRefs:s,negativeNumbers:c}=r,i=[];let a=0,f=null,p=null,h=null;const g=e=>{const t=e.type===u,n=h&&h.type===u;h&&(t&&n||t&&_e(h)||n&&_e(e))?(h.value+=e.value,h.type=u,o&&(h.loc[1]=e.loc[1])):(i.push(e),h=e,"whitespace"!==e.type&&"newline"!==e.type&&(p=f,f=e))};if(/^=/.test(t)){a++,g({type:"fx_prefix",value:"=",...o?{loc:[0,1]}:{}})}for(;a<t.length;){const l=a,s=t.slice(a);let x="",d="";for(let e=0;e<n.length;e++){const t=n[e](s,r);if(t){x=t.type,d=t.value,a+=d.length;break}}x||(x=u,d=t[a],a++);const $={type:x,value:d,...o?{loc:[l,a]}:{}};if("string"===x){const e=d.length;if('""'===d);else if('"'===d||'"'!==d[e-1])$.unterminated=!0;else if('""'!==d&&'"'===d[e-2]){let t=e-1;for(;'"'===d[t];)t--;!(t+1)^(e-t+1)%2==0&&($.unterminated=!0)}}if(c&&"number"===x){const t=h;if(t&&ke(t,e)&&"-"===t.value&&(!p||ke(p,"fx_prefix")||!Ue(p))){const e=i.pop();$.value="-"+d,o&&($.loc[0]=e.loc[0]),f=p,h=i[i.length-1]}}g($)}return s?Le(i):i}function Se(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Fe(e,be,t)}function Me(e){return!!e&&("range"===e.type||e.type===n||e.type===l)}function ze(e){return!!e&&("range"===e.type||e.type===n||e.type===l||e.type===o||e.type===r)}function De(e){return!!e&&("bool"===e.type||e.type===t||"number"===e.type||"string"===e.type)}function je(e){return!!e&&e.type===t}function Ze(e){return!!e&&("whitespace"===e.type||"newline"===e.type)}function qe(e){return!!e&&"func"===e.type}function Be(e){return!!e&&"fx_prefix"===e.type}function Pe(t){return!!t&&t.type===e}const Xe="(END)",We=["ANCHORARRAY","CHOOSE","DROP","IF","IFS","INDEX","INDIRECT","LAMBDA","LET","OFFSET","REDUCE","SINGLE","SWITCH","TAKE","XLOOKUP"],He=e=>!!e&&(e.type===i||("ErrorLiteral"===e.type||e.type===t)&&"#REF!"===e.value||e.type===c&&(":"===e.operator||" "===e.operator||","===e.operator)||e.type===a&&We.includes(e.callee.name.toUpperCase())),Ye={};let Ge,Ke,Ve,Qe=!1,Je=!1;function et(e){const t=new Error(e);throw t.source=Ke.map((e=>e.value)).join(""),t.sourceOffset=Ke.slice(0,Ve).reduce(((e,t)=>e+t.value),"").length,t}function tt(){let e,t=Ve;do{e=Ke[++t]}while(e&&(Ze(e)||Pe(e)&&"("===e.value));return(e=>{const t=(e&&e.value)+"";return!(!ze(e)&&(!Pe(e)||":"!==t&&","!==t&&t.trim())&&(!qe(e)||!We.includes(t.toUpperCase()))&&(!je(e)||"#REF!"!==t))})(e)}function nt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e&&e!==Ge.id&&et(`Expected ${e} but got ${Ge.id}`),Ze(Ke[Ve])){if(!(He(t)&&tt()))for(;Ze(Ke[Ve]);)Ve++}if(Ve>=Ke.length)return void(Ge=Ye[Xe]);const n=Ke[Ve];let l;Ve+=1,n.unterminated&&et("Encountered an unterminated token");let r=n.type;return Pe(n)?(l=Ye[n.value],l||et(`Unknown operator ${n.value}`)):Ze(n)?l=Ye["(WHITESPACE)"]:De(n)?l=Ye.Literal:ze(n)?(l=Ye[i],r=i):qe(n)?l=Ye["(FUNCTION)"]:et(`Unexpected ${n.type} token: ${n.value}`),Ge=Object.create(l),Ge.type=r,Ge.value=n.value,n.loc&&(Ge.loc=[...n.loc]),Ge}function lt(e){let t=Ge;nt(null,t);let n=t.nud();for(;e<Ge.lbp;)t=Ge,nt(null,t),n=t.led(n);return n}const rt={nud:()=>et("Invalid syntax"),led:()=>et("Missing operator")};function ot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Ye[e];return n?t>=n.lbp&&(n.lbp=t):(n={...rt},n.id=e,n.value=e,n.lbp=t,Ye[e]=n),n}function ut(e,t,n){const l=ot(e,t);return l.led=n||function(e){this.type=c,this.operator=this.value,delete this.value;const n=lt(t);return this.arguments=[e,n],this.loc&&(this.loc=[e.loc[0],n.loc[1]]),this},l}function st(e,t){const n=ot(e,0);return n.lbp=70,n.led=t||function(e){return this.type=s,this.operator=this.value,delete this.value,this.arguments=[e],this.loc&&(this.loc[0]=e.loc[0]),this},n}function ct(e,t){const n=ot(e);return n.nud=t||function(){this.type=s,this.operator=this.value,delete this.value;const e=lt(70);return this.arguments=[e],this.loc&&(this.loc[1]=e.loc[1]),this},n}function it(e,t){return ut(e,t,(function(n){He(n)||et(`Unexpected ${e} operator`);const l=lt(t);return He(l)||et(`Unexpected ${Ge.type} following ${this.id}`),this.type=c,this.operator=this.value.trim()?this.value:" ",delete this.value,this.arguments=[n,l],this.loc&&(this.loc=[n.loc[0],l.loc[1]]),this}))}ot(Xe),it(":",80);const at=it(",",80);it("(WHITESPACE)",80);const ft=e=>{const t=at.lbp>0;return null!=e&&(at.lbp=e?80:0),t};function pt(){let e=1;return()=>"fxg"+e++}function ht(e,t){return null==e&&null==t||e===t}function gt(e,t){if(Array.isArray(e)!==Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!ht(e[n],t[n]))return!1;return!0}function xt(e,t){return!e&&!t||String(e).toLowerCase()===String(t).toLowerCase()}function dt(e,t){if((e.name||t.name)&&e.name!==t.name)return!1;if(e.columns||t.columns){if(e.table!==t.table)return!1;if(!gt(e.columns,t.columns))return!1;if(!gt(e.sections,t.sections))return!1}return!!(!e.range&&!t.range||ht(e.range.top,t.range.top)&&ht(e.range.bottom,t.range.bottom)&&ht(e.range.left,t.range.left)&&ht(e.range.right,t.range.right))&&!(!xt(e.workbookName,t.workbookName)||!xt(e.sheetName,t.sheetName))}function $t(e,t,n){return e.sheetName||(e.sheetName=t),e.workbookName||(e.workbookName=n),e}st("%"),st("#",(function(e){return He(e)||et("# expects a reference"),this.type=s,this.operator=this.value,delete this.value,this.arguments=[e],this})),ct("+"),ct("-"),ct("@"),ut("^",50),ut("*",40),ut("/",40),ut("+",30),ut("-",30),ut("&",20),ut("=",10),ut("<",10),ut(">",10),ut("<=",10),ut(">=",10),ut("<>",10),ot("Literal").nud=function(){const{type:e,value:n}=this;if(this.type="Literal",this.raw=n,"number"===e)this.value=+n;else if("bool"===e)this.value="TRUE"===n.toUpperCase();else if(e===t)this.type="ErrorLiteral",this.value=n.toUpperCase();else{if("string"!==e)throw new Error("Unsupported literal type: "+e);this.value=n.slice(1,-1).replace(/""/g,'"')}return this},ot(i).nud=function(){return this.type=i,this},ot(")"),ct("(",(function(){const e=ft(!0),t=lt(0);return nt(")",t),ft(e),t})),ot("(FUNCTION)").nud=function(){return this},ut("(",90,(function(e){"(FUNCTION)"!==e.id&&et("Cannot call a "+e.type);const t=[];let n=!1;if(")"!==Ge.id){const e=ft(!1);for(;")"!==Ge.id;)if(Ze(Ge)&&nt(),","===Ge.id)t.push(null),n=!0,nt();else{const e=lt(0);t.push(e),n=!1,","===Ge.id&&(nt(","),n=!0)}ft(e)}n&&t.push(null);const l=Ge;return delete this.value,this.type=a,this.callee={type:"Identifier",name:e.value},e.loc&&(this.callee.loc=[...e.loc]),this.arguments=t,e.loc&&(this.loc=[e.loc[0],l.loc[1]]),nt(")",this),this})),ot("}"),ot(";"),ct("{",(function(){"}"===Ge.id&&et("Unexpected empty array");let e=[],t=!1;const n=[e],l=ft(!1);for(;!t;){if(Ze(Ge)&&nt(),De(Ge))e.push(Ye.Literal.nud.call(Ge)),nt();else if(Qe&&He(Ge))e.push(Ye[i].nud.call(Ge)),nt();else if(Je&&qe(Ge)){const t=lt(0);e.push(t)}else et(`Unexpected ${Ge.type} in array: ${Ge.value}`);","===Ge.id?nt(","):";"===Ge.id?(nt(";"),e=[],n.push(e)):t=!0}const r=Ge;return nt("}"),ft(l),this.type="ArrayExpression",this.elements=n,this.loc&&(this.loc[1]=r.loc[1]),delete this.value,this}));const yt=(e,t,n)=>Math.min(Math.max(t,e),n);function mt(e,t){return t?String(e+1):e?"["+e+"]":""}function vt(e){let{r0:t,c0:n,r1:l,c1:r}=e;const{$c0:o,$c1:u,$r0:s,$r1:c}=e,i=null==t,a=null==n;let f=null==l,p=null==r;t=yt(s?0:-1048575,0|t,1048575),n=yt(o?0:-16383,0|n,16383),!i&&f&&!a&&p?(l=t,f=!1,r=n,p=!1):(l=yt(c?0:-1048575,0|l,1048575),r=yt(u?0:-16383,0|r,16383));if(0===t&&l>=1048575&&!a&&!p||i&&f){const e=mt(n,o),t=mt(r,u);return"C"+(e===t?e:e+":C"+t)}if(0===n&&r>=16383&&!i&&!f||a&&p){const e=mt(t,s),n=mt(l,c);return"R"+(e===n?e:e+":R"+n)}const h=mt(t,s),g=mt(l,c),x=mt(n,o),d=mt(r,u);return i||f||a||p?(i?"":"R"+h)+(a?"":"C"+x)+":"+(f?"":"R"+g)+(p?"":"C"+d):h!==g||x!==d?"R"+h+"C"+x+":R"+g+"C"+d:"R"+h+"C"+x}function Et(e){let t=null,n=null,l=null,r=null;const o=/^R(?:\[([+-]?\d+)\]|(\d+))?/.exec(e);o&&(o[1]?(t=parseInt(o[1],10),l=!1):o[2]?(t=parseInt(o[2],10)-1,l=!0):(t=0,l=!1),e=e.slice(o[0].length));const u=/^C(?:\[([+-]?\d+)\]|(\d+))?/.exec(e);return u&&(u[1]?(n=parseInt(u[1],10),r=!1):u[2]?(n=parseInt(u[2],10)-1,r=!0):(n=0,r=!1),e=e.slice(u[0].length)),!o&&!u||e.length?null:[t,n,l,r]}function Rt(e){let t=null;const[n,l]=e.split(":",2),r=Et(n);if(r){const[e,n,o,u]=r;if(!l)return null!=e&&null==n?{r0:e,c0:null,r1:e,c1:null,$r0:o,$c0:!1,$r1:o,$c1:!1}:null==e&&null!=n?{r0:null,c0:n,r1:null,c1:n,$r0:!1,$c0:u,$r1:!1,$c1:u}:{r0:e||0,c0:n||0,r1:e||0,c1:n||0,$r0:o||!1,$c0:u||!1,$r1:o||!1,$c1:u||!1};{const r=Et(l);if(!r)return null;{t={};const[l,s,c,i]=r;null!=e&&null!=l?(t.r0=o===c?Math.min(e,l):e,t.$r0=o,t.r1=o===c?Math.max(e,l):l,t.$r1=c):null!=e&&null==l?(t.r0=e,t.$r0=o,t.r1=null,t.$r1=o):null==e&&null!=l?(t.r0=l,t.$r0=c,t.r1=null,t.$r1=c):null==e&&null==l&&(t.r0=null,t.$r0=!1,t.r1=null,t.$r1=!1),null!=n&&null!=s?(t.c0=u===i?Math.min(n,s):n,t.$c0=u,t.c1=u===i?Math.max(n,s):s,t.$c1=i):null!=n&&null==s?(t.c0=n,t.$c0=u,t.c1=null,t.$c1=u):null==n&&null!=s?(t.c0=s,t.$c0=i,t.c1=null,t.$c1=i):null==n&&null==s&&(t.c0=null,t.$c0=!1,t.c1=null,t.$c1=!1)}}}return t}function wt(e){let{allowNamed:t=!0,allowTernary:n=!1,xlsx:l=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=b(e,{allowNamed:t,allowTernary:n,xlsx:l,r1c1:!0});if(r&&(r.r0||r.name)){const e=r.r1?Rt(r.r0+":"+r.r1):Rt(r.r0);return r.name||e?(r.range=e,delete r.r0,delete r.r1,r):null}return null}function Nt(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t?T(e):C(e);return n+(e.name?e.name:vt(e.range))}const bt=(e,t,n)=>null==t?null:e?t:t-n,At={withLocation:!1,mergeRefs:!1,allowTernary:!0,r1c1:!1};function Ct(e,t,n,l){let r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=e;if(null!=o&&!t){if(o=n+e,o<0){if(!r)return NaN;o=l+o+1}if(o>l){if(!r)return NaN;o-=l+1}}return o}const Tt={wrapEdges:!0,mergeRefs:!0,allowTernary:!0,xlsx:!1};const It=Object.freeze({OPERATOR:e,BOOLEAN:"bool",ERROR:t,NUMBER:"number",FUNCTION:"func",NEWLINE:"newline",WHITESPACE:"whitespace",STRING:"string",CONTEXT:"context",CONTEXT_QUOTE:"context_quote",REF_RANGE:"range",REF_BEAM:n,REF_TERNARY:l,REF_NAMED:r,REF_STRUCT:o,FX_PREFIX:"fx_prefix",UNKNOWN:u}),Lt=Object.freeze({UNARY:s,BINARY:c,REFERENCE:i,LITERAL:"Literal",ERROR:"ErrorLiteral",CALL:a,ARRAY:"ArrayExpression",IDENTIFIER:"Identifier"});exports.MAX_COLS=16383,exports.MAX_ROWS=1048575,exports.addA1RangeBounds=j,exports.addTokenMeta=function(e){let{sheetName:t="",workbookName:r=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=[];let c=null;const i=pt(),a=[],f=()=>s.length+(c?1:0);return e.forEach(((e,p)=>{if(e.index=p,e.depth=f(),"("===e.value)s.push(e),e.depth=f();else if(")"===e.value){const t=s.pop();if(t){const n=i();e.groupId=n,e.depth=t.depth,t.groupId=n}else e.error=!0}else if("{"===e.value)c?e.error=!0:(c=e,e.depth=f());else if("}"===e.value){if(c){const t=i();e.groupId=t,e.depth=c.depth,c.groupId=t}else e.error=!0;c=null}else if("range"===e.type||e.type===n||e.type===l||e.type===o){const n=e.type===o?Y(e.value,{allowTernary:!0,xlsx:!0}):z(e.value,{allowTernary:!0,xlsx:!0});if(n&&(n.range||n.columns)){n.source=e.value,$t(n,t,r);const l=a.find((e=>dt(e,n)));l?e.groupId=l.groupId:(n.groupId=i(),e.groupId=n.groupId,a.push(n))}}else e.type===u&&(e.error=!0)})),e},exports.fixRanges=function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{addBounds:!1};if("string"==typeof t)return e(Se(t,n),n).map((e=>e.value)).join("");if(!Array.isArray(t))throw new Error("fixRanges expects an array of tokens");const{addBounds:l,r1c1:r,xlsx:u}=n;if(r)throw new Error("fixRanges does not have an R1C1 mode");let s=0;return t.map((e=>{const t={...e};e.loc&&(t.loc=[...e.loc]);let n=0;if(t.type===o){const e=Q(Y(t.value,{xlsx:u}),{xlsx:u});n=e.length-t.value.length,t.value=e}else if(Me(t)){const e=z(t.value,{xlsx:u,allowTernary:!0}),r=e.range;l&&j(r);const o=D(e,{xlsx:u});n=o.length-t.value.length,t.value=o}return s||n?(t.loc&&(t.loc[0]+=s),s+=n,t.loc&&(t.loc[1]+=s)):s+=n,t}))},exports.fromCol=_,exports.isError=je,exports.isFunction=qe,exports.isFxPrefix=Be,exports.isLiteral=De,exports.isOperator=Pe,exports.isRange=Me,exports.isReference=ze,exports.isWhitespace=Ze,exports.mergeRefTokens=Le,exports.nodeTypes=Lt,exports.parse=function(e,t){if("string"==typeof e)Ke=Se(e,{withLocation:!1,...t,mergeRefs:!0});else{if(!Array.isArray(e))throw new Error("Parse requires a string or array of tokens.");Ke=e}for(Qe=t?.permitArrayRanges,Je=t?.permitArrayCalls,Ve=0;Ze(Ke[Ve])||Be(Ke[Ve]);)Ve++;nt(),ft(!0);const n=lt(0);return nt(Xe),n},exports.parseA1Ref=z,exports.parseR1C1Ref=wt,exports.parseStructRef=Y,exports.stringifyA1Ref=D,exports.stringifyR1C1Ref=Nt,exports.stringifyStructRef=Q,exports.toCol=U,exports.tokenTypes=It,exports.tokenize=Se,exports.translateToA1=function(e,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Tt;const r=M(n),o="string"==typeof e,u={...Tt,...l},s=o?Se(e,{withLocation:!1,mergeRefs:u.mergeRefs,xlsx:u.xlsx,allowTernary:u.allowTernary,r1c1:!0}):e;let c=0;const i={xlsx:u.xlsx,allowTernary:u.allowTernary};return s.forEach((e=>{if(Me(e)){const n=e.value,l=wt(n,i),o=l.range,s={},a=Ct(o.r0,o.$r0,r.top,1048575,u.wrapEdges),f=Ct(o.r1,o.$r1,r.top,1048575,u.wrapEdges);a>f?(s.top=f,s.$top=o.$r1,s.bottom=a,s.$bottom=o.$r0):(s.top=a,s.$top=o.$r0,s.bottom=f,s.$bottom=o.$r1);const p=Ct(o.c0,o.$c0,r.left,16383,u.wrapEdges),h=Ct(o.c1,o.$c1,r.left,16383,u.wrapEdges);p>h?(s.left=h,s.$left=o.$c1,s.right=p,s.$right=o.$c0):(s.left=p,s.$left=o.$c0,s.right=h,s.$right=o.$c1),isNaN(a)||isNaN(f)||isNaN(p)||isNaN(h)?(e.type=t,e.value="#REF!",delete e.groupId):(l.range=s,e.value=D(l,i)),e.loc&&(e.loc[0]+=c,c+=e.value.length-n.length,e.loc[1]+=c)}else c&&e.loc&&(e.loc[0]+=c,e.loc[1]+=c)})),o?s.map((e=>e.value)).join(""):s},exports.translateToR1C1=function(e,t){let{xlsx:n=!1,allowTernary:l=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{top:r,left:o}=M(t),u="string"==typeof e,s=u?Se(e,{...At,xlsx:n,allowTernary:l}):e;let c=0;const i={xlsx:n,allowTernary:l};return s.forEach((e=>{if(Me(e)){const t=e.value,n=z(t,i),l=n.range,u={};u.r0=bt(l.$top,l.top,r),u.r1=bt(l.$bottom,l.bottom,r),u.c0=bt(l.$left,l.left,o),u.c1=bt(l.$right,l.right,o),u.$r0=l.$top,u.$r1=l.$bottom,u.$c0=l.$left,u.$c1=l.$right,n.range=u,e.value=Nt(n,i),e.loc&&(e.loc[0]+=c,c+=e.value.length-t.length,e.loc[1]+=c)}else c&&e.loc&&(e.loc[0]+=c,e.loc[1]+=c)})),u?s.map((e=>e.value)).join(""):s};
|
|
2
2
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnguanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
package/docs/API.md
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
- [addA1RangeBounds( range )](#addA1RangeBounds)
|
|
6
6
|
- [addTokenMeta( tokenlist, _\[context\]_ )](#addTokenMeta)
|
|
7
7
|
- [fixRanges( formula, _\[options\]_ )](#fixRanges)
|
|
8
|
-
- [fromA1( rangeString )](#fromA1)
|
|
9
8
|
- [fromCol( columnString )](#fromCol)
|
|
10
|
-
- [fromR1C1( rangeString )](#fromR1C1)
|
|
11
9
|
- [isError( token )](#isError)
|
|
12
10
|
- [isFunction( token )](#isFunction)
|
|
13
11
|
- [isFxPrefix( token )](#isFxPrefix)
|
|
@@ -24,9 +22,7 @@
|
|
|
24
22
|
- [stringifyA1Ref( refObject, _\[options\]_ )](#stringifyA1Ref)
|
|
25
23
|
- [stringifyR1C1Ref( refObject, _\[options\]_ )](#stringifyR1C1Ref)
|
|
26
24
|
- [stringifyStructRef( refObject, _\[options\]_ )](#stringifyStructRef)
|
|
27
|
-
- [toA1( range )](#toA1)
|
|
28
25
|
- [toCol( columnIndex )](#toCol)
|
|
29
|
-
- [toR1C1( range )](#toR1C1)
|
|
30
26
|
- [tokenize( formula, _\[options\]_ )](#tokenize)
|
|
31
27
|
- [translateToA1( formula, anchorCell, _\[options\]_ )](#translateToA1)
|
|
32
28
|
- [translateToR1C1( formula, anchorCell, _\[options\]_ )](#translateToR1C1)
|
|
@@ -177,24 +173,6 @@ Returns the same formula with the ranges updated. If an array of tokens was supp
|
|
|
177
173
|
|
|
178
174
|
---
|
|
179
175
|
|
|
180
|
-
### <a id="fromA1" href="#fromA1">#</a> fromA1( rangeString ) ⇒ [`RangeA1`](#RangeA1) | `null`
|
|
181
|
-
|
|
182
|
-
Parse a simple string reference to an A1 range into a range object. Will accept `A1`, `A2`, `A:A`, or `1:1`.
|
|
183
|
-
|
|
184
|
-
**See also:** [parseA1Ref](#parseA1Ref).
|
|
185
|
-
|
|
186
|
-
##### Parameters
|
|
187
|
-
|
|
188
|
-
| Name | Type | Description |
|
|
189
|
-
| ----------- | -------- | -------------- |
|
|
190
|
-
| rangeString | `string` | A range string |
|
|
191
|
-
|
|
192
|
-
##### Returns
|
|
193
|
-
|
|
194
|
-
[`RangeA1`](#RangeA1) | `null` – An object representing a valid range or null if it is invalid.
|
|
195
|
-
|
|
196
|
-
---
|
|
197
|
-
|
|
198
176
|
### <a id="fromCol" href="#fromCol">#</a> fromCol( columnString ) ⇒ `number`
|
|
199
177
|
|
|
200
178
|
Convert a column string representation to a 0 based offset number (`"C"` = `2`).
|
|
@@ -213,24 +191,6 @@ The method expects a valid column identifier made up of _only_ A-Z letters, whic
|
|
|
213
191
|
|
|
214
192
|
---
|
|
215
193
|
|
|
216
|
-
### <a id="fromR1C1" href="#fromR1C1">#</a> fromR1C1( rangeString ) ⇒ [`RangeR1C1`](#RangeR1C1) | `null`
|
|
217
|
-
|
|
218
|
-
Parse a simple string reference to an R1C1 range into a range object.
|
|
219
|
-
|
|
220
|
-
**See also:** [parseA1Ref](#parseA1Ref).
|
|
221
|
-
|
|
222
|
-
##### Parameters
|
|
223
|
-
|
|
224
|
-
| Name | Type | Description |
|
|
225
|
-
| ----------- | -------- | -------------- |
|
|
226
|
-
| rangeString | `string` | A range string |
|
|
227
|
-
|
|
228
|
-
##### Returns
|
|
229
|
-
|
|
230
|
-
[`RangeR1C1`](#RangeR1C1) | `null` – An object representing a valid reference or null if it is invalid.
|
|
231
|
-
|
|
232
|
-
---
|
|
233
|
-
|
|
234
194
|
### <a id="isError" href="#isError">#</a> isError( token ) ⇒ `boolean`
|
|
235
195
|
|
|
236
196
|
Determines whether the specified token is an error.
|
|
@@ -399,7 +359,7 @@ The parser requires `mergeRefs` to have been `true` in tokenlist options, becaus
|
|
|
399
359
|
|
|
400
360
|
The AST Abstract Syntax Tree's format is documented in [AST_format.md](./AST_format.md)
|
|
401
361
|
|
|
402
|
-
**See also:**
|
|
362
|
+
**See also:** [nodeTypes](#nodeTypes).
|
|
403
363
|
|
|
404
364
|
##### Parameters
|
|
405
365
|
|
|
@@ -626,24 +586,6 @@ stringifyStructRef({
|
|
|
626
586
|
|
|
627
587
|
---
|
|
628
588
|
|
|
629
|
-
### <a id="toA1" href="#toA1">#</a> toA1( range ) ⇒ `string`
|
|
630
|
-
|
|
631
|
-
Stringify a range object into A1 syntax.
|
|
632
|
-
|
|
633
|
-
**See also:** [parseA1Ref](#parseA1Ref).
|
|
634
|
-
|
|
635
|
-
##### Parameters
|
|
636
|
-
|
|
637
|
-
| Name | Type | Description |
|
|
638
|
-
| ----- | --------------------- | -------------- |
|
|
639
|
-
| range | [`RangeA1`](#RangeA1) | A range object |
|
|
640
|
-
|
|
641
|
-
##### Returns
|
|
642
|
-
|
|
643
|
-
`string` – An A1-style string represenation of a range
|
|
644
|
-
|
|
645
|
-
---
|
|
646
|
-
|
|
647
589
|
### <a id="toCol" href="#toCol">#</a> toCol( columnIndex ) ⇒ `string`
|
|
648
590
|
|
|
649
591
|
Convert a 0 based offset number to a column string representation (`2` = `"C"`).
|
|
@@ -662,24 +604,6 @@ The method expects a number between 0 and 16383. Other input will return garbage
|
|
|
662
604
|
|
|
663
605
|
---
|
|
664
606
|
|
|
665
|
-
### <a id="toR1C1" href="#toR1C1">#</a> toR1C1( range ) ⇒ `string`
|
|
666
|
-
|
|
667
|
-
Stringify a range object into R1C1 syntax.
|
|
668
|
-
|
|
669
|
-
**See also:** [parseR1C1Ref](#parseR1C1Ref).
|
|
670
|
-
|
|
671
|
-
##### Parameters
|
|
672
|
-
|
|
673
|
-
| Name | Type | Description |
|
|
674
|
-
| ----- | ------------------------- | -------------- |
|
|
675
|
-
| range | [`RangeR1C1`](#RangeR1C1) | A range object |
|
|
676
|
-
|
|
677
|
-
##### Returns
|
|
678
|
-
|
|
679
|
-
`string` – An R1C1-style string represenation of a range
|
|
680
|
-
|
|
681
|
-
---
|
|
682
|
-
|
|
683
607
|
### <a id="tokenize" href="#tokenize">#</a> tokenize( formula, _[options = `{}`]_ ) ⇒ `Array<Token>`
|
|
684
608
|
|
|
685
609
|
Breaks a string formula into a list of tokens.
|
|
@@ -707,7 +631,7 @@ To support syntax highlighting as you type, `STRING` tokens are allowed to be "u
|
|
|
707
631
|
]
|
|
708
632
|
```
|
|
709
633
|
|
|
710
|
-
**See also:**
|
|
634
|
+
**See also:** [tokenTypes](#tokenTypes).
|
|
711
635
|
|
|
712
636
|
##### Parameters
|
|
713
637
|
|
|
@@ -802,7 +726,7 @@ translateToR1C1("=SUM(E10,$E$2,Sheet!$E$3)", "D10");
|
|
|
802
726
|
|
|
803
727
|
A dictionary of the types used to identify AST node variants.
|
|
804
728
|
|
|
805
|
-
**See also:**
|
|
729
|
+
**See also:** [parse](#parse).
|
|
806
730
|
|
|
807
731
|
##### Properties
|
|
808
732
|
|
|
@@ -823,7 +747,7 @@ A dictionary of the types used to identify AST node variants.
|
|
|
823
747
|
|
|
824
748
|
A dictionary of the types used to identify token variants.
|
|
825
749
|
|
|
826
|
-
**See also:**
|
|
750
|
+
**See also:** [tokenize](#tokenize).
|
|
827
751
|
|
|
828
752
|
##### Properties
|
|
829
753
|
|
package/docs/Prefixes.md
CHANGED
|
@@ -63,7 +63,7 @@ When Excel saves a workbook to one of its XML formats (most commonly as .xlsx) i
|
|
|
63
63
|
* `[a]!`
|
|
64
64
|
* `[a]b!`
|
|
65
65
|
|
|
66
|
-
Since the XML files only ever emitted with positive integer indexes instead of workbook names, whether the syntax allows anything else is
|
|
66
|
+
Since the XML files only ever emitted with positive integer indexes instead of workbook names, whether the syntax allows anything else is speculative. _Fx_ chooses to be permissive in handling this variant and allows `[Workbook.xlsx]!A1` forms as well as `[1]!A1`.
|
|
67
67
|
|
|
68
68
|
Why the formula language does not use this unambiguous and somewhat more intuitive variant rather than the above form is a question for Excel historians, likely this later form was introduced with the XML format to eliminate the ambiguity?
|
|
69
69
|
|
package/lib/a1.js
CHANGED
|
@@ -84,6 +84,7 @@ export function toAbsolute (range) {
|
|
|
84
84
|
* Stringify a range object into A1 syntax.
|
|
85
85
|
*
|
|
86
86
|
* @private
|
|
87
|
+
* @ignore
|
|
87
88
|
* @see parseA1Ref
|
|
88
89
|
* @param {RangeA1} range A range object
|
|
89
90
|
* @returns {string} An A1-style string represenation of a range
|
|
@@ -161,6 +162,7 @@ function splitA1 (str) {
|
|
|
161
162
|
* Will accept `A1`, `A2`, `A:A`, or `1:1`.
|
|
162
163
|
*
|
|
163
164
|
* @private
|
|
165
|
+
* @ignore
|
|
164
166
|
* @see parseA1Ref
|
|
165
167
|
* @param {string} rangeString A range string
|
|
166
168
|
* @returns {(RangeA1|null)} An object representing a valid range or null if it is invalid.
|
package/lib/fixRanges.spec.js
CHANGED
|
@@ -135,7 +135,15 @@ test('fixRanges structured references', t => {
|
|
|
135
135
|
t.isFixed('[[#all],[#all],[#all],[#all],[ColumnName]]', '[[#All],[ColumnName]]');
|
|
136
136
|
t.isFixed('[@[foo]:bar]', '[@[foo]:[bar]]');
|
|
137
137
|
t.isFixed('[@foo bar]', '[@[foo bar]]');
|
|
138
|
-
|
|
138
|
+
// Care must be taken with spaces in column headers.
|
|
139
|
+
// Excel considers refs only valid if they match the column name
|
|
140
|
+
// but the parser does not know the names, so it must preserve
|
|
141
|
+
// leading/trailing whitespace.
|
|
142
|
+
t.isFixed('[ @[foo bar] ]', '[@[foo bar]]');
|
|
143
|
+
t.isFixed('[ @[ foo bar ] ]', '[@[ foo bar ]]');
|
|
144
|
+
t.isFixed('[ @foo bar ]', '[@[foo bar ]]');
|
|
145
|
+
t.isFixed('[@ foo bar]', '[@[ foo bar]]');
|
|
146
|
+
t.isFixed('[ @ foo bar ]', '[@[ foo bar ]]');
|
|
139
147
|
t.end();
|
|
140
148
|
});
|
|
141
149
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { test } from 'tape';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
addA1RangeBounds,
|
|
5
|
+
addTokenMeta,
|
|
6
|
+
fixRanges,
|
|
7
|
+
fromCol,
|
|
8
|
+
isError,
|
|
9
|
+
isFunction,
|
|
10
|
+
isFxPrefix,
|
|
11
|
+
isLiteral,
|
|
12
|
+
isOperator,
|
|
13
|
+
isRange,
|
|
14
|
+
isReference,
|
|
15
|
+
isWhitespace,
|
|
16
|
+
mergeRefTokens,
|
|
17
|
+
nodeTypes,
|
|
18
|
+
parse,
|
|
19
|
+
parseA1Ref,
|
|
20
|
+
parseR1C1Ref,
|
|
21
|
+
parseStructRef,
|
|
22
|
+
stringifyA1Ref,
|
|
23
|
+
stringifyR1C1Ref,
|
|
24
|
+
stringifyStructRef,
|
|
25
|
+
toCol,
|
|
26
|
+
tokenize,
|
|
27
|
+
tokenTypes,
|
|
28
|
+
translateToA1,
|
|
29
|
+
translateToR1C1
|
|
30
|
+
} from './index.js';
|
|
31
|
+
|
|
32
|
+
// What happens when B2:A1 -> should work!
|
|
33
|
+
test('fx main interface', t => {
|
|
34
|
+
t.ok(typeof addA1RangeBounds === 'function', 'addA1RangeBounds exists');
|
|
35
|
+
t.ok(typeof addTokenMeta === 'function', 'addTokenMeta exists');
|
|
36
|
+
t.ok(typeof fixRanges === 'function', 'fixRanges exists');
|
|
37
|
+
|
|
38
|
+
t.ok(typeof fromCol === 'function', 'fromCol exists');
|
|
39
|
+
|
|
40
|
+
t.ok(typeof isError === 'function', 'isError exists');
|
|
41
|
+
t.ok(typeof isFunction === 'function', 'isFunction exists');
|
|
42
|
+
t.ok(typeof isFxPrefix === 'function', 'isFxPrefix exists');
|
|
43
|
+
t.ok(typeof isLiteral === 'function', 'isLiteral exists');
|
|
44
|
+
t.ok(typeof isOperator === 'function', 'isOperator exists');
|
|
45
|
+
t.ok(typeof isRange === 'function', 'isRange exists');
|
|
46
|
+
t.ok(typeof isReference === 'function', 'isReference exists');
|
|
47
|
+
t.ok(typeof isWhitespace === 'function', 'isWhitespace exists');
|
|
48
|
+
|
|
49
|
+
t.ok(typeof mergeRefTokens === 'function', 'mergeRefTokens exists');
|
|
50
|
+
t.ok(typeof parse === 'function', 'parse exists');
|
|
51
|
+
t.ok(typeof parseA1Ref === 'function', 'parseA1Ref exists');
|
|
52
|
+
t.ok(typeof parseR1C1Ref === 'function', 'parseR1C1Ref exists');
|
|
53
|
+
t.ok(typeof parseStructRef === 'function', 'parseStructRef exists');
|
|
54
|
+
t.ok(typeof stringifyA1Ref === 'function', 'stringifyA1Ref exists');
|
|
55
|
+
t.ok(typeof stringifyR1C1Ref === 'function', 'stringifyR1C1Ref exists');
|
|
56
|
+
t.ok(typeof stringifyStructRef === 'function', 'stringifyStructRef exists');
|
|
57
|
+
t.ok(typeof toCol === 'function', 'toCol exists');
|
|
58
|
+
t.ok(typeof tokenize === 'function', 'tokenize exists');
|
|
59
|
+
t.ok(typeof translateToA1 === 'function', 'translateToA1 exists');
|
|
60
|
+
t.ok(typeof translateToR1C1 === 'function', 'translateToR1C1 exists');
|
|
61
|
+
|
|
62
|
+
t.ok(typeof nodeTypes === 'object', 'nodeTypes exists');
|
|
63
|
+
t.ok(typeof tokenTypes === 'object', 'tokenTypes exists');
|
|
64
|
+
|
|
65
|
+
t.end();
|
|
66
|
+
});
|
|
67
|
+
|
package/lib/rc.js
CHANGED
|
@@ -22,6 +22,7 @@ function toCoord (value, isAbs) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Stringify a range object into R1C1 syntax.
|
|
24
24
|
*
|
|
25
|
+
* @ignore
|
|
25
26
|
* @private
|
|
26
27
|
* @see parseR1C1Ref
|
|
27
28
|
* @param {RangeR1C1} range A range object
|
|
@@ -132,6 +133,7 @@ function parseR1C1Part (ref) {
|
|
|
132
133
|
* Parse a simple string reference to an R1C1 range into a range object.
|
|
133
134
|
*
|
|
134
135
|
* @private
|
|
136
|
+
* @ignore
|
|
135
137
|
* @see parseA1Ref
|
|
136
138
|
* @param {string} rangeString A range string
|
|
137
139
|
* @returns {(RangeR1C1|null)} An object representing a valid reference or null if it is invalid.
|
package/lib/sr.js
CHANGED
|
@@ -71,7 +71,7 @@ export function parseSRange (raw) {
|
|
|
71
71
|
// [column]
|
|
72
72
|
else if ((m1 = matchColumn(s, false))) {
|
|
73
73
|
pos += m1[0].length;
|
|
74
|
-
columns.push(m1[1]
|
|
74
|
+
columns.push(m1[1]);
|
|
75
75
|
}
|
|
76
76
|
// use the "normal" method
|
|
77
77
|
// [[#keyword]]
|
|
@@ -126,7 +126,7 @@ export function parseSRange (raw) {
|
|
|
126
126
|
const leftCol = expect_more ? matchColumn(raw.slice(pos)) : null;
|
|
127
127
|
if (leftCol) {
|
|
128
128
|
pos += leftCol[0].length;
|
|
129
|
-
columns.push(leftCol[1]
|
|
129
|
+
columns.push(leftCol[1]);
|
|
130
130
|
s = raw.slice(pos);
|
|
131
131
|
if (s[0] === ':') {
|
|
132
132
|
s = s.slice(1);
|
|
@@ -134,7 +134,7 @@ export function parseSRange (raw) {
|
|
|
134
134
|
const rightCol = matchColumn(s);
|
|
135
135
|
if (rightCol) {
|
|
136
136
|
pos += rightCol[0].length;
|
|
137
|
-
columns.push(rightCol[1]
|
|
137
|
+
columns.push(rightCol[1]);
|
|
138
138
|
}
|
|
139
139
|
else {
|
|
140
140
|
return null;
|
package/lib/sr.spec.js
CHANGED
|
@@ -45,16 +45,24 @@ test('parse structured references', t => {
|
|
|
45
45
|
columns: [ 'my column' ]
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
t.isSREqual('[
|
|
48
|
+
t.isSREqual('[[my column]:otherColumn]', {
|
|
49
49
|
columns: [ 'my column', 'otherColumn' ]
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
t.isSREqual('[
|
|
53
|
-
columns: [ 'my column', 'otherColumn' ]
|
|
52
|
+
t.isSREqual('[ [my column]:otherColumn ]', {
|
|
53
|
+
columns: [ 'my column', 'otherColumn ' ]
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
t.isSREqual('[ [my column]: otherColumn ]', {
|
|
57
|
+
columns: [ 'my column', ' otherColumn ' ]
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
t.isSREqual('[ @[ my column ]: otherColumn ]', {
|
|
61
|
+
columns: [ ' my column ', ' otherColumn ' ],
|
|
54
62
|
sections: [ 'this row' ]
|
|
55
63
|
});
|
|
56
64
|
|
|
57
|
-
t.isSREqual('[
|
|
65
|
+
t.isSREqual('[[#Data], [my column]:otherColumn]', {
|
|
58
66
|
columns: [ 'my column', 'otherColumn' ],
|
|
59
67
|
sections: [ 'data' ]
|
|
60
68
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@borgar/fx",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.1",
|
|
4
4
|
"description": "Utilities for working with Excel formulas",
|
|
5
5
|
"main": "dist/fx.js",
|
|
6
6
|
"types": "dist/fx.d.ts",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"version": "npm run build",
|
|
17
17
|
"lint": "eslint lib/*.js",
|
|
18
18
|
"test": "tape lib/*.spec.js | tap-min",
|
|
19
|
+
"build:all": "npm run build:types && npm run build:docs && npm run build",
|
|
19
20
|
"build:types": "jsdoc -c tsd.json lib>dist/fx.d.ts",
|
|
20
21
|
"build:docs": "echo '# _Fx_ API\n'>docs/API.md; jsdoc -t node_modules/@borgar/jsdoc-tsmd -d console lib>>docs/API.md",
|
|
21
22
|
"build": "NODE_ENV=production rollup -c"
|
|
@@ -41,20 +42,20 @@
|
|
|
41
42
|
"author": "Borgar Þorsteinsson <borgar@borgar.net> (http://borgar.net/)",
|
|
42
43
|
"license": "MIT",
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "~7.23.
|
|
45
|
-
"@babel/eslint-parser": "~7.
|
|
46
|
-
"@babel/preset-env": "~7.
|
|
45
|
+
"@babel/core": "~7.23.9",
|
|
46
|
+
"@babel/eslint-parser": "~7.23.10",
|
|
47
|
+
"@babel/preset-env": "~7.23.9",
|
|
47
48
|
"@borgar/eslint-config": "~3.1.0",
|
|
48
|
-
"@borgar/jsdoc-tsmd": "~0.2.
|
|
49
|
-
"@rollup/plugin-babel": "~6.0.
|
|
49
|
+
"@borgar/jsdoc-tsmd": "~0.2.1",
|
|
50
|
+
"@rollup/plugin-babel": "~6.0.4",
|
|
50
51
|
"babel-eslint": "~10.1.0",
|
|
51
|
-
"eslint": "~8.
|
|
52
|
-
"eslint-plugin-jsdoc": "~
|
|
52
|
+
"eslint": "~8.56.0",
|
|
53
|
+
"eslint-plugin-jsdoc": "~48.1.0",
|
|
53
54
|
"jsdoc": "~4.0.2",
|
|
54
|
-
"rollup": "~
|
|
55
|
+
"rollup": "~4.12.0",
|
|
55
56
|
"rollup-plugin-minification": "~0.2.0",
|
|
56
57
|
"tap-min": "~3.0.0",
|
|
57
|
-
"tape": "~5.7.
|
|
58
|
-
"typescript": "~5.
|
|
58
|
+
"tape": "~5.7.5",
|
|
59
|
+
"typescript": "~5.3.3"
|
|
59
60
|
}
|
|
60
61
|
}
|