@borgar/fx 4.3.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fx.d.ts +647 -0
- package/dist/fx.js +1 -1
- package/docs/API.md +361 -280
- package/lib/parser.js +1 -1
- package/package.json +14 -10
- package/tsd.json +12 -0
- package/.jsdoc/config.json +0 -17
- package/.jsdoc/publish.js +0 -217
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",i="BinaryExpression",c="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},m=e=>e&&"range"===e.type&&{r1:e.value},$=t=>t&&t.type===e&&"!"===t.value&&{},y=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,m],[x],[y],[E,$,d],[E,$,x,g,m],[E,$,x],[E,$,y]],N=w.concat([[R],[E,$,R],[v],[R,v],[E,$,R,v]]);function b(e,t){const n={withLocation:!1,mergeRefs:!1,allowTernary:!1,allowNamed:!0,r1c1:!1,xlsx:!1,...t},l=Oe(e,we,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 C=/[^0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]/;function A(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+=C.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+=C.test(l)),r&&(t+=r,n+=C.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?"$":"")+_(e),k=(e,t)=>(t?"$":"")+String(e+1);function O(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 _(e){return(e>=702?String.fromCharCode(((e-702)/676-0)%26+65):"")+(e>=26?String.fromCharCode(Math.floor((e/26-1)%26+65)):"")+String.fromCharCode(e%26+65)}function U(e){let{top:t,left:n,bottom:l,right:r}=e;const{$left:o,$right:u,$top:s,$bottom:i}=e,c=null==n,a=null==r,f=null==t,p=null==l;return t=I(0,0|t,1048575),n=I(0,0|n,16383),!c&&!f&&a&&p?(l=t,r=n):(l=I(0,0|l,1048575),r=I(0,0|r,16383)),0===t&&l>=1048575||f&&p?L(n,o)+":"+L(r,u):0===n&&r>=16383||c&&a?k(t,s)+":"+k(l,i):c||f||a||!p?c||!f||a||p?c||f||!a||p?!c||f||a||p?r!==n||l!==t||u!==o||i!==s?L(n,o)+k(t,s)+":"+L(r,u)+k(l,i):L(n,o)+k(t,s):L(r,u)+k(t,s)+":"+k(l,i):L(n,o)+k(t,s)+":"+k(l,i):L(n,o)+k(l,i)+":"+L(r,u):L(n,o)+k(t,s)+":"+L(r,u)}function F(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]?O(t[2]):null,!!t[3],!!t[1]]:null;var n}function S(e){let t=null,n=null,l=null,r=null,o=!1,u=!1,s=!1,i=!1;const[c,a,f]=e.split(":");if(f)return null;const p=F(c),h=a?F(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,i]=h:null==h[0]&&null!=h[1]?[,r,,i]=h:null!=h[0]&&null==h[1]&&([l,,s]=h);else{if(null==t||null==n)return null;l=t,r=n,s=o,i=u}return null!=r&&(null==n||null!=n&&r<n)&&([n,r,u,i]=[r,n,i,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:i}}function M(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=S(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):A(e);return n+(e.name?e.name:U(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,W=/^([^#@[\]:]+)/i,Z={headers:1,data:2,totals:4,all:8,"this row":16,"@":16},q=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Object.freeze(t)},B={0:q(),1:q("headers"),2:q("data"),4:q("totals"),8:q("all"),16:q("this row"),3:q("headers","data"),6:q("data","totals")},P=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=W.exec(e),n)?[n[0],n[0]]:null};function X(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,!Z[e])return null;u|=Z[e]}else if(l=P(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(!Z[e])return null;u|=Z[e],o=o.slice(n[0].length),r+=n[0].length,l=!!n[2]}if(l&&(n=/^@/.exec(o))&&(u|=Z["@"],o=o.slice(1),r+=1,l="]"!==o[0]),!(u in B))return null;const s=l?P(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=P(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=B[u];return{columns:t,sections:s?s.concat():s,length:r,token:e.slice(0,r)}}function H(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=X(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 Y(e){return e.replace(/([[\]#'@])/g,"'$1")}function G(e){return!/^[a-zA-Z0-9\u00a1-\uffff]+$/.test(e)}function K(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function V(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t?T(e):A(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=>`[#${K(e)}]`)).join(","),l&&(n+=",")),t&&1===e.columns.length&&!G(e.columns[0])?n+=Y(e.columns[0]):l&&(n+=e.columns.slice(0,2).map((e=>`[${Y(e)}]`)).join(":")),n+="]"}else n+=`[${Y(e.columns[0])}]`;else n+=`[#${K(e.sections[0])}]`;return n}const Q=/^(?!!)(\[(?:[^\]])+\])?([0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]+)?(?=!)/,J=/^'(?:''|[^'])*('|$)(?=!)/,ee="\\$?[A-Z]{1,3}\\$?[1-9][0-9]{0,6}",te="\\$?[A-Z]{1,3}",ne="\\$?[1-9][0-9]{0,6}",le=new RegExp(`^${te}:${te}`,"i"),re=new RegExp(`^${ne}:${ne}`,"i"),oe=new RegExp(`^${ee}`,"i"),ue=new RegExp(`^((${te}|${ne}):${ee}|${ee}:(${te}|${ne}))(?![\\w($.])`,"i"),se="(?:R(?:\\[[+-]?\\d+\\]|[1-9][0-9]{0,6})?)",ie="(?:C(?:\\[[+-]?\\d+\\]|[1-9][0-9]{0,4})?)",ce=new RegExp(`^${ie}(:${ie})?(?=\\W|$)`,"i"),ae=new RegExp(`^${se}(:${se})?(?=\\W|$)`,"i"),fe=new RegExp(`^(?:(?=[RC])${se}${ie})`,"i"),pe=new RegExp(`^(${se}${ie}(:${ie}|:${se})(?![[\\d])|(${se}|${ie})(:${se}${ie}))(?=\\W|$)`,"i"),he=/^(?![CR]\b)[a-zA-Z\\_\u00a1-\uffff][a-zA-Z0-9\\_.?\u00a1-\uffff]{0,254}/i;function ge(e,t){return n=>{const l=t.exec(n);if(l)return{type:e,value:l[0]}}}const xe=/^'(?:[^[\]]+?)?(?:\[(.+?)\])?(?:[^[\]]+?)'$/,de=/^'\[(.+?)\]'$/;function me(e,t){const n=J.exec(e);if(n){const e=n[0];if(t.xlsx&&de.test(e)||xe.test(e))return{type:"context_quote",value:e}}const l=Q.exec(e);if(l){const[,e,n]=l;if(e&&n||n||e&&!n&&t.xlsx)return{type:"context",value:l[0]}}}function $e(e){const t=X(e);if(t){let n=t.length;for(;" "===e[n];)n++;if("!"!==e[n])return{type:o,value:t.token}}return null}const ye=/([RC])(\[?)(-?\d+)/gi,ve=/(\d+|[a-zA-Z]+)/gi;function Ee(e,t){let r,o;if(t.r1c1){if(t.allowTernary&&(r=pe.exec(e))?o={type:l,value:r[0]}:(r=fe.exec(e))?o={type:"range",value:r[0]}:((r=ae.exec(e))||(r=ce.exec(e)))&&(o={type:n,value:r[0]}),o){for(ye.lastIndex=0;null!==(r=ye.exec(o.value));){const e=("R"===r[1]?1048575:16383)+(r[2]?1:0),t=parseInt(r[3],10);if(t>=e||t<=-e)return null}return o}}else if(t.allowTernary&&(r=ue.exec(e))?o={type:l,value:r[0]}:(r=le.exec(e))||(r=re.exec(e))?o={type:n,value:r[0]}:(r=oe.exec(e))&&(o={type:"range",value:r[0]}),o){for(ve.lastIndex=0;null!==(r=ve.exec(o.value));)if(/^\d/.test(r[1])){if(parseInt(r[1],10)-1>1048575)return null}else if(O(r[1])>16383)return null;return o}}const Re=[ge(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),ge(e,/^(<=|>=|<>|[-+/*^%&<>=]|[{},;]|[()]|@|:|!|#)/),ge("func",/^[A-Z_]+[A-Z\d_.]*(?=\()/i),ge("bool",/^(TRUE|FALSE)\b/i),ge("newline",/^\n+/),ge("whitespace",/^[ \f\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/),ge("string",/^"(?:""|[^"])*("|$)/),me,Ee,$e,ge("number",/^(?:\d+(\.\d+)?(?:[eE][+-]?\d+)?|\d+)/),ge(r,he)],we=[function(t,n){return n.r1c1?"!"===t[0]?{type:e,value:t[0]}:null:"!"===t[0]||":"===t[0]?{type:e,value:t[0]}:null},me,Ee,$e,ge(r,he)],Ne={};function be(e,t){if(e.length){const n=e[0];t[n]=t[n]||{},be(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=>be(e.concat().reverse(),Ne)));const Ce=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 Ce(t,n[u],l,r+1)}return n.$?r:0};function Ae(e){const t=[];for(let n=e.length-1;n>=0;n--){let l=e[n];const r=Ce(e,Ne,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 Te=(e,t)=>e&&e.type===t,Ie={withLocation:!1,mergeRefs:!0,allowTernary:!1,negativeNumbers:!0,r1c1:!1},Le=e=>e.type===r||"func"===e.type,ke=t=>!Te(t,e)||"%"===t.value||"}"===t.value||")"===t.value||"#"===t.value;function Oe(t,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=Object.assign({},Ie,l),{withLocation:o,mergeRefs:s,negativeNumbers:i}=r,c=[];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&&Le(h)||n&&Le(e))?(h.value+=e.value,h.type=u,o&&(h.loc[1]=e.loc[1])):(c.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 m={type:x,value:d,...o?{loc:[l,a]}:{}};if("string"===x){const e=d.length;if('""'===d);else if('"'===d||'"'!==d[e-1])m.unterminated=!0;else if('""'!==d&&'"'===d[e-2]){let t=e-1;for(;'"'===d[t];)t--;!(t+1)^(e-t+1)%2==0&&(m.unterminated=!0)}}if(i&&"number"===x){const t=h;if(t&&Te(t,e)&&"-"===t.value&&(!p||Te(p,"fx_prefix")||!ke(p))){const e=c.pop();m.value="-"+d,o&&(m.loc[0]=e.loc[0]),f=p,h=c[c.length-1]}}g(m)}return s?Ae(c):c}function _e(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Oe(e,Re,t)}function Ue(e){return!!e&&("range"===e.type||e.type===n||e.type===l)}function Fe(e){return!!e&&("range"===e.type||e.type===n||e.type===l||e.type===o||e.type===r)}function Se(e){return!!e&&("bool"===e.type||e.type===t||"number"===e.type||"string"===e.type)}function Me(e){return!!e&&e.type===t}function De(e){return!!e&&("whitespace"===e.type||"newline"===e.type)}function je(e){return!!e&&"func"===e.type}function ze(e){return!!e&&"fx_prefix"===e.type}function We(t){return!!t&&t.type===e}const Ze="(END)",qe=["ANCHORARRAY","CHOOSE","DROP","IF","IFS","INDEX","INDIRECT","LAMBDA","LET","OFFSET","REDUCE","SINGLE","SWITCH","TAKE","XLOOKUP"],Be=e=>!!e&&(e.type===c||("ErrorLiteral"===e.type||e.type===t)&&"#REF!"===e.value||e.type===i&&(":"===e.operator||" "===e.operator||","===e.operator)||e.type===a&&qe.includes(e.callee.name.toUpperCase())),Pe={};let Xe,He,Ye,Ge=!1,Ke=!1;function Ve(e){const t=new Error(e);throw t.source=He.map((e=>e.value)).join(""),t.sourceOffset=He.slice(0,Ye).reduce(((e,t)=>e+t.value),"").length,t}function Qe(){let e,t=Ye;do{e=He[++t]}while(e&&(De(e)||We(e)&&"("===e.value));return(e=>{const t=(e&&e.value)+"";return!(!Fe(e)&&(!We(e)||":"!==t&&","!==t&&t.trim())&&(!je(e)||!qe.includes(t.toUpperCase()))&&(!Me(e)||"#REF!"!==t))})(e)}function Je(){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!==Xe.id&&Ve(`Expected ${e} but got ${Xe.id}`),De(He[Ye])){if(!(Be(t)&&Qe()))for(;De(He[Ye]);)Ye++}if(Ye>=He.length)return void(Xe=Pe[Ze]);const n=He[Ye];let l;Ye+=1,n.unterminated&&Ve("Encountered an unterminated token");let r=n.type;return We(n)?(l=Pe[n.value],l||Ve(`Unknown operator ${n.value}`)):De(n)?l=Pe["(WHITESPACE)"]:Se(n)?l=Pe.Literal:Fe(n)?(l=Pe[c],r=c):je(n)?l=Pe["(FUNCTION)"]:Ve(`Unexpected ${n.type} token: ${n.value}`),Xe=Object.create(l),Xe.type=r,Xe.value=n.value,n.loc&&(Xe.loc=[...n.loc]),Xe}function et(e){let t=Xe;Je(null,t);let n=t.nud();for(;e<Xe.lbp;)t=Xe,Je(null,t),n=t.led(n);return n}const tt={nud:()=>Ve("Invalid syntax"),led:()=>Ve("Missing operator")};function nt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Pe[e];return n?t>=n.lbp&&(n.lbp=t):(n={...tt},n.id=e,n.value=e,n.lbp=t,Pe[e]=n),n}function lt(e,t,n){const l=nt(e,t);return l.led=n||function(e){this.type=i,this.operator=this.value,delete this.value;const n=et(t);return this.arguments=[e,n],this.loc&&(this.loc=[e.loc[0],n.loc[1]]),this},l}function rt(e,t){const n=nt(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 ot(e,t){const n=nt(e);return n.nud=t||function(){this.type=s,this.operator=this.value,delete this.value;const e=et(70);return this.arguments=[e],this.loc&&(this.loc[1]=e.loc[1]),this},n}function ut(e,t){return lt(e,t,(function(n){Be(n)||Ve(`Unexpected ${e} operator`);const l=et(t);return Be(l)||Ve(`Unexpected ${Xe.type} following ${this.id}`),this.type=i,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}))}nt(Ze),ut(":",80);const st=ut(",",80);ut("(WHITESPACE)",80);const it=e=>{const t=st.lbp>0;return null!=e&&(st.lbp=e?80:0),t};function ct(){let e=1;return()=>"fxg"+e++}function at(e,t){return null==e&&null==t||e===t}function ft(e,t){if(Array.isArray(e)!==Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!at(e[n],t[n]))return!1;return!0}function pt(e,t){return!e&&!t||String(e).toLowerCase()===String(t).toLowerCase()}function ht(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(!ft(e.columns,t.columns))return!1;if(!ft(e.sections,t.sections))return!1}return!!(!e.range&&!t.range||at(e.range.top,t.range.top)&&at(e.range.bottom,t.range.bottom)&&at(e.range.left,t.range.left)&&at(e.range.right,t.range.right))&&!(!pt(e.workbookName,t.workbookName)||!pt(e.sheetName,t.sheetName))}function gt(e,t,n){return e.sheetName||(e.sheetName=t),e.workbookName||(e.workbookName=n),e}rt("%"),rt("#",(function(e){return Be(e)||Ve("# expects a reference"),this.type=s,this.operator=this.value,delete this.value,this.arguments=[e],this})),ot("+"),ot("-"),ot("@"),lt("^",50),lt("*",40),lt("/",40),lt("+",30),lt("-",30),lt("&",20),lt("=",10),lt("<",10),lt(">",10),lt("<=",10),lt(">=",10),lt("<>",10),nt("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},nt(c).nud=function(){return this.type=c,this},nt(")"),ot("(",(function(){const e=it(!0),t=et(0);return Je(")",t),it(e),t})),nt("(FUNCTION)").nud=function(){return this},lt("(",90,(function(e){"(FUNCTION)"!==e.id&&Ve("Cannot call a "+e.type);const t=[];let n=!1;if(")"!==Xe.id){const e=it(!1);for(;")"!==Xe.id;)if(De(Xe)&&Je(),","===Xe.id)t.push(null),n=!0,Je();else{const e=et(0);t.push(e),n=!1,","===Xe.id&&(Je(","),n=!0)}it(e)}n&&t.push(null);const l=Xe;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]]),Je(")",this),this})),nt("}"),nt(";"),ot("{",(function(){"}"===Xe.id&&Ve("Unexpected empty array");let e=[],t=!1;const n=[e],l=it(!1);for(;!t;){if(De(Xe)&&Je(),Se(Xe))e.push(Pe.Literal.nud.call(Xe)),Je();else if(Ge&&Be(Xe))e.push(Pe[c].nud.call(Xe)),Je();else if(Ke&&je(Xe)){const t=et(0);e.push(t)}else Ve(`Unexpected ${Xe.type} in array: ${Xe.value}`);","===Xe.id?Je(","):";"===Xe.id?(Je(";"),e=[],n.push(e)):t=!0}const r=Xe;return Je("}"),it(l),this.type="ArrayExpression",this.elements=n,this.loc&&(this.loc[1]=r.loc[1]),delete this.value,this}));const xt=(e,t,n)=>Math.min(Math.max(t,e),n);function dt(e,t){return t?String(e+1):e?"["+e+"]":""}function mt(e){let{r0:t,c0:n,r1:l,c1:r}=e;const{$c0:o,$c1:u,$r0:s,$r1:i}=e,c=null==t,a=null==n;let f=null==l,p=null==r;if(t=xt(s?0:-1048575,0|t,1048575),n=xt(o?0:-16383,0|n,16383),!c&&f&&!a&&p?(l=t,f=!1,r=n,p=!1):(l=xt(i?0:-1048575,0|l,1048575),r=xt(u?0:-16383,0|r,16383)),0===t&&l>=1048575||c&&f){const e=dt(n,o),t=dt(r,u);return"C"+(e===t?e:e+":C"+t)}if(0===n&&r>=16383||a&&p){const e=dt(t,s),n=dt(l,i);return"R"+(e===n?e:e+":R"+n)}const h=dt(t,s),g=dt(l,i),x=dt(n,o),d=dt(r,u);return c||f||a||p?(c?"":"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 $t(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 yt(e){let t=null;const[n,l]=e.split(":",2),r=$t(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=$t(l);if(!r)return null;{t={};const[l,s,i,c]=r;null!=e&&null!=l?(t.r0=o===i?Math.min(e,l):e,t.$r0=o,t.r1=o===i?Math.max(e,l):l,t.$r1=i):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=i,t.r1=null,t.$r1=i):null==e&&null==l&&(t.r0=null,t.$r0=!1,t.r1=null,t.$r1=!1),null!=n&&null!=s?(t.c0=u===c?Math.min(n,s):n,t.$c0=u,t.c1=u===c?Math.max(n,s):s,t.$c1=c):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=c,t.c1=null,t.$c1=c):null==n&&null==s&&(t.c0=null,t.$c0=!1,t.c1=null,t.$c1=!1)}}}return t}function vt(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?yt(r.r0+":"+r.r1):yt(r.r0);return r.name||e?(r.range=e,delete r.r0,delete r.r1,r):null}return null}function Et(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t?T(e):A(e);return n+(e.name?e.name:mt(e.range))}const Rt=(e,t,n)=>null==t?null:e?t:t-n,wt={withLocation:!1,mergeRefs:!1,allowTernary:!0,r1c1:!1};function Nt(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 bt={wrapEdges:!0,mergeRefs:!0,xlsx:!1};const Ct=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}),At=Object.freeze({UNARY:s,BINARY:i,REFERENCE:c,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 i=null;const c=ct(),a=[],f=()=>s.length+(i?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=c();e.groupId=n,e.depth=t.depth,t.groupId=n}else e.error=!0}else if("{"===e.value)i?e.error=!0:(i=e,e.depth=f());else if("}"===e.value){if(i){const t=c();e.groupId=t,e.depth=i.depth,i.groupId=t}else e.error=!0;i=null}else if("range"===e.type||e.type===n||e.type===l||e.type===o){const n=e.type===o?H(e.value,{allowTernary:!0,xlsx:!0}):M(e.value,{allowTernary:!0,xlsx:!0});if(n&&(n.range||n.columns)){n.source=e.value,gt(n,t,r);const l=a.find((e=>ht(e,n)));l?e.groupId=l.groupId:(n.groupId=c(),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(_e(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=V(H(t.value,{xlsx:u}),{xlsx:u});n=e.length-t.value.length,t.value=e}else if(Ue(t)){const e=M(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=O,exports.isError=Me,exports.isFunction=je,exports.isFxPrefix=ze,exports.isLiteral=Se,exports.isOperator=We,exports.isRange=Ue,exports.isReference=Fe,exports.isWhitespace=De,exports.mergeRefTokens=Ae,exports.nodeTypes=At,exports.parse=function(e,t){if("string"==typeof e)He=_e(e,{withLocation:!0,...t,mergeRefs:!0});else{if(!Array.isArray(e))throw new Error("Parse requires a string or array of tokens.");He=e}for(Ge=t?.permitArrayRanges,Ke=t?.permitArrayCalls,Ye=0;De(He[Ye])||ze(He[Ye]);)Ye++;Je(),it(!0);const n=et(0);return Je(Ze),n},exports.parseA1Ref=M,exports.parseR1C1Ref=vt,exports.parseStructRef=H,exports.stringifyA1Ref=D,exports.stringifyR1C1Ref=Et,exports.stringifyStructRef=V,exports.toCol=_,exports.tokenTypes=Ct,exports.tokenize=_e,exports.translateToA1=function(e,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:bt;const r=S(n),o="string"==typeof e,u={...bt,...l},s=o?_e(e,{withLocation:!1,mergeRefs:u.mergeRefs,xlsx:u.xlsx,allowTernary:!0,r1c1:!0}):e;let i=0;const c={xlsx:u.xlsx,allowTernary:!0};return s.forEach((e=>{if(Ue(e)){const n=e.value,l=vt(n,c),o=l.range,s={},a=Nt(o.r0,o.$r0,r.top,1048575,u.wrapEdges),f=Nt(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=Nt(o.c0,o.$c0,r.left,16383,u.wrapEdges),h=Nt(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,c)),e.loc&&(e.loc[0]+=i,i+=e.value.length-n.length,e.loc[1]+=i)}else i&&e.loc&&(e.loc[0]+=i,e.loc[1]+=i)})),o?s.map((e=>e.value)).join(""):s},exports.translateToR1C1=function(e,t){let{xlsx:n=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{top:l,left:r}=S(t),o="string"==typeof e,u=o?_e(e,{...wt,xlsx:n}):e;let s=0;const i={xlsx:n,allowTernary:!0};return u.forEach((e=>{if(Ue(e)){const t=e.value,n=M(t,i),o=n.range,u={};u.r0=Rt(o.$top,o.top,l),u.r1=Rt(o.$bottom,o.bottom,l),u.c0=Rt(o.$left,o.left,r),u.c1=Rt(o.$right,o.right,r),u.$r0=o.$top,u.$r1=o.$bottom,u.$c0=o.$left,u.$c1=o.$right,n.range=u,e.value=Et(n,i),e.loc&&(e.loc[0]+=s,s+=e.value.length-t.length,e.loc[1]+=s)}else s&&e.loc&&(e.loc[0]+=s,e.loc[1]+=s)})),o?u.map((e=>e.value)).join(""):u};
|
|
1
|
+
"use strict";const e="operator",t="error",n="range_beam",l="range_ternary",r="range_named",o="structured",u="unknown",s="UnaryExpression",i="BinaryExpression",c="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},m=e=>e&&"range"===e.type&&{r1:e.value},$=t=>t&&t.type===e&&"!"===t.value&&{},y=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,m],[x],[y],[E,$,d],[E,$,x,g,m],[E,$,x],[E,$,y]],N=w.concat([[R],[E,$,R],[v],[R,v],[E,$,R,v]]);function b(e,t){const n={withLocation:!1,mergeRefs:!1,allowTernary:!1,allowNamed:!0,r1c1:!1,xlsx:!1,...t},l=Oe(e,we,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 C=/[^0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]/;function A(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+=C.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+=C.test(l)),r&&(t+=r,n+=C.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?"$":"")+_(e),k=(e,t)=>(t?"$":"")+String(e+1);function O(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 _(e){return(e>=702?String.fromCharCode(((e-702)/676-0)%26+65):"")+(e>=26?String.fromCharCode(Math.floor((e/26-1)%26+65)):"")+String.fromCharCode(e%26+65)}function U(e){let{top:t,left:n,bottom:l,right:r}=e;const{$left:o,$right:u,$top:s,$bottom:i}=e,c=null==n,a=null==r,f=null==t,p=null==l;return t=I(0,0|t,1048575),n=I(0,0|n,16383),!c&&!f&&a&&p?(l=t,r=n):(l=I(0,0|l,1048575),r=I(0,0|r,16383)),0===t&&l>=1048575||f&&p?L(n,o)+":"+L(r,u):0===n&&r>=16383||c&&a?k(t,s)+":"+k(l,i):c||f||a||!p?c||!f||a||p?c||f||!a||p?!c||f||a||p?r!==n||l!==t||u!==o||i!==s?L(n,o)+k(t,s)+":"+L(r,u)+k(l,i):L(n,o)+k(t,s):L(r,u)+k(t,s)+":"+k(l,i):L(n,o)+k(t,s)+":"+k(l,i):L(n,o)+k(l,i)+":"+L(r,u):L(n,o)+k(t,s)+":"+L(r,u)}function F(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]?O(t[2]):null,!!t[3],!!t[1]]:null;var n}function S(e){let t=null,n=null,l=null,r=null,o=!1,u=!1,s=!1,i=!1;const[c,a,f]=e.split(":");if(f)return null;const p=F(c),h=a?F(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,i]=h:null==h[0]&&null!=h[1]?[,r,,i]=h:null!=h[0]&&null==h[1]&&([l,,s]=h);else{if(null==t||null==n)return null;l=t,r=n,s=o,i=u}return null!=r&&(null==n||null!=n&&r<n)&&([n,r,u,i]=[r,n,i,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:i}}function M(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=S(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):A(e);return n+(e.name?e.name:U(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,W=/^([^#@[\]:]+)/i,Z={headers:1,data:2,totals:4,all:8,"this row":16,"@":16},q=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Object.freeze(t)},B={0:q(),1:q("headers"),2:q("data"),4:q("totals"),8:q("all"),16:q("this row"),3:q("headers","data"),6:q("data","totals")},P=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=W.exec(e),n)?[n[0],n[0]]:null};function X(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,!Z[e])return null;u|=Z[e]}else if(l=P(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(!Z[e])return null;u|=Z[e],o=o.slice(n[0].length),r+=n[0].length,l=!!n[2]}if(l&&(n=/^@/.exec(o))&&(u|=Z["@"],o=o.slice(1),r+=1,l="]"!==o[0]),!(u in B))return null;const s=l?P(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=P(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=B[u];return{columns:t,sections:s?s.concat():s,length:r,token:e.slice(0,r)}}function H(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=X(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 Y(e){return e.replace(/([[\]#'@])/g,"'$1")}function G(e){return!/^[a-zA-Z0-9\u00a1-\uffff]+$/.test(e)}function K(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function V(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t?T(e):A(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=>`[#${K(e)}]`)).join(","),l&&(n+=",")),t&&1===e.columns.length&&!G(e.columns[0])?n+=Y(e.columns[0]):l&&(n+=e.columns.slice(0,2).map((e=>`[${Y(e)}]`)).join(":")),n+="]"}else n+=`[${Y(e.columns[0])}]`;else n+=`[#${K(e.sections[0])}]`;return n}const Q=/^(?!!)(\[(?:[^\]])+\])?([0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]+)?(?=!)/,J=/^'(?:''|[^'])*('|$)(?=!)/,ee="\\$?[A-Z]{1,3}\\$?[1-9][0-9]{0,6}",te="\\$?[A-Z]{1,3}",ne="\\$?[1-9][0-9]{0,6}",le=new RegExp(`^${te}:${te}`,"i"),re=new RegExp(`^${ne}:${ne}`,"i"),oe=new RegExp(`^${ee}`,"i"),ue=new RegExp(`^((${te}|${ne}):${ee}|${ee}:(${te}|${ne}))(?![\\w($.])`,"i"),se="(?:R(?:\\[[+-]?\\d+\\]|[1-9][0-9]{0,6})?)",ie="(?:C(?:\\[[+-]?\\d+\\]|[1-9][0-9]{0,4})?)",ce=new RegExp(`^${ie}(:${ie})?(?=\\W|$)`,"i"),ae=new RegExp(`^${se}(:${se})?(?=\\W|$)`,"i"),fe=new RegExp(`^(?:(?=[RC])${se}${ie})`,"i"),pe=new RegExp(`^(${se}${ie}(:${ie}|:${se})(?![[\\d])|(${se}|${ie})(:${se}${ie}))(?=\\W|$)`,"i"),he=/^(?![CR]\b)[a-zA-Z\\_\u00a1-\uffff][a-zA-Z0-9\\_.?\u00a1-\uffff]{0,254}/i;function ge(e,t){return n=>{const l=t.exec(n);if(l)return{type:e,value:l[0]}}}const xe=/^'(?:[^[\]]+?)?(?:\[(.+?)\])?(?:[^[\]]+?)'$/,de=/^'\[(.+?)\]'$/;function me(e,t){const n=J.exec(e);if(n){const e=n[0];if(t.xlsx&&de.test(e)||xe.test(e))return{type:"context_quote",value:e}}const l=Q.exec(e);if(l){const[,e,n]=l;if(e&&n||n||e&&!n&&t.xlsx)return{type:"context",value:l[0]}}}function $e(e){const t=X(e);if(t){let n=t.length;for(;" "===e[n];)n++;if("!"!==e[n])return{type:o,value:t.token}}return null}const ye=/([RC])(\[?)(-?\d+)/gi,ve=/(\d+|[a-zA-Z]+)/gi;function Ee(e,t){let r,o;if(t.r1c1){if(t.allowTernary&&(r=pe.exec(e))?o={type:l,value:r[0]}:(r=fe.exec(e))?o={type:"range",value:r[0]}:((r=ae.exec(e))||(r=ce.exec(e)))&&(o={type:n,value:r[0]}),o){for(ye.lastIndex=0;null!==(r=ye.exec(o.value));){const e=("R"===r[1]?1048575:16383)+(r[2]?1:0),t=parseInt(r[3],10);if(t>=e||t<=-e)return null}return o}}else if(t.allowTernary&&(r=ue.exec(e))?o={type:l,value:r[0]}:(r=le.exec(e))||(r=re.exec(e))?o={type:n,value:r[0]}:(r=oe.exec(e))&&(o={type:"range",value:r[0]}),o){for(ve.lastIndex=0;null!==(r=ve.exec(o.value));)if(/^\d/.test(r[1])){if(parseInt(r[1],10)-1>1048575)return null}else if(O(r[1])>16383)return null;return o}}const Re=[ge(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),ge(e,/^(<=|>=|<>|[-+/*^%&<>=]|[{},;]|[()]|@|:|!|#)/),ge("func",/^[A-Z_]+[A-Z\d_.]*(?=\()/i),ge("bool",/^(TRUE|FALSE)\b/i),ge("newline",/^\n+/),ge("whitespace",/^[ \f\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/),ge("string",/^"(?:""|[^"])*("|$)/),me,Ee,$e,ge("number",/^(?:\d+(\.\d+)?(?:[eE][+-]?\d+)?|\d+)/),ge(r,he)],we=[function(t,n){return n.r1c1?"!"===t[0]?{type:e,value:t[0]}:null:"!"===t[0]||":"===t[0]?{type:e,value:t[0]}:null},me,Ee,$e,ge(r,he)],Ne={};function be(e,t){if(e.length){const n=e[0];t[n]=t[n]||{},be(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=>be(e.concat().reverse(),Ne)));const Ce=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 Ce(t,n[u],l,r+1)}return n.$?r:0};function Ae(e){const t=[];for(let n=e.length-1;n>=0;n--){let l=e[n];const r=Ce(e,Ne,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 Te=(e,t)=>e&&e.type===t,Ie={withLocation:!1,mergeRefs:!0,allowTernary:!1,negativeNumbers:!0,r1c1:!1},Le=e=>e.type===r||"func"===e.type,ke=t=>!Te(t,e)||"%"===t.value||"}"===t.value||")"===t.value||"#"===t.value;function Oe(t,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=Object.assign({},Ie,l),{withLocation:o,mergeRefs:s,negativeNumbers:i}=r,c=[];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&&Le(h)||n&&Le(e))?(h.value+=e.value,h.type=u,o&&(h.loc[1]=e.loc[1])):(c.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 m={type:x,value:d,...o?{loc:[l,a]}:{}};if("string"===x){const e=d.length;if('""'===d);else if('"'===d||'"'!==d[e-1])m.unterminated=!0;else if('""'!==d&&'"'===d[e-2]){let t=e-1;for(;'"'===d[t];)t--;!(t+1)^(e-t+1)%2==0&&(m.unterminated=!0)}}if(i&&"number"===x){const t=h;if(t&&Te(t,e)&&"-"===t.value&&(!p||Te(p,"fx_prefix")||!ke(p))){const e=c.pop();m.value="-"+d,o&&(m.loc[0]=e.loc[0]),f=p,h=c[c.length-1]}}g(m)}return s?Ae(c):c}function _e(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Oe(e,Re,t)}function Ue(e){return!!e&&("range"===e.type||e.type===n||e.type===l)}function Fe(e){return!!e&&("range"===e.type||e.type===n||e.type===l||e.type===o||e.type===r)}function Se(e){return!!e&&("bool"===e.type||e.type===t||"number"===e.type||"string"===e.type)}function Me(e){return!!e&&e.type===t}function De(e){return!!e&&("whitespace"===e.type||"newline"===e.type)}function je(e){return!!e&&"func"===e.type}function ze(e){return!!e&&"fx_prefix"===e.type}function We(t){return!!t&&t.type===e}const Ze="(END)",qe=["ANCHORARRAY","CHOOSE","DROP","IF","IFS","INDEX","INDIRECT","LAMBDA","LET","OFFSET","REDUCE","SINGLE","SWITCH","TAKE","XLOOKUP"],Be=e=>!!e&&(e.type===c||("ErrorLiteral"===e.type||e.type===t)&&"#REF!"===e.value||e.type===i&&(":"===e.operator||" "===e.operator||","===e.operator)||e.type===a&&qe.includes(e.callee.name.toUpperCase())),Pe={};let Xe,He,Ye,Ge=!1,Ke=!1;function Ve(e){const t=new Error(e);throw t.source=He.map((e=>e.value)).join(""),t.sourceOffset=He.slice(0,Ye).reduce(((e,t)=>e+t.value),"").length,t}function Qe(){let e,t=Ye;do{e=He[++t]}while(e&&(De(e)||We(e)&&"("===e.value));return(e=>{const t=(e&&e.value)+"";return!(!Fe(e)&&(!We(e)||":"!==t&&","!==t&&t.trim())&&(!je(e)||!qe.includes(t.toUpperCase()))&&(!Me(e)||"#REF!"!==t))})(e)}function Je(){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!==Xe.id&&Ve(`Expected ${e} but got ${Xe.id}`),De(He[Ye])){if(!(Be(t)&&Qe()))for(;De(He[Ye]);)Ye++}if(Ye>=He.length)return void(Xe=Pe[Ze]);const n=He[Ye];let l;Ye+=1,n.unterminated&&Ve("Encountered an unterminated token");let r=n.type;return We(n)?(l=Pe[n.value],l||Ve(`Unknown operator ${n.value}`)):De(n)?l=Pe["(WHITESPACE)"]:Se(n)?l=Pe.Literal:Fe(n)?(l=Pe[c],r=c):je(n)?l=Pe["(FUNCTION)"]:Ve(`Unexpected ${n.type} token: ${n.value}`),Xe=Object.create(l),Xe.type=r,Xe.value=n.value,n.loc&&(Xe.loc=[...n.loc]),Xe}function et(e){let t=Xe;Je(null,t);let n=t.nud();for(;e<Xe.lbp;)t=Xe,Je(null,t),n=t.led(n);return n}const tt={nud:()=>Ve("Invalid syntax"),led:()=>Ve("Missing operator")};function nt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Pe[e];return n?t>=n.lbp&&(n.lbp=t):(n={...tt},n.id=e,n.value=e,n.lbp=t,Pe[e]=n),n}function lt(e,t,n){const l=nt(e,t);return l.led=n||function(e){this.type=i,this.operator=this.value,delete this.value;const n=et(t);return this.arguments=[e,n],this.loc&&(this.loc=[e.loc[0],n.loc[1]]),this},l}function rt(e,t){const n=nt(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 ot(e,t){const n=nt(e);return n.nud=t||function(){this.type=s,this.operator=this.value,delete this.value;const e=et(70);return this.arguments=[e],this.loc&&(this.loc[1]=e.loc[1]),this},n}function ut(e,t){return lt(e,t,(function(n){Be(n)||Ve(`Unexpected ${e} operator`);const l=et(t);return Be(l)||Ve(`Unexpected ${Xe.type} following ${this.id}`),this.type=i,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}))}nt(Ze),ut(":",80);const st=ut(",",80);ut("(WHITESPACE)",80);const it=e=>{const t=st.lbp>0;return null!=e&&(st.lbp=e?80:0),t};function ct(){let e=1;return()=>"fxg"+e++}function at(e,t){return null==e&&null==t||e===t}function ft(e,t){if(Array.isArray(e)!==Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!at(e[n],t[n]))return!1;return!0}function pt(e,t){return!e&&!t||String(e).toLowerCase()===String(t).toLowerCase()}function ht(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(!ft(e.columns,t.columns))return!1;if(!ft(e.sections,t.sections))return!1}return!!(!e.range&&!t.range||at(e.range.top,t.range.top)&&at(e.range.bottom,t.range.bottom)&&at(e.range.left,t.range.left)&&at(e.range.right,t.range.right))&&!(!pt(e.workbookName,t.workbookName)||!pt(e.sheetName,t.sheetName))}function gt(e,t,n){return e.sheetName||(e.sheetName=t),e.workbookName||(e.workbookName=n),e}rt("%"),rt("#",(function(e){return Be(e)||Ve("# expects a reference"),this.type=s,this.operator=this.value,delete this.value,this.arguments=[e],this})),ot("+"),ot("-"),ot("@"),lt("^",50),lt("*",40),lt("/",40),lt("+",30),lt("-",30),lt("&",20),lt("=",10),lt("<",10),lt(">",10),lt("<=",10),lt(">=",10),lt("<>",10),nt("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},nt(c).nud=function(){return this.type=c,this},nt(")"),ot("(",(function(){const e=it(!0),t=et(0);return Je(")",t),it(e),t})),nt("(FUNCTION)").nud=function(){return this},lt("(",90,(function(e){"(FUNCTION)"!==e.id&&Ve("Cannot call a "+e.type);const t=[];let n=!1;if(")"!==Xe.id){const e=it(!1);for(;")"!==Xe.id;)if(De(Xe)&&Je(),","===Xe.id)t.push(null),n=!0,Je();else{const e=et(0);t.push(e),n=!1,","===Xe.id&&(Je(","),n=!0)}it(e)}n&&t.push(null);const l=Xe;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]]),Je(")",this),this})),nt("}"),nt(";"),ot("{",(function(){"}"===Xe.id&&Ve("Unexpected empty array");let e=[],t=!1;const n=[e],l=it(!1);for(;!t;){if(De(Xe)&&Je(),Se(Xe))e.push(Pe.Literal.nud.call(Xe)),Je();else if(Ge&&Be(Xe))e.push(Pe[c].nud.call(Xe)),Je();else if(Ke&&je(Xe)){const t=et(0);e.push(t)}else Ve(`Unexpected ${Xe.type} in array: ${Xe.value}`);","===Xe.id?Je(","):";"===Xe.id?(Je(";"),e=[],n.push(e)):t=!0}const r=Xe;return Je("}"),it(l),this.type="ArrayExpression",this.elements=n,this.loc&&(this.loc[1]=r.loc[1]),delete this.value,this}));const xt=(e,t,n)=>Math.min(Math.max(t,e),n);function dt(e,t){return t?String(e+1):e?"["+e+"]":""}function mt(e){let{r0:t,c0:n,r1:l,c1:r}=e;const{$c0:o,$c1:u,$r0:s,$r1:i}=e,c=null==t,a=null==n;let f=null==l,p=null==r;if(t=xt(s?0:-1048575,0|t,1048575),n=xt(o?0:-16383,0|n,16383),!c&&f&&!a&&p?(l=t,f=!1,r=n,p=!1):(l=xt(i?0:-1048575,0|l,1048575),r=xt(u?0:-16383,0|r,16383)),0===t&&l>=1048575||c&&f){const e=dt(n,o),t=dt(r,u);return"C"+(e===t?e:e+":C"+t)}if(0===n&&r>=16383||a&&p){const e=dt(t,s),n=dt(l,i);return"R"+(e===n?e:e+":R"+n)}const h=dt(t,s),g=dt(l,i),x=dt(n,o),d=dt(r,u);return c||f||a||p?(c?"":"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 $t(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 yt(e){let t=null;const[n,l]=e.split(":",2),r=$t(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=$t(l);if(!r)return null;{t={};const[l,s,i,c]=r;null!=e&&null!=l?(t.r0=o===i?Math.min(e,l):e,t.$r0=o,t.r1=o===i?Math.max(e,l):l,t.$r1=i):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=i,t.r1=null,t.$r1=i):null==e&&null==l&&(t.r0=null,t.$r0=!1,t.r1=null,t.$r1=!1),null!=n&&null!=s?(t.c0=u===c?Math.min(n,s):n,t.$c0=u,t.c1=u===c?Math.max(n,s):s,t.$c1=c):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=c,t.c1=null,t.$c1=c):null==n&&null==s&&(t.c0=null,t.$c0=!1,t.c1=null,t.$c1=!1)}}}return t}function vt(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?yt(r.r0+":"+r.r1):yt(r.r0);return r.name||e?(r.range=e,delete r.r0,delete r.r1,r):null}return null}function Et(e){let{xlsx:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t?T(e):A(e);return n+(e.name?e.name:mt(e.range))}const Rt=(e,t,n)=>null==t?null:e?t:t-n,wt={withLocation:!1,mergeRefs:!1,allowTernary:!0,r1c1:!1};function Nt(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 bt={wrapEdges:!0,mergeRefs:!0,xlsx:!1};const Ct=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}),At=Object.freeze({UNARY:s,BINARY:i,REFERENCE:c,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 i=null;const c=ct(),a=[],f=()=>s.length+(i?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=c();e.groupId=n,e.depth=t.depth,t.groupId=n}else e.error=!0}else if("{"===e.value)i?e.error=!0:(i=e,e.depth=f());else if("}"===e.value){if(i){const t=c();e.groupId=t,e.depth=i.depth,i.groupId=t}else e.error=!0;i=null}else if("range"===e.type||e.type===n||e.type===l||e.type===o){const n=e.type===o?H(e.value,{allowTernary:!0,xlsx:!0}):M(e.value,{allowTernary:!0,xlsx:!0});if(n&&(n.range||n.columns)){n.source=e.value,gt(n,t,r);const l=a.find((e=>ht(e,n)));l?e.groupId=l.groupId:(n.groupId=c(),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(_e(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=V(H(t.value,{xlsx:u}),{xlsx:u});n=e.length-t.value.length,t.value=e}else if(Ue(t)){const e=M(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=O,exports.isError=Me,exports.isFunction=je,exports.isFxPrefix=ze,exports.isLiteral=Se,exports.isOperator=We,exports.isRange=Ue,exports.isReference=Fe,exports.isWhitespace=De,exports.mergeRefTokens=Ae,exports.nodeTypes=At,exports.parse=function(e,t){if("string"==typeof e)He=_e(e,{withLocation:!1,...t,mergeRefs:!0});else{if(!Array.isArray(e))throw new Error("Parse requires a string or array of tokens.");He=e}for(Ge=t?.permitArrayRanges,Ke=t?.permitArrayCalls,Ye=0;De(He[Ye])||ze(He[Ye]);)Ye++;Je(),it(!0);const n=et(0);return Je(Ze),n},exports.parseA1Ref=M,exports.parseR1C1Ref=vt,exports.parseStructRef=H,exports.stringifyA1Ref=D,exports.stringifyR1C1Ref=Et,exports.stringifyStructRef=V,exports.toCol=_,exports.tokenTypes=Ct,exports.tokenize=_e,exports.translateToA1=function(e,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:bt;const r=S(n),o="string"==typeof e,u={...bt,...l},s=o?_e(e,{withLocation:!1,mergeRefs:u.mergeRefs,xlsx:u.xlsx,allowTernary:!0,r1c1:!0}):e;let i=0;const c={xlsx:u.xlsx,allowTernary:!0};return s.forEach((e=>{if(Ue(e)){const n=e.value,l=vt(n,c),o=l.range,s={},a=Nt(o.r0,o.$r0,r.top,1048575,u.wrapEdges),f=Nt(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=Nt(o.c0,o.$c0,r.left,16383,u.wrapEdges),h=Nt(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,c)),e.loc&&(e.loc[0]+=i,i+=e.value.length-n.length,e.loc[1]+=i)}else i&&e.loc&&(e.loc[0]+=i,e.loc[1]+=i)})),o?s.map((e=>e.value)).join(""):s},exports.translateToR1C1=function(e,t){let{xlsx:n=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{top:l,left:r}=S(t),o="string"==typeof e,u=o?_e(e,{...wt,xlsx:n}):e;let s=0;const i={xlsx:n,allowTernary:!0};return u.forEach((e=>{if(Ue(e)){const t=e.value,n=M(t,i),o=n.range,u={};u.r0=Rt(o.$top,o.top,l),u.r1=Rt(o.$bottom,o.bottom,l),u.c0=Rt(o.$left,o.left,r),u.c1=Rt(o.$right,o.right,r),u.$r0=o.$top,u.$r1=o.$bottom,u.$c0=o.$left,u.$c1=o.$right,n.range=u,e.value=Et(n,i),e.loc&&(e.loc[0]+=s,s+=e.value.length-t.length,e.loc[1]+=s)}else s&&e.loc&&(e.loc[0]+=s,e.loc[1]+=s)})),o?u.map((e=>e.value)).join(""):u};
|
|
2
2
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnguanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|