forked from fabiooshiro/xlsx-calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxlsx-calc.js
2 lines (2 loc) · 20.6 KB
/
xlsx-calc.js
1
2
!function(r,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t=e();for(var n in t)("object"==typeof exports?exports:r)[n]=t[n]}}(this,(function(){return function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=8)}([function(r,e,t){"use strict";r.exports=function(r){this.setValue=function(e){r=e},this.calc=function(){return r}}},function(r,e,t){"use strict";r.exports=function(r){for(var e,t=r+1,n="",o=10;t>0&&o--;)e=(t-1)%26,n=String.fromCharCode(e+65)+n,t=(t-e-1)/26;return n}},function(r,e,t){"use strict";r.exports=function(r){for(var e=0,t=r.replace(/[0-9]+$/,""),n=t.length;n--;)e+=Math.pow(26,t.length-n-1)*(t.charCodeAt(n)-64);return e-1}},function(r,e,t){"use strict";const n=t(2),o=t(1),i=t(4);r.exports=function(r,e){this.calc=function(){var t,a,f;if(-1!=r.indexOf("!")){var u=r.split("!");a=i(u[0]),t=u[1]}else a=e.sheet_name,t=r;f=e.wb.Sheets[a];var s,l=t.split(":"),c=parseInt(l[0].replace(/^[A-Z]+/,""),10)||0,h=l[1].replace(/^[A-Z]+/,"");""===h&&f["!ref"]&&(h=f["!ref"].split(":")[1].replace(/^[A-Z]+/,"")),s=parseInt(""==h?"500000":h,10);for(var p=n(l[0]),g=n(l[1]),v=[],w=c;w<=s;w++){var A=[];v.push(A);for(var m=p;m<=g;m++){var x=o(m)+w,y=a+"!"+x;if(e.formula_ref[y]){if("new"===e.formula_ref[y].status)e.exec_formula(e.formula_ref[y]);else if("working"===e.formula_ref[y].status)throw new Error("Circular ref");"e"===f[x].t?A.push(f[x]):A.push(f[x].v)}else f[x]?"e"===f[x].t?A.push(f[x]):A.push(f[x].v):A.push(null)}}return v}}},function(r,e,t){"use strict";r.exports=function(r){var e=r.match(/^'(.*)'$/);return e?e[1]:r}},function(r,e,t){const n=t(0),o=t(6),i=t(12),a=t(3);r.exports=function r(e,t){if(!isNaN(e))return new n(+e);if("TRUE"===e)return new n(1);if("string"!=typeof e)return e;if((e=e.trim().replace(/\$/g,"")).match(/^[A-Z]+[0-9]+:[A-Z]+[0-9]+$/))return new a(e,t);if(e.match(/^[^!]+![A-Z]+[0-9]+:[A-Z]+[0-9]+$/))return new a(e,t);if(e.match(/^[A-Z]+:[A-Z]+$/))return new a(e,t);if(e.match(/^[^!]+![A-Z]+:[A-Z]+$/))return new a(e,t);if(e.match(/^[A-Z]+[0-9]+$/))return new o(e,t);if(e.match(/^[^!]+![A-Z]+[0-9]+$/))return new o(e,t);if(e.match(/%$/)){var f=r(e.substr(0,e.length-1),t);return new i(()=>f.calc()/100)}return e}},function(r,e,t){"use strict";const n=t(4);r.exports=function(r,e){var t=this;this.name="RefValue",this.str_expression=r,this.formula=e,t.parseRef=function(){var t,o,i;if(-1!=r.indexOf("!")){var a=r.split("!");o=n(a[0]),t=e.wb.Sheets[o],i=a[1]}else t=e.sheet,o=e.sheet_name,i=r;if(!t)throw Error("Sheet "+o+" not found.");return{sheet:t,sheet_name:o,cell_name:i,cell_full_name:o+"!"+i}},this.calc=function(){var r=t.parseRef(),n=r.sheet,o=r.cell_name,i=r.cell_full_name,a=n[o];if(!a)return null;var f=e.formula_ref[i];if(!f){if("e"===a.t)throw console.log("ref is an error with no formula",o),new Error(a.w);return a.v}if("new"===f.status){if(e.exec_formula(f),"e"===a.t)throw console.log("ref is an error with new formula",i,a.w),new Error(a.w);return a.v}if("working"===f.status)throw new Error("Circular ref");if("done"===f.status){if("e"===a.t)throw console.log("ref is an error after formula eval",i,a.w),new Error(a.w);return a.v}}}},function(r,e,t){"use strict";r.exports=function(r,e){let t={},n=[];for(let o in r.Sheets){let i=r.Sheets[o];for(let a in i)if(i[a]&&i[a].f){let f=t[o+"!"+a]={formula_ref:t,wb:r,sheet:i,sheet_name:o,cell:i[a],name:a,status:"new",exec_formula:e};n.push(f)}}return n}},function(r,e,t){"use strict";const n=t(1),o=t(2),i=t(9),a=t(7),f=t(17);var u=function(r){for(var e=a(r,i),t=e.length-1;t>=0;t--)i(e[t])};u.calculator=function(r){return new f(r,i)},u.set_fx=i.set_fx,u.exec_fx=i.exec_fx,u.col_str_2_int=o,u.int_2_col_str=n,u.import_functions=i.import_functions,u.import_raw_functions=i.import_raw_functions,u.xlsx_Fx=i.xlsx_Fx,u.localizeFunctions=i.localizeFunctions,u.XLSX_CALC=u,r.exports=u},function(r,e,t){"use strict";const n=t(10);let o={},i={};function a(r,e){for(var t in r)i[t]=r[t]}function f(r,e){var t=(e=e||{}).prefix||"";for(var n in r){var i=r[n];"function"==typeof i?!e.override&&o[t+n]||(o[t+n]=i):"object"==typeof i&&f(i,u(e,{prefix:n+"."}))}}function u(r,e){var t=JSON.parse(JSON.stringify(r));for(var n in e)t[n]=e[n];return t}function s(r){return n(r,{xlsx_Fx:o,xlsx_raw_Fx:i})}function l(r){s(r).update_cell_value()}f(t(15)),a(t(16)),l.set_fx=function(r,e){o[r]=e},l.exec_fx=function(r,e){return o[r].apply(this,e)},l.localizeFunctions=function(r){for(let e in r){let t=r[e];o[t]&&(o[e]=o[t]),i[t]&&(i[e]=i[t])}},l.import_functions=f,l.import_raw_functions=a,l.build_expression=s,l.xlsx_Fx=o,r.exports=l},function(r,e,t){const n=t(11),o=t(0),i=t(13),a=t(14),f={"*":"multiply","+":"plus","-":"minus","/":"divide","^":"power","&":"concat","<":"lt",">":"gt","=":"eq"};r.exports=function(r,e){r.status="working";var t,u=e.xlsx_Fx||{},s=e.xlsx_raw_Fx||{},l=r.cell.f;"="==l[0]&&(l=l.substr(1));var c=t=new n(r),h="",p=!1,g=[{exp:c}];function v(r){'"'===r?(c.push(new o(h)),p=!0,h="",m=A):h+=r}function w(r){"'"===r&&(m=A),h+=r}function A(e){var t,o;'"'===e?(m=v,h=""):"'"===e?(m=w,h="'"):"("===e?function(){var e,t=h.trim(),o=u[t],f=s[t];if(f)o=new a(f,r);else if(o)o=new i(o,r);else if(t)throw new Error('"'+r.sheet_name+'"!'+r.name+": Function "+h+" not found");e=new n(r),g.push({exp:e,special:o}),c=e,h=""}():")"===e?(o=g.pop(),(c=o.exp).push(h),t=c,h="",c=g[g.length-1].exp,o.special?(o.special.push(t),c.push(o.special)):c.push(t)):f[e]?function(r){p||c.push(h),p=!1,c.push(r),h=""}(e):","===e&&g[g.length-1].special?(p=!1,g[g.length-1].exp.push(h),g[g.length-1].special.push(g[g.length-1].exp),g[g.length-1].exp=c=new n(r),h=""):h+=e}for(var m=A,x=0;x<l.length;x++)m(l[x]);return t.push(h),t}},function(r,e,t){"use strict";const n=t(0),o=t(3),i=t(5);var a=0;r.exports=function(r){var e,t=this;function f(r){return null==r||""===r}function u(r){if("function"!=typeof r.calc)throw new Error("Undefined "+r)}function s(r,e,t){for(var o=0;o<e.length;o++)if(e[o]===r)try{if(0===o&&"+"===r){u(e[o+1]);let r=e[o+1].calc();e.splice(o,2,new n(r))}else{u(e[o-1]),u(e[o+1]);let r=t(e[o-1].calc(),e[o+1].calc());e.splice(o-1,3,new n(r)),o--}}catch(r){throw r}}t.id=++a,t.args=[],t.name="Expression",t.update_cell_value=function(){try{if(Array.isArray(t.args)&&1===t.args.length&&t.args[0]instanceof o)throw Error("#VALUE!");r.cell.v=t.calc(),"string"==typeof r.cell.v?r.cell.t="s":"number"==typeof r.cell.v&&(r.cell.t="n")}catch(t){var e={"#NULL!":0,"#DIV/0!":7,"#VALUE!":15,"#REF!":23,"#NAME?":29,"#NUM!":36,"#N/A":42,"#GETTING_DATA":43};if(void 0===e[t.message])throw t;r.cell.t="e",r.cell.w=t.message,r.cell.v=e[t.message]}finally{r.status="done"}},t.formula=r,t.calc=function(){let r=t.args.concat();if(function(r){for(var e=r.length;e--;)if("-"===r[e]){u(r[e+1]);var t=r[e+1].calc();if(e>0&&"string"!=typeof r[e-1]){if(r.splice(e,1,"+"),t instanceof Date){t=Date.parse(t),u(r[e-1]);var o=r[e-1].calc();o instanceof Date&&(o=Date.parse(o)/864e5,t/=864e5,r.splice(e-1,1,new n(o)))}r.splice(e+1,1,new n(-t))}else{if("string"==typeof t)throw new Error("#VALUE!");r.splice(e,2,new n(-t))}}}(r),s("^",r,(function(r,e){return Math.pow(+r,+e)})),s("/",r,(function(r,e){if(0==e)throw Error("#DIV/0!");return+r/+e})),s("*",r,(function(r,e){return+r*+e})),s("+",r,(function(r,e){return r instanceof Date&&"number"==typeof e&&(e*=864e5),+r+ +e})),s("&",r,(function(r,e){return""+r+e})),s("<",r,(function(r,e){return r<e})),s(">",r,(function(r,e){return r>e})),s(">=",r,(function(r,e){return r>=e})),s("<=",r,(function(r,e){return r<=e})),s("<>",r,(function(r,e){return r instanceof Date&&e instanceof Date?r.getTime()!==e.getTime():(!f(r)||!f(e))&&r!=e})),s("=",r,(function(r,e){return r instanceof Date&&e instanceof Date?r.getTime()===e.getTime():!(!f(r)||!f(e))||(null==r&&0===e||0===r&&null==e||("string"==typeof r&&"string"==typeof e&&r.toLowerCase()===e.toLowerCase()||r==e))})),1==r.length)return"function"!=typeof r[0].calc?r[0]:r[0].calc()},t.push=function(n){if(n){var o=i(n,r);"="===o&&(">"==e||"<"==e)||"<"==e&&">"===o?t.args[t.args.length-1]+=o:t.args.push(o),e=o}}}},function(r,e,t){"use strict";r.exports=function(r){this.calc=function(){return r()}}},function(r,e,t){"use strict";r.exports=function(r){var e=this;e.name="UserFn",e.args=[],e.calc=function(){var t,n={"#NULL!":0,"#DIV/0!":7,"#VALUE!":15,"#REF!":23,"#NAME?":29,"#NUM!":36,"#N/A":42,"#GETTING_DATA":43};try{t=r.apply(e,e.args.map(r=>r.calc()))}catch(e){if("is_blank"===r.name&&void 0!==n[e.message])t=0;else{if("iserror"!==r.name||void 0===n[e.message])throw e;t=!0}}return t},e.push=function(r){e.args.push(r)}}},function(r,e,t){"use strict";r.exports=function(r,e){var t=this;t.name="UserRawFn",t.args=[],t.calc=function(){try{return r.apply(t,t.args)}catch(r){throw r}},t.push=function(r){t.args.push(r)}}},function(r,e,t){"use strict";let n={FLOOR:Math.floor,"_xlfn.FLOOR.MATH":Math.floor,"FLOOR.MATH":Math.floor,ABS:Math.abs,SQRT:Math.sqrt,VLOOKUP:function(r,e,t){for(var n=0;n<e.length;n++)if(e[n][0]==r)return e[n][t-1];throw Error("#N/A")},MAX:function(){for(var r=null,e=arguments.length;e--;){var t=arguments[e];if(Array.isArray(t))for(var n=t,o=n.length;o--;){var i=n[o];if(Array.isArray(i))for(var a=i.length;a--;)(null==r||null!=i[a]&&r<i[a])&&(r=i[a]);else(null==r||null!=i&&r<i)&&(r=i)}else!isNaN(t)&&(null==r||null!=t&&r<t)&&(r=t)}return r},SUM:v,MIN:function(){for(var r=null,e=arguments.length;e--;){var t=arguments[e];if(Array.isArray(t))for(var n=t,o=n.length;o--;){var i=n[o];if(Array.isArray(i))for(var a=i.length;a--;)(null==r||null!=i[a]&&r>i[a])&&(r=i[a]);else(null==r||null!=i&&r>i)&&(r=i)}else!isNaN(t)&&(null==r||null!=t&&r>t)&&(r=t)}return r},CONCATENATE:function(){for(var r="",e=0;e<arguments.length;e++){var t=arguments[e];null!=t&&(r+=t)}return r},PMT:function(r,e,t,n,o){if(o=o||0,n=n||0,0!=r){var i=Math.pow(1+r,e);return-r*(n+i*t)/((-1+i)*(1+r*o))}if(0!=e)return-(n+t)/e;return 0},COUNTA:g,IRR:function(r,e){var t=-2,n=1,o=0;do{for(var i=(t+n)/2,a=0,f=0;f<r.length;f++){var u=r[f];a+=u[0]/Math.pow(1+i,f)}a>0?(t===n&&(n+=Math.abs(i)),t=i):n=i,o++}while(Math.abs(a)>1e-6&&o<1e5);return i},"NORM.INV":p,"_xlfn.NORM.INV":p,STDEV:function(){var r=l(arguments);function e(r){return r.reduce((function(r,e){return r+e}))/r.length}var t=e(r),n=r.map((function(r){return(r-t)*(r-t)}));return Math.sqrt(n.reduce((function(r,e){return r+e}))/(r.length-1))},AVERAGE:h,EXP:function(r){return Math.pow(Math.E,r)},LN:Math.log,"_xlfn.VAR.P":c,"VAR.P":c,"_xlfn.COVARIANCE.P":s,"COVARIANCE.P":s,TRIM:function(r){return(""+r).trim()},LEN:function(r){return(""+r).length},ISBLANK:u,HLOOKUP:function(r,e,t,n){if(void 0===r||u(r))throw Error("#N/A");t=t||0;let o,i,a=e[0];if("string"==typeof r){for(i=r.toLowerCase(),o=0;o<a.length;o++)if(n&&a[o]===i||-1!==a[o].toLowerCase().indexOf(i))return t<e.length+1?e[t-1][o]:e[0][o]}else for(i=r,o=0;o<a.length;o++)if(n&&a[o]===i||a[o]===i)return t<e.length+1?e[t-1][o]:e[0][o];throw Error("#N/A")},INDEX:function(r,e,t){if(e<=r.length){var n=r[e-1];if(!Array.isArray(n))return r[e];if(!t)return n;if(t<=n.length)return n[t-1]}throw Error("#REF!")},MATCH:function(r,e,t){Array.isArray(e)&&1===e.length&&Array.isArray(e[0])&&(e=e[0]);if(!r&&!e)throw Error("#N/A");2===arguments.length&&(t=1);if(!(e instanceof Array))throw Error("#N/A");if(0===t)return"string"==typeof r?i(e,r):a(e,r);if(1===t)return o(e,r);if(-1===t)return f(e,r);throw Error("#N/A")},SUMPRODUCT:function(){var r=function(r){return void 0===r||""===r||null===r||isNaN(r)?0:parseFloat(r)},e=function(r){for(var e=function(r){return r.length},t=function(r){return r[0].length},n=e(r[0]),o=t(r[0]),i=1;i<r.length;i++)if(e(r[i])!==n||t(r[i])!==o)return!1;return!0};if(!arguments||0===arguments.length)throw Error("#VALUE!");if(!e(arguments))throw Error("#VALUE!");for(var t=0;t<arguments.length;t++){var n=arguments[t];if(Array.isArray(n))for(var o=0;o<n.length;o++){var i=n[o];if(Array.isArray(i))for(var a=0;a<i.length;a++){var f;if((f=i[a])&&"object"==typeof f&&"e"===f.t)throw Error(f.w)}else if((f=i)&&"object"==typeof f&&"e"===f.t)throw Error(f.w)}else if((f=n)&&"object"==typeof f&&"e"===f.t)throw Error(f.w)}var u,s,l,c=arguments.length+1,h=0;for(t=0;t<arguments[0].length;t++)if(arguments[0][t]instanceof Array)for(o=0;o<arguments[0][t].length;o++){for(u=1,a=1;a<c;a++)l=r(arguments[a-1][t][o]),u*=l;h+=u}else{for(u=1,a=1;a<c;a++)s=r(arguments[a-1][t]),u*=s;h+=u}return h},ISNUMBER:function(r){return!isNaN(r)},TODAY:function(){var r=new Date;return r.setHours(0,0,0,0),r},ISERROR:function(){return!1},TIME:function(r,e,t){return 1e3*(60*(60*r+e)+t)/864e5},DAY:function(r){if(!r.getDate)throw Error("#VALUE!");var e=r.getDate();if(isNaN(e))throw Error("#VALUE!");return e},MONTH:function(r){if(!r.getMonth)throw Error("#VALUE!");var e=r.getMonth();if(isNaN(e))throw Error("#VALUE!");return e+1},YEAR:function(r){if(!r.getFullYear)throw Error("#VALUE!");var e=r.getFullYear();if(isNaN(e))throw Error("#VALUE!");return e},RIGHT:function(r,e){if(e=void 0===e?1:parseFloat(e),isNaN(e))throw Error("#VALUE!");r=null==r?"":""+r;return r.substring(r.length-e)},LEFT:function(r,e){if(e=void 0===e?1:parseFloat(e),isNaN(e))throw Error("#VALUE!");r=null==r?"":""+r;return r.substring(0,e)},IFS:function(){for(var r=0;r+1<arguments.length;r+=2){var e=arguments[r],t=arguments[r+1];if(e)return t}throw Error("#N/A")},ROUND:function(r,e){if(0===arguments.length)throw new Error("Err:511");if(1===arguments.length)return Math.round(r);let t=Math.pow(10,e);return Math.round(t*r)/t},CORREL:function(r,e){if(r=l(r),e=l(e),r.length!==e.length)return"N/D";for(var t=1/(r.length-1),n=v.apply(this,r)/r.length,o=v.apply(this,e)/e.length,i=0,a=0,f=0,u=0;u<r.length;u++)i+=(r[u]-n)*(e[u]-o),a+=Math.pow(r[u],2),f+=Math.pow(e[u],2);return a=Math.sqrt(a/t),f=Math.sqrt(f/t),i/(t*a*f)},SUMIF:function(){let r=arguments[1],e=0;return[].slice.call(arguments)[0][0].forEach((t,n)=>{null!==t&&t.replace(/\'/g,"")===r&&(isNaN([].slice.call(arguments)[2][0][n])||(e+=[].slice.call(arguments)[2][0][n]))}),e},CHOOSE:function(r){return arguments[r]},SUBSTITUTE:function(r,e,t,n){if(n<=0)throw Error("#VALUE!");if(!r||!e||!t&&""!==t)return r;if(void 0===n)return r.replace(new RegExp(e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),t);for(var o=0,i=0;r.indexOf(e,o)>0;)if(o=r.indexOf(e,o+1),++i===n)return r.substring(0,o)+t+r.substring(o+e.length)}};function o(r,e){for(var t,n,o=0;o<r.length;o++){if(r[o]===e)return o+1;r[o]<e&&(n?r[o]>n&&(t=o+1,n=r[o]):(t=o+1,n=r[o]))}if(!t)throw Error("#N/A");return t}function i(r,e){for(var t=0;t<r.length;t++)if(e=e.replace(/\?/g,"."),Array.isArray(r[t])){if(1===r[t].length&&"string"==typeof r[t][0]&&r[t][0].toLowerCase()===e.toLowerCase())return t+1}else if("string"==typeof r[t]&&r[t].toLowerCase()===e.toLowerCase())return t+1;throw Error("#N/A")}function a(r,e){for(var t=0;t<r.length;t++)if(Array.isArray(r[t])){if(1===r[t].length&&r[t][0]===e)return t+1}else if(r[t]===e)return t+1;throw Error("#N/A")}function f(r,e){for(var t,n,o=0;o<r.length;o++)if(Array.isArray(r[o])&&r[o].length>0){if(r[o][0]===e)return o+1;r[o][0]>e&&(n?r[o][0]<n&&(t=o+1,n=r[o][0]):(t=o+1,n=r[o][0]))}else{if(r[o]===e)return o+1;r[o]>e&&(n?r[o]<n&&(t=o+1,n=r[o]):(t=o+1,n=r[o]))}if(!t)throw Error("#N/A");return t}function u(r){return!r}function s(r,e){if(r=l(r),e=l(e),r.length!=e.length)return"N/D";for(var t=1/r.length,n=v.apply(this,r)/r.length,o=v.apply(this,e)/e.length,i=0,a=0;a<r.length;a++)i+=(r[a]-n)*(e[a]-o);return i*t}function l(r){for(var e=[],t=0;t<r.length;t++){var n=r[t];if(Array.isArray(n)){for(var o=n,i=o.length;i--;)if("number"==typeof o[i])e.push(o[i]);else if(Array.isArray(o[i]))for(var a=o[i].length;a--;)"number"==typeof o[i][a]&&e.push(o[i][a])}else"number"==typeof n&&e.push(n)}return e}function c(){for(var r=h.apply(this,arguments),e=0,t=0,n=0;n<arguments.length;n++){var o=arguments[n];if(Array.isArray(o))for(var i=o,a=i.length;a--;)for(var f=i[a].length;f--;)null!==i[a][f]&&void 0!==i[a][f]&&(e+=Math.pow(i[a][f]-r,2),t++);else e+=Math.pow(o-r,2),t++}return e/t}function h(){return v.apply(this,arguments)/g.apply(this,arguments)}function p(r,e,t){if(r<0||r>1)throw"The probality p must be bigger than 0 and smaller than 1";if(t<0)throw"The standard deviation sigma must be positive";return 0==r?-1/0:1==r?1/0:0==t?e:(n=r-.5,Math.abs(n)<=.425?i=n*(((((((2509.0809287301227*(o=.180625-n*n)+33430.57558358813)*o+67265.7709270087)*o+45921.95393154987)*o+13731.69376550946)*o+1971.5909503065513)*o+133.14166789178438)*o+3.3871328727963665)/(((((((5226.495278852854*o+28729.085735721943)*o+39307.89580009271)*o+21213.794301586597)*o+5394.196021424751)*o+687.1870074920579)*o+42.31333070160091)*o+1):(o=n>0?1-r:r,i=(o=Math.sqrt(-Math.log(o)))<=5?(((((((.0007745450142783414*(o+=-1.6)+.022723844989269184)*o+.2417807251774506)*o+1.2704582524523684)*o+3.6478483247632045)*o+5.769497221460691)*o+4.630337846156546)*o+1.4234371107496835)/(((((((1.0507500716444169e-9*o+.0005475938084995345)*o+.015198666563616457)*o+.14810397642748008)*o+.6897673349851)*o+1.6763848301838038)*o+2.053191626637759)*o+1):(((((((2.0103343992922881e-7*(o+=-5)+27115555687434876e-21)*o+.0012426609473880784)*o+.026532189526576124)*o+.29656057182850487)*o+1.7848265399172913)*o+5.463784911164114)*o+6.657904643501103)/(((((((20442631033899397e-31*o+1.421511758316446e-7)*o+18463183175100548e-21)*o+.0007868691311456133)*o+.014875361290850615)*o+.1369298809227358)*o+.599832206555888)*o+1),n<0&&(i=-i)),e+t*i);var n,o,i}function g(){for(var r=0,e=arguments.length;e--;){var t=arguments[e];if(Array.isArray(t))for(var n=t,o=n.length;o--;)for(var i=n[o].length;i--;)null!==n[o][i]&&void 0!==n[o][i]&&r++;else null!=t&&r++}return r}function v(){for(var r=0,e=arguments.length;e--;){var t=arguments[e];if(Array.isArray(t))for(var n=t,o=n.length;o--;)for(var i=n[o].length;i--;)isNaN(n[o][i])||(r+=+n[o][i]);else r+=+t}return r}r.exports=n},function(r,e,t){"use strict";const n=t(1),o=t(2),i=t(0),a=t(3),f=t(6);r.exports={OFFSET:function(r,e,t,u,s){if(u=(u||new i(1)).calc(),s=(s||new i(1)).calc(),1===r.args.length&&"RefValue"===r.args[0].name){var l=r.args[0],c=l.parseRef(),h=o(c.cell_name)+t.calc(),p=n(h),g=+c.cell_name.replace(/^[A-Z]+/g,"")+e.calc(),v=p+g;if(1===u&&1===s)return new f(v,l.formula).calc();var w=n(h+s-1)+(g+u-1),A=c.sheet_name+"!"+v+":"+w;return new a(A,l.formula).calc()}},IFERROR:function(r,e){try{var t=r.calc();return"number"!=typeof t||!isNaN(t)&&t!==1/0&&t!==-1/0?t:e.calc()}catch(r){return e.calc()}},IF:function(r,e,t){return r.calc()?e.calc():void 0!==t&&t.calc()},AND:function(){for(var r=0;r<arguments.length;r++)if(!arguments[r].calc())return!1;return!0},OR:function(){for(var r=0;r<arguments.length;r++)if(arguments[r].calc())return!0;return!1},TRANSPOSE:function(r){let e=r.args[0].calc(),t=r.formula.name.match(/([A-Z]+)([0-9]+)/),i=r.formula.sheet,a=o(t[1]),f=+t[2];for(let r=0;r<e.length;r++){let t=e[r];for(let e=0;e<t.length;e++){let o=a+r,u=f+e,s=t[e];i[n(o)+u].v=s}}return e[0][0]}}},function(r,e,t){"use strict";const n=t(0),o=t(5),i=t(7);r.exports=class{constructor(r,e){this.workbook=r,this.expressions=[],this.exec_formula=e,this.variables={},this.formulas=i(r,e);for(let r=this.formulas.length-1;r>=0;r--){let t=e.build_expression(this.formulas[r]);this.expressions.push(t)}this.calcNames()}setVar(r,e){let t=this.variables[r];t?t.setValue(e):this.expressions.forEach(t=>{this.setVarOfExpression(t,r,e)})}getVars(){let r={};for(let e in this.variables)r[e]=this.variables[e].calc();return r}calcNames(){this.workbook&&this.workbook.Workbook&&this.workbook.Workbook.Names&&this.workbook.Workbook.Names.forEach(r=>{let e=this.getRef(r.Ref);this.variables[r.Name]=e,this.expressions.forEach(e=>{this.setVarOfExpression(e,r.Name)})})}getRef(r){if(!this.formulas.length)throw new Error("No formula found.");let e={formula_ref:this.formulas[0].formula_ref,wb:this.workbook,exec_formula:this.exec_formula};return o(r,e)}setVarOfExpression(r,e,t){for(let o=0;o<r.args.length;o++){let i=r.args[o];i===e?r.args[o]=this.variables[e]||(this.variables[e]=new n(t)):"object"!=typeof i||"Expression"!==i.name&&"UserFn"!==i.name||this.setVarOfExpression(i,e,t)}}execute(){this.expressions.forEach(r=>{r.update_cell_value()})}}}])}));
//# sourceMappingURL=xlsx-calc.js.map