@univerjs/engine-formula 0.5.0-alpha.0 → 0.5.0-beta.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/lib/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var Du=Object.defineProperty;var wu=(i,o,e)=>o in i?Du(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var A=(i,o,e)=>wu(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("@univerjs/core"),Jt=require("rxjs"),Pu=require("@univerjs/rpc"),dr=require("@univerjs/engine-formula");var Ot=(i=>(i.FALSE="FALSE",i.TRUE="TRUE",i))(Ot||{}),Rt=(i=>(i[i.SUCCESS=0]="SUCCESS",i[i.ERROR=1]="ERROR",i))(Rt||{}),Je=(i=>(i[i.FRONT=0]="FRONT",i[i.BACK=1]="BACK",i))(Je||{});function ri(i,o,e,t,r){for(let n=0,s=i.length;n<s;n++){const a=i[n];if(o!==a.unitId||e!==a.sheetId)continue;const{startRow:u,startColumn:c,endRow:l,endColumn:f}=a.range;if(t>=u&&t<=l&&r>=c&&r<=f)return!0}return!1}var h=(i=>(i.DIV_BY_ZERO="#DIV/0!",i.NAME="#NAME?",i.VALUE="#VALUE!",i.NUM="#NUM!",i.NA="#N/A",i.CYCLE="#CYCLE!",i.REF="#REF!",i.SPILL="#SPILL!",i.CALC="#CALC!",i.ERROR="#ERROR!",i.CONNECT="#GETTING_DATA",i.NULL="#NULL!",i))(h||{});const qt=new Set(Object.values(h)),ca=[...new Set(Object.values(h).map(i=>i.length))];var ni=(i=>(i[i.Financial=0]="Financial",i[i.Date=1]="Date",i[i.Math=2]="Math",i[i.Statistical=3]="Statistical",i[i.Lookup=4]="Lookup",i[i.Database=5]="Database",i[i.Text=6]="Text",i[i.Logical=7]="Logical",i[i.Information=8]="Information",i[i.Engineering=9]="Engineering",i[i.Cube=10]="Cube",i[i.Compatibility=11]="Compatibility",i[i.Web=12]="Web",i[i.Array=13]="Array",i[i.Univer=14]="Univer",i[i.User=15]="User",i[i.DefinedName=16]="DefinedName",i))(ni||{}),X=(i=>(i.PLUS="+",i.MINUS="-",i.MULTIPLY="*",i.DIVIDED="/",i.CONCATENATE="&",i.POWER="^",i.EQUALS="=",i.NOT_EQUAL="<>",i.GREATER_THAN=">",i.GREATER_THAN_OR_EQUAL=">=",i.LESS_THAN="<",i.LESS_THAN_OR_EQUAL="<=",i))(X||{}),$=(i=>(i.EQUALS="=",i.NOT_EQUAL="<>",i.GREATER_THAN=">",i.GREATER_THAN_OR_EQUAL=">=",i.LESS_THAN="<",i.LESS_THAN_OR_EQUAL="<=",i))($||{});const $r=new Map([["<>",4],["<",4],[">=",4],["=",4],[">",4],["<=",4],["&",3],["+",2],["-",2],["/",1],["*",1],["^",0]]),At=new Set($r.keys()),Lu=new Set(["=","<>",">",">=","<","<="]);var Q=(i=>(i.OPEN_BRACKET="(",i.CLOSE_BRACKET=")",i.COMMA=",",i.SINGLE_QUOTATION="'",i.DOUBLE_QUOTATION='"',i.OPEN_BRACES="{",i.CLOSE_BRACES="}",i.COLON=":",i.OPEN_SQUARE_BRACKET="[",i.CLOSE_SQUARE_BRACKET="]",i))(Q||{}),He=(i=>(i.PERCENTAGE="%",i.POUND="#",i))(He||{});const Yn=new Set(["%","#"]);var pe=(i=>(i.AT="@",i.MINUS="-",i.PLUS="+",i))(pe||{});const xu=" ",si=[...Object.values($),...Object.values(X),...Object.values(Q),...Object.values(He),...Object.values(pe)];function Cr(i){return si.includes(i)}function ai(i){for(const o of si)if(i.indexOf(o)>-1)return!0;return!1}function ju(i){return i[0]==="'"&&i[i.length-1]==="'"?i.substring(1,i.length-1):i}function Uu(i){return Cr(i)&&i!==Q.CLOSE_BRACES&&i!==Q.CLOSE_BRACKET&&i!==Q.SINGLE_QUOTATION&&i!==Q.DOUBLE_QUOTATION||i===" "}const vu=new Set([X.PLUS,X.MINUS,X.MULTIPLY,X.DIVIDED,X.CONCATENATE,X.POWER,X.EQUALS,X.NOT_EQUAL,X.GREATER_THAN,X.GREATER_THAN_OR_EQUAL,X.LESS_THAN,X.LESS_THAN_OR_EQUAL,Q.OPEN_BRACKET,Q.COMMA,Q.COLON,Q.OPEN_BRACES,Q.OPEN_SQUARE_BRACKET]);function Tu(i){return vu.has(i)}const Bu=new Set([X.PLUS,X.MINUS,X.MULTIPLY,X.DIVIDED,X.CONCATENATE,X.POWER,X.EQUALS,X.NOT_EQUAL,X.GREATER_THAN,X.GREATER_THAN_OR_EQUAL,X.LESS_THAN,X.LESS_THAN_OR_EQUAL,Q.OPEN_BRACKET,Q.COMMA,Q.COLON,Q.OPEN_BRACES,Q.OPEN_SQUARE_BRACKET,He.PERCENTAGE,He.POUND]);function Iu(i){return Bu.has(i)}function ii(i){const o={};return Object.keys(i).forEach(e=>{const t=i[e];if(t==null)return!0;o[e]==null&&(o[e]={}),Object.keys(t).forEach(r=>{const n=t[r];o[e][r]=new M.ObjectMatrix(n)})}),o}function Fu(i){const o={};for(const e in i){const t=i[e];if(t!=null){o[e]==null&&(o[e]={});for(const r in t){const n=t[r],s={};n.forValue((a,u,c)=>{s[a]===void 0&&(s[a]={}),s[a][u]=c}),o[e][r]=s}}}return o}const oi='\\[([^\\[\\]\\/?:"<>|*\\\\]+)\\]',la=new RegExp(oi),ku="((?![\\[\\]\\/?*\\\\]).)*!",Mt="$",Rs="\\s*?:\\s*?",Xr="[A-Za-z]+",Kr="[1-9][0-9]*",cr=`'?(${oi})?(${ku})?'?`,ns=`\\${Mt}?${Xr}\\${Mt}?${Kr}`,$u=`^(${pe.AT})?${cr}${ns}${Rs}${ns}$`,fa=new RegExp($u),Yu=`^${cr}\\s*?${ns}(${He.POUND})?$`,ma=new RegExp(Yu),Hu=`^${cr}\\${Mt}?${Kr}${Rs}\\${Mt}?${Kr}$`,ha=new RegExp(Hu),Gu=`^${cr}\\${Mt}?${Xr}${Rs}\\${Mt}?${Xr}$`,ga=new RegExp(Gu),Wu=`^${cr}\\s*?\\${Mt}?${Kr}$`,da=new RegExp(Wu),Qu=`^${cr}\\s*?\\${Mt}?${Xr}$`,Ca=new RegExp(Qu),qu="{.*?}",_a=new RegExp(qu,"g");function Nr(i){return ma.lastIndex=0,ma.test(i)}function Xu(i){return fa.lastIndex=0,fa.test(i)}function ui(i){return ha.lastIndex=0,ha.test(i)}function ci(i){return ga.lastIndex=0,ga.test(i)}function li(i){return da.lastIndex=0,da.test(i)}function fi(i){return Ca.lastIndex=0,Ca.test(i)}function Ku(i){return _a.lastIndex=0,_a.test(i)}function mi(i){return Nr(i)||Xu(i)||ui(i)||ci(i)}const hi={id:"formula.mutation.register-function",type:M.CommandType.MUTATION,handler:()=>!0},Zr={id:"formula.mutation.set-array-formula-data",type:M.CommandType.MUTATION,handler:(i,o)=>!0},Zu=/[^0-9]/g,zu=/[^A-Za-z]/g;function _r(i){let o=i[0]==="$";const e=i.substring(1);let t=e.indexOf("$")>-1;return M.Tools.isStringNumber(e)&&o&&!t&&(o=!1,t=!0),o&&t?M.AbsoluteRefType.ALL:o?M.AbsoluteRefType.COLUMN:t?M.AbsoluteRefType.ROW:M.AbsoluteRefType.NONE}function Ju(i){const o=i.split("!");o.length>1&&(i=o[o.length-1]);const e=i.split(":");return e.length>1?{startAbsoluteRefType:_r(e[0]),endAbsoluteRefType:_r(e[1])}:{startAbsoluteRefType:_r(e[0])}}function Aa(i=M.AbsoluteRefType.NONE){let o="",e="";return i===M.AbsoluteRefType.ROW?o="$":i===M.AbsoluteRefType.COLUMN?e="$":i===M.AbsoluteRefType.ALL&&(o="$",e="$"),{rowAbsoluteString:o,columnAbsoluteString:e}}function St(i){const{startColumn:o,startRow:e,endColumn:t,endRow:r,startAbsoluteRefType:n,endAbsoluteRefType:s,rangeType:a=M.RANGE_TYPE.NORMAL}=i,u=Aa(n),c=Aa(s);if(a===M.RANGE_TYPE.ROW||a===M.RANGE_TYPE.ALL){const m=`${u.rowAbsoluteString}${e+1}`,d=`${c.rowAbsoluteString}${r+1}`;return`${m}:${d}`}if(a===M.RANGE_TYPE.COLUMN){const m=`${u.columnAbsoluteString}${M.Tools.chatAtABC(o)}`,d=`${c.columnAbsoluteString}${M.Tools.chatAtABC(t)}`;return`${m}:${d}`}const l=`${u.columnAbsoluteString}${M.Tools.chatAtABC(o)}${u.rowAbsoluteString}${e+1}`,f=`${c.columnAbsoluteString}${M.Tools.chatAtABC(t)}${c.rowAbsoluteString}${r+1}`;return l===f?l:`${l}:${f}`}function gi(i,o){return Jr(i)?`'${i}'!${St(o)}`:`${i}!${St(o)}`}function di(i,o,e){return Jr(i)||Jr(o)?`'[${i}]${o}'!${St(e)}`:`[${i}]${o}!${St(e)}`}function zr(i){const{unitId:o,sheetName:e,range:t}=i;return o!=null&&o.length>0&&e!=null&&e.length>0?di(o,e,t):e!=null&&e.length>0?gi(e,t):St(t)}function Yr(i){const o=Number.parseInt(i.replace(Zu,""))-1,e=M.Tools.ABCatNum(i.replace(zu,"")),t=_r(i);return{row:o,column:e,absoluteRefType:t}}function An(i){const o=la.exec(i);let e="";o!=null&&(e=o[0].trim(),e=e.slice(1,e.length-1),i=i.replace(la,""));const t=i.indexOf("!");let r="",n="";return t>-1?(r=i.substring(0,t),r[0]==="'"&&r[r.length-1]==="'"&&(r=r.substring(1,r.length-1)),n=i.substring(t+1)):n=i,{refBody:n,sheetName:r,unitId:e}}function Er(i){const{refBody:o,sheetName:e,unitId:t}=An(i),r=o.indexOf(":");if(r===-1){const C=Yr(o),_=C.row,E=C.column,b=C.absoluteRefType;return{unitId:t,sheetName:e,range:{startRow:_,startColumn:E,endRow:_,endColumn:E,startAbsoluteRefType:b,endAbsoluteRefType:b}}}const n=o.substring(0,r),s=o.substring(r+1),a=Yr(n),u=Yr(s),c=a.row>u.row?u.row:a.row,l=a.column>u.column?u.column:a.column,f=a.row>u.row?a.row:u.row,m=a.column>u.column?a.column:u.column;let d=M.RANGE_TYPE.NORMAL;return Number.isNaN(c)&&Number.isNaN(f)?d=M.RANGE_TYPE.COLUMN:Number.isNaN(l)&&Number.isNaN(m)&&(d=M.RANGE_TYPE.ROW),{unitId:t,sheetName:e,range:{startRow:c,startColumn:l,endRow:f,endColumn:m,startAbsoluteRefType:a.absoluteRefType,endAbsoluteRefType:u.absoluteRefType,rangeType:d}}}const ec=["LOG10"];function Ar(i){const o=Ci(i);if(!mi(o)||ec.includes(o.toUpperCase().trim()))return!1;const{range:e}=Er(o);return!(e.endColumn>=16384)}function Ci(i){const o=[];let e=!1;for(let t=0,r=i.length;t<r;t++){const n=i[t];if(n===xu&&!e)o.push(n);else{if(!e&&(n===pe.AT||n===pe.MINUS||n===pe.PLUS))continue;o.push(n),e=!0}}return o.join("")}function tc(i,o){const e=(i==null?void 0:i.split(","))||[];return i===""||e.length===0?[]:_i(i)?e.map(n=>{const s=Er(n);return{unitId:s.unitId,sheetId:o(s.sheetName),range:s.range,sheetName:s.sheetName}}):[]}function _i(i){return((i==null?void 0:i.split(","))||[]).every(e=>Ar(e.trim()))}function Jr(i){return i.length===0?!1:!!(ai(i)||rc(i)||nc(i)||sc(i)||/[\s!$%^&*()+\-=\[\]{};':"\\|,.<>\/?]/.test(i))}function rc(i){const o=i.match(/[1-9][0-9]{0,6}/);return/^[A-Z]+[1-9][0-9]{0,6}$/.test(i)&&o!==null}function nc(i){return/^(R(-?[0-9]+)?C(-?[0-9]+)?|C(-?[0-9]+)?|R(-?[0-9]+)?)$/.test(i)}function sc(i){return!new RegExp("^\\p{Letter}","u").test(i.charAt(0))}var ac=Object.defineProperty,ic=Object.getOwnPropertyDescriptor,oc=(i,o,e,t)=>{for(var r=t>1?void 0:t?ic(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&ac(o,e,r),r},uc=(i,o)=>(e,t)=>o(e,t,i);exports.DefinedNamesService=class extends M.Disposable{constructor(e){super();A(this,"_definedNameMap",{});A(this,"_update$",new Jt.Subject);A(this,"update$",this._update$.asObservable());A(this,"_currentRange",{unitId:"",sheetId:"",range:{startRow:0,endRow:0,startColumn:0,endColumn:0}});A(this,"_currentRange$",new Jt.Subject);A(this,"currentRange$",this._currentRange$.asObservable());A(this,"_focusRange$",new Jt.Subject);A(this,"focusRange$",this._focusRange$.asObservable());this._univerInstanceService=e}dispose(){this._definedNameMap={}}getWorksheetByRef(e,t){var n;const{sheetName:r}=An(t);return(n=this._univerInstanceService.getUnit(e))==null?void 0:n.getSheetBySheetName(r)}focusRange(e,t){const r=this.getValueById(e,t);r!=null&&this._focusRange$.next({...r,unitId:e})}setCurrentRange(e){this._currentRange=e,this._currentRange$.next(e)}getCurrentRange(){return this._currentRange}getCurrentRangeForString(){return St(this._currentRange.range)}registerDefinedNames(e,t){this._definedNameMap[e]=t,this._update()}registerDefinedName(e,t){this._definedNameMap[e]==null&&(this._definedNameMap[e]={}),this._definedNameMap[e][t.id]=t,this._update()}removeDefinedName(e,t){var r;(r=this._definedNameMap[e])==null||delete r[t],this._update()}removeUnitDefinedName(e){delete this._definedNameMap[e],this._update()}getDefinedNameMap(e){return this._definedNameMap[e]}getValueByName(e,t){var n;const r=this._definedNameMap[e];return r==null?null:(n=Array.from(Object.values(r)).filter(s=>s.name===t))==null?void 0:n[0]}getValueById(e,t){var r;return(r=this._definedNameMap[e])==null?void 0:r[t]}hasDefinedName(e){return this._definedNameMap[e]==null?!1:(Array.from(Object.values(this._definedNameMap[e])).length||0)!==0}_update(){this._update$.next(null)}};exports.DefinedNamesService=oc([uc(0,M.IUniverInstanceService)],exports.DefinedNamesService);const lr=M.createIdentifier("univer.formula.defined-names.service"),cc=(i,o)=>{const{unitId:e,id:t}=o;return{...i.get(lr).getValueById(e,t),unitId:e}},Vr={id:"formula.mutation.set-defined-name",type:M.CommandType.MUTATION,handler:()=>!0},En={id:"formula.mutation.remove-defined-name",type:M.CommandType.MUTATION,handler:()=>!0},bn={id:"formula.mutation.set-feature-calculation",type:M.CommandType.MUTATION,handler:()=>!0},yn={id:"formula.mutation.remove-feature-calculation",type:M.CommandType.MUTATION,handler:()=>!0},ps={id:"formula.mutation.set-formula-calculation-start",type:M.CommandType.MUTATION,handler:()=>!0},Ns={id:"formula.mutation.set-formula-calculation-stop",type:M.CommandType.MUTATION,handler:()=>!0},en={id:"formula.mutation.set-formula-calculation-notification",type:M.CommandType.MUTATION,handler:()=>!0},Vs={id:"formula.mutation.set-formula-calculation-result",type:M.CommandType.MUTATION,handler:()=>!0},Rn={id:"formula.mutation.set-formula-data",type:M.CommandType.MUTATION,handler:(i,o)=>!0},pn={id:"formula.mutation.set-other-formula",type:M.CommandType.MUTATION,handler:()=>!0},Nn={id:"formula.mutation.remove-other-formula",type:M.CommandType.MUTATION,handler:()=>!0},Ai={id:"formula.mutation.set-super-table",type:M.CommandType.MUTATION,handler:()=>!0},Ei={id:"formula.mutation.remove-super-table",type:M.CommandType.MUTATION,handler:()=>!0},Os={id:"formula.mutation.set-super-table-option",type:M.CommandType.MUTATION,handler:()=>!0};class ft{constructor(o){A(this,"_cache");this._cache=new M.LRUMap(o)}set(o,e){const t=this._hash(o);this._cache.set(t,e)}get(o){const e=this._hash(o);return this._cache.get(e)}clear(){this._cache.clear()}_hash(o){return o.length<=64?o:M.hashAlgorithm(o).toString()}}const ut="P_1",Nt="R_1",nr="L_1",Or="LR_1",bi="LO_1",lc="LET",br="LAMBDA",fc="CUBE",mc=new Set(["RAND","RANDBETWEEN","NOW","TODAY"]),ss=new ft(1e5);function Yt(i){const o=ss.get(i);if(o)return o;const e=Er(i);return ss.set(i,e),Er(i)}function hc(){ss.clear()}var ve=(i=>(i[i.NORMAL=0]="NORMAL",i[i.NUMBER=1]="NUMBER",i[i.STRING=2]="STRING",i[i.FUNCTION=3]="FUNCTION",i[i.REFERENCE=4]="REFERENCE",i[i.ARRAY=5]="ARRAY",i[i.DEFINED_NAME=6]="DEFINED_NAME",i))(ve||{});function as(i){let o="";for(const e of i)typeof e=="string"?o+=e:o+=e.token;return o}class se{constructor(){A(this,"_parent");A(this,"_token",Nt);A(this,"_children",[]);A(this,"_lambdaId");A(this,"_functionDefinitionPrivacyVar");A(this,"_lambdaParameter","");A(this,"_startIndex",-1);A(this,"_endIndex",-1);A(this,"_definedNames",[])}dispose(){var o;this._children.forEach(e=>{typeof e!="string"&&e.dispose()}),(o=this._functionDefinitionPrivacyVar)==null||o.clear(),this._functionDefinitionPrivacyVar=null,this._children=[],this._parent=null,this._definedNames=[]}getDefinedNames(){return this._definedNames}getStartIndex(){return this._startIndex}getLambdaId(){return this._lambdaId}setLambdaId(o){this._lambdaId=o}getFunctionDefinitionPrivacyVar(){return this._functionDefinitionPrivacyVar}setLambdaPrivacyVar(o){this._functionDefinitionPrivacyVar=o}getLambdaParameter(){return this._lambdaParameter}setLambdaParameter(o){this._lambdaParameter=o}getParent(){return this._parent}setParent(o){this._parent=o}getChildren(){return this._children}setChildren(o){this._children=o}addChildren(o){this._children.push(o)}addChildrenFirst(o){this._children.unshift(o)}getToken(){return this._token}setToken(o){this._token=o}setIndex(o,e){this._startIndex=o,this._endIndex=e}setDefinedNames(o){this._definedNames=o}hasDefinedNames(){return this._definedNames.length>0}replaceChild(o,e){const t=this._getIndexInParent(o);t!=null&&(this.getChildren().splice(t,1,e),e.setParent(this))}changeToParent(o){const e=this.getParent();e&&e.removeChild(this),this.setParent(o),o.getChildren().push(this)}removeChild(o){const e=this._getIndexInParent(o);e!=null&&this.getChildren().splice(e,1)}serialize(){const o=this.getToken(),e=this.getChildren(),t=[],r=e.length;for(let n=0;n<r;n++){const s=e[n];s instanceof se?t.push(s.serialize()):t.push(s)}return{token:o,st:this._startIndex,ed:this._endIndex,children:t}}_getIndexInParent(o){const e=this.getChildren(),t=e.length;for(let r=0;r<t;r++)if(e[r]===o)return r}}const yi=2e3,Hn=new ft(yi),Gn=new ft(yi);class Vn extends M.Disposable{constructor(){super(...arguments);A(this,"_currentLexerNode",new se);A(this,"_upLevel",0);A(this,"_segment","");A(this,"_bracketState",[]);A(this,"_squareBracketState",0);A(this,"_bracesState",0);A(this,"_singleQuotationState",0);A(this,"_doubleQuotationState",0);A(this,"_lambdaState",!1);A(this,"_colonState",!1);A(this,"_formulaErrorCount",0);A(this,"_tableBracketState",!1)}dispose(){this._resetTemp(),this._currentLexerNode.dispose(),Hn.clear(),Gn.clear()}getUpLevel(){return this._upLevel}isColonClose(){return this._colonState===!1}isColonOpen(){return this._colonState===!0}isDoubleQuotationClose(){return this._doubleQuotationState===0}isLambdaOpen(){return this._lambdaState===!0}isLambdaClose(){return this._lambdaState===!1}isSingleQuotationClose(){return this._singleQuotationState===0}isBracesClose(){return this._bracesState===0}isBracketClose(){return this._bracketState.length===0}isSquareBracketClose(){return this._squareBracketState===0}getCurrentLexerNode(){return this._currentLexerNode}getFunctionAndParameter(e,t){const r=this._getCurrentParamIndex(e,t);if(r==null||r===h.VALUE)return;const n=r[0];if(typeof n=="string")return;let s=n.getParent(),a=n;for(;s;){const u=s.getToken();if(u!==ut&&!Cr(u)&&s.getStartIndex()!==-1){const c=s.getChildren().indexOf(a);return{functionName:u,paramIndex:c}}a=s,s=s.getParent()}}checkIfAddBracket(e){let t=0,r=e.length-1,n=e[r];for(;(n===Q.CLOSE_BRACKET||n===" ")&&r>=0;)n===Q.CLOSE_BRACKET&&t++,n=e[--r];const s=this._getCurrentParamIndex(e,e.length-2);if(s==null||s===h.VALUE)return 0;const a=s[0];if(typeof a=="string")return 0;let u=a.getParent(),c=0;for(s[1]===Q.OPEN_BRACKET&&c++;u;){const l=u.getToken();l!==ut&&l!==Q.COLON&&u.getStartIndex()!==-1&&l.toUpperCase()!==br&&(t===0?c+=1:t--),u=u.getParent()}return c}sequenceNodesBuilder(e){const t=Gn.get(e);if(t)return[...t];const r=this._getSequenceArray(e);if(r.length===0)return;const n=this.getSequenceNode(r);return Gn.set(e,[...n]),n}convertRefersToAbsolute(e,t,r){const n=this.sequenceNodesBuilder(e);if(n==null)return e;let s="";e.substring(0,1)===X.EQUALS&&(s=X.EQUALS);for(let a=0,u=n.length;a<u;a++){const c=n[a];if(typeof c!="string"&&c.nodeType===ve.REFERENCE){const{token:l,endIndex:f}=c,m=Yt(l);if(m==null)continue;const{range:d,sheetName:C,unitId:_}=m,E={...d,startAbsoluteRefType:t,endAbsoluteRefType:r},b=zr({range:E,unitId:_,sheetName:C}),R=b.length-l.length;n[a]={...c,token:b,endIndex:f+R};for(let p=a+1;p<u;p++){const V=n[p];typeof V!="string"&&(V.startIndex+=R,V.endIndex+=R)}}}return`${s}${as(n)}`}moveFormulaRefOffset(e,t,r,n=!1){const s=this.sequenceNodesBuilder(e);if(s==null)return e;const a=[];for(let u=0,c=s.length;u<c;u++){const l=s[u];if(typeof l=="string"||l.nodeType!==ve.REFERENCE){a.push(l);continue}const{token:f}=l,m=Yt(f),{sheetName:d,unitId:C}=m;let _=m.range;if(!n&&_.startAbsoluteRefType===M.AbsoluteRefType.ALL&&_.endAbsoluteRefType===M.AbsoluteRefType.ALL){a.push(l);continue}else _=M.moveRangeByOffset(_,t,r,n);let E="";M.isValidRange(_)?E=zr({range:_,unitId:C,sheetName:d}):E=h.REF,a.push({...l,token:E})}return`=${as(a)}`}_formulaSpellCheck(){if(this._currentLexerNode.getChildren().length===0)return!0;const e=this._currentLexerNode.getChildren()[0];return!!(e instanceof se||At.has(e)||Yn.has(e)||e===pe.AT||e===Q.COMMA||e===Q.COLON||e===Q.OPEN_BRACKET)}getSequenceNode(e){const t=[];let r=!1;for(let n=0,s=e.length;n<s;n++){const a=e[n],u=e[n-1],{segment:c,currentString:l}=a;if(l===Q.DOUBLE_QUOTATION&&(r=!0),(c!==""||n===0)&&n!==s-1){t.push(l);continue}let f=(u==null?void 0:u.segment)||"";const m=n-f.length;let d=n-1;const C=n-1;if(n===s-1&&this._isLastMergeString(l)&&(f+=l,d+=1),f===""||$r.has(f)){t.push(l);continue}const _=f.trim(),E=Ci(_);r===!0&&_[_.length-1]===Q.DOUBLE_QUOTATION&&_[0]!==Q.OPEN_BRACES?(r=!1,this._processPushSequenceNode(t,ve.STRING,f,m,d,C)):Nr(E)&&Ar(E)?this._processPushSequenceNode(t,ve.REFERENCE,f,m,d,C):M.Tools.isStringNumber(_)?this._processPushSequenceNode(t,ve.NUMBER,f,m,d,C):_.length>0&&this._processPushSequenceNode(t,ve.FUNCTION,f,m,d,C),(n!==s-1||!this._isLastMergeString(l))&&t.push(l)}return this._mergeSequenceNodeReference(t)}_processPushSequenceNode(e,t,r,n,s,a){this._pushSequenceNode(e,{nodeType:t,token:r,startIndex:n,endIndex:s},a)}_getCurrentParamIndex(e,t){return this._nodeMaker(e,void 0,t)}_isLastMergeString(e){return e===Q.DOUBLE_QUOTATION||M.Tools.isStringNumber(e)||!Cr(e)}_mergeSequenceNodeReference(e){const t=[],r=e.length;let n=0;for(;n<r;){const s=e[n];if(typeof s=="string"){const a=e[n-1];if(s.trim()===Q.CLOSE_BRACES&&a!=null&&typeof a!="string"&&a.nodeType===ve.FUNCTION&&a.token.trim().substring(0,1)===Q.OPEN_BRACES){a.nodeType=ve.ARRAY,a.token+=s,a.endIndex+=s.length,n++;continue}t.push(s)}else{const a=e[n+1],u=e[n+2];a===Q.COLON&&typeof s!="string"&&u!=null&&typeof u!="string"&&Ar((s.token+a+u.token).trim())&&(s.nodeType=ve.REFERENCE,s.token+=a+u.token,s.endIndex=u.endIndex,n+=2),t.push(s)}n++}return this._minusSplitSequenceNode(t)}_minusSplitSequenceNode(e){const t=[];for(const r of e){if(typeof r!="string"){const s=r.token.match(/^(\s*([-@+]\s*)+)(.*)$/);if(s){const a=s[1],u=s[3];if(Ar(u.trim())){const c=a.length,l=r.startIndex,f=r.startIndex+c-1,m={nodeType:ve.NORMAL,token:a,startIndex:l,endIndex:f},d={nodeType:ve.REFERENCE,token:u,startIndex:f+1,endIndex:r.endIndex};t.push(m),t.push(d);continue}}}t.push(r)}return t}_pushSequenceNode(e,t,r){const n=r-t.startIndex+1;e.splice(e.length-n,n,t)}nodeMakerTest(e){return this._nodeMaker(e)}treeBuilder(e,t=!0,r,n){if(t===!0){const m=Hn.get(e),d=n==null?void 0:n(e);if(m&&!d)return m}this._resetCurrentLexerNode(),this._currentLexerNode.setToken(Nt);const s=[];let a=this._nodeMaker(e,s);if(a===h.VALUE||s.length===0)return a;let u=!1,c="",l=[];if(r){const{hasDefinedName:m,sequenceString:d,definedNames:C}=r(s);u=m,c=d,l=C}if(u&&(this._resetCurrentLexerNode(),this._currentLexerNode.setToken(Nt),a=this._nodeMaker(`=${c}`),a===h.VALUE))return a;const f=this._getTopNode(this._currentLexerNode);if(f&&(this._currentLexerNode=f),t){if(!this._suffixExpressionHandler(this._currentLexerNode))return h.VALUE;Hn.set(e,this._currentLexerNode)}return u&&this._currentLexerNode.setDefinedNames(l),this._currentLexerNode}_suffixExpressionHandler(e){var u;const t=e.getChildren();if(!t)return!1;const r=t.length,n=[],s=[];let a=!0;for(let c=0;c<r;c++){const l=t[c];if(l instanceof se)a=this._suffixExpressionHandler(l),n.push(l);else{const f=l.trim();if(f==="")continue;if(At.has(f)){if(f===X.PLUS&&this._deletePlusForPreNode(t[c-1]))continue;if(f!==X.PLUS&&f!==X.MINUS&&this._deletePlusForPreNode(t[c-1]))return!1;for(;s.length>0;){const m=(u=s[s.length-1])==null?void 0:u.trim();if(!m||m===Q.OPEN_BRACKET)break;const d=$r.get(m),C=$r.get(f);if(!d||!C)break;if(C>=d)n.push(s.pop());else break}s.push(l)}else if(f===Q.OPEN_BRACKET)s.push(l);else if(f===Q.CLOSE_BRACKET)this._processSuffixExpressionCloseBracket(n,s,t,c);else{if(this._checkCloseBracket(t[c-1]))return!1;n.push(l)}}}return a?this._processSuffixExpressionRemain(n,s,e):!1}_processSuffixExpressionRemain(e,t,r){const n=e.length,s=e[n-1];for(;t.length>0;){const a=t.pop();if(!(s instanceof se)&&(a===Q.OPEN_BRACKET||a===Q.CLOSE_BRACKET))return!1;e.push(a)}return r.setChildren(e),!0}_processSuffixExpressionCloseBracket(e,t,r,n){var s;if(this._checkOpenBracket(r[n-1])||this._checkOperator(r[n-1]))return!1;for(;t.length>0;){const a=(s=t[t.length-1])==null?void 0:s.trim();if(!a)break;if(a===Q.OPEN_BRACKET){t.pop();break}e.push(t.pop())}}_checkCloseBracket(e){return e===Q.CLOSE_BRACKET||e instanceof se}_checkOpenBracket(e){return e===Q.OPEN_BRACKET}_checkOperator(e){return e==null||e instanceof se?!1:At.has(e)}_deletePlusForPreNode(e){if(e==null)return!0;if(!(e instanceof se)){const t=e.trim();if(At.has(t)||t===Q.OPEN_BRACKET)return!0}return!1}_resetCurrentLexerNode(){this._currentLexerNode=new se}_resetSegment(){this._segment=""}_openBracket(e=0){this._bracketState.push(e)}_closeBracket(){this._bracketState.pop()}_openSquareBracket(){this._squareBracketState+=1}_closeSquareBracket(){this._squareBracketState-=1}_getCurrentBracket(){const e=this._bracketState;return e[e.length-1]}_changeCurrentBracket(e){const t=this._bracketState;t[t.length-1]=e}_openBraces(){this._bracesState+=1}_closeBraces(){this._bracesState-=1}_openSingleQuotation(){this._singleQuotationState+=1}_closeSingleQuotation(){this._singleQuotationState-=1}_openDoubleQuotation(){this._doubleQuotationState+=1}_closeDoubleQuotation(){this._doubleQuotationState-=1}_openLambda(){this._lambdaState=!0}_closeLambda(){this._lambdaState=!1}_openColon(e){this._upLevel=e,this._colonState=!0}_closeColon(){this._upLevel=0,this._colonState=!1}_isTableBracket(){return this._tableBracketState}_openTableBracket(){this._tableBracketState=!0}_closeTableBracket(){this._tableBracketState=!1}_formalErrorOccurred(){this._formulaErrorCount+=1}_hasFormalError(){return this._formulaErrorCount>0}_getLastChildCurrentLexerNode(){const e=this._currentLexerNode.getChildren();if(e&&e.length>0){const t=e[e.length-1];if(t instanceof se)return t}return!1}_getLastChildCurrent(){const e=this._currentLexerNode.getChildren();return e&&e.length>0?e[e.length-1]:!1}_setParentCurrentLexerNode(){const e=this._currentLexerNode.getParent();return e?(this._currentLexerNode=e,!0):!1}_setAncestorCurrentLexerNode(){var r,n,s,a,u,c;const e=(r=this._currentLexerNode)==null?void 0:r.getParent();let t=!1;if(e&&e.getToken()===nr){if((n=e==null?void 0:e.getParent())!=null&&n.getParent()){const l=(a=(s=this._currentLexerNode.getParent())==null?void 0:s.getParent())==null?void 0:a.getParent();l&&(this._currentLexerNode=l),t=!0}}else if(e!=null&&e.getParent()){const l=(u=this._currentLexerNode.getParent())==null?void 0:u.getParent();l&&(this._currentLexerNode=l),t=!0}for(let l=0;l<this._upLevel;l++){const f=(c=this._currentLexerNode)==null?void 0:c.getParent();f&&(this._currentLexerNode=f),this._currentLexerNode?t=!0:t=!1}return t}_segmentCount(){return this._segment.trim().length}_pushSegment(e){this._segment+=e}_pushNodeToChildren(e,t=!1){let r=e;if(r!==""){const n=this._currentLexerNode.getChildren();if(!(r instanceof se)&&this.isColonOpen()){const s=new se;s.setToken(r),s.setParent(this._currentLexerNode),r=s}t?n.unshift(r):n.push(r)}this.isColonOpen()&&(this._setAncestorCurrentLexerNode(),this._closeColon())}_setCurrentLexerNode(e,t=!1){this._pushNodeToChildren(e,t),e.setParent(this._currentLexerNode),this._currentLexerNode=e}_newAndPushCurrentLexerNode(e,t,r=!1){const n=new se;n.setToken(e),n.setIndex(t-e.length,t-1),this._setCurrentLexerNode(n,r)}_getTopNode(e){let t=e;for(;t!=null&&t.getParent();)t=t.getParent();return t}_removeLastChild(){this._currentLexerNode.getChildren().splice(-1)}_formulaErrorLastTokenCheck(e,t){const r=this._findPreviousToken(e,t)||"",n=e.length-1===t;if(!n&&this._isOperatorToken(r)||n&&Tu(r))return!0;if(Yn.has(r)){const s=this._findSecondLastNonSpaceToken(e,t);if(s==null||Iu(s))return!0}return!1}_findPreviousToken(e,t){let r=t;for(;r>=0;){const n=e[r];if(n!==" ")return n;r--}}_findSecondLastNonSpaceToken(e,t){let r=t,n=0;for(;r>=0;){const s=e[r];if(s!==" "&&(n++,n===2))return s;r--}return null}_findNextToken(e,t){let r=t;for(;r>=0;){const n=e[r];if(n!==" ")return n;r++}}_unexpectedEndingTokenExcludeOperator(e){return e===Q.OPEN_BRACKET||e===Q.COMMA||e===X.EQUALS||e===""}_unexpectedEndingToken(e){return!!(this._isOperatorToken(e)||this._unexpectedEndingTokenExcludeOperator(e))}_isOperatorToken(e){return!!At.has(e)}_getSequenceArray(e){const t=[];return this._nodeMaker(e,t),t}_resetTemp(){this._currentLexerNode=new se,this._upLevel=0,this._segment="",this._bracketState=[],this._bracesState=0,this._singleQuotationState=0,this._doubleQuotationState=0,this._lambdaState=!1,this._colonState=!1,this._formulaErrorCount=0}_checkErrorState(){return!!(this._bracketState.length>0||this._bracesState>0||this._singleQuotationState>0||this._doubleQuotationState>0||this._hasFormalError())}_checkSimilarErrorToken(e,t,r){let n=t;if(e!==He.POUND)return!0;let s=r[++n];for(;s===" ";)s=r[++n];return!!Cr(s)}_checkIfErrorObject(e,t){return!!this._findErrorObject(e,t)}_findErrorObject(e,t){for(let r=0;r<ca.length;r++){const n=ca[r],s=t.slice(e,e+n).join("").toUpperCase();if(qt.has(s))return s}}_nodeMaker(e,t,r){let n=e.replace(/\r\n$/,"").replace(/\r/g," ").replace(/\n/g," ");n.substring(0,1)===X.EQUALS&&(n=n.substring(1));const s=n.split(""),a=s.length;let u=0;for(this._resetTemp(),this._formulaErrorLastTokenCheck(s,a-1)&&this._formalErrorOccurred();u<a;){const c=s[u];if(r===u)return[this._currentLexerNode,c];if(c===He.POUND&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()&&this._checkIfErrorObject(u,s)){const l=this._findErrorObject(u,s);if(l==null)return h.VALUE;this._pushNodeToChildren(l);for(let f=0;f<l.length;f++){const m=s[u];this._pushSegment(m),this._addSequenceArray(t,m,u),u++}this._resetSegment();continue}else if(c===Q.OPEN_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())if(this._segmentCount()>0||this.isLambdaOpen()){this.isLambdaClose()&&(this._newAndPushCurrentLexerNode(this._segment,u),this._resetSegment()),this._openBracket(1),this._closeLambda();const l=s[u+1];if(l&&l===Q.CLOSE_BRACKET){if(!this._setParentCurrentLexerNode()&&u!==a-1)return h.VALUE;this._addSequenceArray(t,c,u),u++,this._addSequenceArray(t,l,u),u++,this._closeBracket();continue}else l&&this._newAndPushCurrentLexerNode(ut,u)}else this._pushNodeToChildren(c),this._openBracket(0),this._resetSegment();else if(c===Q.CLOSE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()){this._formulaErrorLastTokenCheck(s,u-1)&&this._formalErrorOccurred(),this._pushNodeToChildren(this._segment),this._resetSegment();const l=this._getCurrentBracket();if(l===0)this._pushNodeToChildren(c);else if(l===1){const f=s[u+1];if(f&&f===Q.OPEN_BRACKET){if(!this._setParentCurrentLexerNode()&&u!==a-1)return h.VALUE;this._newAndPushCurrentLexerNode(nr,u,!0),this._openLambda()}else if(!this._setAncestorCurrentLexerNode()&&u!==a-1)return h.VALUE}else return h.VALUE;this._closeBracket()}else if(c===Q.OPEN_BRACES&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()){if(this._pushSegment(c),this._openBraces(),!this._formulaSpellCheck())return h.VALUE}else if(c===Q.CLOSE_BRACES&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._pushSegment(c),this._pushNodeToChildren(this._segment),this._resetSegment(),this._closeBraces();else if(c===Q.OPEN_SQUARE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._segment.length>0&&this._openTableBracket(),this._pushSegment(c),this._openSquareBracket();else if(c===Q.CLOSE_SQUARE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._closeSquareBracket(),this.isSquareBracketClose()?(this._pushSegment(c),this._isTableBracket()&&(this._pushNodeToChildren(this._segment),this._resetSegment()),this._closeTableBracket()):this._pushSegment(c);else if(c===Q.DOUBLE_QUOTATION&&this.isSingleQuotationClose()&&this.isSquareBracketClose()){if(this.isDoubleQuotationClose())this._openDoubleQuotation();else{const l=s[u+1];l&&l===Q.DOUBLE_QUOTATION?u++:this._closeDoubleQuotation()}this._pushSegment(c)}else if(c===Q.SINGLE_QUOTATION&&this.isDoubleQuotationClose()){if(this.isSingleQuotationClose())this._openSingleQuotation();else{const l=s[u+1];l&&l===Q.SINGLE_QUOTATION?u++:this._closeSingleQuotation()}this._pushSegment(c)}else if(c===Q.COMMA&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()){this._formulaErrorLastTokenCheck(s,u-1)&&this._formalErrorOccurred();const l=this._getCurrentBracket();if(l===1||l==null){if(this._pushNodeToChildren(this._segment),this._resetSegment(),!this._setParentCurrentLexerNode()&&u!==a-1&&l!=null)return h.VALUE;this._newAndPushCurrentLexerNode(ut,u)}else{const f=new se;f.setToken(fc);const m=new se;m.setToken(ut),m.changeToParent(f);const d=this._currentLexerNode.getParent();if(d&&d.getToken()===Q.COLON){const C=d.getParent();if(!C)return h.VALUE;d.changeToParent(m),C.setChildren([]),f.changeToParent(C)}else return h.VALUE;this._changeCurrentBracket(1),this._pushNodeToChildren(this._segment),this._resetSegment(),this._currentLexerNode=f,this._newAndPushCurrentLexerNode(ut,u)}}else if(c===Q.COLON&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()){const l=new se;l.setToken(c);const f=new se;f.setToken(ut),f.setParent(l);const m=new se;m.setToken(ut),m.setParent(l),l.getChildren().push(f,m);let d=l,C=0;if(this._segmentCount()>0){let _,E,b=0;const R=this._segment.trim(),p=R[0],V=R[1];if(p===pe.MINUS&&(_=new se,_.setToken(pe.MINUS),b++),(p===pe.AT||V===pe.AT)&&(E=new se,E.setToken(pe.AT),_&&(_.addChildren(E),E.setParent(_)),b++),b>0&&(this._segment=R.slice(b)),C=b,E)if(E.addChildren(l),l.setParent(E),E.getParent()){const D=E.getParent();D&&(d=D)}else d=E;else _&&(d=_,_.addChildren(l),l.setParent(_));const S=new se;S.setToken(this._segment),S.setParent(f),f.getChildren().push(S),this._resetSegment()}else{const _=this._getLastChildCurrentLexerNode();_&&_.changeToParent(f)}this._setCurrentLexerNode(d),this._currentLexerNode=m,this._openColon(C)}else if(Yn.has(c)&&this._checkSimilarErrorToken(c,u,s)&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isSquareBracketClose()&&this.isBracesClose()){this._pushNodeToChildren(this._segment);const l=new se;l.setToken(c);const f=this._getLastChildCurrent();f instanceof se?f.changeToParent(l):f!==!1&&(l.getChildren().push(f),this._removeLastChild()),this._pushNodeToChildren(l),l.setParent(this._currentLexerNode),this._resetSegment()}else if(At.has(c)&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isSquareBracketClose()&&this.isBracesClose()){let l=this._segment.trim();if(c===X.MINUS&&l===""){const f=this._findPreviousToken(s,u-1)||"",m=this._findNextToken(s,u+1)||"";if(this._unexpectedEndingTokenExcludeOperator(f)&&this._isOperatorToken(m)){this._pushNodeToChildren("0"),this._pushNodeToChildren(X.MINUS),this._addSequenceArray(t,c,u),this._resetSegment(),u++;continue}else if(this._unexpectedEndingToken(f))if(m===X.PLUS){this._pushSegment(X.MINUS),this._addSequenceArray(t,c,u),this._addSequenceArray(t,X.PLUS,u+1),u+=2;continue}else{this._pushSegment(X.MINUS),this._addSequenceArray(t,c,u),u++;continue}}else if(this._segment.length>0&&this._isScientificNotation(s,u,c)){this._pushSegment(c),this._addSequenceArray(t,c,u),u++;continue}else this._segment.length>0&&l===""?l=this._segment:(this._pushNodeToChildren(this._segment),l="");if(c===X.LESS_THAN||c===X.GREATER_THAN){const f=s[u+1];if(f&&At.has(c+f)){this._pushNodeToChildren(l+c+f),this._resetSegment(),this._addSequenceArray(t,c,u),u++,this._addSequenceArray(t,f,u),u++;continue}else this._pushNodeToChildren(l+c)}else this._pushNodeToChildren(l+c);this._resetSegment()}else this._pushSegment(c);this._addSequenceArray(t,c,u),u++}if(this._pushNodeToChildren(this._segment),this._checkErrorState())return h.VALUE}_isScientificNotation(e,t,r){const n=e[t-2];if(n&&Number.isNaN(Number(n))||!(r===X.MINUS||r===X.PLUS))return!1;const s=e[t+1];if(s&&Number.isNaN(Number(s)))return!1;const a=e[t-1];return a&&a.toUpperCase()==="E"}_addSequenceArray(e,t,r){e==null||e.push({segment:this._segment,currentString:t,cur:r,currentLexerNode:this._currentLexerNode})}}function gc(i,o,e,t,r,n,s){const a=(s==null?void 0:s.f)||"",u=(s==null?void 0:s.si)||"",c=M.isFormulaString(a),l=M.isFormulaId(u),f=i.getValue(r,n),m=(f==null?void 0:f.f)||"",d=(f==null?void 0:f.si)||"";function C(){var _;if(M.isFormulaString(m)&&M.isFormulaId(d)){const E=(_=e.get(d))==null?void 0:_.f;E?t.set(d,E):t.set(d,m)}}c&&l?(d!==u&&C(),i.setValue(r,n,{f:a,si:u}),e.set(u,{f:a,r,c:n}),o.setValue(r,n,{f:a,si:u})):c&&!l?(m!==a&&C(),i.setValue(r,n,{f:a}),o.setValue(r,n,{f:a})):!c&&l?(d!==u&&C(),i.setValue(r,n,{f:"",si:u})):!c&&!l&&i.getValue(r,n)&&(C(),i.realDeleteValue(r,n),o.setValue(r,n,null))}function dc(i,o,e,t){const r=i==null?void 0:i.getValue(e,t);if(r==null)return!0;const n=[];i.forValue((l,f,m)=>{l===e&&f===t||M.Rectangle.intersects(m,r)&&n.push(m)});const{startRow:s,startColumn:a,endRow:u,endColumn:c}=r;for(let l=s;l<=u;l++)for(let f=a;f<=c;f++){let m=!1;const d=M.cellToRange(l,f);n.some(C=>M.Rectangle.contains(C,d)?(m=!0,!0):!1),m||o.realDeleteValue(l,f)}}var Cc=Object.defineProperty,_c=Object.getOwnPropertyDescriptor,Ac=(i,o,e,t)=>{for(var r=t>1?void 0:t?_c(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Cc(o,e,r),r},Ea=(i,o)=>(e,t)=>o(e,t,i);exports.FormulaDataModel=class extends M.Disposable{constructor(e,t){super();A(this,"_formulaData",{});A(this,"_arrayFormulaRange",{});A(this,"_arrayFormulaCellData",{});this._univerInstanceService=e,this._lexerTreeBuilder=t,this.initFormulaData()}dispose(){super.dispose(),this._formulaData={},this._arrayFormulaRange={},this._arrayFormulaCellData={}}clearPreviousArrayFormulaCellData(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{var l,f,m,d;const s=r[n],a=(f=(l=this._arrayFormulaRange)==null?void 0:l[t])==null?void 0:f[n];if(a==null)return!0;const u=new M.ObjectMatrix(a);let c=new M.ObjectMatrix;((m=this._arrayFormulaCellData[t])==null?void 0:m[n])!=null&&(c=new M.ObjectMatrix((d=this._arrayFormulaCellData[t])==null?void 0:d[n])),s.forValue((C,_)=>{const E=u.getValue(C,_);if(E==null)return!0;const{startRow:b,startColumn:R,endRow:p,endColumn:V}=E;for(let S=b;S<=p;S++)for(let D=R;D<=V;D++)c.setValue(S,D,null);u.realDeleteValue(C,_)}),this._arrayFormulaCellData[t]&&(this._arrayFormulaCellData[t][n]=c.getData())})})}mergeArrayFormulaCellData(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;this._arrayFormulaRange[t]==null&&(this._arrayFormulaRange[t]={}),this._arrayFormulaCellData[t]==null&&(this._arrayFormulaCellData[t]={}),Object.keys(r).forEach(n=>{var c,l;const s=r[n],a=new M.ObjectMatrix((c=this._arrayFormulaRange[t])==null?void 0:c[n]),u=new M.ObjectMatrix((l=this._arrayFormulaCellData[t])==null?void 0:l[n]);s.forValue((f,m)=>{const d=a==null?void 0:a.getValue(f,m);if(d==null)return!0;const{startRow:C,startColumn:_,endRow:E,endColumn:b}=d;for(let R=C;R<=E;R++)for(let p=_;p<=b;p++)u.setValue(R,p,null)}),s.forValue((f,m,d)=>{u.setValue(f,m,d)}),this._arrayFormulaCellData[t]&&(this._arrayFormulaCellData[t][n]=u.getData())})})}getFormulaData(){return this._formulaData}setFormulaData(e){this._formulaData=e}getArrayFormulaRange(){return this._arrayFormulaRange}setArrayFormulaRange(e){this._arrayFormulaRange=e}getArrayFormulaCellData(){return this._arrayFormulaCellData}setArrayFormulaCellData(e){this._arrayFormulaCellData=e}mergeArrayFormulaRange(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;this._arrayFormulaRange[t]||(this._arrayFormulaRange[t]={}),Object.keys(r).forEach(n=>{var u;const s=new M.ObjectMatrix(r[n]),a=new M.ObjectMatrix((u=this._arrayFormulaRange[t])==null?void 0:u[n]);s.forValue((c,l,f)=>{a.setValue(c,l,f)}),this._arrayFormulaRange[t]&&(this._arrayFormulaRange[t][n]=a.getData())})})}mergeFormulaData(e){Object.keys(e).forEach(t=>{const r=e[t];if(r!==void 0){if(r===null){delete this._formulaData[t];return}this._formulaData[t]||(this._formulaData[t]={}),Object.keys(r).forEach(n=>{var c,l;const s=r[n];if(s===void 0)return;if(s===null){(c=this._formulaData[t])==null||delete c[n];return}(l=this._formulaData[t])!=null&&l[n]||(this._formulaData[t][n]={});const a=new M.ObjectMatrix(s),u=new M.ObjectMatrix(this._formulaData[t][n]);a.forValue((f,m,d)=>{d==null?u.realDeleteValue(f,m):u.setValue(f,m,d)})})}})}deleteArrayFormulaRange(e,t,r,n){var u;const s=(u=this._arrayFormulaRange[e])==null?void 0:u[t];if(s==null)return;const a=new M.ObjectMatrix(s);a.getValue(r,n)&&(a.realDeleteValue(r,n),this._arrayFormulaRange[e]&&(this._arrayFormulaRange[e][t]=a.getData()))}initFormulaData(){if(this._univerInstanceService.getAllUnitsForType(M.UniverInstanceType.UNIVER_SHEET).length===0)return;const t=this._univerInstanceService.getCurrentUnitForType(M.UniverInstanceType.UNIVER_SHEET),r=t.getUnitId();this._formulaData[r]={},t.getSheets().forEach(s=>{const a=s.getCellMatrix(),u=s.getSheetId();Ri(this._formulaData,r,u,a)})}getCalculateData(){const e=this._univerInstanceService.getAllUnitsForType(M.UniverInstanceType.UNIVER_SHEET),t={},r={};for(const n of e){const s=n.getUnitId(),a=n.getSheets(),u={},c={};for(const l of a){const f=l.getSheetId(),m=l.getConfig();u[f]={cellData:new M.ObjectMatrix(m.cellData),rowCount:m.rowCount,columnCount:m.columnCount,rowData:m.rowData,columnData:m.columnData,defaultRowHeight:m.defaultRowHeight,defaultColumnWidth:m.defaultColumnWidth},c[l.getName()]=l.getSheetId()}t[s]=u,r[s]=c}return{allUnitData:t,unitSheetNameMap:r}}updateFormulaData(e,t,r){const n=new M.ObjectMatrix(r),s=this.getFormulaIdMap(e,t),a=new Map,u=this._formulaData;u[e]==null&&(u[e]={});const c=u[e];c[t]==null&&(c[t]={});const l=new M.ObjectMatrix(c[t]||{}),f=new M.ObjectMatrix;return n.forValue((m,d,C)=>{gc(l,f,s,a,m,d,C)}),l.forValue((m,d,C)=>{const _=(C==null?void 0:C.f)||"",E=(C==null?void 0:C.si)||"";if(M.isFormulaId(E)){const b=s.get(E),R=a.get(E);if(b&&!M.isFormulaString(_)){const p=b.f,V=d-b.c,S=m-b.r;l.setValue(m,d,{f:p,si:E,x:V,y:S}),f.setValue(m,d,{f:p,si:E,x:V,y:S})}else if(typeof R=="string"){const p=(C==null?void 0:C.x)||0,V=(C==null?void 0:C.y)||0,S=this._lexerTreeBuilder.moveFormulaRefOffset(R,p,V);a.set(E,{r:m,c:d,f:S}),l.setValue(m,d,{f:S,si:E}),f.setValue(m,d,{f:S,si:E})}else if(typeof R=="object"){const p=d-R.c,V=m-R.r;l.setValue(m,d,{f:R.f,si:E,x:p,y:V}),f.setValue(m,d,{f:R.f,si:E,x:p,y:V})}}}),f.getMatrix()}updateArrayFormulaRange(e,t,r){var u;const n=(u=this._arrayFormulaRange[e])==null?void 0:u[t];if(!n)return;const s=new M.ObjectMatrix(n);new M.ObjectMatrix(r).forValue((c,l,f)=>{s.realDeleteValue(c,l)})}updateArrayFormulaCellData(e,t,r){var l,f;const n=(l=this._arrayFormulaRange[e])==null?void 0:l[t];if(!n)return;const s=new M.ObjectMatrix(n),a=(f=this._arrayFormulaCellData[e])==null?void 0:f[t];if(!a)return;const u=new M.ObjectMatrix(a);new M.ObjectMatrix(r).forValue((m,d,C)=>{dc(s,u,m,d)})}getFormulaItemBySId(e,t,r){const n=this._formulaData;if(n[r]==null)return null;const s=n[r];if((s==null?void 0:s[t])==null)return null;const a=new M.ObjectMatrix(s[t]||{});let u=null;return a.forValue((c,l,f)=>{if(f==null)return!0;const{f:m,si:d,x:C=0,y:_=0}=f;if(d===e&&m.length>0&&C===0&&_===0)return u=f,!1}),u}getFormulaDataItem(e,t,r,n){var s,a,u,c;return(c=(u=(a=(s=this._formulaData)==null?void 0:s[n])==null?void 0:a[r])==null?void 0:u[e])==null?void 0:c[t]}getFormulaIdMap(e,t){const r=new Map,n=this._formulaData;if(n[e]==null)return r;const s=n[e];return(s==null?void 0:s[t])==null||new M.ObjectMatrix(s[t]||{}).forValue((u,c,l)=>{const f=(l==null?void 0:l.f)||"",m=(l==null?void 0:l.si)||"",d=(l==null?void 0:l.x)||0,C=(l==null?void 0:l.y)||0;M.isFormulaString(f)&&M.isFormulaId(m)&&d===0&&C===0&&r.set(m,{f,r:u,c})}),r}getFormulaStringByCell(e,t,r,n){const s=this.getFormulaDataItem(e,t,r,n);if(s==null)return null;const{f:a,si:u,x:c=0,y:l=0}=s;if(u!=null&&(c!==0||l!==0)){let f="";if(a.length>0)f=a;else{const m=this.getFormulaItemBySId(u,r,n);if(m==null||m.f.length===0)return null;f=m.f}return f=this._lexerTreeBuilder.moveFormulaRefOffset(f,c,l),f}return M.isFormulaString(a)?a:null}getFormulaDirtyRanges(){const e=this._formulaData,t=[];for(const r in e){const n=e[r];if(!n)continue;const s=this._univerInstanceService.getUnit(r);if(s)for(const a in n){const u=n[a];if(!u)continue;const c=s.getSheetBySheetId(a);if(!c)continue;const l={};for(const f of Object.keys(u)){const m=Number(f);for(const d in u[m]){const C=Number(d),_=c.getCellRaw(m,C),E=M.isFormulaString(_==null?void 0:_.f)||M.isFormulaId(_==null?void 0:_.si),b=(_==null?void 0:_.v)===void 0;if(!(E&&b))continue;l[C]||(l[C]=[]);const R=l[C].slice(-1)[0];R&&R.endRow===m-1?R.endRow=m:l[C].push({startRow:m,endRow:m})}}for(const f in l){const m=l[f];for(let d=0;d<m.length;d++){const C=m[d];t.push({unitId:r,sheetId:a,range:{rangeType:M.RANGE_TYPE.NORMAL,startRow:C.startRow,endRow:C.endRow,startColumn:Number(f),endColumn:Number(f)}})}}}}return t}};exports.FormulaDataModel=Ac([Ea(0,M.IUniverInstanceService),Ea(1,M.Inject(Vn))],exports.FormulaDataModel);function Ri(i,o,e,t){i[o]||(i[o]={}),i[o][e]||(i[o][e]={});const r=new Map,n=new M.ObjectMatrix(i[o][e]);t.forValue((a,u,c)=>{const l=(c==null?void 0:c.f)||"",f=(c==null?void 0:c.si)||"",m=M.isFormulaString(l),d=M.isFormulaId(f);m&&d?(n.setValue(a,u,{f:l,si:f}),r.set(f,{f:l,r:a,c:u})):m&&!d?n.setValue(a,u,{f:l}):!m&&d&&n.setValue(a,u,{f:"",si:f})}),n.forValue((a,u,c)=>{const l=(c==null?void 0:c.f)||"",f=(c==null?void 0:c.si)||"";if(M.isFormulaId(f)&&!M.isFormulaString(l)){const m=r.get(f);if(m){const d=m.f,C=u-m.c,_=a-m.r;n.setValue(a,u,{f:d,si:f,x:C,y:_})}else n.realDeleteValue(a,u)}});const s=n.getMatrix();return{[o]:{[e]:s}}}const Ec=class is{constructor(o,e){this.low=o,this.high=e}clone(){return new is(this.low,this.high)}get max(){return this.clone()}less_than(o){return this.low<o.low||this.low===o.low&&this.high<o.high}equal_to(o){return this.low===o.low&&this.high===o.high}intersect(o){return!this.not_intersect(o)}not_intersect(o){return this.high<o.low||o.high<this.low}merge(o){return new is(this.low===void 0?o.low:this.low<o.low?this.low:o.low,this.high===void 0?o.high:this.high>o.high?this.high:o.high)}output(){return[this.low,this.high]}static comparable_max(o,e){return o.merge(e)}static comparable_less_than(o,e){return o<e}},we=0,_e=1;class Lt{constructor(o=void 0,e=void 0,t=null,r=null,n=null,s=_e){if(this.left=t,this.right=r,this.parent=n,this.color=s,this.item={key:o,value:e},o&&o instanceof Array&&o.length===2&&!Number.isNaN(o[0])&&!Number.isNaN(o[1])){let[a,u]=o;a>u&&([a,u]=[u,a]),this.item.key=new Ec(a,u)}this.max=this.item.key?this.item.key.max:void 0}isNil(){return this.item.key===void 0&&this.item.value===void 0&&this.left===null&&this.right===null&&this.color===_e}_value_less_than(o){return this.item.value&&o.item.value&&this.item.value.less_than?this.item.value.less_than(o.item.value):this.item.value<o.item.value}less_than(o){return this.item.value===this.item.key&&o.item.value===o.item.key?this.item.key.less_than(o.item.key):this.item.key.less_than(o.item.key)||this.item.key.equal_to(o.item.key)&&this._value_less_than(o)}_value_equal(o){return this.item.value&&o.item.value&&this.item.value.equal_to?this.item.value.equal_to(o.item.value):this.item.value===o.item.value}equal_to(o){return this.item.value===this.item.key&&o.item.value===o.item.key?this.item.key.equal_to(o.item.key):this.item.key.equal_to(o.item.key)&&this._value_equal(o)}intersect(o){return this.item.key.intersect(o.item.key)}copy_data(o){this.item.key=o.item.key,this.item.value=o.item.value}update_max(){if(this.max=this.item.key?this.item.key.max:void 0,this.right&&this.right.max){const o=this.item.key.constructor.comparable_max;this.max=o(this.max,this.right.max)}if(this.left&&this.left.max){const o=this.item.key.constructor.comparable_max;this.max=o(this.max,this.left.max)}}not_intersect_left_subtree(o){const e=this.item.key.constructor.comparable_less_than;let t=this.left.max.high!==void 0?this.left.max.high:this.left.max;return e(t,o.item.key.low)}not_intersect_right_subtree(o){const e=this.item.key.constructor.comparable_less_than;let t=this.right.max.low!==void 0?this.right.max.low:this.right.item.key.low;return e(o.item.key.high,t)}}class Ms{constructor(){this.root=null,this.nil_node=new Lt}get size(){let o=0;return this.tree_walk(this.root,()=>o++),o}get keys(){let o=[];return this.tree_walk(this.root,e=>o.push(e.item.key.output?e.item.key.output():e.item.key)),o}get values(){let o=[];return this.tree_walk(this.root,e=>o.push(e.item.value)),o}get items(){let o=[];return this.tree_walk(this.root,e=>o.push({key:e.item.key.output?e.item.key.output():e.item.key,value:e.item.value})),o}isEmpty(){return this.root==null||this.root===this.nil_node}clear(){this.root=null}insert(o,e=o){if(o===void 0)return;let t=new Lt(o,e,this.nil_node,this.nil_node,null,we);return this.tree_insert(t),this.recalc_max(t),t}exist(o,e=o){let t=new Lt(o,e);return!!this.tree_search(this.root,t)}remove(o,e=o){let t=new Lt(o,e),r=this.tree_search(this.root,t);return r&&this.tree_delete(r),r}search(o,e=(t,r)=>t===r?r.output():t){let t=new Lt(o),r=[];return this.tree_search_interval(this.root,t,r),r.map(n=>e(n.item.value,n.item.key))}intersect_any(o){let e=new Lt(o);return this.tree_find_any_interval(this.root,e)}forEach(o){this.tree_walk(this.root,e=>o(e.item.key,e.item.value))}map(o){const e=new Ms;return this.tree_walk(this.root,t=>e.insert(t.item.key,o(t.item.value,t.item.key))),e}*iterate(o,e=(t,r)=>t===r?r.output():t){let t;for(o?t=this.tree_search_nearest_forward(this.root,new Lt(o)):this.root&&(t=this.local_minimum(this.root));t;)yield e(t.item.value,t.item.key),t=this.tree_successor(t)}recalc_max(o){let e=o;for(;e.parent!=null;)e.parent.update_max(),e=e.parent}tree_insert(o){let e=this.root,t=null;if(this.root==null||this.root===this.nil_node)this.root=o;else{for(;e!==this.nil_node;)t=e,o.less_than(e)?e=e.left:e=e.right;o.parent=t,o.less_than(t)?t.left=o:t.right=o}this.insert_fixup(o)}insert_fixup(o){let e,t;for(e=o;e!==this.root&&e.parent.color===we;)e.parent===e.parent.parent.left?(t=e.parent.parent.right,t.color===we?(e.parent.color=_e,t.color=_e,e.parent.parent.color=we,e=e.parent.parent):(e===e.parent.right&&(e=e.parent,this.rotate_left(e)),e.parent.color=_e,e.parent.parent.color=we,this.rotate_right(e.parent.parent))):(t=e.parent.parent.left,t.color===we?(e.parent.color=_e,t.color=_e,e.parent.parent.color=we,e=e.parent.parent):(e===e.parent.left&&(e=e.parent,this.rotate_right(e)),e.parent.color=_e,e.parent.parent.color=we,this.rotate_left(e.parent.parent)));this.root.color=_e}tree_delete(o){let e,t;o.left===this.nil_node||o.right===this.nil_node?e=o:e=this.tree_successor(o),e.left!==this.nil_node?t=e.left:t=e.right,t.parent=e.parent,e===this.root?this.root=t:(e===e.parent.left?e.parent.left=t:e.parent.right=t,e.parent.update_max()),this.recalc_max(t),e!==o&&(o.copy_data(e),o.update_max(),this.recalc_max(o)),e.color===_e&&this.delete_fixup(t)}delete_fixup(o){let e=o,t;for(;e!==this.root&&e.parent!=null&&e.color===_e;)e===e.parent.left?(t=e.parent.right,t.color===we&&(t.color=_e,e.parent.color=we,this.rotate_left(e.parent),t=e.parent.right),t.left.color===_e&&t.right.color===_e?(t.color=we,e=e.parent):(t.right.color===_e&&(t.color=we,t.left.color=_e,this.rotate_right(t),t=e.parent.right),t.color=e.parent.color,e.parent.color=_e,t.right.color=_e,this.rotate_left(e.parent),e=this.root)):(t=e.parent.left,t.color===we&&(t.color=_e,e.parent.color=we,this.rotate_right(e.parent),t=e.parent.left),t.left.color===_e&&t.right.color===_e?(t.color=we,e=e.parent):(t.left.color===_e&&(t.color=we,t.right.color=_e,this.rotate_left(t),t=e.parent.left),t.color=e.parent.color,e.parent.color=_e,t.left.color=_e,this.rotate_right(e.parent),e=this.root));e.color=_e}tree_search(o,e){if(!(o==null||o===this.nil_node))return e.equal_to(o)?o:e.less_than(o)?this.tree_search(o.left,e):this.tree_search(o.right,e)}tree_search_nearest_forward(o,e){let t,r=o;for(;r&&r!==this.nil_node;)r.less_than(e)?r.intersect(e)?(t=r,r=r.left):r=r.right:((!t||r.less_than(t))&&(t=r),r=r.left);return t||null}tree_search_interval(o,e,t){o!=null&&o!==this.nil_node&&(o.left!==this.nil_node&&!o.not_intersect_left_subtree(e)&&this.tree_search_interval(o.left,e,t),o.intersect(e)&&t.push(o),o.right!==this.nil_node&&!o.not_intersect_right_subtree(e)&&this.tree_search_interval(o.right,e,t))}tree_find_any_interval(o,e){let t=!1;return o!=null&&o!==this.nil_node&&(o.left!==this.nil_node&&!o.not_intersect_left_subtree(e)&&(t=this.tree_find_any_interval(o.left,e)),t||(t=o.intersect(e)),!t&&o.right!==this.nil_node&&!o.not_intersect_right_subtree(e)&&(t=this.tree_find_any_interval(o.right,e))),t}local_minimum(o){let e=o;for(;e.left!=null&&e.left!==this.nil_node;)e=e.left;return e}local_maximum(o){let e=o;for(;e.right!=null&&e.right!==this.nil_node;)e=e.right;return e}tree_successor(o){let e,t,r;if(o.right!==this.nil_node)e=this.local_minimum(o.right);else{for(t=o,r=o.parent;r!=null&&r.right===t;)t=r,r=r.parent;e=r}return e}rotate_left(o){let e=o.right;o.right=e.left,e.left!==this.nil_node&&(e.left.parent=o),e.parent=o.parent,o===this.root?this.root=e:o===o.parent.left?o.parent.left=e:o.parent.right=e,e.left=o,o.parent=e,o!=null&&o!==this.nil_node&&o.update_max(),e=o.parent,e!=null&&e!==this.nil_node&&e.update_max()}rotate_right(o){let e=o.left;o.left=e.right,e.right!==this.nil_node&&(e.right.parent=o),e.parent=o.parent,o===this.root?this.root=e:o===o.parent.left?o.parent.left=e:o.parent.right=e,e.right=o,o.parent=e,o!==null&&o!==this.nil_node&&o.update_max(),e=o.parent,e!=null&&e!==this.nil_node&&e.update_max()}tree_walk(o,e){o!=null&&o!==this.nil_node&&(this.tree_walk(o.left,e),e(o),this.tree_walk(o.right,e))}testRedBlackProperty(){let o=!0;return this.tree_walk(this.root,function(e){e.color===we&&(e.left.color===_e&&e.right.color===_e||(o=!1))}),o}testBlackHeightProperty(o){let e=0,t=0,r=0;if(o.color===_e&&e++,o.left!==this.nil_node?t=this.testBlackHeightProperty(o.left):t=1,o.right!==this.nil_node?r=this.testBlackHeightProperty(o.right):r=1,t!==r)throw new Error("Red-black height property violated");return e+=t,e}}class bc{constructor(){A(this,"_cache",new Map);A(this,"_continueBuildingCache",new Map)}set(o,e,t,r,n){if(!this.shouldContinueBuildingCache(o,e,t,n))return;let s=this._cache.get(o);s==null&&(s=new Map,this._cache.set(o,s));let a=s.get(e);a==null&&(a=new Map,s.set(e,a));let u=a.get(t);u==null&&(u=new Map,a.set(t,u));let c=u.get(r);c==null&&(c=new Set,u.set(r,c)),c.add(n)}getCellValuePositions(o,e,t){var r,n;return(n=(r=this._cache.get(o))==null?void 0:r.get(e))==null?void 0:n.get(t)}getCellPositions(o,e,t,r,n){var a,u,c;const s=(c=(u=(a=this._cache.get(o))==null?void 0:a.get(e))==null?void 0:u.get(t))==null?void 0:c.get(r);return s&&[...s].filter(l=>n.some(([f,m])=>l>=f&&l<=m))}setContinueBuildingCache(o,e,t,r,n){if(t===-1||r===-1||n===-1)return;let s=this._continueBuildingCache.get(o);s==null&&(s=new Map,this._continueBuildingCache.set(o,s));let a=s.get(e);a==null&&(a=new Map,s.set(e,a));let u=a.get(t);if(u==null){u=new Ms,u.insert([r,n]),a.set(t,u);return}this._handleNewInterval(u,r,n)}shouldContinueBuildingCache(o,e,t,r){var a,u;if(t===-1||r===-1)return!1;const n=(u=(a=this._continueBuildingCache.get(o))==null?void 0:a.get(e))==null?void 0:u.get(t);return n?n.search([r,r]).length===0:!0}canUseCache(o,e,t,r,n){var f,m;const s=(m=(f=this._continueBuildingCache.get(o))==null?void 0:f.get(e))==null?void 0:m.get(t);if(t===-1||r===-1||n===-1||!s)return{rowsInCache:[],rowsNotInCache:[]};const a=s.search([r,n]);if(a.length===0)return{rowsInCache:[],rowsNotInCache:[]};a.sort((d,C)=>d[0]-C[0]);const u=[],c=[];let l=r;for(let d=0;d<a.length;d++){const[C,_]=a[d];if(l>=C){if(n<=_){u.push([l,n]);break}u.push([l,_]),l=_+1,d===a.length-1&&l<=n&&c.push([l,n])}else{if(n>_){u.push([C,_]),c.push([l,C-1]),l=_+1,d===a.length-1&&l<=n&&c.push([l,n]);continue}u.push([C,n]),c.push([l,C-1])}}return{rowsInCache:u,rowsNotInCache:c}}clear(){this._cache.clear(),this._continueBuildingCache.clear()}_handleNewInterval(o,e,t){let r=o.search([e,t]);if(r.length===0){const a=[e-1<0?0:e-1,t+1];if(r=o.search(a),r.length===0){o.insert([e,t]);return}}let n=e,s=t;for(const a of r)n=Math.min(n,a[0]),s=Math.max(s,a[1]),o.remove(a);o.insert([n,s])}}const Et=new bc,On="engine-formula.config",yc={};var Rc=Object.defineProperty,pc=Object.getOwnPropertyDescriptor,Nc=(i,o,e,t)=>{for(var r=t>1?void 0:t?pc(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Rc(o,e,r),r},ba=(i,o)=>(e,t)=>o(e,t,i);exports.FormulaCurrentConfigService=class extends M.Disposable{constructor(e,t){super();A(this,"_unitData",{});A(this,"_unitStylesData",{});A(this,"_arrayFormulaCellData",{});A(this,"_arrayFormulaRange",{});A(this,"_formulaData",{});A(this,"_sheetNameMap",{});A(this,"_forceCalculate",!1);A(this,"_clearDependencyTreeCache",{});A(this,"_dirtyRanges",[]);A(this,"_dirtyNameMap",{});A(this,"_dirtyDefinedNameMap",{});A(this,"_dirtyUnitFeatureMap",{});A(this,"_dirtyUnitOtherFormulaMap",{});A(this,"_excludedCell");A(this,"_sheetIdToNameMap",{});A(this,"_executeUnitId","");A(this,"_executeSubUnitId","");this._univerInstanceService=e,this._localeService=t}dispose(){this._unitData={},this._unitStylesData={},this._formulaData={},this._arrayFormulaCellData={},this._arrayFormulaRange={},this._sheetNameMap={},this._dirtyRanges=[],this._dirtyNameMap={},this._dirtyDefinedNameMap={},this._dirtyUnitFeatureMap={},this._excludedCell={},this._sheetIdToNameMap={},this._dirtyUnitOtherFormulaMap={}}getExecuteUnitId(){return this._executeUnitId}getExecuteSubUnitId(){return this._executeSubUnitId}setExecuteUnitId(e){this._executeUnitId=e}setExecuteSubUnitId(e){this._executeSubUnitId=e}getExcludedRange(){return this._excludedCell}getUnitData(){return this._unitData}getUnitStylesData(){return this._unitStylesData}getFormulaData(){return this._formulaData}getArrayFormulaCellData(){return this._arrayFormulaCellData}getArrayFormulaRange(){return this._arrayFormulaRange}getSheetNameMap(){return this._sheetNameMap}isForceCalculate(){return this._forceCalculate}getDirtyRanges(){return this._dirtyRanges}getDirtyNameMap(){return this._dirtyNameMap}getDirtyDefinedNameMap(){return this._dirtyDefinedNameMap}getDirtyUnitFeatureMap(){return this._dirtyUnitFeatureMap}getDirtyUnitOtherFormulaMap(){return this._dirtyUnitOtherFormulaMap}getSheetName(e,t){return this._sheetIdToNameMap[e]==null?"":this._sheetIdToNameMap[e][t]||""}getClearDependencyTreeCache(){return this._clearDependencyTreeCache}getLocale(){return this._localeService.getCurrentLocale()}getSheetsInfo(){const e=this._univerInstanceService.getCurrentUnitForType(M.UniverInstanceType.UNIVER_SHEET),{id:t,sheetOrder:r}=e.getSnapshot();return{sheetOrder:r,sheetNameMap:this._sheetIdToNameMap[t]}}load(e){if(e.allUnitData&&e.unitSheetNameMap&&e.unitStylesData)this._unitData=e.allUnitData,this._unitStylesData=e.unitStylesData,this._sheetNameMap=e.unitSheetNameMap;else{const{allUnitData:t,unitSheetNameMap:r,unitStylesData:n}=this._loadSheetData();this._unitData=t,this._unitStylesData=n,this._sheetNameMap=r}this._formulaData=e.formulaData,this._arrayFormulaCellData=ii(e.arrayFormulaCellData),this._arrayFormulaRange=e.arrayFormulaRange,this._forceCalculate=e.forceCalculate,this._clearDependencyTreeCache=e.clearDependencyTreeCache||{},this._dirtyRanges=e.dirtyRanges,this._dirtyNameMap=e.dirtyNameMap,this._dirtyDefinedNameMap=e.dirtyDefinedNameMap,this._dirtyUnitFeatureMap=e.dirtyUnitFeatureMap,this._dirtyUnitOtherFormulaMap=e.dirtyUnitOtherFormulaMap,this._excludedCell=e.excludedCell,this._mergeNameMap(this._sheetNameMap,this._dirtyNameMap)}getDirtyData(){return{forceCalculation:this._forceCalculate,dirtyRanges:this._dirtyRanges,dirtyNameMap:this._dirtyNameMap,dirtyDefinedNameMap:this._dirtyDefinedNameMap,dirtyUnitFeatureMap:this._dirtyUnitFeatureMap,dirtyUnitOtherFormulaMap:this._dirtyUnitOtherFormulaMap,clearDependencyTreeCache:this._clearDependencyTreeCache}}loadDirtyRangesAndExcludedCell(e,t){this._dirtyRanges=e,this._excludedCell=t,this._dirtyNameMap={}}registerUnitData(e){this._unitData=e}registerFormulaData(e){this._formulaData=e}registerSheetNameMap(e){this._sheetNameMap=e}_mergeNameMap(e,t){Object.keys(t).forEach(r=>{t[r]&&Object.keys(t[r]).forEach(n=>{e[r]==null&&(e[r]={}),e[r][t[r][n]]=n})}),this._sheetIdToNameMap={},Object.keys(e).forEach(r=>{Object.keys(e[r]).forEach(n=>{this._sheetIdToNameMap[r]==null&&(this._sheetIdToNameMap[r]={}),this._sheetIdToNameMap[r][e[r][n]]=n})})}_loadSheetData(){const e=this._univerInstanceService.getAllUnitsForType(M.UniverInstanceType.UNIVER_SHEET),t=this._univerInstanceService.getCurrentUnitForType(M.UniverInstanceType.UNIVER_SHEET),r=t==null?void 0:t.getActiveSheet();this._executeUnitId=t==null?void 0:t.getUnitId(),this._executeSubUnitId=r==null?void 0:r.getSheetId();const n={},s={},a={};for(const u of e){const c=u.getUnitId(),l=u.getSheets(),f={},m={};for(const d of l){const C=d.getSheetId(),_=d.getConfig();f[C]={cellData:new M.ObjectMatrix(_.cellData),rowCount:_.rowCount,columnCount:_.columnCount,rowData:_.rowData,columnData:_.columnData,defaultRowHeight:_.defaultRowHeight,defaultColumnWidth:_.defaultColumnWidth},m[d.getName()]=d.getSheetId()}n[c]=f,s[c]=u.getStyles(),a[c]=m}return{allUnitData:n,unitStylesData:s,unitSheetNameMap:a}}};exports.FormulaCurrentConfigService=Nc([ba(0,M.IUniverInstanceService),ba(1,M.Inject(M.LocaleService))],exports.FormulaCurrentConfigService);const mt=M.createIdentifier("univer.formula.current-data.service");var Vc=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,Mc=(i,o,e,t)=>{for(var r=t>1?void 0:t?Oc(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Vc(o,e,r),r},Wn=(i,o)=>(e,t)=>o(e,t,i);exports.Lexer=class extends M.Disposable{constructor(o,e,t){super(),this._definedNamesService=o,this._lexerTreeBuilder=e,this._formulaCurrentConfigService=t}treeBuilder(o,e=!0){return this._lexerTreeBuilder.treeBuilder(o,e,this._injectDefinedName.bind(this),this._simpleCheckDefinedName.bind(this))}_simpleCheckDefinedName(o){const e=this._formulaCurrentConfigService.getDirtyDefinedNameMap(),t=this._formulaCurrentConfigService.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++){const a=r[n];if(o.indexOf(a)>-1)return!0}}return!1}_checkDefinedNameDirty(o){const e=this._formulaCurrentConfigService.getDirtyDefinedNameMap(),t=this._formulaCurrentConfigService.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++)if(r[n]===o)return!0}return!1}_injectDefinedName(o){const e=this._formulaCurrentConfigService.getExecuteUnitId();if(e==null)return{sequenceString:"",hasDefinedName:!1,definedNames:[]};const t=this._lexerTreeBuilder.getSequenceNode(o);let r="",n=!1;const s=[];for(let a=0,u=t.length;a<u;a++){const c=t[a];if(typeof c=="string"){r+=c;continue}const{nodeType:l,token:f}=c;if(l===ve.REFERENCE||l===ve.FUNCTION){const m=this._definedNamesService.getValueByName(e,f);if(m){let d=m.formulaOrRefString;d.substring(0,1)===X.EQUALS&&(d=d.substring(1)),r+=d,s.push(m.name),n=!0}else this._checkDefinedNameDirty(f)?(r+=h.NAME,n=!0,s.push(f)):r+=f}else r+=f}return{sequenceString:r,hasDefinedName:n,definedNames:s}}};exports.Lexer=Mc([Wn(0,lr),Wn(1,M.Inject(Vn)),Wn(2,mt)],exports.Lexer);function pi(i,o,e,t,r){var s;const n=Object.keys(r);for(const a of n){const u=r[a],c=(s=u==null?void 0:u[t])==null?void 0:s[e];if(c==null)continue;const l=c.getValue(i,o);if(l!=null)return l}}const Sc=["$","£","¥","¤","֏","؋","৳","฿","៛","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],Dc={currency:2,date:4,datetime:5,error:11,fraction:7,general:0,grouped:11,number:1,percent:6,scientific:8,text:9,time:5,unknown:11};function wc(i,o,e){var u,c;if(i==null||o==null)return o;const t=(e==null?void 0:e.getStyleByCell(i))||i.s,r=(e==null?void 0:e.getStyleByCell(o))||o.s;if(t==null||r==null||typeof t!="object"||typeof r!="object")return o;const n=(u=t==null?void 0:t.n)==null?void 0:u.pattern,s=(c=r==null?void 0:r.n)==null?void 0:c.pattern;if(n==null||s==null)return o;const a=n||s;return r.n.pattern=a,o}const os=new ft(1e5);function ya(i){const o=os.get(i);if(o!==void 0)return o;const e=Lc(i);return os.set(i,e),e}function Pc(){os.clear()}function Lc(i){if(xc(i))return 3;const o=M.numfmt.getInfo(i).type||"unknown";return Dc[o]}function xc(i){return!!Sc.find(o=>i.includes(o))&&i.startsWith("_(")}function vr(i,o,e){if(i==="")return o;if(o==="")return i;const t=ya(i),r=ya(o);return e===X.PLUS||e===X.MINUS?t===4&&r===4||t===11&&r===11?"":o:e===X.MULTIPLY||e===X.DIVIDED?t===6&&r===6||t===7&&r===7||t===8&&r===8||t===9&&r===9?o:"":i||o}const jc=new Map([[M.LocaleType.EN_US,"$"],[M.LocaleType.RU_RU,"₽"],[M.LocaleType.VI_VN,"₫"],[M.LocaleType.ZH_CN,"¥"],[M.LocaleType.ZH_TW,"NT$"]]);function Ra(i){return jc.get(i)||"$"}function Ye(i,o=2){let e=o;o>127&&(e=127);let t="";return e>0&&(t=`.${"0".repeat(e)}`),`"${Ra(i)}"#,##0${t}_);[Red]("${Ra(i)}"#,##0${t})`}function Uc(i,o,e=2){return M.numfmt.format(Ye(i,e),o)}const Ss=new ft(1e5);function vc(i){let o=i;o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1));const e=Ss.get(o);if(e)return{isNumberPattern:!0,value:e.value,pattern:e.pattern};const t=M.numfmt.parseNumber(o);if(t)return Qn(o,t.v,t.z);const r=M.numfmt.parseDate(o);if(r)return Qn(o,r.v,r.z);const n=M.numfmt.parseTime(o);return n?Qn(o,n.v,n.z):{isNumberPattern:!1}}function Qn(i,o,e){return Ss.set(i,{value:o,pattern:e}),{isNumberPattern:!0,value:o,pattern:e}}function Tc(){Ss.clear()}class Mn{constructor(){A(this,"pattern","")}dispose(){}getPattern(){return this.pattern}setPattern(o){this.pattern=o}isError(){return!1}isAsyncObject(){return!1}isAsyncArrayObject(){return!1}isReferenceObject(){return!1}isArray(){return!1}isValueObject(){return!1}isEqualType(o){return!1}}class ht extends Mn{constructor(o){super(),this._rawValue=o}isValueObject(){return!0}toUnitRange(){return{range:{startColumn:-1,startRow:-1,endRow:-1,endColumn:-1},sheetId:"",unitId:""}}getValue(){return 0}getArrayValue(){return[]}setValue(o){}setArrayValue(o){}isCube(){return!1}isString(){return!1}isNumber(){return!1}isBoolean(){return!1}isLambda(){return!1}isError(){return!1}isNull(){return!1}sum(){return g.create(h.VALUE)}max(){return g.create(h.VALUE)}min(){return g.create(h.VALUE)}count(){return g.create(h.VALUE)}countA(){return g.create(h.VALUE)}countBlank(){return g.create(h.VALUE)}getNegative(){return g.create(h.VALUE)}getReciprocal(){return g.create(h.VALUE)}plus(o){return g.create(h.VALUE)}minus(o){return g.create(h.VALUE)}multiply(o){return g.create(h.VALUE)}divided(o){return g.create(h.VALUE)}mod(o){return g.create(h.VALUE)}map(o){return g.create(h.NAME)}mapValue(o){return g.create(h.NAME)}compare(o,e,t=!1){return g.create(h.NAME)}isEqual(o){return this.compare(o,$.EQUALS)}isNotEqual(o){return this.compare(o,$.NOT_EQUAL)}isGreaterThanOrEqual(o){return this.compare(o,$.GREATER_THAN_OR_EQUAL)}isLessThanOrEqual(o){return this.compare(o,$.LESS_THAN_OR_EQUAL)}isLessThan(o){return this.compare(o,$.LESS_THAN)}isGreaterThan(o){return this.compare(o,$.GREATER_THAN)}concatenateFront(o){return g.create(h.NAME)}concatenateBack(o){return g.create(h.NAME)}plusBy(o){return g.create(h.VALUE)}minusBy(o){return g.create(h.VALUE)}multiplyBy(o){return g.create(h.VALUE)}dividedBy(o){return g.create(h.VALUE)}modInverse(o){return g.create(h.VALUE)}compareBy(o,e){return g.create(h.NAME)}concatenate(o,e=Je.FRONT){let t=this.getValue().toString();if(typeof o=="string")e===Je.FRONT?t=o+t:t+=o;else if(typeof o=="number")e===Je.FRONT?t=o.toString()+t:t+=o.toString();else if(typeof o=="boolean"){const r=o?"TRUE":"FALSE";e===Je.FRONT?t=r+t:t+=r}return t}pow(o){return g.create(h.VALUE)}powInverse(o){return g.create(h.VALUE)}sqrt(){return g.create(h.VALUE)}cbrt(){return g.create(h.VALUE)}cos(){return g.create(h.VALUE)}cosh(){return g.create(h.VALUE)}acos(){return g.create(h.VALUE)}acosh(){return g.create(h.VALUE)}sin(){return g.create(h.VALUE)}sinh(){return g.create(h.VALUE)}asin(){return g.create(h.VALUE)}asinh(){return g.create(h.VALUE)}tan(){return g.create(h.VALUE)}tanh(){return g.create(h.VALUE)}atan(){return g.create(h.VALUE)}atan2(o){return g.create(h.VALUE)}atan2Inverse(o){return g.create(h.VALUE)}atanh(){return g.create(h.VALUE)}mean(){return this}median(){return this}var(){return this}std(){return this}log(){return g.create(h.VALUE)}log10(){return g.create(h.VALUE)}exp(){return g.create(h.VALUE)}abs(){return g.create(h.VALUE)}round(o){return g.create(h.VALUE)}roundInverse(o){return g.create(h.VALUE)}floor(o){return g.create(h.VALUE)}floorInverse(o){return g.create(h.VALUE)}ceil(o){return g.create(h.VALUE)}ceilInverse(o){return g.create(h.VALUE)}convertToNumberObjectValue(){return g.create(h.VALUE)}convertToBooleanObjectValue(){return g.create(h.VALUE)}}const Bc=1e3,pa=new ft(Bc);class g extends ht{constructor(o,e=""){super(o),this._errorType=o,this._errorContent=e}static create(o,e=""){const t=`${o}-${e}`,r=pa.get(t);if(r)return r;const n=new g(o,e);return pa.set(t,n),n}getValue(){return this._errorType}getErrorType(){return this._errorType}getErrorContent(){return this._errorContent}isEqualType(o){return o.getErrorType()===this.getErrorType()}isError(){return!0}}function Ic(i){if(i===null)return 0;if(i!=null&&i.p){const o=i==null?void 0:i.p.body;if(o==null)return 0;const e=o.dataStream;return M.BuildTextUtils.transform.getPlainText(e)}return(i==null?void 0:i.v)||0}var Ut=(i=>(i[i.MIN=0]="MIN",i[i.MAX=1]="MAX",i))(Ut||{}),Oe=(i=>(i[i.NORMAL=0]="NORMAL",i[i.MIN=1]="MIN",i[i.MAX=2]="MAX",i))(Oe||{});function tn(){return Intl&&Intl.Collator?new Intl.Collator(void 0,{numeric:!1}).compare:(i,o)=>i.localeCompare(o)}function Fc(i){return i.indexOf("*")>-1||i.indexOf("?")>-1}function qn(i,o){const e=$c(o).replace(/~?[*?]/g,r=>r.startsWith("~")?`\\${r.substring(1)}`:r==="*"?".*":r==="?"?".":r);return new RegExp(`^${e}$`).test(i)}function Na(i){return i.replace(/~?[*?]/g,o=>o.startsWith("~")?o.substring(1):" ")}function kc(i,o,e){let t=!1;switch(e){case $.EQUALS:t=qn(i,o);break;case $.NOT_EQUAL:t=!qn(i,o);break;case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:t=qn(i,o)||i>Na(o);break;case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:t=i<Na(o);break}return t}function $c(i){return i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}function us(i){switch(i){case 1:return 2;case 0:return 0;case-1:return 1;default:return 0}}function cs(i){return i===-2?1:0}function Ds(i){let o;switch(i){case $.EQUALS:o=$.EQUALS;break;case $.GREATER_THAN:o=$.LESS_THAN;break;case $.GREATER_THAN_OR_EQUAL:o=$.LESS_THAN_OR_EQUAL;break;case $.LESS_THAN:o=$.GREATER_THAN;break;case $.LESS_THAN_OR_EQUAL:o=$.GREATER_THAN_OR_EQUAL;break;case $.NOT_EQUAL:o=$.NOT_EQUAL;break}return o}/*!
1
+ "use strict";var Du=Object.defineProperty;var wu=(i,o,e)=>o in i?Du(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var A=(i,o,e)=>wu(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("@univerjs/core"),Jt=require("rxjs"),Pu=require("@univerjs/rpc"),dr=require("@univerjs/engine-formula");var Ot=(i=>(i.FALSE="FALSE",i.TRUE="TRUE",i))(Ot||{}),Rt=(i=>(i[i.SUCCESS=0]="SUCCESS",i[i.ERROR=1]="ERROR",i))(Rt||{}),Je=(i=>(i[i.FRONT=0]="FRONT",i[i.BACK=1]="BACK",i))(Je||{});function ri(i,o,e,t,r){for(let n=0,s=i.length;n<s;n++){const a=i[n];if(o!==a.unitId||e!==a.sheetId)continue;const{startRow:u,startColumn:c,endRow:l,endColumn:f}=a.range;if(t>=u&&t<=l&&r>=c&&r<=f)return!0}return!1}var h=(i=>(i.DIV_BY_ZERO="#DIV/0!",i.NAME="#NAME?",i.VALUE="#VALUE!",i.NUM="#NUM!",i.NA="#N/A",i.CYCLE="#CYCLE!",i.REF="#REF!",i.SPILL="#SPILL!",i.CALC="#CALC!",i.ERROR="#ERROR!",i.CONNECT="#GETTING_DATA",i.NULL="#NULL!",i))(h||{});const qt=new Set(Object.values(h)),ca=[...new Set(Object.values(h).map(i=>i.length))];var ni=(i=>(i[i.Financial=0]="Financial",i[i.Date=1]="Date",i[i.Math=2]="Math",i[i.Statistical=3]="Statistical",i[i.Lookup=4]="Lookup",i[i.Database=5]="Database",i[i.Text=6]="Text",i[i.Logical=7]="Logical",i[i.Information=8]="Information",i[i.Engineering=9]="Engineering",i[i.Cube=10]="Cube",i[i.Compatibility=11]="Compatibility",i[i.Web=12]="Web",i[i.Array=13]="Array",i[i.Univer=14]="Univer",i[i.User=15]="User",i[i.DefinedName=16]="DefinedName",i))(ni||{}),X=(i=>(i.PLUS="+",i.MINUS="-",i.MULTIPLY="*",i.DIVIDED="/",i.CONCATENATE="&",i.POWER="^",i.EQUALS="=",i.NOT_EQUAL="<>",i.GREATER_THAN=">",i.GREATER_THAN_OR_EQUAL=">=",i.LESS_THAN="<",i.LESS_THAN_OR_EQUAL="<=",i))(X||{}),$=(i=>(i.EQUALS="=",i.NOT_EQUAL="<>",i.GREATER_THAN=">",i.GREATER_THAN_OR_EQUAL=">=",i.LESS_THAN="<",i.LESS_THAN_OR_EQUAL="<=",i))($||{});const $r=new Map([["<>",4],["<",4],[">=",4],["=",4],[">",4],["<=",4],["&",3],["+",2],["-",2],["/",1],["*",1],["^",0]]),At=new Set($r.keys()),Lu=new Set(["=","<>",">",">=","<","<="]);var Q=(i=>(i.OPEN_BRACKET="(",i.CLOSE_BRACKET=")",i.COMMA=",",i.SINGLE_QUOTATION="'",i.DOUBLE_QUOTATION='"',i.OPEN_BRACES="{",i.CLOSE_BRACES="}",i.COLON=":",i.OPEN_SQUARE_BRACKET="[",i.CLOSE_SQUARE_BRACKET="]",i))(Q||{}),He=(i=>(i.PERCENTAGE="%",i.POUND="#",i))(He||{});const Yn=new Set(["%","#"]);var pe=(i=>(i.AT="@",i.MINUS="-",i.PLUS="+",i))(pe||{});const xu=" ",si=[...Object.values($),...Object.values(X),...Object.values(Q),...Object.values(He),...Object.values(pe)];function Cr(i){return si.includes(i)}function ai(i){for(const o of si)if(i.indexOf(o)>-1)return!0;return!1}function ju(i){return i[0]==="'"&&i[i.length-1]==="'"?i.substring(1,i.length-1):i}function Uu(i){return Cr(i)&&i!==Q.CLOSE_BRACES&&i!==Q.CLOSE_BRACKET&&i!==Q.SINGLE_QUOTATION&&i!==Q.DOUBLE_QUOTATION||i===" "}const vu=new Set([X.PLUS,X.MINUS,X.MULTIPLY,X.DIVIDED,X.CONCATENATE,X.POWER,X.EQUALS,X.NOT_EQUAL,X.GREATER_THAN,X.GREATER_THAN_OR_EQUAL,X.LESS_THAN,X.LESS_THAN_OR_EQUAL,Q.OPEN_BRACKET,Q.COMMA,Q.COLON,Q.OPEN_BRACES,Q.OPEN_SQUARE_BRACKET]);function Tu(i){return vu.has(i)}const Bu=new Set([X.PLUS,X.MINUS,X.MULTIPLY,X.DIVIDED,X.CONCATENATE,X.POWER,X.EQUALS,X.NOT_EQUAL,X.GREATER_THAN,X.GREATER_THAN_OR_EQUAL,X.LESS_THAN,X.LESS_THAN_OR_EQUAL,Q.OPEN_BRACKET,Q.COMMA,Q.COLON,Q.OPEN_BRACES,Q.OPEN_SQUARE_BRACKET,He.PERCENTAGE,He.POUND]);function Iu(i){return Bu.has(i)}function ii(i){const o={};return Object.keys(i).forEach(e=>{const t=i[e];if(t==null)return!0;o[e]==null&&(o[e]={}),Object.keys(t).forEach(r=>{const n=t[r];o[e][r]=new M.ObjectMatrix(n)})}),o}function Fu(i){const o={};for(const e in i){const t=i[e];if(t!=null){o[e]==null&&(o[e]={});for(const r in t){const n=t[r],s={};n.forValue((a,u,c)=>{s[a]===void 0&&(s[a]={}),s[a][u]=c}),o[e][r]=s}}}return o}const oi='\\[([^\\[\\]\\/?:"<>|*\\\\]+)\\]',la=new RegExp(oi),ku="((?![\\[\\]\\/?*\\\\]).)*!",Mt="$",Rs="\\s*?:\\s*?",Xr="[A-Za-z]+",Kr="[1-9][0-9]*",cr=`'?(${oi})?(${ku})?'?`,ns=`\\${Mt}?${Xr}\\${Mt}?${Kr}`,$u=`^(${pe.AT})?${cr}${ns}${Rs}${ns}$`,fa=new RegExp($u),Yu=`^${cr}\\s*?${ns}(${He.POUND})?$`,ma=new RegExp(Yu),Hu=`^${cr}\\${Mt}?${Kr}${Rs}\\${Mt}?${Kr}$`,ha=new RegExp(Hu),Gu=`^${cr}\\${Mt}?${Xr}${Rs}\\${Mt}?${Xr}$`,ga=new RegExp(Gu),Wu=`^${cr}\\s*?\\${Mt}?${Kr}$`,da=new RegExp(Wu),Qu=`^${cr}\\s*?\\${Mt}?${Xr}$`,Ca=new RegExp(Qu),qu="{.*?}",_a=new RegExp(qu,"g");function Nr(i){return ma.lastIndex=0,ma.test(i)}function Xu(i){return fa.lastIndex=0,fa.test(i)}function ui(i){return ha.lastIndex=0,ha.test(i)}function ci(i){return ga.lastIndex=0,ga.test(i)}function li(i){return da.lastIndex=0,da.test(i)}function fi(i){return Ca.lastIndex=0,Ca.test(i)}function Ku(i){return _a.lastIndex=0,_a.test(i)}function mi(i){return Nr(i)||Xu(i)||ui(i)||ci(i)}const hi={id:"formula.mutation.register-function",type:M.CommandType.MUTATION,handler:()=>!0},Zr={id:"formula.mutation.set-array-formula-data",type:M.CommandType.MUTATION,handler:(i,o)=>!0},Zu=/[^0-9]/g,zu=/[^A-Za-z]/g;function _r(i){let o=i[0]==="$";const e=i.substring(1);let t=e.indexOf("$")>-1;return M.Tools.isStringNumber(e)&&o&&!t&&(o=!1,t=!0),o&&t?M.AbsoluteRefType.ALL:o?M.AbsoluteRefType.COLUMN:t?M.AbsoluteRefType.ROW:M.AbsoluteRefType.NONE}function Ju(i){const o=i.split("!");o.length>1&&(i=o[o.length-1]);const e=i.split(":");return e.length>1?{startAbsoluteRefType:_r(e[0]),endAbsoluteRefType:_r(e[1])}:{startAbsoluteRefType:_r(e[0])}}function Aa(i=M.AbsoluteRefType.NONE){let o="",e="";return i===M.AbsoluteRefType.ROW?o="$":i===M.AbsoluteRefType.COLUMN?e="$":i===M.AbsoluteRefType.ALL&&(o="$",e="$"),{rowAbsoluteString:o,columnAbsoluteString:e}}function St(i){const{startColumn:o,startRow:e,endColumn:t,endRow:r,startAbsoluteRefType:n,endAbsoluteRefType:s,rangeType:a=M.RANGE_TYPE.NORMAL}=i,u=Aa(n),c=Aa(s);if(a===M.RANGE_TYPE.ROW||a===M.RANGE_TYPE.ALL){const m=`${u.rowAbsoluteString}${e+1}`,d=`${c.rowAbsoluteString}${r+1}`;return`${m}:${d}`}if(a===M.RANGE_TYPE.COLUMN){const m=`${u.columnAbsoluteString}${M.Tools.chatAtABC(o)}`,d=`${c.columnAbsoluteString}${M.Tools.chatAtABC(t)}`;return`${m}:${d}`}const l=`${u.columnAbsoluteString}${M.Tools.chatAtABC(o)}${u.rowAbsoluteString}${e+1}`,f=`${c.columnAbsoluteString}${M.Tools.chatAtABC(t)}${c.rowAbsoluteString}${r+1}`;return l===f?l:`${l}:${f}`}function gi(i,o){return Jr(i)?`'${i}'!${St(o)}`:`${i}!${St(o)}`}function di(i,o,e){return Jr(i)||Jr(o)?`'[${i}]${o}'!${St(e)}`:`[${i}]${o}!${St(e)}`}function zr(i){const{unitId:o,sheetName:e,range:t}=i;return o!=null&&o.length>0&&e!=null&&e.length>0?di(o,e,t):e!=null&&e.length>0?gi(e,t):St(t)}function Yr(i){const o=Number.parseInt(i.replace(Zu,""))-1,e=M.Tools.ABCatNum(i.replace(zu,"")),t=_r(i);return{row:o,column:e,absoluteRefType:t}}function An(i){const o=la.exec(i);let e="";o!=null&&(e=o[0].trim(),e=e.slice(1,e.length-1),i=i.replace(la,""));const t=i.indexOf("!");let r="",n="";return t>-1?(r=i.substring(0,t),r[0]==="'"&&r[r.length-1]==="'"&&(r=r.substring(1,r.length-1)),n=i.substring(t+1)):n=i,{refBody:n,sheetName:r,unitId:e}}function Er(i){const{refBody:o,sheetName:e,unitId:t}=An(i),r=o.indexOf(":");if(r===-1){const C=Yr(o),_=C.row,E=C.column,b=C.absoluteRefType;return{unitId:t,sheetName:e,range:{startRow:_,startColumn:E,endRow:_,endColumn:E,startAbsoluteRefType:b,endAbsoluteRefType:b}}}const n=o.substring(0,r),s=o.substring(r+1),a=Yr(n),u=Yr(s),c=a.row>u.row?u.row:a.row,l=a.column>u.column?u.column:a.column,f=a.row>u.row?a.row:u.row,m=a.column>u.column?a.column:u.column;let d=M.RANGE_TYPE.NORMAL;return Number.isNaN(c)&&Number.isNaN(f)?d=M.RANGE_TYPE.COLUMN:Number.isNaN(l)&&Number.isNaN(m)&&(d=M.RANGE_TYPE.ROW),{unitId:t,sheetName:e,range:{startRow:c,startColumn:l,endRow:f,endColumn:m,startAbsoluteRefType:a.absoluteRefType,endAbsoluteRefType:u.absoluteRefType,rangeType:d}}}const ec=["LOG10"];function Ar(i){const o=Ci(i);if(!mi(o)||ec.includes(o.toUpperCase().trim()))return!1;const{range:e}=Er(o);return!(e.endColumn>=16384)}function Ci(i){const o=[];let e=!1;for(let t=0,r=i.length;t<r;t++){const n=i[t];if(n===xu&&!e)o.push(n);else{if(!e&&(n===pe.AT||n===pe.MINUS||n===pe.PLUS))continue;o.push(n),e=!0}}return o.join("")}function tc(i,o){const e=(i==null?void 0:i.split(","))||[];return i===""||e.length===0?[]:_i(i)?e.map(n=>{const s=Er(n);return{unitId:s.unitId,sheetId:o(s.sheetName),range:s.range,sheetName:s.sheetName}}):[]}function _i(i){return((i==null?void 0:i.split(","))||[]).every(e=>Ar(e.trim()))}function Jr(i){return i.length===0?!1:!!(ai(i)||rc(i)||nc(i)||sc(i)||/[\s!$%^&*()+\-=\[\]{};':"\\|,.<>\/?]/.test(i))}function rc(i){const o=i.match(/[1-9][0-9]{0,6}/);return/^[A-Z]+[1-9][0-9]{0,6}$/.test(i)&&o!==null}function nc(i){return/^(R(-?[0-9]+)?C(-?[0-9]+)?|C(-?[0-9]+)?|R(-?[0-9]+)?)$/.test(i)}function sc(i){return!new RegExp("^\\p{Letter}","u").test(i.charAt(0))}var ac=Object.defineProperty,ic=Object.getOwnPropertyDescriptor,oc=(i,o,e,t)=>{for(var r=t>1?void 0:t?ic(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&ac(o,e,r),r},uc=(i,o)=>(e,t)=>o(e,t,i);exports.DefinedNamesService=class extends M.Disposable{constructor(e){super();A(this,"_definedNameMap",{});A(this,"_update$",new Jt.Subject);A(this,"update$",this._update$.asObservable());A(this,"_currentRange",{unitId:"",sheetId:"",range:{startRow:0,endRow:0,startColumn:0,endColumn:0}});A(this,"_currentRange$",new Jt.Subject);A(this,"currentRange$",this._currentRange$.asObservable());A(this,"_focusRange$",new Jt.Subject);A(this,"focusRange$",this._focusRange$.asObservable());this._univerInstanceService=e}dispose(){this._definedNameMap={}}getWorksheetByRef(e,t){var n;const{sheetName:r}=An(t);return(n=this._univerInstanceService.getUnit(e))==null?void 0:n.getSheetBySheetName(r)}focusRange(e,t){const r=this.getValueById(e,t);r!=null&&this._focusRange$.next({...r,unitId:e})}setCurrentRange(e){this._currentRange=e,this._currentRange$.next(e)}getCurrentRange(){return this._currentRange}getCurrentRangeForString(){return St(this._currentRange.range)}registerDefinedNames(e,t){this._definedNameMap[e]=t,this._update()}registerDefinedName(e,t){this._definedNameMap[e]==null&&(this._definedNameMap[e]={}),this._definedNameMap[e][t.id]=t,this._update()}removeDefinedName(e,t){var r;(r=this._definedNameMap[e])==null||delete r[t],this._update()}removeUnitDefinedName(e){delete this._definedNameMap[e],this._update()}getDefinedNameMap(e){return this._definedNameMap[e]}getValueByName(e,t){var n;const r=this._definedNameMap[e];return r==null?null:(n=Array.from(Object.values(r)).filter(s=>s.name===t))==null?void 0:n[0]}getValueById(e,t){var r;return(r=this._definedNameMap[e])==null?void 0:r[t]}hasDefinedName(e){return this._definedNameMap[e]==null?!1:(Array.from(Object.values(this._definedNameMap[e])).length||0)!==0}_update(){this._update$.next(null)}};exports.DefinedNamesService=oc([uc(0,M.IUniverInstanceService)],exports.DefinedNamesService);const lr=M.createIdentifier("univer.formula.defined-names.service"),cc=(i,o)=>{const{unitId:e,id:t}=o;return{...i.get(lr).getValueById(e,t),unitId:e}},Vr={id:"formula.mutation.set-defined-name",type:M.CommandType.MUTATION,handler:()=>!0},En={id:"formula.mutation.remove-defined-name",type:M.CommandType.MUTATION,handler:()=>!0},bn={id:"formula.mutation.set-feature-calculation",type:M.CommandType.MUTATION,handler:()=>!0},yn={id:"formula.mutation.remove-feature-calculation",type:M.CommandType.MUTATION,handler:()=>!0},ps={id:"formula.mutation.set-formula-calculation-start",type:M.CommandType.MUTATION,handler:()=>!0},Ns={id:"formula.mutation.set-formula-calculation-stop",type:M.CommandType.MUTATION,handler:()=>!0},en={id:"formula.mutation.set-formula-calculation-notification",type:M.CommandType.MUTATION,handler:()=>!0},Vs={id:"formula.mutation.set-formula-calculation-result",type:M.CommandType.MUTATION,handler:()=>!0},Rn={id:"formula.mutation.set-formula-data",type:M.CommandType.MUTATION,handler:(i,o)=>!0},pn={id:"formula.mutation.set-other-formula",type:M.CommandType.MUTATION,handler:()=>!0},Nn={id:"formula.mutation.remove-other-formula",type:M.CommandType.MUTATION,handler:()=>!0},Ai={id:"formula.mutation.set-super-table",type:M.CommandType.MUTATION,handler:()=>!0},Ei={id:"formula.mutation.remove-super-table",type:M.CommandType.MUTATION,handler:()=>!0},Os={id:"formula.mutation.set-super-table-option",type:M.CommandType.MUTATION,handler:()=>!0};class ft{constructor(o){A(this,"_cache");this._cache=new M.LRUMap(o)}set(o,e){const t=this._hash(o);this._cache.set(t,e)}get(o){const e=this._hash(o);return this._cache.get(e)}clear(){this._cache.clear()}_hash(o){return o.length<=64?o:M.hashAlgorithm(o).toString()}}const ut="P_1",Nt="R_1",nr="L_1",Or="LR_1",bi="LO_1",lc="LET",br="LAMBDA",fc="CUBE",mc=new Set(["RAND","RANDBETWEEN","NOW","TODAY"]),ss=new ft(1e5);function Yt(i){const o=ss.get(i);if(o)return o;const e=Er(i);return ss.set(i,e),Er(i)}function hc(){ss.clear()}var ve=(i=>(i[i.NORMAL=0]="NORMAL",i[i.NUMBER=1]="NUMBER",i[i.STRING=2]="STRING",i[i.FUNCTION=3]="FUNCTION",i[i.REFERENCE=4]="REFERENCE",i[i.ARRAY=5]="ARRAY",i[i.DEFINED_NAME=6]="DEFINED_NAME",i))(ve||{});function as(i){let o="";for(const e of i)typeof e=="string"?o+=e:o+=e.token;return o}class se{constructor(){A(this,"_parent");A(this,"_token",Nt);A(this,"_children",[]);A(this,"_lambdaId");A(this,"_functionDefinitionPrivacyVar");A(this,"_lambdaParameter","");A(this,"_startIndex",-1);A(this,"_endIndex",-1);A(this,"_definedNames",[])}dispose(){var o;this._children.forEach(e=>{typeof e!="string"&&e.dispose()}),(o=this._functionDefinitionPrivacyVar)==null||o.clear(),this._functionDefinitionPrivacyVar=null,this._children=[],this._parent=null,this._definedNames=[]}getDefinedNames(){return this._definedNames}getStartIndex(){return this._startIndex}getLambdaId(){return this._lambdaId}setLambdaId(o){this._lambdaId=o}getFunctionDefinitionPrivacyVar(){return this._functionDefinitionPrivacyVar}setLambdaPrivacyVar(o){this._functionDefinitionPrivacyVar=o}getLambdaParameter(){return this._lambdaParameter}setLambdaParameter(o){this._lambdaParameter=o}getParent(){return this._parent}setParent(o){this._parent=o}getChildren(){return this._children}setChildren(o){this._children=o}addChildren(o){this._children.push(o)}addChildrenFirst(o){this._children.unshift(o)}getToken(){return this._token}setToken(o){this._token=o}setIndex(o,e){this._startIndex=o,this._endIndex=e}setDefinedNames(o){this._definedNames=o}hasDefinedNames(){return this._definedNames.length>0}replaceChild(o,e){const t=this._getIndexInParent(o);t!=null&&(this.getChildren().splice(t,1,e),e.setParent(this))}changeToParent(o){const e=this.getParent();e&&e.removeChild(this),this.setParent(o),o.getChildren().push(this)}removeChild(o){const e=this._getIndexInParent(o);e!=null&&this.getChildren().splice(e,1)}serialize(){const o=this.getToken(),e=this.getChildren(),t=[],r=e.length;for(let n=0;n<r;n++){const s=e[n];s instanceof se?t.push(s.serialize()):t.push(s)}return{token:o,st:this._startIndex,ed:this._endIndex,children:t}}_getIndexInParent(o){const e=this.getChildren(),t=e.length;for(let r=0;r<t;r++)if(e[r]===o)return r}}const yi=2e3,Hn=new ft(yi),Gn=new ft(yi);class Vn extends M.Disposable{constructor(){super(...arguments);A(this,"_currentLexerNode",new se);A(this,"_upLevel",0);A(this,"_segment","");A(this,"_bracketState",[]);A(this,"_squareBracketState",0);A(this,"_bracesState",0);A(this,"_singleQuotationState",0);A(this,"_doubleQuotationState",0);A(this,"_lambdaState",!1);A(this,"_colonState",!1);A(this,"_formulaErrorCount",0);A(this,"_tableBracketState",!1)}dispose(){this._resetTemp(),this._currentLexerNode.dispose(),Hn.clear(),Gn.clear()}getUpLevel(){return this._upLevel}isColonClose(){return this._colonState===!1}isColonOpen(){return this._colonState===!0}isDoubleQuotationClose(){return this._doubleQuotationState===0}isLambdaOpen(){return this._lambdaState===!0}isLambdaClose(){return this._lambdaState===!1}isSingleQuotationClose(){return this._singleQuotationState===0}isBracesClose(){return this._bracesState===0}isBracketClose(){return this._bracketState.length===0}isSquareBracketClose(){return this._squareBracketState===0}getCurrentLexerNode(){return this._currentLexerNode}getFunctionAndParameter(e,t){const r=this._getCurrentParamIndex(e,t);if(r==null||r===h.VALUE)return;const n=r[0];if(typeof n=="string")return;let s=n.getParent(),a=n;for(;s;){const u=s.getToken();if(u!==ut&&!Cr(u)&&s.getStartIndex()!==-1){const c=s.getChildren().indexOf(a);return{functionName:u,paramIndex:c}}a=s,s=s.getParent()}}checkIfAddBracket(e){let t=0,r=e.length-1,n=e[r];for(;(n===Q.CLOSE_BRACKET||n===" ")&&r>=0;)n===Q.CLOSE_BRACKET&&t++,n=e[--r];const s=this._getCurrentParamIndex(e,e.length-2);if(s==null||s===h.VALUE)return 0;const a=s[0];if(typeof a=="string")return 0;let u=a.getParent(),c=0;for(s[1]===Q.OPEN_BRACKET&&c++;u;){const l=u.getToken();l!==ut&&l!==Q.COLON&&u.getStartIndex()!==-1&&l.toUpperCase()!==br&&(t===0?c+=1:t--),u=u.getParent()}return c}sequenceNodesBuilder(e){const t=Gn.get(e);if(t)return[...t];const r=this._getSequenceArray(e);if(r.length===0)return;const n=this.getSequenceNode(r);return Gn.set(e,[...n]),n}convertRefersToAbsolute(e,t,r){const n=this.sequenceNodesBuilder(e);if(n==null)return e;let s="";e.substring(0,1)===X.EQUALS&&(s=X.EQUALS);for(let a=0,u=n.length;a<u;a++){const c=n[a];if(typeof c!="string"&&c.nodeType===ve.REFERENCE){const{token:l,endIndex:f}=c,m=Yt(l);if(m==null)continue;const{range:d,sheetName:C,unitId:_}=m,E={...d,startAbsoluteRefType:t,endAbsoluteRefType:r},b=zr({range:E,unitId:_,sheetName:C}),R=b.length-l.length;n[a]={...c,token:b,endIndex:f+R};for(let p=a+1;p<u;p++){const V=n[p];typeof V!="string"&&(V.startIndex+=R,V.endIndex+=R)}}}return`${s}${as(n)}`}moveFormulaRefOffset(e,t,r,n=!1){const s=this.sequenceNodesBuilder(e);if(s==null)return e;const a=[];for(let u=0,c=s.length;u<c;u++){const l=s[u];if(typeof l=="string"||l.nodeType!==ve.REFERENCE){a.push(l);continue}const{token:f}=l,m=Yt(f),{sheetName:d,unitId:C}=m;let _=m.range;if(!n&&_.startAbsoluteRefType===M.AbsoluteRefType.ALL&&_.endAbsoluteRefType===M.AbsoluteRefType.ALL){a.push(l);continue}else _=M.moveRangeByOffset(_,t,r,n);let E="";M.isValidRange(_)?E=zr({range:_,unitId:C,sheetName:d}):E=h.REF,a.push({...l,token:E})}return`=${as(a)}`}_formulaSpellCheck(){if(this._currentLexerNode.getChildren().length===0)return!0;const e=this._currentLexerNode.getChildren()[0];return!!(e instanceof se||At.has(e)||Yn.has(e)||e===pe.AT||e===Q.COMMA||e===Q.COLON||e===Q.OPEN_BRACKET)}getSequenceNode(e){const t=[];let r=!1;for(let n=0,s=e.length;n<s;n++){const a=e[n],u=e[n-1],{segment:c,currentString:l}=a;if(l===Q.DOUBLE_QUOTATION&&(r=!0),(c!==""||n===0)&&n!==s-1){t.push(l);continue}let f=(u==null?void 0:u.segment)||"";const m=n-f.length;let d=n-1;const C=n-1;if(n===s-1&&this._isLastMergeString(l)&&(f+=l,d+=1),f===""||$r.has(f)){t.push(l);continue}const _=f.trim(),E=Ci(_);r===!0&&_[_.length-1]===Q.DOUBLE_QUOTATION&&_[0]!==Q.OPEN_BRACES?(r=!1,this._processPushSequenceNode(t,ve.STRING,f,m,d,C)):Nr(E)&&Ar(E)?this._processPushSequenceNode(t,ve.REFERENCE,f,m,d,C):M.Tools.isStringNumber(_)?this._processPushSequenceNode(t,ve.NUMBER,f,m,d,C):_.length>0&&this._processPushSequenceNode(t,ve.FUNCTION,f,m,d,C),(n!==s-1||!this._isLastMergeString(l))&&t.push(l)}return this._mergeSequenceNodeReference(t)}_processPushSequenceNode(e,t,r,n,s,a){this._pushSequenceNode(e,{nodeType:t,token:r,startIndex:n,endIndex:s},a)}_getCurrentParamIndex(e,t){return this._nodeMaker(e,void 0,t)}_isLastMergeString(e){return e===Q.DOUBLE_QUOTATION||M.Tools.isStringNumber(e)||!Cr(e)}_mergeSequenceNodeReference(e){const t=[],r=e.length;let n=0;for(;n<r;){const s=e[n];if(typeof s=="string"){const a=e[n-1];if(s.trim()===Q.CLOSE_BRACES&&a!=null&&typeof a!="string"&&a.nodeType===ve.FUNCTION&&a.token.trim().substring(0,1)===Q.OPEN_BRACES){a.nodeType=ve.ARRAY,a.token+=s,a.endIndex+=s.length,n++;continue}t.push(s)}else{const a=e[n+1],u=e[n+2];a===Q.COLON&&typeof s!="string"&&u!=null&&typeof u!="string"&&Ar((s.token+a+u.token).trim())&&(s.nodeType=ve.REFERENCE,s.token+=a+u.token,s.endIndex=u.endIndex,n+=2),t.push(s)}n++}return this._minusSplitSequenceNode(t)}_minusSplitSequenceNode(e){const t=[];for(const r of e){if(typeof r!="string"){const s=r.token.match(/^(\s*([-@+]\s*)+)(.*)$/);if(s){const a=s[1],u=s[3];if(Ar(u.trim())){const c=a.length,l=r.startIndex,f=r.startIndex+c-1,m={nodeType:ve.NORMAL,token:a,startIndex:l,endIndex:f},d={nodeType:ve.REFERENCE,token:u,startIndex:f+1,endIndex:r.endIndex};t.push(m),t.push(d);continue}}}t.push(r)}return t}_pushSequenceNode(e,t,r){const n=r-t.startIndex+1;e.splice(e.length-n,n,t)}nodeMakerTest(e){return this._nodeMaker(e)}treeBuilder(e,t=!0,r,n){if(t===!0){const m=Hn.get(e),d=n==null?void 0:n(e);if(m&&!d)return m}this._resetCurrentLexerNode(),this._currentLexerNode.setToken(Nt);const s=[];let a=this._nodeMaker(e,s);if(a===h.VALUE||s.length===0)return a;let u=!1,c="",l=[];if(r){const{hasDefinedName:m,sequenceString:d,definedNames:C}=r(s);u=m,c=d,l=C}if(u&&(this._resetCurrentLexerNode(),this._currentLexerNode.setToken(Nt),a=this._nodeMaker(`=${c}`),a===h.VALUE))return a;const f=this._getTopNode(this._currentLexerNode);if(f&&(this._currentLexerNode=f),t){if(!this._suffixExpressionHandler(this._currentLexerNode))return h.VALUE;Hn.set(e,this._currentLexerNode)}return u&&this._currentLexerNode.setDefinedNames(l),this._currentLexerNode}_suffixExpressionHandler(e){var u;const t=e.getChildren();if(!t)return!1;const r=t.length,n=[],s=[];let a=!0;for(let c=0;c<r;c++){const l=t[c];if(l instanceof se)a=this._suffixExpressionHandler(l),n.push(l);else{const f=l.trim();if(f==="")continue;if(At.has(f)){if(f===X.PLUS&&this._deletePlusForPreNode(t[c-1]))continue;if(f!==X.PLUS&&f!==X.MINUS&&this._deletePlusForPreNode(t[c-1]))return!1;for(;s.length>0;){const m=(u=s[s.length-1])==null?void 0:u.trim();if(!m||m===Q.OPEN_BRACKET)break;const d=$r.get(m),C=$r.get(f);if(!d||!C)break;if(C>=d)n.push(s.pop());else break}s.push(l)}else if(f===Q.OPEN_BRACKET)s.push(l);else if(f===Q.CLOSE_BRACKET)this._processSuffixExpressionCloseBracket(n,s,t,c);else{if(this._checkCloseBracket(t[c-1]))return!1;n.push(l)}}}return a?this._processSuffixExpressionRemain(n,s,e):!1}_processSuffixExpressionRemain(e,t,r){const n=e.length,s=e[n-1];for(;t.length>0;){const a=t.pop();if(!(s instanceof se)&&(a===Q.OPEN_BRACKET||a===Q.CLOSE_BRACKET))return!1;e.push(a)}return r.setChildren(e),!0}_processSuffixExpressionCloseBracket(e,t,r,n){var s;if(this._checkOpenBracket(r[n-1])||this._checkOperator(r[n-1]))return!1;for(;t.length>0;){const a=(s=t[t.length-1])==null?void 0:s.trim();if(!a)break;if(a===Q.OPEN_BRACKET){t.pop();break}e.push(t.pop())}}_checkCloseBracket(e){return e===Q.CLOSE_BRACKET||e instanceof se}_checkOpenBracket(e){return e===Q.OPEN_BRACKET}_checkOperator(e){return e==null||e instanceof se?!1:At.has(e)}_deletePlusForPreNode(e){if(e==null)return!0;if(!(e instanceof se)){const t=e.trim();if(At.has(t)||t===Q.OPEN_BRACKET)return!0}return!1}_resetCurrentLexerNode(){this._currentLexerNode=new se}_resetSegment(){this._segment=""}_openBracket(e=0){this._bracketState.push(e)}_closeBracket(){this._bracketState.pop()}_openSquareBracket(){this._squareBracketState+=1}_closeSquareBracket(){this._squareBracketState-=1}_getCurrentBracket(){const e=this._bracketState;return e[e.length-1]}_changeCurrentBracket(e){const t=this._bracketState;t[t.length-1]=e}_openBraces(){this._bracesState+=1}_closeBraces(){this._bracesState-=1}_openSingleQuotation(){this._singleQuotationState+=1}_closeSingleQuotation(){this._singleQuotationState-=1}_openDoubleQuotation(){this._doubleQuotationState+=1}_closeDoubleQuotation(){this._doubleQuotationState-=1}_openLambda(){this._lambdaState=!0}_closeLambda(){this._lambdaState=!1}_openColon(e){this._upLevel=e,this._colonState=!0}_closeColon(){this._upLevel=0,this._colonState=!1}_isTableBracket(){return this._tableBracketState}_openTableBracket(){this._tableBracketState=!0}_closeTableBracket(){this._tableBracketState=!1}_formalErrorOccurred(){this._formulaErrorCount+=1}_hasFormalError(){return this._formulaErrorCount>0}_getLastChildCurrentLexerNode(){const e=this._currentLexerNode.getChildren();if(e&&e.length>0){const t=e[e.length-1];if(t instanceof se)return t}return!1}_getLastChildCurrent(){const e=this._currentLexerNode.getChildren();return e&&e.length>0?e[e.length-1]:!1}_setParentCurrentLexerNode(){const e=this._currentLexerNode.getParent();return e?(this._currentLexerNode=e,!0):!1}_setAncestorCurrentLexerNode(){var r,n,s,a,u,c;const e=(r=this._currentLexerNode)==null?void 0:r.getParent();let t=!1;if(e&&e.getToken()===nr){if((n=e==null?void 0:e.getParent())!=null&&n.getParent()){const l=(a=(s=this._currentLexerNode.getParent())==null?void 0:s.getParent())==null?void 0:a.getParent();l&&(this._currentLexerNode=l),t=!0}}else if(e!=null&&e.getParent()){const l=(u=this._currentLexerNode.getParent())==null?void 0:u.getParent();l&&(this._currentLexerNode=l),t=!0}for(let l=0;l<this._upLevel;l++){const f=(c=this._currentLexerNode)==null?void 0:c.getParent();f&&(this._currentLexerNode=f),this._currentLexerNode?t=!0:t=!1}return t}_segmentCount(){return this._segment.trim().length}_pushSegment(e){this._segment+=e}_pushNodeToChildren(e,t=!1){let r=e;if(r!==""){const n=this._currentLexerNode.getChildren();if(!(r instanceof se)&&this.isColonOpen()){const s=new se;s.setToken(r),s.setParent(this._currentLexerNode),r=s}t?n.unshift(r):n.push(r)}this.isColonOpen()&&(this._setAncestorCurrentLexerNode(),this._closeColon())}_setCurrentLexerNode(e,t=!1){this._pushNodeToChildren(e,t),e.setParent(this._currentLexerNode),this._currentLexerNode=e}_newAndPushCurrentLexerNode(e,t,r=!1){const n=new se;n.setToken(e),n.setIndex(t-e.length,t-1),this._setCurrentLexerNode(n,r)}_getTopNode(e){let t=e;for(;t!=null&&t.getParent();)t=t.getParent();return t}_removeLastChild(){this._currentLexerNode.getChildren().splice(-1)}_formulaErrorLastTokenCheck(e,t){const r=this._findPreviousToken(e,t)||"",n=e.length-1===t;if(!n&&this._isOperatorToken(r)||n&&Tu(r))return!0;if(Yn.has(r)){const s=this._findSecondLastNonSpaceToken(e,t);if(s==null||Iu(s))return!0}return!1}_findPreviousToken(e,t){let r=t;for(;r>=0;){const n=e[r];if(n!==" ")return n;r--}}_findSecondLastNonSpaceToken(e,t){let r=t,n=0;for(;r>=0;){const s=e[r];if(s!==" "&&(n++,n===2))return s;r--}return null}_findNextToken(e,t){let r=t;for(;r>=0;){const n=e[r];if(n!==" ")return n;r++}}_unexpectedEndingTokenExcludeOperator(e){return e===Q.OPEN_BRACKET||e===Q.COMMA||e===X.EQUALS||e===""}_unexpectedEndingToken(e){return!!(this._isOperatorToken(e)||this._unexpectedEndingTokenExcludeOperator(e))}_isOperatorToken(e){return!!At.has(e)}_getSequenceArray(e){const t=[];return this._nodeMaker(e,t),t}_resetTemp(){this._currentLexerNode=new se,this._upLevel=0,this._segment="",this._bracketState=[],this._bracesState=0,this._singleQuotationState=0,this._doubleQuotationState=0,this._lambdaState=!1,this._colonState=!1,this._formulaErrorCount=0}_checkErrorState(){return!!(this._bracketState.length>0||this._bracesState>0||this._singleQuotationState>0||this._doubleQuotationState>0||this._hasFormalError())}_checkSimilarErrorToken(e,t,r){let n=t;if(e!==He.POUND)return!0;let s=r[++n];for(;s===" ";)s=r[++n];return!!Cr(s)}_checkIfErrorObject(e,t){return!!this._findErrorObject(e,t)}_findErrorObject(e,t){for(let r=0;r<ca.length;r++){const n=ca[r],s=t.slice(e,e+n).join("").toUpperCase();if(qt.has(s))return s}}_nodeMaker(e,t,r){let n=e.replace(/\r\n$/,"").replace(/\r/g," ").replace(/\n/g," ");n.substring(0,1)===X.EQUALS&&(n=n.substring(1));const s=n.split(""),a=s.length;let u=0;for(this._resetTemp(),this._formulaErrorLastTokenCheck(s,a-1)&&this._formalErrorOccurred();u<a;){const c=s[u];if(r===u)return[this._currentLexerNode,c];if(c===He.POUND&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()&&this._checkIfErrorObject(u,s)){const l=this._findErrorObject(u,s);if(l==null)return h.VALUE;this._pushNodeToChildren(l);for(let f=0;f<l.length;f++){const m=s[u];this._pushSegment(m),this._addSequenceArray(t,m,u),u++}this._resetSegment();continue}else if(c===Q.OPEN_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())if(this._segmentCount()>0||this.isLambdaOpen()){this.isLambdaClose()&&(this._newAndPushCurrentLexerNode(this._segment,u),this._resetSegment()),this._openBracket(1),this._closeLambda();const l=s[u+1];if(l&&l===Q.CLOSE_BRACKET){if(!this._setParentCurrentLexerNode()&&u!==a-1)return h.VALUE;this._addSequenceArray(t,c,u),u++,this._addSequenceArray(t,l,u),u++,this._closeBracket();continue}else l&&this._newAndPushCurrentLexerNode(ut,u)}else this._pushNodeToChildren(c),this._openBracket(0),this._resetSegment();else if(c===Q.CLOSE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()){this._formulaErrorLastTokenCheck(s,u-1)&&this._formalErrorOccurred(),this._pushNodeToChildren(this._segment),this._resetSegment();const l=this._getCurrentBracket();if(l===0)this._pushNodeToChildren(c);else if(l===1){const f=s[u+1];if(f&&f===Q.OPEN_BRACKET){if(!this._setParentCurrentLexerNode()&&u!==a-1)return h.VALUE;this._newAndPushCurrentLexerNode(nr,u,!0),this._openLambda()}else if(!this._setAncestorCurrentLexerNode()&&u!==a-1)return h.VALUE}else return h.VALUE;this._closeBracket()}else if(c===Q.OPEN_BRACES&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()){if(this._pushSegment(c),this._openBraces(),!this._formulaSpellCheck())return h.VALUE}else if(c===Q.CLOSE_BRACES&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._pushSegment(c),this._pushNodeToChildren(this._segment),this._resetSegment(),this._closeBraces();else if(c===Q.OPEN_SQUARE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._segment.length>0&&this._openTableBracket(),this._pushSegment(c),this._openSquareBracket();else if(c===Q.CLOSE_SQUARE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._closeSquareBracket(),this.isSquareBracketClose()?(this._pushSegment(c),this._isTableBracket()&&(this._pushNodeToChildren(this._segment),this._resetSegment()),this._closeTableBracket()):this._pushSegment(c);else if(c===Q.DOUBLE_QUOTATION&&this.isSingleQuotationClose()&&this.isSquareBracketClose()){if(this.isDoubleQuotationClose())this._openDoubleQuotation();else{const l=s[u+1];l&&l===Q.DOUBLE_QUOTATION?u++:this._closeDoubleQuotation()}this._pushSegment(c)}else if(c===Q.SINGLE_QUOTATION&&this.isDoubleQuotationClose()){if(this.isSingleQuotationClose())this._openSingleQuotation();else{const l=s[u+1];l&&l===Q.SINGLE_QUOTATION?u++:this._closeSingleQuotation()}this._pushSegment(c)}else if(c===Q.COMMA&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()){this._formulaErrorLastTokenCheck(s,u-1)&&this._formalErrorOccurred();const l=this._getCurrentBracket();if(l===1||l==null){if(this._pushNodeToChildren(this._segment),this._resetSegment(),!this._setParentCurrentLexerNode()&&u!==a-1&&l!=null)return h.VALUE;this._newAndPushCurrentLexerNode(ut,u)}else{const f=new se;f.setToken(fc);const m=new se;m.setToken(ut),m.changeToParent(f);const d=this._currentLexerNode.getParent();if(d&&d.getToken()===Q.COLON){const C=d.getParent();if(!C)return h.VALUE;d.changeToParent(m),C.setChildren([]),f.changeToParent(C)}else return h.VALUE;this._changeCurrentBracket(1),this._pushNodeToChildren(this._segment),this._resetSegment(),this._currentLexerNode=f,this._newAndPushCurrentLexerNode(ut,u)}}else if(c===Q.COLON&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()){const l=new se;l.setToken(c);const f=new se;f.setToken(ut),f.setParent(l);const m=new se;m.setToken(ut),m.setParent(l),l.getChildren().push(f,m);let d=l,C=0;if(this._segmentCount()>0){let _,E,b=0;const R=this._segment.trim(),p=R[0],V=R[1];if(p===pe.MINUS&&(_=new se,_.setToken(pe.MINUS),b++),(p===pe.AT||V===pe.AT)&&(E=new se,E.setToken(pe.AT),_&&(_.addChildren(E),E.setParent(_)),b++),b>0&&(this._segment=R.slice(b)),C=b,E)if(E.addChildren(l),l.setParent(E),E.getParent()){const D=E.getParent();D&&(d=D)}else d=E;else _&&(d=_,_.addChildren(l),l.setParent(_));const S=new se;S.setToken(this._segment),S.setParent(f),f.getChildren().push(S),this._resetSegment()}else{const _=this._getLastChildCurrentLexerNode();_&&_.changeToParent(f)}this._setCurrentLexerNode(d),this._currentLexerNode=m,this._openColon(C)}else if(Yn.has(c)&&this._checkSimilarErrorToken(c,u,s)&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isSquareBracketClose()&&this.isBracesClose()){this._pushNodeToChildren(this._segment);const l=new se;l.setToken(c);const f=this._getLastChildCurrent();f instanceof se?f.changeToParent(l):f!==!1&&(l.getChildren().push(f),this._removeLastChild()),this._pushNodeToChildren(l),l.setParent(this._currentLexerNode),this._resetSegment()}else if(At.has(c)&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isSquareBracketClose()&&this.isBracesClose()){let l=this._segment.trim();if(c===X.MINUS&&l===""){const f=this._findPreviousToken(s,u-1)||"",m=this._findNextToken(s,u+1)||"";if(this._unexpectedEndingTokenExcludeOperator(f)&&this._isOperatorToken(m)){this._pushNodeToChildren("0"),this._pushNodeToChildren(X.MINUS),this._addSequenceArray(t,c,u),this._resetSegment(),u++;continue}else if(this._unexpectedEndingToken(f))if(m===X.PLUS){this._pushSegment(X.MINUS),this._addSequenceArray(t,c,u),this._addSequenceArray(t,X.PLUS,u+1),u+=2;continue}else{this._pushSegment(X.MINUS),this._addSequenceArray(t,c,u),u++;continue}}else if(this._segment.length>0&&this._isScientificNotation(s,u,c)){this._pushSegment(c),this._addSequenceArray(t,c,u),u++;continue}else this._segment.length>0&&l===""?l=this._segment:(this._pushNodeToChildren(this._segment),l="");if(c===X.LESS_THAN||c===X.GREATER_THAN){const f=s[u+1];if(f&&At.has(c+f)){this._pushNodeToChildren(l+c+f),this._resetSegment(),this._addSequenceArray(t,c,u),u++,this._addSequenceArray(t,f,u),u++;continue}else this._pushNodeToChildren(l+c)}else this._pushNodeToChildren(l+c);this._resetSegment()}else this._pushSegment(c);this._addSequenceArray(t,c,u),u++}if(this._pushNodeToChildren(this._segment),this._checkErrorState())return h.VALUE}_isScientificNotation(e,t,r){const n=e[t-2];if(n&&Number.isNaN(Number(n))||!(r===X.MINUS||r===X.PLUS))return!1;const s=e[t+1];if(s&&Number.isNaN(Number(s)))return!1;const a=e[t-1];return a&&a.toUpperCase()==="E"}_addSequenceArray(e,t,r){e==null||e.push({segment:this._segment,currentString:t,cur:r,currentLexerNode:this._currentLexerNode})}}function gc(i,o,e,t,r,n,s){const a=(s==null?void 0:s.f)||"",u=(s==null?void 0:s.si)||"",c=M.isFormulaString(a),l=M.isFormulaId(u),f=i.getValue(r,n),m=(f==null?void 0:f.f)||"",d=(f==null?void 0:f.si)||"";function C(){var _;if(M.isFormulaString(m)&&M.isFormulaId(d)){const E=(_=e.get(d))==null?void 0:_.f;E?t.set(d,E):t.set(d,m)}}c&&l?(d!==u&&C(),i.setValue(r,n,{f:a,si:u}),e.set(u,{f:a,r,c:n}),o.setValue(r,n,{f:a,si:u})):c&&!l?(m!==a&&C(),i.setValue(r,n,{f:a}),o.setValue(r,n,{f:a})):!c&&l?(d!==u&&C(),i.setValue(r,n,{f:"",si:u})):!c&&!l&&i.getValue(r,n)&&(C(),i.realDeleteValue(r,n),o.setValue(r,n,null))}function dc(i,o,e,t){const r=i==null?void 0:i.getValue(e,t);if(r==null)return!0;const n=[];i.forValue((l,f,m)=>{l===e&&f===t||M.Rectangle.intersects(m,r)&&n.push(m)});const{startRow:s,startColumn:a,endRow:u,endColumn:c}=r;for(let l=s;l<=u;l++)for(let f=a;f<=c;f++){let m=!1;const d=M.cellToRange(l,f);n.some(C=>M.Rectangle.contains(C,d)?(m=!0,!0):!1),m||o.realDeleteValue(l,f)}}var Cc=Object.defineProperty,_c=Object.getOwnPropertyDescriptor,Ac=(i,o,e,t)=>{for(var r=t>1?void 0:t?_c(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Cc(o,e,r),r},Ea=(i,o)=>(e,t)=>o(e,t,i);exports.FormulaDataModel=class extends M.Disposable{constructor(e,t){super();A(this,"_formulaData",{});A(this,"_arrayFormulaRange",{});A(this,"_arrayFormulaCellData",{});this._univerInstanceService=e,this._lexerTreeBuilder=t,this.initFormulaData()}dispose(){super.dispose(),this._formulaData={},this._arrayFormulaRange={},this._arrayFormulaCellData={}}clearPreviousArrayFormulaCellData(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{var l,f,m,d;const s=r[n],a=(f=(l=this._arrayFormulaRange)==null?void 0:l[t])==null?void 0:f[n];if(a==null)return!0;const u=new M.ObjectMatrix(a);let c=new M.ObjectMatrix;((m=this._arrayFormulaCellData[t])==null?void 0:m[n])!=null&&(c=new M.ObjectMatrix((d=this._arrayFormulaCellData[t])==null?void 0:d[n])),s.forValue((C,_)=>{const E=u.getValue(C,_);if(E==null)return!0;const{startRow:b,startColumn:R,endRow:p,endColumn:V}=E;for(let S=b;S<=p;S++)for(let D=R;D<=V;D++)c.setValue(S,D,null);u.realDeleteValue(C,_)}),this._arrayFormulaCellData[t]&&(this._arrayFormulaCellData[t][n]=c.getData())})})}mergeArrayFormulaCellData(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;this._arrayFormulaRange[t]==null&&(this._arrayFormulaRange[t]={}),this._arrayFormulaCellData[t]==null&&(this._arrayFormulaCellData[t]={}),Object.keys(r).forEach(n=>{var c,l;const s=r[n],a=new M.ObjectMatrix((c=this._arrayFormulaRange[t])==null?void 0:c[n]),u=new M.ObjectMatrix((l=this._arrayFormulaCellData[t])==null?void 0:l[n]);s.forValue((f,m)=>{const d=a==null?void 0:a.getValue(f,m);if(d==null)return!0;const{startRow:C,startColumn:_,endRow:E,endColumn:b}=d;for(let R=C;R<=E;R++)for(let p=_;p<=b;p++)u.setValue(R,p,null)}),s.forValue((f,m,d)=>{u.setValue(f,m,d)}),this._arrayFormulaCellData[t]&&(this._arrayFormulaCellData[t][n]=u.getData())})})}getFormulaData(){return this._formulaData}setFormulaData(e){this._formulaData=e}getArrayFormulaRange(){return this._arrayFormulaRange}setArrayFormulaRange(e){this._arrayFormulaRange=e}getArrayFormulaCellData(){return this._arrayFormulaCellData}setArrayFormulaCellData(e){this._arrayFormulaCellData=e}mergeArrayFormulaRange(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;this._arrayFormulaRange[t]||(this._arrayFormulaRange[t]={}),Object.keys(r).forEach(n=>{var u;const s=new M.ObjectMatrix(r[n]),a=new M.ObjectMatrix((u=this._arrayFormulaRange[t])==null?void 0:u[n]);s.forValue((c,l,f)=>{a.setValue(c,l,f)}),this._arrayFormulaRange[t]&&(this._arrayFormulaRange[t][n]=a.getData())})})}mergeFormulaData(e){Object.keys(e).forEach(t=>{const r=e[t];if(r!==void 0){if(r===null){delete this._formulaData[t];return}this._formulaData[t]||(this._formulaData[t]={}),Object.keys(r).forEach(n=>{var c,l;const s=r[n];if(s===void 0)return;if(s===null){(c=this._formulaData[t])==null||delete c[n];return}(l=this._formulaData[t])!=null&&l[n]||(this._formulaData[t][n]={});const a=new M.ObjectMatrix(s),u=new M.ObjectMatrix(this._formulaData[t][n]);a.forValue((f,m,d)=>{d==null?u.realDeleteValue(f,m):u.setValue(f,m,d)})})}})}deleteArrayFormulaRange(e,t,r,n){var u;const s=(u=this._arrayFormulaRange[e])==null?void 0:u[t];if(s==null)return;const a=new M.ObjectMatrix(s);a.getValue(r,n)&&(a.realDeleteValue(r,n),this._arrayFormulaRange[e]&&(this._arrayFormulaRange[e][t]=a.getData()))}initFormulaData(){if(this._univerInstanceService.getAllUnitsForType(M.UniverInstanceType.UNIVER_SHEET).length===0)return;const t=this._univerInstanceService.getCurrentUnitForType(M.UniverInstanceType.UNIVER_SHEET),r=t.getUnitId();this._formulaData[r]={},t.getSheets().forEach(s=>{const a=s.getCellMatrix(),u=s.getSheetId();Ri(this._formulaData,r,u,a)})}getCalculateData(){const e=this._univerInstanceService.getAllUnitsForType(M.UniverInstanceType.UNIVER_SHEET),t={},r={};for(const n of e){const s=n.getUnitId(),a=n.getSheets(),u={},c={};for(const l of a){const f=l.getSheetId(),m=l.getConfig();u[f]={cellData:new M.ObjectMatrix(m.cellData),rowCount:m.rowCount,columnCount:m.columnCount,rowData:m.rowData,columnData:m.columnData,defaultRowHeight:m.defaultRowHeight,defaultColumnWidth:m.defaultColumnWidth},c[l.getName()]=l.getSheetId()}t[s]=u,r[s]=c}return{allUnitData:t,unitSheetNameMap:r}}updateFormulaData(e,t,r){const n=new M.ObjectMatrix(r),s=this.getFormulaIdMap(e,t),a=new Map,u=this._formulaData;u[e]==null&&(u[e]={});const c=u[e];c[t]==null&&(c[t]={});const l=new M.ObjectMatrix(c[t]||{}),f=new M.ObjectMatrix;return n.forValue((m,d,C)=>{gc(l,f,s,a,m,d,C)}),l.forValue((m,d,C)=>{const _=(C==null?void 0:C.f)||"",E=(C==null?void 0:C.si)||"";if(M.isFormulaId(E)){const b=s.get(E),R=a.get(E);if(b&&!M.isFormulaString(_)){const p=b.f,V=d-b.c,S=m-b.r;l.setValue(m,d,{f:p,si:E,x:V,y:S}),f.setValue(m,d,{f:p,si:E,x:V,y:S})}else if(typeof R=="string"){const p=(C==null?void 0:C.x)||0,V=(C==null?void 0:C.y)||0,S=this._lexerTreeBuilder.moveFormulaRefOffset(R,p,V);a.set(E,{r:m,c:d,f:S}),l.setValue(m,d,{f:S,si:E}),f.setValue(m,d,{f:S,si:E})}else if(typeof R=="object"){const p=d-R.c,V=m-R.r;l.setValue(m,d,{f:R.f,si:E,x:p,y:V}),f.setValue(m,d,{f:R.f,si:E,x:p,y:V})}}}),f.getMatrix()}updateArrayFormulaRange(e,t,r){var u;const n=(u=this._arrayFormulaRange[e])==null?void 0:u[t];if(!n)return;const s=new M.ObjectMatrix(n);new M.ObjectMatrix(r).forValue((c,l,f)=>{s.realDeleteValue(c,l)})}updateArrayFormulaCellData(e,t,r){var l,f;const n=(l=this._arrayFormulaRange[e])==null?void 0:l[t];if(!n)return;const s=new M.ObjectMatrix(n),a=(f=this._arrayFormulaCellData[e])==null?void 0:f[t];if(!a)return;const u=new M.ObjectMatrix(a);new M.ObjectMatrix(r).forValue((m,d,C)=>{dc(s,u,m,d)})}getFormulaItemBySId(e,t,r){const n=this._formulaData;if(n[r]==null)return null;const s=n[r];if((s==null?void 0:s[t])==null)return null;const a=new M.ObjectMatrix(s[t]||{});let u=null;return a.forValue((c,l,f)=>{if(f==null)return!0;const{f:m,si:d,x:C=0,y:_=0}=f;if(d===e&&m.length>0&&C===0&&_===0)return u=f,!1}),u}getFormulaDataItem(e,t,r,n){var s,a,u,c;return(c=(u=(a=(s=this._formulaData)==null?void 0:s[n])==null?void 0:a[r])==null?void 0:u[e])==null?void 0:c[t]}getFormulaIdMap(e,t){const r=new Map,n=this._formulaData;if(n[e]==null)return r;const s=n[e];return(s==null?void 0:s[t])==null||new M.ObjectMatrix(s[t]||{}).forValue((u,c,l)=>{const f=(l==null?void 0:l.f)||"",m=(l==null?void 0:l.si)||"",d=(l==null?void 0:l.x)||0,C=(l==null?void 0:l.y)||0;M.isFormulaString(f)&&M.isFormulaId(m)&&d===0&&C===0&&r.set(m,{f,r:u,c})}),r}getFormulaStringByCell(e,t,r,n){const s=this.getFormulaDataItem(e,t,r,n);if(s==null)return null;const{f:a,si:u,x:c=0,y:l=0}=s;if(u!=null&&(c!==0||l!==0)){let f="";if(a.length>0)f=a;else{const m=this.getFormulaItemBySId(u,r,n);if(m==null||m.f.length===0)return null;f=m.f}return f=this._lexerTreeBuilder.moveFormulaRefOffset(f,c,l),f}return M.isFormulaString(a)?a:null}getFormulaDirtyRanges(){const e=this._formulaData,t=[];for(const r in e){const n=e[r];if(!n)continue;const s=this._univerInstanceService.getUnit(r);if(s)for(const a in n){const u=n[a];if(!u)continue;const c=s.getSheetBySheetId(a);if(!c)continue;const l={};for(const f of Object.keys(u)){const m=Number(f);for(const d in u[m]){const C=Number(d),_=c.getCellRaw(m,C),E=M.isFormulaString(_==null?void 0:_.f)||M.isFormulaId(_==null?void 0:_.si),b=(_==null?void 0:_.v)===void 0;if(!(E&&b))continue;l[C]||(l[C]=[]);const R=l[C].slice(-1)[0];R&&R.endRow===m-1?R.endRow=m:l[C].push({startRow:m,endRow:m})}}for(const f in l){const m=l[f];for(let d=0;d<m.length;d++){const C=m[d];t.push({unitId:r,sheetId:a,range:{rangeType:M.RANGE_TYPE.NORMAL,startRow:C.startRow,endRow:C.endRow,startColumn:Number(f),endColumn:Number(f)}})}}}}return t}};exports.FormulaDataModel=Ac([Ea(0,M.IUniverInstanceService),Ea(1,M.Inject(Vn))],exports.FormulaDataModel);function Ri(i,o,e,t){i[o]||(i[o]={}),i[o][e]||(i[o][e]={});const r=new Map,n=new M.ObjectMatrix(i[o][e]);t.forValue((a,u,c)=>{const l=(c==null?void 0:c.f)||"",f=(c==null?void 0:c.si)||"",m=M.isFormulaString(l),d=M.isFormulaId(f);m&&d?(n.setValue(a,u,{f:l,si:f}),r.set(f,{f:l,r:a,c:u})):m&&!d?n.setValue(a,u,{f:l}):!m&&d&&n.setValue(a,u,{f:"",si:f})}),n.forValue((a,u,c)=>{const l=(c==null?void 0:c.f)||"",f=(c==null?void 0:c.si)||"";if(M.isFormulaId(f)&&!M.isFormulaString(l)){const m=r.get(f);if(m){const d=m.f,C=u-m.c,_=a-m.r;n.setValue(a,u,{f:d,si:f,x:C,y:_})}else n.realDeleteValue(a,u)}});const s=n.getMatrix();return{[o]:{[e]:s}}}const Ec=class is{constructor(o,e){this.low=o,this.high=e}clone(){return new is(this.low,this.high)}get max(){return this.clone()}less_than(o){return this.low<o.low||this.low===o.low&&this.high<o.high}equal_to(o){return this.low===o.low&&this.high===o.high}intersect(o){return!this.not_intersect(o)}not_intersect(o){return this.high<o.low||o.high<this.low}merge(o){return new is(this.low===void 0?o.low:this.low<o.low?this.low:o.low,this.high===void 0?o.high:this.high>o.high?this.high:o.high)}output(){return[this.low,this.high]}static comparable_max(o,e){return o.merge(e)}static comparable_less_than(o,e){return o<e}},we=0,_e=1;class Lt{constructor(o=void 0,e=void 0,t=null,r=null,n=null,s=_e){if(this.left=t,this.right=r,this.parent=n,this.color=s,this.item={key:o,value:e},o&&o instanceof Array&&o.length===2&&!Number.isNaN(o[0])&&!Number.isNaN(o[1])){let[a,u]=o;a>u&&([a,u]=[u,a]),this.item.key=new Ec(a,u)}this.max=this.item.key?this.item.key.max:void 0}isNil(){return this.item.key===void 0&&this.item.value===void 0&&this.left===null&&this.right===null&&this.color===_e}_value_less_than(o){return this.item.value&&o.item.value&&this.item.value.less_than?this.item.value.less_than(o.item.value):this.item.value<o.item.value}less_than(o){return this.item.value===this.item.key&&o.item.value===o.item.key?this.item.key.less_than(o.item.key):this.item.key.less_than(o.item.key)||this.item.key.equal_to(o.item.key)&&this._value_less_than(o)}_value_equal(o){return this.item.value&&o.item.value&&this.item.value.equal_to?this.item.value.equal_to(o.item.value):this.item.value===o.item.value}equal_to(o){return this.item.value===this.item.key&&o.item.value===o.item.key?this.item.key.equal_to(o.item.key):this.item.key.equal_to(o.item.key)&&this._value_equal(o)}intersect(o){return this.item.key.intersect(o.item.key)}copy_data(o){this.item.key=o.item.key,this.item.value=o.item.value}update_max(){if(this.max=this.item.key?this.item.key.max:void 0,this.right&&this.right.max){const o=this.item.key.constructor.comparable_max;this.max=o(this.max,this.right.max)}if(this.left&&this.left.max){const o=this.item.key.constructor.comparable_max;this.max=o(this.max,this.left.max)}}not_intersect_left_subtree(o){const e=this.item.key.constructor.comparable_less_than;let t=this.left.max.high!==void 0?this.left.max.high:this.left.max;return e(t,o.item.key.low)}not_intersect_right_subtree(o){const e=this.item.key.constructor.comparable_less_than;let t=this.right.max.low!==void 0?this.right.max.low:this.right.item.key.low;return e(o.item.key.high,t)}}class Ms{constructor(){this.root=null,this.nil_node=new Lt}get size(){let o=0;return this.tree_walk(this.root,()=>o++),o}get keys(){let o=[];return this.tree_walk(this.root,e=>o.push(e.item.key.output?e.item.key.output():e.item.key)),o}get values(){let o=[];return this.tree_walk(this.root,e=>o.push(e.item.value)),o}get items(){let o=[];return this.tree_walk(this.root,e=>o.push({key:e.item.key.output?e.item.key.output():e.item.key,value:e.item.value})),o}isEmpty(){return this.root==null||this.root===this.nil_node}clear(){this.root=null}insert(o,e=o){if(o===void 0)return;let t=new Lt(o,e,this.nil_node,this.nil_node,null,we);return this.tree_insert(t),this.recalc_max(t),t}exist(o,e=o){let t=new Lt(o,e);return!!this.tree_search(this.root,t)}remove(o,e=o){let t=new Lt(o,e),r=this.tree_search(this.root,t);return r&&this.tree_delete(r),r}search(o,e=(t,r)=>t===r?r.output():t){let t=new Lt(o),r=[];return this.tree_search_interval(this.root,t,r),r.map(n=>e(n.item.value,n.item.key))}intersect_any(o){let e=new Lt(o);return this.tree_find_any_interval(this.root,e)}forEach(o){this.tree_walk(this.root,e=>o(e.item.key,e.item.value))}map(o){const e=new Ms;return this.tree_walk(this.root,t=>e.insert(t.item.key,o(t.item.value,t.item.key))),e}*iterate(o,e=(t,r)=>t===r?r.output():t){let t;for(o?t=this.tree_search_nearest_forward(this.root,new Lt(o)):this.root&&(t=this.local_minimum(this.root));t;)yield e(t.item.value,t.item.key),t=this.tree_successor(t)}recalc_max(o){let e=o;for(;e.parent!=null;)e.parent.update_max(),e=e.parent}tree_insert(o){let e=this.root,t=null;if(this.root==null||this.root===this.nil_node)this.root=o;else{for(;e!==this.nil_node;)t=e,o.less_than(e)?e=e.left:e=e.right;o.parent=t,o.less_than(t)?t.left=o:t.right=o}this.insert_fixup(o)}insert_fixup(o){let e,t;for(e=o;e!==this.root&&e.parent.color===we;)e.parent===e.parent.parent.left?(t=e.parent.parent.right,t.color===we?(e.parent.color=_e,t.color=_e,e.parent.parent.color=we,e=e.parent.parent):(e===e.parent.right&&(e=e.parent,this.rotate_left(e)),e.parent.color=_e,e.parent.parent.color=we,this.rotate_right(e.parent.parent))):(t=e.parent.parent.left,t.color===we?(e.parent.color=_e,t.color=_e,e.parent.parent.color=we,e=e.parent.parent):(e===e.parent.left&&(e=e.parent,this.rotate_right(e)),e.parent.color=_e,e.parent.parent.color=we,this.rotate_left(e.parent.parent)));this.root.color=_e}tree_delete(o){let e,t;o.left===this.nil_node||o.right===this.nil_node?e=o:e=this.tree_successor(o),e.left!==this.nil_node?t=e.left:t=e.right,t.parent=e.parent,e===this.root?this.root=t:(e===e.parent.left?e.parent.left=t:e.parent.right=t,e.parent.update_max()),this.recalc_max(t),e!==o&&(o.copy_data(e),o.update_max(),this.recalc_max(o)),e.color===_e&&this.delete_fixup(t)}delete_fixup(o){let e=o,t;for(;e!==this.root&&e.parent!=null&&e.color===_e;)e===e.parent.left?(t=e.parent.right,t.color===we&&(t.color=_e,e.parent.color=we,this.rotate_left(e.parent),t=e.parent.right),t.left.color===_e&&t.right.color===_e?(t.color=we,e=e.parent):(t.right.color===_e&&(t.color=we,t.left.color=_e,this.rotate_right(t),t=e.parent.right),t.color=e.parent.color,e.parent.color=_e,t.right.color=_e,this.rotate_left(e.parent),e=this.root)):(t=e.parent.left,t.color===we&&(t.color=_e,e.parent.color=we,this.rotate_right(e.parent),t=e.parent.left),t.left.color===_e&&t.right.color===_e?(t.color=we,e=e.parent):(t.left.color===_e&&(t.color=we,t.right.color=_e,this.rotate_left(t),t=e.parent.left),t.color=e.parent.color,e.parent.color=_e,t.left.color=_e,this.rotate_right(e.parent),e=this.root));e.color=_e}tree_search(o,e){if(!(o==null||o===this.nil_node))return e.equal_to(o)?o:e.less_than(o)?this.tree_search(o.left,e):this.tree_search(o.right,e)}tree_search_nearest_forward(o,e){let t,r=o;for(;r&&r!==this.nil_node;)r.less_than(e)?r.intersect(e)?(t=r,r=r.left):r=r.right:((!t||r.less_than(t))&&(t=r),r=r.left);return t||null}tree_search_interval(o,e,t){o!=null&&o!==this.nil_node&&(o.left!==this.nil_node&&!o.not_intersect_left_subtree(e)&&this.tree_search_interval(o.left,e,t),o.intersect(e)&&t.push(o),o.right!==this.nil_node&&!o.not_intersect_right_subtree(e)&&this.tree_search_interval(o.right,e,t))}tree_find_any_interval(o,e){let t=!1;return o!=null&&o!==this.nil_node&&(o.left!==this.nil_node&&!o.not_intersect_left_subtree(e)&&(t=this.tree_find_any_interval(o.left,e)),t||(t=o.intersect(e)),!t&&o.right!==this.nil_node&&!o.not_intersect_right_subtree(e)&&(t=this.tree_find_any_interval(o.right,e))),t}local_minimum(o){let e=o;for(;e.left!=null&&e.left!==this.nil_node;)e=e.left;return e}local_maximum(o){let e=o;for(;e.right!=null&&e.right!==this.nil_node;)e=e.right;return e}tree_successor(o){let e,t,r;if(o.right!==this.nil_node)e=this.local_minimum(o.right);else{for(t=o,r=o.parent;r!=null&&r.right===t;)t=r,r=r.parent;e=r}return e}rotate_left(o){let e=o.right;o.right=e.left,e.left!==this.nil_node&&(e.left.parent=o),e.parent=o.parent,o===this.root?this.root=e:o===o.parent.left?o.parent.left=e:o.parent.right=e,e.left=o,o.parent=e,o!=null&&o!==this.nil_node&&o.update_max(),e=o.parent,e!=null&&e!==this.nil_node&&e.update_max()}rotate_right(o){let e=o.left;o.left=e.right,e.right!==this.nil_node&&(e.right.parent=o),e.parent=o.parent,o===this.root?this.root=e:o===o.parent.left?o.parent.left=e:o.parent.right=e,e.right=o,o.parent=e,o!==null&&o!==this.nil_node&&o.update_max(),e=o.parent,e!=null&&e!==this.nil_node&&e.update_max()}tree_walk(o,e){o!=null&&o!==this.nil_node&&(this.tree_walk(o.left,e),e(o),this.tree_walk(o.right,e))}testRedBlackProperty(){let o=!0;return this.tree_walk(this.root,function(e){e.color===we&&(e.left.color===_e&&e.right.color===_e||(o=!1))}),o}testBlackHeightProperty(o){let e=0,t=0,r=0;if(o.color===_e&&e++,o.left!==this.nil_node?t=this.testBlackHeightProperty(o.left):t=1,o.right!==this.nil_node?r=this.testBlackHeightProperty(o.right):r=1,t!==r)throw new Error("Red-black height property violated");return e+=t,e}}class bc{constructor(){A(this,"_cache",new Map);A(this,"_continueBuildingCache",new Map)}set(o,e,t,r,n){if(!this.shouldContinueBuildingCache(o,e,t,n))return;let s=this._cache.get(o);s==null&&(s=new Map,this._cache.set(o,s));let a=s.get(e);a==null&&(a=new Map,s.set(e,a));let u=a.get(t);u==null&&(u=new Map,a.set(t,u));let c=u.get(r);c==null&&(c=new Set,u.set(r,c)),c.add(n)}getCellValuePositions(o,e,t){var r,n;return(n=(r=this._cache.get(o))==null?void 0:r.get(e))==null?void 0:n.get(t)}getCellPositions(o,e,t,r,n){var a,u,c;const s=(c=(u=(a=this._cache.get(o))==null?void 0:a.get(e))==null?void 0:u.get(t))==null?void 0:c.get(r);return s&&[...s].filter(l=>n.some(([f,m])=>l>=f&&l<=m))}setContinueBuildingCache(o,e,t,r,n){if(t===-1||r===-1||n===-1)return;let s=this._continueBuildingCache.get(o);s==null&&(s=new Map,this._continueBuildingCache.set(o,s));let a=s.get(e);a==null&&(a=new Map,s.set(e,a));let u=a.get(t);if(u==null){u=new Ms,u.insert([r,n]),a.set(t,u);return}this._handleNewInterval(u,r,n)}shouldContinueBuildingCache(o,e,t,r){var a,u;if(t===-1||r===-1)return!1;const n=(u=(a=this._continueBuildingCache.get(o))==null?void 0:a.get(e))==null?void 0:u.get(t);return n?n.search([r,r]).length===0:!0}canUseCache(o,e,t,r,n){var f,m;const s=(m=(f=this._continueBuildingCache.get(o))==null?void 0:f.get(e))==null?void 0:m.get(t);if(t===-1||r===-1||n===-1||!s)return{rowsInCache:[],rowsNotInCache:[]};const a=s.search([r,n]);if(a.length===0)return{rowsInCache:[],rowsNotInCache:[]};a.sort((d,C)=>d[0]-C[0]);const u=[],c=[];let l=r;for(let d=0;d<a.length;d++){const[C,_]=a[d];if(l>=C){if(n<=_){u.push([l,n]);break}u.push([l,_]),l=_+1,d===a.length-1&&l<=n&&c.push([l,n])}else{if(n>_){u.push([C,_]),c.push([l,C-1]),l=_+1,d===a.length-1&&l<=n&&c.push([l,n]);continue}u.push([C,n]),c.push([l,C-1])}}return{rowsInCache:u,rowsNotInCache:c}}clear(){this._cache.clear(),this._continueBuildingCache.clear()}_handleNewInterval(o,e,t){let r=o.search([e,t]);if(r.length===0){const a=[e-1<0?0:e-1,t+1];if(r=o.search(a),r.length===0){o.insert([e,t]);return}}let n=e,s=t;for(const a of r)n=Math.min(n,a[0]),s=Math.max(s,a[1]),o.remove(a);o.insert([n,s])}}const Et=new bc,On="engine-formula.config",yc={};var Rc=Object.defineProperty,pc=Object.getOwnPropertyDescriptor,Nc=(i,o,e,t)=>{for(var r=t>1?void 0:t?pc(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Rc(o,e,r),r},ba=(i,o)=>(e,t)=>o(e,t,i);exports.FormulaCurrentConfigService=class extends M.Disposable{constructor(e,t){super();A(this,"_unitData",{});A(this,"_unitStylesData",{});A(this,"_arrayFormulaCellData",{});A(this,"_arrayFormulaRange",{});A(this,"_formulaData",{});A(this,"_sheetNameMap",{});A(this,"_forceCalculate",!1);A(this,"_clearDependencyTreeCache",{});A(this,"_dirtyRanges",[]);A(this,"_dirtyNameMap",{});A(this,"_dirtyDefinedNameMap",{});A(this,"_dirtyUnitFeatureMap",{});A(this,"_dirtyUnitOtherFormulaMap",{});A(this,"_excludedCell");A(this,"_sheetIdToNameMap",{});A(this,"_executeUnitId","");A(this,"_executeSubUnitId","");this._univerInstanceService=e,this._localeService=t}dispose(){this._unitData={},this._unitStylesData={},this._formulaData={},this._arrayFormulaCellData={},this._arrayFormulaRange={},this._sheetNameMap={},this._dirtyRanges=[],this._dirtyNameMap={},this._dirtyDefinedNameMap={},this._dirtyUnitFeatureMap={},this._excludedCell={},this._sheetIdToNameMap={},this._dirtyUnitOtherFormulaMap={}}getExecuteUnitId(){return this._executeUnitId}getExecuteSubUnitId(){return this._executeSubUnitId}setExecuteUnitId(e){this._executeUnitId=e}setExecuteSubUnitId(e){this._executeSubUnitId=e}getExcludedRange(){return this._excludedCell}getUnitData(){return this._unitData}getUnitStylesData(){return this._unitStylesData}getFormulaData(){return this._formulaData}getArrayFormulaCellData(){return this._arrayFormulaCellData}getArrayFormulaRange(){return this._arrayFormulaRange}getSheetNameMap(){return this._sheetNameMap}isForceCalculate(){return this._forceCalculate}getDirtyRanges(){return this._dirtyRanges}getDirtyNameMap(){return this._dirtyNameMap}getDirtyDefinedNameMap(){return this._dirtyDefinedNameMap}getDirtyUnitFeatureMap(){return this._dirtyUnitFeatureMap}getDirtyUnitOtherFormulaMap(){return this._dirtyUnitOtherFormulaMap}getSheetName(e,t){return this._sheetIdToNameMap[e]==null?"":this._sheetIdToNameMap[e][t]||""}getClearDependencyTreeCache(){return this._clearDependencyTreeCache}getLocale(){return this._localeService.getCurrentLocale()}getSheetsInfo(){const e=this._univerInstanceService.getCurrentUnitForType(M.UniverInstanceType.UNIVER_SHEET),{id:t,sheetOrder:r}=e.getSnapshot();return{sheetOrder:r,sheetNameMap:this._sheetIdToNameMap[t]}}getSheetRowColumnCount(e,t){const r=this._univerInstanceService.getUnit(e),n=r==null?void 0:r.getSheetBySheetId(t),s=n==null?void 0:n.getSnapshot();if(!s)return{rowCount:0,columnCount:0};const{rowCount:a,columnCount:u}=s;return{rowCount:a,columnCount:u}}load(e){if(e.allUnitData&&e.unitSheetNameMap&&e.unitStylesData)this._unitData=e.allUnitData,this._unitStylesData=e.unitStylesData,this._sheetNameMap=e.unitSheetNameMap;else{const{allUnitData:t,unitSheetNameMap:r,unitStylesData:n}=this._loadSheetData();this._unitData=t,this._unitStylesData=n,this._sheetNameMap=r}this._formulaData=e.formulaData,this._arrayFormulaCellData=ii(e.arrayFormulaCellData),this._arrayFormulaRange=e.arrayFormulaRange,this._forceCalculate=e.forceCalculate,this._clearDependencyTreeCache=e.clearDependencyTreeCache||{},this._dirtyRanges=e.dirtyRanges,this._dirtyNameMap=e.dirtyNameMap,this._dirtyDefinedNameMap=e.dirtyDefinedNameMap,this._dirtyUnitFeatureMap=e.dirtyUnitFeatureMap,this._dirtyUnitOtherFormulaMap=e.dirtyUnitOtherFormulaMap,this._excludedCell=e.excludedCell,this._mergeNameMap(this._sheetNameMap,this._dirtyNameMap)}getDirtyData(){return{forceCalculation:this._forceCalculate,dirtyRanges:this._dirtyRanges,dirtyNameMap:this._dirtyNameMap,dirtyDefinedNameMap:this._dirtyDefinedNameMap,dirtyUnitFeatureMap:this._dirtyUnitFeatureMap,dirtyUnitOtherFormulaMap:this._dirtyUnitOtherFormulaMap,clearDependencyTreeCache:this._clearDependencyTreeCache}}loadDirtyRangesAndExcludedCell(e,t){this._dirtyRanges=e,this._excludedCell=t,this._dirtyNameMap={}}registerUnitData(e){this._unitData=e}registerFormulaData(e){this._formulaData=e}registerSheetNameMap(e){this._sheetNameMap=e}_mergeNameMap(e,t){Object.keys(t).forEach(r=>{t[r]&&Object.keys(t[r]).forEach(n=>{e[r]==null&&(e[r]={}),e[r][t[r][n]]=n})}),this._sheetIdToNameMap={},Object.keys(e).forEach(r=>{Object.keys(e[r]).forEach(n=>{this._sheetIdToNameMap[r]==null&&(this._sheetIdToNameMap[r]={}),this._sheetIdToNameMap[r][e[r][n]]=n})})}_loadSheetData(){const e=this._univerInstanceService.getAllUnitsForType(M.UniverInstanceType.UNIVER_SHEET),t=this._univerInstanceService.getCurrentUnitForType(M.UniverInstanceType.UNIVER_SHEET),r=t==null?void 0:t.getActiveSheet();this._executeUnitId=t==null?void 0:t.getUnitId(),this._executeSubUnitId=r==null?void 0:r.getSheetId();const n={},s={},a={};for(const u of e){const c=u.getUnitId(),l=u.getSheets(),f={},m={};for(const d of l){const C=d.getSheetId(),_=d.getConfig();f[C]={cellData:new M.ObjectMatrix(_.cellData),rowCount:_.rowCount,columnCount:_.columnCount,rowData:_.rowData,columnData:_.columnData,defaultRowHeight:_.defaultRowHeight,defaultColumnWidth:_.defaultColumnWidth},m[d.getName()]=d.getSheetId()}n[c]=f,s[c]=u.getStyles(),a[c]=m}return{allUnitData:n,unitStylesData:s,unitSheetNameMap:a}}};exports.FormulaCurrentConfigService=Nc([ba(0,M.IUniverInstanceService),ba(1,M.Inject(M.LocaleService))],exports.FormulaCurrentConfigService);const mt=M.createIdentifier("univer.formula.current-data.service");var Vc=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,Mc=(i,o,e,t)=>{for(var r=t>1?void 0:t?Oc(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Vc(o,e,r),r},Wn=(i,o)=>(e,t)=>o(e,t,i);exports.Lexer=class extends M.Disposable{constructor(o,e,t){super(),this._definedNamesService=o,this._lexerTreeBuilder=e,this._formulaCurrentConfigService=t}treeBuilder(o,e=!0){return this._lexerTreeBuilder.treeBuilder(o,e,this._injectDefinedName.bind(this),this._simpleCheckDefinedName.bind(this))}_simpleCheckDefinedName(o){const e=this._formulaCurrentConfigService.getDirtyDefinedNameMap(),t=this._formulaCurrentConfigService.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++){const a=r[n];if(o.indexOf(a)>-1)return!0}}return!1}_checkDefinedNameDirty(o){const e=this._formulaCurrentConfigService.getDirtyDefinedNameMap(),t=this._formulaCurrentConfigService.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++)if(r[n]===o)return!0}return!1}_injectDefinedName(o){const e=this._formulaCurrentConfigService.getExecuteUnitId();if(e==null)return{sequenceString:"",hasDefinedName:!1,definedNames:[]};const t=this._lexerTreeBuilder.getSequenceNode(o);let r="",n=!1;const s=[];for(let a=0,u=t.length;a<u;a++){const c=t[a];if(typeof c=="string"){r+=c;continue}const{nodeType:l,token:f}=c;if(l===ve.REFERENCE||l===ve.FUNCTION){const m=this._definedNamesService.getValueByName(e,f);if(m){let d=m.formulaOrRefString;d.substring(0,1)===X.EQUALS&&(d=d.substring(1)),r+=d,s.push(m.name),n=!0}else this._checkDefinedNameDirty(f)?(r+=h.NAME,n=!0,s.push(f)):r+=f}else r+=f}return{sequenceString:r,hasDefinedName:n,definedNames:s}}};exports.Lexer=Mc([Wn(0,lr),Wn(1,M.Inject(Vn)),Wn(2,mt)],exports.Lexer);function pi(i,o,e,t,r){var s;const n=Object.keys(r);for(const a of n){const u=r[a],c=(s=u==null?void 0:u[t])==null?void 0:s[e];if(c==null)continue;const l=c.getValue(i,o);if(l!=null)return l}}const Sc=["$","£","¥","¤","֏","؋","৳","฿","៛","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],Dc={currency:2,date:4,datetime:5,error:11,fraction:7,general:0,grouped:11,number:1,percent:6,scientific:8,text:9,time:5,unknown:11};function wc(i,o,e){var u,c;if(i==null||o==null)return o;const t=(e==null?void 0:e.getStyleByCell(i))||i.s,r=(e==null?void 0:e.getStyleByCell(o))||o.s;if(t==null||r==null||typeof t!="object"||typeof r!="object")return o;const n=(u=t==null?void 0:t.n)==null?void 0:u.pattern,s=(c=r==null?void 0:r.n)==null?void 0:c.pattern;if(n==null||s==null)return o;const a=n||s;return r.n.pattern=a,o}const os=new ft(1e5);function ya(i){const o=os.get(i);if(o!==void 0)return o;const e=Lc(i);return os.set(i,e),e}function Pc(){os.clear()}function Lc(i){if(xc(i))return 3;const o=M.numfmt.getInfo(i).type||"unknown";return Dc[o]}function xc(i){return!!Sc.find(o=>i.includes(o))&&i.startsWith("_(")}function vr(i,o,e){if(i==="")return o;if(o==="")return i;const t=ya(i),r=ya(o);return e===X.PLUS||e===X.MINUS?t===4&&r===4||t===11&&r===11?"":o:e===X.MULTIPLY||e===X.DIVIDED?t===6&&r===6||t===7&&r===7||t===8&&r===8||t===9&&r===9?o:"":i||o}const jc=new Map([[M.LocaleType.EN_US,"$"],[M.LocaleType.RU_RU,"₽"],[M.LocaleType.VI_VN,"₫"],[M.LocaleType.ZH_CN,"¥"],[M.LocaleType.ZH_TW,"NT$"]]);function Ra(i){return jc.get(i)||"$"}function Ye(i,o=2){let e=o;o>127&&(e=127);let t="";return e>0&&(t=`.${"0".repeat(e)}`),`"${Ra(i)}"#,##0${t}_);[Red]("${Ra(i)}"#,##0${t})`}function Uc(i,o,e=2){return M.numfmt.format(Ye(i,e),o)}const Ss=new ft(1e5);function vc(i){let o=i;o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1));const e=Ss.get(o);if(e)return{isNumberPattern:!0,value:e.value,pattern:e.pattern};const t=M.numfmt.parseNumber(o);if(t)return Qn(o,t.v,t.z);const r=M.numfmt.parseDate(o);if(r)return Qn(o,r.v,r.z);const n=M.numfmt.parseTime(o);return n?Qn(o,n.v,n.z):{isNumberPattern:!1}}function Qn(i,o,e){return Ss.set(i,{value:o,pattern:e}),{isNumberPattern:!0,value:o,pattern:e}}function Tc(){Ss.clear()}class Mn{constructor(){A(this,"pattern","")}dispose(){}getPattern(){return this.pattern}setPattern(o){this.pattern=o}isError(){return!1}isAsyncObject(){return!1}isAsyncArrayObject(){return!1}isReferenceObject(){return!1}isArray(){return!1}isValueObject(){return!1}isEqualType(o){return!1}}class ht extends Mn{constructor(o){super(),this._rawValue=o}isValueObject(){return!0}toUnitRange(){return{range:{startColumn:-1,startRow:-1,endRow:-1,endColumn:-1},sheetId:"",unitId:""}}getValue(){return 0}getArrayValue(){return[]}setValue(o){}setArrayValue(o){}isCube(){return!1}isString(){return!1}isNumber(){return!1}isBoolean(){return!1}isLambda(){return!1}isError(){return!1}isNull(){return!1}sum(){return g.create(h.VALUE)}max(){return g.create(h.VALUE)}min(){return g.create(h.VALUE)}count(){return g.create(h.VALUE)}countA(){return g.create(h.VALUE)}countBlank(){return g.create(h.VALUE)}getNegative(){return g.create(h.VALUE)}getReciprocal(){return g.create(h.VALUE)}plus(o){return g.create(h.VALUE)}minus(o){return g.create(h.VALUE)}multiply(o){return g.create(h.VALUE)}divided(o){return g.create(h.VALUE)}mod(o){return g.create(h.VALUE)}map(o){return g.create(h.NAME)}mapValue(o){return g.create(h.NAME)}compare(o,e,t=!1){return g.create(h.NAME)}isEqual(o){return this.compare(o,$.EQUALS)}isNotEqual(o){return this.compare(o,$.NOT_EQUAL)}isGreaterThanOrEqual(o){return this.compare(o,$.GREATER_THAN_OR_EQUAL)}isLessThanOrEqual(o){return this.compare(o,$.LESS_THAN_OR_EQUAL)}isLessThan(o){return this.compare(o,$.LESS_THAN)}isGreaterThan(o){return this.compare(o,$.GREATER_THAN)}concatenateFront(o){return g.create(h.NAME)}concatenateBack(o){return g.create(h.NAME)}plusBy(o){return g.create(h.VALUE)}minusBy(o){return g.create(h.VALUE)}multiplyBy(o){return g.create(h.VALUE)}dividedBy(o){return g.create(h.VALUE)}modInverse(o){return g.create(h.VALUE)}compareBy(o,e){return g.create(h.NAME)}concatenate(o,e=Je.FRONT){let t=this.getValue().toString();if(typeof o=="string")e===Je.FRONT?t=o+t:t+=o;else if(typeof o=="number")e===Je.FRONT?t=o.toString()+t:t+=o.toString();else if(typeof o=="boolean"){const r=o?"TRUE":"FALSE";e===Je.FRONT?t=r+t:t+=r}return t}pow(o){return g.create(h.VALUE)}powInverse(o){return g.create(h.VALUE)}sqrt(){return g.create(h.VALUE)}cbrt(){return g.create(h.VALUE)}cos(){return g.create(h.VALUE)}cosh(){return g.create(h.VALUE)}acos(){return g.create(h.VALUE)}acosh(){return g.create(h.VALUE)}sin(){return g.create(h.VALUE)}sinh(){return g.create(h.VALUE)}asin(){return g.create(h.VALUE)}asinh(){return g.create(h.VALUE)}tan(){return g.create(h.VALUE)}tanh(){return g.create(h.VALUE)}atan(){return g.create(h.VALUE)}atan2(o){return g.create(h.VALUE)}atan2Inverse(o){return g.create(h.VALUE)}atanh(){return g.create(h.VALUE)}mean(){return this}median(){return this}var(){return this}std(){return this}log(){return g.create(h.VALUE)}log10(){return g.create(h.VALUE)}exp(){return g.create(h.VALUE)}abs(){return g.create(h.VALUE)}round(o){return g.create(h.VALUE)}roundInverse(o){return g.create(h.VALUE)}floor(o){return g.create(h.VALUE)}floorInverse(o){return g.create(h.VALUE)}ceil(o){return g.create(h.VALUE)}ceilInverse(o){return g.create(h.VALUE)}convertToNumberObjectValue(){return g.create(h.VALUE)}convertToBooleanObjectValue(){return g.create(h.VALUE)}}const Bc=1e3,pa=new ft(Bc);class g extends ht{constructor(o,e=""){super(o),this._errorType=o,this._errorContent=e}static create(o,e=""){const t=`${o}-${e}`,r=pa.get(t);if(r)return r;const n=new g(o,e);return pa.set(t,n),n}getValue(){return this._errorType}getErrorType(){return this._errorType}getErrorContent(){return this._errorContent}isEqualType(o){return o.getErrorType()===this.getErrorType()}isError(){return!0}}function Ic(i){if(i===null)return 0;if(i!=null&&i.p){const o=i==null?void 0:i.p.body;if(o==null)return 0;const e=o.dataStream;return M.BuildTextUtils.transform.getPlainText(e)}return(i==null?void 0:i.v)||0}var Ut=(i=>(i[i.MIN=0]="MIN",i[i.MAX=1]="MAX",i))(Ut||{}),Oe=(i=>(i[i.NORMAL=0]="NORMAL",i[i.MIN=1]="MIN",i[i.MAX=2]="MAX",i))(Oe||{});function tn(){return Intl&&Intl.Collator?new Intl.Collator(void 0,{numeric:!1}).compare:(i,o)=>i.localeCompare(o)}function Fc(i){return i.indexOf("*")>-1||i.indexOf("?")>-1}function qn(i,o){const e=$c(o).replace(/~?[*?]/g,r=>r.startsWith("~")?`\\${r.substring(1)}`:r==="*"?".*":r==="?"?".":r);return new RegExp(`^${e}$`).test(i)}function Na(i){return i.replace(/~?[*?]/g,o=>o.startsWith("~")?o.substring(1):" ")}function kc(i,o,e){let t=!1;switch(e){case $.EQUALS:t=qn(i,o);break;case $.NOT_EQUAL:t=!qn(i,o);break;case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:t=qn(i,o)||i>Na(o);break;case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:t=i<Na(o);break}return t}function $c(i){return i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}function us(i){switch(i){case 1:return 2;case 0:return 0;case-1:return 1;default:return 0}}function cs(i){return i===-2?1:0}function Ds(i){let o;switch(i){case $.EQUALS:o=$.EQUALS;break;case $.GREATER_THAN:o=$.LESS_THAN;break;case $.GREATER_THAN_OR_EQUAL:o=$.LESS_THAN_OR_EQUAL;break;case $.LESS_THAN:o=$.GREATER_THAN;break;case $.LESS_THAN_OR_EQUAL:o=$.GREATER_THAN_OR_EQUAL;break;case $.NOT_EQUAL:o=$.NOT_EQUAL;break}return o}/*!
2
2
  * decimal.js v10.4.3
3
3
  * An arbitrary-precision Decimal type for JavaScript.
4
4
  * https://github.com/MikeMcl/decimal.js
5
5
  * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
6
6
  * MIT Licence
7
- */var Zt=9e15,Pt=1e9,ls="0123456789abcdef",rn="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",nn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",fs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Zt,maxE:Zt,crypto:!1},Ni,ct,oe=!0,Sn="[DecimalError] ",Dt=Sn+"Invalid argument: ",Vi=Sn+"Precision limit exceeded",Oi=Sn+"crypto unavailable",Mi="[object Decimal]",xe=Math.floor,Se=Math.pow,Yc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Hc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Gc=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Si=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,tt=1e7,te=7,Wc=9007199254740991,Qc=rn.length-1,ms=nn.length-1,v={toStringTag:Mi};v.absoluteValue=v.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),ee(i)};v.ceil=function(){return ee(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(i,o){var e,t=this,r=t.constructor;if(i=new r(i),o=new r(o),!i.s||!o.s)return new r(NaN);if(i.gt(o))throw Error(Dt+o);return e=t.cmp(i),e<0?i:t.cmp(o)>0?o:new r(t)};v.comparedTo=v.cmp=function(i){var o,e,t,r,n=this,s=n.d,a=(i=new n.constructor(i)).d,u=n.s,c=i.s;if(!s||!a)return!u||!c?NaN:u!==c?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-c:0;if(u!==c)return u;if(n.e!==i.e)return n.e>i.e^u<0?1:-1;for(t=s.length,r=a.length,o=0,e=t<r?t:r;o<e;++o)if(s[o]!==a[o])return s[o]>a[o]^u<0?1:-1;return t===r?0:t>r^u<0?1:-1};v.cosine=v.cos=function(){var i,o,e=this,t=e.constructor;return e.d?e.d[0]?(i=t.precision,o=t.rounding,t.precision=i+Math.max(e.e,e.sd())+te,t.rounding=1,e=qc(t,xi(t,e)),t.precision=i,t.rounding=o,ee(ct==2||ct==3?e.neg():e,i,o,!0)):new t(1):new t(NaN)};v.cubeRoot=v.cbrt=function(){var i,o,e,t,r,n,s,a,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(oe=!1,n=l.s*Se(l.s*l,1/3),!n||Math.abs(n)==1/0?(e=Pe(l.d),i=l.e,(n=(i-e.length+1)%3)&&(e+=n==1||n==-2?"0":"00"),n=Se(e,1/3),i=xe((i+1)/3)-(i%3==(i<0?-1:2)),n==1/0?e="5e"+i:(e=n.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),t=new f(e),t.s=l.s):t=new f(n.toString()),s=(i=f.precision)+3;;)if(a=t,u=a.times(a).times(a),c=u.plus(l),t=Re(c.plus(l).times(a),c.plus(u),s+2,1),Pe(a.d).slice(0,s)===(e=Pe(t.d)).slice(0,s))if(e=e.slice(s-3,s+1),e=="9999"||!r&&e=="4999"){if(!r&&(ee(a,i+1,0),a.times(a).times(a).eq(l))){t=a;break}s+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(ee(t,i+1,1),o=!t.times(t).times(t).eq(l));break}return oe=!0,ee(t,i,f.rounding,o)};v.decimalPlaces=v.dp=function(){var i,o=this.d,e=NaN;if(o){if(i=o.length-1,e=(i-xe(this.e/te))*te,i=o[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e};v.dividedBy=v.div=function(i){return Re(this,new this.constructor(i))};v.dividedToIntegerBy=v.divToInt=function(i){var o=this,e=o.constructor;return ee(Re(o,new e(i),0,1,1),e.precision,e.rounding)};v.equals=v.eq=function(i){return this.cmp(i)===0};v.floor=function(){return ee(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(i){return this.cmp(i)>0};v.greaterThanOrEqualTo=v.gte=function(i){var o=this.cmp(i);return o==1||o===0};v.hyperbolicCosine=v.cosh=function(){var i,o,e,t,r,n=this,s=n.constructor,a=new s(1);if(!n.isFinite())return new s(n.s?1/0:NaN);if(n.isZero())return a;e=s.precision,t=s.rounding,s.precision=e+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<32?(i=Math.ceil(r/3),o=(1/wn(4,i)).toString()):(i=16,o="2.3283064365386962890625e-10"),n=sr(s,1,n.times(o),new s(1),!0);for(var u,c=i,l=new s(8);c--;)u=n.times(n),n=a.minus(u.times(l.minus(u.times(l))));return ee(n,s.precision=e,s.rounding=t,!0)};v.hyperbolicSine=v.sinh=function(){var i,o,e,t,r=this,n=r.constructor;if(!r.isFinite()||r.isZero())return new n(r);if(o=n.precision,e=n.rounding,n.precision=o+Math.max(r.e,r.sd())+4,n.rounding=1,t=r.d.length,t<3)r=sr(n,2,r,r,!0);else{i=1.4*Math.sqrt(t),i=i>16?16:i|0,r=r.times(1/wn(5,i)),r=sr(n,2,r,r,!0);for(var s,a=new n(5),u=new n(16),c=new n(20);i--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(c))))}return n.precision=o,n.rounding=e,ee(r,o,e,!0)};v.hyperbolicTangent=v.tanh=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+7,t.rounding=1,Re(e.sinh(),e.cosh(),t.precision=i,t.rounding=o)):new t(e.s)};v.inverseCosine=v.acos=function(){var i,o=this,e=o.constructor,t=o.abs().cmp(1),r=e.precision,n=e.rounding;return t!==-1?t===0?o.isNeg()?et(e,r,n):new e(0):new e(NaN):o.isZero()?et(e,r+4,n).times(.5):(e.precision=r+6,e.rounding=1,o=o.asin(),i=et(e,r+4,n).times(.5),e.precision=r,e.rounding=n,i.minus(o))};v.inverseHyperbolicCosine=v.acosh=function(){var i,o,e=this,t=e.constructor;return e.lte(1)?new t(e.eq(1)?0:NaN):e.isFinite()?(i=t.precision,o=t.rounding,t.precision=i+Math.max(Math.abs(e.e),e.sd())+4,t.rounding=1,oe=!1,e=e.times(e).minus(1).sqrt().plus(e),oe=!0,t.precision=i,t.rounding=o,e.ln()):new t(e)};v.inverseHyperbolicSine=v.asinh=function(){var i,o,e=this,t=e.constructor;return!e.isFinite()||e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,t.rounding=1,oe=!1,e=e.times(e).plus(1).sqrt().plus(e),oe=!0,t.precision=i,t.rounding=o,e.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var i,o,e,t,r=this,n=r.constructor;return r.isFinite()?r.e>=0?new n(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(i=n.precision,o=n.rounding,t=r.sd(),Math.max(t,i)<2*-r.e-1?ee(new n(r),i,o,!0):(n.precision=e=t-r.e,r=Re(r.plus(1),new n(1).minus(r),e+i,1),n.precision=i+4,n.rounding=1,r=r.ln(),n.precision=i,n.rounding=o,r.times(.5))):new n(NaN)};v.inverseSine=v.asin=function(){var i,o,e,t,r=this,n=r.constructor;return r.isZero()?new n(r):(o=r.abs().cmp(1),e=n.precision,t=n.rounding,o!==-1?o===0?(i=et(n,e+4,t).times(.5),i.s=r.s,i):new n(NaN):(n.precision=e+6,n.rounding=1,r=r.div(new n(1).minus(r.times(r)).sqrt().plus(1)).atan(),n.precision=e,n.rounding=t,r.times(2)))};v.inverseTangent=v.atan=function(){var i,o,e,t,r,n,s,a,u,c=this,l=c.constructor,f=l.precision,m=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=ms)return s=et(l,f+4,m).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(f+4<=ms)return s=et(l,f+4,m).times(.5),s.s=c.s,s}for(l.precision=a=f+10,l.rounding=1,e=Math.min(28,a/te+2|0),i=e;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(oe=!1,o=Math.ceil(a/te),t=1,u=c.times(c),s=new l(c),r=c;i!==-1;)if(r=r.times(u),n=s.minus(r.div(t+=2)),r=r.times(u),s=n.plus(r.div(t+=2)),s.d[o]!==void 0)for(i=o;s.d[i]===n.d[i]&&i--;);return e&&(s=s.times(2<<e-1)),oe=!0,ee(s,l.precision=f,l.rounding=m,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&xe(this.e/te)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(i){return this.cmp(i)<0};v.lessThanOrEqualTo=v.lte=function(i){return this.cmp(i)<1};v.logarithm=v.log=function(i){var o,e,t,r,n,s,a,u,c=this,l=c.constructor,f=l.precision,m=l.rounding,d=5;if(i==null)i=new l(10),o=!0;else{if(i=new l(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new l(NaN);o=i.eq(10)}if(e=c.d,c.s<0||!e||!e[0]||c.eq(1))return new l(e&&!e[0]?-1/0:c.s!=1?NaN:e?0:1/0);if(o)if(e.length>1)n=!0;else{for(r=e[0];r%10===0;)r/=10;n=r!==1}if(oe=!1,a=f+d,s=pt(c,a),t=o?sn(l,a+10):pt(i,a),u=Re(s,t,a,1),yr(u.d,r=f,m))do if(a+=10,s=pt(c,a),t=o?sn(l,a+10):pt(i,a),u=Re(s,t,a,1),!n){+Pe(u.d).slice(r+1,r+15)+1==1e14&&(u=ee(u,f+1,0));break}while(yr(u.d,r+=10,m));return oe=!0,ee(u,f,m)};v.minus=v.sub=function(i){var o,e,t,r,n,s,a,u,c,l,f,m,d=this,C=d.constructor;if(i=new C(i),!d.d||!i.d)return!d.s||!i.s?i=new C(NaN):d.d?i.s=-i.s:i=new C(i.d||d.s!==i.s?d:NaN),i;if(d.s!=i.s)return i.s=-i.s,d.plus(i);if(c=d.d,m=i.d,a=C.precision,u=C.rounding,!c[0]||!m[0]){if(m[0])i.s=-i.s;else if(c[0])i=new C(d);else return new C(u===3?-0:0);return oe?ee(i,a,u):i}if(e=xe(i.e/te),l=xe(d.e/te),c=c.slice(),n=l-e,n){for(f=n<0,f?(o=c,n=-n,s=m.length):(o=m,e=l,s=c.length),t=Math.max(Math.ceil(a/te),s)+2,n>t&&(n=t,o.length=1),o.reverse(),t=n;t--;)o.push(0);o.reverse()}else{for(t=c.length,s=m.length,f=t<s,f&&(s=t),t=0;t<s;t++)if(c[t]!=m[t]){f=c[t]<m[t];break}n=0}for(f&&(o=c,c=m,m=o,i.s=-i.s),s=c.length,t=m.length-s;t>0;--t)c[s++]=0;for(t=m.length;t>n;){if(c[--t]<m[t]){for(r=t;r&&c[--r]===0;)c[r]=tt-1;--c[r],c[t]+=tt}c[t]-=m[t]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--e;return c[0]?(i.d=c,i.e=Dn(c,e),oe?ee(i,a,u):i):new C(u===3?-0:0)};v.modulo=v.mod=function(i){var o,e=this,t=e.constructor;return i=new t(i),!e.d||!i.s||i.d&&!i.d[0]?new t(NaN):!i.d||e.d&&!e.d[0]?ee(new t(e),t.precision,t.rounding):(oe=!1,t.modulo==9?(o=Re(e,i.abs(),0,3,1),o.s*=i.s):o=Re(e,i,0,t.modulo,1),o=o.times(i),oe=!0,e.minus(o))};v.naturalExponential=v.exp=function(){return hs(this)};v.naturalLogarithm=v.ln=function(){return pt(this)};v.negated=v.neg=function(){var i=new this.constructor(this);return i.s=-i.s,ee(i)};v.plus=v.add=function(i){var o,e,t,r,n,s,a,u,c,l,f=this,m=f.constructor;if(i=new m(i),!f.d||!i.d)return!f.s||!i.s?i=new m(NaN):f.d||(i=new m(i.d||f.s===i.s?f:NaN)),i;if(f.s!=i.s)return i.s=-i.s,f.minus(i);if(c=f.d,l=i.d,a=m.precision,u=m.rounding,!c[0]||!l[0])return l[0]||(i=new m(f)),oe?ee(i,a,u):i;if(n=xe(f.e/te),t=xe(i.e/te),c=c.slice(),r=n-t,r){for(r<0?(e=c,r=-r,s=l.length):(e=l,t=n,s=c.length),n=Math.ceil(a/te),s=n>s?n+1:s+1,r>s&&(r=s,e.length=1),e.reverse();r--;)e.push(0);e.reverse()}for(s=c.length,r=l.length,s-r<0&&(r=s,e=l,l=c,c=e),o=0;r;)o=(c[--r]=c[r]+l[r]+o)/tt|0,c[r]%=tt;for(o&&(c.unshift(o),++t),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=Dn(c,t),oe?ee(i,a,u):i};v.precision=v.sd=function(i){var o,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Dt+i);return e.d?(o=Di(e.d),i&&e.e+1>o&&(o=e.e+1)):o=NaN,o};v.round=function(){var i=this,o=i.constructor;return ee(new o(i),i.e+1,o.rounding)};v.sine=v.sin=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+Math.max(e.e,e.sd())+te,t.rounding=1,e=Kc(t,xi(t,e)),t.precision=i,t.rounding=o,ee(ct>2?e.neg():e,i,o,!0)):new t(NaN)};v.squareRoot=v.sqrt=function(){var i,o,e,t,r,n,s=this,a=s.d,u=s.e,c=s.s,l=s.constructor;if(c!==1||!a||!a[0])return new l(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(oe=!1,c=Math.sqrt(+s),c==0||c==1/0?(o=Pe(a),(o.length+u)%2==0&&(o+="0"),c=Math.sqrt(o),u=xe((u+1)/2)-(u<0||u%2),c==1/0?o="5e"+u:(o=c.toExponential(),o=o.slice(0,o.indexOf("e")+1)+u),t=new l(o)):t=new l(c.toString()),e=(u=l.precision)+3;;)if(n=t,t=n.plus(Re(s,n,e+2,1)).times(.5),Pe(n.d).slice(0,e)===(o=Pe(t.d)).slice(0,e))if(o=o.slice(e-3,e+1),o=="9999"||!r&&o=="4999"){if(!r&&(ee(n,u+1,0),n.times(n).eq(s))){t=n;break}e+=4,r=1}else{(!+o||!+o.slice(1)&&o.charAt(0)=="5")&&(ee(t,u+1,1),i=!t.times(t).eq(s));break}return oe=!0,ee(t,u,l.rounding,i)};v.tangent=v.tan=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+10,t.rounding=1,e=e.sin(),e.s=1,e=Re(e,new t(1).minus(e.times(e)).sqrt(),i+10,0),t.precision=i,t.rounding=o,ee(ct==2||ct==4?e.neg():e,i,o,!0)):new t(NaN)};v.times=v.mul=function(i){var o,e,t,r,n,s,a,u,c,l=this,f=l.constructor,m=l.d,d=(i=new f(i)).d;if(i.s*=l.s,!m||!m[0]||!d||!d[0])return new f(!i.s||m&&!m[0]&&!d||d&&!d[0]&&!m?NaN:!m||!d?i.s/0:i.s*0);for(e=xe(l.e/te)+xe(i.e/te),u=m.length,c=d.length,u<c&&(n=m,m=d,d=n,s=u,u=c,c=s),n=[],s=u+c,t=s;t--;)n.push(0);for(t=c;--t>=0;){for(o=0,r=u+t;r>t;)a=n[r]+d[t]*m[r-t-1]+o,n[r--]=a%tt|0,o=a/tt|0;n[r]=(n[r]+o)%tt|0}for(;!n[--s];)n.pop();return o?++e:n.shift(),i.d=n,i.e=Dn(n,e),oe?ee(i,f.precision,f.rounding):i};v.toBinary=function(i,o){return ws(this,2,i,o)};v.toDecimalPlaces=v.toDP=function(i,o){var e=this,t=e.constructor;return e=new t(e),i===void 0?e:(Ie(i,0,Pt),o===void 0?o=t.rounding:Ie(o,0,8),ee(e,i+e.e+1,o))};v.toExponential=function(i,o){var e,t=this,r=t.constructor;return i===void 0?e=nt(t,!0):(Ie(i,0,Pt),o===void 0?o=r.rounding:Ie(o,0,8),t=ee(new r(t),i+1,o),e=nt(t,!0,i+1)),t.isNeg()&&!t.isZero()?"-"+e:e};v.toFixed=function(i,o){var e,t,r=this,n=r.constructor;return i===void 0?e=nt(r):(Ie(i,0,Pt),o===void 0?o=n.rounding:Ie(o,0,8),t=ee(new n(r),i+r.e+1,o),e=nt(t,!1,i+t.e+1)),r.isNeg()&&!r.isZero()?"-"+e:e};v.toFraction=function(i){var o,e,t,r,n,s,a,u,c,l,f,m,d=this,C=d.d,_=d.constructor;if(!C)return new _(d);if(c=e=new _(1),t=u=new _(0),o=new _(t),n=o.e=Di(C)-d.e-1,s=n%te,o.d[0]=Se(10,s<0?te+s:s),i==null)i=n>0?o:c;else{if(a=new _(i),!a.isInt()||a.lt(c))throw Error(Dt+a);i=a.gt(o)?n>0?o:c:a}for(oe=!1,a=new _(Pe(C)),l=_.precision,_.precision=n=C.length*te*2;f=Re(a,o,0,1,1),r=e.plus(f.times(t)),r.cmp(i)!=1;)e=t,t=r,r=c,c=u.plus(f.times(r)),u=r,r=o,o=a.minus(f.times(r)),a=r;return r=Re(i.minus(e),t,0,1,1),u=u.plus(r.times(c)),e=e.plus(r.times(t)),u.s=c.s=d.s,m=Re(c,t,n,1).minus(d).abs().cmp(Re(u,e,n,1).minus(d).abs())<1?[c,t]:[u,e],_.precision=l,oe=!0,m};v.toHexadecimal=v.toHex=function(i,o){return ws(this,16,i,o)};v.toNearest=function(i,o){var e=this,t=e.constructor;if(e=new t(e),i==null){if(!e.d)return e;i=new t(1),o=t.rounding}else{if(i=new t(i),o===void 0?o=t.rounding:Ie(o,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(oe=!1,e=Re(e,i,0,o,1).times(i),oe=!0,ee(e)):(i.s=e.s,e=i),e};v.toNumber=function(){return+this};v.toOctal=function(i,o){return ws(this,8,i,o)};v.toPower=v.pow=function(i){var o,e,t,r,n,s,a=this,u=a.constructor,c=+(i=new u(i));if(!a.d||!i.d||!a.d[0]||!i.d[0])return new u(Se(+a,c));if(a=new u(a),a.eq(1))return a;if(t=u.precision,n=u.rounding,i.eq(1))return ee(a,t,n);if(o=xe(i.e/te),o>=i.d.length-1&&(e=c<0?-c:c)<=Wc)return r=wi(u,a,e,t),i.s<0?new u(1).div(r):ee(r,t,n);if(s=a.s,s<0){if(o<i.d.length-1)return new u(NaN);if(i.d[o]&1||(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return e=Se(+a,c),o=e==0||!isFinite(e)?xe(c*(Math.log("0."+Pe(a.d))/Math.LN10+a.e+1)):new u(e+"").e,o>u.maxE+1||o<u.minE-1?new u(o>0?s/0:0):(oe=!1,u.rounding=a.s=1,e=Math.min(12,(o+"").length),r=hs(i.times(pt(a,t+e)),t),r.d&&(r=ee(r,t+5,1),yr(r.d,t,n)&&(o=t+10,r=ee(hs(i.times(pt(a,o+e)),o),o+5,1),+Pe(r.d).slice(t+1,t+15)+1==1e14&&(r=ee(r,t+1,0)))),r.s=s,oe=!0,u.rounding=n,ee(r,t,n))};v.toPrecision=function(i,o){var e,t=this,r=t.constructor;return i===void 0?e=nt(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(Ie(i,1,Pt),o===void 0?o=r.rounding:Ie(o,0,8),t=ee(new r(t),i,o),e=nt(t,i<=t.e||t.e<=r.toExpNeg,i)),t.isNeg()&&!t.isZero()?"-"+e:e};v.toSignificantDigits=v.toSD=function(i,o){var e=this,t=e.constructor;return i===void 0?(i=t.precision,o=t.rounding):(Ie(i,1,Pt),o===void 0?o=t.rounding:Ie(o,0,8)),ee(new t(e),i,o)};v.toString=function(){var i=this,o=i.constructor,e=nt(i,i.e<=o.toExpNeg||i.e>=o.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e};v.truncated=v.trunc=function(){return ee(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var i=this,o=i.constructor,e=nt(i,i.e<=o.toExpNeg||i.e>=o.toExpPos);return i.isNeg()?"-"+e:e};function Pe(i){var o,e,t,r=i.length-1,n="",s=i[0];if(r>0){for(n+=s,o=1;o<r;o++)t=i[o]+"",e=te-t.length,e&&(n+=bt(e)),n+=t;s=i[o],t=s+"",e=te-t.length,e&&(n+=bt(e))}else if(s===0)return"0";for(;s%10===0;)s/=10;return n+s}function Ie(i,o,e){if(i!==~~i||i<o||i>e)throw Error(Dt+i)}function yr(i,o,e,t){var r,n,s,a;for(n=i[0];n>=10;n/=10)--o;return--o<0?(o+=te,r=0):(r=Math.ceil((o+1)/te),o%=te),n=Se(10,te-o),a=i[r]%n|0,t==null?o<3?(o==0?a=a/100|0:o==1&&(a=a/10|0),s=e<4&&a==99999||e>3&&a==49999||a==5e4||a==0):s=(e<4&&a+1==n||e>3&&a+1==n/2)&&(i[r+1]/n/100|0)==Se(10,o-2)-1||(a==n/2||a==0)&&(i[r+1]/n/100|0)==0:o<4?(o==0?a=a/1e3|0:o==1?a=a/100|0:o==2&&(a=a/10|0),s=(t||e<4)&&a==9999||!t&&e>3&&a==4999):s=((t||e<4)&&a+1==n||!t&&e>3&&a+1==n/2)&&(i[r+1]/n/1e3|0)==Se(10,o-3)-1,s}function Hr(i,o,e){for(var t,r=[0],n,s=0,a=i.length;s<a;){for(n=r.length;n--;)r[n]*=o;for(r[0]+=ls.indexOf(i.charAt(s++)),t=0;t<r.length;t++)r[t]>e-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/e|0,r[t]%=e)}return r.reverse()}function qc(i,o){var e,t,r;if(o.isZero())return o;t=o.d.length,t<32?(e=Math.ceil(t/3),r=(1/wn(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),i.precision+=e,o=sr(i,1,o.times(r),new i(1));for(var n=e;n--;){var s=o.times(o);o=s.times(s).minus(s).times(8).plus(1)}return i.precision-=e,o}var Re=function(){function i(t,r,n){var s,a=0,u=t.length;for(t=t.slice();u--;)s=t[u]*r+a,t[u]=s%n|0,a=s/n|0;return a&&t.unshift(a),t}function o(t,r,n,s){var a,u;if(n!=s)u=n>s?1:-1;else for(a=u=0;a<n;a++)if(t[a]!=r[a]){u=t[a]>r[a]?1:-1;break}return u}function e(t,r,n,s){for(var a=0;n--;)t[n]-=a,a=t[n]<r[n]?1:0,t[n]=a*s+t[n]-r[n];for(;!t[0]&&t.length>1;)t.shift()}return function(t,r,n,s,a,u){var c,l,f,m,d,C,_,E,b,R,p,V,S,D,w,P,L,T,B,W,q=t.constructor,ie=t.s==r.s?1:-1,Z=t.d,G=r.d;if(!Z||!Z[0]||!G||!G[0])return new q(!t.s||!r.s||(Z?G&&Z[0]==G[0]:!G)?NaN:Z&&Z[0]==0||!G?ie*0:ie/0);for(u?(d=1,l=t.e-r.e):(u=tt,d=te,l=xe(t.e/d)-xe(r.e/d)),B=G.length,L=Z.length,b=new q(ie),R=b.d=[],f=0;G[f]==(Z[f]||0);f++);if(G[f]>(Z[f]||0)&&l--,n==null?(D=n=q.precision,s=q.rounding):a?D=n+(t.e-r.e)+1:D=n,D<0)R.push(1),C=!0;else{if(D=D/d+2|0,f=0,B==1){for(m=0,G=G[0],D++;(f<L||m)&&D--;f++)w=m*u+(Z[f]||0),R[f]=w/G|0,m=w%G|0;C=m||f<L}else{for(m=u/(G[0]+1)|0,m>1&&(G=i(G,m,u),Z=i(Z,m,u),B=G.length,L=Z.length),P=B,p=Z.slice(0,B),V=p.length;V<B;)p[V++]=0;W=G.slice(),W.unshift(0),T=G[0],G[1]>=u/2&&++T;do m=0,c=o(G,p,B,V),c<0?(S=p[0],B!=V&&(S=S*u+(p[1]||0)),m=S/T|0,m>1?(m>=u&&(m=u-1),_=i(G,m,u),E=_.length,V=p.length,c=o(_,p,E,V),c==1&&(m--,e(_,B<E?W:G,E,u))):(m==0&&(c=m=1),_=G.slice()),E=_.length,E<V&&_.unshift(0),e(p,_,V,u),c==-1&&(V=p.length,c=o(G,p,B,V),c<1&&(m++,e(p,B<V?W:G,V,u))),V=p.length):c===0&&(m++,p=[0]),R[f++]=m,c&&p[0]?p[V++]=Z[P]||0:(p=[Z[P]],V=1);while((P++<L||p[0]!==void 0)&&D--);C=p[0]!==void 0}R[0]||R.shift()}if(d==1)b.e=l,Ni=C;else{for(f=1,m=R[0];m>=10;m/=10)f++;b.e=f+l*d-1,ee(b,a?n+b.e+1:n,s,C)}return b}}();function ee(i,o,e,t){var r,n,s,a,u,c,l,f,m,d=i.constructor;e:if(o!=null){if(f=i.d,!f)return i;for(r=1,a=f[0];a>=10;a/=10)r++;if(n=o-r,n<0)n+=te,s=o,l=f[m=0],u=l/Se(10,r-s-1)%10|0;else if(m=Math.ceil((n+1)/te),a=f.length,m>=a)if(t){for(;a++<=m;)f.push(0);l=u=0,r=1,n%=te,s=n-te+1}else break e;else{for(l=a=f[m],r=1;a>=10;a/=10)r++;n%=te,s=n-te+r,u=s<0?0:l/Se(10,r-s-1)%10|0}if(t=t||o<0||f[m+1]!==void 0||(s<0?l:l%Se(10,r-s-1)),c=e<4?(u||t)&&(e==0||e==(i.s<0?3:2)):u>5||u==5&&(e==4||t||e==6&&(n>0?s>0?l/Se(10,r-s):0:f[m-1])%10&1||e==(i.s<0?8:7)),o<1||!f[0])return f.length=0,c?(o-=i.e+1,f[0]=Se(10,(te-o%te)%te),i.e=-o||0):f[0]=i.e=0,i;if(n==0?(f.length=m,a=1,m--):(f.length=m+1,a=Se(10,te-n),f[m]=s>0?(l/Se(10,r-s)%Se(10,s)|0)*a:0),c)for(;;)if(m==0){for(n=1,s=f[0];s>=10;s/=10)n++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;n!=a&&(i.e++,f[0]==tt&&(f[0]=1));break}else{if(f[m]+=a,f[m]!=tt)break;f[m--]=0,a=1}for(n=f.length;f[--n]===0;)f.pop()}return oe&&(i.e>d.maxE?(i.d=null,i.e=NaN):i.e<d.minE&&(i.e=0,i.d=[0])),i}function nt(i,o,e){if(!i.isFinite())return Li(i);var t,r=i.e,n=Pe(i.d),s=n.length;return o?(e&&(t=e-s)>0?n=n.charAt(0)+"."+n.slice(1)+bt(t):s>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(i.e<0?"e":"e+")+i.e):r<0?(n="0."+bt(-r-1)+n,e&&(t=e-s)>0&&(n+=bt(t))):r>=s?(n+=bt(r+1-s),e&&(t=e-r-1)>0&&(n=n+"."+bt(t))):((t=r+1)<s&&(n=n.slice(0,t)+"."+n.slice(t)),e&&(t=e-s)>0&&(r+1===s&&(n+="."),n+=bt(t))),n}function Dn(i,o){var e=i[0];for(o*=te;e>=10;e/=10)o++;return o}function sn(i,o,e){if(o>Qc)throw oe=!0,e&&(i.precision=e),Error(Vi);return ee(new i(rn),o,1,!0)}function et(i,o,e){if(o>ms)throw Error(Vi);return ee(new i(nn),o,e,!0)}function Di(i){var o=i.length-1,e=o*te+1;if(o=i[o],o){for(;o%10==0;o/=10)e--;for(o=i[0];o>=10;o/=10)e++}return e}function bt(i){for(var o="";i--;)o+="0";return o}function wi(i,o,e,t){var r,n=new i(1),s=Math.ceil(t/te+4);for(oe=!1;;){if(e%2&&(n=n.times(o),Oa(n.d,s)&&(r=!0)),e=xe(e/2),e===0){e=n.d.length-1,r&&n.d[e]===0&&++n.d[e];break}o=o.times(o),Oa(o.d,s)}return oe=!0,n}function Va(i){return i.d[i.d.length-1]&1}function Pi(i,o,e){for(var t,r=new i(o[0]),n=0;++n<o.length;)if(t=new i(o[n]),t.s)r[e](t)&&(r=t);else{r=t;break}return r}function hs(i,o){var e,t,r,n,s,a,u,c=0,l=0,f=0,m=i.constructor,d=m.rounding,C=m.precision;if(!i.d||!i.d[0]||i.e>17)return new m(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(o==null?(oe=!1,u=C):u=o,a=new m(.03125);i.e>-2;)i=i.times(a),f+=5;for(t=Math.log(Se(2,f))/Math.LN10*2+5|0,u+=t,e=n=s=new m(1),m.precision=u;;){if(n=ee(n.times(i),u,1),e=e.times(++l),a=s.plus(Re(n,e,u,1)),Pe(a.d).slice(0,u)===Pe(s.d).slice(0,u)){for(r=f;r--;)s=ee(s.times(s),u,1);if(o==null)if(c<3&&yr(s.d,u-t,d,c))m.precision=u+=10,e=n=a=new m(1),l=0,c++;else return ee(s,m.precision=C,d,oe=!0);else return m.precision=C,s}s=a}}function pt(i,o){var e,t,r,n,s,a,u,c,l,f,m,d=1,C=10,_=i,E=_.d,b=_.constructor,R=b.rounding,p=b.precision;if(_.s<0||!E||!E[0]||!_.e&&E[0]==1&&E.length==1)return new b(E&&!E[0]?-1/0:_.s!=1?NaN:E?0:_);if(o==null?(oe=!1,l=p):l=o,b.precision=l+=C,e=Pe(E),t=e.charAt(0),Math.abs(n=_.e)<15e14){for(;t<7&&t!=1||t==1&&e.charAt(1)>3;)_=_.times(i),e=Pe(_.d),t=e.charAt(0),d++;n=_.e,t>1?(_=new b("0."+e),n++):_=new b(t+"."+e.slice(1))}else return c=sn(b,l+2,p).times(n+""),_=pt(new b(t+"."+e.slice(1)),l-C).plus(c),b.precision=p,o==null?ee(_,p,R,oe=!0):_;for(f=_,u=s=_=Re(_.minus(1),_.plus(1),l,1),m=ee(_.times(_),l,1),r=3;;){if(s=ee(s.times(m),l,1),c=u.plus(Re(s,new b(r),l,1)),Pe(c.d).slice(0,l)===Pe(u.d).slice(0,l))if(u=u.times(2),n!==0&&(u=u.plus(sn(b,l+2,p).times(n+""))),u=Re(u,new b(d),l,1),o==null)if(yr(u.d,l-C,R,a))b.precision=l+=C,c=s=_=Re(f.minus(1),f.plus(1),l,1),m=ee(_.times(_),l,1),r=a=1;else return ee(u,b.precision=p,R,oe=!0);else return b.precision=p,u;u=c,r+=2}}function Li(i){return String(i.s*i.s/0)}function gs(i,o){var e,t,r;for((e=o.indexOf("."))>-1&&(o=o.replace(".","")),(t=o.search(/e/i))>0?(e<0&&(e=t),e+=+o.slice(t+1),o=o.substring(0,t)):e<0&&(e=o.length),t=0;o.charCodeAt(t)===48;t++);for(r=o.length;o.charCodeAt(r-1)===48;--r);if(o=o.slice(t,r),o){if(r-=t,i.e=e=e-t-1,i.d=[],t=(e+1)%te,e<0&&(t+=te),t<r){for(t&&i.d.push(+o.slice(0,t)),r-=te;t<r;)i.d.push(+o.slice(t,t+=te));o=o.slice(t),t=te-o.length}else t-=r;for(;t--;)o+="0";i.d.push(+o),oe&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function Xc(i,o){var e,t,r,n,s,a,u,c,l;if(o.indexOf("_")>-1){if(o=o.replace(/(\d)_(?=\d)/g,"$1"),Si.test(o))return gs(i,o)}else if(o==="Infinity"||o==="NaN")return+o||(i.s=NaN),i.e=NaN,i.d=null,i;if(Hc.test(o))e=16,o=o.toLowerCase();else if(Yc.test(o))e=2;else if(Gc.test(o))e=8;else throw Error(Dt+o);for(n=o.search(/p/i),n>0?(u=+o.slice(n+1),o=o.substring(2,n)):o=o.slice(2),n=o.indexOf("."),s=n>=0,t=i.constructor,s&&(o=o.replace(".",""),a=o.length,n=a-n,r=wi(t,new t(e),n,n*2)),c=Hr(o,e,tt),l=c.length-1,n=l;c[n]===0;--n)c.pop();return n<0?new t(i.s*0):(i.e=Dn(c,l),i.d=c,oe=!1,s&&(i=Re(i,r,a*4)),u&&(i=i.times(Math.abs(u)<54?Se(2,u):x.pow(2,u))),oe=!0,i)}function Kc(i,o){var e,t=o.d.length;if(t<3)return o.isZero()?o:sr(i,2,o,o);e=1.4*Math.sqrt(t),e=e>16?16:e|0,o=o.times(1/wn(5,e)),o=sr(i,2,o,o);for(var r,n=new i(5),s=new i(16),a=new i(20);e--;)r=o.times(o),o=o.times(n.plus(r.times(s.times(r).minus(a))));return o}function sr(i,o,e,t,r){var n,s,a,u,c=i.precision,l=Math.ceil(c/te);for(oe=!1,u=e.times(e),a=new i(t);;){if(s=Re(a.times(u),new i(o++*o++),c,1),a=r?t.plus(s):t.minus(s),t=Re(s.times(u),new i(o++*o++),c,1),s=a.plus(t),s.d[l]!==void 0){for(n=l;s.d[n]===a.d[n]&&n--;);if(n==-1)break}n=a,a=t,t=s,s=n}return oe=!0,s.d.length=l+1,s}function wn(i,o){for(var e=i;--o;)e*=i;return e}function xi(i,o){var e,t=o.s<0,r=et(i,i.precision,1),n=r.times(.5);if(o=o.abs(),o.lte(n))return ct=t?4:1,o;if(e=o.divToInt(r),e.isZero())ct=t?3:2;else{if(o=o.minus(e.times(r)),o.lte(n))return ct=Va(e)?t?2:3:t?4:1,o;ct=Va(e)?t?1:4:t?3:2}return o.minus(r).abs()}function ws(i,o,e,t){var r,n,s,a,u,c,l,f,m,d=i.constructor,C=e!==void 0;if(C?(Ie(e,1,Pt),t===void 0?t=d.rounding:Ie(t,0,8)):(e=d.precision,t=d.rounding),!i.isFinite())l=Li(i);else{for(l=nt(i),s=l.indexOf("."),C?(r=2,o==16?e=e*4-3:o==8&&(e=e*3-2)):r=o,s>=0&&(l=l.replace(".",""),m=new d(1),m.e=l.length-s,m.d=Hr(nt(m),10,r),m.e=m.d.length),f=Hr(l,10,r),n=u=f.length;f[--u]==0;)f.pop();if(!f[0])l=C?"0p+0":"0";else{if(s<0?n--:(i=new d(i),i.d=f,i.e=n,i=Re(i,m,e,t,0,r),f=i.d,n=i.e,c=Ni),s=f[e],a=r/2,c=c||f[e+1]!==void 0,c=t<4?(s!==void 0||c)&&(t===0||t===(i.s<0?3:2)):s>a||s===a&&(t===4||c||t===6&&f[e-1]&1||t===(i.s<0?8:7)),f.length=e,c)for(;++f[--e]>r-1;)f[e]=0,e||(++n,f.unshift(1));for(u=f.length;!f[u-1];--u);for(s=0,l="";s<u;s++)l+=ls.charAt(f[s]);if(C){if(u>1)if(o==16||o==8){for(s=o==16?4:3,--u;u%s;u++)l+="0";for(f=Hr(l,r,o),u=f.length;!f[u-1];--u);for(s=1,l="1.";s<u;s++)l+=ls.charAt(f[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)l="0"+l;l="0."+l}else if(++n>u)for(n-=u;n--;)l+="0";else n<u&&(l=l.slice(0,n)+"."+l.slice(n))}l=(o==16?"0x":o==2?"0b":o==8?"0o":"")+l}return i.s<0?"-"+l:l}function Oa(i,o){if(i.length>o)return i.length=o,!0}function Zc(i){return new this(i).abs()}function zc(i){return new this(i).acos()}function Jc(i){return new this(i).acosh()}function el(i,o){return new this(i).plus(o)}function tl(i){return new this(i).asin()}function rl(i){return new this(i).asinh()}function nl(i){return new this(i).atan()}function sl(i){return new this(i).atanh()}function al(i,o){i=new this(i),o=new this(o);var e,t=this.precision,r=this.rounding,n=t+4;return!i.s||!o.s?e=new this(NaN):!i.d&&!o.d?(e=et(this,n,1).times(o.s>0?.25:.75),e.s=i.s):!o.d||i.isZero()?(e=o.s<0?et(this,t,r):new this(0),e.s=i.s):!i.d||o.isZero()?(e=et(this,n,1).times(.5),e.s=i.s):o.s<0?(this.precision=n,this.rounding=1,e=this.atan(Re(i,o,n,1)),o=et(this,n,1),this.precision=t,this.rounding=r,e=i.s<0?e.minus(o):e.plus(o)):e=this.atan(Re(i,o,n,1)),e}function il(i){return new this(i).cbrt()}function ol(i){return ee(i=new this(i),i.e+1,2)}function ul(i,o,e){return new this(i).clamp(o,e)}function cl(i){if(!i||typeof i!="object")throw Error(Sn+"Object expected");var o,e,t,r=i.defaults===!0,n=["precision",1,Pt,"rounding",0,8,"toExpNeg",-Zt,0,"toExpPos",0,Zt,"maxE",0,Zt,"minE",-Zt,0,"modulo",0,9];for(o=0;o<n.length;o+=3)if(e=n[o],r&&(this[e]=fs[e]),(t=i[e])!==void 0)if(xe(t)===t&&t>=n[o+1]&&t<=n[o+2])this[e]=t;else throw Error(Dt+e+": "+t);if(e="crypto",r&&(this[e]=fs[e]),(t=i[e])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(Oi);else this[e]=!1;else throw Error(Dt+e+": "+t);return this}function ll(i){return new this(i).cos()}function fl(i){return new this(i).cosh()}function ji(i){var o,e,t;function r(n){var s,a,u,c=this;if(!(c instanceof r))return new r(n);if(c.constructor=r,Ma(n)){c.s=n.s,oe?!n.d||n.e>r.maxE?(c.e=NaN,c.d=null):n.e<r.minE?(c.e=0,c.d=[0]):(c.e=n.e,c.d=n.d.slice()):(c.e=n.e,c.d=n.d?n.d.slice():n.d);return}if(u=typeof n,u==="number"){if(n===0){c.s=1/n<0?-1:1,c.e=0,c.d=[0];return}if(n<0?(n=-n,c.s=-1):c.s=1,n===~~n&&n<1e7){for(s=0,a=n;a>=10;a/=10)s++;oe?s>r.maxE?(c.e=NaN,c.d=null):s<r.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[n]):(c.e=s,c.d=[n]);return}else if(n*0!==0){n||(c.s=NaN),c.e=NaN,c.d=null;return}return gs(c,n.toString())}else if(u!=="string")throw Error(Dt+n);return(a=n.charCodeAt(0))===45?(n=n.slice(1),c.s=-1):(a===43&&(n=n.slice(1)),c.s=1),Si.test(n)?gs(c,n):Xc(c,n)}if(r.prototype=v,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=cl,r.clone=ji,r.isDecimal=Ma,r.abs=Zc,r.acos=zc,r.acosh=Jc,r.add=el,r.asin=tl,r.asinh=rl,r.atan=nl,r.atanh=sl,r.atan2=al,r.cbrt=il,r.ceil=ol,r.clamp=ul,r.cos=ll,r.cosh=fl,r.div=ml,r.exp=hl,r.floor=gl,r.hypot=dl,r.ln=Cl,r.log=_l,r.log10=El,r.log2=Al,r.max=bl,r.min=yl,r.mod=Rl,r.mul=pl,r.pow=Nl,r.random=Vl,r.round=Ol,r.sign=Ml,r.sin=Sl,r.sinh=Dl,r.sqrt=wl,r.sub=Pl,r.sum=Ll,r.tan=xl,r.tanh=jl,r.trunc=Ul,i===void 0&&(i={}),i&&i.defaults!==!0)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],o=0;o<t.length;)i.hasOwnProperty(e=t[o++])||(i[e]=this[e]);return r.config(i),r}function ml(i,o){return new this(i).div(o)}function hl(i){return new this(i).exp()}function gl(i){return ee(i=new this(i),i.e+1,3)}function dl(){var i,o,e=new this(0);for(oe=!1,i=0;i<arguments.length;)if(o=new this(arguments[i++]),o.d)e.d&&(e=e.plus(o.times(o)));else{if(o.s)return oe=!0,new this(1/0);e=o}return oe=!0,e.sqrt()}function Ma(i){return i instanceof x||i&&i.toStringTag===Mi||!1}function Cl(i){return new this(i).ln()}function _l(i,o){return new this(i).log(o)}function Al(i){return new this(i).log(2)}function El(i){return new this(i).log(10)}function bl(){return Pi(this,arguments,"lt")}function yl(){return Pi(this,arguments,"gt")}function Rl(i,o){return new this(i).mod(o)}function pl(i,o){return new this(i).mul(o)}function Nl(i,o){return new this(i).pow(o)}function Vl(i){var o,e,t,r,n=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Ie(i,1,Pt),t=Math.ceil(i/te),this.crypto)if(crypto.getRandomValues)for(o=crypto.getRandomValues(new Uint32Array(t));n<t;)r=o[n],r>=429e7?o[n]=crypto.getRandomValues(new Uint32Array(1))[0]:a[n++]=r%1e7;else if(crypto.randomBytes){for(o=crypto.randomBytes(t*=4);n<t;)r=o[n]+(o[n+1]<<8)+(o[n+2]<<16)+((o[n+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(o,n):(a.push(r%1e7),n+=4);n=t/4}else throw Error(Oi);else for(;n<t;)a[n++]=Math.random()*1e7|0;for(t=a[--n],i%=te,t&&i&&(r=Se(10,te-i),a[n]=(t/r|0)*r);a[n]===0;n--)a.pop();if(n<0)e=0,a=[0];else{for(e=-1;a[0]===0;e-=te)a.shift();for(t=1,r=a[0];r>=10;r/=10)t++;t<te&&(e-=te-t)}return s.e=e,s.d=a,s}function Ol(i){return ee(i=new this(i),i.e+1,this.rounding)}function Ml(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Sl(i){return new this(i).sin()}function Dl(i){return new this(i).sinh()}function wl(i){return new this(i).sqrt()}function Pl(i,o){return new this(i).sub(o)}function Ll(){var i=0,o=arguments,e=new this(o[i]);for(oe=!1;e.s&&++i<o.length;)e=e.plus(o[i]);return oe=!0,ee(e,this.precision,this.rounding)}function xl(i){return new this(i).tan()}function jl(i){return new this(i).tanh()}function Ul(i){return ee(i=new this(i),i.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var x=v.constructor=ji(fs);rn=new x(rn);nn=new x(nn);function vl(i,o){const e=i+o;return Number.isSafeInteger(e)?e:new x(i).add(o).toNumber()}function Tl(i,o){const e=i-o;return Number.isSafeInteger(e)?e:new x(i).sub(o).toNumber()}function fr(i,o){const e=i*o;return Number.isSafeInteger(e)?e:new x(i).mul(o).toNumber()}function Bl(i,o){const e=i/o;return Number.isSafeInteger(e)?e:new x(i).div(o).toNumber()}function Vt(i,o){const e=10**Math.trunc(o),t=Pn(i,e);return Math.round(fr(i,e)+t)/e}function ke(i,o){const e=10**Math.trunc(o),t=Pn(i,e);return Math.floor(fr(i,e)+t)/e}function Be(i,o){const e=10**Math.trunc(o),t=Pn(i,e);return Math.ceil(fr(i,e)-t)/e}function Pn(i,o){return Number.EPSILON*Math.max(1,Math.abs(fr(i,o)))}function Sa(i,o){return i-o*Math.floor(i/o)}function Il(i,o){return i**o}function Fl(i){return Math.sqrt(i)}function Da(i,o){return i===o}function kl(i,o){return i>o}function $l(i,o){return i>=o}function Yl(i,o){return i<o}function Hl(i,o){return i<=o}function ds(i,o=15){return Number.parseFloat(i.toPrecision(o))}function Gl(i,o,e=Number.EPSILON){return Math.abs(i-o)<e}function Ui(i,o=12,e=1e-10){const t=ds(i,o);return Gl(i,t,e)?t:ds(i)}function Wl(i){return i-Math.trunc(i)}const _n=class _n extends ht{static create(){return this._instance=this._instance||new _n(0),this._instance}isNull(){return!0}plus(o){return y.create(0).plus(o)}minus(o){return y.create(0).minus(o)}multiply(o){return y.create(0).multiply(o)}divided(o){return y.create(0).divided(o)}mod(o){return y.create(0).mod(o)}compare(o,e){return o.isString()?j.create("").compare(o,e):o.isBoolean()?k.create(!1).compare(o,e):y.create(0).compare(o,e)}concatenateFront(o){return o.isArray()?o.concatenateBack(j.create("")):j.create(this.concatenate(o.getValue(),Je.FRONT))}concatenateBack(o){return o.isArray()?o.concatenateFront(j.create("")):j.create(this.concatenate(o.getValue(),Je.BACK))}plusBy(o){return y.create(0).plusBy(o)}minusBy(o){return y.create(0).minusBy(o)}multiplyBy(o){return y.create(0).multiplyBy(o)}dividedBy(o){return y.create(0).dividedBy(o)}compareBy(o,e){return typeof o=="string"?j.create("").compareBy(o,e):typeof o=="boolean"?k.create(!1).compareBy(o,e):y.create(0).compareBy(o,e)}pow(o){return y.create(0).pow(o)}sqrt(){return y.create(0).sqrt()}cbrt(){return y.create(0).cbrt()}cos(){return y.create(0).cos()}cosh(){return y.create(0).cosh()}acos(){return y.create(0).acos()}acosh(){return y.create(0).acosh()}sin(){return y.create(0).sin()}sinh(){return y.create(0).sinh()}asin(){return y.create(0).asin()}asinh(){return y.create(0).asinh()}tan(){return y.create(0).tan()}tanh(){return y.create(0).tanh()}atan(){return y.create(0).atan()}atan2(o){return y.create(0).atan2(o)}atanh(){return y.create(0).atanh()}log(){return g.create(h.NUM)}log10(){return g.create(h.NUM)}exp(){return y.create(0).exp()}abs(){return y.create(0).abs()}round(o){return y.create(0).round(o)}floor(o){return y.create(0).floor(o)}ceil(o){return y.create(0).ceil(o)}convertToNumberObjectValue(){return y.create(0)}convertToBooleanObjectValue(){return k.create(!1)}};A(_n,"_instance");let ae=_n;const Tt=class Tt extends ht{constructor(e){super(e);A(this,"_value",!1);this._value=e}static create(e){return e?(this._instanceTrue=this._instanceTrue||new Tt(!0),this._instanceTrue):(this._instanceFalse=this._instanceFalse||new Tt(!1),this._instanceFalse)}getValue(){return this._value}isBoolean(){return!0}getNegative(){const e=this.getValue();let t=0;return e&&(t=1),y.create(-t)}getReciprocal(){return this.getValue()?y.create(1):g.create(h.DIV_BY_ZERO)}plus(e){return this._convertToNumber().plus(e)}minus(e){return this._convertToNumber().minus(e)}multiply(e){return this._convertToNumber().multiply(e)}divided(e){return this._convertToNumber().divided(e)}mod(e){return this._convertToNumber().mod(e)}compare(e,t){return e.isArray()?e.compare(this,Ds(t)):e.isNull()?this._convertToNumber().compare(e,t):this.compareBy(e.getValue(),t)}compareBy(e,t){let r=!1;if(typeof e=="string"||typeof e=="number")r=this._compareString(t);else if(typeof e=="boolean"){const n=y.create(e?1:0);return this._convertToNumber().compare(n,t)}return Tt.create(r)}_compareString(e){switch(e){case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!0;case $.EQUALS:case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:case $.NOT_EQUAL:return!1}}concatenateFront(e){return this._convertToNumber().concatenateFront(e)}concatenateBack(e){return this._convertToNumber().concatenateBack(e)}_convertToNumber(){const e=this.getValue();let t=0;return e&&(t=1),y.create(t)}pow(e){return this._convertToNumber().pow(e)}sqrt(){return this._convertToNumber().sqrt()}cbrt(){return this._convertToNumber().cbrt()}cos(){return this._convertToNumber().cos()}cosh(){return this._convertToNumber().cosh()}acos(){return this._convertToNumber().acos()}acosh(){return this._convertToNumber().acosh()}sin(){return this._convertToNumber().sin()}sinh(){return this._convertToNumber().sinh()}asin(){return this._convertToNumber().asin()}asinh(){return this._convertToNumber().asinh()}tan(){return this._convertToNumber().tan()}tanh(){return this._convertToNumber().tanh()}atan(){return this._convertToNumber().atan()}atan2(e){return this._convertToNumber().atan2(e)}atanh(){return this._convertToNumber().atanh()}log(){return this._convertToNumber().log()}log10(){return this._convertToNumber().log10()}exp(){return this._convertToNumber().exp()}abs(){return this._convertToNumber().abs()}round(e){return this._convertToNumber().round(e)}floor(e){return this._convertToNumber().floor(e)}ceil(e){return this._convertToNumber().ceil(e)}convertToNumberObjectValue(){return xn(this.getValue())}convertToBooleanObjectValue(){return this}};A(Tt,"_instanceTrue"),A(Tt,"_instanceFalse");let k=Tt;class y extends ht{constructor(e){super(e);A(this,"_value",0);this._value=Number(e)}static create(e,t=""){const r=new y(e);return t&&r.setPattern(t),r}getValue(){return this._value}setValue(e){this._value=e}isNumber(){return!0}getNegative(){return y.create(0).minus(this)}getReciprocal(){return y.create(1).divided(this)}plus(e){if(e.isArray())return e.plus(this);let t=this.plusBy(e.getValue());if(t.isError())return t;const r=vr(this.getPattern(),e.getPattern(),X.PLUS);return t=y.create(Number(t.getValue()),r),t}equalZero(){return this._value===0}minus(e){if(e.isArray()){const n=e.getNegative();return n.isError()?n:n.plus(this)}let t=this.minusBy(e.getValue());if(t.isError())return t;const r=vr(this.getPattern(),e.getPattern(),X.MINUS);return t=y.create(Number(t.getValue()),r),t}multiply(e){if(e.isArray())return e.multiply(this);let t=this.multiplyBy(e.getValue());if(t.isError())return t;const r=vr(this.getPattern(),e.getPattern(),X.MULTIPLY);return t=y.create(Number(t.getValue()),r),t}divided(e){if(e.isArray()){const n=e.getReciprocal();return n.isError()?n:n.multiply(this)}let t=this.dividedBy(e.getValue());if(t.isError())return t;const r=vr(this.getPattern(),e.getPattern(),X.DIVIDED);return t=y.create(Number(t.getValue()),r),t}mod(e){if(e.isArray())return e.modInverse(this);const t=this.getValue(),r=e.getValue();if(e.isNull())return g.create(h.DIV_BY_ZERO);if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(r===0)return g.create(h.DIV_BY_ZERO);if(!Number.isFinite(t)||!Number.isFinite(r)||Math.abs(r)*11259e8<=Math.abs(t))return g.create(h.NUM);const n=Sa(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}if(typeof r=="boolean"){const n=r?1:0;return n===0?g.create(h.DIV_BY_ZERO):y.create(Sa(t,n))}return this}concatenateFront(e){return e.isArray()?e.concatenateBack(this):j.create(this.concatenate(e.getValue(),Je.FRONT))}concatenateBack(e){return e.isArray()?e.concatenateFront(this):j.create(this.concatenate(e.getValue(),Je.BACK))}compare(e,t){return e.isArray()?e.compare(this,Ds(t)):this.compareBy(e.getValue(),t)}plusBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=vl(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}minusBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=Tl(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}multiplyBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=fr(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}dividedBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);if(r===0)return g.create(h.DIV_BY_ZERO);const n=Bl(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}compareBy(e,t){const r=this.getValue();let n=!1;return typeof e=="string"?n=this._compareString(t):typeof e=="number"?n=this._compareNumber(r,e,t):typeof e=="boolean"&&(n=this._compareBoolean(t)),k.create(n)}_compareString(e){switch(e){case $.EQUALS:case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!1;case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:case $.NOT_EQUAL:return!0}}_compareNumber(e,t,r){return!Number.isFinite(e)||!Number.isFinite(t)?this._compareInfinity(e,t,r):this._compareFiniteNumber(e,t,r)}_compareFiniteNumber(e,t,r){switch(r){case $.EQUALS:return Da(e,t);case $.GREATER_THAN:return kl(e,t);case $.GREATER_THAN_OR_EQUAL:return $l(e,t);case $.LESS_THAN:return Yl(e,t);case $.LESS_THAN_OR_EQUAL:return Hl(e,t);case $.NOT_EQUAL:return!Da(e,t)}}_compareBoolean(e){switch(e){case $.EQUALS:case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!1;case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:case $.NOT_EQUAL:return!0}}pow(e){if(e.isArray())return e.powInverse(this);if(this.isError())return this;const t=this.getValue();let r=e;if(e.isString()&&(r=e.convertToNumberObjectValue()),r.isError())return r;const n=+r.getValue();if(Number.isNaN(n))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(n))return g.create(h.NUM);if(t===0)return n<0?g.create(h.DIV_BY_ZERO):n===0?g.create(h.NUM):y.create(0);const s=Il(t,n);return Number.isFinite(s)?y.create(s):g.create(h.NUM)}sqrt(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Fl(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cbrt(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cbrt(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cos(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cos(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cosh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cosh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}acos(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.acos(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}acosh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.acosh(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}sin(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.sin(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}sinh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.sinh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}asin(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.asin(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}asinh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.asinh(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}tan(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.tan(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}tanh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.tanh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}atan(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.atan(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}atan2(e){if(e.isArray())return e.atan2Inverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);if(t===0&&r===0)return g.create(h.DIV_BY_ZERO);const n=Math.atan2(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Math.atan2(t,r?1:0)):this}atanh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.atanh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}log(){const e=this.getValue();if(typeof e=="number"&&e<=0||!Number.isFinite(e))return g.create(h.NUM);const t=Math.log(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}log10(){const e=this.getValue();if(typeof e=="number"&&e<=0||!Number.isFinite(e))return g.create(h.NUM);const t=Math.log10(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}exp(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.exp(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}abs(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.abs(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}round(e){if(e.isArray())return e.roundInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-Vt(Math.abs(t),r):Vt(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Vt(t,r?1:0)):this}floor(e){if(e.isArray())return e.floorInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-ke(Math.abs(t),r):ke(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(ke(t,r?1:0)):this}ceil(e){if(e.isArray())return e.ceilInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-Be(Math.abs(t),r):Be(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Be(t,r?1:0)):this}convertToNumberObjectValue(){return this}convertToBooleanObjectValue(){return Ln(!0)}_compareInfinity(e,t,r){let n=!1;switch(r){case $.EQUALS:n=e===t;break;case $.GREATER_THAN:n=e>t;break;case $.GREATER_THAN_OR_EQUAL:n=e>=t;break;case $.LESS_THAN:n=e<t;break;case $.LESS_THAN_OR_EQUAL:n=e<=t;break;case $.NOT_EQUAL:n=e!==t;break}return n}}const Ql=1e5,wa=new ft(Ql);class j extends ht{constructor(e){super(e);A(this,"_value");this._value=e}static create(e){const t=wa.get(e);if(t)return t;const r=new j(e);return wa.set(e,r),r}getValue(){return this._value}isString(){return!0}concatenateFront(e){return e.isArray()?e.concatenateBack(this):j.create(this.concatenate(e.getValue(),Je.FRONT))}concatenateBack(e){return e.isArray()?e.concatenateFront(this):j.create(this.concatenate(e.getValue(),Je.BACK))}plus(e){return this.convertToNumberObjectValue().plus(e)}minus(e){return this.convertToNumberObjectValue().minus(e)}multiply(e){return this.convertToNumberObjectValue().multiply(e)}divided(e){return this.convertToNumberObjectValue().divided(e)}compare(e,t,r){return e.isArray()?e.compare(this,Ds(t),r):this.compareBy(e.getValue(),t,r)}compareBy(e,t,r=!1){let n=this.getValue(),s=!1;if(typeof e=="string"){let a=e;if(r||(n=n.toLocaleLowerCase(),a=a.toLocaleLowerCase()),Fc(a))return this._checkWildcard(a,t);s=this._compareString(n,a,t)}else typeof e=="number"?s=this._compareNumber(t):typeof e=="boolean"&&(s=this._compareBoolean(t));return k.create(s)}_compareString(e,t,r){switch(r){case $.EQUALS:return e===t;case $.GREATER_THAN:return e>t;case $.GREATER_THAN_OR_EQUAL:return e>=t;case $.LESS_THAN:return e<t;case $.LESS_THAN_OR_EQUAL:return e<=t;case $.NOT_EQUAL:return e!==t}}_compareNumber(e){switch(e){case $.NOT_EQUAL:case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!0;case $.EQUALS:case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:return!1}}_compareBoolean(e){switch(e){case $.EQUALS:case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!1;case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:case $.NOT_EQUAL:return!0}}convertToNumberObjectValue(){return xn(this.getValue())}convertToBooleanObjectValue(){return k.create(!0)}_checkWildcard(e,t){const r=this.getValue().toLocaleLowerCase(),n=kc(r,e,t);return k.create(n)}}function Ln(i){if(typeof i=="boolean")return k.create(i);let o=!1;if(typeof i=="string"){const e=i.toLocaleUpperCase();e===Ot.TRUE?o=!0:e===Ot.FALSE&&(o=!1)}else i===1?o=!0:o=!1;return k.create(o)}function ql(i){let o=i.toString();return o.charAt(0)==='"'&&o.charAt(o.length-1)==='"'&&(o=o.slice(1,-1),o=o.replace(/""/g,'"')),j.create(o)}function xn(i,o=""){if(typeof i=="boolean"){let e=0;return i&&(e=1),y.create(e,o)}else{if(typeof i=="number")return Number.isFinite(i)?y.create(i,o):g.create(h.NUM);if(M.isRealNum(i))return y.create(Number(i),o)}return g.create(h.VALUE)}function Xl(i){return""}function vi(i=[]){const o=[];for(let e=0;e<i.length;e++){const t=i[e];o[e]==null&&(o[e]=[]);for(let r=0;r<t.length;r++){const n=t[r];o[e][r]=lt.create(n)}}return o}function Kl(i=[]){const o=[];for(let e=0;e<i.length;e++){const t=i[e];o[e]==null&&(o[e]=[]);for(let r=0;r<t.length;r++){const n=t[r];n==null?o[e][r]=null:n.isError()?o[e][r]=n.getErrorType():o[e][r]=n.getValue()}}return o}class K extends ht{constructor(e){super(typeof e=="string"?e:Xl());A(this,"_values",[]);A(this,"_rowCount",-1);A(this,"_columnCount",-1);A(this,"_unitId","");A(this,"_sheetId","");A(this,"_currentRow",-1);A(this,"_currentColumn",-1);A(this,"_sliceCache",new Map);A(this,"_flattenCache");A(this,"_defaultValue",null);A(this,"_flattenPosition");this._values=this._formatValue(e)}static create(e){return new K(e)}static createByArray(e){const r={calculateValueList:vi(e),rowCount:e.length,columnCount:e[0].length||0,unitId:"",sheetId:"",row:-1,column:-1};return new K(r)}dispose(){this._values=[],this._defaultValue=null,this._flattenPosition=null,this._clearCache()}clone(){return this.map(e=>e)}getRowCount(){return this._rowCount}setRowCount(e){this._rowCount=e}getColumnCount(){return this._columnCount}setColumnCount(e){this._columnCount=e}setCurrent(e,t){this._currentRow=e,this._currentColumn=t}setUnitId(e){this._unitId=e}getUnitId(){return this._unitId}setSheetId(e){this._sheetId=e}getSheetId(){return this._sheetId}getCurrentRow(){return this._currentRow}getCurrentColumn(){return this._currentColumn}getArrayValue(){return this._values}setArrayValue(e){this._clearCache(),this._values=e}isArray(){return!0}setDefaultValue(e){this._defaultValue=e}get(e,t){var r;return((r=this._values[e])==null?void 0:r[t])||this._defaultValue}getRealValue(e,t){const r=this._values[e];if(r==null)return null;const n=r[t];return n==null?null:n}getValueOrDefault(e,t){return this.get(e,t)||this._defaultValue}set(e,t,r){if(e>=this._rowCount||t>=this._columnCount)throw new Error("Exceeding array bounds.");this._clearCache(),this._values[e][t]=r}getRangePosition(){const t=this.getRowCount(),r=0,n=this.getColumnCount();return{startRow:0,endRow:t-1,startColumn:r,endColumn:n-1}}iterator(e){var u;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=this.getArrayValue();for(let c=t;c<=r;c++)for(let l=n;l<=s;l++)if(e(((u=a[c])==null?void 0:u[l])||this._defaultValue,c,l)===!1)return}iteratorReverse(e){var u;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=this.getArrayValue();for(let c=r;c>=t;c--)for(let l=s;l>=n;l--)if(e(((u=a[c])==null?void 0:u[l])||this._defaultValue,c,l)===!1)return}getLastTruePosition(){let e;return this.iteratorReverse((t,r,n)=>{if(t!=null&&t.isBoolean()&&t.getValue()===!0)return e={row:r,column:n},!1}),e}getFirstTruePosition(){let e;return this.iterator((t,r,n)=>{if(t!=null&&t.isBoolean()&&t.getValue()===!0)return e={row:r,column:n},!1}),e}getFirstCell(){const{startRow:e,startColumn:t}=this.getRangePosition();return this.get(e,t)||this._defaultValue||ae.create()}getLastCell(){const{endRow:e,endColumn:t}=this.getRangePosition();return this.get(e,t)||this._defaultValue||ae.create()}pick(e){const t=this.pickRaw(e);return this._createNewArray(t,1,t[0].length)}pickRaw(e){const t=e.getRowCount(),r=e.getColumnCount();if(t!==this._rowCount||r!==this._columnCount)return[[ae.create()]];const n=[];n[0]=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.get(s,a);if(!(u==null||u.isError())&&u.getValue()===!0){const c=this.get(s,a);n[0].push(c)}}return n}flatten(){if(this._flattenCache!=null)return this._flattenCache;const e=[];e[0]=[];for(let r=0;r<this._rowCount;r++)for(let n=0;n<this._columnCount;n++){const s=this.get(r,n);e[0].push(s)}const t=this._createNewArray(e,1,e[0].length);return t.setDefaultValue(this._defaultValue),this._flattenCache=t,t}flattenPosition(){if(this._flattenPosition!=null)return this._flattenPosition;const e=[],t=[],r=[],n=[];let s=0;for(let u=0;u<this._rowCount;u++)for(let c=0;c<this._columnCount;c++){const l=this.get(u,c);if(l==null||l.isError()||l.isNull()){s++;continue}l.isString()?(e.push(l),r.push(s++)):(t.push(l),n.push(s++))}const a={stringArray:e,numberArray:t,stringPosition:r,numberPosition:n};return this._flattenPosition=a,a}slice(e,t){let r=0,n=this._rowCount,s=1,a=0,u=this._columnCount,c=1;if(e!=null&&(r=e[0]||0,n=e[1]||this._rowCount,s=e[2]||1),t!=null&&(a=t[0]||0,u=t[1]||this._columnCount,c=t[2]||1),r>=this._rowCount||a>=this._columnCount)return;const l=`${r}_${n}_${s}_${a}_${u}_${c}`,f=this._sliceCache.get(l);if(f!=null)return f;const m=[],d=this._values;let C=0,_=0;for(let p=r;p<n;p+=s){_=0,m[C]==null&&(m[C]=[]);for(let V=a;V<u;V+=c){if(!d[p])return;let S=d[p][V]||this._defaultValue;S==null&&(S=ae.create()),m[C][_]=S,_++}C++}if(m.length===0||m[0].length===0)return;const E=s>1?-1:r+this._currentRow,b=c>1?-1:a+this._currentColumn,R=this._createNewArray(m,m.length,m[0].length,E,b);return R.setDefaultValue(this._defaultValue),this._sliceCache.set(l,R),R}sortByRow(e){const t=this._transposeArray(this._values);t.sort(this._sort(e)),this._clearCache(),this._values=this._transposeArray(t)}sortByColumn(e){this._clearCache(),this._values.sort(this._sort(e))}transpose(){const e=this._transposeArray(this._values),t=this._rowCount,r=this._columnCount,n=this._createNewArray(e,r,t);return n.setDefaultValue(this._defaultValue),n}orderSearch(e,t=Oe.MIN,r=!1,n=!1){let s,a,u,c;const l=(f,m,d)=>{if(f==null)return!0;let C;if(n===!0?C=f.compare(e,$.EQUALS):C=f.isEqual(e),(C==null?void 0:C.getValue())===!0)return s=f,u={row:m,column:d},!1;t===Oe.MAX?f.isGreaterThan(e).getValue()===!0&&(a==null||f.minus(e).abs().isLessThanOrEqual(a.minus(e).abs()).getValue()===!0)&&(a=f,c={row:m,column:d}):t===Oe.MIN&&f.isLessThan(e).getValue()===!0&&(a==null||f.minus(e).abs().isLessThanOrEqual(a.minus(e).abs()).getValue()===!0)&&(a=f,c={row:m,column:d})};if(r?this.iteratorReverse((f,m,d)=>l(f,m,d)):this.iterator((f,m,d)=>l(f,m,d)),s!=null)return u;if(a!=null)return c}binarySearch(e,t=Ut.MIN,r=Oe.MIN){if(e.isError())return;const{stringArray:n,stringPosition:s,numberArray:a,numberPosition:u}=this.flattenPosition();return e.isString()?this._binarySearch(e,n,s,t,r):this._binarySearch(e,a,u,t,r)}_binarySearch(e,t,r,n=Ut.MIN,s=Oe.MIN){const a=tn(),u=Number(e.getValue()),c=!Number.isNaN(u);let l=0,f=t.length-1,m=-1,d=-1,C=-1;for(;l<=f;){const _=Math.floor((l+f)/2),E=t[_];let b;if(E.isNull())b=n===Ut.MIN?1:-1;else{const R=E.getValue();if(c){const p=Number(R);b=Number.isNaN(p)?1:Math.sign(p-u)}else b=a(R.toString().toLocaleLowerCase(),e.getValue().toString().toLocaleLowerCase())}if(n===Ut.MAX&&(b=-b),b===0){m=_;break}b<0?(d=_,l=_+1):(C=_,f=_-1)}if(s===Oe.NORMAL)return m!==-1?r[m]:void 0;if(s===Oe.MIN)return m!==-1?r[m]:n===Ut.MIN?r[d]:r[C];if(s===Oe.MAX)return m!==-1?r[m]:n===Ut.MIN?r[C]:r[d]}sum(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isString()||t.isBoolean()||t.isNull())return!0;if(t.isError())return e=t,!1;e=e.plus(t)}),e}max(){let e=y.create(Number.NEGATIVE_INFINITY);return this.iterator(t=>{if(t==null)return!0;if(t.isError())return e=t,!1;if(t.isString()||t.isNull()||t.isBoolean())return!0;e.isLessThan(t).getValue()&&(e=t)}),e}min(){let e=y.create(Number.POSITIVE_INFINITY);return this.iterator(t=>{if(t==null)return!0;if(t.isError())return e=t,!1;if(t.isString()||t.isNull()||t.isBoolean())return!0;e.isGreaterThan(t).getValue()&&(e=t)}),e}count(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isError()||t.isString()||t.isNull()||t.isBoolean())return!0;e=e.plusBy(1)}),e}countA(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isNull())return!0;e=e.plusBy(1)}),e}countBlank(){let e=y.create(0);return this.iterator(t=>{(t==null||t.isNull()||t.getValue()==="")&&(e=e.plusBy(1))}),e}getNegative(){return K.create("{0}").minus(this)}getReciprocal(){return K.create("{1}").divided(this)}plus(e){return this._batchOperator(e,1)}minus(e){return this._batchOperator(e,0)}multiply(e){return this._batchOperator(e,2)}divided(e){return this._batchOperator(e,3)}mod(e){return this._batchOperator(e,4)}modInverse(e){return this.map(t=>t.isError()?t:e.mod(t))}compare(e,t,r){return this._batchOperator(e,5,t,r)}concatenateFront(e){return this._batchOperator(e,6)}concatenateBack(e){return this._batchOperator(e,7)}map(e){const t=(r,n,s)=>r==null?ae.create():r.isError()?r:e(r,n,s);return this.mapValue(t)}mapValue(e){var s;const t=this._rowCount,r=this._columnCount,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){const l=(s=this._values)==null?void 0:s[a];if(l==null)u[c]=g.create(h.VALUE);else{const f=l[c]||this._defaultValue;f?u[c]=e(f,a,c):u[c]=ae.create()}}n.push(u)}return this._createNewArray(n,t,r)}pow(e){return this._batchOperator(e,8)}powInverse(e){return this.map(t=>t.isError()?t:e.pow(t))}sqrt(){return this.map(e=>e.isError()?e:e.sqrt())}cbrt(){return this.map(e=>e.isError()?e:e.cbrt())}cos(){return this.map(e=>e.isError()?e:e.cos())}cosh(){return this.map(e=>e.isError()?e:e.cosh())}acos(){return this.map(e=>e.isError()?e:e.acos())}acosh(){return this.map(e=>e.isError()?e:e.acosh())}sin(){return this.map(e=>e.isError()?e:e.sin())}sinh(){return this.map(e=>e.isError()?e:e.sinh())}asin(){return this.map(e=>e.isError()?e:e.asin())}asinh(){return this.map(e=>e.isError()?e:e.asinh())}tan(){return this.map(e=>e.isError()?e:e.tan())}tanh(){return this.map(e=>e.isError()?e:e.tanh())}atan(){return this.map(e=>e.isError()?e:e.atan())}atanh(){return this.map(e=>e.isError()?e:e.atanh())}atan2(e){return this._batchOperator(e,12)}atan2Inverse(e){return this.map(t=>t.isError()?t:e.atan2(t))}mean(e=0){const t=this.sum(),r=this.count();return t.divided(e===0?r:r.minusBy(1))}median(){const e=this.flattenPosition().numberArray,t=this._createNewArray([e],1,e.length),r=t.getColumnCount();if(r<=1)return t.get(0,0)||ae.create();if(t.sortByRow(0),r%2===0){const n=t.get(0,r/2)||ae.create(),s=t.get(0,r/2-1)||ae.create();return n.plus(s).divided(y.create(2))}return t.get(0,(r-1)/2)||ae.create()}var(e=0){const t=this.mean(),r=[[]];this.iterator(l=>{if(l==null||l.isError()||l.isString()||l.isBoolean()||l.isNull())return;const f=l.minus(t).pow(y.create(2));f.isError()||r[0].push(f)});const{_unitId:n,_sheetId:s,_currentRow:a,_currentColumn:u}=this;return K.create({calculateValueList:r,rowCount:1,columnCount:r[0].length,unitId:n,sheetId:s,row:a,column:u}).mean(e)}std(e=0){const t=this.var(e);return t.isError()?t:t.sqrt()}log(){return this.map(e=>e.isError()?e:e.log())}log10(){return this.map(e=>e.isError()?e:e.log10())}exp(){return this.map(e=>e.isError()?e:e.exp())}abs(){return this.map(e=>e.isError()?e:e.abs())}round(e){return this._batchOperator(e,9)}roundInverse(e){return this.map(t=>t.isError()?t:e.round(t))}floor(e){return this._batchOperator(e,10)}floorInverse(e){return this.map(t=>t.isError()?t:e.floor(t))}ceil(e){return this._batchOperator(e,11)}ceilInverse(e){return this.map(t=>t.isError()?t:e.ceil(t))}toValue(){return Kl(this._values)}_clearCache(){this._flattenCache=null,this._sliceCache.clear()}_sort(e){const t=tn();return(r,n)=>{const s=r[e],a=n[e];return s==null?1:a==null?-1:s.isError()&&s.isError()?0:s.isError()?1:a.isError()?-1:t(s.getValue(),a.getValue())}}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}_batchOperator(e,t,r,n){const s=[];let a=this._rowCount,u=this._columnCount;if(e.isArray()){const f=e.getRowCount(),m=e.getColumnCount();if(a=Math.max(f,a),u=Math.max(m,u),f===1&&m===1){const d=e.getFirstCell();for(let C=0;C<u;C++)s.push(d)}else if(f===1&&this._columnCount>1){const d=e.getArrayValue();for(let C=0;C<u;C++)s.push(d[0][C])}else return this._batchOperatorArray(e,t,r,n)}else for(let f=0;f<u;f++)s.push(e);const c=[];for(let f=0;f<u;f++){const m=s[f];this._batchOperatorValue(m,f,c,t,r,n)}const l=this._createNewArray(c,a,u);return l.setDefaultValue(k.create(!1)),l}_batchOperatorValue(e,t,r,n,s,a){const u=this._rowCount,c=this.getUnitId(),l=this.getSheetId(),f=this.getCurrentRow(),m=this.getCurrentColumn();if(n===5){const{rowsInCache:d,rowsNotInCache:C}=Et.canUseCache(c,l,t+m,f,f+u-1);if(d.length>0){if(s===$.EQUALS){const _=Et.getCellPositions(c,l,t+m,e.getValue(),d);_!=null&&_.forEach(E=>{if(E<f||E>f+u-1)return;const b=E-f;r[b]==null&&(r[b]=[]),r[b][t]=k.create(!0)})}else{const _=Et.getCellValuePositions(c,l,t+m);_!=null&&_.forEach((E,b)=>{let R=ae.create();qt.has(b)?R=g.create(b):typeof b=="string"?R=j.create(b):typeof b=="number"?R=y.create(b):typeof b=="boolean"&&(R=k.create(b));let p;R.isError()?p=R:e.isError()?p=e:p=R.compare(e,s,a),(p.isError()||p.getValue()===!0)&&E.forEach(V=>{V>=f&&V<=f+u-1&&(r[V-f]==null&&(r[V-f]=[]),r[V-f][t]=p)})})}if(C.length>0)for(const _ of C){const[E,b]=_;for(let R=E;R<=b;R++)this.__batchOperatorRowValue(e,t,r,n,R-f,c,l,f,m,s,a);Et.setContinueBuildingCache(c,l,t+m,E,b)}return}}for(let d=0;d<u;d++)this.__batchOperatorRowValue(e,t,r,n,d,c,l,f,m,s,a);Et.setContinueBuildingCache(c,l,t+m,f,f+u-1)}__batchOperatorRowValue(e,t,r,n,s,a,u,c,l,f,m){const d=this.getValueOrDefault(s,t);if(r[s]==null&&(r[s]=[]),d&&e)if(d.isError())r[s][t]=d;else if(e.isError())r[s][t]=e;else switch(n){case 1:r[s][t]=d.plus(e);break;case 0:r[s][t]=d.minus(e);break;case 2:r[s][t]=d.multiply(e);break;case 3:r[s][t]=d.divided(e);break;case 4:r[s][t]=d.mod(e);break;case 5:f?r[s][t]=d.compare(e,f,m):r[s][t]=g.create(h.VALUE);break;case 6:r[s][t]=d.concatenateFront(e);break;case 7:r[s][t]=d.concatenateBack(e);break;case 8:r[s][t]=d.pow(e);break;case 9:r[s][t]=d.round(e);break;case 10:r[s][t]=d.floor(e);break;case 12:r[s][t]=d.atan2(e);break;case 11:r[s][t]=d.ceil(e);break}else r[s][t]=g.create(h.NA);d!=null&&(d.isError()?Et.set(a,u,t+l,d.getErrorType(),s+c):Et.set(a,u,t+l,d.getValue(),s+c))}_batchOperatorArray(e,t,r,n){let s=e.getRowCount(),a=e.getColumnCount();s<this._rowCount&&(s=this._rowCount),a<this._columnCount&&(a=this._columnCount);const u=[],c=this._checkArrayCalculateType(this),l=this._checkArrayCalculateType(e);for(let f=0;f<s;f++){const m=[];for(let d=0;d<a;d++){let C;c===3?C=this.getValueOrDefault(0,0):c===1?C=this.getValueOrDefault(0,d):c===2?C=this.getValueOrDefault(f,0):C=this.getValueOrDefault(f,d);let _;if(l===3?_=e.getValueOrDefault(0,0):l===1?_=e.getValueOrDefault(0,d):l===2?_=e.getValueOrDefault(f,0):_=e.getValueOrDefault(f,d),C&&_)if(C.isError())m[d]=C;else if(_.isError())m[d]=_;else switch(t){case 1:m[d]=C.plus(_);break;case 0:m[d]=C.minus(_);break;case 2:m[d]=C.multiply(_);break;case 3:m[d]=C.divided(_);break;case 4:m[d]=C.mod(_);break;case 5:r?m[d]=C.compare(_,r,n):m[d]=g.create(h.VALUE);break;case 6:m[d]=C.concatenateFront(_);break;case 7:m[d]=C.concatenateBack(_);break;case 8:m[d]=C.pow(_);break;case 9:m[d]=C.round(_);break;case 12:m[d]=C.atan2(_);break;case 10:m[d]=C.floor(_);break;case 11:m[d]=C.ceil(_);break}else m[d]=g.create(h.NA)}u.push(m)}return this._createNewArray(u,s,a)}_checkArrayCalculateType(e){return e.getRowCount()===1&&e.getColumnCount()===1?3:e.getRowCount()===1?1:e.getColumnCount()===1?2:0}_formatValue(e){if(typeof e!="string")return e=e,this._rowCount=e.rowCount,this._columnCount=e.columnCount,this._unitId=e.unitId,this._sheetId=e.sheetId,this._currentRow=e.row,this._currentColumn=e.column,e.calculateValueList;e=e.slice(1,-1);const t=e.split(";"),r=t.length,n=[];let s=0;for(let a=0;a<r;a++){const c=t[a].split(","),l=c.length;s<l&&(s=l);const f=[];for(let m=0;m<l;m++){const d=c[m].trim();f.push(lt.create(d))}n.push(f)}return this._rowCount=r,this._columnCount=s,n}_createNewArray(e,t,r,n=-1,s=-1){(this._currentColumn===-1||this._currentRow===-1)&&(n=-1,s=-1);const a={calculateValueList:e,rowCount:t,columnCount:r,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:n,column:s};return K.create(a)}}class lt{static create(o){if(o==null)return ae.create();if(typeof o=="boolean")return k.create(o);if(typeof o=="string"){const e=o.toLocaleUpperCase().trim();if(qt.has(e))return g.create(e);if(e===Ot.TRUE||e===Ot.FALSE)return Ln(o);if(M.isRealNum(o))return y.create(Number(o));const{isNumberPattern:t,value:r,pattern:n}=vc(o);if(t)return y.create(r,n);const s=o.replace(/\n/g,"").replace(/\r/g,"");return!Zl(s)&&Ku(s)?K.create(s):ql(o)}return typeof o=="number"?xn(o):g.create(h.VALUE)}}function Zl(i){const o=i.trim();return o.startsWith('"')&&o.endsWith('"')}const zl=1e4,Cs=new ft(zl);class Mr extends Mn{constructor(e){super();A(this,"_forcedSheetId","");A(this,"_forcedSheetName","");A(this,"_defaultSheetId","");A(this,"_rangeData",{startColumn:-1,startRow:-1,endRow:-1,endColumn:-1});A(this,"_unitData",{});A(this,"_unitStylesData",{});A(this,"_defaultUnitId","");A(this,"_forcedUnitId","");A(this,"_runtimeData",{});A(this,"_arrayFormulaCellData",{});A(this,"_runtimeArrayFormulaCellData",{});A(this,"_runtimeFeatureCellData",{});A(this,"_refOffsetX",0);A(this,"_refOffsetY",0);this._token=e}dispose(){this._unitData={},this._unitStylesData={},this._runtimeData={}}getToken(){return this._token}setToken(e){this._token=e}isExceedRange(){const{startRow:e,endRow:t,startColumn:r,endColumn:n}=this.getRangePosition();return e<0||r<0||t>=this.getActiveSheetRowCount()||n>=this.getActiveSheetColumnCount()}setRefOffset(e=0,t=0){this._refOffsetX=e,this._refOffsetY=t}getRefOffset(){return{x:this._refOffsetX,y:this._refOffsetY}}getRangePosition(){let{startRow:e,startColumn:t,endRow:r,endColumn:n}=M.moveRangeByOffset(this._rangeData,this._refOffsetX,this._refOffsetY);return Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Number.isNaN(r)&&(r=this.getActiveSheetRowCount()-1),Number.isNaN(n)&&(n=this.getActiveSheetColumnCount()-1),{...this._rangeData,startRow:e,endRow:r,startColumn:t,endColumn:n}}isReferenceObject(){return!0}iterator(e){const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition();if(this._checkIfWorksheetMiss())return e(g.create(h.VALUE),t,n);const a=this._forcedUnitId||this._defaultUnitId,u=this._forcedSheetId||this._defaultSheetId;for(let c=t;c<=r;c++)for(let l=n;l<=s;l++){if(c<0||l<0)return e(g.create(h.REF),c,l);const f=this.getCellData(c,l);let m=!1;if(M.isNullCell(f)){m=e(null,c,l);continue}let d=this.getCellValueObject(f);if(c===t&&l===n){const C=this.getCellPattern(a,u,c,l);if(C&&d.isNumber()){const _=Number(d.getValue());d=y.create(_,C)}}if(m=e(d,c,l),m===!1)return}}getFirstCell(){const{startRow:e,startColumn:t}=this.getRangePosition(),r=this.getCellData(e,t);if(!r)return y.create(0);let n=this.getCellValueObject(r);const s=this._forcedUnitId||this._defaultUnitId,a=this._forcedSheetId||this._defaultSheetId,u=this.getCellPattern(s,a,e,t);if(u&&n.isNumber()){const c=Number(n.getValue());n=y.create(c,u)}return n}getRangeData(){return this._rangeData}setRangeData(e){this._rangeData=e}getUnitId(){return this._forcedUnitId&&this._forcedUnitId.length>0?this._forcedUnitId:this._defaultUnitId}getSheetId(){return this._forcedSheetId&&this._forcedSheetId.length>0?this._forcedSheetId:this._defaultSheetId}setForcedUnitIdDirect(e){e.length>0&&(this._forcedUnitId=e)}getForcedUnitId(){return this._forcedUnitId}setForcedSheetId(e){var t;this._forcedSheetId=(t=e[this.getUnitId()])==null?void 0:t[this._forcedSheetName]}setForcedSheetIdDirect(e){this._forcedSheetId=e}getForcedSheetId(){return this._forcedSheetId}setForcedSheetName(e){e.length>0&&(this._forcedSheetName=e)}getForcedSheetName(){return this._forcedSheetName}setDefaultSheetId(e){this._defaultSheetId=e}getDefaultSheetId(){return this._defaultSheetId}setDefaultUnitId(e){this._defaultUnitId=e}getDefaultUnitId(){return this._defaultUnitId}getUnitData(){return this._unitData}setUnitData(e){this._unitData=e}getUnitStylesData(){return this._unitStylesData}setUnitStylesData(e){this._unitStylesData=e}getRuntimeData(){return this._runtimeData}setRuntimeData(e){this._runtimeData=e}getArrayFormulaCellData(){return this._arrayFormulaCellData}setArrayFormulaCellData(e){this._arrayFormulaCellData=e}getRuntimeArrayFormulaCellData(){return this._runtimeArrayFormulaCellData}setRuntimeArrayFormulaCellData(e){this._runtimeArrayFormulaCellData=e}getRuntimeFeatureCellData(){return this._runtimeFeatureCellData}setRuntimeFeatureCellData(e){this._runtimeFeatureCellData=e}getActiveSheetRowCount(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.rowCount)||0}getActiveSheetColumnCount(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.columnCount)||0}getRowCount(){return this._rangeData.endRow-this._rangeData.startRow+1}getColumnCount(){return this._rangeData.endColumn-this._rangeData.startColumn+1}getRowData(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.rowData)||{}}getColumnData(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.columnData)||{}}isCell(){return!1}isColumn(){return!1}isRow(){return!1}isRange(){return!1}isTable(){return!1}unionBy(e){return g.create(h.REF)}unionRange(e,t){return{startRow:-1,startColumn:-1,endRow:-1,endColumn:-1}}getCellValueObject(e){const t=Ic(e);if(qt.has(t))return g.create(t);if(e.t===M.CellValueType.NUMBER){const r=this._getPatternByCell(e);return xn(t,r)}return e.t===M.CellValueType.STRING||e.t===M.CellValueType.FORCE_STRING?j.create(t.toString()):e.t===M.CellValueType.BOOLEAN?Ln(t):lt.create(t)}_getPatternByCell(e){var n;const t=this._unitStylesData[this.getUnitId()];if(!t)return"";const r=t.getStyleByCell(e);return((n=r==null?void 0:r.n)==null?void 0:n.pattern)||""}getCellByRow(e){return this.getCellByPosition(e)}getCellByColumn(e){return this.getCellByPosition(void 0,e)}getCurrentActiveSheetData(){var e;return(e=this._unitData[this.getUnitId()])==null?void 0:e[this.getSheetId()]}getCurrentStylesData(){return this._unitStylesData[this.getUnitId()]}getCurrentRuntimeSheetData(){var e,t;return(t=(e=this._runtimeData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCurrentActiveArrayFormulaCellData(){var e,t;return(t=(e=this._arrayFormulaCellData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCurrentRuntimeActiveArrayFormulaCellData(){var e,t;return(t=(e=this._runtimeArrayFormulaCellData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCellData(e,t){const r=this.getCurrentActiveSheetData(),n=this.getCurrentRuntimeSheetData(),s=this.getCurrentActiveArrayFormulaCellData(),a=this.getCurrentRuntimeActiveArrayFormulaCellData();return(n==null?void 0:n.getValue(e,t))||(a==null?void 0:a.getValue(e,t))||this.getRuntimeFeatureCellValue(e,t)||(s==null?void 0:s.getValue(e,t))||(r==null?void 0:r.cellData.getValue(e,t))}getRuntimeFeatureCellValue(e,t){return pi(e,t,this.getSheetId(),this.getUnitId(),this._runtimeFeatureCellData)}getCellByPosition(e,t){let r=e,n=t;r||(r=this._rangeData.startRow),n||(n=this._rangeData.startColumn);const s=this.getCellData(r,n);return s?this.getCellValueObject(s):g.create(h.VALUE)}getCellPattern(e,t,r,n){var c,l,f,m;const s=this._unitStylesData[e];if(!s)return"";const a=(f=(l=(c=this._unitData[e])==null?void 0:c[t])==null?void 0:l.cellData)==null?void 0:f.getValue(r,n);if(!a)return"";const u=s.getStyleByCell(a);return((m=u==null?void 0:u.n)==null?void 0:m.pattern)||""}toArrayValueObject(e=!0){var C;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=`${this.getUnitId()}_${this.getSheetId()}_${t}_${r}_${n}_${s}`,u=Cs.get(a);if(u&&e)return u;const c=r-t+1,l=s-n+1;if(c<0||l<0)return this._getBlankArrayValueObject();const f=new Array(c);this.iterator((_,E,b)=>{const R=E-t,p=b-n;f[R]||(f[R]=new Array(l)),_==null&&(_=ae.create()),f[R][p]=_});const m={calculateValueList:f,rowCount:f.length,columnCount:((C=f[0])==null?void 0:C.length)||0,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:t,column:n},d=K.create(m);return e&&Cs.set(a,d),d}toUnitRange(){return{range:this.getRangePosition(),sheetId:this.getSheetId(),unitId:this.getUnitId()}}_checkIfWorksheetMiss(){return(this._forcedSheetId==null||this._forcedSheetId.length===0)&&this._forcedSheetName.length>0}_getBlankArrayValueObject(){const e={calculateValueList:[],rowCount:0,columnCount:0,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:0,column:0};return K.create(e)}}class Ti extends Mn{constructor(o){super(),this._promise=o}isAsyncObject(){return!0}async getValue(){return this._promise}}class Bi extends Mn{constructor(o){super(),this._promiseList=o}isAsyncArrayObject(){return!0}async getValue(){var t;const o=[];for(let r=0;r<this._promiseList.length;r++){const n=this._promiseList[r];o[r]==null&&(o[r]=[]);for(let s=0;s<n.length;s++){const a=n[s];a.isAsyncObject()?o[r][s]=await a.getValue():o[r][s]=a}}const e={calculateValueList:o,rowCount:o.length,columnCount:((t=o[0])==null?void 0:t.length)||0,unitId:"",sheetId:"",row:0,column:0};return K.create(e)}}class Rr extends Mr{constructor(o,e,t){super(""),this.setRangeData(o),e&&this.setForcedSheetIdDirect(e),t&&this.setForcedUnitIdDirect(t)}isRange(){return!0}}class Ps extends Mr{constructor(o){super(o);const e=Yt(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName),this.setRangeData(e.range)}isCell(){return!0}unionBy(o){if(!o.isCell())return g.create(h.REF);const e=o,t=this.unionRange(this.getRangeData(),e.getRangeData());return this._createRange(t)}unionRange(o,e){const t=o.startRow,r=o.startColumn,n=e.startRow,s=e.startColumn,a={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1};return t>n?(a.startRow=n,a.endRow=t):(a.startRow=t,a.endRow=n),r>s?(a.startColumn=s,a.endColumn=r):(a.startColumn=r,a.endColumn=s),o.startAbsoluteRefType&&(a.startAbsoluteRefType=o.startAbsoluteRefType),e.startAbsoluteRefType&&(a.endAbsoluteRefType=e.startAbsoluteRefType),a}_createRange(o){const e=new Rr(o,this.getForcedSheetId(),this.getForcedUnitId());e.setUnitData(this.getUnitData()),e.setDefaultSheetId(this.getDefaultSheetId()),e.setDefaultUnitId(this.getDefaultUnitId()),e.setRuntimeData(this.getRuntimeData()),e.setUnitStylesData(this.getUnitStylesData()),e.setArrayFormulaCellData(this.getArrayFormulaCellData()),e.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData()),e.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());const{x:t,y:r}=this.getRefOffset();e.setRefOffset(t,r);const n=this.getForcedSheetId();e.setForcedSheetName(this.getForcedSheetName()),n!=null&&e.setForcedSheetIdDirect(n);const s=this.getForcedUnitId();return s&&e.setForcedUnitIdDirect(s),e}}class Ls extends Mr{constructor(o){super(o);const e=Yt(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName);const t={...e.range,startColumn:e.range.startColumn,startRow:Number.NaN,endColumn:e.range.endColumn,endRow:Number.NaN,rangeType:M.RANGE_TYPE.COLUMN};this.setRangeData(t)}isColumn(){return!0}unionBy(o){if(!o.isColumn())return g.create(h.REF);const e=o;if(e.getForcedSheetName()!==void 0&&e.getForcedSheetName()!=="")return g.create(h.REF);const t=this.getRangeData(),r=e.getRangeData(),n=r.startColumn;if(n>=t.startColumn&&n<=t.endColumn)return this;const s=t.startColumn;return n>s?t.endColumn=n:(t.startColumn=n,t.endColumn=s),r.startAbsoluteRefType&&(t.endAbsoluteRefType=r.startAbsoluteRefType),t.rangeType=M.RANGE_TYPE.COLUMN,this.setToken(`${this.getToken()}${Q.COLON}${e.getToken()}`),this}}class xs extends Mr{constructor(o){super(o);const e=Yt(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName);const t={...e.range,startColumn:Number.NaN,startRow:e.range.startRow,endColumn:Number.NaN,endRow:e.range.endRow,rangeType:M.RANGE_TYPE.ROW};this.setRangeData(t)}isRow(){return!0}unionBy(o){if(!o.isRow())return g.create(h.REF);const e=o;if(e.getForcedSheetName()!==void 0&&e.getForcedSheetName()!=="")return g.create(h.REF);const t=this.getRangeData(),r=e.getRangeData(),n=r.startRow;if(n>=t.startRow&&n<=t.endRow)return this;const s=t.startRow;return n>s?t.endRow=n:(t.startRow=n,t.endRow=s),r.startAbsoluteRefType&&(t.endAbsoluteRefType=r.startAbsoluteRefType),t.rangeType=M.RANGE_TYPE.ROW,this.setToken(`${this.getToken()}${Q.COLON}${e.getToken()}`),this}}function O(i,o,e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=[];for(let a=0;a<i;a++){const u=[];for(let c=0;c<o;c++){if(r===1&&n===1){const f=e.isArray()?e.get(0,0):e;u.push(f);continue}if(r===1&&c<n){const f=e.get(0,c);u.push(f);continue}if(n===1&&a<r){const f=e.get(a,0);u.push(f);continue}if(a>=r||c>=n){u.push(t!=null?t:ae.create());continue}const l=e.get(a,c);u.push(l)}s.push(u)}return Ht(s,i,o)}function Ht(i,o,e,t="",r=""){const n={calculateValueList:i,rowCount:o,columnCount:e,unitId:t,sheetId:r,row:-1,column:-1};return K.create(n)}function mr(i){const o=[$.EQUALS,$.NOT_EQUAL,$.GREATER_THAN_OR_EQUAL,$.GREATER_THAN,$.LESS_THAN_OR_EQUAL,$.LESS_THAN];for(const e of o)if(i.startsWith(e)){const t=i.substring(e.length);return[e,lt.create(t)]}return[$.EQUALS,lt.create(i)]}function jn(i,o,e,t){if(!e)if(o.isString()){const r=`${o.getValue()}`,[n,s]=mr(r);e=n,o=s}else e=$.EQUALS;return i.compare(o,e,t)}function Jl(i,o){const e=Math.max(i.isArray()?i.getRowCount():1,o.isArray()?o.getRowCount():1),t=Math.max(i.isArray()?i.getColumnCount():1,o.isArray()?o.getColumnCount():1),r=O(e,t,i),n=O(e,t,o);return r.mapValue((s,a,u)=>{const c=n.get(a,u);return s!=null&&s.isError()?s:c!=null&&c.isError()?c:s!=null&&s.isBoolean()&&(c!=null&&c.isBoolean())?Ln(s.getValue()&&c.getValue()):k.create(!1)})}function ef(i){const o=i.getValue();let e=0;return o&&(e=1),y.create(e)}function Pa(i){return i.isArray()&&i.getRowCount()===1&&i.getColumnCount()===1?!0:i.isReferenceObject()?!!(i.isCell()||i.getRowCount()===1&&i.getColumnCount()===1):(i=i,!!(i.isString()||i.isNumber()||i.isBoolean()||i.isError()||i.isNull()))}function xt(i){const o=i==null?void 0:i.getPattern();let e={};if(o&&(e={s:{n:{pattern:o}}}),i==null)return{v:null,...e};if(i.isError())return{v:i.getErrorType(),t:M.CellValueType.STRING,...e};if(i.isValueObject()){const t=i,r=t.getValue();return t.isNumber()?{v:r,t:M.CellValueType.NUMBER,...e}:t.isBoolean()?{v:r?1:0,t:M.CellValueType.BOOLEAN,...e}:t.isString()?{v:r,t:M.CellValueType.STRING,...e}:t.isNull()?{v:null,...e}:{v:r,t:M.CellValueType.STRING,...e}}}function hr(i){let o=0,e=0;return i.forEach((t,r)=>{if(r%2===1)if(t.isArray()){const n=t;o=Math.max(o,n.getRowCount()),e=Math.max(e,n.getColumnCount())}else o=Math.max(o,1),e=Math.max(e,1)}),{maxRowLength:o,maxColumnLength:e}}function Sr(i,o,e,t){const r=o.getRowCount(),n=o.getColumnCount();for(let s=0;s<i.length;s++){if(s%2===1)continue;const a=i[s],u=a.getRowCount(),c=a.getColumnCount();if(u!==r||c!==n)return O(e,t,g.create(h.VALUE))}return null}function Dr(i,o,e,t=!1){const r=[];for(let n=0;n<i.length;n++){if(n%2===1)continue;const s=i[n],a=i[n+1];O(o,e,a,g.create(h.NA)).iterator((c,l,f)=>{if(!c)return;let m=jn(s,c);const[,d]=mr(`${c.getValue()}`);if(t&&(m=Un(m,s,d)),r[l]===void 0&&(r[l]=[]),r[l][f]===void 0){r[l][f]=m;return}r[l][f]=Jl(r[l][f],m)})}return r}function Un(i,o,e){return i.mapValue((t,r,n)=>{const s=o.get(r,n);return s&&tf(s,e)?t:s!=null&&s.isError()&&e.isError()&&s.getValue()===e.getValue()?k.create(!0):k.create(!1)})}function tf(i,o){if(i.isNumber()&&o.isNumber()||i.isBoolean()&&o.isBoolean())return!0;const e=i.isString()&&i.getValue()==="",t=o.isString()&&o.getValue()==="";return!!((e||i.isNull())&&(t||o.isNull())||i.isString()&&!e&&o.isString()&&!t)}var Gr=(i=>(i[i.CELL=0]="CELL",i[i.COLUMN=1]="COLUMN",i[i.ROW=2]="ROW",i))(Gr||{});const Bt=new Map;function rf(i,o){const e=Bt.get(i);if(e)return e;let t;switch(o){case 0:t=new Ps(i);break;case 1:t=new Ls(i);break;case 2:t=new xs(i);break;default:throw new Error("Unknown reference object type")}return Bt.set(i,t),t}function nf(i,o){const e=`${i.getToken()}:${o.getToken()}`,t=Bt.get(e);if(t){const{x:n,y:s}=i.getRefOffset();return t.setRefOffset(n,s),t}let r=g.create(h.NAME);return(i.isCell()&&o.isCell()||i.isRow()&&o.isRow()||i.isColumn()&&o.isColumn())&&(r=i.unionBy(o),Bt.set(e,r)),r}function sf(){Bt.clear()}var af=Object.defineProperty,of=Object.getOwnPropertyDescriptor,uf=(i,o,e,t)=>{for(var r=t>1?void 0:t?of(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&af(o,e,r),r},cf=(i,o)=>(e,t)=>o(e,t,i),ze=(i=>(i[i.IDLE=0]="IDLE",i[i.START=1]="START",i[i.START_DEPENDENCY=2]="START_DEPENDENCY",i[i.START_CALCULATION=3]="START_CALCULATION",i[i.CURRENTLY_CALCULATING=4]="CURRENTLY_CALCULATING",i[i.START_DEPENDENCY_ARRAY_FORMULA=5]="START_DEPENDENCY_ARRAY_FORMULA",i[i.START_CALCULATION_ARRAY_FORMULA=6]="START_CALCULATION_ARRAY_FORMULA",i[i.CURRENTLY_CALCULATING_ARRAY_FORMULA=7]="CURRENTLY_CALCULATING_ARRAY_FORMULA",i[i.CALCULATION_COMPLETED=8]="CALCULATION_COMPLETED",i))(ze||{}),zt=(i=>(i[i.INITIAL=0]="INITIAL",i[i.STOP_EXECUTION=1]="STOP_EXECUTION",i[i.NOT_EXECUTED=2]="NOT_EXECUTED",i[i.SUCCESS=3]="SUCCESS",i))(zt||{});exports.FormulaRuntimeService=class extends M.Disposable{constructor(e){super();A(this,"_formulaExecuteStage",0);A(this,"_stopState",!1);A(this,"_currentRow",-1);A(this,"_currentColumn",-1);A(this,"_currentRowCount",Number.NEGATIVE_INFINITY);A(this,"_currentColumnCount",Number.NEGATIVE_INFINITY);A(this,"_currentSubUnitId","");A(this,"_currentUnitId","");A(this,"_runtimeData",{});A(this,"_runtimeOtherData",{});A(this,"_unitArrayFormulaRange",{});A(this,"_runtimeArrayFormulaCellData",{});A(this,"_runtimeClearArrayFormulaCellData",{});A(this,"_runtimeFeatureRange",{});A(this,"_runtimeFeatureCellData",{});A(this,"_functionsExecutedState",0);A(this,"_functionDefinitionPrivacyVar",new Map);A(this,"_totalFormulasToCalculate",0);A(this,"_completedFormulasCount",0);A(this,"_totalArrayFormulasToCalculate",0);A(this,"_completedArrayFormulasCount",0);A(this,"_formulaCycleIndex",0);A(this,"_isCycleDependency",!1);this._currentConfigService=e}get currentRow(){return this._currentRow}get currentColumn(){return this._currentColumn}get currentRowCount(){return this._currentRowCount}get currentColumnCount(){return this._currentColumnCount}get currentSubUnitId(){return this._currentSubUnitId}get currentUnitId(){return this._currentUnitId}dispose(){this.reset(),this._runtimeFeatureCellData={},this._runtimeFeatureRange={},this.clearReferenceAndNumberformatCache()}enableCycleDependency(){this._isCycleDependency=!0}disableCycleDependency(){this._isCycleDependency=!1}isCycleDependency(){return this._isCycleDependency}setFormulaCycleIndex(e){this._formulaCycleIndex=e}getFormulaCycleIndex(){return this._formulaCycleIndex}setTotalArrayFormulasToCalculate(e){this._totalArrayFormulasToCalculate=e}getTotalArrayFormulasToCalculate(){return this._totalArrayFormulasToCalculate}setCompletedArrayFormulasCount(e){this._completedArrayFormulasCount=e}getCompletedArrayFormulasCount(){return this._completedArrayFormulasCount}setTotalFormulasToCalculate(e){this._totalFormulasToCalculate=e}getTotalFormulasToCalculate(){return this._totalFormulasToCalculate}setCompletedFormulasCount(e){this._completedFormulasCount=e}getCompletedFormulasCount(){return this._completedFormulasCount}markedAsSuccessfullyExecuted(){this._functionsExecutedState=3}markedAsNoFunctionsExecuted(){this._functionsExecutedState=2}markedAsStopFunctionsExecuted(){this._functionsExecutedState=1}markedAsInitialFunctionsExecuted(){this._functionsExecutedState=0}stopExecution(){this._stopState=!0,this.setFormulaExecuteStage(0)}isStopExecution(){return this._stopState}setFormulaExecuteStage(e){this._formulaExecuteStage=e}getFormulaExecuteStage(){return this._formulaExecuteStage}reset(){this._formulaExecuteStage=0,this._runtimeData={},this._runtimeOtherData={},this._unitArrayFormulaRange={},this._runtimeArrayFormulaCellData={},this._runtimeClearArrayFormulaCellData={},this._functionDefinitionPrivacyVar.clear(),this.markedAsInitialFunctionsExecuted(),this._stopState=!1,this._isCycleDependency=!1,this._totalFormulasToCalculate=0,this._completedFormulasCount=0,this.clearReferenceAndNumberformatCache()}clearReferenceAndNumberformatCache(){Pc(),Tc(),hc(),sf()}setCurrent(e,t,r,n,s,a){this._currentRow=e,this._currentColumn=t,this._currentRowCount=r,this._currentColumnCount=n,this._currentSubUnitId=s,this._currentUnitId=a}clearFunctionDefinitionPrivacyVar(){this._functionDefinitionPrivacyVar.clear()}registerFunctionDefinitionPrivacyVar(e,t){this._functionDefinitionPrivacyVar.set(e,t)}getFunctionDefinitionPrivacyVar(e){return this._functionDefinitionPrivacyVar.get(e)}setRuntimeOtherData(e,t,r,n){const s=this._currentSubUnitId,a=this._currentUnitId;this._runtimeOtherData[a]===void 0&&(this._runtimeOtherData[a]={});const u=this._runtimeOtherData[a];(u[s]===void 0||u[s]===null)&&(u[s]={});const c=u[s];let l=[];if(n.isReferenceObject()||n.isValueObject()&&n.isArray()){const f=n,{startRow:m,startColumn:d}=f.getRangePosition();f.iterator((C,_,E)=>{const b=xt(C),R=_-m,p=E-d;l[R]==null&&(l[R]=[]),l[R][p]=b})}else l=[[xt(n)]];(c[e]===void 0||c[e]===null)&&(c[e]={}),(c[e][r]===void 0||c[e][r]===null)&&(c[e][r]={}),c[e][r][t]=l}setRuntimeData(e){const t=this._currentRow,r=this._currentColumn,n=this._currentRowCount,s=this.currentColumnCount,a=this._currentSubUnitId,u=this._currentUnitId;this._runtimeData[u]==null&&(this._runtimeData[u]={});const c=this._runtimeData[u];c[a]==null&&(c[a]=new M.ObjectMatrix),this._unitArrayFormulaRange[u]==null&&(this._unitArrayFormulaRange[u]={});const l=this._unitArrayFormulaRange[u];(l[a]===null||l[a]===void 0)&&(l[a]={});const f=new M.ObjectMatrix(l[a]);this._runtimeArrayFormulaCellData[u]===void 0&&(this._runtimeArrayFormulaCellData[u]={});const m=this._runtimeArrayFormulaCellData[u];m[a]==null&&(m[a]=new M.ObjectMatrix),this._runtimeClearArrayFormulaCellData[u]===void 0&&(this._runtimeClearArrayFormulaCellData[u]={});const d=this._runtimeClearArrayFormulaCellData[u];d[a]==null&&(d[a]=new M.ObjectMatrix);const C=c[a],_=m[a],E=d[a];if(e.isReferenceObject()||e.isValueObject()&&e.isArray()){const b=e,{startRow:R,startColumn:p,endRow:V,endColumn:S}=b.getRangePosition();if(R===V&&p===S){const w=b.getFirstCell(),P=xt(w);C.setValue(t,r,P),E.setValue(t,r,P);return}const D={startRow:t,startColumn:r,endRow:V-R+t,endColumn:S-p+r};if(f.setValue(t,r,D),this._checkIfArrayFormulaRangeHasData(u,a,t,r,D)||this._checkIfArrayFormulaExceeded(n,s,D)){const w=xt(g.create(h.SPILL));C.setValue(t,r,w),E.setValue(t,r,w);const P=this._currentConfigService.getUnitData();b.iterator((L,T,B)=>{var Z,G;const W=T-R+t,q=B-p+r,ie=(G=(Z=P[u])==null?void 0:Z[a])==null?void 0:G.cellData.getValue(W,q);if(T===R&&B===p)_.setValue(t,r,w);else if(ie!=null)ie.v==null&&(ie.v=""),_.setValue(W,q,ie);else{if(this._isInOtherArrayFormulaRange(u,a,t,r,W,q))return!0;_.setValue(W,q,{v:""})}})}else{const w=g.create(h.SPILL);b.iterator((P,L,T)=>{const B=xt(P);if(L===R&&T===p){if(P!=null&&P.isError()&&P.isEqualType(w))return E.setValue(t,r,{}),C.setValue(t,r,{...xt(w)}),!1;C.setValue(t,r,{...B})}const W=L-R+t,q=T-p+r;_.setValue(W,q,B)})}}else{const b=xt(e);C.setValue(t,r,b),E.setValue(t,r,b)}}getUnitData(){return this._runtimeData}getUnitArrayFormula(){return this._unitArrayFormulaRange}getRuntimeOtherData(){return this._runtimeOtherData}getRuntimeArrayFormulaCellData(){return this._runtimeArrayFormulaCellData}getRuntimeClearArrayFormulaCellData(){return this._runtimeClearArrayFormulaCellData}getRuntimeFeatureRange(){return this._runtimeFeatureRange}setRuntimeFeatureRange(e,t){this._runtimeFeatureRange[e]=t}getRuntimeFeatureCellData(){return this._runtimeFeatureCellData}setRuntimeFeatureCellData(e,t){this._runtimeFeatureCellData[e]=t}getAllRuntimeData(){return{unitData:this.getUnitData(),arrayFormulaRange:this.getUnitArrayFormula(),unitOtherData:this.getRuntimeOtherData(),functionsExecutedState:this._functionsExecutedState,arrayFormulaCellData:this.getRuntimeArrayFormulaCellData(),clearArrayFormulaCellData:this.getRuntimeClearArrayFormulaCellData(),runtimeFeatureRange:this.getRuntimeFeatureRange(),runtimeFeatureCellData:this.getRuntimeFeatureCellData()}}getRuntimeState(){return{totalFormulasToCalculate:this.getTotalFormulasToCalculate(),completedFormulasCount:this.getCompletedFormulasCount(),totalArrayFormulasToCalculate:this.getTotalArrayFormulasToCalculate(),completedArrayFormulasCount:this.getCompletedArrayFormulasCount(),stage:this.getFormulaExecuteStage(),formulaCycleIndex:this.getFormulaCycleIndex()}}_checkIfArrayFormulaRangeHasData(e,t,r,n,s){var d,C,_,E,b,R,p,V,S,D,w;const{startRow:a,startColumn:u,endRow:c,endColumn:l}=s,f=this._currentConfigService.getUnitData(),m=this._currentConfigService.getArrayFormulaCellData();(_=(C=(d=this._unitArrayFormulaRange[e])==null?void 0:d[t])==null?void 0:C[r])==null||_[n];for(let P=a;P<=c;P++)for(let L=u;L<=l;L++){if(P===r&&n===L)continue;const T=(R=(b=(E=this._runtimeData)==null?void 0:E[e])==null?void 0:b[t])==null?void 0:R.getValue(P,L);(V=(p=m==null?void 0:m[e])==null?void 0:p[t])==null||V.getValue(P,L);const B=(w=(D=(S=f==null?void 0:f[e])==null?void 0:S[t])==null?void 0:D.cellData)==null?void 0:w.getValue(P,L),W=this._getRuntimeFeatureCellValue(P,L,t,e);if(!M.isNullCell(T)||this._isInOtherArrayFormulaRange(e,t,r,n,P,L)||!M.isNullCell(B)||!M.isNullCell(W))return!0}return!1}_getRuntimeFeatureCellValue(e,t,r,n){return pi(e,t,r,n,this._runtimeFeatureCellData)}_arrayCellHasData(e){return e==null?!1:e.v!==void 0}_isInOtherArrayFormulaRange(e,t,r,n,s,a){var f;const u=(f=this._currentConfigService.getArrayFormulaRange()[e])==null?void 0:f[t];if(u==null)return!1;let c=!1;return new M.ObjectMatrix(u).forValue((m,d,C)=>{var b,R;if(m===r&&d===n)return;const _=this._isInArrayFormulaRange(C,s,a),E=(R=(b=this._runtimeData[e])==null?void 0:b[t])==null?void 0:R.getValue(m,d);_&&(E==null?void 0:E.v)!==h.SPILL&&(c=!0)}),c}_isInArrayFormulaRange(e,t,r){if(e==null)return!1;const{startRow:n,startColumn:s,endRow:a,endColumn:u}=e;return t>=n&&t<=a&&r>=s&&r<=u}_checkIfArrayFormulaExceeded(e,t,r){return r.endRow>=e||r.endColumn>=t}_isInDirtyRange(e,t,r,n){const s=this._currentConfigService.getDirtyRanges();return s.length===0?!0:ri(s,e,t,r,n)}};exports.FormulaRuntimeService=uf([cf(0,mt)],exports.FormulaRuntimeService);const st=M.createIdentifier("univer.formula.runtime.service");var ue=(i=>(i[i.REFERENCE=1]="REFERENCE",i[i.VALUE=2]="VALUE",i[i.OPERATOR=3]="OPERATOR",i[i.FUNCTION=4]="FUNCTION",i[i.LAMBDA=5]="LAMBDA",i[i.LAMBDA_PARAMETER=6]="LAMBDA_PARAMETER",i[i.ERROR=7]="ERROR",i[i.BASE=8]="BASE",i[i.ROOT=9]="ROOT",i[i.UNION=10]="UNION",i[i.PREFIX=11]="PREFIX",i[i.SUFFIX=12]="SUFFIX",i[i.NULL=13]="NULL",i))(ue||{});const at=new Map([[1,7],[2,9],[3,8],[4,6],[5,1],[6,2],[9,10],[10,3],[11,4],[12,5]]);class Fe{constructor(o){A(this,"_children",[]);A(this,"_definedNames");A(this,"_parent");A(this,"_valueObject");A(this,"_calculateState",!1);A(this,"_async",!1);A(this,"_address",!1);A(this,"_isForcedCalculateFunction",!1);this._token=o}dispose(){var o;this._children.forEach(e=>{e.dispose()}),(o=this._valueObject)==null||o.dispose(),this._valueObject=null,this._children=[],this._definedNames=null,this._parent=null}get nodeType(){return ue.BASE}isAsync(){return this._async}isAddress(){return this._address}isForcedCalculateFunction(){return this._isForcedCalculateFunction}setAsync(){this._async=!0}setAddress(){this._address=!0}getParent(){return this._parent}setParent(o){this._parent=o,o.addChildren(this)}setForcedCalculateFunction(){this._isForcedCalculateFunction=!0}getChildren(){return this._children}addChildren(...o){this._children.push(...o)}getToken(){return this._token}setValue(o){this._valueObject=o}getValue(){return this._valueObject}isCalculated(){return this._calculateState}setCalculated(){this._calculateState=!0}execute(){}setNotEmpty(o=!0){}async executeAsync(){return Promise.resolve(Rt.SUCCESS)}serialize(){const o=this.getToken(),e=this.getChildren(),t=[],r=e.length;for(let s=0;s<r;s++){const a=e[s];t.push(a.serialize())}const n={token:o,nodeType:this.nodeType};return r>0&&(n.children=t),n}hasDefinedName(o){var e;return((e=this._definedNames)==null?void 0:e.includes(o))||!1}setDefinedNames(o){this._definedNames=o}getDefinedNames(){return this._definedNames}}class De extends Fe{constructor(e){super(e);A(this,"_errorValueObject");this._errorValueObject=g.create(e)}get nodeType(){return ue.ERROR}static create(e){return new De(e)}getValue(){return this._errorValueObject}}const it=100;class ot{get zIndex(){return 0}dispose(){}create(o,e,t){let r;return o instanceof se?r=o.getToken():r=o,new Fe(r)}}class _s extends Fe{get nodeType(){return ue.ROOT}execute(){const o=this.getChildren();if(o.length>1){this.setValue(g.create(h.VALUE));return}const e=o[0];e==null?this.setValue(g.create(h.VALUE)):this.setValue(e.getValue())}}class js extends ot{get zIndex(){return at.get(ue.ROOT)||it}checkAndCreateNodeType(o){if(!(o instanceof se))return;if(o.getToken()===Nt)return new _s(Nt)}}const gt=M.createIdentifier("univer.formula-function.service");class Ii extends M.Disposable{constructor(){super(...arguments);A(this,"_functionExecutors",new Map);A(this,"_functionDescriptions",new Map)}dispose(){this._functionExecutors.clear(),this._functionDescriptions.clear()}registerExecutors(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionExecutors.set(r.name,r)}}getExecutors(){return this._functionExecutors}getExecutor(e){return this._functionExecutors.get(e)}hasExecutor(e){return this._functionExecutors.has(e)}unregisterExecutors(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionExecutors.delete(r)}}registerDescriptions(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.set(r.functionName,r)}return M.toDisposable(()=>{for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.delete(r.functionName)}})}getDescriptions(){return this._functionDescriptions}getDescription(e){return this._functionDescriptions.get(e)}hasDescription(e){return this._functionDescriptions.has(e)}unregisterDescriptions(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.delete(r)}}}var Le=(i=>(i.COMPARE="COMPARE",i.DIVIDED="DIVIDED",i.MINUS="MINUS",i.MULTIPLY="MULTIPLY",i.PLUS="PLUS",i.UNION="UNION",i.CUBE="CUBE",i))(Le||{}),lf=Object.defineProperty,ff=Object.getOwnPropertyDescriptor,mf=(i,o,e,t)=>{for(var r=t>1?void 0:t?ff(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&lf(o,e,r),r},La=(i,o)=>(e,t)=>o(e,t,i);class an extends Fe{constructor(o,e,t){super(e),this._runtimeService=o,this._operatorString=e,this._functionExecutor=t}get nodeType(){return ue.PREFIX}execute(){let e=this.getChildren()[0].getValue(),t;if(e==null)throw new Error("object is null");this._operatorString===pe.MINUS?(e.isReferenceObject()&&(e=e.toArrayValueObject()),t=this._functionExecutor.calculate(y.create(0),e)):this._operatorString===pe.AT?t=this._handlerAT(e):t=g.create(h.VALUE),this.setValue(t)}_handlerAT(o){if(!o.isReferenceObject())return g.create(h.VALUE);const e=o;if(e.isCell())return g.create(h.VALUE);const t=this._runtimeService,r=t.currentRow||0,n=t.currentColumn||0,s=e.getRangePosition(),{startRow:a,startColumn:u,endRow:c,endColumn:l}=s;return l!==u&&c!==a||a===c&&u===l?g.create(h.VALUE):c===a&&n>=u&&n<=l?e.getCellByColumn(n):u===l&&r>=a&&r<=c?e.getCellByRow(r):e.isTable()?e.getCellByPosition(r):g.create(h.VALUE)}}exports.PrefixNodeFactory=class extends ot{constructor(o,e){super(),this._functionService=o,this._runtimeService=e}get zIndex(){return at.get(ue.PREFIX)||it}checkAndCreateNodeType(o){if(!(o instanceof se))return;const e=o.getToken(),t=e.trim();if(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"')return;let r="";if(t===pe.MINUS)r=Le.MINUS;else return t===pe.AT?new an(this._runtimeService,t):void 0;const n=this._functionService.getExecutor(r);return n?new an(this._runtimeService,t,n):(console.error(`No function ${e}`),De.create(h.NAME))}};exports.PrefixNodeFactory=mf([La(0,gt),La(1,st)],exports.PrefixNodeFactory);new RegExp(pe.MINUS,"g");new RegExp(pe.AT,"g");function Fi(i,o,e){let t,r,n=i;const s=n.slice(0,2);let a=0;if(s[0]===pe.MINUS){const u=o.getExecutor(Le.MINUS);t=new an(e,pe.MINUS,u),a++}return s[0]===pe.AT&&(r=new an(e,pe.AT),t&&r.setParent(t),a++),a>0&&(n=n.slice(a)),{tokenTrim:n,minusPrefixNode:t,atPrefixNode:r}}var hf=Object.defineProperty,gf=Object.getOwnPropertyDescriptor,df=(i,o,e,t)=>{for(var r=t>1?void 0:t?gf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&hf(o,e,r),r},Kt=(i,o)=>(e,t)=>o(e,t,i);class Cf extends Fe{constructor(o,e,t,r,n,s){super(""),this._functionExecutor=e,this._currentConfigService=t,this._runtimeService=r,this._definedNamesService=n,this._formulaDataModel=s,this._functionExecutor.isAsync()&&this.setAsync(),this._functionExecutor.isAddress()&&this.setAddress(),this._functionExecutor.needsLocale&&this._setLocale(),this._functionExecutor.needsSheetsInfo&&this._setSheetsInfo(),this._functionExecutor.needsFormulaDataModel&&this._functionExecutor.setFormulaDataModel(this._formulaDataModel)}get nodeType(){return ue.FUNCTION}async executeAsync(){const o=[],e=this.getChildren(),t=e.length;this._compatibility();for(let s=0;s<t;s++){const u=e[s].getValue();u!=null&&(u.isReferenceObject()&&!this._functionExecutor.needsReferenceObject?o.push(u.toArrayValueObject()):o.push(u))}const r=this._calculate(o);let n;return r.isAsyncObject()||r.isAsyncArrayObject()?n=await r.getValue():n=r,this._setRefData(n),this.setValue(n),Promise.resolve(Rt.SUCCESS)}execute(){const o=[],e=this.getChildren(),t=e.length;this._compatibility();for(let n=0;n<t;n++){const a=e[n].getValue();a!=null&&(a.isReferenceObject()&&!this._functionExecutor.needsReferenceObject?o.push(a.toArrayValueObject()):o.push(a))}const r=this._calculate(o);this._setRefData(r),this.setValue(r)}_compatibility(){this._lookupCompatibility()}_lookupCompatibility(){const o=this.getChildren(),e=o.length;if(!this._functionExecutor.needsExpandParams||e!==3)return;const t=o[1].getValue(),r=o[2].getValue();if(!(t!=null&&t.isReferenceObject())&&!(r!=null&&r.isReferenceObject()))return;let n,s;if(t!=null&&t.isReferenceObject()){const C=t.getRangeData(),{startRow:_,startColumn:E,endRow:b,endColumn:R}=C;n=b-_+1,s=R-E+1}else n=t!=null&&t.isArray()?t.getRowCount():1,s=t!=null&&t.isArray()?t.getColumnCount():1;const a=r.getRangeData(),{startRow:u,startColumn:c,endRow:l,endColumn:f}=a,m=l-u+1,d=f-c+1;n!==m&&(a.endRow+=n-m),s!==d&&(a.endColumn+=s-d)}_calculate(o){var n;const{minParams:e,maxParams:t}=this._functionExecutor;if(e!==-1&&t!==-1&&(o.length<e||o.length>t))return g.create(h.NA);let r;if(this._setRefInfo(),this._functionExecutor.isCustom()){const s=this._functionExecutor.calculateCustom(...o.map(a=>a.isArray()?a.toValue():a.getValue()));if(typeof s!="object"||s==null)r=lt.create(s);else{const a=vi(s);r=K.create({calculateValueList:a,rowCount:a.length,columnCount:((n=a[0])==null?void 0:n.length)||0,unitId:"",sheetId:"",row:-1,column:-1})}}else this._functionExecutor.isAddress()&&this._setDefinedNamesForFunction(),r=this._functionExecutor.calculate(...o);return r}_setDefinedNamesForFunction(){const o=this._currentConfigService.getExecuteUnitId();if(o==null)return;const e=this._definedNamesService.getDefinedNameMap(o);e!=null&&this._functionExecutor.setDefinedNames(e)}_setRefInfo(){const{currentUnitId:o,currentSubUnitId:e,currentRow:t,currentColumn:r}=this._runtimeService;this._functionExecutor.setRefInfo(o,e,t,r)}_setRefData(o){if(!o.isReferenceObject())return;const e=o;e.setForcedSheetId(this._currentConfigService.getSheetNameMap()),e.setUnitData(this._currentConfigService.getUnitData()),e.setArrayFormulaCellData(this._currentConfigService.getArrayFormulaCellData()),e.setRuntimeData(this._runtimeService.getUnitData()),e.setRuntimeArrayFormulaCellData(this._runtimeService.getRuntimeArrayFormulaCellData()),e.setRuntimeFeatureCellData(this._runtimeService.getRuntimeFeatureCellData())}_setLocale(){this._functionExecutor.setLocale(this._currentConfigService.getLocale())}_setSheetsInfo(){this._functionExecutor.setSheetsInfo(this._currentConfigService.getSheetsInfo())}}class _f extends Fe{constructor(o="Error"){super(o)}get nodeType(){return ue.FUNCTION}async executeAsync(){return this.setValue(g.create(h.NAME)),Promise.resolve(Rt.SUCCESS)}execute(){this.setValue(g.create(h.NAME))}}exports.FunctionNodeFactory=class extends ot{constructor(o,e,t,r,n,s){super(),this._functionService=o,this._currentConfigService=e,this._runtimeService=t,this._definedNamesService=r,this._injector=n,this._formulaDataModel=s}get zIndex(){return at.get(ue.FUNCTION)||it}create(o){const e=this._functionService.getExecutor(o);return e?new Cf(o,e,this._currentConfigService,this._runtimeService,this._definedNamesService,this._formulaDataModel):(console.error(`No function ${o}`),De.create(h.NAME))}checkAndCreateNodeType(o){if(typeof o=="string")return;const e=o.getToken(),{tokenTrim:t,minusPrefixNode:r,atPrefixNode:n}=Fi(e.trim(),this._functionService,this._runtimeService);if(!Number.isNaN(Number(t))&&!this._isParentUnionNode(o))return De.create(h.VALUE);const s=t.toUpperCase();if(this._functionService.hasExecutor(s)){const a=this.create(s);return n?a.setParent(n):r&&a.setParent(r),a}}_isParentUnionNode(o){var e,t;return((t=(e=o.getParent())==null?void 0:e.getParent())==null?void 0:t.getToken())===Q.COLON}};exports.FunctionNodeFactory=df([Kt(0,gt),Kt(1,mt),Kt(2,st),Kt(3,lr),Kt(4,M.Inject(M.Injector)),Kt(5,M.Inject(exports.FormulaDataModel))],exports.FunctionNodeFactory);var Af=Object.defineProperty,Ef=Object.getOwnPropertyDescriptor,bf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Ef(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Af(o,e,r),r},yf=(i,o)=>(e,t)=>o(e,t,i);exports.Interpreter=class extends M.Disposable{constructor(o){super(),this._runtimeService=o}async executeAsync(o){if(!o||!o.node)return Promise.resolve(g.create(h.VALUE));const e=o.node,t=o.refOffsetX,r=o.refOffsetY;await this._executeAsync(e,t,r);const n=e.getValue();return n==null?Promise.resolve(g.create(h.VALUE)):Promise.resolve(n)}execute(o){if(!o||!o.node)return g.create(h.VALUE);const e=o.node,t=o.refOffsetX,r=o.refOffsetY;this._execute(e,t,r);const n=e.getValue();return n==null?g.create(h.VALUE):n}executePreCalculateNode(o){return o.execute(),o.getValue()}checkAsyncNode(o){if(o==null)return!1;const e=[];this._checkAsyncNode(o,e);for(let t=0,r=e.length;t<r;t++)if(e[t]===!0)return!0;return!1}_checkAsyncNode(o,e){const t=o.getChildren(),r=t.length;for(let n=0;n<r;n++){const s=t[n];e.push(s.isAsync()),this._checkAsyncNode(s,e)}}async _executeAsync(o,e=0,t=0){if(this._runtimeService.isStopExecution())return Promise.resolve(Rt.ERROR);const r=o.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.getToken().toUpperCase()===br&&a.isEmptyParamFunction()){a.execute();continue}await this._executeAsync(a,e,t)}return o.nodeType===ue.REFERENCE&&o.setRefOffset(e,t),o.nodeType===ue.FUNCTION&&o.isAsync()?await o.executeAsync():o.execute(),Promise.resolve(Rt.SUCCESS)}_execute(o,e=0,t=0){if(this._runtimeService.isStopExecution())return Rt.ERROR;const r=o.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.getToken().toUpperCase()===br&&a.isEmptyParamFunction()){a.execute();continue}this._execute(a,e,t)}return o.nodeType===ue.REFERENCE&&o.setRefOffset(e,t),o.execute(),Rt.SUCCESS}};exports.Interpreter=bf([yf(0,st)],exports.Interpreter);function ki(i){return i instanceof se?i.getToken()===nr:!1}function Rf(i){return i instanceof se?i.getToken()===bi:!1}function Us(i,o,e){const t=i.getChildren(),r=t.length,n=t[0];for(let s=0;s<r;s++){const a=t[s];if(!(ki(n)&&s!==0))if(a instanceof se)Us(a,o,e);else{const u=a.trim();if(e.has(u)){const c=new se;c.setToken(Or),c.setLambdaId(o),c.setLambdaPrivacyVar(e),c.setLambdaParameter(u),t[s]=c}}}}function pf(i){let o=i;for(;o!=null&&o.getParent();)o=o.getParent();return o}function xa(i,o=0,e=0){return{node:i,refOffsetX:o,refOffsetY:e}}function $i(i){if(!i)return;if(i.getToken()!==Or)return i;const o=i,e=o.getCurrentLambdaPrivacyVar(),t=o.getLambdaParameter();if(!e)return;const r=e.get(t);return r==null&&i.getValue()?i:$i(r)}class vs extends ht{constructor(e,t,r){super(0);A(this,"_lambdaPrivacyValueMap",new Map);this._lambdaNode=e,this._interpreter=t,this._lambdaPrivacyVarKeys=r,this._lambdaPrivacyValueMap.clear()}static create(e,t,r){return new vs(e,t,r)}dispose(){this._lambdaPrivacyValueMap.clear(),this._lambdaPrivacyValueMap=new Map,this._lambdaNode=null,this._interpreter=null,this._lambdaPrivacyVarKeys=[]}isLambda(){return!0}execute(...e){const t=this._lambdaPrivacyVarKeys.length;if(e.length!==t||!this._interpreter||!this._lambdaNode)return g.create(h.VALUE);this._setLambdaPrivacyValueMap(e),this._setLambdaNodeValue(this._lambdaNode),this._lambdaNode.setNotEmpty(!1);let r;if(this._interpreter.checkAsyncNode(this._lambdaNode))r=new Ti(this._interpreter.executeAsync(xa(this._lambdaNode)));else{const n=this._interpreter.execute(xa(this._lambdaNode));n.isReferenceObject()?r=n.toArrayValueObject():r=n}return this._lambdaNode.setNotEmpty(!0),r}_setLambdaNodeValue(e){if(!e)return;const t=e.getChildren(),r=t.length;for(let n=0;n<r;n++){const s=t[n];if(s.getToken()===Or){const u=s.getLambdaParameter(),c=this._lambdaPrivacyValueMap.get(u);if(c)s.setValue(c);else{const l=s.getCurrentLambdaPrivacyVar(),f=$i(l.get(u));f!=null&&s.setValue(f.getValue())}continue}this._setLambdaNodeValue(s)}}_setLambdaPrivacyValueMap(e){for(let t=0;t<e.length;t++){const r=e[t],n=this._lambdaPrivacyVarKeys[t];this._lambdaPrivacyValueMap.set(n,r)}}getLambdaPrivacyVarKeys(){return this._lambdaPrivacyVarKeys}}var Nf=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,Of=(i,o,e,t)=>{for(var r=t>1?void 0:t?Vf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Nf(o,e,r),r},ja=(i,o)=>(e,t)=>o(e,t,i);class Mf extends Fe{constructor(e,t,r,n){super(e);A(this,"_isNotEmpty",!0);this._lambdaId=t,this._interpreter=r,this._lambdaPrivacyVarKeys=n}get nodeType(){return ue.LAMBDA}setNotEmpty(e=!1){this._isNotEmpty=e}isEmptyParamFunction(){return this.getChildren().length<2&&this._isNotEmpty}isFunctionParameter(){return this._lambdaId===null}getLambdaId(){return this._lambdaId}execute(){if(this.isEmptyParamFunction())this.setValue(vs.create(this,this._interpreter,this._lambdaPrivacyVarKeys));else{const e=this.getChildren(),t=e.length;this.setValue(e[t-1].getValue())}}}exports.LambdaNodeFactory=class extends ot{constructor(o,e){super(),this._runtimeService=o,this._interpreter=e}get zIndex(){return at.get(ue.LAMBDA)||it}create(o){const e=o.getChildren(),t=e[0];let r=e.slice(1,-1);const n=e[e.length-1];if(!(t instanceof se&&n instanceof se))return De.create(h.NAME);if(t.getToken()===nr){const u=t.getChildren();if(r.length!==u.length)return De.create(h.VALUE)}else r=e.slice(0,-1);const s=M.Tools.generateRandomId(8),a=new Map;for(let u=0;u<r.length;u++){const c=r[u];if(c instanceof se){const l=c.getChildren()[0];c.setToken(bi),a.set(l.trim(),void 0)}else return De.create(h.VALUE)}return this._runtimeService.registerFunctionDefinitionPrivacyVar(s,a),this._updateLambdaStatement(n,s,a),new Mf(o.getToken(),s,this._interpreter,[...a.keys()])}checkAndCreateNodeType(o){if(!(!(o instanceof se)||o.getToken().trim().toUpperCase()!==br))return this.create(o)}_updateLambdaStatement(o,e,t){Us(o,e,t)}};exports.LambdaNodeFactory=Of([ja(0,st),ja(1,M.Inject(exports.Interpreter))],exports.LambdaNodeFactory);function Yi(i){if(!i)return;if(i.getToken()!==Or)return i;const o=i,e=o.getCurrentLambdaPrivacyVar(),t=o.getLambdaParameter();if(e)return Yi(e.get(t))}class Sf extends Fe{constructor(o,e,t){super(o),this._lambdaParameter=e,this._currentLambdaPrivacyVar=t}getLambdaParameter(){return this._lambdaParameter}getCurrentLambdaPrivacyVar(){return this._currentLambdaPrivacyVar}get nodeType(){return ue.LAMBDA_PARAMETER}execute(){const o=Yi(this._currentLambdaPrivacyVar.get(this._lambdaParameter));if(o)this.setValue(o.getValue());else{const e=this.getValue();(e==null||e.isError())&&this.setValue(g.create(h.NAME))}}}class Ts extends ot{get zIndex(){return at.get(ue.LAMBDA_PARAMETER)||it}create(o){const e=o.getFunctionDefinitionPrivacyVar(),t=o.getLambdaParameter();return e?new Sf(o.getToken(),t,e):new De(h.NAME)}checkAndCreateNodeType(o){if(!(!(o instanceof se)||o.getToken().trim()!==Or))return this.create(o)}}class Df extends Fe{constructor(o){super(o),this._operatorString=o}get nodeType(){return ue.NULL}execute(){this.setValue(ae.create())}}var Y=(i=>(i.ABS="ABS",i.ACOS="ACOS",i.ACOSH="ACOSH",i.ACOT="ACOT",i.ACOTH="ACOTH",i.AGGREGATE="AGGREGATE",i.ARABIC="ARABIC",i.ASIN="ASIN",i.ASINH="ASINH",i.ATAN="ATAN",i.ATAN2="ATAN2",i.ATANH="ATANH",i.BASE="BASE",i.CEILING="CEILING",i.CEILING_MATH="CEILING.MATH",i.CEILING_PRECISE="CEILING.PRECISE",i.COMBIN="COMBIN",i.COMBINA="COMBINA",i.COS="COS",i.COSH="COSH",i.COT="COT",i.COTH="COTH",i.CSC="CSC",i.CSCH="CSCH",i.DECIMAL="DECIMAL",i.DEGREES="DEGREES",i.EVEN="EVEN",i.EXP="EXP",i.FACT="FACT",i.FACTDOUBLE="FACTDOUBLE",i.FLOOR="FLOOR",i.FLOOR_MATH="FLOOR.MATH",i.FLOOR_PRECISE="FLOOR.PRECISE",i.GCD="GCD",i.INT="INT",i.ISO_CEILING="ISO.CEILING",i.LCM="LCM",i.LET="LET",i.LN="LN",i.LOG="LOG",i.LOG10="LOG10",i.MDETERM="MDETERM",i.MINVERSE="MINVERSE",i.MMULT="MMULT",i.MOD="MOD",i.MROUND="MROUND",i.MULTINOMIAL="MULTINOMIAL",i.MUNIT="MUNIT",i.ODD="ODD",i.PI="PI",i.POWER="POWER",i.PRODUCT="PRODUCT",i.QUOTIENT="QUOTIENT",i.RADIANS="RADIANS",i.RAND="RAND",i.RANDARRAY="RANDARRAY",i.RANDBETWEEN="RANDBETWEEN",i.ROMAN="ROMAN",i.ROUND="ROUND",i.ROUNDDOWN="ROUNDDOWN",i.ROUNDUP="ROUNDUP",i.SEC="SEC",i.SECH="SECH",i.SERIESSUM="SERIESSUM",i.SEQUENCE="SEQUENCE",i.SIGN="SIGN",i.SIN="SIN",i.SINH="SINH",i.SQRT="SQRT",i.SQRTPI="SQRTPI",i.SUBTOTAL="SUBTOTAL",i.SUM="SUM",i.SUMIF="SUMIF",i.SUMIFS="SUMIFS",i.SUMPRODUCT="SUMPRODUCT",i.SUMSQ="SUMSQ",i.SUMX2MY2="SUMX2MY2",i.SUMX2PY2="SUMX2PY2",i.SUMXMY2="SUMXMY2",i.TAN="TAN",i.TANH="TANH",i.TRUNC="TRUNC",i))(Y||{}),ne=(i=>(i.ASC="ASC",i.ARRAYTOTEXT="ARRAYTOTEXT",i.BAHTTEXT="BAHTTEXT",i.CHAR="CHAR",i.CLEAN="CLEAN",i.CODE="CODE",i.CONCAT="CONCAT",i.CONCATENATE="CONCATENATE",i.DBCS="DBCS",i.DOLLAR="DOLLAR",i.EXACT="EXACT",i.FIND="FIND",i.FINDB="FINDB",i.FIXED="FIXED",i.LEFT="LEFT",i.LEFTB="LEFTB",i.LEN="LEN",i.LENB="LENB",i.LOWER="LOWER",i.MID="MID",i.MIDB="MIDB",i.NUMBERVALUE="NUMBERVALUE",i.PHONETIC="PHONETIC",i.PROPER="PROPER",i.REGEXEXTRACT="REGEXEXTRACT",i.REGEXMATCH="REGEXMATCH",i.REGEXREPLACE="REGEXREPLACE",i.REPLACE="REPLACE",i.REPLACEB="REPLACEB",i.REPT="REPT",i.RIGHT="RIGHT",i.RIGHTB="RIGHTB",i.SEARCH="SEARCH",i.SEARCHB="SEARCHB",i.SUBSTITUTE="SUBSTITUTE",i.T="T",i.TEXT="TEXT",i.TEXTAFTER="TEXTAFTER",i.TEXTBEFORE="TEXTBEFORE",i.TEXTJOIN="TEXTJOIN",i.TEXTSPLIT="TEXTSPLIT",i.TRIM="TRIM",i.UNICHAR="UNICHAR",i.UNICODE="UNICODE",i.UPPER="UPPER",i.VALUE="VALUE",i.VALUETOTEXT="VALUETOTEXT",i.CALL="CALL",i.EUROCONVERT="EUROCONVERT",i.REGISTER_ID="REGISTER.ID",i))(ne||{}),wf=Object.defineProperty,Pf=Object.getOwnPropertyDescriptor,Lf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Pf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&wf(o,e,r),r},xf=(i,o)=>(e,t)=>o(e,t,i);class jf extends Fe{constructor(o,e){super(o),this._functionExecutor=e}get nodeType(){return ue.OPERATOR}execute(){const o=this.getChildren();this._functionExecutor.name===Le.COMPARE&&this._functionExecutor.setCompareType(this.getToken());const e=o[0],t=o[1];let r=e==null?void 0:e.getValue(),n=t==null?void 0:t.getValue();const s=this.getToken();if((r==null||n==null)&&s!==X.MINUS&&s!==X.PLUS){this.setValue(g.create(h.VALUE));return}r==null&&(r=ae.create()),n==null&&(n=ae.create()),r.isReferenceObject()&&(r=r.toArrayValueObject()),n.isReferenceObject()&&(n=n.toArrayValueObject()),this.setValue(this._functionExecutor.calculate(r,n))}}exports.OperatorNodeFactory=class extends ot{constructor(o){super(),this._functionService=o}get zIndex(){return at.get(ue.OPERATOR)||it}create(o){let e="";const t=o;t===X.PLUS?e=Le.PLUS:t===X.MINUS?e=Le.MINUS:t===X.MULTIPLY?e=Le.MULTIPLY:t===X.DIVIDED?e=Le.DIVIDED:t===X.CONCATENATE?e=ne.CONCATENATE:t===X.POWER?e=Y.POWER:Lu.has(t)&&(e=Le.COMPARE);const r=this._functionService.getExecutor(e);return r?new jf(t,r):(console.error(`No function ${o}`),De.create(h.NAME))}checkAndCreateNodeType(o){if(o instanceof se)return;const e=o.trim();if(!(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"')&&At.has(e))return this.create(e)}};exports.OperatorNodeFactory=Lf([xf(0,gt)],exports.OperatorNodeFactory);var Uf=Object.defineProperty,vf=Object.getOwnPropertyDescriptor,Tf=(i,o,e,t)=>{for(var r=t>1?void 0:t?vf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Uf(o,e,r),r},Xn=(i,o)=>(e,t)=>o(e,t,i);class Kn extends Fe{constructor(e,t,r,n,s=!1){super(r);A(this,"_refOffsetX",0);A(this,"_refOffsetY",0);this._currentConfigService=e,this._runtimeService=t,this._referenceObjectType=n,this._isPrepareMerge=s}get nodeType(){return ue.REFERENCE}execute(){const e=this._currentConfigService,t=this._runtimeService,r=rf(this.getToken(),this._referenceObjectType);r.setDefaultUnitId(t.currentUnitId),r.setDefaultSheetId(t.currentSubUnitId),r.setForcedSheetId(e.getSheetNameMap()),r.setUnitData(e.getUnitData()),r.setArrayFormulaCellData(e.getArrayFormulaCellData()),r.setRuntimeData(t.getUnitData()),r.setUnitStylesData(e.getUnitStylesData()),r.setRuntimeArrayFormulaCellData(t.getRuntimeArrayFormulaCellData()),r.setRuntimeFeatureCellData(t.getRuntimeFeatureCellData());const{x:n,y:s}=this.getRefOffset();r.setRefOffset(n,s),!this._isPrepareMerge&&r.isExceedRange()?this.setValue(g.create(h.NAME)):this.setValue(r)}setRefOffset(e=0,t=0){this._refOffsetX=e,this._refOffsetY=t}getRefOffset(){return{x:this._refOffsetX,y:this._refOffsetY}}}exports.ReferenceNodeFactory=class extends ot{constructor(o,e,t){super(),this._currentConfigService=o,this._formulaRuntimeService=e,this._functionService=t}get zIndex(){return at.get(ue.REFERENCE)||it}checkAndCreateNodeType(o){var f,m;let e=!1,t,r=!1;o instanceof se?(e=!0,t=o.getToken().trim(),((m=(f=o.getParent())==null?void 0:f.getParent())==null?void 0:m.getToken().trim())===Q.COLON&&(r=!0)):t=o.trim();const n=this._currentConfigService,s=this._formulaRuntimeService,{tokenTrim:a,minusPrefixNode:u,atPrefixNode:c}=Fi(t,this._functionService,s);if(!e&&a.charAt(0)==='"'&&a.charAt(a.length-1)==='"')return;let l;if(Nr(a)?l=new Kn(n,s,a,Gr.CELL,r):e&&this._checkParentIsUnionOperator(o)&&(li(a)?l=new Kn(n,s,a,Gr.ROW,r):fi(a)&&(l=new Kn(n,s,a,Gr.COLUMN,r))),l)return c?l.setParent(c):u&&l.setParent(u),l}_checkParentIsUnionOperator(o){var e,t;return((t=(e=o.getParent())==null?void 0:e.getParent())==null?void 0:t.getToken().trim())===Q.COLON}};exports.ReferenceNodeFactory=Tf([Xn(0,mt),Xn(1,st),Xn(2,gt)],exports.ReferenceNodeFactory);var Bf=Object.defineProperty,If=Object.getOwnPropertyDescriptor,Ff=(i,o,e,t)=>{for(var r=t>1?void 0:t?If(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Bf(o,e,r),r},Zn=(i,o)=>(e,t)=>o(e,t,i);class Ua extends Fe{constructor(o,e,t,r){super(t),this._currentConfigService=o,this._lexer=e,this._operatorString=t,this._functionExecutor=r}get nodeType(){return ue.SUFFIX}execute(){let e=this.getChildren()[0].getValue(),t;if(e==null)throw new Error("object is null");if(this._operatorString===He.PERCENTAGE){if(e.isReferenceObject()&&(e=e.toArrayValueObject()),t=this._functionExecutor.calculate(e,y.create(100)),t.isNumber()){const r=Number(t.getValue());t=y.create(r,"0.00%")}}else this._operatorString===He.POUND?t=this._handlerPound(e):t=g.create(h.VALUE);this.setValue(t)}_handlerPound(o){var u,c,l,f;if(!o.isReferenceObject()||!o.isCell())return g.create(h.VALUE);const e=o,t=e.getRangePosition(),r=e.getUnitId(),n=e.getSheetId(),s=this._currentConfigService.getFormulaData(),a=(f=(l=(c=(u=s==null?void 0:s[r])==null?void 0:u[n])==null?void 0:c[t.startRow])==null?void 0:l[t.startColumn])==null?void 0:f.f;return a&&this._lexer.treeBuilder(a),g.create(h.VALUE)}}exports.SuffixNodeFactory=class extends ot{constructor(o,e,t){super(),this._functionService=o,this._lexer=e,this._currentConfigService=t}get zIndex(){return at.get(ue.SUFFIX)||it}checkAndCreateNodeType(o){if(!(o instanceof se))return;const e=o.getToken().trim();if(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"')return;let t="";if(e===He.PERCENTAGE)t=Le.DIVIDED;else return e===He.POUND?new Ua(this._currentConfigService,this._lexer,e):void 0;const r=this._functionService.getExecutor(t);return r?new Ua(this._currentConfigService,this._lexer,e,r):(console.error(`No function ${o}`),De.create(h.NAME))}};exports.SuffixNodeFactory=Ff([Zn(0,gt),Zn(1,M.Inject(exports.Lexer)),Zn(2,mt)],exports.SuffixNodeFactory);var kf=Object.defineProperty,$f=Object.getOwnPropertyDescriptor,Yf=(i,o,e,t)=>{for(var r=t>1?void 0:t?$f(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&kf(o,e,r),r},Hf=(i,o)=>(e,t)=>o(e,t,i);class Gf extends Fe{constructor(o){super(o)}get nodeType(){return ue.UNION}execute(){const o=this.getChildren(),e=o[0],t=o[1],r=e.getValue(),n=t.getValue();if(r==null||n==null)throw new Error("leftNode and rightNode");let s;this.getToken()===Q.COLON?s=this._unionFunction(r,n):s=g.create(h.NAME),this.setValue(s)}_unionFunction(o,e){return o.isError()||e.isError()||!o.isReferenceObject()||!e.isReferenceObject()?g.create(h.REF):(o=o,e=e,nf(o,e))}}exports.UnionNodeFactory=class extends ot{constructor(o){super(),this._functionService=o}get zIndex(){return at.get(ue.UNION)||it}create(o){return new Gf(o)}checkAndCreateNodeType(o){if(!(o instanceof se))return;const t=o.getToken().trim();if(!(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"')&&t===Q.COLON)return this.create(t)}};exports.UnionNodeFactory=Yf([Hf(0,gt)],exports.UnionNodeFactory);class Wf extends Fe{constructor(o){super(o)}get nodeType(){return ue.VALUE}execute(){this.setValue(lt.create(this.getToken()))}}class Bs extends ot{get zIndex(){return at.get(ue.VALUE)||it}_checkValueNode(o){if(Number.isNaN(Number(o))){const e=o.trim(),t=e.charAt(0),r=e.charAt(e.length-1);if(qt.has(e))return this.create(e);if(t==='"'&&r==='"')return this.create(e);if(t==="{"&&r==="}")return this.create(e);const n=e.toUpperCase();if(n===Ot.TRUE||n===Ot.FALSE)return this.create(n)}else return this.create(o)}create(o){return new Wf(o)}checkAndCreateNodeType(o){if(!(o instanceof se))return this._checkValueNode(o)}}var Qf=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,Xf=(i,o,e,t)=>{for(var r=t>1?void 0:t?qf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Qf(o,e,r),r},Ze=(i,o)=>(e,t)=>o(e,t,i);exports.AstTreeBuilder=class extends M.Disposable{constructor(e,t,r,n,s,a,u,c,l,f,m){super();A(this,"_astNodeFactoryList",[]);this._runtimeService=e,this._astRootNodeFactory=t,this._functionNodeFactory=r,this._lambdaNodeFactory=n,this._lambdaParameterNodeFactory=s,this._operatorNodeFactory=a,this._prefixNodeFactory=u,this._referenceNodeFactory=c,this._suffixNodeFactory=l,this._unionNodeFactory=f,this._valueNodeFactory=m,this._initializeAstNode()}dispose(){this._astNodeFactoryList.forEach(e=>{e.dispose()}),this._astNodeFactoryList=[]}parse(e){const t=new _s(Nt),r=this._parse(e,t);return e.hasDefinedNames()&&(r==null||r.setDefinedNames(e.getDefinedNames())),r}_lambdaParameterHandler(e,t){if(t.getLambdaId==null)return De.create(h.VALUE);const r=t.getLambdaId(),n=new _s(Nt),s=this._runtimeService.getFunctionDefinitionPrivacyVar(r);if(!s)return!1;const a=[...s.keys()],u=e.getChildren(),c=u.length;for(let l=0;l<c;l++){const f=u[l];if(f instanceof se){Us(f,r,s),this._parse(f,n);const d=n.getChildren()[l];d!=null&&s.set(a[l],d)}else return!1}return n.setParent(t),t}_changeLetToLambda(e){const t=e.getChildren(),r=t.length;if(r%2!==1||r===0)return;const n=new se;n.setToken(br);const s=new se;s.setToken(nr);const a=[...t];for(let c=0;c<r;c++){const l=a[c];if(!(l instanceof se))return;c%2===0?l.changeToParent(n):l.changeToParent(s)}n.addChildrenFirst(s),s.setParent(n);const u=e.getParent();return u==null||u.replaceChild(e,n),n}_parse(e,t){const r=e.getChildren(),n=r.length,s=[];let a=null;const u=e.getToken().trim().toUpperCase();if(u===lc){const f=this._changeLetToLambda(e);return f!=null?this._parse(f,t):De.create(h.ERROR)}if(u===ut){if(a=t,n===0)return new Df(Nt).setParent(t),a}else{if(u===nr){let f=this._lambdaParameterHandler(e,t);return f===!1&&(f=De.create(h.ERROR)),f}if(a=this._checkAstNode(e),a==null)return De.create(h.NAME)}const c=r[0];for(let f=0;f<n;f++){const m=r[f];if(ki(c)){if(f!==0&&f!==n-1)continue}else if(Rf(m)&&f!==n-1)continue;let d=null;if(m instanceof se){if(d=this._parse(m,a),d===a)continue}else d=this._checkAstNode(m);if(d==null)return De.create(h.NAME);if(d=pf(d),d==null)return;switch(d.nodeType){case ue.FUNCTION:{const C=d.getToken().trim().toUpperCase();mc.has(C)&&d.setForcedCalculateFunction(),s.push(d);break}case ue.LAMBDA:s.push(d);break;case ue.LAMBDA_PARAMETER:s.push(d);break;case ue.OPERATOR:{const C=s.pop(),_=s.pop();_&&_.setParent(d),C&&C.setParent(d),s.push(d);break}case ue.REFERENCE:s.push(d);break;case ue.ROOT:s.push(d);break;case ue.UNION:s.push(d);break;case ue.VALUE:s.push(d);break;case ue.PREFIX:s.push(d);break;case ue.SUFFIX:s.push(d);break}}const l=s.length;for(let f=0;f<l;f++)s[f].setParent(a);return a}_checkAstNode(e){let t=null;const r=this._astNodeFactoryList.length;for(let n=0;n<r&&(t=this._astNodeFactoryList[n].checkAndCreateNodeType(e),t==null);n++);return t==null?new _f:t}_initializeAstNode(){this._astNodeFactoryList=[this._astRootNodeFactory,this._functionNodeFactory,this._lambdaNodeFactory,this._lambdaParameterNodeFactory,this._operatorNodeFactory,this._prefixNodeFactory,this._referenceNodeFactory,this._suffixNodeFactory,this._unionNodeFactory,this._valueNodeFactory].sort(M.sortRules)}};exports.AstTreeBuilder=Xf([Ze(0,st),Ze(1,M.Inject(js)),Ze(2,M.Inject(exports.FunctionNodeFactory)),Ze(3,M.Inject(exports.LambdaNodeFactory)),Ze(4,M.Inject(Ts)),Ze(5,M.Inject(exports.OperatorNodeFactory)),Ze(6,M.Inject(exports.PrefixNodeFactory)),Ze(7,M.Inject(exports.ReferenceNodeFactory)),Ze(8,M.Inject(exports.SuffixNodeFactory)),Ze(9,M.Inject(exports.UnionNodeFactory)),Ze(10,M.Inject(Bs))],exports.AstTreeBuilder);class Hi extends M.Disposable{constructor(){super(...arguments);A(this,"_otherFormulaData",new Map);A(this,"_featureFormulaData",new Map);A(this,"_formulaData",new Map);A(this,"_definedNameMap",new Map);A(this,"_otherFormulaDataMainData",new Set);A(this,"_dependencyRTreeCache",new M.RTree);A(this,"_dependencyTreeIdLast",0)}buildDependencyTree(e,t){throw new Error("Method not implemented.")}getTreeById(e){throw new Error("Method not implemented.")}getAllTree(){throw new Error("Method not implemented.")}reset(){throw new Error("Method not implemented.")}addOtherFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}removeOtherFormulaDependency(e,t,r){throw new Error("Method not implemented.")}clearOtherFormulaDependency(e,t){throw new Error("Method not implemented.")}addFeatureFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}removeFeatureFormulaDependency(e,t,r){throw new Error("Method not implemented.")}clearFeatureFormulaDependency(e,t){throw new Error("Method not implemented.")}addFormulaDependency(e,t,r,n,s){throw new Error("Method not implemented.")}removeFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}clearFormulaDependency(e,t){throw new Error("Method not implemented.")}removeFormulaDependencyByDefinedName(e,t){throw new Error("Method not implemented.")}searchDependency(e,t){return this._dependencyRTreeCache.bulkSearch(e,t)}_restDependencyTreeId(){this._dependencyTreeIdLast=0}getOtherFormulaDependency(e,t,r){var n,s;return(s=(n=this._otherFormulaData.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}addOtherFormulaDependencyMainData(e){this._otherFormulaDataMainData.add(e)}hasOtherFormulaDataMainData(e){return this._otherFormulaDataMainData.has(e)}_removeDependencyRTreeCacheById(e,t){this._dependencyRTreeCache.removeById(e,t)}getFeatureFormulaDependency(e,t,r){var n,s;return(s=(n=this._featureFormulaData.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}getFormulaDependency(e,t,r,n){var s,a;return(a=(s=this._formulaData.get(e))==null?void 0:s.get(t))==null?void 0:a.getValue(r,n)}addDependencyRTreeCache(e){const t=[];for(let r=0;r<e.rangeList.length;r++){const n=e.rangeList[r],{unitId:s,sheetId:a,range:u}=n;t.push({unitId:s,sheetId:a,range:u,id:e.treeId})}this._dependencyRTreeCache.bulkInsert(t),this._addAllTreeMap(e)}getLastTreeId(){const e=this._dependencyTreeIdLast;return this._dependencyTreeIdLast++,e}_addAllTreeMap(e){throw new Error("Method not implemented.")}_addDefinedName(e,t,r){this._definedNameMap.has(e)||this._definedNameMap.set(e,new Map);const n=this._definedNameMap.get(e);n.has(t)||n.set(t,new Set),n.get(t).add(r)}addFormulaDependencyByDefinedName(e,t){const r=e.treeId,n=(t==null?void 0:t.getDefinedNames())||[];for(const s of n)this._addDefinedName(e.unitId,s,r)}}class Gi extends Hi{constructor(){super(...arguments);A(this,"_allTreeMap",new Map)}dispose(){this.reset()}buildDependencyTree(e,t=[]){const r=this.getAllTree();return e.length===0?(this._buildReverseDependency(r,t),r):(this._buildDependencyTree(r,e),this._buildReverseDependency(r,e),r)}_buildDependencyTree(e,t){const r=new Map;for(let n=0;n<t.length;n++){const s=t[n];r.set(s.treeId,s)}for(let n=0;n<e.length;n++){const s=e[n],a=s.toRTreeItem(),u=this._dependencyRTreeCache.bulkSearch(a);for(const c of u){const l=r.get(c);l&&s!==l&&!l.hasChildren(s.treeId)&&l.pushChildren(s)}}r.clear()}_buildReverseDependency(e,t){const r=new Map;for(let n=0;n<e.length;n++){const s=e[n];r.set(s.treeId,s)}for(let n=0;n<t.length;n++){const s=t[n],a=s.toRTreeItem(),u=this._dependencyRTreeCache.bulkSearch(a);for(const c of u){const l=r.get(c);l&&s!==l&&!l.hasChildren(s.treeId)&&l.pushChildren(s)}}r.clear()}getAllTree(){const e=[];return this._allTreeMap.forEach(t=>{t.resetState(),e.push(t)}),e}getTreeById(e){return this._allTreeMap.get(e)}reset(){this._otherFormulaData.clear(),this._featureFormulaData.clear(),this._formulaData.clear(),this._dependencyRTreeCache.clear(),this._allTreeMap.clear(),this._restDependencyTreeId(),this._otherFormulaDataMainData.clear()}addOtherFormulaDependency(e,t,r,n){this._otherFormulaData.has(e)||this._otherFormulaData.set(e,new Map);const s=this._otherFormulaData.get(e);s.has(t)||s.set(t,new Map);const a=s.get(t);a.has(r)||a.set(r,new M.ObjectMatrix),a.get(r).setValue(n.refOffsetX,n.refOffsetY,n.treeId),this._addAllTreeMap(n)}removeOtherFormulaDependency(e,t,r){const n=this._otherFormulaData.get(e);if(n&&n.has(t)){const s=n.get(t);r.forEach(a=>{const u=s.get(a);u!=null&&(u.forValue((c,l,f)=>{this._removeDependencyRTreeCache(f),this.clearDependencyForTree(this._allTreeMap.get(f)),this._removeAllTreeMap(f)}),s.delete(a),this._otherFormulaDataMainData.delete(a))}),s.size===0&&n.delete(t),n.size===0&&this._otherFormulaData.delete(e)}}clearOtherFormulaDependency(e,t){const r=this._otherFormulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t);for(const s of n.keys()){const a=n.get(s);a!=null&&(a.forValue((u,c,l)=>{const f=this._allTreeMap.get(l);f&&(this.clearDependencyForTree(f),this._removeAllTreeMap(l))}),this._otherFormulaDataMainData.delete(s))}n.clear()}else if(r){for(const n of r.keys()){const s=r.get(n);this._removeDependencyRTreeCacheById(e,n);for(const a of s.keys()){const u=s.get(a);u!=null&&(u.forValue((c,l,f)=>{const m=this._allTreeMap.get(f);m&&(this.clearDependencyForTree(m),this._removeAllTreeMap(f))}),this._otherFormulaDataMainData.delete(a))}}this._otherFormulaData.delete(e)}}addFeatureFormulaDependency(e,t,r,n){this._featureFormulaData.has(e)||this._featureFormulaData.set(e,new Map);const s=this._featureFormulaData.get(e);s.has(t)||s.set(t,new Map),s.get(t).set(r,n.treeId),this._addAllTreeMap(n)}removeFeatureFormulaDependency(e,t,r){const n=this._featureFormulaData.get(e);if(n&&n.has(t)){const s=n.get(t);r.forEach(a=>{const u=s.get(a);u!=null&&(this._removeDependencyRTreeCache(u),s.delete(a),this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u))})}}clearFeatureFormulaDependency(e,t){const r=this._featureFormulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t),n.forEach(s=>{s!=null&&(this.clearDependencyForTree(this._allTreeMap.get(s)),this._removeAllTreeMap(s))}),n.clear()}else r&&(r.forEach((n,s)=>{this._removeDependencyRTreeCacheById(e,s),n.forEach(a=>{a!=null&&(this.clearDependencyForTree(this._allTreeMap.get(a)),this._removeAllTreeMap(a))})}),this._featureFormulaData.delete(e))}addFormulaDependency(e,t,r,n,s){this._formulaData.has(e)||this._formulaData.set(e,new Map);const a=this._formulaData.get(e);a.has(t)||a.set(t,new M.ObjectMatrix),a.get(t).setValue(r,n,s.treeId),this._addAllTreeMap(s)}removeFormulaDependency(e,t,r,n){const s=this._formulaData.get(e);if(s&&s.has(t)){const a=s.get(t),u=a.getValue(r,n);if(u==null)return;this._removeDependencyRTreeCache(u),a.realDeleteValue(r,n),this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u)}}clearFormulaDependency(e,t){const r=this._formulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t),n.forValue((s,a,u)=>{if(u==null)return!0;this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u)}),n.reset()}else r&&(r.forEach((n,s)=>{this._removeDependencyRTreeCacheById(e,s),n.forValue((a,u,c)=>{if(c==null)return!0;this.clearDependencyForTree(this._allTreeMap.get(c)),this._removeAllTreeMap(c)})}),this._formulaData.delete(e))}clearDependencyForTree(e){if(e==null)return;const t=e.parents,r=e.children,n=this._allTreeMap;for(const s of t){const a=n.get(s);a==null||a.children.delete(e.treeId)}for(const s of r){const a=n.get(s);a==null||a.parents.delete(e.treeId)}e.dispose()}_removeDependencyRTreeCache(e){if(e==null)return;const t=this._allTreeMap.get(e);if(t){const r=[];for(let n=0;n<t.rangeList.length;n++){const s=t.rangeList[n],{unitId:a,sheetId:u,range:c}=s;r.push({unitId:a,sheetId:u,range:c,id:e})}this._dependencyRTreeCache.bulkRemove(r)}}removeFormulaDependencyByDefinedName(e,t){const r=this._definedNameMap.get(e);if(r){const n=r.get(t);if(n){for(const s of n)this._removeDependencyRTreeCache(s),this.clearDependencyForTree(this._allTreeMap.get(s)),this._removeAllTreeMap(s);n.clear()}}}_removeAllTreeMap(e){e!=null&&this._allTreeMap.delete(e)}_addAllTreeMap(e){this._allTreeMap.set(e.treeId,e)}}const wr=M.createIdentifier("univer.formula.dependency-manager.service");class Wi extends M.Disposable{constructor(){super(...arguments);A(this,"_referenceExecutorMap",new Map);A(this,"_onChanged$",new Jt.Subject);A(this,"onChanged$",this._onChanged$.asObservable())}dispose(){this._referenceExecutorMap.clear()}remove(e,t,r){r.forEach(n=>{var s,a;(a=(s=this._referenceExecutorMap.get(e))==null?void 0:s.get(t))==null||a.delete(n)}),this._onChanged$.next({unitId:e,subUnitId:t,featureIds:r})}get(e,t,r){var n,s;return(s=(n=this._referenceExecutorMap.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}has(e,t,r){var n,s;return!!((s=(n=this._referenceExecutorMap.get(e))==null?void 0:n.get(t))!=null&&s.has(r))}register(e,t,r,n){let s=this._referenceExecutorMap.get(e);s||(s=new Map,this._referenceExecutorMap.set(e,s));let a=s.get(t);a||(a=new Map,s.set(t,a)),this._onChanged$.next({unitId:e,subUnitId:t,featureIds:[r]}),a.set(r,n)}getReferenceExecutorMap(){return this._referenceExecutorMap}}const ar=M.createIdentifier("univer.formula.feature-calculation-manager.service");class Qi extends M.Disposable{constructor(){super(...arguments);A(this,"_otherFormulaData",{})}dispose(){this._otherFormulaData={}}remove(e){var s,a,u;const{unitId:t,subUnitId:r,formulaId:n}=e;(u=(a=(s=this._otherFormulaData)==null?void 0:s[t])==null?void 0:a[r])==null||delete u[n]}get(e){var s,a;const{unitId:t,subUnitId:r,formulaId:n}=e;return(a=(s=this._otherFormulaData[t])==null?void 0:s[r])==null?void 0:a[n]}has(e){var s,a;const{unitId:t,subUnitId:r,formulaId:n}=e;return((a=(s=this._otherFormulaData[t])==null?void 0:s[r])==null?void 0:a[n])!=null}register(e){const{unitId:t,subUnitId:r,formulaId:n,item:s}=e;this._otherFormulaData[t]||(this._otherFormulaData[t]={}),this._otherFormulaData[t][r]||(this._otherFormulaData[t][r]={}),this._otherFormulaData[t][r][n]=s}batchRegister(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{const s=r[n];if(s==null)return!0;Object.keys(s).forEach(a=>{const u=s[a];if(u==null)return!0;this.register({unitId:t,subUnitId:n,formulaId:a,item:u})})})})}batchRemove(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{const s=r[n];if(s==null)return!0;Object.keys(s).forEach(a=>{this.remove({unitId:t,subUnitId:n,formulaId:a})})})})}getOtherFormulaData(){return this._otherFormulaData}}const vn=M.createIdentifier("univer.formula.other-formula-manager.service"),Kf=5e3,va=new ft(Kf);function As(i,o,e,t,r){let n=va.get(`${i}${o}`);if(n&&!qi(n,r))return n;const s=e.treeBuilder(o);if(qt.has(s))return De.create(s);if(n=t.parse(s),n==null)throw new Error("astNode is null");return va.set(`${i}${o}`,n),n}function qi(i,o){const e=o.getDirtyDefinedNameMap(),t=o.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++){const a=r[n];if(i.hasDefinedName(a))return!0}}return!1}function Zf(i,o,e){return!!(o!=null&&qi(o,e))}var on=(i=>(i[i.NORMAL_FORMULA=0]="NORMAL_FORMULA",i[i.OTHER_FORMULA=1]="OTHER_FORMULA",i[i.FEATURE_FORMULA=2]="FEATURE_FORMULA",i))(on||{});class Xi{constructor(){A(this,"_state",0);A(this,"treeId");A(this,"children",new Set);A(this,"parents",new Set)}resetState(){this._state=0}setAdded(){this._state=1}isAdded(){return this._state===1}setSkip(){this._state=2}isSkip(){return this._state===2}pushChildren(o){this.children.add(o.treeId),o._pushParent(this)}hasChildren(o){return this.children.has(o)}_pushParent(o){this.parents.add(o.treeId)}}class Es extends Xi{constructor(){super(...arguments);A(this,"refTree");A(this,"refOffsetX",-1);A(this,"refOffsetY",-1);A(this,"isCache",!1);A(this,"isDirty",!1);A(this,"getDirtyData");A(this,"featureId")}get isVirtual(){return!0}get row(){return this.refTree==null?-1:this.refTree.row+this.refOffsetY}get column(){return this.refTree==null?-1:this.refTree.column+this.refOffsetX}get rowCount(){return this.refTree==null?0:this.refTree.rowCount}get columnCount(){return this.refTree==null?0:this.refTree.columnCount}get unitId(){return this.refTree==null?"":this.refTree.unitId}get subUnitId(){return this.refTree==null?"":this.refTree.subUnitId}get formula(){var e,t;return(t=(e=this.refTree)==null?void 0:e.formula)!=null?t:""}get nodeData(){return{node:this.node,refOffsetX:this.refOffsetX,refOffsetY:this.refOffsetY}}get node(){var e;return(e=this.refTree)==null?void 0:e.node}dispose(){this.refTree=null}get rangeList(){const e=[];if(this.refTree==null)return[];for(let t=0;t<this.refTree.rangeList.length;t++){const r=this.refTree.rangeList[t];e.push({unitId:r.unitId,sheetId:r.sheetId,range:M.moveRangeByOffset(r.range,this.refOffsetX,this.refOffsetY)})}return e}toRTreeItem(){const e=this.row,t=this.column;return[{unitId:this.unitId,sheetId:this.subUnitId,range:{startRow:e,startColumn:t,endRow:e,endColumn:t}}]}inRangeData(e){const t=e.startRow,r=e.startColumn,n=e.endRow,s=e.endColumn,a=this.row,u=this.column;return!(a<t||a>n||u<r||u>s)}dependencySheetName(e){return this.refTree==null?!1:this.refTree.dependencySheetName(e)}isExcludeRange(e){var r;const t=this.rangeList;if(t.length===0)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c,range:l}=a,f=(r=e==null?void 0:e[u])==null?void 0:r[c];let{startRow:m,endRow:d,startColumn:C,endColumn:_}=l;Number.isNaN(m)&&(m=0),Number.isNaN(C)&&(C=0),Number.isNaN(d)&&(d=Number.POSITIVE_INFINITY),Number.isNaN(_)&&(_=Number.POSITIVE_INFINITY);let E=!1;if(f==null||f.forValue((b,R)=>{if(b>=m&&b<=d&&R>=C&&R<=_)return E=!0,!1}),E)return!0}return!1}get formulaId(){return this.refTree==null?"":this.refTree.formulaId}}class Wr extends Xi{constructor(e){super();A(this,"isCache",!1);A(this,"featureId");A(this,"featureDirtyRanges",[]);A(this,"refOffsetX",0);A(this,"refOffsetY",0);A(this,"type",0);A(this,"formulaId");A(this,"subUnitId","");A(this,"unitId","");A(this,"rangeList",[]);A(this,"formula","");A(this,"row",-1);A(this,"column",-1);A(this,"rowCount",Number.NEGATIVE_INFINITY);A(this,"columnCount",Number.NEGATIVE_INFINITY);A(this,"isDirty",!1);A(this,"node");A(this,"getDirtyData");this.treeId=e}get isVirtual(){return!1}get nodeData(){return{node:this.node,refOffsetX:0,refOffsetY:0}}toJson(){return{formula:this.formula,refOffsetX:this.refOffsetX,refOffsetY:this.refOffsetY}}dispose(){this.featureDirtyRanges=[],this.rangeList=[],this.getDirtyData=null}inRangeData(e){const t=e.startRow,r=e.startColumn,n=e.endRow,s=e.endColumn,a=this.row,u=this.column;return!(a<t||a>n||u<r||u>s)}dependencySheetName(e){var r;const t=this.rangeList;if(t.length===0||e==null)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c}=a;if(((r=e[u])==null?void 0:r[c])!=null)return!0}return!1}isExcludeRange(e){var r;const t=this.rangeList;if(t.length===0)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c,range:l}=a,f=(r=e==null?void 0:e[u])==null?void 0:r[c];let{startRow:m,endRow:d,startColumn:C,endColumn:_}=l;Number.isNaN(m)&&(m=0),Number.isNaN(C)&&(C=0),Number.isNaN(d)&&(d=Number.POSITIVE_INFINITY),Number.isNaN(_)&&(_=Number.POSITIVE_INFINITY);let E=!1;if(f==null||f.forValue((b,R)=>{if(b>=m&&b<=d&&R>=C&&R<=_)return E=!0,!1}),E)return!0}return!1}pushRangeList(e){this.rangeList.push(...e)}shouldBePushRangeList(){return this.rangeList.length===0&&this.type!==2}toRTreeItem(){if(this.featureId!=null)return this.featureDirtyRanges;const e=this.row,t=this.column;return[{unitId:this.unitId,sheetId:this.subUnitId,range:{startRow:e,startColumn:t,endRow:e,endColumn:t}}]}}var zf=Object.defineProperty,Jf=Object.getOwnPropertyDescriptor,em=(i,o,e,t)=>{for(var r=t>1?void 0:t?Jf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&zf(o,e,r),r},_t=(i,o)=>(e,t)=>o(e,t,i);function vt(i){return i.getLastTreeId()||0}const un=M.createIdentifier("engine-formula.dependency-generator");exports.FormulaDependencyGenerator=class extends M.Disposable{constructor(e,t,r,n,s,a,u,c){super();A(this,"_updateRangeFlattenCache",new Map);this._currentConfigService=e,this._runtimeService=t,this._otherFormulaManagerService=r,this._featureCalculationManagerService=n,this._interpreter=s,this._astTreeBuilder=a,this._lexer=u,this._dependencyManagerService=c}dispose(){this._updateRangeFlattenCache.clear()}async generate(){this._updateRangeFlatten();const e=this._currentConfigService.getFormulaData(),t=this._otherFormulaManagerService.getOtherFormulaData(),r=this._currentConfigService.getClearDependencyTreeCache();r!=null&&Object.keys(r).forEach(f=>{f!=null&&Object.keys(r[f]).forEach(m=>{m!=null&&(this._dependencyManagerService.clearOtherFormulaDependency(f,m),this._dependencyManagerService.clearFeatureFormulaDependency(f,m),this._dependencyManagerService.clearFormulaDependency(f,m))})});const n=this._currentConfigService.getUnitData(),s=await this._generateTreeList(e,t,n),a=this._getUpdateTreeListAndMakeDependency(s);let u=this._calculateRunList(a);return this._dependencyFeatureCalculation(u)&&(u.forEach(f=>{f.resetState()}),u=this._calculateRunList(u)),this._checkIsCycleDependency(u)&&this._runtimeService.enableCycleDependency(),Promise.resolve(u)}_dependencyFeatureCalculation(e){const t=this._featureCalculationManagerService.getReferenceExecutorMap();if(t.size===0)return;this._clearFeatureCalculationNode(e);let r=!1;return t.forEach((n,s)=>{n.forEach((a,u)=>{a.forEach((c,l)=>{const{unitId:f,subUnitId:m,getDirtyData:d}=c,C=d(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData()),_=this._convertDirtyRangesToUnitRange(C.dirtyRanges),E=this._intersectFeatureCalculation(_,e,{unitId:f,subUnitId:m,featureId:l});if(E.length>0){let b=this._getExistTreeList({unitId:f,subUnitId:m,featureId:l},e);b==null&&(b=this._getFeatureFormulaTree(l,vt(this._dependencyManagerService),c),e.push(b)),b.parents=new Set,E.forEach(R=>{R.hasChildren(b.treeId)||R.pushChildren(b)}),r=!0}})})}),r}_clearFeatureCalculationNode(e){const t=this._featureCalculationManagerService.getReferenceExecutorMap();e.forEach(r=>{var a,u,c,l;const n=new Set;for(const f of r.children){const m=this._dependencyManagerService.getTreeById(f);m&&(m.featureId&&(u=(a=t.get(r.unitId))==null?void 0:a.get(r.subUnitId))!=null&&u.has(m.featureId)||n.add(f))}r.children=n;const s=new Set;for(const f of r.parents){const m=this._dependencyManagerService.getTreeById(f);m&&(m.featureId&&(l=(c=t.get(r.unitId))==null?void 0:c.get(r.subUnitId))!=null&&l.has(m.featureId)||s.add(f))}r.parents=s})}_convertDirtyRangesToUnitRange(e){const t=[];for(const r in e){const n=e[r];for(const s in n){const a=n[s];for(const u of a)t.push({unitId:r,sheetId:s,range:u})}}return t}_intersectFeatureCalculation(e,t,r){const n=[],s=this._dependencyManagerService.searchDependency(e);for(let a=0,u=t.length;a<u;a++){const c=t[a];if(c.unitId===r.unitId&&c.subUnitId===r.subUnitId&&c.featureId===r.featureId)continue;s.has(c.treeId)&&n.push(c)}return n}_getExistTreeList(e,t){const{unitId:r,subUnitId:n,featureId:s}=e;for(let a=0,u=t.length;a<u;a++){const c=t[a];if(c.unitId===r&&c.subUnitId===n&&c.featureId===s)return c}}_isCyclicUtil(e,t,r){const n=this._dependencyManagerService.getTreeById(e);if(n==null)return!1;if(!t.has(n.treeId)){t.add(n.treeId),r.add(n.treeId);for(const s of n.children)if(!t.has(s)&&this._isCyclicUtil(s,t,r)||r.has(s))return!0}return r.delete(n.treeId),!1}_checkIsCycleDependency(e){const t=new Set,r=new Set;for(let n=0,s=e.length;n<s;n++){const a=e[n];if(this._isCyclicUtil(a.treeId,t,r)===!0)return!0}return!1}async _generateTreeList(e,t,r){const n=Object.keys(e),s=Object.keys(t),a=[];this._currentConfigService.isForceCalculate()&&this._dependencyManagerService.reset(),this._registerFormulas(n,e,r,a),this._registerOtherFormulas(t,s,a),this._registerFeatureFormulas(a);for(let c=0,l=a.length;c<l;c++){const f=a[c],m=f.node;if(m==null||(f.isDirty=this._includeTree(f,m),f.isVirtual))continue;this._runtimeService.setCurrent(f.row,f.column,f.rowCount,f.columnCount,f.subUnitId,f.unitId);const d=await this._getRangeListByNode({node:m,refOffsetX:f.refOffsetX,refOffsetY:f.refOffsetY});f.pushRangeList(d)}for(let c=0,l=a.length;c<l;c++){const f=a[c];f.isCache||this._dependencyManagerService.addDependencyRTreeCache(f)}return a}_registerFeatureFormulas(e){this._featureCalculationManagerService.getReferenceExecutorMap().forEach((r,n)=>{r.forEach((s,a)=>{s.forEach((u,c)=>{const l=this._dependencyManagerService.getFeatureFormulaDependency(u.unitId,u.subUnitId,c);e.push(this._getFeatureFormulaTree(c,l,u))})})})}_getFeatureFormulaTree(e,t,r){const{unitId:n,subUnitId:s,dependencyRanges:a,getDirtyData:u}=r,c=t||vt(this._dependencyManagerService),l=new Wr(c);l.unitId=n,l.subUnitId=s,l.rangeList=a,l.getDirtyData=u;const f=u(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData()),m=this._convertDirtyRangesToUnitRange(f.dirtyRanges);return l.featureDirtyRanges=m,l.featureId=e,l.type=on.FEATURE_FORMULA,this._dependencyManagerService.addFeatureFormulaDependency(n,s,e,l),this._dependencyManagerService.getFeatureFormulaDependency(r.unitId,r.subUnitId,e)&&(l.isCache=!0),l}_registerOtherFormulas(e,t,r){for(const n of t){const s=e[n];if(s==null)continue;const a=Object.keys(s);for(const u of a){const c=s[u];if(c==null)continue;const l=Object.keys(c);for(const f of l){const m=this._dependencyManagerService.hasOtherFormulaDataMainData(f),d=c[f],{f:C,ranges:_}=d;let E=!1;m&&(E=!0);const b=As(n,C,this._lexer,this._astTreeBuilder,this._currentConfigService),{firstRow:R,firstColumn:p}=this._getFirstCellOfRange(_),V=this._dependencyManagerService.getOtherFormulaDependency(n,u,f),S=(V==null?void 0:V.getValue(0,0))||vt(this._dependencyManagerService),D=new Wr(S);for(let w=0;w<_.length;w++){const P=_[w],{startRow:L,startColumn:T,endRow:B,endColumn:W}=P;for(let q=L;q<=B;q++)for(let ie=T;ie<=W;ie++){const Z=ie-p,G=q-R;if(Z===0&&G===0){D.node=b,D.formula=C,D.unitId=n,D.subUnitId=u,D.formulaId=f,D.type=on.OTHER_FORMULA,D.isCache=E,r.push(D),this._dependencyManagerService.addOtherFormulaDependency(n,u,f,D),this._dependencyManagerService.addFormulaDependencyByDefinedName(D);continue}const ce=new Es;ce.treeId=(V==null?void 0:V.getValue(Z,G))||vt(this._dependencyManagerService),ce.refTree=D,ce.refOffsetX=Z,ce.refOffsetY=G,ce.isCache=E,this._dependencyManagerService.addOtherFormulaDependency(n,u,f,ce),this._dependencyManagerService.addFormulaDependencyByDefinedName(ce),r.push(ce)}}this._dependencyManagerService.addOtherFormulaDependencyMainData(f)}}}}_getFirstCellOfRange(e){const t=e[0];return{firstRow:t.startRow,firstColumn:t.startColumn}}_registerFormulas(e,t,r,n){for(const s of e){const a=t[s];if(a==null)continue;const u=Object.keys(a);for(const c of u){const l=new M.ObjectMatrix(a[c]||{}),f=new Map;l.forValue((m,d,C)=>{if(C==null)return!0;const{x:_=0,y:E=0,si:b}=C;if(!(_===0&&E===0&&b!=null))return!0;const R=this._createFDtree(s,c,m,d,r,C),p=this._dependencyManagerService.getFormulaDependency(s,c,m,d);p!=null?R.treeId=p:(this._dependencyManagerService.addFormulaDependency(s,c,m,d,R),this._dependencyManagerService.addFormulaDependencyByDefinedName(R)),f.set(b,R),n.push(R)}),l.forValue((m,d,C)=>{if(C==null)return!0;const{x:_=0,y:E=0,si:b}=C;if(_===0&&E===0&&b!=null)return!0;let R;if(b&&f.has(b)){const V=f.get(b);R=this._createVirtualFDtree(V,C)}else R=this._createFDtree(s,c,m,d,r,C);const p=this._dependencyManagerService.getFormulaDependency(s,c,m,d);p!=null?R.treeId=p:(this._dependencyManagerService.addFormulaDependency(s,c,m,d,R),this._dependencyManagerService.addFormulaDependencyByDefinedName(R)),n.push(R)}),f.clear()}}}_createFDtree(e,t,r,n,s,a){const{f:u,x:c=0,y:l=0}=a,f=new Wr(vt(this._dependencyManagerService)),m=s[e][t],d=As(e,u,this._lexer,this._astTreeBuilder,this._currentConfigService);return f.node=d,f.formula=u,f.unitId=e,f.subUnitId=t,f.row=r,f.column=n,f.rowCount=m.rowCount,f.columnCount=m.columnCount,f}_createVirtualFDtree(e,t){const{x:r=0,y:n=0}=t,s=new Es;return s.treeId=vt(this._dependencyManagerService),s.refTree=e,s.refOffsetX=r,s.refOffsetY=n,s}_updateRangeFlatten(){const e=this._currentConfigService.isForceCalculate(),t=this._currentConfigService.getDirtyRanges();if(!e){this._updateRangeFlattenCache.clear();for(let r=0;r<t.length;r++){const n=t[r],s=n.range,a=n.sheetId,u=n.unitId;this._addFlattenCache(u,a,s)}}}_addFlattenCache(e,t,r){let n=this._updateRangeFlattenCache.get(e);n==null&&(n=new Map,this._updateRangeFlattenCache.set(e,n));let s=n.get(t);s==null&&(s=[],n.set(t,s)),s.push(r)}_isPreCalculateNode(e){return e.nodeType===ue.UNION||e.nodeType===ue.PREFIX&&e.getToken()===pe.AT||e.nodeType===ue.SUFFIX&&e.getToken()===He.POUND}_nodeTraversalRef(e,t){const r=e.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(this._isPreCalculateNode(a)){t.push(a);continue}else a.nodeType===ue.REFERENCE&&t.push(a);this._nodeTraversalRef(a,t)}}_nodeTraversalReferenceFunction(e,t){const r=e.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.nodeType===ue.FUNCTION&&a.isAddress()){t.push(a);continue}this._nodeTraversalReferenceFunction(a,t)}}async _executeNode(e,t=0,r=0){let n;const s={node:e,refOffsetX:t,refOffsetY:r};return this._interpreter.checkAsyncNode(e)?n=await this._interpreter.executeAsync(s):n=this._interpreter.execute(s),n}async _getRangeListByNode(e){const t=[],r=[],n=e.refOffsetX,s=e.refOffsetY,a=e.node;if(a==null)return[];this._nodeTraversalRef(a,t),this._nodeTraversalReferenceFunction(a,r);const u=[];for(let c=0,l=t.length;c<l;c++){const f=t[c],d=(await this._executeNode(f,n,s)).toUnitRange();u.push(d),f.setValue(null)}for(let c=0,l=r.length;c<l;c++){const f=r[c],d=(await this._executeNode(f,n,s)).toUnitRange();u.push(d),f.setValue(null)}return u}_getUpdateTreeListAndMakeDependency(e){const t=[],r=new Set,n=this._currentConfigService.isForceCalculate(),s=this._currentConfigService.getDirtyRanges(),a=this._dependencyManagerService.searchDependency(s),u=this._dependencyManagerService.buildDependencyTree(e);for(const c of u){const l=c.treeId;(n||c.isDirty||c.dependencySheetName(this._currentConfigService.getDirtyNameMap())||a.has(l)&&!c.isExcludeRange(this._currentConfigService.getExcludedRange()))&&!r.has(l)&&(t.push(c),r.add(l))}return t}_includeTreeFeature(e){var s,a;const t=e.unitId,r=e.subUnitId,n=e.featureId;if(n!=null){const u=this._currentConfigService.getDirtyUnitFeatureMap();if(((a=(s=u==null?void 0:u[t])==null?void 0:s[r])==null?void 0:a[n])!=null)return!0}return!1}_includeOtherFormula(e){var s,a;const t=e.unitId,r=e.subUnitId,n=e.formulaId;if(n!=null){const u=this._currentConfigService.getDirtyUnitOtherFormulaMap();if(((a=(s=u==null?void 0:u[t])==null?void 0:s[r])==null?void 0:a[n])!=null)return!0}return!1}_detectForcedRecalculationNode(e,t){return t==null?!1:this._detectForcedRecalculationNodeRecursion(t)}_detectForcedRecalculationNodeRecursion(e){if(e.isForcedCalculateFunction())return!0;const t=e.getChildren();for(let r=0,n=t.length;r<n;r++){const s=t[r];if(this._detectForcedRecalculationNodeRecursion(s))return!0}return!1}_includeTree(e,t){var l,f,m;const r=e.unitId,n=e.subUnitId;if(this._detectForcedRecalculationNode(e,t)===!0||this._includeTreeFeature(e)===!0||this._includeOtherFormula(e)===!0||Zf(e,t,this._currentConfigService)===!0)return!0;const s=(f=(l=this._currentConfigService.getExcludedRange())==null?void 0:l[r])==null?void 0:f[n];if((s==null?void 0:s.getValue(e.row,e.column))!=null)return!1;if(((m=this._currentConfigService.getDirtyNameMap()[r])==null?void 0:m[n])!=null)return!0;if(!this._updateRangeFlattenCache.has(r))return!1;const u=this._updateRangeFlattenCache.get(r);if(!u.has(n))return!1;const c=u.get(n);for(const d of c)if(e.inRangeData(d))return!0;return!1}_calculateRunList(e){const t=e,r=[],n=[];for(;t.length>0;){const s=t.pop();if(!(s===void 0||s.isSkip())){if(s.isAdded()){r.push(s),s.setSkip();continue}n.length=0;for(const a of s.parents){const u=this._dependencyManagerService.getTreeById(a);if(!u)throw new Error("ParentDependencyTree object is null");u.isAdded()||s.isSkip()||n.push(u)}n.length===0?(r.push(s),s.setSkip()):(s.setAdded(),t.push(s,...n))}}return r}};exports.FormulaDependencyGenerator=em([_t(0,mt),_t(1,st),_t(2,vn),_t(3,ar),_t(4,M.Inject(exports.Interpreter)),_t(5,M.Inject(exports.AstTreeBuilder)),_t(6,M.Inject(exports.Lexer)),_t(7,wr)],exports.FormulaDependencyGenerator);var tm=Object.defineProperty,rm=Object.getOwnPropertyDescriptor,nm=(i,o,e,t)=>{for(var r=t>1?void 0:t?rm(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&tm(o,e,r),r},jt=(i,o)=>(e,t)=>o(e,t,i);const sm=1,Ki=500,cn=M.createIdentifier("engine-formula.calculate-formula.service");exports.CalculateFormulaService=class extends M.Disposable{constructor(e,t,r,n,s,a,u){super();A(this,"_executionInProgressListener$",new Jt.Subject);A(this,"executionInProgressListener$",this._executionInProgressListener$.asObservable());A(this,"_executionCompleteListener$",new Jt.Subject);A(this,"executionCompleteListener$",this._executionCompleteListener$.asObservable());this._configService=e,this._lexer=t,this._currentConfigService=r,this._runtimeService=n,this._formulaDependencyGenerator=s,this._interpreter=a,this._astTreeBuilder=u}stopFormulaExecution(){this._runtimeService.stopExecution()}setRuntimeFeatureCellData(e,t){this._runtimeService.setRuntimeFeatureCellData(e,t)}setRuntimeFeatureRange(e,t){this._runtimeService.setRuntimeFeatureRange(e,t)}async execute(e){this._runtimeService.setFormulaExecuteStage(ze.START),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._currentConfigService.load(e),this._runtimeService.reset();const t=this._configService.getConfig("CYCLE_REFERENCE_COUNT")||sm;for(let r=0;r<t&&(this._runtimeService.setFormulaCycleIndex(r),await this._execute(),Cs.clear(),!!this._runtimeService.isCycleDependency());r++);this._runtimeService.setFormulaExecuteStage(ze.CALCULATION_COMPLETED),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData()),Et.clear(),this._runtimeService.reset()}async _execute(){const e=await this._apply();if(e==null)return;const{arrayFormulaRange:t,runtimeFeatureRange:r}=e,{dirtyRanges:n,excludedCell:s}=this._getArrayFormulaDirtyRangeAndExcludedRange(t,r);return n==null||n.length===0||(this._currentConfigService.loadDirtyRangesAndExcludedCell(n,s),await this._apply(!0)),!0}_getArrayFormulaDirtyRangeAndExcludedRange(e,t){const r=[],n={};return Object.keys(e).forEach(s=>{const a=e[s];if(a==null)return!0;Object.keys(a).forEach(u=>{const c=new M.ObjectMatrix(a[u]);if(c==null)return!0;const l=new M.ObjectMatrix;c.forValue((f,m,d)=>{l.setValue(f,m,!0),r.push({unitId:s,sheetId:u,range:d})}),n[s]==null&&(n[s]={}),n[s][u]=l})}),Object.keys(t).forEach(s=>{const a=t[s];Object.keys(a).forEach(u=>{const c=a[u];if(c==null)return!0;Object.keys(c).forEach(l=>{const f=c[l];if(f==null)return!0;for(const m of f)r.push({unitId:u,sheetId:l,range:m})})})}),{dirtyRanges:r,excludedCell:n}}async _apply(e=!1){e?this._runtimeService.setFormulaExecuteStage(ze.START_DEPENDENCY_ARRAY_FORMULA):this._runtimeService.setFormulaExecuteStage(ze.START_DEPENDENCY),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());const t=(await this._formulaDependencyGenerator.generate()).reverse(),r=this._interpreter;e?(this._runtimeService.setFormulaExecuteStage(ze.START_CALCULATION_ARRAY_FORMULA),this._runtimeService.setTotalArrayFormulasToCalculate(t.length)):(this._runtimeService.setFormulaExecuteStage(ze.START_CALCULATION),this._runtimeService.setTotalFormulasToCalculate(t.length)),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());let n=[];const s=this._configService.getConfig(On),a=(s==null?void 0:s.intervalCount)||Ki,u=t.length;for(let c=0;c<u;c++){const l=t[c],f=l.nodeData,m=l.getDirtyData;if(c%a===0&&(await new Promise(C=>{const _=M.requestImmediateMacroTask(C);n.push(_)}),e?(this._runtimeService.setFormulaExecuteStage(ze.CURRENTLY_CALCULATING_ARRAY_FORMULA),this._runtimeService.setCompletedArrayFormulasCount(c+1)):(this._runtimeService.setFormulaExecuteStage(ze.CURRENTLY_CALCULATING),this._runtimeService.setCompletedFormulasCount(c+1)),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._runtimeService.isStopExecution()||f==null&&m==null)){this._runtimeService.setFormulaExecuteStage(ze.IDLE),this._runtimeService.markedAsStopFunctionsExecuted(),this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData());return}this._runtimeService.setCurrent(l.row,l.column,l.rowCount,l.columnCount,l.subUnitId,l.unitId);let d;if(m!=null&&l.featureId!=null){const{runtimeCellData:C,dirtyRanges:_}=m(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData());this._runtimeService.setRuntimeFeatureCellData(l.featureId,C),this._runtimeService.setRuntimeFeatureRange(l.featureId,_)}else f!=null&&(r.checkAsyncNode(f.node)?d=await r.executeAsync(f):d=r.execute(f),l.formulaId!=null?this._runtimeService.setRuntimeOtherData(l.formulaId,l.refOffsetX,l.refOffsetY,d):this._runtimeService.setRuntimeData(d))}return n.forEach(c=>c()),n=[],u>0?this._runtimeService.markedAsSuccessfullyExecuted():e||this._runtimeService.markedAsNoFunctionsExecuted(),this._runtimeService.getAllRuntimeData()}calculate(e,t=!0){const r=this._lexer.treeBuilder(e,t);if(Object.values(h).includes(r))return De.create(r);const n=this._astTreeBuilder.parse(r);n==null||n.serialize()}};exports.CalculateFormulaService=nm([jt(0,M.IConfigService),jt(1,M.Inject(exports.Lexer)),jt(2,mt),jt(3,st),jt(4,un),jt(5,M.Inject(exports.Interpreter)),jt(6,M.Inject(exports.AstTreeBuilder))],exports.CalculateFormulaService);var am=Object.defineProperty,im=Object.getOwnPropertyDescriptor,om=(i,o,e,t)=>{for(var r=t>1?void 0:t?im(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&am(o,e,r),r},zn=(i,o)=>(e,t)=>o(e,t,i);exports.CalculateController=class extends M.Disposable{constructor(o,e,t){super(),this._commandService=o,this._calculateFormulaService=e,this._formulaDataModel=t,this._initialize()}_initialize(){this._commandExecutedListener(),this._initialExecuteFormulaListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(o.id===Ns.id)this._calculateFormulaService.stopFormulaExecution();else if(o.id===Rn.id){const e=o.params.formulaData;this._formulaDataModel.mergeFormulaData(e)}else if(o.id===ps.id){const e=o.params;this._calculate(e)}else if(o.id===Zr.id){const e=o.params;if(e==null)return;const{arrayFormulaRange:t,arrayFormulaCellData:r}=e;this._formulaDataModel.setArrayFormulaRange(t),this._formulaDataModel.setArrayFormulaCellData(r)}}))}async _calculate(o){const{forceCalculation:e=!1,dirtyRanges:t=[],dirtyNameMap:r={},dirtyDefinedNameMap:n={},dirtyUnitFeatureMap:s={},dirtyUnitOtherFormulaMap:a={},clearDependencyTreeCache:u={}}=o,c=this._formulaDataModel.getFormulaData(),l=this._formulaDataModel.getArrayFormulaCellData(),f=this._formulaDataModel.getArrayFormulaRange();this._calculateFormulaService.execute({formulaData:c,arrayFormulaCellData:l,arrayFormulaRange:f,forceCalculate:e,dirtyRanges:t,dirtyNameMap:r,dirtyDefinedNameMap:n,dirtyUnitFeatureMap:s,dirtyUnitOtherFormulaMap:a,clearDependencyTreeCache:u})}_initialExecuteFormulaListener(){this._calculateFormulaService.executionCompleteListener$.subscribe(o=>{const e=o.functionsExecutedState;switch(e){case zt.NOT_EXECUTED:break;case zt.STOP_EXECUTION:break;case zt.SUCCESS:this._applyResult(o);break;case zt.INITIAL:break}this._commandService.executeCommand(en.id,{functionsExecutedState:e},{onlyLocal:!0})}),this._calculateFormulaService.executionInProgressListener$.subscribe(o=>{this._commandService.executeCommand(en.id,{stageInfo:o},{onlyLocal:!0})})}async _applyResult(o){const{unitData:e,unitOtherData:t,arrayFormulaRange:r,arrayFormulaCellData:n,clearArrayFormulaCellData:s}=o;if(!e){console.error("No sheetData from Formula Engine!");return}r&&(this._formulaDataModel.clearPreviousArrayFormulaCellData(s),this._formulaDataModel.mergeArrayFormulaCellData(n),this._formulaDataModel.mergeArrayFormulaRange(r),this._commandService.executeCommand(Zr.id,{arrayFormulaRange:this._formulaDataModel.getArrayFormulaRange(),arrayFormulaCellData:this._formulaDataModel.getArrayFormulaCellData()},{onlyLocal:!0})),this._commandService.executeCommand(Vs.id,{unitData:Fu(e),unitOtherData:t},{onlyLocal:!0})}};exports.CalculateController=om([zn(0,M.ICommandService),zn(1,cn),zn(2,M.Inject(exports.FormulaDataModel))],exports.CalculateController);var um=Object.defineProperty,cm=Object.getOwnPropertyDescriptor,lm=(i,o,e,t)=>{for(var r=t>1?void 0:t?cm(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&um(o,e,r),r},Ta=(i,o)=>(e,t)=>o(e,t,i);exports.SetDefinedNameController=class extends M.Disposable{constructor(o,e){super(),this._commandService=o,this._definedNamesService=e,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(o.id===Vr.id){const e=o.params;if(e==null)return;const{id:t,unitId:r,name:n,formulaOrRefString:s,comment:a,hidden:u,localSheetId:c}=e;this._definedNamesService.registerDefinedName(r,{id:t,name:n.trim(),formulaOrRefString:s.trim(),comment:a==null?void 0:a.trim(),hidden:u,localSheetId:c})}else if(o.id===En.id){const e=o.params;if(e==null)return;const{unitId:t,id:r}=e;this._definedNamesService.removeDefinedName(t,r)}}))}};exports.SetDefinedNameController=lm([Ta(0,M.ICommandService),Ta(1,lr)],exports.SetDefinedNameController);const Ba=/[\[\]]/g;function Ia(i,o){if(Ba.test(i)){const e=Number(i.replace(Ba,""));return o+e}return Number(i)-1}function Jn(i,o=0,e=0){i=i.toLocaleUpperCase();const t=i.split(/[RC]/),r=t[1],n=t[2],s=Ia(r,o),a=Ia(n,e);return{row:s,column:a,absoluteRefType:M.AbsoluteRefType.NONE}}function Zi(i,o=0,e=0){const{refBody:t,sheetName:r,unitId:n}=An(i),s=t.indexOf(":");if(s===-1){const _=Jn(t,o,e),E=_.row,b=_.column,R=_.absoluteRefType;return{unitId:n,sheetName:r,range:{startRow:E,startColumn:b,endRow:E,endColumn:b,startAbsoluteRefType:R,endAbsoluteRefType:R}}}const a=t.substring(0,s),u=t.substring(s+1),c=Jn(a,o,e),l=Jn(u,o,e),f=c.row,m=c.column,d=l.row,C=l.column;return{unitId:n,sheetName:r,range:{startRow:f,startColumn:m,endRow:d,endColumn:C,startAbsoluteRefType:c.absoluteRefType,endAbsoluteRefType:l.absoluteRefType}}}function fm(i){const o=Tr(i.startRow,i.startAbsoluteRefType,!0),e=Tr(i.startColumn,i.startAbsoluteRefType,!1),t=Tr(i.endRow,i.endAbsoluteRefType,!0),r=Tr(i.endColumn,i.endAbsoluteRefType,!1);return o===t&&e===r?`R${o}C${e}`:`R${o}C${e}:R${t}C${r}`}function Tr(i,o=M.AbsoluteRefType.ALL,e){switch(i+=1,o){case M.AbsoluteRefType.ALL:return`${i}`;case M.AbsoluteRefType.ROW:return e?`${i}`:`[${i}]`;case M.AbsoluteRefType.COLUMN:return e?`[${i}]`:`${i}`;case M.AbsoluteRefType.NONE:return`[${i}]`}}const zi=[];var Ji=(i=>i)(Ji||{});class N{constructor(o){A(this,"_unitId");A(this,"_subUnitId");A(this,"_row",-1);A(this,"_column",-1);A(this,"_definedNames");A(this,"_locale");A(this,"_sheetOrder");A(this,"_sheetNameMap");A(this,"_formulaDataModel");A(this,"needsExpandParams",!1);A(this,"needsReferenceObject",!1);A(this,"needsLocale",!1);A(this,"needsSheetsInfo",!1);A(this,"needsFormulaDataModel",!1);A(this,"minParams",-1);A(this,"maxParams",-1);this._name=o}get name(){return this._name}get unitId(){return this._unitId}get subUnitId(){return this._subUnitId}get row(){return this._row}get column(){return this._column}dispose(){}getDefinedName(o){var t;const e=this._definedNames;return e==null?null:(t=Array.from(Object.values(e)).filter(r=>r.name===o))==null?void 0:t[0]}setDefinedNames(o){this._definedNames=o}getLocale(){return this._locale}setLocale(o){this._locale=o}getSheetsInfo(){return{sheetOrder:this._sheetOrder,sheetNameMap:this._sheetNameMap}}setSheetsInfo({sheetOrder:o,sheetNameMap:e}){this._sheetOrder=o,this._sheetNameMap=e}setFormulaDataModel(o){this._formulaDataModel=o}isAsync(){return!1}isAddress(){return!1}isCustom(){return!1}setRefInfo(o,e,t,r){this._unitId=o,this._subUnitId=e,this._row=t,this._column=r}calculateCustom(...o){return null}calculate(...o){return g.create(h.VALUE)}checkArrayType(o){return o.isReferenceObject()||o.isValueObject()&&o.isArray()}getIndexNumValue(o,e=1){let t=o;if(t.isArray()&&(t=t.getFirstCell()),t.isBoolean())return t.getValue()===!1?g.create(h.VALUE):e;if(t.isString()){const r=Number(t.getValue());return Number.isNaN(r)?g.create(h.REF):r}else if(t.isNumber())return t.getValue();return g.create(h.VALUE)}getZeroOrOneByOneDefault(o){if(o==null)return 1;let e=1;if(o.isArray()&&(o=o.getFirstCell()),o.isBoolean())o.getValue()===!1&&(e=0);else{if(o.isString())return;o.isNumber()&&o.getValue()===0&&(e=0)}return e}getMatchTypeValue(o){if(o==null)return 1;let e=1;if(o.isArray()&&(o=o.getFirstCell()),o.isBoolean())o.getValue()===!1&&(e=0);else{if(o.isString())return;if(o.isNumber()){const t=o.getValue();t<=0&&(e=t)}}return e}binarySearch(o,e,t,r,n){const s=e.binarySearch(o,r,n);if(s==null)return g.create(h.NA);let a;return t.getRowCount()===1?a=t.get(0,s)||ae.create():a=t.get(s,0)||ae.create(),a.isNull()?y.create(0):a}_getOneFirstByRaw(o){return o.length===0?g.create(h.NA):o[0][0]||g.create(h.NA)}_getOneLastByRaw(o){return o.length===0?g.create(h.NA):o[o.length-1][o[0].length-1]||g.create(h.NA)}equalSearch(o,e,t,r=!0){const n=t.pickRaw(e.isEqual(o));return r?this._getOneFirstByRaw(n):this._getOneLastByRaw(n)}fuzzySearch(o,e,t,r=!0){const n=t.pickRaw(e.compare(o,$.EQUALS));return r?this._getOneFirstByRaw(n):this._getOneLastByRaw(n)}orderSearch(o,e,t,r=Oe.MIN,n=!1){const s=e.orderSearch(o,r,n);if(s==null)return g.create(h.NA);const a=t.get(s.row,s.column)||ae.create();return a.isNull()?g.create(h.NA):a}binarySearchExpand(o,e,t,r=0,n,s){const a=e.binarySearch(o,n,s);return a==null?g.create(h.NA):r===0?t.slice([a,a+1]):t.slice(void 0,[a,a+1])}equalSearchExpand(o,e,t,r=!0,n=0){const s=e.isEqual(o);let a;return r?a=s.getFirstTruePosition():a=s.getLastTruePosition(),a==null?g.create(h.NA):n===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}fuzzySearchExpand(o,e,t,r=!0,n=0){const s=e.compare(o,$.EQUALS);let a;return r?a=s.getFirstTruePosition():a=s.getLastTruePosition(),a==null?g.create(h.NA):n===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}orderSearchExpand(o,e,t,r=Oe.MIN,n=!1,s=0){const a=e.orderSearch(o,r,n);return a==null?g.create(h.NA):s===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}flattenArray(o,e=!0){const t=[];t[0]=[];for(let r=0;r<o.length;r++){let n=o[r];if((n.isString()||n.isBoolean()||n.isNull())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()){let s;if(n.iterator(a=>{if(a==null||a.isNull()||e&&(a.isString()||a.isBoolean()))return!0;if(a=this._includingLogicalValuesAndText(a),a.isError())return s=a,!1;t[0].push(a)}),s!=null&&s.isError())return s}else t[0].push(n)}return Ht(t,1,t[0].length)}_includingLogicalValuesAndText(o){if(o.isBoolean()&&(o=ef(o)),o.isString()){const e=Number(o.getValue());o=y.create(Number.isNaN(e)?0:e)}return o}createReferenceObject(o,e){const t=o.getForcedUnitId(),r=o.getForcedSheetId()||"",n=o.getForcedSheetName(),a=zr({unitId:t,sheetName:n,range:e});let u;return Nr(a)?u=new Ps(a):li(a)?u=new xs(a):fi(a)?u=new Ls(a):u=new Rr(e,r,t),this._setReferenceDefault(o,u)}_setReferenceDefault(o,e){return this.unitId==null||this.subUnitId==null?g.create(h.REF):(e.setDefaultUnitId(this.unitId),e.setDefaultSheetId(this.subUnitId),e.setUnitData(o.getUnitData()),e.setRuntimeData(o.getRuntimeData()),e.setArrayFormulaCellData(o.getArrayFormulaCellData()),e.setRuntimeArrayFormulaCellData(o.getRuntimeArrayFormulaCellData()),e)}}var ir;(i=>{const o=.636619772;function e(n,s){let a=0;for(let u=0;u<n.length;++u)a=s*a+n[u];return a}function t(n,s,a,u,c){if(s===0)return a;if(s===1)return u;const l=2/n;let f=a,m=u,d=u;for(let C=1;C<s;++C)d=m*C*l+c*f,f=m,m=d;return d}function r(n,s,a,u){return function(l,f){if(a){if(l===0)return a===1?-1/0:1/0;if(l<0)return Number.NaN}if(f===0)return n(l);if(f===1)return s(l);if(f<0)return Number.NaN;const m=f|0,d=n(l),C=s(l);return t(l,m,d,C,u)}}i.besselj=(()=>{const n=[-184.9052456,77392.33017,-1121442418e-2,6516196407e-1,-13362590354,57568490574],s=[1,267.8532712,59272.64853,9494680718e-3,1029532985,57568490411],a=[2093887211e-16,-2073370639e-15,2734510407e-14,-.001098628627,1],u=[-934935152e-16,7621095161e-16,-6911147651e-15,.0001430488765,-.01562499995];function c(_){let E=0,b=0,R=0,p=_*_;if(_<8)b=e(n,p),R=e(s,p),E=b/R;else{const V=_-.785398164;p=64/p,b=e(a,p),R=e(u,p),E=Math.sqrt(o/_)*(Math.cos(V)*b-Math.sin(V)*R*8/_)}return E}const l=[-30.16036606,15704.4826,-2972611439e-3,2423968531e-1,-7895059235,72362614232],f=[1,376.9991397,99447.43394,1858330474e-2,2300535178,144725228442],m=[-240337019e-15,2457520174e-15,-3516396496e-14,.00183105,1],d=[105787412e-15,-88228987e-14,8449199096e-15,-.0002002690873,.04687499995];function C(_){let E=0,b=0,R=0,p=_*_;const V=Math.abs(_)-2.356194491;return Math.abs(_)<8?(b=_*e(l,p),R=e(f,p),E=b/R):(p=64/p,b=e(m,p),R=e(d,p),E=Math.sqrt(o/Math.abs(_))*(Math.cos(V)*b-Math.sin(V)*R*8/Math.abs(_)),_<0&&(E=-E)),E}return function _(E,b){const R=Math.round(b);if(!Number.isFinite(E))return Number.isNaN(E)?E:0;if(R<0)return(R%2?-1:1)*_(E,-R);if(E<0)return(R%2?-1:1)*_(-E,R);if(R===0)return c(E);if(R===1)return C(E);if(E===0)return 0;let p=0;if(E>R)p=t(E,R,c(E),C(E),-1);else{const V=2*Math.floor((R+Math.floor(Math.sqrt(40*R)))/2);let S=!1,D=0,w=0,P=1,L=0;const T=2/E;for(let B=V;B>0;B--)if(L=B*T*P-D,D=P,P=L,Math.abs(P)>1e10&&(P*=1e-10,D*=1e-10,p*=1e-10,w*=1e-10),S&&(w+=P),S=!S,B===R&&(p=D),V-B>100&&p===0)return Number.NaN;w=2*w-P,p/=w}return p}})(),i.bessely=(()=>{const n=[228.4622733,-86327.92757,1087988129e-2,-5123598036e-1,7062834065,-2957821389],s=[1,226.1030244,47447.2647,7189466438e-3,7452499648e-1,40076544269],a=[2093887211e-16,-2073370639e-15,2734510407e-14,-.001098628627,1],u=[-934945152e-16,7621095161e-16,-6911147651e-15,.0001430488765,-.01562499995];function c(_){let E=0,b=0,R=0,p=_*_;const V=_-.785398164;return _<8?(b=e(n,p),R=e(s,p),E=b/R+o*(0,i.besselj)(_,0)*Math.log(_)):(p=64/p,b=e(a,p),R=e(u,p),E=Math.sqrt(o/_)*(Math.sin(V)*b+Math.cos(V)*R*8/_)),E}const l=[8511.937935,-4237922726e-3,7349264551e-1,-51534381390,127527439e4,-4900604943e3],f=[1,354.9632885,102042.605,2245904002e-2,3733650367,424441966400,249958057e5],m=[-240337019e-15,2457520174e-15,-3516396496e-14,.00183105,1],d=[105787412e-15,-88228987e-14,8449199096e-15,-.0002002690873,.04687499995];function C(_){let E=0,b=0,R=0,p=_*_;const V=_-2.356194491;return _<8?(b=_*e(l,p),R=e(f,p),E=b/R+o*((0,i.besselj)(_,1)*Math.log(_)-1/_)):(p=64/p,b=e(m,p),R=e(d,p),E=Math.sqrt(o/_)*(Math.sin(V)*b+Math.cos(V)*R*8/_)),E}return r(c,C,1,-1)})(),i.besseli=(()=>{const n=[.0045813,.0360768,.2659732,1.2067492,3.0899424,3.5156229,1],s=[.00392377,-.01647633,.02635537,-.02057706,.00916281,-.00157565,.00225319,.01328592,.39894228];function a(f){return f<=3.75?e(n,f*f/(3.75*3.75)):Math.exp(Math.abs(f))/Math.sqrt(Math.abs(f))*e(s,3.75/Math.abs(f))}const u=[32411e-8,.00301532,.02658733,.15084934,.51498869,.87890594,.5],c=[-.00420059,.01787654,-.02895312,.02282967,-.01031555,.00163801,-.00362018,-.03988024,.39894228];function l(f){return f<3.75?f*e(u,f*f/(3.75*3.75)):(f<0?-1:1)*Math.exp(Math.abs(f))/Math.sqrt(Math.abs(f))*e(c,3.75/Math.abs(f))}return function f(m,d){const C=Math.round(d);if(C===0)return a(m);if(C===1)return l(m);if(C<0)return Number.NaN;if(Math.abs(m)===0)return 0;if(m===1/0)return 1/0;let _=0,E;const b=2/Math.abs(m);let R=0,p=1,V=0;const S=2*Math.round((C+Math.round(Math.sqrt(40*C)))/2);for(E=S;E>0;E--)if(V=E*b*p+R,R=p,p=V,Math.abs(p)>1e10&&(p*=1e-10,R*=1e-10,_*=1e-10),E===C&&(_=R),S-E>100&&_===0)return Number.NaN;return _*=f(m,0)/p,m<0&&C%2?-_:_}})(),i.besselk=(()=>{const n=[74e-7,1075e-7,.00262698,.0348859,.23069756,.4227842,-.57721566],s=[53208e-8,-.0025154,.00587872,-.01062446,.02189568,-.07832358,1.25331414];function a(f){return f<=2?-Math.log(f/2)*(0,i.besseli)(f,0)+e(n,f*f/4):Math.exp(-f)/Math.sqrt(f)*e(s,2/f)}const u=[-4686e-8,-.00110404,-.01919402,-.18156897,-.67278579,.15443144,1],c=[-68245e-8,.00325614,-.00780353,.01504268,-.0365562,.23498619,1.25331414];function l(f){return f<=2?Math.log(f/2)*(0,i.besseli)(f,1)+1/f*e(u,f*f/4):Math.exp(-f)/Math.sqrt(f)*e(c,2/f)}return r(a,l,2,1)})()})(ir||(ir={}));function Is(i){return/^[01]{1,10}$/.test(i)}function Fs(i){return/^[0-7]{1,10}$/.test(i)}function ks(i){return/^[0-9A-Fa-f]{1,10}$/.test(i)}function Ft(i){if(i===0)return 0;const o=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18];let e=i,t=!1;e<0&&(e=-e,t=!0);const r=2/(2+e),n=4*r-2;let s=0,a=0,u;for(let l=o.length-1;l>0;l--)u=s,s=n*s-a+o[l],a=u;const c=r*Math.exp(-e*e+.5*(o[0]+n*s)-a);return t?c-1:1-c}function $s(i){return 1-Ft(i)}function mm(i){if(i>=2)return-100;if(i<=0)return 100;const o=i<1?i:2-i,e=Math.sqrt(-2*Math.log(o/2));let t=-.70711*((2.30753+e*.27061)/(1+e*(.99229+e*.04481))-e);for(let r=0;r<2;r++){const n=$s(t)-o;t+=n/(1.1283791670955126*Math.exp(-t*t)-t*n)}return i<1?t:-t}function er(i,o=1){let e=Math.floor(i);if(i<0)return Number.NaN;let t=1;for(;e>1&&Number.isFinite(t);)t*=e,e-=o;return t}function kt(i,o){const e=Math.min(i-o,o);let t=1;for(let r=1;r<=e&&Number.isFinite(t);r++)t*=i-r+1,t/=r;return t}function bs(i,o){let e=Math.floor(i),t=Math.floor(o);for(;t!==0;){const r=t;t=e%t,e=r}return e}function Fa(i,o){const e=bs(i,o);return e===0?0:Math.abs(i*o)/e}function Tn(i){const o=i.length;if(o===1)return i[0][0];if(o===2)return i[0][0]*i[1][1]-i[0][1]*i[1][0];let e=0;for(let t=0;t<o;t++)e+=(t%2===0?1:-1)*i[0][t]*Tn(eo(i,0,t));return e}function hm(i){const o=Tn(i);return o===0?null:i.length===1?[[1/o]]:gm(i).map(r=>r.map(n=>n/o))}function eo(i,o,e){return i.filter((t,r)=>r!==o).map(t=>t.filter((r,n)=>n!==e))}function gm(i){const o=i.length,e=Array.from({length:o},()=>new Array(o).fill(0));for(let t=0;t<o;t++)for(let r=0;r<o;r++){const n=(t+r)%2===0?1:-1;e[r][t]=n*Tn(eo(i,t,r))}return e}function tr(i,o){return i.map(e=>o[0].map((t,r)=>e.reduce((n,s,a)=>n+s*o[a][r],0)))}function yt(i){return i[0].map((o,e)=>i.map(t=>t[e]))}function dm(i){const o=Cm(i);if(!o)return null;const{matrixU:e,matrixS:t,matrixV:r}=o,n=yt(e),s=Array.from({length:t.length},()=>new Array(i[0].length).fill(0)),a=Math.max(i.length,i[0].length)*Number.EPSILON*t[0];for(let u=0;u<t.length;u++)Math.abs(t[u])>a&&(s[u][u]=1/t[u]);return tr(r,tr(s,n))}function Cm(i){const o=yt(i),e=o.length,t=o[0].length;if(e<t)return null;const r=new Array(t).fill(0),n=new Array(t).fill(0),s=Array.from({length:t},()=>new Array(t).fill(0));let a=Number.EPSILON,u=0,c=0,l=0;for(let _=0;_<t;_++){if(r[_]=u,c=es(o,_,e,_,_),c<=1e-64/a)u=0;else{u=Math.sqrt(c),o[_][_]>=0&&(u=-u);const b=o[_][_]*u-c;o[_][_]-=u;for(let R=_+1;R<t;R++){c=es(o,_,e,_,R);for(let p=_;p<e;p++)o[p][R]+=c/b*o[p][_]}}if(n[_]=u,c=ka(o,_+1,t,_,_),c<=1e-64/a)u=0;else{u=Math.sqrt(c),o[_][_+1]>=0&&(u=-u);const b=o[_][_+1]*u-c;o[_][_+1]-=u;for(let R=_+1;R<t;R++)r[R]=o[_][R]/b;for(let R=_+1;R<e;R++){c=ka(o,_+1,t,R,_);for(let p=_+1;p<t;p++)o[R][p]+=c*r[p]}}const E=Math.abs(n[_])+Math.abs(r[_]);E>l&&(l=E)}let f=0;for(let _=t-1;_>=0;_--){if(u!==0){for(let E=f;E<t;E++)s[E][_]=o[_][E]/(u*o[_][_+1]);for(let E=f;E<t;E++){c=0;for(let b=f;b<t;b++)c+=o[_][b]*s[b][E];for(let b=f;b<t;b++)s[b][E]+=c*s[b][_]}}for(let E=f;E<t;E++)s[_][E]=0,s[E][_]=0;s[_][_]=1,u=r[_],f=_}for(let _=t-1;_>=0;_--){u=n[_];for(let E=_+1;E<t;E++)o[_][E]=0;if(u!==0){for(let E=_+1;E<t;E++){c=es(o,_+1,e,_,E);for(let b=_;b<e;b++)o[b][E]+=c/(o[_][_]*u)*o[b][_]}for(let E=_;E<e;E++)o[E][_]/=u}else for(let E=_;E<e;E++)o[E][_]=0;o[_][_]+=1}a*=l;let m=0,d=0,C=0;for(let _=t-1;_>=0;_--)for(let E=0;E<50;E++){let b=!1,R=_;for(;R>=0;R--){if(Math.abs(r[R])<=a){b=!0;break}if(Math.abs(n[R-1])<=a)break}if(!b){let D=0,w=1;for(let P=R;P<_+1&&(m=w*r[P],d=n[P],r[P]*=D,!(Math.abs(m)<=a));P++){C=Br(m,d),n[P]=C,D=d/C,w=-m/C;for(let L=0;L<e;L++){const T=o[L][R-1],B=o[L][P];o[L][R-1]=T*D+B*w,o[L][P]=-T*w+B*D}}}if(R===_){if(n[_]<0){n[_]=-n[_];for(let D=0;D<t;D++)s[D][_]=-s[D][_]}break}if(E>=49)return null;let p=n[R];m=((n[_-1]-n[_])*(n[_-1]+n[_])+(r[_-1]-r[_])*(r[_-1]+r[_]))/(2*r[_]*n[_-1]),C=Br(m,1),m<0?m=((p-n[_])*(p+n[_])+r[_]*(n[_-1]/(m-C)-r[_]))/p:m=((p-n[_])*(p+n[_])+r[_]*(n[_-1]/(m+C)-r[_]))/p;let V=1,S=1;for(let D=R+1;D<_+1;D++){let w=r[D],P=n[D];d=S*w,w*=V,C=Br(m,d),r[D-1]=C,V=m/C,S=d/C,m=p*V+w*S,d=P*S,w=-p*S+w*V,P*=V;for(let L=0;L<t;L++){const T=s[L][D-1],B=s[L][D];s[L][D-1]=T*V+B*S,s[L][D]=-T*S+B*V}C=Br(m,d),n[D-1]=C,V=m/C,S=d/C,m=V*w+S*P,p=-S*w+V*P;for(let L=0;L<e;L++){const T=o[L][D-1],B=o[L][D];o[L][D-1]=T*V+B*S,o[L][D]=-T*S+B*V}}r[R]=0,r[_]=m,n[_]=p}for(let _=0;_<n.length;_++)n[_]<a&&(n[_]=0);for(let _=0;_<t;_++)for(let E=_-1;E>=0;E--)if(n[E]<n[_]){const b=n[E];n[E]=n[_],n[_]=b;for(let R=0;R<o.length;R++){const p=o[R][_];o[R][_]=o[R][E],o[R][E]=p}for(let R=0;R<s.length;R++){const p=s[R][_];s[R][_]=s[R][E],s[R][E]=p}_=E}return{matrixU:o,matrixS:n,matrixV:s}}function Br(i,o){let e=0;return Math.abs(i)>Math.abs(o)?(e=o/i,Math.abs(i)*Math.sqrt(1+e*e)):o!==0?(e=i/o,Math.abs(o)*Math.sqrt(1+e*e)):0}function es(i,o,e,t,r){let n=0;for(let s=o;s<e;s++)n+=i[s][t]*i[s][r];return n}function ka(i,o,e,t,r){let n=0;for(let s=o;s<e;s++)n+=i[t][s]*i[r][s];return n}const Ir=new Map([["I",1],["V",5],["X",10],["L",50],["C",100],["D",500],["M",1e3]]),_m=new Map([[1,"I"],[4,"IV"],[5,"V"],[9,"IX"],[10,"X"],[40,"XL"],[45,"VL"],[49,"IL"],[50,"L"],[90,"XC"],[95,"VC"],[99,"IC"],[100,"C"],[400,"CD"],[450,"LD"],[490,"XD"],[495,"VD"],[499,"ID"],[500,"D"],[900,"CM"],[950,"LM"],[990,"XM"],[995,"VM"],[999,"IM"],[1e3,"M"]]),Am=[[1,4,5,9,10,40,50,90,100,400,500,900,1e3,4e3],[1,4,5,9,10,40,45,50,90,95,100,400,450,500,900,950,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,500,900,950,990,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,495,500,900,950,990,995,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,495,499,500,900,950,990,995,999,1e3,4e3]];function to(i,o,e){return i<=0?0:i>=1?1:Bn(i,o,e)}function Em(i,o,e){return i<=0||i>=1?0:o===1&&e===1?1:o<512&&e<512?i**(o-1)*(1-i)**(e-1)/Hs(o,e):Math.exp((o-1)*Math.log(i)+(e-1)*Math.log(1-i)-Gs(o,e))}function Ys(i,o,e){if(i<=0)return 0;if(i>=1)return 1;const t=1e-8;let r;if(o>=1&&e>=1){const c=i<.5?i:1-i,l=Math.sqrt(-2*Math.log(c));r=(2.30753+l*.27061)/(1+l*(.99229+l*.04481))-l,i<.5&&(r=-r);const f=(r*r-3)/6,m=2/(1/(2*o-1)+1/(2*e-1)),d=r*Math.sqrt(f+m)/m-(1/(2*e-1)-1/(2*o-1))*(f+5/6-2/(3*m));r=o/(o+e*Math.exp(2*d))}else{const c=Math.exp(o*Math.log(o/(o+e)))/o,l=Math.exp(e*Math.log(e/(o+e)))/e,f=c+l;i<c/f?r=(o*f*i)**(1/o):r=1-(e*f*(1-i))**(1/e)}const n=-Gs(o,e);let s,a,u;for(let c=0;c<10;c++){if(r===0||r===1)return r;if(s=Bn(r,o,e)-i,a=Math.exp((o-1)*Math.log(r)+(e-1)*Math.log(1-r)+n),u=s/a,r-=a=u/(1-.5*Math.min(1,u*((o-1)/r-(e-1)/(1-r)))),r<=0&&(r=.5*(r+a)),r>=1&&(r=.5*(r+a+1)),Math.abs(a)<t*r&&c>0)break}return r}function Bn(i,o,e){const t=i===0||i===1?0:Math.exp(rt(o+e)-rt(o)-rt(e)+o*Math.log(i)+e*Math.log(1-i));return i<(o+1)/(o+e+2)?t*$a(i,o,e)/o:1-t*$a(1-i,e,o)/e}function $a(i,o,e){let n=1-(o+e)*i/(o+1);Math.abs(n)<1e-8&&(n=1e-8),n=1/n;let s=1,a=n;for(let u=1;u<=100;u++){let c=u*(e-u)*i/((o-1+u*2)*(o+u*2));if(n=1+c*n,Math.abs(n)<1e-8&&(n=1e-8),s=1+c/s,Math.abs(s)<1e-8&&(s=1e-8),n=1/n,a*=n*s,c=-(o+u)*(o+e+u)*i/((o+u*2)*(o+1+u*2)),n=1+c*n,Math.abs(n)<1e-8&&(n=1e-8),s=1+c/s,Math.abs(s)<1e-8&&(s=1e-8),n=1/n,a*=n*s,Math.abs(n*s-1)<1e-8)break}return a}function Hs(i,o){return i+o>170?Math.exp(Gs(i,o)):Qr(i)*Qr(o)/Qr(i+o)}function Gs(i,o){return rt(i)+rt(o)-rt(i+o)}function ro(i,o,e){if(i<0)return 0;if(i>=o)return 1;if(e<0||e>1||o<=0)return Number.NaN;let t=0;for(let r=0;r<=i;r++)t+=Ws(r,o,e);return t}function Ws(i,o,e){return e===0||e===1?o*e===i?1:0:kt(o,i)*e**i*(1-e)**(o-i)}function Qs(i,o){return i<=0?0:Xs(o/2,i/2)}function bm(i,o){return i<0?0:i===0&&o===2?.5:Math.exp((o/2-1)*Math.log(i)-i/2-o/2*Math.log(2)-rt(o/2))}function no(i,o){return i<=0?0:i>=1?1/0:2*io(i,o/2)}function qs(i,o,e){return i<0?0:Bn(o*i/(o*i+e),o/2,e/2)}function ym(i,o,e){if(i<0)return 0;if(i===0&&o<2)return 1/0;if(i===0&&o===2)return 1;let t=1/Hs(o/2,e/2);return t*=(o/e)**(o/2),t*=i**(o/2-1),t*=(1+o/e*i)**(-(o+e)/2),t}function so(i,o,e){return i<=0?0:i>=1?1/0:e/(o*(1/Ys(i,o/2,e/2)-1))}function Rm(i,o){return i<0?0:1-Math.exp(-o*i)}function pm(i,o){return i<0?0:o*Math.exp(-o*i)}function ao(i,o,e){const t=o.length;let r=0,n=0;for(let m=0;m<t;m++)r+=o[m],n+=e[m];const s=r/t,a=n/t;let u=0,c=0;for(let m=0;m<t;m++)u+=(o[m]-s)*(e[m]-a),c+=(e[m]-a)**2;if(c===0)return 1/0;const l=u/c;return s-l*a+l*i}function Qr(i){const o=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],e=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535];let t=0,r=i;if(i>171.6243769536076)return 1/0;if(r<=0){const f=r%1+36e-17;if(f)t=(r&1?-1:1)*Math.PI/Math.sin(Math.PI*f),r=1-r;else return 1/0}const n=r;let s=0,a;r<1?a=r++:a=(r-=s=(r|0)-1)-1;let u=0,c=0;for(let f=0;f<8;++f)u=(u+o[f])*a,c=c*a+e[f];let l=u/c+1;if(n<r)l/=n;else if(n>r)for(let f=0;f<s;++f)l*=r,r++;return t&&(l=t/l),l}function Nm(i,o,e){return i<=0?0:Xs(o,i/e)}function Vm(i,o,e){return i<0?0:i===0&&o===1?1/e:Math.exp((o-1)*Math.log(i)-i/e-rt(o)-o*Math.log(e))}function Om(i,o,e){return i<=0?0:i>=1?1/0:e*io(i,o)}function rt(i){const o=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];let e=i,t=i+5.5;t-=(i+.5)*Math.log(t);let r=1.000000000190015;for(let n=0;n<6;n++)r+=o[n]/++e;return-t+Math.log(2.5066282746310007*r/i)}function Xs(i,o){if(o<0||i<=0)return Number.NaN;const e=1e-30,t=-~(Math.log(i>=1?i:1/i)*8.5+i*.4+17),r=rt(i),n=Math.exp(-o+i*Math.log(o)-r);let s=i,a=1/i,u=a;if(o<i+1){if(n===0)return 0;for(let d=1;d<=t&&(a+=u*=o/++s,!(Math.abs(u)<Math.abs(a)*e));d++);return a*n}if(n===0)return 1;let c=o+1-i,l=1/e,f=1/c,m=f;for(let d=1;d<=t;d++){const C=-d*(d-i);if(c+=2,f=C*f+c,Math.abs(f)<e&&(f=e),l=c+C/l,Math.abs(l)<e&&(l=e),f=1/f,m*=f*l,Math.abs(f*l-1)<e)break}return 1-m*n}function io(i,o){if(i<=0)return 0;if(i>=1)return Math.max(100,o+100*Math.sqrt(o));let e;if(o>1){const a=i<.5?i:1-i,u=Math.sqrt(-2*Math.log(a));e=(2.30753+u*.27061)/(1+u*(.99229+u*.04481))-u,i<.5&&(e=-e),e=Math.max(.001,o*(1-1/(9*o)-e/(3*Math.sqrt(o)))**3)}else{const a=1-o*(.253+o*.12);i<a?e=(i/a)**(1/o):e=1-Math.log(1-(i-a)/(1-a))}const t=1e-8,r=rt(o);let n,s;for(let a=0;a<12;a++){if(e<=0)return 0;if(n=Xs(o,e)-i,o>1?s=Math.exp((o-1)*(Math.log(o-1)-1)-r)*Math.exp(-(e-(o-1))+(o-1)*(Math.log(e)-Math.log(o-1))):s=Math.exp(-e+(o-1)*Math.log(e)-r),s!==0&&(s=n/s/(1-.5*Math.min(1,n/s*((o-1)/e-1)))),e-=s,e<=0&&(e=.5*(e+s)),Math.abs(s)<t*e)break}return e}function Mm(i,o,e,t){let r=0;for(let n=0;n<=i;n++)r+=Ks(n,o,e,t);return r}function Ks(i,o,e,t){return o-i>t-e?0:kt(e,i)*kt(t-e,o-i)/kt(t,o)}function oo(i,o,e){return i<0?0:.5+.5*Ft((Math.log(i)-o)/Math.sqrt(2*e*e))}function Sm(i,o,e){return i<=0?0:Math.exp(-Math.log(i)-.5*Math.log(2*Math.PI)-Math.log(e)-(Math.log(i)-o)**2/(2*e*e))}function Dm(i,o,e){return Math.exp(In(i,o,e))}function wm(i,o,e){if(i<0)return 0;let t=0;for(let r=0;r<=i;r++)t+=Zs(r,o,e);return t}function Zs(i,o,e){return i<0?0:kt(i+o-1,o-1)*e**o*(1-e)**i}function Pr(i,o,e){return .5*(1+Ft((i-o)/Math.sqrt(2*e*e)))}function uo(i,o,e){return Math.exp(-.5*Math.log(2*Math.PI)-Math.log(e)-(i-o)**2/(2*e*e))}function In(i,o,e){return-1.4142135623730951*e*mm(2*i)+o}function Pm(i,o){let e=0;for(let t=0;t<=i;t++)e+=co(t,o);return e}function co(i,o){return Math.exp(-o)*o**i/er(i)}function Lr(i,o){const e=.5*Bn(o/(i**2+o),o/2,.5);return i<0?e:1-e}function Lm(i,o){const e=(1+i**2/o)**(-(o+1)/2);return 1/(Math.sqrt(o)*Hs(.5,o/2))*e}function zs(i,o){let e=Ys(2*Math.min(i,1-i),.5*o,.5);return e=Math.sqrt(o*(1-e)/e),i>.5?e:-e}function Ge(i,o,e,t,r){const n=[],s=[];let a=!0;for(let u=0;u<e;u++){const c=Math.floor(u/t),l=u%t,f=Math.floor(u/r),m=u%r,d=i.isArray()?i.get(c,l):i,C=o.isArray()?o.get(f,m):o;if(d.isError())return{isError:!0,errorObject:d,array1Values:n,array2Values:s,noCalculate:a};if(C.isError())return{isError:!0,errorObject:C,array1Values:n,array2Values:s,noCalculate:a};if(d.isNull()||C.isNull()||d.isBoolean()||C.isBoolean())continue;const _=d.getValue(),E=C.getValue();!M.isRealNum(_)||!M.isRealNum(E)||(n.push(+_),s.push(+E),a=!1)}return{isError:!1,errorObject:null,array1Values:n,array2Values:s,noCalculate:a}}function rr(i){let o=i;if(i.isArray()){const e=i.getRowCount(),t=i.getColumnCount();if(e>1||t>1)return g.create(h.VALUE);o=i.get(0,0)}return o.isError(),o}function Js(...i){for(let o=0;o<i.length;o++){const e=rr(i[o]);if(e.isError())return{isError:!0,errorObject:e};i[o]=e}return{isError:!1,variants:i}}function H(...i){for(let o=0;o<i.length;o++){const e=rr(i[o]);if(e.isError())return{isError:!0,errorObject:e};if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE)};i[o]=e}return{isError:!1,variants:i}}function je(...i){for(let o=0;o<i.length;o++){let e=i[o];if(e.isError())return{isError:!0,errorObject:e};if(e.isNull())return{isError:!0,errorObject:g.create(h.NA)};if(e=rr(i[o]),e.isError())return{isError:!0,errorObject:e};if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE)};i[o]=e}return{isError:!1,variants:i}}function I(...i){for(let o=0;o<i.length;o++){let e=i[o];if(e.isString()&&(e=e.convertToNumberObjectValue()),e.isError())return{isError:!0,errorObject:e};i[o]=e}return{isError:!1,variants:i}}class lo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=n!=null?n:y.create(0),u=s!=null?s:y.create(1);a.isNull()&&(a=y.create(0)),u.isNull()&&(u=y.create(1));const c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.mapValue((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p);return this._handleSignleObject(b,V,S,D,w)});return c===1&&l===1?E.get(0,0):E}_handleSignleObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;const{isError:a,errorObject:u,variants:c}=I(e,t,r,n,s);if(a)return u;const[l,f,m,d,C]=c,_=+l.getValue(),E=+f.getValue(),b=+m.getValue(),R=+d.getValue(),p=+C.getValue();if(E<=0||b<=0||_<=0||_>=1||R>=p)return g.create(h.NUM);const V=Ys(_,E,b)*(p-R)+R;return y.create(V)}}class fo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),C=Math.floor(+l.getValue()),_=+f.getValue(),E=+m.getValue();if(d<0||d>C||_<0||_>1)return g.create(h.NUM);let b;return E?b=ro(d,C,_):b=Ws(d,C,_),y.create(b)}}class mo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=+c.getValue(),d=+l.getValue();if(f<0||m<=0||m>=1||d<=0||d>=1)return g.create(h.NUM);let C=0;for(;C<=f&&!(ro(C,f,m)>=d);)C++;return y.create(C)}}class ho extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||l<1||l>10**10)return g.create(h.NUM);const f=1-Qs(c,l);return y.create(f)}}class go extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=no(1-c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Co extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.NA);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d,r,n)}_getResult(e,t,r,n){let s=0;for(let c=0;c<e.length;c++){if(t[c]===0)return g.create(h.DIV_BY_ZERO);s+=(e[c]-t[c])**2/t[c]}let a=(r-1)*(n-1);r===1?a=n-1:n===1&&(a=r-1);const u=1-Qs(s,a);return y.create(u)}}class _o extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);if(f.isError())return f;if(C.isError())return C;if(_.isError())return _;const{isError:E,errorObject:b,variants:R}=I(f,C,_);if(E)return b;const[p,V,S]=R,D=+p.getValue(),w=+V.getValue(),P=Math.floor(+S.getValue());if(D<=0||D>=1||w<=0||P<1)return g.create(h.NUM);const L=Math.abs(In(D/2,0,1)*w/Math.sqrt(P));return y.create(L)});return n===1&&s===1?l.get(0,0):l}}class Ao extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length===0)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let l=0;l<r;l++)n+=e[l],s+=t[l];const a=n/r,u=s/r;let c=0;for(let l=0;l<r;l++){const f=e[l]-a,m=t[l]-u;c+=f*m}return y.create(c/r)}}class Eo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<0||m<=0)return g.create(h.NUM);let C;return d?C=Rm(f,m):C=pm(f,m),y.create(C)}}class bo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const C=1-qs(f,m,d);return y.create(C)}}class yo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||f>1||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const C=so(1-f,m,d);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class Ro extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variance:s,ns1:a}=this._getValues(e);if(r)return n;const{isError:u,errorObject:c,variance:l,ns1:f}=this._getValues(t);if(u)return c;let m=2*(1-qs(s/l,a,f));return m>1&&(m=2-m),y.create(m)}_getValues(e){let t=0,r=0;const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;if(n===1&&s===1){const f=e.isArray()?e.get(0,0):e;return f.isError()?{isError:!0,errorObject:f,variance:t,ns1:r}:f.isNull()?{isError:!0,errorObject:g.create(h.VALUE),variance:t,ns1:r}:{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r}}const a=[];let u=0;for(let f=0;f<n;f++)for(let m=0;m<s;m++){const d=e.isArray()?e.get(f,m):e;if(d.isError())return{isError:!0,errorObject:d,variance:t,ns1:r};if(d.isNull()||d.isBoolean())continue;const C=d.getValue();M.isRealNum(C)&&(a.push(+C),u+=+C)}if(a.length<=1)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r};const c=u/a.length;let l=0;for(let f=0;f<a.length;f++)l+=(a[f]-c)**2;return r=a.length-1,t=l/r,t===0?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r}:{isError:!1,errorObject:null,variance:t,ns1:r}}}class po extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=+l.getValue(),_=+f.getValue(),E=+m.getValue();if(d<0||C<=0||_<=0)return g.create(h.NUM);let b;return E?b=Nm(d,C,_):b=Vm(d,C,_),y.create(b)}}class No extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<0||f>1||m<=0||d<=0)return g.create(h.NUM);const C=Om(f,m,d);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class Vo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||f>=1||d<=0)return g.create(h.NUM);const C=Dm(f,m,d);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class Oo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t={};let r=0,n=1;for(let s=0;s<e.length;s++){const a=e[s];if(a.isError())return a;if(a.isString()){const l=a.convertToNumberObjectValue();if(l.isError())return l}const u=a.isArray()?a.getRowCount():1,c=a.isArray()?a.getColumnCount():1;for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=a.isArray()?a.get(l,f):a;if(m.isError())return m;if(m.isNull()||m.isBoolean()||m.isString())continue;const d=m.getValue();M.isRealNum(d)&&(t[+d]?(t[+d].count++,t[+d].count>n&&(n=t[+d].count)):t[+d]={count:1,order:r++})}}return r===0||n===1?new g(h.NA):this._getResult(t,n)}_getResult(e,t){const r=Object.entries(e).filter(([n,{count:s}])=>s===t).sort((n,s)=>n[1].order-s[1].order).map(([n])=>+n);return y.create(r[0])}}class Mo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=+l.getValue(),_=+f.getValue(),E=+m.getValue();if(_<=0)return g.create(h.NUM);let b;return E?b=Pr(d,C,_):b=uo(d,C,_),y.create(b)}}class So extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||f>=1||d<=0)return g.create(h.NUM);const C=In(f,m,d);return y.create(C)}}class Do extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSignleObject(r));return e.getRowCount()===1&&e.getColumnCount()===1?t.get(0,0):t}return this._handleSignleObject(e)}_handleSignleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue();if(a<=0||a>=1)return g.create(h.NUM);const u=In(a,0,1);return y.create(u)}}class wo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=+a.getValue(),c=e.length;if(u<0||u>1)return g.create(h.NUM);const l=u*(c-1),f=Math.floor(l),m=l-f;if(m===0)return y.create(e[f]);const d=e[f]+m*(e[f+1]-e[f]);return y.create(d)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class Po extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getValues(e);let s=r!=null?r:y.create(3);s.isNull()&&(s=y.create(3));const a=Math.max(t.isArray()?t.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(t.isArray()?t.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,t,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,C)=>{const _=l.get(d,C);return m.isError()?m:_.isError()?_:this._handleSingleObject(n,m,_)});return a===1&&u===1?f.get(0,0):f}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=I(t,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=Math.floor(+c.getValue()),m=e.length;if(m===0||l<e[0]||l>e[m-1])return g.create(h.NA);if(m===1)return l===e[0]?y.create(1):g.create(h.NA);let d=0,C=!1,_=0;for(;!C&&_<m;)l===e[_]?(d=_/(m-1),C=!0):l>e[_]&&_+1<m&&l<e[_+1]&&(d=(_+(l-e[_])/(e[_+1]-e[_]))/(m-1),C=!0),_++;return C?f<1?g.create(h.NUM):(d=ke(d,f),y.create(d)):g.create(h.NA)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.sort((s,a)=>s-a)}}class Lo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=+c.getValue(),d=+l.getValue();if(f<0||m<0)return g.create(h.NUM);let C;return d?C=Pm(f,m):C=co(f,m),y.create(C)}}class xo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<0||u>4)return g.create(h.NUM);const c=u/4,l=e.length,f=c*(l-1),m=Math.floor(f),d=f-m;if(d===0)return y.create(e[m]);const C=e[m]+d*(e[m+1]-e[m]);return y.create(C)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class jo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.std()}}class Uo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.std(1)}}class vo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<=0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=Math.abs(zs(c/2,l));return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class To extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a,array1Values:u,array2Values:c}=this._handleArray1AndArray2(e,t),l=this._getArrayValues(e),f=this._getArrayValues(t),m=Math.max(r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),d=Math.max(r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),C=O(m,d,r,g.create(h.NA)),_=O(m,d,n,g.create(h.NA)),E=C.mapValue((b,R,p)=>{const V=_.get(R,p);if(e.isError())return e;if(t.isError())return t;if(b.isError())return b;if(V.isError())return V;const{isError:S,errorObject:D,variants:w}=I(b,V);if(S)return D;const[P,L]=w,T=Math.floor(+P.getValue()),B=Math.floor(+L.getValue());return![1,2].includes(T)||![1,2,3].includes(B)?g.create(h.NUM):B===1&&s?a:B!==1&&l instanceof g?l:B!==1&&f instanceof g?f:this._handleSignleObject(B===1?u:l,B===1?c:f,T,B)});return m===1&&d===1?E.get(0,0):E}_handleSignleObject(e,t,r,n){if(e.length<2||t.length<2)return g.create(h.DIV_BY_ZERO);const{isError:s,errorObject:a,x:u,degFreedom:c}=this._getTDistParamByArrayValues(e,t,n);if(s)return a;let l=Lr(-u,c);return r===2&&(l*=2),Number.isNaN(l)||!Number.isFinite(l)?g.create(h.NUM):y.create(l)}_getArrayValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()){if(t*r===1)return g.create(h.VALUE);continue}u.isBoolean()||u.isString()||n.push(+u.getValue())}return n}_handleArray1AndArray2(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return{isError:!0,errorObject:u,array1Values:[],array2Values:[]};let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return{isError:!0,errorObject:c,array1Values:[],array2Values:[]};if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return{isError:!0,errorObject:g.create(h.VALUE),array1Values:[],array2Values:[]};if(r*n!==s*a)return{isError:!0,errorObject:g.create(h.NA),array1Values:[],array2Values:[]};const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?{isError:!0,errorObject:f,array1Values:[],array2Values:[]}:C||m.length<2?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),array1Values:[],array2Values:[]}:{isError:!1,errorObject:null,array1Values:m,array2Values:d}}_getTDistParamByArrayValues(e,t,r){return r===1?this._getTDistParamByType1(e,t):r===2?this._getTDistParamByType2(e,t):this._getTDistParamByType3(e,t)}_getTDistParamByType1(e,t){const r=e.length;let n=0,s=0,a=0;for(let m=0;m<r;m++)n+=e[m],s+=t[m],a+=(e[m]-t[m])**2;const u=n-s,c=r*a-u**2,l=r-1;return c===0?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:l}:{isError:!1,errorObject:null,x:Math.abs(u)*Math.sqrt(l/c),degFreedom:l}}_getTDistParamByType2(e,t){const r=e.length,n=t.length;let s=0,a=0;for(let E=0;E<r;E++)s+=e[E],a+=e[E]**2;let u=0,c=0;for(let E=0;E<n;E++)u+=t[E],c+=t[E]**2;const l=a-s**2/r,f=c-u**2/n,m=Math.sqrt(l+f);if(m===0)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:0};const d=r-1+n-1,C=Math.sqrt(r*n*d/(r+n));return{isError:!1,errorObject:null,x:Math.abs(s/r-u/n)/m*C,degFreedom:d}}_getTDistParamByType3(e,t){const r=e.length,n=t.length;let s=0,a=0;for(let _=0;_<r;_++)s+=e[_],a+=e[_]**2;let u=0,c=0;for(let _=0;_<n;_++)u+=t[_],c+=t[_]**2;const l=(a-s**2/r)/(r*(r-1)),f=(c-u**2/n)/(n*(n-1));if(l+f===0)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:0};const m=l/(l+f),d=Math.abs(s/r-u/n)/Math.sqrt(l+f),C=1/(m**2/(r-1)+(1-m)**2/(n-1));return{isError:!1,errorObject:null,x:d,degFreedom:C}}}class Bo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.var()}}class Io extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.var(1)}}class Fo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=+l.getValue(),_=+f.getValue(),E=+m.getValue();if(d<0||C<=0||_<=0)return g.create(h.NUM);const b=Math.exp(-((d/_)**C));let R;return E?R=1-b:R=C/_**C*d**(C-1)*b,Number.isNaN(R)||!Number.isFinite(R)?g.create(h.NUM):y.create(R)}}class ko extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getArrayValues(e),s=Math.max(t.isArray()?t.getRowCount():1,r!=null&&r.isArray()?r.getRowCount():1),a=Math.max(t.isArray()?t.getColumnCount():1,r!=null&&r.isArray()?r.getColumnCount():1),u=O(s,a,t,g.create(h.NA)),c=r?O(s,a,r,g.create(h.NA)):void 0,l=u.mapValue((f,m,d)=>{if(n instanceof g)return n;if(f.isError())return f;const C=r?c.get(m,d):void 0;return C!=null&&C.isError()?C:n.length===0?g.create(h.NA):n.length===1?g.create(h.DIV_BY_ZERO):this._handleSignleObject(n,f,C)});return s===1&&a===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=+u.getValue(),l=e.length;let f=0,m=0;for(let E=0;E<l;E++)f+=e[E],m+=e[E]**2;let d=0;if(r!==void 0){const{isError:E,errorObject:b,variants:R}=I(r);if(E)return b;const[p]=R;d=+p.getValue()}else{const E=f/l;d=Math.sqrt((m-2*E*f+l*E**2)/(l-1))}if(d<=0)return g.create(h.NUM);const C=(f/l-c)/(d/Math.sqrt(l)),_=1-Pr(C,0,1);return Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):y.create(_)}_getArrayValues(e){const t=[],r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1;for(let s=0;s<r;s++)for(let a=0;a<n;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&t.push(+c)}return t}}class xm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=n!=null?n:y.create(0),u=s!=null?s:y.create(1);a.isNull()&&(a=y.create(0)),u.isNull()&&(u=y.create(1));const c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.mapValue((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p);return this._handleSignleObject(b,V,S,D,w)});return c===1&&l===1?E.get(0,0):E}_handleSignleObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;const{isError:a,errorObject:u,variants:c}=I(e,t,r,n,s);if(a)return u;const[l,f,m,d,C]=c,_=+l.getValue(),E=+f.getValue(),b=+m.getValue(),R=+d.getValue(),p=+C.getValue();if(E<=0||b<=0||_<R||_>p||R===p)return g.create(h.NUM);const V=to((_-R)/(p-R),E,b);return y.create(V)}}var le=(i=>(i.BETADIST="BETADIST",i.BETAINV="BETAINV",i.BINOMDIST="BINOMDIST",i.CHIDIST="CHIDIST",i.CHIINV="CHIINV",i.CHITEST="CHITEST",i.CONFIDENCE="CONFIDENCE",i.COVAR="COVAR",i.CRITBINOM="CRITBINOM",i.EXPONDIST="EXPONDIST",i.FDIST="FDIST",i.FINV="FINV",i.FTEST="FTEST",i.GAMMADIST="GAMMADIST",i.GAMMAINV="GAMMAINV",i.HYPGEOMDIST="HYPGEOMDIST",i.LOGINV="LOGINV",i.LOGNORMDIST="LOGNORMDIST",i.MODE="MODE",i.NEGBINOMDIST="NEGBINOMDIST",i.NORMDIST="NORMDIST",i.NORMINV="NORMINV",i.NORMSDIST="NORMSDIST",i.NORMSINV="NORMSINV",i.PERCENTILE="PERCENTILE",i.PERCENTRANK="PERCENTRANK",i.POISSON="POISSON",i.QUARTILE="QUARTILE",i.RANK="RANK",i.STDEV="STDEV",i.STDEVP="STDEVP",i.TDIST="TDIST",i.TINV="TINV",i.TTEST="TTEST",i.VAR="VAR",i.VARP="VARP",i.WEIBULL="WEIBULL",i.ZTEST="ZTEST",i))(le||{});class jm extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),C=Math.floor(+l.getValue()),_=Math.floor(+f.getValue()),E=Math.floor(+m.getValue());if(d<0||d>C||d>_||d<C-E+_||C<=0||C>E||_<=0||_>E||E<=0)return g.create(h.NUM);let b=Ks(d,C,_,E);return Number.isNaN(b)&&(b=0),y.create(b)}}class Um extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||d<=0)return g.create(h.NUM);const C=oo(f,m,d);return y.create(C)}}class vm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=Math.floor(+c.getValue()),d=+l.getValue();if(f<0||m<1||d<=0||d>=1)return g.create(h.NUM);const C=Zs(f,m,d);return y.create(C)}}class Tm extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSignleObject(r));return e.getRowCount()===1&&e.getColumnCount()===1?t.get(0,0):t}return this._handleSignleObject(e)}_handleSignleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Pr(a,0,1);return y.create(u)}}class Bm extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),C=m.map((_,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+_.getValue(),V=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);const D=u.sort((w,P)=>V?w-P:P-w).indexOf(p);return D===-1?g.create(h.NA):y.create(D+1)});return l===1&&f===1?C.get(0,0):C}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class Im extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||m<1||m>10**10||d<1||d>2)return g.create(h.NUM);let C=Lr(-f,m);return d===2&&(C*=2),Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}const $o=[[xm,le.BETADIST],[lo,le.BETAINV],[fo,le.BINOMDIST],[ho,le.CHIDIST],[go,le.CHIINV],[Co,le.CHITEST],[_o,le.CONFIDENCE],[Ao,le.COVAR],[mo,le.CRITBINOM],[Eo,le.EXPONDIST],[bo,le.FDIST],[yo,le.FINV],[Ro,le.FTEST],[po,le.GAMMADIST],[No,le.GAMMAINV],[jm,le.HYPGEOMDIST],[Um,le.LOGNORMDIST],[Vo,le.LOGINV],[Oo,le.MODE],[vm,le.NEGBINOMDIST],[Mo,le.NORMDIST],[So,le.NORMINV],[Tm,le.NORMSDIST],[Do,le.NORMSINV],[wo,le.PERCENTILE],[Po,le.PERCENTRANK],[Lo,le.POISSON],[xo,le.QUARTILE],[Bm,le.RANK],[Uo,le.STDEV],[jo,le.STDEVP],[Im,le.TDIST],[vo,le.TINV],[To,le.TTEST],[Io,le.VAR],[Bo,le.VARP],[Fo,le.WEIBULL],[ko,le.ZTEST]],Yo=[];var Ho=(i=>(i.CUBEKPIMEMBER="CUBEKPIMEMBER",i.CUBEMEMBER="CUBEMEMBER",i.CUBEMEMBERPROPERTY="CUBEMEMBERPROPERTY",i.CUBERANKEDMEMBER="CUBERANKEDMEMBER",i.CUBESET="CUBESET",i.CUBESETCOUNT="CUBESETCOUNT",i.CUBEVALUE="CUBEVALUE",i))(Ho||{});class Fm extends N{isCustom(){return!0}}function We(i){const o=[];if(i.isError())return{isError:!0,errorObject:i,databaseValues:o};const e=i.isArray()?i.getRowCount():1,t=i.isArray()?i.getColumnCount():1;if(e<2)return{isError:!0,errorObject:g.create(h.VALUE),databaseValues:o};for(let r=0;r<e;r++){const n=[];for(let s=0;s<t;s++){const a=i.get(r,s);if(a.isNull()){n.push(null);continue}let u=`${a.getValue()}`;if(a.isBoolean()&&(u=u.toLocaleUpperCase()),a.isNumber()||M.isRealNum(u)){n.push(+u);continue}n.push(u)}o.push(n)}return{isError:!1,errorObject:null,databaseValues:o}}function Qe(i,o){let e=-1;if(i.isError())return{isError:!0,errorObject:i,fieldIndex:e};const t=i.isArray()?i.getRowCount():1,r=i.isArray()?i.getColumnCount():1;if(t>1||r>1)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};const n=i.isArray()?i.get(0,0):i;let s=`${n.getValue()}`;if(n.isNull()?s=0:n.isBoolean()?s=n.getValue()?1:0:(n.isNumber()||M.isRealNum(s))&&(s=Math.floor(+s)),typeof s=="number"){if(s<1||s>o[0].length)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};e=s-1}else if(e=o[0].findIndex(a=>a===null?!1:`${a}`.toLocaleLowerCase()===s.toLocaleLowerCase()),e===-1)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};return{isError:!1,errorObject:null,fieldIndex:e}}function qe(i){const o=[];if(i.isError())return{isError:!0,errorObject:i,criteriaValues:o};const e=i.isArray()?i.getRowCount():1,t=i.isArray()?i.getColumnCount():1;if(e<2)return{isError:!0,errorObject:g.create(h.VALUE),criteriaValues:o};for(let r=0;r<e;r++){const n=[];for(let s=0;s<t;s++){const a=i.get(r,s);if(a.isNull()){n.push(null);continue}const u=`${a.getValue()}`;if(a.isBoolean()){n.push(a.getValue()?1:0);continue}if(a.isNumber()||M.isRealNum(u)){n.push(+u);continue}n.push(u)}o.push(n)}return{isError:!1,errorObject:null,criteriaValues:o}}function Xe(i,o,e){const t=i.length,r=i[0].length,n={};let s=!1;for(let a=1;a<t;a++){let u=!0;for(let c=0;c<r;c++){const l=i[a][c];if(l===null)continue;let f=n[c];if(f===void 0){const m=i[0][c];f=o[0].findIndex(d=>d===null||m===null?!1:`${d}`.toLocaleLowerCase()===`${m}`.toLocaleLowerCase()),n[c]=f}if(f===-1&&(typeof l=="string"||l===0)){u=!1;break}else if(f>-1){const m=o[e][f];if(m===null){u=!1;break}const[d,C]=mr(`${l}`);if(!lt.create(`${m}`).compare(C,d).getValue()){u=!1;break}}}if(u){s=!0;break}}return s}class km extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Xe(d,a,E)&&(C+=b,_++)}return _===0?g.create(h.DIV_BY_ZERO):y.create(C/_)}}class $m extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0;for(let _=1;_<a.length;_++)typeof a[_][l]=="number"&&Xe(d,a,_)&&C++;return y.create(C)}}class Ym extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0;for(let _=1;_<a.length;_++){const E=a[_][l];E!=null&&Xe(d,a,_)&&C++}return y.create(C)}}class Hm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];b!=null&&Xe(d,a,E)&&(C++,_=E)}return C===0?g.create(h.VALUE):C>1?g.create(h.NUM):e.get(_,l)}}class Gm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=-1/0,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Xe(d,a,E)&&(C=Math.max(C,b),_++)}return _===0?y.create(0):y.create(C)}}class Wm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=1/0,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Xe(d,a,E)&&(C=Math.min(C,b),_++)}return _===0?y.create(0):y.create(C)}}class Qm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=1,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Xe(d,a,E)&&(C*=b,_++)}return _===0?y.create(0):y.create(C)}}class qm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const C=[];let _=0,E=0;for(let V=1;V<a.length;V++){const S=a[V][l];typeof S=="number"&&Xe(d,a,V)&&(C.push(S),_+=S,E++)}if(E<=1)return g.create(h.DIV_BY_ZERO);const b=_/E;let R=0;for(let V=0;V<E;V++)R+=(C[V]-b)**2;const p=Math.sqrt(R/(E-1));return y.create(p)}}class Xm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const C=[];let _=0,E=0;for(let V=1;V<a.length;V++){const S=a[V][l];typeof S=="number"&&Xe(d,a,V)&&(C.push(S),_+=S,E++)}if(E===0)return g.create(h.DIV_BY_ZERO);const b=_/E;let R=0;for(let V=0;V<E;V++)R+=(C[V]-b)**2;const p=Math.sqrt(R/E);return y.create(p)}}class Km extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0;for(let _=1;_<a.length;_++){const E=a[_][l];typeof E=="number"&&Xe(d,a,_)&&(C+=E)}return y.create(C)}}class Zm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const C=[];let _=0,E=0;for(let V=1;V<a.length;V++){const S=a[V][l];typeof S=="number"&&Xe(d,a,V)&&(C.push(S),_+=S,E++)}if(E<=1)return g.create(h.DIV_BY_ZERO);const b=_/E;let R=0;for(let V=0;V<E;V++)R+=(C[V]-b)**2;const p=R/(E-1);return y.create(p)}}class zm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const C=[];let _=0,E=0;for(let V=1;V<a.length;V++){const S=a[V][l];typeof S=="number"&&Xe(d,a,V)&&(C.push(S),_+=S,E++)}if(E===0)return g.create(h.DIV_BY_ZERO);const b=_/E;let R=0;for(let V=0;V<E;V++)R+=(C[V]-b)**2;const p=R/E;return y.create(p)}}var Te=(i=>(i.DAVERAGE="DAVERAGE",i.DCOUNT="DCOUNT",i.DCOUNTA="DCOUNTA",i.DGET="DGET",i.DMAX="DMAX",i.DMIN="DMIN",i.DPRODUCT="DPRODUCT",i.DSTDEV="DSTDEV",i.DSTDEVP="DSTDEVP",i.DSUM="DSUM",i.DVAR="DVAR",i.DVARP="DVARP",i))(Te||{});const Go=[[km,Te.DAVERAGE],[$m,Te.DCOUNT],[Ym,Te.DCOUNTA],[Hm,Te.DGET],[Gm,Te.DMAX],[Wm,Te.DMIN],[Qm,Te.DPRODUCT],[qm,Te.DSTDEV],[Xm,Te.DSTDEVP],[Km,Te.DSUM],[Zm,Te.DVAR],[zm,Te.DVARP]];var ye=(i=>(i.DATE="DATE",i.DATEDIF="DATEDIF",i.DATEVALUE="DATEVALUE",i.DAY="DAY",i.DAYS="DAYS",i.DAYS360="DAYS360",i.EDATE="EDATE",i.EOMONTH="EOMONTH",i.HOUR="HOUR",i.ISOWEEKNUM="ISOWEEKNUM",i.MINUTE="MINUTE",i.MONTH="MONTH",i.NETWORKDAYS="NETWORKDAYS",i.NETWORKDAYS_INTL="NETWORKDAYS.INTL",i.NOW="NOW",i.SECOND="SECOND",i.TIME="TIME",i.TIMEVALUE="TIMEVALUE",i.TODAY="TODAY",i.WEEKDAY="WEEKDAY",i.WEEKNUM="WEEKNUM",i.WORKDAY="WORKDAY",i.WORKDAY_INTL="WORKDAY.INTL",i.YEAR="YEAR",i.YEARFRAC="YEARFRAC",i))(ye||{});const ea="yyyy/mm/dd;@",Jm="yyyy/mm/dd hh:mm",eh="h:mm A/P";function Ee(i){const o=new Date(Date.UTC(1900,0,1)),e=new Date(Date.UTC(1900,1,28)),t=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate());let r=(t-o.getTime())/(1e3*3600*24);return t>e.getTime()&&(r+=1),Math.floor(r)+1}function Fn(i){const o=new Date(Date.UTC(1900,0,1,0,0,0)),e=new Date(Date.UTC(1900,1,28,0,0,0));let r=(i.getTime()-o.getTime())/(1e3*3600*24);return i>e&&(r+=1),r+1}function re(i){const o=new Date(Date.UTC(1900,0,1)),e=new Date(Date.UTC(1900,1,28));let t=Math.floor(i)-1;return t>(e.getTime()-o.getTime())/(1e3*3600*24)&&(t-=1),new Date(o.getTime()+t*(1e3*3600*24))}function ta(i){const o=new Date(Date.UTC(1900,0,1,0,0,0)),e=new Date(Date.UTC(1900,1,28,0,0,0));let t=i-1;return t>(e.getTime()-o.getTime())/(1e3*3600*24)&&(t-=1),t<0&&(t=i),new Date(o.getTime()+t*(1e3*3600*24))}function ra(i){if(!/^\d{4}[-/](0?[1-9]|1[012])[-/](0?[1-9]|[12][0-9]|3[01])$/.test(i))return!1;const e=i.replace(/-/g,"/").replace(/T.+/,""),t=new Date(`${e}`);if(Number.isNaN(t.getTime()))return!1;const r=t.getFullYear(),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=`${r}-${n}-${s}`;return i.replace(/\//g,"-").split("-").map(c=>c.padStart(2,"0")).join("-")===a}function Ya(i){return M.numfmt.parseDate(i)}function Wo(i){return M.numfmt.parseValue(i)}function Ha(i){return M.numfmt.parseTime(i)}function Qo(i){return M.numfmt.isDate(i)}const qo={1:[6,0],2:[0,1],3:[1,2],4:[2,3],5:[3,4],6:[4,5],7:[5,6],11:[0],12:[1],13:[2],14:[3],15:[4],16:[5],17:[6]};function pr(i){return!!(typeof i=="string"&&/^[0|1]{7}/.test(i)||qo[Number(i)])}function Xo(i){if(!pr(i))return[];if(typeof i=="string"&&/^[0|1]{7}/.test(i)){const o=[];for(let e=1;e<=i.length;e++)`${i[e-1]}`=="1"&&(e===i.length?o.push(0):o.push(e));return o}return qo[Number(i)]||[]}function ln(i,o,e=1,t){const r=Xo(e),n=Math.floor(i),s=Math.floor(o),a=s>n?n:s;let u=0;const c=Math.abs(Math.floor(o)-Math.floor(i))+1;for(let l=0;l<c;l++){const f=a+l;if(t&&t.length>0&&t.some(d=>Math.floor(d)===f))continue;const m=Gt(f);r.includes(m)||u++}return s>n?u:-u}function fn(i,o,e=1,t){const r=Xo(e),n=Math.floor(i);let s=n,a=Math.abs(o);for(let u=1;u<=a;u++){const c=o<0?n-u:n+u;if(c<0)return g.create(h.NUM);if(t&&t.length>0&&t.some(f=>Math.floor(f)===c)){a++;continue}const l=Gt(c);if(r.includes(l)){a++;continue}s=c}return s}function F(i){if(i.isError())return i;const o=i.getValue();if(i.isString()){let e;if(Ya(`${o}`))e=Ya(`${o}`).v;else if(Ha(`${o}`))e=Ha(`${o}`).v;else if(M.isRealNum(o))e=+o;else return g.create(h.VALUE);return e instanceof Date&&(e=Fn(e)),+e<0||+e>2958465?g.create(h.NUM):+e}else{const e=+i.getValue();return e<0||e>2958465?g.create(h.NUM):e}}function Gt(i){const o=Math.floor(i)===60;let e=re(i);const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())).getTime(),r=new Date(Date.UTC(1900,1,28)).getTime();return!o&&t<=r&&(e=new Date(t-24*3600*1e3)),new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())).getUTCDay()}function Ce(i,o,e){switch(e){case 0:return th(i,o);case 1:return rh(i,o);case 2:return{days:Math.abs(o-i),yearDays:360};case 3:return{days:Math.abs(o-i),yearDays:365};case 4:return nh(i,o);default:return{days:Math.abs(o-i),yearDays:365}}}function th(i,o){const e=re(i),t=i>0?e.getUTCFullYear():1900,r=i>0?e.getUTCMonth()+1:1;let n=i>0?e.getUTCDate():0,s=re(o),a=o>0?s.getUTCFullYear():1900,u=o>0?s.getUTCMonth()+1:1,c=o>0?s.getUTCDate():0;r===2?re(i+1).getUTCMonth()+1===3&&(n=30):n===31&&(n=30),c===31&&(n<30?(s=re(o+1),a=s.getUTCFullYear(),u=s.getUTCMonth()+1,c=s.getUTCDate()):c=30);const l=(a-t)*360,f=o>=i?30-n:-n,m=o>=i?c:c-30,d=(o>=i?u-r-1:u-r+1)*30;return{days:Math.abs(l+f+m+d),yearDays:360}}function rh(i,o){const e=re(i),t=i>0?e.getUTCFullYear():1900,r=re(o),n=o>0?r.getUTCFullYear():1900,s=Math.abs(o-i),a=Math.abs(n-t)+1;let u,c;if(n<t){const l=new Date(Date.UTC(n,0,1)),f=new Date(Date.UTC(t,11,31));u=Ee(l),c=Ee(f),n===1900&&(u+=1)}else{const l=new Date(Date.UTC(t,0,1)),f=new Date(Date.UTC(n,11,31));u=Ee(l),c=Ee(f),t===1900&&(u+=1)}return{days:s,yearDays:(c-u+1)/a}}function nh(i,o){const e=re(i),t=i>0?e.getUTCFullYear():1900,r=i>0?e.getUTCMonth()+1:1;let n=i>0?e.getUTCDate():0;const s=re(o),a=o>0?s.getUTCFullYear():1900,u=o>0?s.getUTCMonth()+1:1;let c=o>0?s.getUTCDate():0;n===31&&(n=30),c===31&&(c=30);const l=(a-t)*360,f=o>=i?30-n:-n,m=o>=i?c:c-30,d=(o>=i?u-r-1:u-r+1)*30;return{days:Math.abs(l+f+m+d),yearDays:360}}function sh(i){return i%4===0&&i%100!==0||i%400===0}function ah(i){return i%4===0&&i%100!==0||i%400===0||i===1900}const ih=[31,29,31,30,31,30,31,31,30,31,30,31],oh=[31,28,31,30,31,30,31,31,30,31,30,31];function xr(i,o){return sh(i)?ih[o]:oh[o]}function kn(i){return ah(i)?366:365}function Ko(i,o){switch(o){case 0:case 2:case 4:return 360;case 1:return kn(re(i).getUTCFullYear());case 3:return 365;default:return-1}}function or(i,o,e){return xr(i,o)===e}function ur(i,o){let e=i.getUTCFullYear(),t=i.getUTCMonth();const r=i.getUTCDate();return or(e,t,r)?(i.setUTCDate(1),i.setUTCMonth(i.getUTCMonth()+o),e=i.getUTCFullYear(),t=i.getUTCMonth(),i.setUTCDate(xr(e,t))):i.setUTCMonth(i.getUTCMonth()+o),i}class uh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e),u=O(n,s,t),c=O(n,s,r);return a.map((l,f,m)=>{const d=u.get(f,m)||ae.create(),C=c.get(f,m)||ae.create();if(l.isError())return l;if(d.isError())return d;if(C.isError())return C;if(l.isString()||d.isString()||C.isString())return g.create(h.VALUE);let _=+l.getValue();const E=Math.floor(+d.getValue()),b=+C.getValue();if(_<0||_>9999)return g.create(h.NUM);_>=0&&_<1899&&(_+=1900);const R=new Date(_,E-1,b),p=Ee(R);return p<0?g.create(h.NUM):y.create(p,ea)})}}class ch extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t,a=r;if(n.isArray()&&(n=n.get(0,0)),s.isArray()&&(s=s.get(0,0)),a.isArray()&&(a=a.get(0,0)),n.isError())return n;if(s.isError())return s;if(a.isError())return a;const u=F(n);if(typeof u!="number")return u;const c=F(s);return typeof c!="number"?c:c<u||!a.isString()?g.create(h.NUM):this._getResultByUnit(u,c,a)}_getResultByUnit(e,t,r){const n=re(e),s=n.getUTCFullYear(),a=n.getUTCMonth()+1,u=n.getUTCDate(),c=re(t),l=c.getUTCFullYear(),f=c.getUTCMonth()+1,m=c.getUTCDate(),d=`${r.getValue()}`.toLocaleUpperCase();let C=0,_;switch(d){case"Y":C=l-s,(f<a||f===a&&m<u)&&(C-=1);break;case"M":C=(l-s)*12+f-a,m<u&&(C-=1);break;case"D":C=Math.floor(t)-Math.floor(e);break;case"MD":C=m-u,m<u&&(_=new Date(Date.UTC(l,f-1,0)),C+=xr(_.getUTCFullYear(),_.getUTCMonth()));break;case"YM":C=f-a,(f<a||f===a&&m<u)&&(C+=12),m<u&&(C-=1);break;case"YD":_=new Date(Date.UTC(s,f-1,m)),(f<a||f===a&&m<u)&&(_=new Date(Date.UTC(s+1,f-1,m))),C=Math.floor(Ee(_))-Math.floor(e);break;default:return g.create(h.NUM)}return y.create(C)}}class lh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isString()){const t=`${e.getValue()}`,r=Wo(t);if(r){let{v:n,z:s}=r;if(s&&Qo(s))return n instanceof Date&&(n=Fn(n)),y.create(Math.trunc(+n))}}return g.create(h.VALUE)}}class fh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t;const r=e.getValue();if(e.isString()){if(!ra(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+e.getValue();if(a<0)return g.create(h.NUM);if(a===0)return y.create(0);t=re(a)}const n=t.getDate();return y.create(n)}}class mh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t),u=s.map((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const d=F(c);if(typeof d!="number")return d;const C=F(m);if(typeof C!="number")return C;const _=Math.floor(d)-Math.floor(C);return y.create(_)});return r===1&&n===1?u.get(0,0):u}}class hh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:k.create(!1);if(e.isError())return e;if(t.isError())return t;if(n.isError())return n;const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.map((m,d,C)=>{const _=c.get(d,C);let E=l.get(d,C);if(m.isError())return m;const b=F(m);if(typeof b!="number")return b;if(_.isError())return _;const R=F(_);if(typeof R!="number")return R;if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;const p=+E.getValue(),{days:V}=Ce(b,R,p?4:0),S=R>=b?V:-V;return y.create(S)});return s===1&&a===1?f.get(0,0):f}}class gh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.map((u,c,l)=>{const f=a.get(c,l)||ae.create();if(u.isError())return u;if(f.isError())return f;if(u.isString()||u.isBoolean()||f.isString()||f.isBoolean())return g.create(h.VALUE);const m=+u.getValue();if(m<0)return g.create(h.NUM);const d=Math.floor(+f.getValue()),C=re(m),_=C.getUTCFullYear(),E=C.getUTCMonth()+d,b=C.getUTCDate(),R=new Date(Date.UTC(_,E,b)),p=Ee(R);return y.create(p,ea)})}}class dh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e,n=t;if(r.isArray()){const d=r.getRowCount(),C=r.getColumnCount();if(d>1||C>1)return g.create(h.VALUE);r=r.get(0,0)}if(n.isArray()){const d=n.getRowCount(),C=n.getColumnCount();if(d>1||C>1)return g.create(h.VALUE);n=n.get(0,0)}if(r.isError())return r;if(n.isError())return n;const s=F(r);if(typeof s!="number")return s;if(n.isBoolean())return g.create(h.VALUE);const a=re(s),u=s>0?a.getUTCFullYear():1900,c=s>0?a.getUTCMonth():0,l=Math.floor(+n.getValue());if(Number.isNaN(l))return g.create(h.VALUE);const f=new Date(Date.UTC(u,c+l+1,0)),m=Ee(f);return y.create(m)}}class Ch extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=F(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ta(t).getUTCHours();return y.create(n)}}class _h extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=F(e);if(typeof t!="number")return t;const r=re(t),n=t>0?r.getUTCFullYear():1900;let s=new Date(Date.UTC(n,0,1)),a=Ee(s),u=Gt(a),c;u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u),t<c&&(s=new Date(Date.UTC(n-1,0,1)),a=Ee(s),u=Gt(a),u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u));const l=Math.ceil((t-c+1)/7);return y.create(l)}}class Ah extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=F(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ta(t).getUTCMinutes();return y.create(n)}}class Eh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;let t;const r=e.getValue();if(e.isString()){if(!ra(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+e.getValue();if(a<0)return g.create(h.NUM);if(a===0)return y.create(1);t=re(a)}const n=t.getUTCMonth()+1;return y.create(n)}}class bh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t;if(n.isArray()){const l=n.getRowCount(),f=n.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(s.isArray()){const l=s.getRowCount(),f=s.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(r!=null&&r.isError())return r;if(n.isBoolean()||s.isBoolean())return g.create(h.VALUE);const a=F(n);if(typeof a!="number")return a;const u=F(s);if(typeof u!="number")return u;if(r)return this._getResultByHolidays(a,u,r);const c=ln(a,u);return y.create(c)}_getResultByHolidays(e,t,r){const n=[];if(r!=null&&r.isArray()){const a=r.getRowCount(),u=r.getColumnCount();for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=r.get(c,l);if(f.isBoolean())return g.create(h.VALUE);const m=F(f);if(typeof m!="number")return m;n.push(m)}}else{if(r.isBoolean())return g.create(h.VALUE);const a=F(r);if(typeof a!="number")return a;n.push(a)}const s=ln(e,t,1,n);return y.create(s)}}class yh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){return e.isError()?e:t.isError()?t:r!=null&&r.isError()?r:n!=null&&n.isError()?n:r!=null&&r.isArray()?r.map(s=>this._handleSingleObject(e,t,s,n)):this._handleSingleObject(e,t,r,n)}_handleSingleObject(e,t,r,n){let s=e,a=t;if(s.isArray()){const m=s.getRowCount(),d=s.getColumnCount();if(m>1||d>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(a.isArray()){const m=a.getRowCount(),d=a.getColumnCount();if(m>1||d>1)return g.create(h.VALUE);a=a.get(0,0)}if(a.isError())return a;let u=1;if(r){if(u=r.getValue(),r.isBoolean()&&(u=+u),r.isString()&&!pr(u))return g.create(h.VALUE);if(!pr(u))return g.create(h.NUM)}if(s.isBoolean()||a.isBoolean())return g.create(h.VALUE);const c=F(s);if(typeof c!="number")return c;const l=F(a);if(typeof l!="number")return l;if(n)return this._getResultByHolidays(c,l,u,n);const f=ln(c,l,u);return y.create(f)}_getResultByHolidays(e,t,r,n){const s=[];if(n!=null&&n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=n.get(l,f);if(m.isBoolean())return g.create(h.VALUE);const d=F(m);if(typeof d!="number")return d;s.push(d)}}else{if(n.isBoolean())return g.create(h.VALUE);const u=F(n);if(typeof u!="number")return u;s.push(u)}const a=ln(e,t,r,s);return y.create(a)}}class Rh extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){const e=new Date,t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())),r=Fn(t);return y.create(r,Jm)}}class ph extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=F(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ta(t).getUTCSeconds();return y.create(n)}}class Nh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e),u=O(n,s,t),c=O(n,s,r);return a.map((l,f,m)=>this._calculateTime(l,u,c,f,m))}_calculateTime(e,t,r,n,s){let a=e,u=t.get(n,s)||ae.create(),c=r.get(n,s)||ae.create();if((a.isString()||a.isBoolean())&&(a=a.convertToNumberObjectValue()),(u.isString()||u.isBoolean())&&(u=u.convertToNumberObjectValue()),(c.isString()||c.isBoolean())&&(c=c.convertToNumberObjectValue()),a.isError())return a;if(u.isError())return u;if(c.isError())return c;let l=Math.floor(+a.getValue()),f=Math.floor(+u.getValue()),m=Math.floor(+c.getValue());if(l<0||f<0||m<0||l>32767||f>32767||m>32767)return g.create(h.NUM);f+=Math.floor(m/60),m%=60,l+=Math.floor(f/60),f%=60,l%=24;const C=(l*3600+f*60+m)/86400;return y.create(C,eh)}}class Vh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isString()){const t=`${e.getValue()}`,r=Wo(t);if(r){let{v:n,z:s}=r;if(s&&Qo(s))return n instanceof Date&&(n=Fn(n)),y.create(Wl(+n))}}return g.create(h.VALUE)}}class Oh extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){const e=Ee(new Date);return y.create(e,ea)}}class Mh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"_returnTypeMap",{1:[1,2,3,4,5,6,7],2:[7,1,2,3,4,5,6],3:[6,0,1,2,3,4,5],11:[7,1,2,3,4,5,6],12:[6,7,1,2,3,4,5],13:[5,6,7,1,2,3,4],14:[4,5,6,7,1,2,3],15:[3,4,5,6,7,1,2],16:[2,3,4,5,6,7,1],17:[1,2,3,4,5,6,7]})}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{const d=u.get(f,m);return this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(r.isError())return r;const n=F(e);if(typeof n!="number")return n;if(r.isString()&&(r=r.convertToNumberObjectValue(),r.isError()))return r;const s=Math.floor(+r.getValue());if(!this._returnTypeMap[s])return g.create(h.NUM);const a=Gt(n),u=this._returnTypeMap[s][a];return y.create(u)}}class Sh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"_returnTypeMap",{1:0,2:1,11:1,12:2,13:3,14:4,15:5,16:6,17:0,21:4})}calculate(e,t){let r=e,n=t!=null?t:y.create(1);if(r.isArray()){const u=r.getRowCount(),c=r.getColumnCount();if(u>1||c>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;if(n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();if(u>1||c>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean())return g.create(h.VALUE);const s=F(r);if(typeof s!="number")return s;if(n.isBoolean())return g.create(h.VALUE);const a=Math.floor(+n.getValue());return Number.isNaN(a)?g.create(h.VALUE):a in this._returnTypeMap?this._getResult(s,a):g.create(h.NUM)}_getResult(e,t){const r=re(e),n=e>0?r.getUTCFullYear():1900;let s=new Date(Date.UTC(n,0,1)),a=Ee(s),u=Gt(a),c;if(t===21)u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u),e<c&&(s=new Date(Date.UTC(n-1,0,1)),a=Ee(s),u=Gt(a),u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u));else{const f=this._returnTypeMap[t];u<f?c=a-(u+7-f):c=a-(u-f)}const l=Math.ceil((e-c+1)/7);return y.create(l)}}class Dh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t;if(n.isArray()){const l=n.getRowCount(),f=n.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(s.isArray()){const l=s.getRowCount(),f=s.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(r!=null&&r.isError())return r;if(n.isBoolean()||s.isBoolean())return g.create(h.VALUE);const a=F(n);if(typeof a!="number")return a;const u=+s.getValue();if(Number.isNaN(u))return g.create(h.VALUE);if(r)return this._getResultByHolidays(a,u,r);const c=fn(a,u);return typeof c!="number"?c:y.create(c)}_getResultByHolidays(e,t,r){const n=[];if(r!=null&&r.isArray()){const a=r.getRowCount(),u=r.getColumnCount();for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=r.get(c,l);if(f.isBoolean())return g.create(h.VALUE);const m=F(f);if(typeof m!="number")return m;n.push(m)}}else{if(r.isBoolean())return g.create(h.VALUE);const a=F(r);if(typeof a!="number")return a;n.push(a)}const s=fn(e,t,1,n);return typeof s!="number"?s:y.create(s)}}class wh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){return e.isError()?e:t.isError()?t:r!=null&&r.isError()?r:n!=null&&n.isError()?n:r!=null&&r.isArray()?r.map(s=>this._handleSingleObject(e,t,s,n)):this._handleSingleObject(e,t,r,n)}_handleSingleObject(e,t,r,n){const s=r!=null?r:y.create(1),a=this._checkArrayError(e);if(a.isError())return a;const u=this._checkArrayError(t);if(u.isError())return u;if(a.isBoolean()||u.isBoolean())return g.create(h.VALUE);const c=F(e);if(typeof c!="number")return c;const l=+t.getValue();if(Number.isNaN(l))return g.create(h.VALUE);let f=s.getValue();if(s.isBoolean()&&(f=+f),s.isString()&&(!pr(f)||f==="1111111"))return g.create(h.VALUE);if(!pr(f))return g.create(h.NUM);if(n)return this._getResultByHolidays(c,l,f,n);const m=fn(c,l,f);return typeof m!="number"?m:y.create(m)}_checkArrayError(e){let t=e;if(t.isArray()){const r=t.getRowCount(),n=t.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=t.get(0,0)}return t.isError(),t}_getResultByHolidays(e,t,r,n){const s=[];if(n!=null&&n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=n.get(l,f);if(m.isBoolean())return g.create(h.VALUE);const d=F(m);if(typeof d!="number")return d;s.push(d)}}else{if(n.isBoolean())return g.create(h.VALUE);const u=F(n);if(typeof u!="number")return u;s.push(u)}const a=fn(e,t,r,s);return typeof a!="number"?a:y.create(a)}}class Ph extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;let t;const r=e.getValue();if(e.isString()){if(!ra(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+r;if(a<0)return g.create(h.NUM);if(a===0)return y.create(1900);t=re(a)}const n=t.getUTCFullYear();return y.create(n)}}class Lh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:y.create(0);const s=rr(e);if(s.isError())return s;const a=rr(t);if(a.isError())return a;if(n=rr(n),n.isError())return n;if(s.isBoolean()||a.isBoolean()||n.isBoolean())return g.create(h.VALUE);const u=F(s);if(typeof u!="number")return u;const c=F(a);if(typeof c!="number")return c;const l=Math.floor(+n.getValue());if(Number.isNaN(l))return g.create(h.VALUE);if(l<0||l>4)return g.create(h.NUM);const{days:f,yearDays:m}=Ce(u,c,l),d=f/m;return y.create(d)}}const Zo=[[uh,ye.DATE],[ch,ye.DATEDIF],[lh,ye.DATEVALUE],[fh,ye.DAY],[mh,ye.DAYS],[hh,ye.DAYS360],[gh,ye.EDATE],[dh,ye.EOMONTH],[Ch,ye.HOUR],[_h,ye.ISOWEEKNUM],[Ah,ye.MINUTE],[Eh,ye.MONTH],[bh,ye.NETWORKDAYS],[yh,ye.NETWORKDAYS_INTL],[Rh,ye.NOW],[ph,ye.SECOND],[Nh,ye.TIME],[Vh,ye.TIMEVALUE],[Oh,ye.TODAY],[Mh,ye.WEEKDAY],[Sh,ye.WEEKNUM],[Dh,ye.WORKDAY],[wh,ye.WORKDAY_INTL],[Ph,ye.YEAR],[Lh,ye.YEARFRAC]];var z=(i=>(i.BESSELI="BESSELI",i.BESSELJ="BESSELJ",i.BESSELK="BESSELK",i.BESSELY="BESSELY",i.BIN2DEC="BIN2DEC",i.BIN2HEX="BIN2HEX",i.BIN2OCT="BIN2OCT",i.BITAND="BITAND",i.BITLSHIFT="BITLSHIFT",i.BITOR="BITOR",i.BITRSHIFT="BITRSHIFT",i.BITXOR="BITXOR",i.COMPLEX="COMPLEX",i.CONVERT="CONVERT",i.DEC2BIN="DEC2BIN",i.DEC2HEX="DEC2HEX",i.DEC2OCT="DEC2OCT",i.DELTA="DELTA",i.ERF="ERF",i.ERF_PRECISE="ERF.PRECISE",i.ERFC="ERFC",i.ERFC_PRECISE="ERFC.PRECISE",i.GESTEP="GESTEP",i.HEX2BIN="HEX2BIN",i.HEX2DEC="HEX2DEC",i.HEX2OCT="HEX2OCT",i.IMABS="IMABS",i.IMAGINARY="IMAGINARY",i.IMARGUMENT="IMARGUMENT",i.IMCONJUGATE="IMCONJUGATE",i.IMCOS="IMCOS",i.IMCOSH="IMCOSH",i.IMCOT="IMCOT",i.IMCSC="IMCSC",i.IMCSCH="IMCSCH",i.IMDIV="IMDIV",i.IMEXP="IMEXP",i.IMLN="IMLN",i.IMLOG10="IMLOG10",i.IMLOG2="IMLOG2",i.IMPOWER="IMPOWER",i.IMPRODUCT="IMPRODUCT",i.IMREAL="IMREAL",i.IMSEC="IMSEC",i.IMSECH="IMSECH",i.IMSIN="IMSIN",i.IMSINH="IMSINH",i.IMSQRT="IMSQRT",i.IMSUB="IMSUB",i.IMSUM="IMSUM",i.IMTAN="IMTAN",i.OCT2BIN="OCT2BIN",i.OCT2DEC="OCT2DEC",i.OCT2HEX="OCT2HEX",i))(z||{});class xh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besseli(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class jh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besselj(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Uh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besselk(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class vh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.bessely(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Th extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!Is(a))return g.create(h.NUM);let u;return a.length===10&&a.substring(0,1)==="1"?u=Number.parseInt(a.substring(1),2)-512:u=Number.parseInt(a,2),y.create(u)}}class Bh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Is(c))return g.create(h.NUM);let l;if(c.length===10&&c.substring(0,1)==="1")l=(0xfffffffe00+Number.parseInt(c.substring(1),2)).toString(16);else if(l=Number.parseInt(c,2).toString(16),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l.toLocaleUpperCase())}}class Ih extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Is(c))return g.create(h.NUM);let l;if(c.length===10&&c.substring(0,1)==="1")l=(1073741312+Number.parseInt(c.substring(1),2)).toString(8);else if(l=Number.parseInt(c,2).toString(8),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l)}}class Fh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue(),_=+d.getValue();if(C<0||_<0||Math.floor(C)!==C||Math.floor(_)!==_||C>0xffffffffffff||_>0xffffffffffff)return g.create(h.NUM);const E=C&_;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class kh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue();let _=+d.getValue();if(C<0||Math.floor(C)!==C||C>0xffffffffffff||Math.abs(_)>53)return g.create(h.NUM);_=Math.trunc(_);const E=Number(_>=0?BigInt(C)<<BigInt(_):BigInt(C)>>BigInt(-_));return E>0xffffffffffff?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class $h extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue(),_=+d.getValue();if(C<0||_<0||Math.floor(C)!==C||Math.floor(_)!==_||C>0xffffffffffff||_>0xffffffffffff)return g.create(h.NUM);const E=Number(BigInt(C)|BigInt(_));return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Yh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue();let _=+d.getValue();if(C<0||Math.floor(C)!==C||C>0xffffffffffff||Math.abs(_)>53)return g.create(h.NUM);_=Math.trunc(_);const E=Number(_>=0?BigInt(C)>>BigInt(_):BigInt(C)<<BigInt(-_));return E>0xffffffffffff?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Hh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue(),_=+d.getValue();if(C<0||_<0||Math.floor(C)!==C||Math.floor(_)!==_||C>0xffffffffffff||_>0xffffffffffff)return g.create(h.NUM);const E=C^_;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}x.prototype.cos=function(){const i=this.toNumber();return new x(Math.cos(i))};let de=class fe{constructor(o){A(this,"_inumber","");A(this,"_realNum",0);A(this,"_iNum",0);A(this,"_suffix","");A(this,"_isError",!1);if(`${o}`.trim()===""){this._isError=!0;return}this._inumber=o,this._getImReal(),this._getImAginary(),this._getImSuffix()}static getComplex(o,e,t){const r=new x(o).toSignificantDigits(15).toNumber(),n=new x(e).toSignificantDigits(15).toNumber(),s=t===""?"i":t;let a;if(r===0&&n===0)a=0;else if(r===0)a=n===1?s:`${n}${s}`;else if(n===0)a=r;else{const u=n>0?"+":"",c=n===1?s:`${n}${s}`;a=`${r}${u}${c}`}return a}static createByComplexStr(o,e,t){const r=fe.getComplex(o,e,t);return new fe(r)}_getImReal(){if(this._inumber===0||this._inumber==="0"){this._realNum=0;return}const o=`${this._inumber}`;if(["i","+i","1i","+1i","-i","-1i","j","+j","1j","+1j","-j","-1j"].indexOf(o)>=0){this._realNum=0;return}let e=o.indexOf("+"),t=o.indexOf("-");e===0&&(e=o.indexOf("+",1)),t===0&&(t=o.indexOf("-",1));const r=o.substring(o.length-1,o.length),n=r==="i"||r==="j";if(e>=0||t>=0){if(!n){this._isError=!0;return}e>=0?Number.isNaN(+o.substring(0,e))||Number.isNaN(+o.substring(e+1,o.length-1))?this._isError=!0:this._realNum=+o.substring(0,e):Number.isNaN(+o.substring(0,t))||Number.isNaN(+o.substring(t+1,o.length-1))?this._isError=!0:this._realNum=+o.substring(0,t)}else n?Number.isNaN(+o.substring(0,o.length-1))?this._isError=!0:this._realNum=0:Number.isNaN(+o)?this._isError=!0:this._realNum=+o}_getImAginary(){if(this._isError)return;if(this._inumber===0||this._inumber==="0"){this._iNum=0;return}let o=`${this._inumber}`;if(["i","j"].indexOf(o)>=0){this._iNum=1;return}o=o.replace("+i","+1i").replace("-i","-1i").replace("+j","+1j").replace("-j","-1j");let e=o.indexOf("+"),t=o.indexOf("-");e===0&&(e=o.indexOf("+",1)),t===0&&(t=o.indexOf("-",1));const r=o.substring(o.length-1,o.length),n=r==="i"||r==="j";if(e>=0||t>=0){if(!n){this._isError=!0;return}e>=0?Number.isNaN(+o.substring(0,e))||Number.isNaN(+o.substring(e+1,o.length-1))?this._isError=!0:this._iNum=+o.substring(e+1,o.length-1):Number.isNaN(+o.substring(0,t))||Number.isNaN(+o.substring(t+1,o.length-1))?this._isError=!0:this._iNum=-+o.substring(t+1,o.length-1)}else n?Number.isNaN(+o.substring(0,o.length-1))?this._isError=!0:this._iNum=+o.substring(0,o.length-1):Number.isNaN(+o)?this._isError=!0:this._iNum=0}_getImSuffix(){const o=`${this._inumber}`,e=o.substring(o.length-1);this._suffix=e==="i"||e==="j"?e:""}getRealNum(){return this._realNum}getINum(){return this._iNum}getSuffix(){return this._suffix}isError(){return this._isError}toString(){return fe.getComplex(this._realNum,this._iNum,this._suffix)}isDifferentSuffixes(o){const e=o.getSuffix();return this._suffix===""||e===""?!1:this._suffix!==e}Abs(){return x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))).toSignificantDigits(16).toNumber()}Argument(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2)));let e=x.acos(new x(this._realNum).div(o)).toSignificantDigits(16).toNumber();return this._iNum<0&&(e=-e),e}Conjugate(){return fe.getComplex(this._realNum,-this._iNum,this._suffix)}Cos(){if(this._iNum){const o=x.cos(this._realNum).mul(x.cosh(this._iNum)).toNumber(),e=x.sin(this._realNum).mul(x.sinh(this._iNum)).negated().toNumber();return fe.getComplex(o,e,this._suffix)}else{const o=x.cos(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Cosh(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return this._isError=!0,"";if(this._iNum){const o=x.cosh(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.sinh(this._realNum).mul(x.sin(this._iNum)).toNumber();return fe.getComplex(o,e,this._suffix)}else{const o=x.cosh(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Cot(){if(this._iNum){const o=x.cosh(this._iNum*2).sub(x.cos(this._realNum*2)),e=x.sin(this._realNum*2).div(o).toNumber(),t=x.sinh(this._iNum*2).div(o).negated().toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.tan(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Csc(){if(this._iNum){const o=x.cosh(this._iNum*2).sub(x.cos(this._realNum*2)),e=x.sin(this._realNum).mul(x.cosh(this._iNum)).mul(2).div(o).toNumber(),t=x.cos(this._realNum).mul(x.sinh(this._iNum)).mul(-2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.sin(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Csch(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return fe.getComplex(0,0,this._suffix);if(this._iNum){const o=x.cosh(this._realNum*2).sub(x.cos(this._iNum*2)),e=x.sinh(this._realNum).mul(x.cos(this._iNum)).mul(2).div(o).toNumber(),t=x.cosh(this._realNum).mul(x.sin(this._iNum)).mul(-2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.sinh(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Div(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=r.mul(r).add(n.mul(n)),a=e.mul(r).add(t.mul(n)).div(s).toNumber(),u=t.mul(r).sub(e.mul(n)).div(s).toNumber(),c=this._suffix===""?o.getSuffix():this._suffix;return fe.getComplex(a,u,c)}Exp(){if(!Number.isFinite(Math.exp(this._realNum)))return this._isError=!0,"";const o=x.exp(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.exp(this._realNum).mul(x.sin(this._iNum)).toNumber();return fe.getComplex(o,e,this._suffix)}Ln(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.ln(o).toNumber(),t=x.acos(new x(this._realNum).div(o)).toNumber();return fe.getComplex(e,t,this._suffix)}Log10(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.ln(o);let t=x.acos(new x(this._realNum).div(o));this._iNum<0&&(t=t.negated());const r=x.ln(10),n=new x(0),s=r.mul(r).add(n.mul(n)),a=e.mul(r).add(t.mul(n)).div(s).toNumber(),u=t.mul(r).sub(e.mul(n)).div(s).toNumber();return fe.getComplex(a,u,this._suffix)}Log2(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.ln(o);let t=x.acos(new x(this._realNum).div(o));this._iNum<0&&(t=t.negated());const r=x.ln(2),n=new x(0),s=r.mul(r).add(n.mul(n)),a=e.mul(r).add(t.mul(n)).div(s).toNumber(),u=t.mul(r).sub(e.mul(n)).div(s).toNumber();return fe.getComplex(a,u,this._suffix)}Power(o){if(this._realNum===0&&this._iNum===0)return o>0?fe.getComplex(this._realNum,this._iNum,this._suffix):(this._isError=!0,"");let e=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),t=x.acos(new x(this._realNum).div(e));this._iNum<0&&(t=t.negated()),e=x.pow(e,o),t=t.mul(o);const r=x.cos(t).mul(e).toNumber(),n=x.sin(t).mul(e).toNumber();return!Number.isFinite(r)||!Number.isFinite(n)?(this._isError=!0,""):fe.getComplex(r,n,this._suffix)}Product(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.mul(r).sub(t.mul(n)).toNumber(),a=e.mul(n).add(t.mul(r)).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return fe.getComplex(s,a,u)}Sec(){if(this._iNum){const o=x.cosh(this._iNum*2).add(x.cos(this._realNum*2)),e=x.cos(this._realNum).mul(x.cosh(this._iNum)).mul(2).div(o).toNumber(),t=x.sin(this._realNum).mul(x.sinh(this._iNum)).mul(2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.cos(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Sech(){if(!Number.isFinite(Math.sinh(this._realNum*2))||!Number.isFinite(Math.cosh(this._realNum*2)))return fe.getComplex(0,0,this._suffix);if(this._iNum){const o=x.cosh(this._realNum*2).add(x.cos(this._iNum*2)),e=x.cosh(this._realNum).mul(x.cos(this._iNum)).mul(2).div(o).toNumber(),t=x.sinh(this._realNum).mul(x.sin(this._iNum)).mul(-2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.cosh(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Sin(){if(this._iNum){const o=x.sin(this._realNum).mul(x.cosh(this._iNum)).toNumber(),e=x.cos(this._realNum).mul(x.sinh(this._iNum)).toNumber();return fe.getComplex(o,e,this._suffix)}else{const o=x.sin(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Sinh(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return this._isError=!0,"";if(this._iNum){const o=x.sinh(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.cosh(this._realNum).mul(x.sin(this._iNum)).toNumber();return fe.getComplex(o,e,this._suffix)}else{const o=x.sinh(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Sqrt(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.sqrt(o);let t=x.acos(new x(this._realNum).div(o));this._iNum<0&&(t=t.negated());const r=e.mul(x.cos(t.div(2).toNumber())).toNumber(),n=e.mul(x.sin(t.div(2))).toNumber();return fe.getComplex(r,n,this._suffix)}Sub(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.sub(r).toNumber(),a=t.sub(n).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return fe.getComplex(s,a,u)}Sum(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.add(r).toNumber(),a=t.add(n).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return fe.getComplex(s,a,u)}Tan(){if(this._iNum){const o=x.cos(this._realNum*2).add(x.cosh(this._iNum*2)),e=x.sin(this._realNum*2).div(o).toNumber(),t=x.sinh(this._iNum*2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=x.tan(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}};class Gh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:j.create("i"),{isError:s,errorObject:a,variants:u}=H(e,t,n);if(s)return a;const[c,l,f]=u,m=+c.getValue(),d=+l.getValue(),C=`${f.getValue()}`;if(Number.isNaN(m)||Number.isNaN(d)||C!=="i"&&C!=="j")return g.create(h.VALUE);const _=de.getComplex(m,d,C);return typeof _=="number"?y.create(_):j.create(_)}}class Wh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"_units",[["a.u. of action","?",null,"action",!1,!1,105457168181818e-48],["a.u. of charge","e",null,"electric_charge",!1,!1,160217653141414e-33],["a.u. of energy","Eh",null,"energy",!1,!1,435974417757576e-32],["a.u. of length","a?",null,"length",!1,!1,529177210818182e-25],["a.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["a.u. of time","?/Eh",null,"time",!1,!1,241888432650516e-31],["admiralty knot","admkn",null,"speed",!1,!0,.514773333],["ampere","A",null,"electric_current",!0,!1,1],["ampere per meter","A/m",null,"magnetic_field_intensity",!0,!1,1],["ångström","Å",["ang"],"length",!1,!0,1e-10],["are","ar",null,"area",!1,!0,100],["astronomical unit","ua",null,"length",!1,!1,149597870691667e-25],["bar","bar",null,"pressure",!1,!1,1e5],["barn","b",null,"area",!1,!1,1e-28],["becquerel","Bq",null,"radioactivity",!0,!1,1],["bit","bit",["b"],"information",!1,!0,1],["btu","BTU",["btu"],"energy",!1,!0,1055.05585262],["byte","byte",null,"information",!1,!0,8],["candela","cd",null,"luminous_intensity",!0,!1,1],["candela per square metre","cd/m?",null,"luminance",!0,!1,1],["centigrade","C",["cel"],"temperature",!0,!1,1],["cubic ångström","ang3",["ang^3"],"volume",!1,!0,1e-30],["cubic foot","ft3",["ft^3"],"volume",!1,!0,.028316846592],["cubic inch","in3",["in^3"],"volume",!1,!0,16387064e-12],["cubic light-year","ly3",["ly^3"],"volume",!1,!0,846786664623715e-61],["cubic metre","m3",["m^3"],"volume",!0,!0,1],["cubic mile","mi3",["mi^3"],"volume",!1,!0,416818182544058e-5],["cubic nautical mile","Nmi3",["Nmi^3"],"volume",!1,!0,6352182208],["cubic Pica","Pica3",["Picapt3","Pica^3","Picapt^3"],"volume",!1,!0,758660370370369e-22],["cubic yard","yd3",["yd^3"],"volume",!1,!0,.764554857984],["cup","cup",null,"volume",!1,!0,.0002365882365],["dalton","Da",["u"],"mass",!1,!1,166053886282828e-41],["day","d",["day"],"time",!1,!0,86400],["degree","°",null,"angle",!1,!1,.0174532925199433],["dyne","dyn",["dy"],"force",!1,!0,1e-5],["electronvolt","eV",["ev"],"energy",!1,!0,1.60217656514141],["ell","ell",null,"length",!1,!0,1.143],["erg","erg",["e"],"energy",!1,!0,1e-7],["fahrenheit","F",["fah"],"temperature",!0,!1,1],["fluid ounce","oz",null,"volume",!1,!0,295735295625e-16],["foot","ft",null,"length",!1,!0,.3048],["foot-pound","flb",null,"energy",!1,!0,1.3558179483314],["gal","Gal",null,"acceleration",!1,!1,.01],["gallon","gal",null,"volume",!1,!0,.003785411784],["gauss","G",["ga"],"magnetic_flux_density",!1,!0,1],["grain","grain",null,"mass",!1,!0,647989e-10],["gram","g",null,"mass",!1,!0,.001],["gray","Gy",null,"absorbed_dose",!0,!1,1],["gross registered ton","GRT",["regton"],"volume",!1,!0,2.8316846592],["hectare","ha",null,"area",!1,!0,1e4],["henry","H",null,"inductance",!0,!1,1],["hertz","Hz",null,"frequency",!0,!1,1],["horsepower","HP",["h"],"power",!1,!0,745.69987158227],["horsepower-hour","HPh",["hh","hph"],"energy",!1,!0,2684519538e-3],["hour","h",["hr"],"time",!1,!0,3600],["imperial gallon (U.K.)","uk_gal",null,"volume",!1,!0,.00454609],["imperial hundredweight","lcwt",["uk_cwt","hweight"],"mass",!1,!0,50.802345],["imperial quart (U.K)","uk_qt",null,"volume",!1,!0,.0011365225],["imperial ton","brton",["uk_ton","LTON"],"mass",!1,!0,1016.046909],["inch","in",null,"length",!1,!0,.0254],["international acre","uk_acre",null,"area",!1,!0,4046.8564224],["IT calorie","cal",null,"energy",!1,!0,4.1868],["joule","J",null,"energy",!0,!0,1],["katal","kat",null,"catalytic_activity",!0,!1,1],["kelvin","K",["kel"],"temperature",!0,!0,1],["kilogram","kg",null,"mass",!0,!0,1],["knot","kn",null,"speed",!1,!0,.514444444444444],["light-year","ly",null,"length",!1,!0,9460730472580800],["litre","L",["l","lt"],"volume",!1,!0,.001],["lumen","lm",null,"luminous_flux",!0,!1,1],["lux","lx",null,"illuminance",!0,!1,1],["maxwell","Mx",null,"magnetic_flux",!1,!1,1e-18],["measurement ton","MTON",null,"volume",!1,!0,1.13267386368],["meter per hour","m/h",["m/hr"],"speed",!1,!0,.00027777777777778],["meter per second","m/s",["m/sec"],"speed",!0,!0,1],["meter per second squared","m?s??",null,"acceleration",!0,!1,1],["parsec","pc",["parsec"],"length",!1,!0,0x6da012f958ee1c],["meter squared per second","m?/s",null,"kinematic_viscosity",!0,!1,1],["metre","m",null,"length",!0,!0,1],["miles per hour","mph",null,"speed",!1,!0,.44704],["millimetre of mercury","mmHg",null,"pressure",!1,!1,133.322],["minute","?",null,"angle",!1,!1,.000290888208665722],["minute","min",["mn"],"time",!1,!0,60],["modern teaspoon","tspm",null,"volume",!1,!0,5e-6],["mole","mol",null,"amount_of_substance",!0,!1,1],["morgen","Morgen",null,"area",!1,!0,2500],["n.u. of action","?",null,"action",!1,!1,105457168181818e-48],["n.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["n.u. of speed","c?",null,"speed",!1,!1,299792458],["n.u. of time","?/(me?c??)",null,"time",!1,!1,128808866778687e-35],["nautical mile","M",["Nmi"],"length",!1,!0,1852],["newton","N",null,"force",!0,!0,1],["œrsted","Oe ",null,"magnetic_field_intensity",!1,!1,79.5774715459477],["ohm","Ω",null,"electric_resistance",!0,!1,1],["ounce mass","ozm",null,"mass",!1,!0,.028349523125],["pascal","Pa",null,"pressure",!0,!1,1],["pascal second","Pa?s",null,"dynamic_viscosity",!0,!1,1],["pferdestärke","PS",null,"power",!1,!0,735.49875],["phot","ph",null,"illuminance",!1,!1,1e-4],["pica (1/6 inch)","pica",null,"length",!1,!0,.00035277777777778],["pica (1/72 inch)","Pica",["Picapt"],"length",!1,!0,.00423333333333333],["poise","P",null,"dynamic_viscosity",!1,!1,.1],["pond","pond",null,"force",!1,!0,.00980665],["pound force","lbf",null,"force",!1,!0,4.4482216152605],["pound mass","lbm",null,"mass",!1,!0,.45359237],["quart","qt",null,"volume",!1,!0,.000946352946],["radian","rad",null,"angle",!0,!1,1],["rankine","Rank",null,"temperature",!1,!0,1],["reaumur","Reau",null,"temperature",!1,!0,1],["second","?",null,"angle",!1,!1,484813681109536e-20],["second","s",["sec"],"time",!0,!0,1],["short hundredweight","cwt",["shweight"],"mass",!1,!0,45.359237],["siemens","S",null,"electrical_conductance",!0,!1,1],["sievert","Sv",null,"equivalent_dose",!0,!1,1],["slug","sg",null,"mass",!1,!0,14.59390294],["square ångström","ang2",["ang^2"],"area",!1,!0,1e-20],["square foot","ft2",["ft^2"],"area",!1,!0,.09290304],["square inch","in2",["in^2"],"area",!1,!0,64516e-8],["square light-year","ly2",["ly^2"],"area",!1,!0,895054210748189e17],["square meter","m?",null,"area",!0,!0,1],["square mile","mi2",["mi^2"],"area",!1,!0,2589988110336e-6],["square nautical mile","Nmi2",["Nmi^2"],"area",!1,!0,3429904],["square Pica","Pica2",["Picapt2","Pica^2","Picapt^2"],"area",!1,!0,1792111111111e-17],["square yard","yd2",["yd^2"],"area",!1,!0,.83612736],["statute mile","mi",null,"length",!1,!0,1609.344],["steradian","sr",null,"solid_angle",!0,!1,1],["stilb","sb",null,"luminance",!1,!1,1e-4],["stokes","St",null,"kinematic_viscosity",!1,!1,1e-4],["stone","stone",null,"mass",!1,!0,6.35029318],["tablespoon","tbs",null,"volume",!1,!0,147868e-10],["teaspoon","tsp",null,"volume",!1,!0,492892e-11],["tesla","T",null,"magnetic_flux_density",!0,!0,1],["thermodynamic calorie","c",null,"energy",!1,!0,4.184],["ton","ton",null,"mass",!1,!0,907.18474],["tonne","t",null,"mass",!1,!1,1e3],["U.K. pint","uk_pt",null,"volume",!1,!0,.00056826125],["U.S. bushel","bushel",null,"volume",!1,!0,.03523907],["U.S. oil barrel","barrel",null,"volume",!1,!0,.158987295],["U.S. pint","pt",["us_pt"],"volume",!1,!0,.000473176473],["U.S. survey mile","survey_mi",null,"length",!1,!0,1609.347219],["U.S. survey/statute acre","us_acre",null,"area",!1,!0,4046.87261],["volt","V",null,"voltage",!0,!1,1],["watt","W",null,"power",!0,!0,1],["watt-hour","Wh",["wh"],"energy",!1,!0,3600],["weber","Wb",null,"magnetic_flux",!0,!1,1],["yard","yd",null,"length",!1,!0,.9144],["year","yr",null,"time",!1,!0,31557600]]);A(this,"_binaryPrefixes",{Yi:["yobi",80,12089258196146292e8,"Yi","yotta"],Zi:["zebi",70,11805916207174113e5,"Zi","zetta"],Ei:["exbi",60,1152921504606847e3,"Ei","exa"],Pi:["pebi",50,0x4000000000000,"Pi","peta"],Ti:["tebi",40,1099511627776,"Ti","tera"],Gi:["gibi",30,1073741824,"Gi","giga"],Mi:["mebi",20,1048576,"Mi","mega"],ki:["kibi",10,1024,"ki","kilo"]});A(this,"_unitPrefixes",{Y:["yotta",1e24,"Y"],Z:["zetta",1e21,"Z"],E:["exa",1e18,"E"],P:["peta",1e15,"P"],T:["tera",1e12,"T"],G:["giga",1e9,"G"],M:["mega",1e6,"M"],k:["kilo",1e3,"k"],h:["hecto",100,"h"],e:["dekao",10,"e"],d:["deci",.1,"d"],c:["centi",.01,"c"],m:["milli",.001,"m"],u:["micro",1e-6,"u"],n:["nano",1e-9,"n"],p:["pico",1e-12,"p"],f:["femto",1e-15,"f"],a:["atto",1e-18,"a"],z:["zepto",1e-21,"z"],y:["yocto",1e-24,"y"]})}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=H(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=`${c.getValue()}`,d=`${l.getValue()}`;if(Number.isNaN(f))return g.create(h.VALUE);let C,_=1,E,b=1;const{_from:R,_to:p}=this._lookupFromAndToUnits(m,d);if(C=R,E=p,C===null){const{_from:S,_fromMultiplier:D}=this._lookupFromPrefix(m);C=S,_=D}if(E===null){const{_to:S,_toMultiplier:D}=this._lookupToPrefix(d);E=S,b=D}if(C===null||E===null||C[3]!==E[3])return g.create(h.NA);let V;return C[3]==="temperature"?(V=this._getTemperatureConversion(f,C[1],E[1]),V=+V.toFixed(2)):V=f*C[6]*_/(E[6]*b),y.create(V)}_lookupFromAndToUnits(e,t){let r=null,n=null,s;for(let a=0;a<this._units.length;a++)s=this._units[a][2]===null?[]:this._units[a][2],(this._units[a][1]===e||s.indexOf(e)>=0)&&(r=this._units[a]),(this._units[a][1]===t||s.indexOf(t)>=0)&&(n=this._units[a]);return{_from:r,_to:n}}_lookupFromPrefix(e){let t=null,r=1,n=e,s;const a=this._binaryPrefixes[e.substring(0,2)];let u=this._unitPrefixes[e.substring(0,1)];e.substring(0,2)==="da"&&(u=["dekao",10,"da"]),a?(r=a[2],n=e.substring(2)):u&&(r=u[1],n=e.substring(u[2].length));for(let c=0;c<this._units.length;c++)s=this._units[c][2]===null?[]:this._units[c][2],(this._units[c][1]===n||s.indexOf(n)>=0)&&(t=this._units[c]);return{_from:t,_fromMultiplier:r}}_lookupToPrefix(e){let t=null,r=1,n=e,s;const a=this._binaryPrefixes[e.substring(0,2)];let u=this._unitPrefixes[e.substring(0,1)];e.substring(0,2)==="da"&&(u=["dekao",10,"da"]),a?(r=a[2],n=e.substring(2)):u&&(r=u[1],n=e.substring(u[2].length));for(let c=0;c<this._units.length;c++)s=this._units[c][2]===null?[]:this._units[c][2],(this._units[c][1]===n||s.indexOf(n)>=0)&&(t=this._units[c]);return{_to:t,_toMultiplier:r}}_getTemperatureConversion(e,t,r){switch(t){case"C":return this._centigradeConversion(e,r);case"F":return this._fahrenheitConversion(e,r);case"K":return this._kelvinConversion(e,r);case"Rank":return this._rankineConversion(e,r);case"Reau":return this._reaumurConversion(e,r);default:return e}}_centigradeConversion(e,t){switch(t){case"F":return e*9/5+32;case"K":return e+273.15;case"Rank":return(e+273.15)*9/5;case"Reau":return e*4/5;default:return e}}_fahrenheitConversion(e,t){switch(t){case"C":return(e-32)*5/9;case"K":return(e-32)*5/9+273.15;case"Rank":return e+459.67;case"Reau":return(e-32)*4/9;default:return e}}_kelvinConversion(e,t){switch(t){case"C":return e-273.15;case"F":return(e-273.15)*9/5+32;case"Rank":return e*9/5;case"Reau":return(e-273.15)*4/5;default:return e}}_rankineConversion(e,t){switch(t){case"C":return(e-491.67)*5/9;case"F":return e-459.67;case"K":return e*5/9;case"Reau":return(e-491.67)*4/9;default:return e}}_reaumurConversion(e,t){switch(t){case"C":return e*5/4;case"F":return e*9/4+32;case"K":return e*5/4+273.15;case"Rank":return e*9/4+491.67;default:return e}}}class Qh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,3}$/.test(`${c}`)||c<-512||c>511)return g.create(h.NUM);let l;if(c<0){const f=(512+c).toString(2);l=`1${"0".repeat(9-f.length)}${f}`}else if(l=Number.parseInt(`${c}`,10).toString(2),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l)}}class qh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,12}$/.test(`${c}`)||c<-549755813888||c>549755813887)return g.create(h.NUM);let l;if(c<0)l=(1099511627776+c).toString(16);else if(l=Number.parseInt(`${c}`,10).toString(16),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l.toLocaleUpperCase())}}class Xh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,9}$/.test(`${c}`)||c<-536870912||c>536870911)return g.create(h.NUM);let l;if(c<0)l=(1073741824+c).toString(8);else if(l=Number.parseInt(`${c}`,10).toString(8),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l)}}class Kh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),{isError:n,errorObject:s,variants:a}=H(e,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);const m=l===f?1:0;return y.create(m)}}class Zh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r;if(t){const{isError:n,errorObject:s,variants:a}=H(e,t);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);r=Ft(f)-Ft(l)}else{const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=+u.getValue();if(Number.isNaN(c))return g.create(h.VALUE);r=Ft(c)}return y.create(r)}}class zh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=Ft(a);return y.create(u)}}class Jh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=$s(a);return y.create(u)}}class eg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=$s(a);return y.create(u)}}class tg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);const r=t!=null?t:y.create(0),{isError:n,errorObject:s,variants:a}=H(e,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);const m=l>=f?1:0;return y.create(m)}}class rg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:d,errorObject:C,variants:_}=H(t);if(d)return C;const[E]=_;if(r=Math.floor(+E.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!ks(c))return g.create(h.NUM);const l=c.length===10&&c.substring(0,1).toLocaleUpperCase()==="F",f=l?Number.parseInt(c,16)-1099511627776:Number.parseInt(c,16);if(f<-512||f>511)return g.create(h.NUM);let m;if(l){const d=(512+f).toString(2);m=`1${"0".repeat(9-d.length)}${d}`}else if(m=f.toString(2),t){if(r<m.length)return g.create(h.NUM);m="0".repeat(r-m.length)+m}return j.create(m)}}class ng extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!ks(a))return g.create(h.NUM);let u=Number.parseInt(a,16);return u>=549755813888&&(u-=1099511627776),y.create(u)}}class sg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:m,errorObject:d,variants:C}=H(t);if(m)return d;const[_]=C;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!ks(c))return g.create(h.NUM);const l=Number.parseInt(c,16);if(l>536870911&&l<0xffe0000000)return g.create(h.NUM);let f;if(l>=0xffe0000000)f=(l-0xffc0000000).toString(8);else if(f=l.toString(8),t){if(r<f.length)return g.create(h.NUM);f="0".repeat(r-f.length)+f}return j.create(f)}}class ag extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Abs();return y.create(c)}}class ig extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.getINum();return y.create(c)}}class og extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);if(u.getRealNum()===0&&u.getINum()===0)return g.create(h.DIV_BY_ZERO);const c=u.Argument();return y.create(c)}}class ug extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Conjugate();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class cg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Cos();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class lg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Cosh();return u.isError()?g.create(h.NUM):typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class fg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Cot();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class mg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Csc();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class hg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Csch();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class gg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=`${u.getValue()}`,f=new de(c),m=new de(l);if(f.isError()||m.isError()||f.isDifferentSuffixes(m)||m.getRealNum()===0&&m.getINum()===0)return g.create(h.NUM);const d=f.Div(m);return typeof d=="number"||M.isRealNum(d)?y.create(+d):j.create(d)}}class dg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Exp();return u.isError()?g.create(h.NUM):typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Cg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Ln();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class _g extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Log10();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Ag extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Log2();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Eg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=new de(c);if(l.isError())return g.create(h.NUM);const f=+u.getValue();if(Number.isNaN(f))return g.create(h.VALUE);const m=l.Power(f);return l.isError()?g.create(h.NUM):typeof m=="number"||M.isRealNum(m)?y.create(+m):j.create(m)}}class bg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="";for(let r=0;r<e.length;r++){if(t instanceof g)return t;const n=e[r];if(n.isArray()){let s=!1,a;if(n.iterator(u=>{if(t=this._handleSingleObject(u,t),t instanceof g)return s=!0,a=t,!1}),s)return a}else t=this._handleSingleObject(n,t)}return t instanceof g?t:typeof t=="number"||M.isRealNum(t)?y.create(+t):j.create(t)}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);const n=`${e.getValue()}`;if(typeof t!="number"&&!t){const s=new de(n);if(s.isError())return g.create(h.NUM);r=s.toString()}else{const s=new de(t),a=new de(n);if(s.isError()||a.isError())return g.create(h.NUM);if(s.isDifferentSuffixes(a))return g.create(h.VALUE);r=s.Product(a)}return r}}class yg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.getRealNum();return y.create(c)}}class Rg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Sec();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class pg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Sech();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Ng extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Sin();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Vg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Sinh();return u.isError()?g.create(h.NUM):typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Og extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);if(u.getRealNum()===0&&u.getINum()===0)return y.create(0);const c=u.Sqrt();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Mg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=`${u.getValue()}`,f=new de(c),m=new de(l);if(f.isError()||m.isError()||f.isDifferentSuffixes(m))return g.create(h.NUM);const d=f.Sub(m);return typeof d=="number"||M.isRealNum(d)?y.create(+d):j.create(d)}}class Sg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="";for(let r=0;r<e.length;r++){if(t instanceof g)return t;const n=e[r];if(n.isArray()){let s=!1,a;if(n.iterator(u=>{if(t=this._handleSingleObject(u,t),t instanceof g)return s=!0,a=t,!1}),s)return a}else t=this._handleSingleObject(n,t)}return t instanceof g?t:typeof t=="number"||M.isRealNum(t)?y.create(+t):j.create(t)}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);const n=`${e.getValue()}`;if(typeof t!="number"&&!t){const s=new de(n);if(s.isError())return g.create(h.NUM);r=s.toString()}else{const s=new de(t),a=new de(n);if(s.isError()||a.isError())return g.create(h.NUM);if(s.isDifferentSuffixes(a))return g.create(h.VALUE);r=s.Sum(a)}return r}}class Dg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Tan();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class wg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:d,errorObject:C,variants:_}=H(t);if(d)return C;const[E]=_;if(r=Math.floor(+E.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Fs(c))return g.create(h.NUM);const l=c.length===10&&c.substring(0,1)==="7",f=l?Number.parseInt(c,8)-1073741824:Number.parseInt(c,8);if(f<-512||f>511)return g.create(h.NUM);let m;if(l){const d=(512+f).toString(2);m=`1${"0".repeat(9-d.length)}${d}`}else if(m=f.toString(2),t){if(r<m.length)return g.create(h.NUM);m="0".repeat(r-m.length)+m}return j.create(m)}}class Pg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!Fs(a))return g.create(h.NUM);let u=Number.parseInt(a,8);return u>=536870912&&(u-=1073741824),y.create(u)}}class Lg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:m,errorObject:d,variants:C}=H(t);if(m)return d;const[_]=C;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Fs(c))return g.create(h.NUM);const l=Number.parseInt(c,8);let f;if(l>=536870912)f=`ff${(l+3221225472).toString(16)}`;else if(f=l.toString(16),t){if(r<f.length)return g.create(h.NUM);f="0".repeat(r-f.length)+f}return j.create(f.toLocaleUpperCase())}}const zo=[[xh,z.BESSELI],[jh,z.BESSELJ],[Uh,z.BESSELK],[vh,z.BESSELY],[Th,z.BIN2DEC],[Bh,z.BIN2HEX],[Ih,z.BIN2OCT],[Fh,z.BITAND],[kh,z.BITLSHIFT],[$h,z.BITOR],[Yh,z.BITRSHIFT],[Hh,z.BITXOR],[Gh,z.COMPLEX],[Wh,z.CONVERT],[Qh,z.DEC2BIN],[qh,z.DEC2HEX],[Xh,z.DEC2OCT],[Kh,z.DELTA],[Zh,z.ERF],[zh,z.ERF_PRECISE],[Jh,z.ERFC],[eg,z.ERFC_PRECISE],[tg,z.GESTEP],[rg,z.HEX2BIN],[ng,z.HEX2DEC],[sg,z.HEX2OCT],[ag,z.IMABS],[ig,z.IMAGINARY],[og,z.IMARGUMENT],[ug,z.IMCONJUGATE],[cg,z.IMCOS],[lg,z.IMCOSH],[fg,z.IMCOT],[mg,z.IMCSC],[hg,z.IMCSCH],[gg,z.IMDIV],[dg,z.IMEXP],[Cg,z.IMLN],[_g,z.IMLOG10],[Ag,z.IMLOG2],[Eg,z.IMPOWER],[bg,z.IMPRODUCT],[yg,z.IMREAL],[Rg,z.IMSEC],[pg,z.IMSECH],[Ng,z.IMSIN],[Vg,z.IMSINH],[Og,z.IMSQRT],[Mg,z.IMSUB],[Sg,z.IMSUM],[Dg,z.IMTAN],[wg,z.OCT2BIN],[Pg,z.OCT2DEC],[Lg,z.OCT2HEX]];var J=(i=>(i.ACCRINT="ACCRINT",i.ACCRINTM="ACCRINTM",i.AMORDEGRC="AMORDEGRC",i.AMORLINC="AMORLINC",i.COUPDAYBS="COUPDAYBS",i.COUPDAYS="COUPDAYS",i.COUPDAYSNC="COUPDAYSNC",i.COUPNCD="COUPNCD",i.COUPNUM="COUPNUM",i.COUPPCD="COUPPCD",i.CUMIPMT="CUMIPMT",i.CUMPRINC="CUMPRINC",i.DB="DB",i.DDB="DDB",i.DISC="DISC",i.DOLLARDE="DOLLARDE",i.DOLLARFR="DOLLARFR",i.DURATION="DURATION",i.EFFECT="EFFECT",i.FV="FV",i.FVSCHEDULE="FVSCHEDULE",i.INTRATE="INTRATE",i.IPMT="IPMT",i.IRR="IRR",i.ISPMT="ISPMT",i.MDURATION="MDURATION",i.MIRR="MIRR",i.NOMINAL="NOMINAL",i.NPER="NPER",i.NPV="NPV",i.ODDFPRICE="ODDFPRICE",i.ODDFYIELD="ODDFYIELD",i.ODDLPRICE="ODDLPRICE",i.ODDLYIELD="ODDLYIELD",i.PDURATION="PDURATION",i.PMT="PMT",i.PPMT="PPMT",i.PRICE="PRICE",i.PRICEDISC="PRICEDISC",i.PRICEMAT="PRICEMAT",i.PV="PV",i.RATE="RATE",i.RECEIVED="RECEIVED",i.RRI="RRI",i.SLN="SLN",i.SYD="SYD",i.TBILLEQ="TBILLEQ",i.TBILLPRICE="TBILLPRICE",i.TBILLYIELD="TBILLYIELD",i.VDB="VDB",i.XIRR="XIRR",i.XNPV="XNPV",i.YIELD="YIELD",i.YIELDDISC="YIELDDISC",i.YIELDMAT="YIELDMAT",i))(J||{});function $n(i,o,e,t){const r=wt(i,o,e),{days:n}=Ce(r,i,t);return n}function $e(i,o,e,t){let r;if(t===1){const n=wt(i,o,e);let s=re(n);s=ur(s,12/e);const a=Ee(s);n<0&&e===1?r=365:r=a-n}else t===3?r=365/e:r=360/e;return r}function Jo(i,o,e){const t=re(i);let r=re(o);for(r.setUTCFullYear(t.getUTCFullYear()),r<t&&r.setUTCFullYear(r.getUTCFullYear()+1);r>t;)r=ur(r,-12/e);return r=ur(r,12/e),Ee(r)}function Wt(i,o,e){let t=0;const r=re(i);let n=re(o);for(;n>r;)n=ur(n,-12/e),t++;return t}function wt(i,o,e){const t=re(i);let r=re(o);for(r.setUTCFullYear(t.getUTCFullYear()),r<t&&r.setUTCFullYear(r.getUTCFullYear()+1);r>t;)r=ur(r,-12/e);return Ee(r)}function eu(i,o,e,t,r,n){const s=$n(i,o,r,n),a=$e(i,o,r,n),u=Wt(i,o,r),c=(a-s)/a-1,l=t/r+1,f=e*100/r;let m=0,d=0;for(let E=1;E<=u;E++){const b=E+c,R=f/l**b;m+=b*R,d+=R}const C=u+c,_=100/l**C;return m+=C*_,d+=_,m/d/r}function jr(i,o,e,t,r){let n;if(i===0)n=(e+t)/o;else{const s=(1+i)**o;n=r===1?(t*i/(s-1)+e*i/(1-1/s))/(1+i):t*i/(s-1)+e*i/(1-1/s)}return-n}function Qt(i,o,e,t,r){let n;if(i===0)n=t+e*o;else{if(i===-1&&o===0)return Number.NaN;const s=(1+i)**o;n=r===1?t*s+e*(1+i)*(s-1)/i:t*s+e*(s-1)/i}return-n}function tu(i,o,e,t,r,n){const s=jr(i,e,t,r,n);return(o===1?n===1?0:-t:n===1?Qt(i,o-2,s,t,1)-s:Qt(i,o-1,s,t,0))*i}function ru(i,o){let e=0;for(let t=1;t<=o.length;t++)e+=o[t-1]/(1+i)**t;return e}function nu(i,o,e,t,r,n,s,a,u){const c=It(e,t,u),l=$e(i,t,a,u);return c<l?xg(i,o,e,t,r,n,s,a,u,c,l):jg(i,o,e,t,r,n,s,a,u,l)}function xg(i,o,e,t,r,n,s,a,u,c,l){let f=0;const m=Wt(i,o,a),d=It(i,t,u);f+=s/(1+n/a)**(m-1+d/l),f+=100*r/a*c/l/(1+n/a)**(d/l);for(let _=2;_<=m;_++)f+=100*r/a/(1+n/a)**(_-1+d/l);const C=It(e,i,u);return f-=100*r/a*C/l,f}function jg(i,o,e,t,r,n,s,a,u,c){let l=0;const f=Wt(t,o,a),m=Ug(t,i,12/a,!0);let d;if(u===2||u===3){const R=Jo(i,t,a);d=It(i,R,u)}else{const R=wt(i,t,a),{days:p}=Ce(R,i,u);d=c-p}l+=s/(1+n/a)**(f+m+d/c);const C=Wt(e,t,a);let _=t,E=0,b=0;for(let R=C;R>=1;R--){const p=$t(_,-12/a,!1),V=u===1?It(p,_,u):c,S=R>1?V:It(e,_,u);E+=S/V;const D=e>p?e:p,w=i<_?i:_,P=It(D,w,u);b+=P/V,_=p}l+=100*r/a*E/(1+n/a)**(m+d/c);for(let R=1;R<=f;R++)l+=100*r/a/(1+n/a)**(R+m+d/c);return l-=100*r/a*b,l}function It(i,o,e){const{days:t}=Ce(i,o,e);return i<o?t:0}function su(i,o,e){const t=re(i),r=t.getUTCFullYear(),n=t.getUTCMonth(),s=t.getUTCDate(),a=or(r,n,s),u=re(o),c=u.getUTCFullYear(),l=u.getUTCMonth(),f=u.getUTCDate(),m=or(c,l,f);return!(s!==f&&!(a&&m)||Math.abs((c-r)*12+(l-n))%(12/e)!==0)}function gr(i,o,e){return wt(i,o,e)>=0}function $t(i,o,e){let t=re(i);if(t=ur(t,o),e){const r=t.getUTCFullYear(),n=t.getUTCMonth(),s=xr(r,n);t.setUTCDate(s)}return Ee(t)}function Ug(i,o,e,t){const r=re(i),n=re(o),s=r.getUTCFullYear(),a=r.getUTCMonth(),u=r.getUTCDate(),c=n.getUTCFullYear(),l=n.getUTCMonth(),f=n.getUTCDate(),m=or(s,a,u),d=!m&&a!==1&&u>28&&u<xr(s,a)?or(c,l,f):m,C=$t(o,0,d);let _=+t-0+ +(o<C),E=$t(C,e,d);for(;!(e>0?E>=o:E<=o);)E=$t(E,e,d),_++;return _}function na(i,o){let n=1,s=0,a=i,u;for(;n>1e-7&&s<500;){const c=(o(a+1e-7)-o(a-1e-7))/2e-7;u=a-o(a)/c,s++,n=Math.abs(u-a),a=u}return Number.isNaN(a)||Math.abs(a)===1/0||s===500?vg(i,o):a}function vg(i,o){const r=Number.MAX_VALUE,n=-1,s=1.6;let a=i-.01<=n?n+1e-7:i-.01,u=i+.01>=r?r-1e-7:i+.01,c,l,f=0;if(i<=n||i>=r)return g.create(h.NUM);for(let E=0;E<60;E++){c=a<=n?n+1e-7:a,l=u>=r?r-1e-7:u;const b=o(c),R=o(l);if(b*R<=0)break;if(b*R>0)a=c+s*(c-l),u=l+s*(l-c);else return g.create(h.NUM);if(E===59)return g.create(h.NUM)}c=c,l=l;let m=o(c);const d=o(l);let C,_;if(Math.abs(m)<1e-7||Math.abs(d)<1e-7)return g.create(h.NUM);do _=c+(l-c)/2,C=o(_),m*C<0?l=_:c=_,m=o(c),f++;while(Math.abs(C)>1e-7&&f<60);return _}function qr(i,o,e,t,r,n,s){const a=Wt(i,o,n),u=$e(i,o,n,s),c=$n(i,o,n,s);if(a===1){const m=u-c,d=100*e/n+r,C=t/n*m/u+1,_=100*e/n*c/u;return d/C-_}const l=u-c;let f=r/(1+t/n)**(a-1+l/u);for(let m=1;m<=a;m++)f+=100*e/n/(1+t/n)**(m-1+l/u);return f-=100*e/n*c/u,f}function ys(i,o,e,t,r){let n=0,s=r/e;s>=1?(s=1,n=t===1?i:0):n=i*(1-s)**(t-1);const a=i*(1-s)**t;let u=0;return a<o?u=n-o:u=n-a,u<0&&(u=0),u}class Tg extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",8)}calculate(e,t,r,n,s,a,u,c){const l=u!=null?u:y.create(0),f=c!=null?c:k.create(!0),{isError:m,errorObject:d,variants:C}=H(e,t,r,n,s,a,l);if(m)return d;const[_,E,b,R,p,V,S]=C,D=F(_);if(typeof D!="number")return D;const w=F(E);if(typeof w!="number")return w;const P=F(b);if(typeof P!="number")return P;const L=+R.getValue(),T=+p.getValue(),B=Math.floor(+V.getValue()),W=Math.floor(+S.getValue()),q=+f.getValue();return Number.isNaN(L)||Number.isNaN(T)||Number.isNaN(B)||Number.isNaN(W)||Number.isNaN(q)?g.create(h.VALUE):L<=0||T<=0||![1,2,4].includes(B)||W<0||W>4||Math.floor(D)>=Math.floor(P)?g.create(h.NUM):this._getResult(D,w,P,L,T,B,W,q)}_getResult(e,t,r,n,s,a,u,c){let l=wt(e,t,a);if(l<=0)return y.create(0);l=wt(r,t,a);const f=12/a,m=re(t),d=m.getUTCFullYear(),C=m.getUTCMonth(),_=m.getUTCDate(),E=or(d,C,_);let b=$t(t,-f,E);if(r>t&&c)for(b=t;b<r;)b=$t(b,f,E);let R=e>b?e:b,{days:p}=Ce(R,r,u);if(l>=e){const{days:L}=Ce(R,r,u?4:0);p=L}r<R&&(p=-p);let V=$e(b,t,a,u),S=p/V,D=b,w=e;for(;D>e;){w=D,D=$t(D,-f,E),R=e>D?e:D;const{days:L}=Ce(R,w,u);if(u===0)w>=R||e<=D?p=L:p=-L,V=$e(D,w,a,u);else if(p=w<R?-L:L,u===3)V=365/a;else{const{days:T}=Ce(D,w,u);V=w<D?-T:T}S+=e<=D?c?1:0:p/V}const P=s*n/a*S;return y.create(P)}}class Bg extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=H(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>Math.floor(b))return g.create(h.NUM);if(Math.floor(E)===Math.floor(b))return y.create(0);const{days:S,yearDays:D}=Ce(E,b,V),w=p*R*S/D;return y.create(w)}}class Ig extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){const c=u!=null?u:y.create(0),{isError:l,errorObject:f,variants:m}=H(e,t,r,n,s,a,c);if(l)return f;const[d,C,_,E,b,R,p]=m,V=F(C);if(typeof V!="number")return V;const S=F(_);if(typeof S!="number")return S;const D=+d.getValue(),w=+E.getValue();let P=+b.getValue();const L=+R.getValue(),T=Math.floor(+p.getValue());return Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(T)?g.create(h.VALUE):D<=0||w<0||D<w||Math.floor(V)>Math.floor(S)||P<0||L<=0||![0,1,3,4].includes(T)?g.create(h.NUM):(P>1?P=Math.floor(P):P=Math.ceil(P),this._getResult(D,V,S,w,P,L,T))}_getResult(e,t,r,n,s,a,u){const c=e-n,l=e*a,{days:f,yearDays:m}=Ce(t,r,u),d=f/m,C=Math.ceil(c/l-d);if(C<0)return y.create(0);let _=l;return s===0?_=l*d:s===C?_=c-l*(d+s-1):s>C&&(_=0),y.create(_)}}class Fg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);const R=$n(C,_,E,b);return y.create(R)}}class kg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);const R=$e(C,_,E,b);return y.create(R)}}class $g extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);const R=re(C),p=re(_);for(p.setUTCFullYear(R.getUTCFullYear()),p<R&&p.setUTCFullYear(p.getUTCFullYear()+1);p>R;)p.setUTCMonth(p.getUTCMonth()-12/E);p.setUTCMonth(p.getUTCMonth()+12/E);const V=Ee(p),{days:S}=Ce(C,V,b);return y.create(S)}}class Yg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);const R=Jo(C,_,E);return y.create(R)}}class Hg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_)||wt(C,_,E)<0)return g.create(h.NUM);const p=Wt(C,_,E);return y.create(p)}}class Gg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);let R=wt(C,_,E);return R<0&&(R=0),y.create(R)}}class Wg extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=H(e,t,r,n,s,a);if(u)return c;const[f,m,d,C,_,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+C.getValue(),S=+_.getValue(),D=+E.getValue();return Number.isNaN(b)||Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D)?g.create(h.VALUE):b<=0||R<=0||p<=0||V<1||S<1||V>S||V>R||S>R||![0,1].includes(D)?g.create(h.NUM):Math.trunc(V)!==V&&Math.trunc(S)!==S&&Math.trunc(V)===Math.trunc(S)?y.create(0):this._getResult(b,R,p,V,S,D)}_getResult(e,t,r,n,s,a){const u=jr(e,t,r,0,a);let c=0,l=Math.ceil(n);l===1&&(a===0&&(c=-r),l++);let f=!1;for(let m=l;m<=s;m++){const d=a===1?Qt(e,m-2,u,r,1):Qt(e,m-1,u,r,0);if(d===0){f=!0;break}c+=a===1?d-u:d}return c*=e,(c<u*(s-n+1)||f)&&(c=u*(s-n+1)),y.create(c)}}class Qg extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=H(e,t,r,n,s,a);if(u)return c;const[f,m,d,C,_,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+C.getValue(),S=+_.getValue(),D=+E.getValue();return Number.isNaN(b)||Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D)?g.create(h.VALUE):b<=0||R<=0||p<=0||V<1||S<1||V>S||![0,1].includes(D)?g.create(h.NUM):Math.trunc(V)!==V&&Math.trunc(S)!==S&&Math.trunc(V)===Math.trunc(S)?y.create(0):this._getResult(b,R,p,V,S,D)}_getResult(e,t,r,n,s,a){const u=jr(e,t,r,0,a);let c=0,l=Math.ceil(n);l===1&&(c=a===0?u+r*e:u,l++);for(let f=l;f<=s;f++)c+=a===1?u-(Qt(e,f-2,u,r,1)-u)*e:u-Qt(e,f-1,u,r,0)*e;return y.create(c)}}class qg extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(12);a.isNull()&&(a=y.create(12));const u=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,a.isArray()?a.getRowCount():1),c=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,a.isArray()?a.getColumnCount():1),l=O(u,c,e,g.create(h.NA)),f=O(u,c,t,g.create(h.NA)),m=O(u,c,r,g.create(h.NA)),d=O(u,c,n,g.create(h.NA)),C=O(u,c,a,g.create(h.NA)),_=l.map((E,b,R)=>{const p=f.get(b,R),V=m.get(b,R),S=d.get(b,R),D=C.get(b,R),{isError:w,errorObject:P,variants:L}=I(E,p,V,S,D);if(w)return P;const[T,B,W,q,ie]=L,Z=+T.getValue(),G=+B.getValue(),ce=+W.getValue();let ge=+q.getValue();const Ae=Math.floor(+ie.getValue());return Z<0||G<0||ce<=0||ge<=0||Math.floor(ge)>Math.floor(ce)||Ae<1||Ae>12?g.create(h.NUM):(ge<1&&(ge=1),ge=Math.floor(ge),this._getResult(Z,G,ce,ge,Ae,b,R))});return u===1&&c===1?_.get(0,0):_}_getResult(e,t,r,n,s,a,u){const c=+(1-(t/e)**(1/r)).toFixed(3),l=e*c*s/12;let f=l,m=0;const d=n===r?r-1:n;for(let _=2;_<=d;_++)m=(e-f)*c,f+=m;let C;return n===1?C=l:n===r?C=(e-f)*c:C=m,Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):a===0&&u===0?y.create(C,Ye(this.getLocale())):y.create(C)}}class Xg extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(2);a.isNull()&&(a=y.create(2));const u=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,a.isArray()?a.getRowCount():1),c=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,a.isArray()?a.getColumnCount():1),l=O(u,c,e,g.create(h.NA)),f=O(u,c,t,g.create(h.NA)),m=O(u,c,r,g.create(h.NA)),d=O(u,c,n,g.create(h.NA)),C=O(u,c,a,g.create(h.NA)),_=l.map((E,b,R)=>{const p=f.get(b,R),V=m.get(b,R),S=d.get(b,R),D=C.get(b,R),{isError:w,errorObject:P,variants:L}=I(E,p,V,S,D);if(w)return P;const[T,B,W,q,ie]=L,Z=+T.getValue(),G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue();if(Z<0||G<0||ce<=0||ge<=0||ge>ce||Ae<=0)return g.create(h.NUM);const be=ys(Z,G,ce,ge,Ae);return Number.isNaN(be)||!Number.isFinite(be)?g.create(h.NUM):b===0&&R===0?y.create(be,Ye(this.getLocale())):y.create(be)});return u===1&&c===1?_.get(0,0):_}}class Kg extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=H(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>=Math.floor(b))return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=(p-R)/p*(D/S);return y.create(w)}}class Zg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);if(l>=0&&l<1)return g.create(h.DIV_BY_ZERO);l=Number.parseInt(`${l}`,10);let f=Number.parseInt(`${c}`,10);f+=c%1*10**Math.ceil(Math.log(l)/Math.LN10)/l;const m=10**(Math.ceil(Math.log(l)/Math.LN2)+1);return f=Math.round(f*m)/m,y.create(f)}}class zg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);if(l>=0&&l<1)return g.create(h.DIV_BY_ZERO);l=Number.parseInt(`${l}`,10);let f=Number.parseInt(`${c}`,10);return f+=c%1*10**-Math.ceil(Math.log(l)/Math.LN10)*l,y.create(f)}}class Jg extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,C,_,E,b]=f,R=F(m);if(typeof R!="number")return R;const p=F(d);if(typeof p!="number")return p;const V=+C.getValue(),S=+_.getValue(),D=Math.floor(+E.getValue()),w=Math.floor(+b.getValue());if(Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);if(V<0||S<0||![1,2,4].includes(D)||w<0||w>4||Math.floor(R)>=Math.floor(p)||R<=0||p<=366)return g.create(h.NUM);const P=eu(R,p,V,S,D,w);return y.create(P)}}class e1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(c<=0||l<1)return g.create(h.NUM);l=Number.parseInt(`${l}`,10);const f=(1+c/l)**l-1;return y.create(f)}}class t1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p),{isError:P,errorObject:L,variants:T}=I(b,V,S,D,w);if(P)return L;const[B,W,q,ie,Z]=T,G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue(),be=+Z.getValue(),he=Qt(G,ce,ge,Ae,be?1:0);return Number.isNaN(he)||!Number.isFinite(he)?g.create(h.NUM):R===0&&p===0?y.create(he,Ye(this.getLocale())):y.create(he)});return c===1&&l===1?E.get(0,0):E}}class r1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e);if(r)return n;const[a]=s,u=+a.getValue();if(Number.isNaN(u))return g.create(h.VALUE);let c=u;if(t.isArray()){const l=t.getArrayValue().flat();for(let f=0;f<l.length;f++){const m=l[f];if(m.isBoolean())return g.create(h.VALUE);const d=+m.getValue();if(Number.isNaN(d))return g.create(h.VALUE);c*=1+d}}else{if(t.isBoolean())return g.create(h.VALUE);const l=+t.getValue();if(Number.isNaN(l))return g.create(h.VALUE);c*=1+l}return y.create(c)}}class n1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=H(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>=Math.floor(b))return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=(p-R)/R*(D/S);return y.create(w)}}class s1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a){const u=s!=null?s:y.create(0),c=a!=null?a:y.create(0),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),C=O(l,f,r,g.create(h.NA)),_=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.map((p,V,S)=>{const D=d.get(V,S),w=C.get(V,S),P=_.get(V,S),L=E.get(V,S),T=b.get(V,S),{isError:B,errorObject:W,variants:q}=I(p,D,w,P,L,T);if(B)return W;const[ie,Z,G,ce,ge,Ae]=q,be=+ie.getValue(),he=+Z.getValue(),Ue=+G.getValue(),dt=+ce.getValue(),Xt=+ge.getValue(),Ct=+Ae.getValue();if(he<1||Math.floor(he)>Math.ceil(Ue))return g.create(h.NUM);const Ke=tu(be,he,Ue,dt,Xt,Ct?1:0);return Number.isNaN(Ke)||!Number.isFinite(Ke)?g.create(h.NUM):V===0&&S===0?y.create(Ke,Ye(this.getLocale())):y.create(Ke)});return l===1&&f===1?R.get(0,0):R}}class a1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r=t!=null?t:y.create(.1);return r.isNull()&&(r=y.create(.1)),r.isArray()?r.map((n,s,a)=>this._handleSingleObject(e,n,s,a)):this._handleSingleObject(e,r)}_handleSingleObject(e,t,r=0,n=0){if(e.isError())return e;if(t.isError())return t;if(e.isNull())return g.create(h.VALUE);if(!e.isArray())return g.create(h.NUM);const{_values:s,valuesHasError:a}=this._getValues(e);if(a)return g.create(h.VALUE);let u=t;if(u.isString()&&(u=u.convertToNumberObjectValue(),u.isError()))return u;const c=+u.getValue(),{positive:l,negative:f}=this._checkValues(s);if(!l||!f)return g.create(h.NUM);const m=na(c,d=>ru(d,s));return typeof m!="number"?m:r===0&&n===0?y.create(m,"0%"):y.create(m)}_getValues(e){const t=[];let r=!1;return e.iterator(n=>{const s=n;if(s.isError())return r=!0,!1;if(s.isNull()||s.isBoolean())return!0;const a=+s.getValue();if(Number.isNaN(a))return!0;t.push(a)}),{_values:t,valuesHasError:r}}_checkValues(e){let t=!1,r=!1;for(let n=0;n<e.length;n++)e[n]>0&&(t=!0),e[n]<0&&(r=!0);return{positive:t,negative:r}}}class i1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.map((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_),{isError:p,errorObject:V,variants:S}=I(d,E,b,R);if(p)return V;const[D,w,P,L]=S,T=+D.getValue(),B=+w.getValue(),W=+P.getValue(),q=+L.getValue();if(W===0)return g.create(h.DIV_BY_ZERO);const ie=q*T*(B/W-1);return y.create(ie)});return s===1&&a===1?m.get(0,0):m}}class o1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,C,_,E,b]=f,R=F(m);if(typeof R!="number")return R;const p=F(d);if(typeof p!="number")return p;const V=+C.getValue(),S=+_.getValue(),D=Math.floor(+E.getValue()),w=Math.floor(+b.getValue());if(Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);if(V<0||S<0||![1,2,4].includes(D)||w<0||w>4||Math.floor(R)>=Math.floor(p))return g.create(h.NUM);let P=eu(R,p,V,S,D,w);return P/=1+S/D,y.create(P)}}class u1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{_values:n,numberValues:s,positive:a,negative:u}=this._getValues(e),c=Math.max(t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),l=Math.max(t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),f=O(c,l,t,g.create(h.NA)),m=O(c,l,r,g.create(h.NA)),d=f.map((C,_,E)=>{const b=m.get(_,E);if(e.isError())return e;if(b.isError())return b;if(n.isError())return n;if(!a||!u)return g.create(h.DIV_BY_ZERO);const R=+C.getValue(),p=+b.getValue();if(Number.isNaN(R)||Number.isNaN(p))return g.create(h.VALUE);if(p===-1)return g.create(h.DIV_BY_ZERO);const V=this._getResult(s,R,p);return _===0&&E===0?y.create(V,"0%"):y.create(V)});return c===1&&l===1?d.get(0,0):d}_getValues(e){let t=e,r=[],n=!1,s=!1;if(!e.isError())if(e.isNull())t=g.create(h.VALUE);else if(!e.isArray())t=g.create(h.DIV_BY_ZERO);else{const{numberValues:a,valuesHasError:u,errorObject:c,positive:l,negative:f}=this._checkValues(e);u&&(t=c),r=a,n=l,s=f}return{_values:t,numberValues:r,positive:n,negative:s}}_checkValues(e){const t=[];let r=!1,n=g.create(h.VALUE),s=!1,a=!1;return e.iterator(u=>{const c=u;if(c.isError())return r=!0,n=c,!1;if(c.isNull()||c.isBoolean())return!0;const l=+c.getValue();if(Number.isNaN(l))return!0;l>0&&(s=!0),l<0&&(a=!0),t.push(l)}),{numberValues:t,valuesHasError:r,errorObject:n,positive:s,negative:a}}_getResult(e,t,r){const n=e.length,s=[],a=[];for(let d=0;d<n;d++)e[d]>0?a.push(e[d]):e[d]<0&&s.push(e[d]);const u=this._npv(r,e,"positive"),c=this._npv(t,e,"negative"),l=-u*(1+r)**n,f=c*(1+t);return(l/f)**(1/(n-1))-1}_npv(e,t,r){let n=0;for(let s=1;s<=t.length;s++){const a=t[s-1];(r==="positive"&&a>0||r==="negative"&&a<0)&&(n+=a/(1+e)**s)}return n}}class c1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(c<=0||l<1)return g.create(h.NUM);l=Number.parseInt(`${l}`,10);const f=((c+1)**(1/l)-1)*l;return y.create(f)}}class l1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p),{isError:P,errorObject:L,variants:T}=I(b,V,S,D,w);if(P)return L;const[B,W,q,ie,Z]=T,G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue();let be=+Z.getValue();if(be=be?1:0,G===0&&ce===0)return g.create(h.DIV_BY_ZERO);let he;if(G===0)he=-(ge+Ae)/ce;else{const Ue=ce*(1+G*be)-Ae*G,dt=ge*G+ce*(1+G*be);he=Math.log(Ue/dt)/Math.log(1+G)}return Number.isNaN(he)||!Number.isFinite(he)?g.create(h.NUM):y.create(he)});return c===1&&l===1?E.get(0,0):E}}class f1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsLocale",!0)}calculate(e,...t){if(e.isError())return e;const{isError:r,errorObject:n,values:s}=this._getValues(t);return e.isArray()?e.map((a,u,c)=>this._handleSingleObject(a,r,n,s,u,c)):this._handleSingleObject(e,r,n,s)}_handleSingleObject(e,t,r,n,s=0,a=0){let u=e;if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(t)return r;const c=+e.getValue(),l=ru(c,n);return Number.isNaN(l)||Math.abs(l)===1/0?g.create(h.DIV_BY_ZERO):s===0&&a===0?y.create(l,Ye(this.getLocale())):y.create(l)}_getValues(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isError())return{isError:!0,errorObject:n};if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{const c=u;if(c.isError())return s=!0,a=c,!1;if(c.isNull()||c.isBoolean())return!0;const l=+c.getValue();if(Number.isNaN(l))return!0;t.push(l)}),s)return{isError:s,errorObject:a}}else{const s=+n.getValue();if(Number.isNaN(s))return{isError:!0,errorObject:g.create(h.VALUE)};t.push(s)}}return{isError:!1,values:t}}}class m1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c,l){let f=l!=null?l:y.create(0);f.isNull()&&(f=y.create(0));const{isError:m,errorObject:d,variants:C}=je(e,t,r,n,s,a,u,c,f);if(m)return d;const[_,E,b,R,p,V,S,D,w]=C,P=F(_);if(typeof P!="number")return P;const L=F(E);if(typeof L!="number")return L;const T=F(b);if(typeof T!="number")return T;const B=F(R);if(typeof B!="number")return B;const W=+p.getValue(),q=+V.getValue(),ie=+S.getValue(),Z=Math.floor(+D.getValue()),G=Math.floor(+w.getValue());if(Number.isNaN(W)||Number.isNaN(q)||Number.isNaN(ie)||Number.isNaN(Z)||Number.isNaN(G))return g.create(h.VALUE);if(W<0||q<0||ie<=0||![1,2,4].includes(Z)||G<0||G>4||!this._validDate(L,B,P,T,Z))return g.create(h.NUM);const ce=nu(P,L,T,B,W,q,ie,Z,G);return y.create(ce)}_validDate(e,t,r,n,s){return this._getDateCorrectOrder(e,t,r,n)&&su(e,t,s)&&gr(n,e,s)}_getDateCorrectOrder(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&Math.floor(r)>Math.floor(n)}}class h1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c,l){let f=l!=null?l:y.create(0);f.isNull()&&(f=y.create(0));const{isError:m,errorObject:d,variants:C}=je(e,t,r,n,s,a,u,c,f);if(m)return d;const[_,E,b,R,p,V,S,D,w]=C,P=F(_);if(typeof P!="number")return P;const L=F(E);if(typeof L!="number")return L;const T=F(b);if(typeof T!="number")return T;const B=F(R);if(typeof B!="number")return B;const W=+p.getValue(),q=+V.getValue(),ie=+S.getValue(),Z=Math.floor(+D.getValue()),G=Math.floor(+w.getValue());return Number.isNaN(W)||Number.isNaN(q)||Number.isNaN(ie)||Number.isNaN(Z)||Number.isNaN(G)?g.create(h.VALUE):W<0||q<=0||ie<=0||![1,2,4].includes(Z)||G<0||G>4||!this._validDate(L,B,P,T,Z)?g.create(h.NUM):this._getResult(P,L,T,B,W,q,ie,Z,G)}_validDate(e,t,r,n,s){return this._getDateCorrectOrder(e,t,r,n)&&su(e,t,s)&&gr(n,e,s)}_getDateCorrectOrder(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&Math.floor(r)>Math.floor(n)}_getResult(e,t,r,n,s,a,u,c,l){const{days:f}=Ce(e,t,l),m=(s*f*100-(a-100))/((a-100)*.25*(1+2*f)+f*100);function d(_){return a-nu(e,t,r,n,s,_,u,c,l)}const C=na(m,_=>d(_));return typeof C!="number"?C:y.create(C)}}class g1 extends N{constructor(){super(...arguments);A(this,"minParams",7);A(this,"maxParams",8)}calculate(e,t,r,n,s,a,u,c){let l=c!=null?c:y.create(0);l.isNull()&&(l=y.create(0));const{isError:f,errorObject:m,variants:d}=je(e,t,r,n,s,a,u,l);if(f)return m;const[C,_,E,b,R,p,V,S]=d,D=F(C);if(typeof D!="number")return D;const w=F(_);if(typeof w!="number")return w;const P=F(E);if(typeof P!="number")return P;const L=+b.getValue(),T=+R.getValue(),B=+p.getValue(),W=Math.floor(+V.getValue()),q=Math.floor(+S.getValue());if(Number.isNaN(L)||Number.isNaN(T)||Number.isNaN(B)||Number.isNaN(W)||Number.isNaN(q))return g.create(h.VALUE);if(L<0||T<0||B<=0||![1,2,4].includes(W)||q<0||q>4||!this._validDate(w,D,P,W))return g.create(h.NUM);const ie=this._getResult(D,w,P,L,T,B,W,q);return y.create(ie)}_validDate(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&gr(r,e,n)}_getResult(e,t,r,n,s,a,u,c){const l=this._getCoupDate(t,r,u),f=this._getFrac(r,e,l,u,c),m=this._getFrac(r,t,l,u,c),d=this._getFrac(e,t,l,u,c);return(a*u+100*n*(m-f*(1+s*d/u)))/(s*d+u)}_getCoupDate(e,t,r){const n=re(e),s=re(t);for(s.setUTCFullYear(n.getUTCFullYear()),s>n&&s.setUTCFullYear(s.getUTCFullYear()-1);s<n;)s.setUTCMonth(s.getUTCMonth()+12/r);return Ee(s)}_getFrac(e,t,r,n,s){const a=re(e),u=re(t),c=re(r);for(c.setUTCFullYear(a.getUTCFullYear()),c<a&&c.setUTCFullYear(c.getUTCFullYear()+1);c>a;)c.setUTCMonth(c.getUTCMonth()-12/n);let l=Ee(c);c.setUTCMonth(c.getUTCMonth()+12/n);let f=Ee(c);if(f>=t){const{days:p}=Ce(e,t,s),V=$e(l,f,n,s);return p/V}const{days:m}=Ce(e,f,s),d=$e(l,f,n,s);let C=m/d;const _=re(f),E=re(f);for(E.setUTCMonth(E.getUTCMonth()+12/n);E<u;)_.setUTCMonth(_.getUTCMonth()+12/n),E.setUTCMonth(E.getUTCMonth()+12/n),C+=1;l=Ee(_),f=Ee(E);const{days:b}=Ce(l,t,s),R=$e(l,f,n,s);return C+=b/R,C}}class d1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c){let l=c!=null?c:y.create(0);l.isNull()&&(l=y.create(0));const{isError:f,errorObject:m,variants:d}=je(e,t,r,n,s,a,u,l);if(f)return m;const[C,_,E,b,R,p,V,S]=d,D=F(C);if(typeof D!="number")return D;const w=F(_);if(typeof w!="number")return w;const P=F(E);if(typeof P!="number")return P;const L=+b.getValue(),T=+R.getValue(),B=+p.getValue(),W=Math.floor(+V.getValue()),q=Math.floor(+S.getValue());if(Number.isNaN(L)||Number.isNaN(T)||Number.isNaN(B)||Number.isNaN(W)||Number.isNaN(q))return g.create(h.VALUE);if(L<0||T<=0||B<=0||![1,2,4].includes(W)||q<0||q>4||!this._validDate(w,D,P,W))return g.create(h.NUM);const ie=this._getResult(D,w,P,L,T,B,W,q);return y.create(ie)}_validDate(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&gr(r,e,n)}_getResult(e,t,r,n,s,a,u,c){const l=this._getCoupDate(t,r,u),f=this._getFrac(r,e,l,u,c),m=this._getFrac(r,t,l,u,c),d=this._getFrac(e,t,l,u,c);return(u*(a-s)+100*n*(m-f))/(d*s+100*n*f*d/u)}_getCoupDate(e,t,r){const n=re(e),s=re(t);for(s.setUTCFullYear(n.getUTCFullYear()),s>n&&s.setUTCFullYear(s.getUTCFullYear()-1);s<n;)s.setUTCMonth(s.getUTCMonth()+12/r);return Ee(s)}_getFrac(e,t,r,n,s){const a=re(e),u=re(t),c=re(r);for(c.setUTCFullYear(a.getUTCFullYear()),c<a&&c.setUTCFullYear(c.getUTCFullYear()+1);c>a;)c.setUTCMonth(c.getUTCMonth()-12/n);let l=Ee(c);c.setUTCMonth(c.getUTCMonth()+12/n);let f=Ee(c);if(f>=t){const{days:p}=Ce(e,t,s),V=$e(l,f,n,s);return p/V}const{days:m}=Ce(e,f,s),d=$e(l,f,n,s);let C=m/d;const _=re(f),E=re(f);for(E.setUTCMonth(E.getUTCMonth()+12/n);E<u;)_.setUTCMonth(_.getUTCMonth()+12/n),E.setUTCMonth(E.getUTCMonth()+12/n),C+=1;l=Ee(_),f=Ee(E);const{days:b}=Ce(l,t,s),R=$e(l,f,n,s);return C+=b/R,C}}class C1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d),{isError:E,errorObject:b,variants:R}=I(f,C,_);if(E)return b;const[p,V,S]=R,D=+p.getValue(),w=+V.getValue(),P=+S.getValue();if(D<=-1)return g.create(h.NUM);const L=(Math.log(P)-Math.log(w))/Math.log(1+D);return Number.isNaN(L)||!Number.isFinite(L)?g.create(h.NUM):y.create(L)});return n===1&&s===1?l.get(0,0):l}}class _1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p),{isError:P,errorObject:L,variants:T}=I(b,V,S,D,w);if(P)return L;const[B,W,q,ie,Z]=T,G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue(),be=+Z.getValue();if(G<=-1)return g.create(h.NUM);const he=jr(G,ce,ge,Ae,be?1:0);return Number.isNaN(he)||!Number.isFinite(he)?g.create(h.NUM):R===0&&p===0?y.create(he,Ye(this.getLocale())):y.create(he)});return c===1&&l===1?E.get(0,0):E}}class A1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a){const u=s!=null?s:y.create(0),c=a!=null?a:y.create(0),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),C=O(l,f,r,g.create(h.NA)),_=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.map((p,V,S)=>{const D=d.get(V,S),w=C.get(V,S),P=_.get(V,S),L=E.get(V,S),T=b.get(V,S),{isError:B,errorObject:W,variants:q}=I(p,D,w,P,L,T);if(B)return W;const[ie,Z,G,ce,ge,Ae]=q,be=+ie.getValue(),he=+Z.getValue(),Ue=+G.getValue(),dt=+ce.getValue(),Xt=+ge.getValue(),Ct=+Ae.getValue();if(he<1||Math.floor(he)>Math.ceil(Ue)||he-Ue>=1)return g.create(h.NUM);const Ke=jr(be,Ue,dt,Xt,Ct?1:0)-tu(be,he,Ue,dt,Xt,Ct?1:0);return Number.isNaN(Ke)||!Number.isFinite(Ke)?g.create(h.NUM):V===0&&S===0?y.create(Ke,Ye(this.getLocale())):y.create(Ke)});return l===1&&f===1?R.get(0,0):R}}class E1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){let c=u!=null?u:y.create(0);c.isNull()&&(c=y.create(0));const{isError:l,errorObject:f,variants:m}=je(e,t,r,n,s,a,c);if(l)return f;const[d,C,_,E,b,R,p]=m,V=F(d);if(typeof V!="number")return V;const S=F(C);if(typeof S!="number")return S;const D=+_.getValue(),w=+E.getValue(),P=+b.getValue(),L=Math.floor(+R.getValue()),T=Math.floor(+p.getValue());if(Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(T))return g.create(h.VALUE);if(D<0||w<0||P<=0||![1,2,4].includes(L)||T<0||T>4||V>=S||!gr(V,S,L))return g.create(h.NUM);const B=qr(V,S,D,w,P,L,T);return y.create(B)}}class b1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=p-R*p*S/D;return y.create(w)}}class y1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,C,_,E,b]=f,R=F(m);if(typeof R!="number")return R;const p=F(d);if(typeof p!="number")return p;const V=F(C);if(typeof V!="number")return V;const S=+_.getValue(),D=+E.getValue(),w=Math.floor(+b.getValue());if(Number.isNaN(S)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);const P=this._getDateCorrectOrder(p,R,V);if(S<0||D<0||w<0||w>4||!P)return g.create(h.NUM);const L=Ko(R,w),{days:T}=Ce(R,p,w),{days:B}=Ce(V,p,w),{days:W}=Ce(V,R,w),q=(100+B/L*S*100)/(1+T/L*D)-W/L*S*100;return y.create(q)}_getDateCorrectOrder(e,t,r){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)}}class R1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p),{isError:P,errorObject:L,variants:T}=I(b,V,S,D,w);if(P)return L;const[B,W,q,ie,Z]=T,G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue();let be=+Z.getValue();be=be?1:0;const he=G===0?-ge*ce-Ae:((1-(1+G)**ce)/G*ge*(1+G*be)-Ae)/(1+G)**ce;return Number.isNaN(he)||!Number.isFinite(he)?g.create(h.NUM):R===0&&p===0?y.create(he,Ye(this.getLocale())):y.create(he)});return c===1&&l===1?E.get(0,0):E}}class p1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const u=n!=null?n:y.create(0),c=s!=null?s:y.create(0),l=a!=null?a:y.create(.1),f=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,e,g.create(h.NA)),C=O(f,m,t,g.create(h.NA)),_=O(f,m,r,g.create(h.NA)),E=O(f,m,u,g.create(h.NA)),b=O(f,m,c,g.create(h.NA)),R=O(f,m,l,g.create(h.NA)),p=d.map((V,S,D)=>{const w=C.get(S,D),P=_.get(S,D),L=E.get(S,D),T=b.get(S,D),B=R.get(S,D),{isError:W,errorObject:q,variants:ie}=I(V,w,P,L,T,B);if(W)return q;const[Z,G,ce,ge,Ae,be]=ie,he=+Z.getValue(),Ue=+G.getValue(),dt=+ce.getValue(),Xt=+ge.getValue();let Ct=+Ae.getValue();const Ke=+be.getValue();return Ct=Ct?1:0,he<=0||Ue>=0?g.create(h.NUM):this._getResult(he,Ue,dt,Xt,Ct,Ke,S,D)});return f===1&&m===1?p.get(0,0):p}_getResult(e,t,r,n,s,a,u,c){let m=a;for(let d=0;d<20;d++){if(m<=-1)return g.create(h.NUM);let C,_;if(Math.abs(m)<1e-10?C=r*(1+e*m)+t*(1+m*s)*e+n:(_=(1+m)**e,C=r*_+t*(1/m+s)*(_-1)+n),Math.abs(C)<1e-10)break;let E;if(Math.abs(m)<1e-10)E=r*e+t*s*e;else{_=(1+m)**e;const b=e*(1+m)**(e-1);E=r*b+t*(1/m+s)*b+t*(-1/(m*m))*(_-1)}m-=C/E}return u===0&&c===0?y.create(m,"0%"):y.create(m)}}class N1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=R/(1-p*S/D);return w<0?g.create(h.NUM):y.create(w)}}class V1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d),{isError:E,errorObject:b,variants:R}=I(f,C,_);if(E)return b;const[p,V,S]=R,D=+p.getValue(),w=+V.getValue(),P=+S.getValue();if(D<=0)return g.create(h.NUM);if(w===0&&P===0)return y.create(0);const L=(P/w)**(1/D)-1;return Number.isNaN(L)||!Number.isFinite(L)||P/w<0?g.create(h.NUM):y.create(L)});return n===1&&s===1?l.get(0,0):l}}class O1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsLocale",!0)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);if(C.isError())return C;if(_.isError())return _;const E=+f.getValue(),b=+C.getValue(),R=+_.getValue();if(Number.isNaN(E)||Number.isNaN(b)||Number.isNaN(R))return g.create(h.VALUE);if(R===0)return g.create(h.DIV_BY_ZERO);const p=(E-b)/R;return m===0&&d===0?y.create(p,Ye(this.getLocale())):y.create(p)});return n===1&&s===1?l.get(0,0):l}}class M1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4);A(this,"needsLocale",!0)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.map((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);if(E.isError())return E;if(b.isError())return b;if(R.isError())return R;const p=+d.getValue(),V=+E.getValue(),S=+b.getValue(),D=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D))return g.create(h.VALUE);if(V<0||S<=0||D>S)return g.create(h.NUM);const w=(p-V)*(S-D+1)*2/(S*(S+1));return C===0&&_===0?y.create(w,Ye(this.getLocale())):y.create(w)});return s===1&&a===1?m.get(0,0):m}}class S1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=F(u);if(typeof f!="number")return f;const m=F(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const C=Math.floor(m)-Math.floor(f),E=re(f).getUTCFullYear(),b=kn(E);if(C>b)return g.create(h.NUM);let R=365*d/(360-d*C);if(C>182){const p=100*(1-d*C/360),V=C/365;if(R=(-V+Math.sqrt(V*V-(V*2-1)*(1-100/p)))/(V-.5),Number.isNaN(R))return g.create(h.NUM)}return R<0?g.create(h.NUM):y.create(R)}}class D1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsLocale",!0)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=F(u);if(typeof f!="number")return f;const m=F(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const C=Math.floor(m)-Math.floor(f),E=re(f).getUTCFullYear(),b=kn(E);if(C>b)return g.create(h.NUM);const R=100*(1-d*C/360);return R<0?g.create(h.NUM):y.create(R,Ye(this.getLocale()))}}class w1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=F(u);if(typeof f!="number")return f;const m=F(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const C=Math.floor(m)-Math.floor(f),E=re(f).getUTCFullYear(),b=kn(E);if(C>b)return g.create(h.NUM);const R=(100-d)/d*360/C;return y.create(R)}}class P1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",7);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a,u){let c=a!=null?a:y.create(2);c.isNull()&&(c=y.create(2));let l=u!=null?u:k.create(!1);l.isNull()&&(l=k.create(!1));const f=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,e,g.create(h.NA)),C=O(f,m,t,g.create(h.NA)),_=O(f,m,r,g.create(h.NA)),E=O(f,m,n,g.create(h.NA)),b=O(f,m,s,g.create(h.NA)),R=O(f,m,c,g.create(h.NA)),p=O(f,m,l,g.create(h.NA));return this._getResultArray(d,C,_,E,b,R,p,f,m)}_getResultArray(e,t,r,n,s,a,u,c,l){const f=e.map((m,d,C)=>{const _=t.get(d,C),E=r.get(d,C),b=n.get(d,C),R=s.get(d,C),p=a.get(d,C),V=u.get(d,C),{isError:S,errorObject:D,variants:w}=I(m,_,E,b,R,p,V);if(S)return D;const[P,L,T,B,W,q,ie]=w,Z=+P.getValue(),G=+L.getValue(),ce=+T.getValue(),ge=+B.getValue(),Ae=+W.getValue(),be=+q.getValue(),he=+ie.getValue();if(Z<0||G<0||ce<0||ge<0||Ae<0||Ae>ce||ge>Ae||be<0)return g.create(h.NUM);if(ce===0&&ge===0&&Ae===0)return g.create(h.DIV_BY_ZERO);const Ue=this._getResult(Z,G,ce,ge,Ae,be,he);return d===0&&C===0?y.create(Ue,Ye(this.getLocale())):y.create(Ue)});return c===1&&l===1?f.get(0,0):f}_getResult(e,t,r,n,s,a,u){const c=Math.floor(n),l=Math.ceil(s);let f=0;if(e<t){if(n>=1||u)return f;const m=Math.abs(e-t);return f=m*(s-n)>m?m:m*(s-n),-f}if(u)for(let m=c+1;m<=l;m++){let d=ys(e,t,r,m,a);m===c+1?d*=Math.min(s,c+1)-n:m===l&&(d*=s+1-l),f+=d}else{const m=e-this._getVdb(e,t,r,r,n,a);f=this._getVdb(m,t,r,r-n,s-n,a)}return f}_getVdb(e,t,r,n,s,a){const u=Math.ceil(s);let c=0,l=e-t,f=0,m=0,d=!1;for(let C=1;C<=u;C++){if(d)m=f;else{const _=ys(e,t,r,C,a);f=l/(n-(C-1)),f>_?(m=f,d=!0):(m=_,l-=_)}C===u&&(m*=s+1-u),c+=m}return c}}class L1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:n,errorObejct:s,_values:a,_dates:u}=this._checkErrors(e,t);if(n)return s;let c=r!=null?r:y.create(.1);c.isNull()&&(c=y.create(.1));const{isError:l,errorObject:f,variants:m}=H(c);if(l)return f;const[d]=m,C=+d.getValue();if(Number.isNaN(C))return g.create(h.VALUE);const{positive:_,negative:E}=this._checkValues(a);if(!_||!E||(a==null?void 0:a.length)!==(u==null?void 0:u.length)||C<0)return g.create(h.NUM);const b=na(C,R=>this._iterF(a,u,R));return typeof b!="number"?b:y.create(b)}_checkErrors(e,t){if(e.isError())return{isError:!0,errorObejct:e};if(t.isError())return{isError:!0,errorObejct:t};const{isError:r,errorObejct:n,_values:s}=this._checkErrorValues(e);if(r)return{isError:r,errorObejct:n};const{isError:a,errorObejct:u,_dates:c}=this._checkErrorDates(t);return a?{isError:a,errorObejct:u}:{isError:!1,_values:s,_dates:c}}_checkErrorValues(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;t.push(u)}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_values:t}}else{const r=e.getValue();return e.isBoolean()||e.isString()&&!M.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkErrorDates(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{if(s!=null&&s.isError())return r=!0,n=s,!1;if(s!=null&&s.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const a=+s.getValue();if(Number.isNaN(a))return r=!0,n=g.create(h.VALUE),!1;if(a<0)return r=!0,n=g.create(h.NUM),!1;t.push(Math.floor(a))}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_dates:t}}else{const r=e.getValue();return e.isBoolean()||e.isString()&&!M.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:+r<0?{isError:!0,errorObejct:g.create(h.NUM)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkValues(e){let t=!1,r=!1;for(let n=0;n<e.length;n++)e[n]>0&&(t=!0),e[n]<0&&(r=!0);return{positive:t,negative:r}}_iterF(e,t,r){return e.reduce((n,s,a)=>n+s/(1+r)**((t[a]-t[0])/365),0)}}class x1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isNull()||t.isNull()||r.isNull())return g.create(h.NA);const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=+u.getValue();if(Number.isNaN(c))return g.create(h.VALUE);let{isError:l,errorObejct:f,_values:m,_dates:d}=this._checkErrors(t,r);if(l)return f;if(m=m,d=d,c<0||m.length!==d.length)return g.create(h.NUM);let C=0;const _=d[0];for(let E=0;E<d.length;E++){const b=d[E],R=m[E];C+=R/(1+c)**((b-_)/365)}return y.create(C)}_checkErrors(e,t){if(e.isError())return{isError:!0,errorObejct:e};if(t.isError())return{isError:!0,errorObejct:t};const{isError:r,errorObejct:n,_values:s}=this._checkErrorValues(e);if(r)return{isError:r,errorObejct:n};const{isError:a,errorObejct:u,_dates:c}=this._checkErrorDates(t);return a?{isError:a,errorObejct:u}:{isError:!1,_values:s,_dates:c}}_checkErrorValues(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isNull()||a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;t.push(u)}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_values:t}}else{const r=e.getValue();return e.isNull()||e.isBoolean()||e.isString()&&!M.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkErrorDates(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isNull()||a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;if(u<0)return r=!0,n=g.create(h.NUM),!1;t.push(Math.floor(u))}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_dates:t}}else{const r=e.getValue();return e.isNull()||e.isBoolean()||e.isString()&&!M.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:+r<0?{isError:!0,errorObejct:g.create(h.NUM)}:{isError:!0,errorObejct:g.create(h.NA)}}}}class j1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){let c=u!=null?u:y.create(0);c.isNull()&&(c=y.create(0));const{isError:l,errorObject:f,variants:m}=je(e,t,r,n,s,a,c);if(l)return f;const[d,C,_,E,b,R,p]=m,V=F(d);if(typeof V!="number")return V;const S=F(C);if(typeof S!="number")return S;const D=+_.getValue(),w=+E.getValue(),P=+b.getValue(),L=Math.floor(+R.getValue()),T=Math.floor(+p.getValue());if(Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(T))return g.create(h.VALUE);if(D<0||w<=0||P<=0||![1,2,4].includes(L)||T<0||T>4||V>=S||!gr(V,S,L))return g.create(h.NUM);const B=this._getResult(V,S,D,w,P,L,T);return y.create(B)}_getResult(e,t,r,n,s,a,u){if(Wt(e,t,a)>1){let E=r||.01,b=qr(e,t,r,E,s,a,u),R=b-n;for(let p=0;p<100&&Math.abs(R)>1e-7;p++)b=qr(e,t,r,1.01*E,s,a,u),E+=-R/(b-n-R)*E*.01,R=qr(e,t,r,E,s,a,u)-n;return E}const l=$n(e,t,a,u),f=$e(e,t,a,u),{days:m}=Ce(e,t,u),d=n/100+l/f*r/a;return(s/100+r/a-d)/d*a*f/m}}class U1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=(p/R-1)/(S/D);return y.create(w)}}class v1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,C,_,E,b]=f,R=F(m);if(typeof R!="number")return R;const p=F(d);if(typeof p!="number")return p;const V=F(C);if(typeof V!="number")return V;const S=+_.getValue(),D=+E.getValue(),w=Math.floor(+b.getValue());if(Number.isNaN(S)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);const P=this._getDateCorrectOrder(p,R,V);if(S<0||D<=0||w<0||w>4||!P)return g.create(h.NUM);const L=Ko(R,w),{days:T}=Ce(R,p,w),{days:B}=Ce(V,p,w),{days:W}=Ce(V,R,w),q=((1+B/L*S)/(D/100+W/L*S)-1)/(T/L);return y.create(q)}_getDateCorrectOrder(e,t,r){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)}}const au=[[Tg,J.ACCRINT],[Bg,J.ACCRINTM],[Ig,J.AMORLINC],[Fg,J.COUPDAYBS],[kg,J.COUPDAYS],[$g,J.COUPDAYSNC],[Yg,J.COUPNCD],[Hg,J.COUPNUM],[Gg,J.COUPPCD],[Wg,J.CUMIPMT],[Qg,J.CUMPRINC],[qg,J.DB],[Xg,J.DDB],[Kg,J.DISC],[Zg,J.DOLLARDE],[zg,J.DOLLARFR],[Jg,J.DURATION],[e1,J.EFFECT],[t1,J.FV],[r1,J.FVSCHEDULE],[n1,J.INTRATE],[s1,J.IPMT],[a1,J.IRR],[i1,J.ISPMT],[o1,J.MDURATION],[u1,J.MIRR],[c1,J.NOMINAL],[l1,J.NPER],[f1,J.NPV],[m1,J.ODDFPRICE],[h1,J.ODDFYIELD],[g1,J.ODDLPRICE],[d1,J.ODDLYIELD],[C1,J.PDURATION],[_1,J.PMT],[A1,J.PPMT],[E1,J.PRICE],[b1,J.PRICEDISC],[y1,J.PRICEMAT],[R1,J.PV],[p1,J.RATE],[N1,J.RECEIVED],[V1,J.RRI],[O1,J.SLN],[M1,J.SYD],[S1,J.TBILLEQ],[D1,J.TBILLPRICE],[w1,J.TBILLYIELD],[P1,J.VDB],[L1,J.XIRR],[x1,J.XNPV],[j1,J.YIELD],[U1,J.YIELDDISC],[v1,J.YIELDMAT]];class T1 extends N{constructor(){super(...arguments);A(this,"needsReferenceObject",!0);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isError())return r;if(r.isReferenceObject()&&(r=r.toArrayValueObject()),r.isArray()){const n=r.getRowCount(),s=r.getColumnCount();if(n===1&&s===1){const a=r.get(0,0);return this._handleSingleObject(a,t)}return r.map(a=>a.isError()?a:this._handleSingleObject(a,t,!0))}return this._handleSingleObject(r,t)}_handleSingleObject(e,t,r=!1){let n=t;if(n.isError())return n;if(!n.isReferenceObject())return g.create(h.NA);const s=n.getCurrentActiveSheetData(),{columnData:a,defaultColumnWidth:u}=s;n=n.toArrayValueObject();const c=n.getCurrentRow(),l=n.getCurrentColumn();n=n.getFirstCell();const f=`${e.getValue()}`;let m;switch(f.toLocaleLowerCase()){case"address":return j.create(`$${M.Tools.chatAtABC(l)}$${c+1}`);case"col":return y.create(l+1);case"color":return y.create(0);case"contents":return n;case"filename":return g.create(h.VALUE);case"format":return j.create("G");case"parentheses":return y.create(0);case"prefix":return j.create("");case"protect":return y.create(1);case"row":return y.create(c+1);case"type":return m="v",n.isNull()&&(m="b"),n.isString()&&(m="l"),j.create(m);case"width":return this._getWidthResult(a,u,l,r);default:return g.create(h.VALUE)}}_getWidthResult(e,t,r,n){var u;let s=(u=e[r])==null?void 0:u.w;if(!s&&s!==0&&(s=t),n)return y.create(s);const a=[[s,s===t]];return K.createByArray(a)}}class B1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"_errorTypeValueMap",new Map([[h.NULL,1],[h.DIV_BY_ZERO,2],[h.VALUE,3],[h.REF,4],[h.NAME,5],[h.NUM,6],[h.NA,7],[h.CONNECT,8],[h.CALC,14]]))}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=e.getValue(),r=this._errorTypeValueMap.get(t);return r?y.create(r):g.create(h.NA)}}var Ne=(i=>(i.CELL="CELL",i.ERROR_TYPE="ERROR.TYPE",i.INFO="INFO",i.ISBLANK="ISBLANK",i.ISERR="ISERR",i.ISERROR="ISERROR",i.ISEVEN="ISEVEN",i.ISFORMULA="ISFORMULA",i.ISLOGICAL="ISLOGICAL",i.ISNA="ISNA",i.ISNONTEXT="ISNONTEXT",i.ISNUMBER="ISNUMBER",i.ISODD="ISODD",i.ISOMITTED="ISOMITTED",i.ISREF="ISREF",i.ISTEXT="ISTEXT",i.N="N",i.NA="NA",i.SHEET="SHEET",i.SHEETS="SHEETS",i.TYPE="TYPE",i))(Ne||{});class I1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isNull()?k.create(!0):e.isArray()?e.mapValue(t=>t.isNull()?k.create(!0):k.create(!1)):k.create(!1)}}class F1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.getValue()===h.NA?k.create(!1):e.isError()?k.create(!0):e.isArray()?e.mapValue(t=>t.getValue()===h.NA?k.create(!1):t.isError()?k.create(!0):k.create(!1)):k.create(!1)}}class k1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?k.create(!0):e.isArray()?e.mapValue(t=>t.isError()?k.create(!0):k.create(!1)):k.create(!1)}}class $1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isError())return t;if(t.isBoolean())return g.create(h.VALUE);const r=Math.trunc(+t.getValue());if(Number.isNaN(r))return g.create(h.VALUE);const n=r%2===0;return k.create(n)}}class Y1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){var u;if(e.isError())return e;if(!e.isReferenceObject())return g.create(h.NA);const t=(u=e.getCurrentActiveSheetData())==null?void 0:u.cellData.getMatrix(),{startRow:r,startColumn:n}=e.getRangePosition(),s=e.toArrayValueObject(),a=s.mapValue((c,l,f)=>{var d;const m=(d=t==null?void 0:t[r+l])==null?void 0:d[n+f];return m!=null&&m.f||m!=null&&m.si?k.create(!0):k.create(!1)});return s.getRowCount()===1&&s.getColumnCount()===1?a.get(0,0):a}}class H1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isBoolean()?k.create(!0):e.isArray()?e.mapValue(t=>t.isBoolean()?k.create(!0):k.create(!1)):k.create(!1)}}class G1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.getValue()===h.NA?k.create(!0):e.isArray()?e.mapValue(t=>t.getValue()===h.NA?k.create(!0):k.create(!1)):k.create(!1)}}class W1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return!e.isArray()&&!e.isString()?k.create(!0):e.isArray()?e.mapValue(t=>t.isString()?k.create(!1):k.create(!0)):k.create(!1)}}class Q1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isNumber()?k.create(!0):e.isArray()?e.mapValue(t=>t.isNumber()?k.create(!0):k.create(!1)):k.create(!1)}}class q1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isError())return t;if(t.isBoolean())return g.create(h.VALUE);const r=Math.trunc(+t.getValue());if(Number.isNaN(r))return g.create(h.VALUE);const n=r%2!==0;return k.create(n)}}class X1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){return e.isReferenceObject()?k.create(!0):k.create(!1)}}class K1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isString()?k.create(!0):e.isArray()?e.mapValue(t=>t.isString()?k.create(!0):k.create(!1)):k.create(!1)}}class Z1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(e.isArray()&&(t=e.get(0,0)),t.isError())return t;if(t.isString())return y.create(0);const r=+t.getValue();return y.create(r)}}class z1 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return g.create(h.NA)}}class J1 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1);A(this,"needsReferenceObject",!0);A(this,"needsSheetsInfo",!0)}calculate(e){var u;if(e!=null&&e.isError())return e;const{sheetOrder:t,sheetNameMap:r}=this.getSheetsInfo();if(!e){const c=t.findIndex(l=>l===this.subUnitId);return y.create(c+1)}if(e.isReferenceObject()){const c=e.getForcedSheetId(),l=e.getDefaultSheetId(),f=t.findIndex(m=>c?m===c:m===l);return y.create(f+1)}if(e.isArray())return g.create(h.NA);const n=`${e.getValue()}`.toLocaleLowerCase(),s=(u=Object.entries(r).find(([c,l])=>l.toLocaleLowerCase()===n))==null?void 0:u[0];if(!s)return g.create(h.NA);const a=t.findIndex(c=>c===s);return y.create(a+1)}}class e0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0);A(this,"needsSheetsInfo",!0)}calculate(){const{sheetOrder:e}=this.getSheetsInfo();return y.create(e.length)}}class t0 extends N{constructor(){super(...arguments);A(this,"needsReferenceObject",!0);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isReferenceObject()){const t=e.getRowCount(),r=e.getColumnCount();if(t===1&&r===1){const n=e.getFirstCell();if(n.isError())return y.create(16);if(n.isBoolean())return y.create(4);if(n.isString())return y.create(2);if(n.isNumber()||n.isNull())return y.create(1)}else return y.create(64)}else{if(e.isArray())return y.create(64);if(e.isError())return y.create(16);if(e.isBoolean())return y.create(4);if(e.isString())return y.create(2);if(e.isNumber()||e.isNull())return y.create(1)}return y.create(128)}}const iu=[[T1,Ne.CELL],[B1,Ne.ERROR_TYPE],[I1,Ne.ISBLANK],[F1,Ne.ISERR],[k1,Ne.ISERROR],[$1,Ne.ISEVEN],[Y1,Ne.ISFORMULA],[H1,Ne.ISLOGICAL],[G1,Ne.ISNA],[W1,Ne.ISNONTEXT],[Q1,Ne.ISNUMBER],[q1,Ne.ISODD],[X1,Ne.ISREF],[K1,Ne.ISTEXT],[Z1,Ne.N],[z1,Ne.NA],[J1,Ne.SHEET],[e0,Ne.SHEETS],[t0,Ne.TYPE]];class r0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=!0,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(t=t&&!!a.getValue(),r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(t=t&&!!s.getValue(),r=!1)}return r?g.create(h.VALUE):k.create(t)}}class n0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"needsReferenceObject",!0)}calculate(e,t){let r=e,n=null;if(e.isReferenceObject()&&(r=e.toArrayValueObject(),n=e),r.isError())return r;if(t.isError())return t;if(!(t.isValueObject()&&t.isLambda()&&t.getLambdaPrivacyVarKeys().length===1))return g.create(h.VALUE);const s=t,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;r=O(a,u,r);const c=[[]];for(let l=0;l<u;l++){const f=[];for(let C=0;C<a;C++){const _=r.get(C,l);f.push([_])}let m=K.create({calculateValueList:f,rowCount:a,columnCount:1,unitId:"",sheetId:"",row:0,column:0});if(n){const{startRow:C,startColumn:_}=n.getRangePosition(),E={startRow:C,startColumn:_+l,endRow:C+a-1,endColumn:_+l};m=this.createReferenceObject(n,E)}let d=s.execute(m);if(d.isArray()){const C=d.getRowCount(),_=d.getColumnCount();if(C>1||_>1)return g.create(h.CALC);d=d.get(0,0)}d.isNull()&&(d=y.create(0)),c[0].push(d)}return u===1?c[0][0]:K.create({calculateValueList:c,rowCount:1,columnCount:u,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class s0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"needsReferenceObject",!0)}calculate(e,t){let r=e,n=null;if(e.isReferenceObject()&&(r=e.toArrayValueObject(),n=e),r.isError())return r;if(t.isError())return t;if(!(t.isValueObject()&&t.isLambda()&&t.getLambdaPrivacyVarKeys().length===1))return g.create(h.VALUE);const s=t,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;r=O(a,u,r);const c=[];for(let l=0;l<a;l++){const f=[[]];for(let C=0;C<u;C++){const _=r.get(l,C);f[0].push(_)}let m=K.create({calculateValueList:f,rowCount:1,columnCount:u,unitId:"",sheetId:"",row:0,column:0});if(n){const{startRow:C,startColumn:_}=n.getRangePosition(),E={startRow:C+l,startColumn:_,endRow:C+l,endColumn:_+u-1};m=this.createReferenceObject(n,E)}let d=s.execute(m);if(d.isArray()){const C=d.getRowCount(),_=d.getColumnCount();if(C>1||_>1)return g.create(h.CALC);d=d.get(0,0)}d.isNull()&&(d=y.create(0)),c.push([d])}return a===1?c[0][0]:K.create({calculateValueList:c,rowCount:a,columnCount:1,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class a0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return k.create(!1)}}var Ve=(i=>(i.AND="AND",i.BYCOL="BYCOL",i.BYROW="BYROW",i.FALSE="FALSE",i.IF="IF",i.IFERROR="IFERROR",i.IFNA="IFNA",i.IFS="IFS",i.LAMBDA="LAMBDA",i.LET="LET",i.MAKEARRAY="MAKEARRAY",i.MAP="MAP",i.NOT="NOT",i.OR="OR",i.REDUCE="REDUCE",i.SCAN="SCAN",i.SWITCH="SWITCH",i.TRUE="TRUE",i.XOR="XOR",i))(Ve||{});class i0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r=k.create(!1)){const n=this._getSingleValueObject(e);if(n.isError())return n;if(!n.isArray())return n.getValue()?t:r;const s=Math.max(n.isArray()?n.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),a=Math.max(n.isArray()?n.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),u=O(s,a,n),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA));return u.map((f,m,d)=>{if(f.isNull())return g.create(h.NA);{const C=c.get(m,d)||ae.create(),_=l.get(m,d)||ae.create();return this._calculateSingleCell(f,C,_)}})}_getSingleValueObject(e){return e.isArray()&&e.getRowCount()===1&&e.getColumnCount()===1?e.getFirstCell():e}_calculateSingleCell(e,t,r){return e.isNull()?g.create(h.NA):e.getValue()?t.isNull()?g.create(h.NA):t:r.isNull()?g.create(h.NA):r}}class o0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;if(!e.isArray())return e.isError()?t:e;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.iterator((u,c,l)=>{u!=null&&u.isError()&&s.set(c,l,a.get(c,l))}),s}}class u0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError()&&e.getErrorType()!==h.NA)return e;if(t.isError())return t;if(!e.isArray())return e.isError()&&e.getErrorType()===h.NA?t:e;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.iterator((u,c,l)=>{u!=null&&u.isError()&&u.getErrorType()===h.NA&&s.set(c,l,a.get(c,l))}),s}}class c0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(...e){if(e.length%2!==0)return g.create(h.NA);for(let a=0;a<e.length;a++)if(e[a].isError())return e[a];const t=Math.max(...e.map(a=>a.isArray()?a.getRowCount():1)),r=Math.max(...e.map(a=>a.isArray()?a.getColumnCount():1)),n=e.map(a=>O(t,r,a,g.create(h.NA))),s=n[0].map((a,u,c)=>{for(let l=0;l<n.length;l+=2){const f=n[l].get(u,c)||ae.create(),m=n[l+1].get(u,c)||ae.create();if(f.isNull())continue;if(f.isError())return f;const d=f.getValue();if(f.isString()){if(`${d}`.toLocaleUpperCase()==="TRUE")return m;if(`${d}`.toLocaleUpperCase()==="FALSE")continue;return g.create(h.VALUE)}if(+d)return m.isNull()?g.create(h.NA):m}return g.create(h.NA)});return t===1&&r===1?s.get(0,0):s}}class l0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){return g.create(h.VALUE)}}class f0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(...e){return g.create(h.VALUE)}}class m0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(...e){const t=this.getIndexNumValue(e[0]);if(typeof t!="number")return t;const r=this.getIndexNumValue(e[1]);if(typeof r!="number")return r;if(!(e[2].isValueObject()&&e[2].isLambda()))return g.create(h.VALUE);const n=e[2],s=[];for(let a=0;a<t;a++){s[a]==null&&(s[a]=[]);for(let u=0;u<r;u++){let c=n.execute(y.create(a+1),y.create(u+1));c.isArray()&&(c=c.get(0,0)),s[a][u]=c}}return new Bi(s)}isAsync(){return!0}}let h0=class extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}calculate(...e){const t=[];let r=null,n=0,s=0;for(let u=0;u<e.length;u++){const c=e[u];let l=c;if(l.isReferenceObject()&&(l=c.toArrayValueObject()),l.isError())return l;if(u===e.length-1){if(!(c.isValueObject()&&c.isLambda()))return g.create(h.VALUE);r=c}else t.push(c),n=Math.max(n,l.isArray()?l.getRowCount():1),s=Math.max(s,l.isArray()?l.getColumnCount():1)}const a=this._getResultArray(t,r,n,s);return a instanceof g?a:n===1&&s===1?a[0][0]:K.create({calculateValueList:a,rowCount:n,columnCount:s,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getResultArray(e,t,r,n){const s=[];for(let a=0;a<r;a++){const u=[];for(let c=0;c<n;c++){const l=[];let f=!1;for(let d=0;d<e.length;d++){let C=e[d],_=null;if(C.isReferenceObject()&&(_=C,C=C.toArrayValueObject()),!C.isArray())if(a===0&&c===0){l.push(_||C);continue}else{u.push(g.create(h.NA)),f=!0;break}let E=C.get(a,c);if(!E){u.push(g.create(h.NA)),f=!0;break}if(_){const{startRow:b,startColumn:R}=_.getRangePosition(),p={startRow:b+a,startColumn:R+c,endRow:b+a,endColumn:R+c};E=this.createReferenceObject(_,p)}l.push(E)}if(f||l.length===0)continue;let m=t.execute(...l);if(m.isArray()){const d=m.getRowCount(),C=m.getColumnCount();if(d>1||C>1)return g.create(h.CALC);m=m.get(0,0)}m.isNull()&&(m=y.create(0)),u.push(m)}s.push(u)}return s}};class g0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;const t=+e.getValue();return Number.isNaN(t)?g.create(h.VALUE):k.create(!t)}}class d0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=!1,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(t=t||!!a.getValue(),r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(t=t||!!s.getValue(),r=!1)}return r?new g(h.VALUE):new k(t)}}class C0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n,s;e.isReferenceObject()?(n=e.toArrayValueObject(),s=e):(n=e,s=null);let a,u;return t.isReferenceObject()?(a=t.toArrayValueObject(),u=t):(a=t,u=null),n.isArray()?n.mapValue(c=>this._handleSingleValueObject(c,a,r,s,u)):this._handleSingleValueObject(n,a,r,s,u)}_handleSingleValueObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(!(r.isValueObject()&&r.isLambda()&&r.getLambdaPrivacyVarKeys().length===2))return g.create(h.VALUE);const a=r,u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;let l=e;n&&(l=n);for(let f=0;f<u;f++)for(let m=0;m<c;m++){let d=t.isArray()?t.get(f,m):t;if(d.isError())return d;if(s){const{startRow:_,startColumn:E}=s.getRangePosition(),b={startRow:_+f,startColumn:E+m,endRow:_+f,endColumn:E+m};d=this.createReferenceObject(s,b)}let C=a.execute(l,d);if(C.isError())return C;C.isNull()&&(C=y.create(0)),l=C}return l.isReferenceObject()?l.toArrayValueObject():l}}class _0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e,s=null;e.isReferenceObject()&&(n=e.toArrayValueObject(),s=e),n=n;let a=t,u=null;if(t.isReferenceObject()&&(a=t.toArrayValueObject(),u=t),a=a,n.isError())return n;if(a.isError())return a;if(r.isError())return r;if(!(r.isValueObject()&&r.isLambda()&&r.getLambdaPrivacyVarKeys().length===2))return g.create(h.VALUE);if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.CALC);n=n.get(0,0)}return this._getResult(n,a,r,s,u)}_getResult(e,t,r,n,s){const a=[],u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;let l=e;n&&(l=n);for(let f=0;f<u;f++){const m=[];for(let d=0;d<c;d++){if(l.isError()){m.push(l);continue}let C=t.isArray()?t.get(f,d):t;if(C.isError()){l=C,m.push(C);continue}if(s){const{startRow:E,startColumn:b}=s.getRangePosition(),R={startRow:E+f,startColumn:b+d,endRow:E+f,endColumn:b+d};C=this.createReferenceObject(s,R)}let _=r.execute(l,C);if(_.isArray()){const E=_.getRowCount(),b=_.getColumnCount();if(E>1||b>1)return g.create(h.CALC);_=_.get(0,0)}_.isNull()&&(_=y.create(0)),l=_,m.push(_)}a.push(m)}return u===1&&c===1?a[0][0]:K.create({calculateValueList:a,rowCount:u,columnCount:c,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class A0 extends N{constructor(){super(...arguments);A(this,"minParams",3)}calculate(e,...t){if(e.isError())return e;const r=t.length%2!==0,n=r?t[t.length-1]:ae.create();return!e.isArray()&&!t.some(s=>s.isArray())?this._handleNonArrayInputs(e,t,n,r):this._handleArrayInputs(e,t,n,r)}_handleNonArrayInputs(e,t,r,n){for(let s=0;s<t.length-(n?1:0);s+=2){const a=t[s],u=t[s+1];if(!a.isNull()){if(a.isError())return a;if(`${e.getValue()}`.toLocaleLowerCase()===`${a.getValue()}`.toLocaleLowerCase())return u.isNull()?g.create(h.NA):u}}return r.isNull()?g.create(h.NA):r}_handleArrayInputs(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,...t.map(f=>f.isArray()?f.getRowCount():1),r.isArray()?r.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,...t.map(f=>f.isArray()?f.getColumnCount():1),r.isArray()?r.getColumnCount():1),u=O(s,a,e),c=t.map(f=>O(s,a,f,g.create(h.NA))),l=O(s,a,r,g.create(h.NA));return u.map((f,m,d)=>{for(let _=0;_<c.length-(n?1:0);_+=2){const E=c[_].get(m,d)||ae.create(),b=c[_+1].get(m,d)||ae.create();if(!E.isNull()){if(E.isError()||f.isError())return E.isError()?E:f;if(`${f.getValue()}`.toLocaleLowerCase()===`${E.getValue()}`.toLocaleLowerCase())return b.isNull()?g.create(h.NA):b}}const C=l.get(m,d)||ae.create();return C.isNull()?g.create(h.NA):C})}}class E0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return k.create(!0)}}class b0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(a.getValue()&&t++,r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(s.getValue()&&t++,r=!1)}return r?g.create(h.VALUE):k.create(t%2===1)}}const ou=[[r0,Ve.AND],[n0,Ve.BYCOL],[s0,Ve.BYROW],[a0,Ve.FALSE],[i0,Ve.IF],[o0,Ve.IFERROR],[u0,Ve.IFNA],[c0,Ve.IFS],[l0,Ve.LAMBDA],[f0,Ve.LET],[m0,Ve.MAKEARRAY],[h0,Ve.MAP],[g0,Ve.NOT],[d0,Ve.OR],[C0,Ve.REDUCE],[_0,Ve.SCAN],[A0,Ve.SWITCH],[E0,Ve.TRUE],[b0,Ve.XOR]];class y0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",5)}calculate(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;const a=r!=null?r:y.create(1),u=n!=null?n:k.create(!0),c=s!=null?s:j.create(""),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),C=O(l,f,a,g.create(h.NA)),_=O(l,f,u,g.create(h.NA)),E=O(l,f,c,g.create(h.NA));return m.map((b,R,p)=>{const V=d.get(R,p)||g.create(h.NA),S=C.get(R,p)||g.create(h.NA),D=_.get(R,p)||g.create(h.NA),w=E.get(R,p)||g.create(h.NA);return b.isError()?b:V.isError()?V:S.isError()?S:D.isError()?D:w.isError()?w:this._calculateSingleCell(b,V,S,D,w)})}_calculateSingleCell(e,t,r,n,s){const a=Number.parseInt(`${Number(e.getValue())-1}`),u=Number.parseInt(`${Number(t.getValue())-1}`),c=Number.parseInt(`${Number(r.getValue())}`);if(Number.isNaN(a)||Number.isNaN(u)||Number.isNaN(c)||c<1||c>4)return g.create(h.VALUE);const l=R0(c),f=this.getZeroOrOneByOneDefault(n),m=`${s.getValue()}`,d=Jr(m)?`'${m}'`:m,C={startRow:a,startColumn:u,endRow:a,endColumn:u,startAbsoluteRefType:l,endAbsoluteRefType:l},_=n&&!f?fm(C):St(C);return j.create(d!==""?`${d}!${_}`:_)}}function R0(i){switch(i){case 1:return M.AbsoluteRefType.ALL;case 2:return M.AbsoluteRefType.ROW;case 3:return M.AbsoluteRefType.COLUMN;case 4:return M.AbsoluteRefType.NONE;default:return M.AbsoluteRefType.ALL}}class p0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){return e.isReferenceObject()?y.create(1):g.create(h.VALUE)}}class N0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}isAddress(){return!0}calculate(e,...t){let r=e;if(r.isError())return r;if(r.isReferenceObject()&&(r=r.toArrayValueObject()),!r.isArray()){const c=r.convertToNumberObjectValue();return c.isError()?c:t[Math.trunc(+c.getValue())-1]||g.create(h.VALUE)}let n=r.isArray()?r.getRowCount():1,s=r.isArray()?r.getColumnCount():1;t.forEach((c,l)=>{if(c.isArray()){const f=c;n=Math.max(n,f.getRowCount()),s=Math.max(s,f.getColumnCount())}else n=Math.max(n,1),s=Math.max(s,1)});const a=O(n,s,r,g.create(h.NA)),u=t.map(c=>{let l=c;return l.isReferenceObject()&&(l=l.toArrayValueObject()),O(n,s,l,g.create(h.NA))});return a.map((c,l,f)=>{if(c.isError())return c;const m=c.convertToNumberObjectValue();if(m.isError())return m;const d=u[Math.trunc(+m.getValue())-1];let C=(d==null?void 0:d.get(l,f))||g.create(h.VALUE);return C!=null&&C.isNull()&&(C=y.create(0)),C})}}class V0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=[];for(let a=0;a<t.length;a++){let u=t[a];if(u.isArray()){const f=u.getRowCount(),m=u.getColumnCount();if(f>1||m>1)return g.create(h.VALUE);u=u.get(0,0)}if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;const c=Math.trunc(+u.getValue());if(c===0||Math.abs(c)>n)return g.create(h.VALUE);let l=e;n>1&&(c<0?l=e.slice(void 0,[c+n,c+1+n]):l=e.slice(void 0,[c-1,c]));for(let f=0;f<r;f++)s[f]||(s[f]=[]),e.isArray()?s[f].push(l.get(f,0)):s[f].push(e)}return K.create({calculateValueList:s,rowCount:s.length,columnCount:s[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class O0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=e.isArray()?e.getRowCount():1,n=[];for(let s=0;s<t.length;s++){let a=t[s];if(a.isArray()){const l=a.getRowCount(),f=a.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);a=a.get(0,0)}if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return a;const u=Math.trunc(+a.getValue());if(u===0||Math.abs(u)>r)return g.create(h.VALUE);let c=e;r>1&&(u<0?c=e.slice([u+r,u+1+r]):c=e.slice([u-1,u])),e.isArray()?n.push(c.getArrayValue()[0]):n.push([e])}return K.create({calculateValueList:n,rowCount:n.length,columnCount:n[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class M0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1)}calculate(e){if(e==null)return y.create(this.column+1);if(e.isError())return e;if(!e.isArray())return g.create(h.NA);const t=e.getCurrentColumn(),r=e.getColumnCount(),n=[];for(let a=0;a<r;a++)n.push(y.create(t+a+1));const s={calculateValueList:[n],rowCount:1,columnCount:r,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(s)}}class S0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isString()||e.isNumber()||e.isBoolean())return y.create(1);if(!e.isArray())return g.create(h.NA);const t=e.getColumnCount();return y.create(t)}}class D0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(0),s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA));if(u>1||c>1)return l.mapValue((R,p,V)=>{const S=f.get(p,V);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:D,errorObject:w}=this._checkRowsColumns(R,S,s,a);return D?w:e.isArray()?g.create(h.VALUE):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const m=t.isArray()?t.get(0,0):t,d=n.isArray()?n.get(0,0):n,{isError:C,errorObject:_,rowsValue:E,columnsValue:b}=this._checkRowsColumns(m,d,s,a);return C?_:this._getResultArray(e,E,b,s,a)}_checkRowsColumns(e,t,r,n){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};const s=Math.trunc(+e.getValue()),a=Math.trunc(+t.getValue());return Number.isNaN(s)||Number.isNaN(a)?{isError:!0,errorObject:g.create(h.VALUE)}:Math.abs(s)>=r||Math.abs(a)>=n?{isError:!0,errorObject:g.create(h.CALC)}:{isError:!1,rowsValue:s,columnsValue:a}}_getResultArray(e,t,r,n,s){const a=t>=0?[t,n]:[0,n+t],u=r>=0?[r,s]:[0,s+r];let c;return t===0&&r===0?c=e:t===0?c=e.slice(void 0,u):r===0?c=e.slice(a,void 0):c=e.slice(a,u),c=c.map(l=>l.isNull()?y.create(0):l),n-t===1&&s-r===1?c.get(0,0):c}}class w0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1;let u=t,c=r!=null?r:y.create(a);const l=n!=null?n:g.create(h.NA);t.isNull()&&(u=y.create(s)),c.isNull()&&(c=y.create(a));const f=Math.max(u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),m=Math.max(u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),d=O(f,m,u,g.create(h.NA)),C=O(f,m,c,g.create(h.NA));if(f>1||m>1)return d.mapValue((D,w,P)=>{const L=C.get(w,P);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:T,errorObject:B}=this._checkRowsColumnsPadWith(D,L,l,s,a);return T?B:e.isArray()?e.get(0,0):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const _=u.isArray()?u.get(0,0):u,E=c.isArray()?c.get(0,0):c,{isError:b,errorObject:R,rowsValue:p,columnsValue:V,padWithObject:S}=this._checkRowsColumnsPadWith(_,E,l,s,a);return b?R:this._getResultArray(e,p,V,S,s,a)}_checkRowsColumnsPadWith(e,t,r,n,s){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};const a=Math.trunc(+e.getValue()),u=Math.trunc(+t.getValue());if(Number.isNaN(a)||Number.isNaN(u))return{isError:!0,errorObject:g.create(h.VALUE)};if(Math.abs(a)<n||Math.abs(u)<s)return{isError:!0,errorObject:g.create(h.VALUE)};let c=r;if(r.isArray()){const l=r.getRowCount(),f=r.getColumnCount();if(l>1||f>1)return{isError:!0,errorObject:g.create(h.VALUE)};c=r.get(0,0)}return{isError:!1,rowsValue:a,columnsValue:u,padWithObject:c}}_getResultArray(e,t,r,n,s,a){let u=[];e.isArray()?u=e.map(f=>f.isNull()?y.create(0):f).getArrayValue():u=[[e]];const c=Math.max(0,t-s),l=Math.max(0,r-a);for(let f=0;f<c;f++)u.push(new Array(a).fill(n));for(let f=0;f<l;f++)u.forEach(m=>{m.push(n)});return t===1&&r===1?u[0][0]:K.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class P0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:g.create(h.CALC);if(e.isError())return e;if(t.isError())return t;const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;return u>1&&c>1||u===1&&c!==a||c===1&&u!==s?g.create(h.VALUE):s===1&&a===1?this._getResultArrayByR1C1(e,t,n):u===1?c!==a?g.create(h.VALUE):this._getResultArrayByR1(s,a,e,t,n):c===1?u!==s?g.create(h.VALUE):this._getResultArrayByC1(s,a,e,t,n):n}_getResultArrayByR1C1(e,t,r){let n=e,s=t;return n.isArray()&&(n=n.get(0,0)),s.isArray()&&(s=s.get(0,0)),s.isString()&&(s=s.convertToNumberObjectValue()),s.isError()?s:+s.getValue()?n:r}_getResultArrayByR1(e,t,r,n,s){const a=[];for(let u=0;u<t;u++){let c=n.get(0,u);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;if(+c.getValue())for(let f=0;f<e;f++){a[f]||(a[f]=[]);const m=r.get(f,u);a[f].push(m)}}return a.length===0?s:K.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getResultArrayByC1(e,t,r,n,s){const a=[];for(let u=0;u<e;u++){let c=n.get(u,0);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;if(!+c.getValue())continue;const f=[];for(let m=0;m<t;m++){const d=r.get(u,m);f.push(d)}a.push(f)}return a.length===0?s:K.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class L0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0);A(this,"needsFormulaDataModel",!0)}calculate(e){var f,m;if(!e.isReferenceObject())return g.create(h.NA);const t=e.getUnitId(),r=e.getSheetId(),s=(m=(f=e.getUnitData()[t])==null?void 0:f[r])==null?void 0:m.cellData,{startRow:a,startColumn:u}=e.getRangePosition(),l=e.toArrayValueObject().mapValue((d,C,_)=>{const E=s.getValue(a+C,u+_);if(E!=null&&E.f||E!=null&&E.si){const b=this._formulaDataModel.getFormulaStringByCell(a+C,u+_,r,t);return j.create(b)}return g.create(h.NA)});return l.getRowCount()===1&&l.getColumnCount()===1?l.get(0,0):l}}var me=(i=>(i.ADDRESS="ADDRESS",i.AREAS="AREAS",i.CHOOSE="CHOOSE",i.CHOOSECOLS="CHOOSECOLS",i.CHOOSEROWS="CHOOSEROWS",i.COLUMN="COLUMN",i.COLUMNS="COLUMNS",i.DROP="DROP",i.EXPAND="EXPAND",i.FILTER="FILTER",i.FORMULATEXT="FORMULATEXT",i.GETPIVOTDATA="GETPIVOTDATA",i.HLOOKUP="HLOOKUP",i.HSTACK="HSTACK",i.HYPERLINK="HYPERLINK",i.IMAGE="IMAGE",i.INDEX="INDEX",i.INDIRECT="INDIRECT",i.LOOKUP="LOOKUP",i.MATCH="MATCH",i.OFFSET="OFFSET",i.ROW="ROW",i.ROWS="ROWS",i.RTD="RTD",i.SORT="SORT",i.SORTBY="SORTBY",i.TAKE="TAKE",i.TOCOL="TOCOL",i.TOROW="TOROW",i.TRANSPOSE="TRANSPOSE",i.UNIQUE="UNIQUE",i.VLOOKUP="VLOOKUP",i.VSTACK="VSTACK",i.WRAPCOLS="WRAPCOLS",i.WRAPROWS="WRAPROWS",i.XLOOKUP="XLOOKUP",i.XMATCH="XMATCH",i))(me||{});class x0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray()||r.isError()||n!=null&&n.isError())return g.create(h.NA);const s=this.getZeroOrOneByOneDefault(n);if(s==null)return g.create(h.VALUE);const a=this.getIndexNumValue(r);if(a instanceof g)return a;const u=t.slice([0,1]),c=t.slice([a-1,a]);return u==null||c==null?g.create(h.REF):e.isArray()?e.map(l=>this._handleSingleObject(l,u,c,s)):this._handleSingleObject(e,u,c,s)}_handleSingleObject(e,t,r,n){return n===0?this.equalSearch(e,t,r):this.binarySearch(e,t,r)}}class j0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=Math.max(...e.map(n=>n.isArray()?n.getRowCount():1)),r=[];for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<t;c++){r[c]||(r[c]=[]);for(let l=0;l<u;l++){let f=s;s.isArray()&&(f=s.get(c,l)),c>a-1||!f?r[c].push(g.create(h.NA)):r[c].push(f)}}}return K.create({calculateValueList:r,rowCount:r.length,columnCount:r[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class U0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4);A(this,"needsReferenceObject",!0)}calculate(e,t,r,n){if(e.isError())return e;if(t!=null&&t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;let s=0,a=0;if(e.isValueObject())s=1,a=1;else if(e.isReferenceObject()){const{startRow:d,endRow:C,startColumn:_,endColumn:E}=e.getRangePosition();s=C-d+1,a=E-_+1}else return g.create(h.VALUE);let u,c;s===1&&a>1&&r==null?(c=t!=null?t:y.create(0),u=y.create(0)):(u=t!=null?t:y.create(0),c=r!=null?r:y.create(0));let l=n!=null?n:y.create(1);u.isReferenceObject()&&(u=u.toArrayValueObject()),c.isReferenceObject()&&(c=c.toArrayValueObject()),l.isReferenceObject()&&(l=l.toArrayValueObject());const f=Math.max(u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1);if(u=u,c=c,l=l,f===1&&m===1)return this._calculateSingleCell(e,u,c,l);{const d=O(f,m,u,g.create(h.NA)),C=O(f,m,c,g.create(h.NA)),_=O(f,m,l,g.create(h.NA));return d.map((E,b,R)=>{const p=C.get(b,R)||ae.create(),V=_.get(b,R)||ae.create(),S=this._calculateSingleCell(e,E,p,V);return S.isReferenceObject()?S.toArrayValueObject().getFirstCell():S})}}_calculateSingleCell(e,t,r,n){if(t.isError())return t;const s=this._getNumberValue(t);if(s===void 0||s<0)return g.create(h.VALUE);if(r.isError())return r;const a=this._getNumberValue(r);if(a===void 0||a<0)return g.create(h.VALUE);if(n.isError())return n;const u=this._getAreaNumberValue(n);return u===void 0||u<1?g.create(h.VALUE):e.isReferenceObject()?this._getReferenceObject(e,s,a,u):e.isValueObject()&&s===1&&a===1?e:g.create(h.REF)}_getNumberValue(e){if(e==null)return 0;let t=0;if(e.isBoolean())e.getValue()===!0&&(t=1);else{if(e.isString())return;e.isNumber()?t=Math.floor(e.getValue()):e.isNull()&&(t=0)}return t}_getAreaNumberValue(e){if(e==null)return 1;let t=0;if(e.isBoolean())e.getValue()===!0&&(t=1);else{if(e.isString())return;e.isNumber()?t=Math.floor(e.getValue()):e.isNull()&&(t=0)}return t}_getReferenceObject(e,t,r,n){const{startRow:s,endRow:a,startColumn:u,endColumn:c}=e.getRangePosition();let l=0,f=0,m=0,d=0;if(t===0?(l=s,f=a):l=f=s+t-1,r===0?(m=u,d=c):m=d=u+r-1,l>a||m>c)return g.create(h.REF);const C={startRow:l,startColumn:m,endRow:f,endColumn:d};return this.createReferenceObject(e,C)}}class v0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}isAddress(){return!0}calculate(e,t){if(e.isError())return e;if(t!=null&&t.isError())return t;let r=this.getZeroOrOneByOneDefault(t);r==null&&(r=1);let n=e;if(e.isArray()){const s=e.getRowCount(),a=e.getColumnCount();if(s>1||a>1)return e.map(()=>g.create(h.VALUE));n=e.getFirstCell()}return this._handleSingleObject(n,r)}_handleSingleObject(e,t){const r=`${e.getValue()}`;if(r.trim()==="")return g.create(h.REF);const n=this._convertToDefinedName(r);if(t===0){const f=Zi(n),{range:m,sheetName:d,unitId:C}=f,_=new Rr(m);return _.setForcedUnitIdDirect(C),_.setForcedSheetName(d),this._setDefault(_)}if(Nr(n))return this._setDefault(new Ps(n));if(ui(n))return this._setDefault(new xs(n));if(ci(n))return this._setDefault(new Ls(n));const s=Yt(n),{range:a,sheetName:u,unitId:c}=s;if(Number.isNaN(a.startRow)||a.endRow+1>1048576||Number.isNaN(a.startColumn)||a.endColumn+1>16384)return g.create(h.REF);const l=new Rr(a);return l.setForcedUnitIdDirect(c),l.setForcedSheetName(u),this._setDefault(l)}_setDefault(e){return this.unitId==null||this.subUnitId==null?g.create(h.REF):(e.setDefaultUnitId(this.unitId),e.setDefaultSheetId(this.subUnitId),e)}_convertToDefinedName(e){const t=this.getDefinedName(e);if(t==null)return e;const r=t.formulaOrRefString;return r==null?e:r.startsWith(X.EQUALS)?r.slice(1):r}}class T0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsExpandParams",!0)}calculate(e,t,r){return e.isError()?e:t.isError()?g.create(h.REF):t.isArray()?r!=null&&r.isError()?r:t.getColumnCount()===1||t.getRowCount()===1?r!=null&&!r.isArray()?g.create(h.REF):this._handleVector(e,t,r):this._handleArray(e,t):g.create(h.VALUE)}_handleVector(e,t,r){let n=r;if(n==null)n=t;else if(n.getRowCount()!==t.getRowCount()||n.getColumnCount()!==t.getColumnCount())return g.create(h.REF);return e.isArray()?e.map(s=>this.binarySearch(s,t,n)):this.binarySearch(e,t,n)}_handleArray(e,t){const r=t.getRowCount(),n=t.getColumnCount();let s,a;return n>r?(s=t.slice([0,1]),a=t.slice([r-1,r])):(s=t.slice(void 0,[0,1]),a=t.slice(void 0,[n-1,n])),s==null||a==null?g.create(h.VALUE):e.isArray()?e.map(u=>this.binarySearch(u,s,a)):this.binarySearch(e,s,a)}}class B0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray())return g.create(h.VALUE);const n=t.getRowCount(),s=t.getColumnCount();if(n!==1&&s!==1||r!=null&&r.isError())return g.create(h.NA);const a=this.getMatchTypeValue(r);return a==null?g.create(h.VALUE):e.isArray()?e.map(u=>this._handleSingleObject(u,t,a)):this._handleSingleObject(e,t,a)}_handleSingleObject(e,t,r){const n=this._getSearchModeValue(r),s=t.orderSearch(e,n);if(s==null)return g.create(h.NA);if(s instanceof g)return s;const a=t.getRowCount()===1?s.column+1:s.row+1;return y.create(a)}_getSearchModeValue(e){switch(e){case 1:return Oe.MIN;case 0:return Oe.NORMAL;case-1:return Oe.MAX}}}class I0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsReferenceObject",!0)}isAddress(){return!0}calculate(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;if(!e.isReferenceObject())return g.create(h.VALUE);const a=e.getRowCount(),u=e.getColumnCount();let c=t;c.isReferenceObject()&&(c=c.toArrayValueObject());let l=r;l.isReferenceObject()&&(l=l.toArrayValueObject());let f=n!=null?n:y.create(a);f.isReferenceObject()&&(f=f.toArrayValueObject()),f.isNull()&&(f=y.create(a));let m=s!=null?s:y.create(u);m.isReferenceObject()&&(m=m.toArrayValueObject()),m.isNull()&&(m=y.create(u));const d=Math.max(c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1),C=Math.max(c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1);if(c=c,l=l,f=f,m=m,d===1&&C===1)return c=c.isArray()?c.get(0,0):c,l=l.isArray()?l.get(0,0):l,f=f.isArray()?f.get(0,0):f,m=m.isArray()?m.get(0,0):m,this._handleSingleObject(e,c,l,f,m);const _=O(d,C,c,g.create(h.NA)),E=O(d,C,l,g.create(h.NA)),b=O(d,C,f,g.create(h.NA)),R=O(d,C,m,g.create(h.NA));return _.mapValue((p,V,S)=>{const D=E.get(V,S),w=b.get(V,S),P=R.get(V,S);return p.isError()?p:D.isError()?D:w.isError()?w:P.isError()?P:this._handleSingleObject(e,p,D,w,P,!0)})}_handleSingleObject(e,t,r,n,s,a=!1){const{startRow:u,startColumn:c}=e.getRangePosition();let l=t;if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;let f=r;if(f.isString()&&(f=f.convertToNumberObjectValue()),f.isError())return f;const m=+l.getValue(),d=+f.getValue();if(typeof m!="number"||typeof d!="number")return g.create(h.VALUE);const C=u+m,_=c+d;if(C<0||_<0)return g.create(h.REF);const E=this.getIndexNumValue(n),b=this.getIndexNumValue(s);if(typeof E!="number"||typeof b!="number")return g.create(h.VALUE);if(E===0||b===0)return g.create(h.REF);const R=E>0?C+E-1:C+E+1,p=b>0?_+b-1:_+b+1;if(R<0||p<0)return g.create(h.REF);if(a)return g.create(h.VALUE);const V=C<R?C:R,S=_<p?_:p,D=C>R?C:R,w=_>p?_:p,P={startRow:V,startColumn:S,endRow:D,endColumn:w};return this.createReferenceObject(e,P)}}class F0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1)}calculate(e){if(e==null)return y.create(this.row+1);if(e.isError())return e;if(!e.isArray())return g.create(h.NA);const t=e.getCurrentRow(),r=e.getRowCount(),n=[];for(let a=0;a<r;a++)n.push([y.create(t+a+1)]);const s={calculateValueList:n,rowCount:r,columnCount:1,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(s)}}class k0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isString()||e.isNumber()||e.isBoolean())return y.create(1);if(!e.isArray())return g.create(h.NA);const t=e.getRowCount();return y.create(t)}}class $0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const s=t!=null?t:y.create(1),a=r!=null?r:y.create(1),u=n!=null?n:k.create(!1);if(u.isArray()){const c=u.getRowCount(),l=u.getColumnCount();if(c===1&&l===1){const f=u.get(0,0);return this._handleSingleObject(e,s,a,f)}return u.map(f=>{const m=this._handleSingleObject(e,s,a,f);return m.isArray()?m.get(0,0):m})}return this._handleSingleObject(e,s,a,u)}_handleSingleObject(e,t,r,n){if(e.isError())return e;const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=this._checkArrayError(t);if(u.isError())return u;const c=Math.floor(+u.getValue());if(c<1)return g.create(h.VALUE);const l=this._checkArrayError(r);if(l.isError())return l;const f=Math.floor(+l.getValue());if(f!==-1&&f!==1)return g.create(h.VALUE);let m=n;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;if(!e.isArray()||s===1&&a===1)return e;const d=+m.getValue();return this._getResult(e,c,f,d,s,a)}_checkArrayError(e){let t=e;if(t.isArray()){const r=t.getRowCount(),n=t.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=t.get(0,0)}return t.isString()&&(t=t.convertToNumberObjectValue()),t}_getResult(e,t,r,n,s,a){if(n){if(t>s)return g.create(h.VALUE);const u=e.transpose().getArrayValue();return u.sort(this._sort(t-1,r)),K.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}).transpose()}else{if(t>a)return g.create(h.VALUE);const u=e.getArrayValue();return u.sort(this._sort(t-1,r)),K.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}_sort(e,t=1){const r=tn();return t===1?this._sortAsc(e,r):this._sortDesc(e,r)}_sortAsc(e,t){return(r,n)=>{const s=r[e],a=n[e];if(s==null||s.isNull())return 1;if(a==null||a.isNull())return-1;if(s.isError()&&a.isError())return 0;if(s.isError())return 1;if(a.isError())return-1;const u=s.getValue(),c=a.getValue();return s.isBoolean()&&u===!0?1:a.isBoolean()&&c===!0?-1:s.isBoolean()&&u===!1?1:a.isBoolean()&&c===!1?-1:s.isNumber()&&a.isNumber()?+u-+c:t(u,c)}}_sortDesc(e,t){return(r,n)=>{const s=r[e],a=n[e];if(s==null||s.isNull())return 1;if(a==null||a.isNull())return-1;if(s.isError()&&a.isError())return 0;if(s.isError())return-1;if(a.isError())return 1;const u=s.getValue(),c=a.getValue();return s.isBoolean()&&u===!0?-1:a.isBoolean()&&c===!0?1:s.isBoolean()&&u===!1?-1:a.isBoolean()&&c===!1?1:s.isNumber()&&a.isNumber()?+c-+u:t(c,u)}}}class Y0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){t.length===1&&t.push(y.create(1));const r=this._getVariantsError(e,...t),{maxRowLength:n,maxColumnLength:s}=hr(t);if(r.isError()){const c=O(n,s,r);return n===1&&s===1?c.get(0,0):c}const a=t.map((c,l)=>l%2===0?c:O(n,s,c,g.create(h.NA))),u=this._getResultArray(e,a,n,s);return n===1&&s===1?u[0][0]:K.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getVariantsError(e,...t){if(e.isError())return e;for(let u=0;u<t.length;u++){const c=t[u];if(c.isError())return c}if(t.length<2||t.length%2!==0)return g.create(h.VALUE);const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t[0].isArray()?t[0].getRowCount():1,a=t[0].isArray()?t[0].getColumnCount():1;if((s>1||a>1)&&(s>1&&a>1||s===1&&a!==n||a===1&&s!==r))return g.create(h.VALUE);for(let u=2;u<t.length;u++){if(u%2===1)continue;const c=t[u].isArray()?t[u].getRowCount():1,l=t[u].isArray()?t[u].getColumnCount():1;if(c!==s||l!==a)return g.create(h.VALUE)}return k.create(!0)}_getResultArray(e,t,r,n){const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=t[0].isArray()?t[0].getRowCount():1,c=t[0].isArray()?t[0].getColumnCount():1,l=[];for(let f=0;f<r;f++){l[f]=[];for(let m=0;m<n;m++){const{isError:d,errorObject:C,byArrays:_,sortOrders:E}=this._getByArraysAndSortOrders(t,f,m,c);if(d){l[f].push(C);continue}if(!e.isArray()||s===1&&a===1){l[f].push(e);continue}let b=e.getArrayValue();u===1&&c===1||(u===1?(b=b.concat(_),b=this._transposeArray(b),b.sort(this._sort(s,E)),b=this._transposeArray(b).slice(0,s)):c===1&&(b=this._transposeArray(b),b=b.concat(_),b=this._transposeArray(b),b.sort(this._sort(a,E)),b=b.map(p=>p.slice(0,a))));const R=K.create({calculateValueList:b,rowCount:b.length,columnCount:b[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column});if(r>1||n>1){l[f].push(R.get(0,0));continue}l[f].push(R)}}return l}_getByArraysAndSortOrders(e,t,r,n){const s=[],a=[];let u=!1,c=null;for(let l=0;l<e.length;l++){if(l%2===1)continue;const f=e[l];let m=e[l+1].get(t,r);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError()){u=!0,c=m;break}const d=Math.floor(+m.getValue());if(d!==-1&&d!==1){u=!0,c=g.create(h.VALUE);break}if(a.push(d),f.isArray()){let C=f.getArrayValue();n===1&&(C=this._transposeArray(C)),s.push(C[0])}else s.push([f])}return{isError:u,errorObject:c,byArrays:s,sortOrders:a}}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}_sort(e,t){const r=tn();return(n,s)=>{let a=n[e],u=s[e],c=this._compare(a,u,t[0],r);if(c===0&&t.length>1){for(let l=1;l<t.length;l++)if(a=n[e+l],u=s[e+l],c=this._compare(a,u,t[l],r),c!==0)return c}return c}}_compare(e,t,r,n){return r===1?this._asc(e,t,n):this._desc(e,t,n)}_asc(e,t,r){if(e==null||e.isNull())return 1;if(t==null||t.isNull())return-1;if(e.isError()&&t.isError())return 0;if(e.isError())return 1;if(t.isError())return-1;const n=e.getValue(),s=t.getValue();return e.isBoolean()&&n===!0?1:t.isBoolean()&&s===!0?-1:e.isBoolean()&&n===!1?1:t.isBoolean()&&s===!1?-1:e.isNumber()&&t.isNumber()?+n-+s:r(n,s)}_desc(e,t,r){if(e==null||e.isNull())return 1;if(t==null||t.isNull())return-1;if(e.isError()&&t.isError())return 0;if(e.isError())return-1;if(t.isError())return 1;const n=e.getValue(),s=t.getValue();return e.isBoolean()&&n===!0?-1:t.isBoolean()&&s===!0?1:e.isBoolean()&&n===!1?-1:t.isBoolean()&&s===!1?1:e.isNumber()&&t.isNumber()?+s-+n:r(s,n)}}class H0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;let a=t,u=r!=null?r:y.create(s);t.isNull()&&(a=y.create(n)),u.isNull()&&(u=y.create(s));const c=Math.max(a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,a,g.create(h.NA)),m=O(c,l,u,g.create(h.NA));if(c>1||l>1)return f.mapValue((p,V,S)=>{const D=m.get(V,S);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:w,errorObject:P}=this._checkRowsColumns(p,D,n,s);return w?P:e.isArray()?g.create(h.VALUE):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const d=a.isArray()?a.get(0,0):a,C=u.isArray()?u.get(0,0):u,{isError:_,errorObject:E,rowsValue:b,columnsValue:R}=this._checkRowsColumns(d,C,n,s);return _?E:this._getResultArray(e,b,R,n,s)}_checkRowsColumns(e,t,r,n){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};let s=Math.trunc(+e.getValue()),a=Math.trunc(+t.getValue());return Number.isNaN(s)||Number.isNaN(a)?{isError:!0,errorObject:g.create(h.VALUE)}:Math.abs(s)===0||Math.abs(a)===0?{isError:!0,errorObject:g.create(h.CALC)}:(s>r&&(s=r),a>n&&(a=n),{isError:!1,rowsValue:s,columnsValue:a})}_getResultArray(e,t,r,n,s){if(!e.isArray())return e;const a=t>=0?[0,t]:[n+t,n],u=r>=0?[0,r]:[s+r,s];let c;return t===n&&r===s?c=e:t===n?c=e.slice(void 0,u):r===s?c=e.slice(a,void 0):c=e.slice(a,u),c=c.map(l=>l.isNull()?y.create(0):l),t===1&&r===1?c.get(0,0):c}}class G0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(0),s=r!=null?r:k.create(!1),a=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,n,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,C)=>{const _=l.get(d,C);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(m.isError())return m;if(_.isError())return _;const E=Math.trunc(+m.getValue()),b=+_.getValue();if(Number.isNaN(E)||E<0||E>3||Number.isNaN(b))return g.create(h.VALUE);if(!e.isArray())return e;let R=[];return b?R=this._getArrayValueByColumn(e,E):R=this._getArrayValueByRow(e,E),R.length===0?g.create(h.CALC):a>1||u>1||R.length===1?R[0]:K.create({calculateValueList:R.map(p=>[p]),rowCount:R.length,columnCount:1,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return a===1&&u===1?f.get(0,0):f}_getArrayValueByColumn(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<s;u++)for(let c=0;c<n;c++){const l=r.get(c,u);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_getArrayValueByRow(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){const l=r.get(u,c);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_isIgnore(e,t){switch(t){case 0:return!1;case 1:return e.isNull();case 2:return e.isError();case 3:return e.isNull()||e.isError();default:return!1}}}class W0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(0),s=r!=null?r:k.create(!1),a=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,n,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,C)=>{const _=l.get(d,C);if(e.isError())return e;if(m.isError())return m;if(_.isError())return _;const E=Math.trunc(+m.getValue()),b=+_.getValue();if(Number.isNaN(E)||E<0||E>3||Number.isNaN(b)||e.isNull())return g.create(h.VALUE);if(!e.isArray())return e;let R=[];return b?R=this._getArrayValueByColumn(e,E):R=this._getArrayValueByRow(e,E),R.length===0?g.create(h.CALC):a>1||u>1||R.length===1?R[0]:K.create({calculateValueList:[R],rowCount:1,columnCount:R.length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return a===1&&u===1?f.get(0,0):f}_getArrayValueByColumn(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<s;u++)for(let c=0;c<n;c++){const l=r.get(c,u);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_getArrayValueByRow(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){const l=r.get(u,c);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_isIgnore(e,t){switch(t){case 0:return!1;case 1:return e.isNull();case 2:return e.isError();case 3:return e.isNull()||e.isError();default:return!1}}}class Q0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount();return t===1&&r===1?e.get(0,0):e.transpose()}return e}}class q0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:k.create(!1),s=r!=null?r:k.create(!1),a=e.isArray()?e.getRowCount():1,u=e.isArray()?e.getColumnCount():1,c=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),l=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),f=O(c,l,n,g.create(h.NA)),m=O(c,l,s,g.create(h.NA)),d=f.map((C,_,E)=>{let b=C,R=m.get(_,E);if(e.isError())return e;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+b.getValue(),V=+R.getValue();let S;return!p&&a===1||p&&u===1?S=e:S=this._getResult(e,p,V),(c>1||l>1)&&(S!=null&&S.isArray())?S.get(0,0):S});return c===1&&l===1?d.get(0,0):d}_getResult(e,t,r){const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;let a=e.getArrayValue(),u=n,c=s;t&&(a=this._transposeArray(a),u=s,c=n);const l=this._getRepeatRows(a,u,c);if(l.length>0){const f=[];l.forEach(m=>{m.forEach((d,C)=>{(C!==0||r)&&f.push(d)})}),a=a.filter((m,d)=>!f.includes(d))}return a.length===0?g.create(h.CALC):(t&&(a=this._transposeArray(a)),K.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}))}_getRepeatRows(e,t,r){let n=[];for(let s=0;s<r;s++)if(s===0){const a=new Array(t).fill(null).map((u,c)=>({r:c,valueObject:e[c][s]}));n=this._getRepeatRowsByObjects(a)}else{if(n.length===0)break;let a=[];n.forEach(u=>{const c=u.map(f=>({r:f,valueObject:e[f][s]})),l=this._getRepeatRowsByObjects(c);a=a.concat(l)}),n=a}return n}_getRepeatRowsByObjects(e){const t=new Map;return e.forEach(r=>{const n=r.r,s=r.valueObject;let a=s.getValue();if(s.isNull()?a=null:s.isString()&&M.isRealNum(a)&&(a=+a),!t.has(a))t.set(a,[n]);else{const u=t.get(a);u.push(n),t.set(a,u)}}),Array.from(t.values()).filter(r=>r.length>1)}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}}class X0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return t;if(!t.isArray())return g.create(h.VALUE);if(r.isError())return r;if(n!=null&&n.isError())return n;const s=n!=null?n:k.create(!0);return Pa(e)&&Pa(s)&&r.isArray()?this._handleArrayColIndexNum(e,t,r,s):this._handleNonArrayColIndexNum(e,t,r,s)}_handleArrayColIndexNum(e,t,r,n){const s=e.isArray()?e.getFirstCell():e,a=this.getZeroOrOneByOneDefault(n);if(a==null)return g.create(h.VALUE);let u;const c=[];return r.iterator((l,f,m)=>{if(l==null)return u=g.create(h.VALUE),!1;const d=this._handleTableArray(s,t,l,a);if(d.isError())return u=d,!1;c[f]===void 0&&(c[f]=[]),c[f][m]=d}),u||Ht(c,c.length,c[0].length,this.unitId||"",this.subUnitId||"")}_handleNonArrayColIndexNum(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e),c=O(s,a,n);return u.map((l,f,m)=>{if(l.isError())return l;const d=c.get(f,m);if(d==null)return g.create(h.VALUE);if(d.isError())return d;const C=this.getZeroOrOneByOneDefault(d);return C==null?g.create(h.VALUE):this._handleTableArray(l,t,r,C)})}_handleTableArray(e,t,r,n){let s=this.getIndexNumValue(r);if(s instanceof g)return s;if(s=Math.floor(s),s<1)return g.create(h.VALUE);const a=t.slice(void 0,[0,1]);if(a==null)return g.create(h.VALUE);const u=t.slice(void 0,[s-1,s]);return u==null?g.create(h.REF):this._handleSingleObject(e,a,u,n)}_handleSingleObject(e,t,r,n){return n===0?this.equalSearch(e,t,r):this.binarySearch(e,t,r)}}class K0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=Math.max(...e.map(n=>n.isArray()?n.getColumnCount():1)),r=[];for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++){const l=[];for(let f=0;f<t;f++){let m=s;s.isArray()&&(m=s.get(c,f)),f>u-1||!m?l.push(g.create(h.NA)):l.push(m)}r.push(l)}}return K.create({calculateValueList:r,rowCount:r.length,columnCount:r[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class Z0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:g.create(h.NA);n.isNull()&&(n=g.create(h.NA));const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA)),m=l.mapValue((d,C,_)=>{const E=f.get(C,_);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(d.isError())return d;const b=Math.trunc(+d.getValue());if(s>1&&a>1||Number.isNaN(b))return g.create(h.VALUE);if(b<1)return g.create(h.NUM);const R=e.isArray()?e.getArrayValue().flat():[e],p=this._getWrapArray(R,b,E);return u>1||c>1||p.length===1&&p[0].length===1?p[0][0]:K.create({calculateValueList:p,rowCount:p.length,columnCount:p[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return u===1&&c===1?m.get(0,0):m}_getWrapArray(e,t,r){const n=Math.ceil(e.length/t),s=n>1?t:e.length,a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){a[c]||(a[c]=[]);const l=u*s+c;l<e.length?a[c].push(e[l].isNull()?y.create(0):e[l]):a[c].push(r)}return a}}class z0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:g.create(h.NA);n.isNull()&&(n=g.create(h.NA));const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA)),m=l.mapValue((d,C,_)=>{const E=f.get(C,_);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(d.isError())return d;const b=Math.trunc(+d.getValue());if(s>1&&a>1||Number.isNaN(b))return g.create(h.VALUE);if(b<1)return g.create(h.NUM);const R=e.isArray()?e.getArrayValue().flat():[e],p=this._getWrapArray(R,b,E);return u>1||c>1||p.length===1&&p[0].length===1?p[0][0]:K.create({calculateValueList:p,rowCount:p.length,columnCount:p[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return u===1&&c===1?m.get(0,0):m}_getWrapArray(e,t,r){const n=Math.ceil(e.length/t),s=n>1?t:e.length,a=[];for(let u=0;u<n;u++){const c=[];for(let l=0;l<s;l++){const f=u*s+l;f<e.length?c.push(e[f].isNull()?y.create(0):e[f]):c.push(r)}a.push(c)}return a}}class J0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){if(e.isError())return e;if(t.isError()||r.isError())return g.create(h.REF);if(!t.isArray()||!r.isArray())return g.create(h.VALUE);const u=t.getRowCount(),c=t.getColumnCount(),l=r.getRowCount(),f=r.getColumnCount();if(u!==1&&c!==1||u===1&&c>1&&c!==f||c===1&&u>1&&u!==l)return g.create(h.VALUE);if(n!=null&&n.isError()||s!=null&&s.isError()||a!=null&&a.isError())return g.create(h.NA);const m=n!=null?n:g.create(h.NA),d=this.getIndexNumValue(s||y.create(0));if(d instanceof g)return d;const C=this.getIndexNumValue(a||y.create(1));return C instanceof g?C:this._getResult(e,t,r,m,d,C,u,c,l,f)}_getResult(e,t,r,n,s,a,u,c,l,f){const m=e.isArray()?e.getRowCount():1,d=e.isArray()?e.getColumnCount():1;if(m>1||d>1){let b;return u===1?b=r.slice([0,1]):b=r.slice(void 0,[0,1]),b==null?g.create(h.NA):e.map(R=>{const p=this._checkErrorCombination(s,a);if(p)return p;const V=this._handleSingleObject(R,t,b,s,a);return V.isError()?n:V})}const C=e.isArray()?e.get(0,0):e;if(c===f&&u===l){const b=this._checkErrorCombination(s,a);if(b)return b;const R=this._handleSingleObject(C,t,r,s,a);return R.isError()?n:R}let _=0;c===f&&(_=1);const E=this._handleExpandObject(C,t,r,s,a,_);return E==null?g.create(h.NA):E}_handleExpandObject(e,t,r,n,s,a=0){if((s===2||s===-2)&&n!==2){const u=cs(s),c=us(n);return this.binarySearchExpand(e,t,r,a,u,c)}return n===2?this.fuzzySearchExpand(e,t,r,s!==-1,a):n===-1||n===1?this.orderSearchExpand(e,t,r,n===1?Oe.MAX:Oe.MIN,s===-1,a):this.equalSearchExpand(e,t,r,s!==-1,a)}_handleSingleObject(e,t,r,n,s){if((s===2||s===-2)&&n!==2){const a=cs(s),u=us(n);return this.binarySearch(e,t,r,a,u)}return n===2?this.fuzzySearch(e,t,r,s!==-1):n===-1||n===1?this.orderSearch(e,t,r,n===1?Oe.MAX:Oe.MIN,s===-1):this.equalSearch(e,t,r,s!==-1)}_checkErrorCombination(e,t){return e===2&&(t===-2||t===2)?g.create(h.VALUE):null}}class ed extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray())return g.create(h.VALUE);const s=t.getRowCount(),a=t.getColumnCount();if(s!==1&&a!==1)return g.create(h.VALUE);if(r!=null&&r.isError()||n!=null&&n.isError())return g.create(h.NA);const u=this.getIndexNumValue(r||y.create(0));if(u instanceof g)return u;const c=this.getIndexNumValue(n||y.create(1));return c instanceof g?c:e.isArray()?e.map(l=>this._handleSingleObject(l,t,u,c)):this._handleSingleObject(e,t,u,c)}_handleSingleObject(e,t,r,n){let s;if((n===2||n===-2)&&r!==2){const a=cs(n),u=us(r);s=t.binarySearch(e,a,u)}else if(r===2){const a=t.compare(e,$.EQUALS);let u;if(n!==-1?u=a.getFirstTruePosition():u=a.getLastTruePosition(),u==null)return g.create(h.NA);s=t.getRowCount()===1?u.column:u.row}else if(r===-1||r===1){const a=t.orderSearch(e,r===1?Oe.MAX:Oe.MIN,n===-1);if(a==null)return g.create(h.NA);if(a instanceof g)return a;s=t.getRowCount()===1?a.column:a.row}else{const a=t.isEqual(e);let u;if(n!==-1?u=a.getFirstTruePosition():u=a.getLastTruePosition(),u==null)return g.create(h.NA);s=t.getRowCount()===1?u.column:u.row}return s==null?g.create(h.NA):y.create(s+1)}}const uu=[[y0,me.ADDRESS],[p0,me.AREAS],[N0,me.CHOOSE],[V0,me.CHOOSECOLS],[O0,me.CHOOSEROWS],[M0,me.COLUMN],[S0,me.COLUMNS],[D0,me.DROP],[w0,me.EXPAND],[P0,me.FILTER],[L0,me.FORMULATEXT],[x0,me.HLOOKUP],[j0,me.HSTACK],[U0,me.INDEX],[v0,me.INDIRECT],[T0,me.LOOKUP],[B0,me.MATCH],[I0,me.OFFSET],[F0,me.ROW],[k0,me.ROWS],[$0,me.SORT],[Y0,me.SORTBY],[H0,me.TAKE],[G0,me.TOCOL],[W0,me.TOROW],[Q0,me.TRANSPOSE],[q0,me.UNIQUE],[X0,me.VLOOKUP],[K0,me.VSTACK],[Z0,me.WRAPCOLS],[z0,me.WRAPROWS],[J0,me.XLOOKUP],[ed,me.XMATCH]];class td extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.abs()}}class rd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.acos()}}class nd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.acosh()}}class sd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.isArray()?t.map(r=>r.isError()?r:Ga(r)):Ga(t)}}function Ga(i){let o=i.getValue();if(i.isBoolean()&&(o=o?1:0),!Number.isFinite(o))return g.create(h.VALUE);o=Number(o);let e=Math.atan(1/o);return o<0&&(e+=Math.PI),Number.isNaN(e)?g.create(h.VALUE):y.create(e)}class ad extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.isArray()?t.map(r=>r.isError()?r:Wa(r)):Wa(t)}}function Wa(i){let o=i.getValue();if(i.isBoolean()&&(o=o?1:0),!Number.isFinite(o))return g.create(h.VALUE);if(o=Number(o),Math.abs(o)<=1)return g.create(h.NUM);const e=1/2*Math.log((o+1)/(o-1));return Number.isNaN(e)?g.create(h.VALUE):y.create(e)}class id extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return y.create(0);if(e.isBoolean()||e.isNumber())return g.create(h.VALUE);let t=e.getValue().toLocaleString().toLocaleUpperCase();if(t.length>255)return g.create(h.VALUE);const r=t.startsWith("-");r&&(t=t.slice(1));let n=0;for(let s=0;s<t.length;s++){const a=Ir.get(t[s])||0,u=Ir.get(t[s+1])||0,c=Ir.get(t[s+2])||0,l=Ir.get(t[s+3])||0;if(!a||c>=u&&c>a||a===u&&a===c&&a===l||a===u/2)return g.create(h.VALUE);a<u?n-=a:n+=a}return y.create(r?-n:n)}}class od extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.asin()}}class ud extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.asinh()}}class cd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.atan()}}class ld extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e,n=t;return r.isString()&&(r=r.convertToNumberObjectValue()),r.isError()?r:(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:n.atan2(r))}}class fd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.atanh()}}class md extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(0);if(e.isError())return e;if(t.isError())return t;if(n.isError())return n;const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.map((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return this._handleSingleObject(m,_,E)});return f.getRowCount()===1&&f.getColumnCount()===1?f.getArrayValue()[0][0]:f}_handleSingleObject(e,t,r){let n=e;if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;let s=t;if(s.isString()&&(s=s.convertToNumberObjectValue()),s.isError())return s;let a=r;if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return a;const u=Math.floor(+n.getValue()),c=Math.floor(+s.getValue()),l=Math.floor(+a.getValue());if(u<0||u>=2**53||c<2||c>36||l<0)return g.create(h.NUM);let f=u.toString(c);return f.length<l&&(f=new Array(l-f.length+1).join("0")+f),j.create(f.toLocaleUpperCase())}}class hd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue(),_=+d.getValue();if(C>0&&_<0)return g.create(h.NUM);if(C===0||_===0)return y.create(0);const E=Be(C/_,0)*_;return y.create(E)});return u.getRowCount()===1&&u.getColumnCount()===1?u.getArrayValue()[0][0]:u}}class gd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(1),s=r!=null?r:y.create(0);if(e.isError())return e;if(n.isError())return n;if(s.isError())return s;const a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.map((d,C,_)=>{let E=d,b=l.get(C,_),R=f.get(C,_);if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+E.getValue(),V=+b.getValue(),S=+R.getValue();return p===0||V===0?y.create(0):this._getResult(p,V,S)});return a===1&&u===1?m.get(0,0):m}_getResult(e,t,r){let n;return e<0&&r!==0?n=(t<0?Be(Math.abs(e)/Math.abs(t),0):-Be(Math.abs(e)/t,0))*t:n=(t<0?-Be(e/Math.abs(t),0):Be(e/t,0))*t,y.create(n)}}class dd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),C=l;if(C.isString()&&(C=C.convertToNumberObjectValue()),C.isError())return C;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+C.getValue(),E=+d.getValue();if(_===0||E===0)return y.create(0);const b=(E<0?-Be(_/Math.abs(E),0):Be(_/E,0))*E;return y.create(b)});return n===1&&s===1?c.get(0,0):c}}class Cd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),d.isString()&&(d=d.convertToNumberObjectValue()),m.isError())return m;if(d.isError())return d;const C=Math.floor(+m.getValue()),_=Math.floor(+d.getValue());if(C<0||_<0||C<_)return g.create(h.NUM);const E=kt(C,_);return Number.isNaN(E)||!Number.isFinite(E)?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class _d extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),d.isString()&&(d=d.convertToNumberObjectValue()),m.isError())return m;if(d.isError())return d;const C=Math.floor(+m.getValue()),_=Math.floor(+d.getValue());if(C<0||_<0||C===0&&C<_)return g.create(h.NUM);const E=kt(C+_-1,C-1);return Number.isNaN(E)||!Number.isFinite(E)?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Ad extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.cos()}}class Ed extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.cosh()}}class bd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):r===0?g.create(h.DIV_BY_ZERO):t.tan().getReciprocal()}}class yd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:+t.getValue()===0?g.create(h.DIV_BY_ZERO):t.tanh().getReciprocal()}}class Rd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):r===0?g.create(h.DIV_BY_ZERO):t.sin().getReciprocal()}}class pd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return r===0?g.create(h.DIV_BY_ZERO):!Number.isNaN(r)&&!Number.isFinite(Math.sinh(r))?y.create(0):t.sinh().getReciprocal()}}class Nd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{if(c.isError())return c;let m=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const d=`${c.getValue()}`,C=Math.floor(+m.getValue());if(M.isRealNum(d)&&(+d<0||+d>=2**53||!Number.isInteger(+d))||d.toLocaleLowerCase()==="true"||d.toLocaleLowerCase()==="false"||C<2||C>36)return g.create(h.NUM);if(d.replace(/\s/g,"")==="")return y.create(0);if(!this._isValidCharForRadix(d,C))return g.create(h.NUM);const _=Number.parseInt(d,C);return Number.isNaN(_)?g.create(h.NUM):y.create(_)});return r===1&&n===1?u.get(0,0):u}_isValidCharForRadix(e,t){for(const r of e){const n=r.toUpperCase().charCodeAt(0);if(t<=10&&!(n>=48&&n<48+t)||t>10&&!(n>=48&&n<58||n>=65&&n<65+t-10))return!1}return!0}}class Vd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=r*(180/Math.PI);return Number.isNaN(n)?g.create(h.VALUE):y.create(n)}}class Od extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=(r<0?-Be(Math.abs(r)/2,0):Be(r/2,0))*2;return Number.isNaN(n)?g.create(h.VALUE):n===0?y.create(0):y.create(n)}}class Md extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.exp()}}class Sd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue()),n=er(r);return Number.isNaN(n)||!Number.isFinite(n)?g.create(h.NUM):y.create(n)}}class Dd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(e.isArray()){const r=e.getRowCount(),n=e.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=e.get(0,0)}return this._handleSingleObject(t)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue()),n=er(r,2);return Number.isNaN(n)||!Number.isFinite(n)?g.create(h.NUM):y.create(n)}}class wd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=a.get(l,f),d=c;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const C=+d.getValue(),_=+m.getValue();if(C>0&&_<0)return g.create(h.NUM);if(C===0)return y.create(0);if(_===0)return g.create(h.DIV_BY_ZERO);const E=ke(C/_,0)*_;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Pd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(1),s=r!=null?r:y.create(0),a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.map((d,C,_)=>{let E=d,b=l.get(C,_),R=f.get(C,_);if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+E.getValue(),V=+b.getValue(),S=+R.getValue();if(p===0||V===0)return y.create(0);let D;return p<0&&S!==0?D=(V<0?ke(Math.abs(p)/Math.abs(V),0):-ke(Math.abs(p)/V,0))*V:D=(V<0?-ke(p/Math.abs(V),0):ke(p/V,0))*V,y.create(D)});return a===1&&u===1?m.get(0,0):m}}class Ld extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),C=l;if(C.isString()&&(C=C.convertToNumberObjectValue()),C.isError())return C;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+C.getValue(),E=+d.getValue();if(_===0||E===0)return y.create(0);const b=(E<0?-ke(_/Math.abs(E),0):ke(_/E,0))*E;return y.create(b)});return n===1&&s===1?c.get(0,0):c}}class xd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];if(!n.isNull())if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{if(u!=null&&u.isNull())return!0;const{isError:c,errorObject:l,number:f}=this._handleSingleObject(u);if(c)return s=!0,a=l,!1;t=bs(t,f)}),s)return a}else{const{isError:s,errorObject:a,number:u}=this._handleSingleObject(n);if(s)return a;t=bs(t,u)}}return y.create(t)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0||r>=2**53?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class jd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue());return y.create(r)}}class Ud extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=1,r=!0;for(let n=0;n<e.length;n++){const s=e[n];if(!s.isNull())if(s.isArray()){let a=!1,u=g.create(h.VALUE);if(s.iterator(c=>{if(c!=null&&c.isNull())return!0;const{isError:l,errorObject:f,number:m}=this._handleSingleObject(c);if(l)return a=!0,u=f,!1;t=Fa(t,m),r=!1}),a)return u}else{const{isError:a,errorObject:u,number:c}=this._handleSingleObject(s);if(a)return u;t=Fa(t,c),r=!1}}return r?y.create(0):Number.isNaN(t)||!Number.isFinite(t)||t>=2**53?g.create(h.VALUE):y.create(t)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class vd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.log()}}class Td extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(10);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),C=l;if(C.isString()&&(C=C.convertToNumberObjectValue()),C.isError())return C;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+C.getValue(),E=+d.getValue();if(_<=0||E<=0)return g.create(h.NUM);const b=Math.log(E);if(b===0)return g.create(h.DIV_BY_ZERO);const R=Math.log(_)/b;return y.create(R)});return n===1&&s===1?c.get(0,0):c}}class Bd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.log10()}}class Id extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){let l=e.isArray()?e.get(a,c):e;if(l.isError())return l;if(l.isNull()||l.isBoolean())return g.create(h.VALUE);if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;const f=+l.getValue();u.push(f)}n.push(u)}if(t!==r)return g.create(h.VALUE);const s=Tn(n);return y.create(s)}}class Fd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){let l=e.isArray()?e.get(a,c):e;if(l.isError())return l;if(l.isNull()||l.isBoolean())return g.create(h.VALUE);if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;const f=+l.getValue();u.push(f)}n.push(u)}if(t!==r)return g.create(h.VALUE);const s=hm(n);return s===null?g.create(h.NUM):K.createByArray(s)}}class kd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;if(n!==s)return g.create(h.VALUE);const u=this._getMatrix(e,r,n),c=this._getMatrix(t,s,a);if(u instanceof g)return u;if(c instanceof g)return c;const l=tr(u,c);return K.createByArray(l)}_getMatrix(e,t,r){const n=[];for(let s=0;s<t;s++){const a=[];for(let u=0;u<r;u++){let c=e.isArray()?e.get(s,u):e;if(c.isError())return c;if(c.isNull()||c.isBoolean())return g.create(h.VALUE);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;const l=+c.getValue();a.push(l)}n.push(a)}return n}}class $d extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.mod(n)}}class Yd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isArray()){const c=r.getRowCount(),l=r.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;let n=t;if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean()||n.isBoolean())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(Number.isNaN(s)||Number.isNaN(a))return g.create(h.VALUE);if(a===0)return y.create(0);if(s>0&&a<0||s<0&&a>0)return g.create(h.NUM);const u=Vt(s/a,0)*a;return y.create(u)}}class Hd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=1;for(let s=0;s<e.length;s++){const a=e[s];if(!a.isNull())if(a.isArray()){let u=!1,c=g.create(h.VALUE);if(a.iterator(l=>{if(l!=null&&l.isNull())return!0;const{isError:f,errorObject:m,number:d}=this._handleSingleObject(l);if(f)return u=!0,c=m,!1;if(t+=d,t>170)return u=!0,c=g.create(h.NUM),!1;r*=er(d)}),u)return c}else{const{isError:u,errorObject:c,number:l}=this._handleSingleObject(a);if(u)return c;if(t+=l,t>170)return g.create(h.NUM);r*=er(l)}}const n=er(t)/r;return y.create(n)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class Gd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount(),n=e.mapValue(s=>{const a=this._handleSingleObject(s);return a.isError()?a:t>1||r>1?a.get(0,0):a});return t===1&&r===1?n.get(0,0):n}return this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue());if(r<=0)return g.create(h.VALUE);const n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<r;a++)n[s][a]=s===a?1:0}return K.createByArray(n)}}class Wd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);let n=r<0?-Be(Math.abs(r),0):Be(r,0);return Number.isNaN(n)?g.create(h.VALUE):(Math.abs(n)%2===0&&(r<0?n--:n++),y.create(n))}}class Qd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return y.create(Math.PI)}}class qd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.pow(n)}}class Xd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(1);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isArray()&&(n=this._multiplyArray(n)),n.isError())return n;if(t=t.multiply(n),t.isError())return t}}return t}_multiplyArray(e){let t=y.create(1);return e.iterator(r=>{if(r==null||r.isString()||r.isBoolean()||r.isNull())return!0;if(r.isError())return t=r,!1;t=t.multiply(r)}),t}}class Kd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=+u.getValue();if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l===0)return g.create(h.DIV_BY_ZERO);const f=Math.trunc(c/l);return y.create(f)}}class Zd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=r*(Math.PI/180);return Number.isNaN(n)?g.create(h.VALUE):y.create(n)}}class zd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return y.create(Math.random())}}class Jd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",5)}calculate(e,t,r,n,s){if(e!=null&&e.isError())return e;if(t!=null&&t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;const a=e!=null?e:y.create(1),u=t!=null?t:y.create(1),c=r!=null?r:y.create(0),l=n!=null?n:y.create(1),f=s!=null?s:y.create(0);return this._calculateResult(a,u,c,l,f)}_calculateResult(e,t,r,n,s){const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1);if(a===1&&u===1)return this._calculateSingleCell(e,t,r,n,s);const c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,n,g.create(h.NA)),d=O(a,u,s,g.create(h.NA));return c.map((C,_,E)=>{const b=l.get(_,E),R=f.get(_,E),p=m.get(_,E),V=d.get(_,E),S=this._handleError(C,b,R,p,V);if(S.errorObject)return S.errorObject;let{minValue:D,maxValue:w,wholeNumberValue:P}=S,L;return P?(D=Math.ceil(D),w=Math.floor(w),L=Math.floor(Math.random()*(w-D+1))+D):L=Math.random()*(w-D)+D,L<D||L>w?g.create(h.VALUE):y.create(L)})}_calculateSingleCell(e,t,r,n,s){let a=e;a.isArray()&&(a=a.get(0,0));let u=t;u.isArray()&&(u=u.get(0,0));let c=r;c.isArray()&&(c=c.get(0,0));let l=n;l.isArray()&&(l=l.get(0,0));let f=s;f.isArray()&&(f=f.get(0,0));const m=this._handleError(a,u,c,l,f);if(m.errorObject)return m.errorObject;let{rowsValue:d,columnsValue:C,minValue:_,maxValue:E,wholeNumberValue:b}=m;if(b&&(_=Math.ceil(_),E=Math.floor(E),_>E))return g.create(h.VALUE);const R=[];for(let p=0;p<d;p++){const V=[];for(let S=0;S<C;S++)b?V.push(Math.floor(Math.random()*(E-_+1))+_):V.push(Math.random()*(E-_)+_);R.push(V)}return d===1&&C===1?y.create(R[0][0]):K.createByArray(R)}_handleError(e,t,r,n,s){let a=e;if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return{errorObject:a};let u=t;if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return{errorObject:u};let c=r;if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return{errorObject:c};let l=n;if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return{errorObject:l};let f=s;return f.isString()&&(f=f.convertToNumberObjectValue()),f.isError()?{errorObject:f}:this._getValue(a,u,c,l,f)}_getValue(e,t,r,n,s){const a=Math.floor(+e.getValue()),u=Math.floor(+t.getValue());if(a===0||u===0)return{errorObject:g.create(h.CALC)};if(a<0||u<0)return{errorObject:g.create(h.VALUE)};const c=+r.getValue(),l=+n.getValue(),f=+s.getValue();return c>l?{errorObject:g.create(h.VALUE)}:f&&(!Number.isInteger(c)||!Number.isInteger(l))?{errorObject:g.create(h.VALUE)}:{rowsValue:a,columnsValue:u,minValue:c,maxValue:l,wholeNumberValue:f}}}class eC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isArray()){const c=r.getRowCount(),l=r.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;let n=t;if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean()||n.isBoolean())return g.create(h.VALUE);let s=+r.getValue(),a=+n.getValue();if(Number.isNaN(s)||Number.isNaN(a))return g.create(h.VALUE);if(s>a)return g.create(h.NUM);s=Math.ceil(s),a=Math.floor(a);const u=Math.floor(Math.random()*(a-s+1))+s;return y.create(u)}}class tC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e);if(r)return n;const[a]=s;let u=Math.floor(+a.getValue()),c=t;if(c.isString()&&(c=c.convertToNumberObjectValue(),c.isError()))return c;let l=Math.floor(+c.getValue());if(c.isBoolean()&&(l=c.getValue()?0:4),u<0||u>3999||l<0||l>4)return g.create(h.VALUE);const f=Am[l];let m=f.length-1,d="";for(;u>0;){m=this._binarySearch(u,0,m,f);const C=f[m];u-=C,d+=_m.get(C)}return j.create(d)}_binarySearch(e,t,r,n){let s=t,a=r;for(;a-s>1;){const u=Math.floor((s+a)/2),c=n[u];if(c===e)return u;c>e?a=u:s=u}return s!==a&&n[a]<=e?a:s}}class rC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.round(n)}}class nC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.floor(n)}}class sC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.ceil(n)}}class aC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):t.cos().getReciprocal()}}class iC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Number.isFinite(Math.cosh(r))?Math.abs(r)>=2**27?g.create(h.NUM):t.cosh().getReciprocal():y.create(0)}}class oC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){let s=e,a=t!=null?t:y.create(1),u=r!=null?r:y.create(1),c=n!=null?n:y.create(1);s.isNull()&&(s=y.create(1)),a.isNull()&&(a=y.create(1)),u.isNull()&&(u=y.create(1)),c.isNull()&&(c=y.create(1));const l=Math.max(s.isArray()?s.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(s.isArray()?s.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,s,g.create(h.NA)),d=O(l,f,a,g.create(h.NA)),C=O(l,f,u,g.create(h.NA)),_=O(l,f,c,g.create(h.NA)),E=m.mapValue((b,R,p)=>{const V=d.get(R,p),S=C.get(R,p),D=_.get(R,p);return b.isError()?b:V.isError()?V:S.isError()?S:D.isError()?D:this._getResult(b,V,S,D,l,f)});return l===1&&f===1?E.get(0,0):E}_getResult(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=I(e,t,r,n);if(u)return c;const[f,m,d,C]=l,_=Math.floor(+f.getValue()),E=Math.floor(+m.getValue()),b=+d.getValue(),R=+C.getValue();if(_<0||E<0)return g.create(h.VALUE);if(_===0||E===0)return g.create(h.CALC);const p=[];for(let V=0;V<_;V++){p[V]=[];for(let S=0;S<E;S++)p[V][S]=b+(V*E+S)*R}return s>1||a>1?y.create(p[0][0]):K.createByArray(p)}}class uC extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isNull()||t.isNull()||r.isNull()||n.isNull())return g.create(h.NA);const{isError:s,errorObject:a,variants:u}=H(e,t,r);if(s)return a;const{isError:c,errorObject:l,variants:f}=I(...u);if(c)return l;const[m,d,C]=f,_=+m.getValue(),E=+d.getValue(),b=+C.getValue(),R=[];if(n.isArray()){let V=!1,S=g.create(h.VALUE);if(n.iterator(D=>{const{isError:w,errorObject:P,coefficientsObject:L}=this._handleSingleObject(D);if(w)return V=!0,S=P,!1;const T=+L.getValue();R.push(T)}),V)return S}else{const{isError:V,errorObject:S,coefficientsObject:D}=this._handleSingleObject(n);if(V)return S;const w=+D.getValue();R.push(w)}let p=0;for(let V=0;V<R.length;V++)p+=R[V]*_**(E+V*b);return Number.isNaN(p)||!Number.isFinite(p)?g.create(h.NUM):y.create(p)}_handleSingleObject(e){if(e.isError())return{isError:!0,errorObject:e,coefficientsObject:null};if(e!=null&&e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),coefficientsObject:null};let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?{isError:!0,errorObject:t,coefficientsObject:null}:{isError:!1,errorObject:null,coefficientsObject:t}}}class cC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue();return a>0?y.create(1):a<0?y.create(-1):y.create(0)}}class lC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sin()}}class fC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sinh()}}class mC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sqrt()}}class hC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(r<0)return g.create(h.NUM);const n=Math.sqrt(r*Math.PI);return y.create(n)}}class gC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}calculate(e,...t){if(e.isError())return e;if(e.isReferenceObject()){const r=[];return e.iterator((n,s,a)=>{r[s]==null&&(r[s]=[]),r[s][a]=this._handleSingleObject(n,...t)}),Ht(r,r.length,r[0].length)}return this._handleSingleObject(e,...t)}_handleSingleObject(e,...t){const r=this._getIndexNumValue(e);let n;if(r instanceof g)return r;switch(r){case 1:n=this._average(!1,...t);break;case 2:n=this._count(!1,...t);break;case 3:n=this._counta(!1,...t);break;case 4:n=this._max(!1,...t);break;case 5:n=this._min(!1,...t);break;case 6:n=this._product(!1,...t);break;case 7:n=this._stdev(!1,...t);break;case 8:n=this._stdevp(!1,...t);break;case 9:n=this._sum(!1,...t);break;case 10:n=this._var(!1,...t);break;case 11:n=this._varp(!1,...t);break;case 101:n=this._average(!0,...t);break;case 102:n=this._count(!0,...t);break;case 103:n=this._counta(!0,...t);break;case 104:n=this._max(!0,...t);break;case 105:n=this._min(!0,...t);break;case 106:n=this._product(!0,...t);break;case 107:n=this._stdev(!0,...t);break;case 108:n=this._stdevp(!0,...t);break;case 109:n=this._sum(!0,...t);break;case 110:n=this._var(!0,...t);break;case 111:n=this._varp(!0,...t);break;default:n=g.create(h.VALUE)}return n}_getIndexNumValue(e){const t=e?Number(e.getValue()):0;if(Number.isNaN(t))return g.create(h.VALUE);const r=Math.floor(t);return r>=1&&r<=11||r>=101&&r<=111?r:g.create(h.VALUE)}_average(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:r.mean()}_count(e,...t){let r=y.create(0);for(let n=0;n<t.length;n++){const s=t[n];if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();s.iterator((u,c)=>{if(e&&this._isRowHidden(a,c))return!0;u!=null&&u.isNumber()&&(r=r.plusBy(1))})}return r}_counta(e,...t){let r=y.create(0);for(let n=0;n<t.length;n++){const s=t[n];if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();s.iterator((u,c)=>{if(e&&this._isRowHidden(a,c)||u==null||u.isNull())return!0;r=r.plusBy(1)})}return r}_max(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?y.create(0):r.max()}_min(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?y.create(0):r.min()}_product(e,...t){const r=this._flattenRefArray(e,...t);if(r.isError())return r;if(this._isBlankArrayObject(r))return y.create(0);let n=y.create(1);return r.iterator(s=>{n=n.multiply(s)}),n}_stdev(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.std(1)}_stdevp(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.std()}_sum(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:r.sum()}_var(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.var(1)}_varp(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.var()}_flattenRefArray(e,...t){const r=[];r[0]=[];for(let n=0;n<t.length;n++){const s=t[n];if(s.isError())return s;if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();let u;if(s.iterator((c,l)=>{if(e&&this._isRowHidden(a,l)||c==null||c.isNull()||c.isString()||c.isBoolean())return!0;if(c.isError())return u=c,!1;r[0].push(c)}),u!=null&&u.isError())return u}return Ht(r,1,r[0].length)}_isRowHidden(e,t){const r=e[t];return r?r.hd===M.BooleanNumber.TRUE:!1}_isBlankArrayObject(e){return e.getArrayValue()[0].length===0}}class dC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()||(n.isArray()&&(n=n.sum()),n.isError()))return n;if(t=t.plus(n),t.isError())return t}return t}}class CC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=t;if(t.isReferenceObject()&&(n=t.toArrayValueObject()),n.isArray()){const s=n.mapValue(a=>this._handleSingleObject(e,a,r));return s.getRowCount()===1&&s.getColumnCount()===1?s.get(0,0):s}return this._handleSingleObject(e,n,r)}_handleSingleObject(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;if(!e.isReferenceObject()||r&&!r.isReferenceObject())return g.create(h.VALUE);const n=e.toArrayValueObject();let s=jn(n,t);const[,a]=mr(`${t.getValue()}`);s=Un(s,n,a);const u=n.getRowCount(),c=n.getColumnCount();let l=n;if(r){l=r.toArrayValueObject();const f=l.getRowCount(),m=l.getColumnCount();if(u!==f||c!==m){const d=r.getRangeData();d.endRow=d.startRow+u-1,d.endColumn=d.startColumn+c-1,r.setRangeData(d),l=r.toArrayValueObject()}}return l.pick(s).sum()}}class _C extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;if(!e.isArray()||t.length<2||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=hr(t),s=Sr(t,e,r,n);if(s)return s;const a=Dr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>e.pick(a).sum())),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(n)}}class AC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=this._initArray1(e);if(t.length>0){const n=r.getRowCount(),s=r.getColumnCount();let a=this._getResultArrayByArray1(n,s,r);if(a instanceof g)return a;a=a;for(let c=0;c<t.length;c++){if(t[c].isError())return t[c];let l=1,f=1;if(t[c].isArray()&&(l=t[c].getRowCount(),f=t[c].getColumnCount()),l!==n||f!==s)return g.create(h.VALUE);for(let m=0;m<n;m++){const d=[];for(let C=0;C<s;C++){let _=t[c];if(t[c].isArray()&&(_=t[c].get(m,C)),_.isError())return _;const E=_.getValue();!E||!M.isRealNum(E)?d.push(0):d.push(+E*a[m][C])}a[m]=d}}const u=a.reduce((c,l)=>c.concat(l)).reduce((c,l)=>c+l,0);return y.create(u)}else return r.sum()}_initArray1(e){let t=e;return t.isArray()||(t=K.create({calculateValueList:[[t]],rowCount:1,columnCount:1,unitId:"",sheetId:"",row:0,column:0})),t}_getResultArrayByArray1(e,t,r){const n=[];for(let s=0;s<e;s++){const a=[];for(let u=0;u<t;u++){const c=r.get(s,u);if(c.isError())return c;const l=c.getValue();!l||!M.isRealNum(l)?a.push(0):a.push(+l)}n.push(a)}return n}}class EC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);const r=y.create(2);for(let n=0;n<e.length;n++){let s=e[n];if(s.isString()&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()?s.iterator(a=>{if(a==null||a.isString()||a.isBoolean()||a.isNull())return!0;if(a.isError())return t=a,!1;t=t.plus(a.pow(r))}):t=t.plus(s.pow(r)),t.isError())return t}return t}}class bC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ae.create();const d=[],C=[];let _=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),S=+p.getValue();d.push(V),C.push(S),_+=V**2-S**2}),m.isError()?m:d.length===0||C.length===0?g.create(h.DIV_BY_ZERO):y.create(_)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!M.isRealNum(s)||r.isBoolean()||n.isString()&&!M.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=s**2-a**2;return y.create(u)}}class yC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ae.create();const d=[],C=[];let _=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),S=+p.getValue();d.push(V),C.push(S),_+=V**2+S**2}),m.isError()?m:d.length===0||C.length===0?g.create(h.DIV_BY_ZERO):y.create(_)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!M.isRealNum(s)||r.isBoolean()||n.isString()&&!M.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=s**2+a**2;return y.create(u)}}class RC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ae.create();const d=[],C=[];let _=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),S=+p.getValue();d.push(V),C.push(S),_+=(V-S)**2}),m.isError()?m:d.length===0||C.length===0?g.create(h.DIV_BY_ZERO):y.create(_)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!M.isRealNum(s)||r.isBoolean()||n.isString()&&!M.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=(s-a)**2;return y.create(u)}}class pC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.tan()}}class NC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.tanh()}}class VC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),C=l;if(C.isString()&&(C=C.convertToNumberObjectValue()),C.isError())return C;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+C.getValue(),E=+d.getValue(),b=10**Math.trunc(E),R=Pn(_,b),p=Math.trunc(fr(_,b)+R)/b;return y.create(p)});return n===1&&s===1?c.get(0,0):c}}const cu=[[td,Y.ABS],[rd,Y.ACOS],[nd,Y.ACOSH],[sd,Y.ACOT],[ad,Y.ACOTH],[id,Y.ARABIC],[od,Y.ASIN],[ud,Y.ASINH],[cd,Y.ATAN],[ld,Y.ATAN2],[fd,Y.ATANH],[md,Y.BASE],[hd,Y.CEILING],[gd,Y.CEILING_MATH],[dd,Y.CEILING_PRECISE],[Cd,Y.COMBIN],[_d,Y.COMBINA],[Ad,Y.COS],[Ed,Y.COSH],[bd,Y.COT],[yd,Y.COTH],[Rd,Y.CSC],[pd,Y.CSCH],[Nd,Y.DECIMAL],[Vd,Y.DEGREES],[Od,Y.EVEN],[Md,Y.EXP],[Sd,Y.FACT],[Dd,Y.FACTDOUBLE],[wd,Y.FLOOR],[Pd,Y.FLOOR_MATH],[Ld,Y.FLOOR_PRECISE],[xd,Y.GCD],[jd,Y.INT],[Ud,Y.LCM],[vd,Y.LN],[Td,Y.LOG],[Bd,Y.LOG10],[Id,Y.MDETERM],[Fd,Y.MINVERSE],[kd,Y.MMULT],[$d,Y.MOD],[Yd,Y.MROUND],[Hd,Y.MULTINOMIAL],[Gd,Y.MUNIT],[Wd,Y.ODD],[Qd,Y.PI],[qd,Y.POWER],[Xd,Y.PRODUCT],[Kd,Y.QUOTIENT],[Zd,Y.RADIANS],[zd,Y.RAND],[Jd,Y.RANDARRAY],[eC,Y.RANDBETWEEN],[tC,Y.ROMAN],[rC,Y.ROUND],[nC,Y.ROUNDDOWN],[sC,Y.ROUNDUP],[aC,Y.SEC],[iC,Y.SECH],[uC,Y.SERIESSUM],[oC,Y.SEQUENCE],[cC,Y.SIGN],[lC,Y.SIN],[fC,Y.SINH],[mC,Y.SQRT],[hC,Y.SQRTPI],[gC,Y.SUBTOTAL],[dC,Y.SUM],[CC,Y.SUMIF],[_C,Y.SUMIFS],[AC,Y.SUMPRODUCT],[EC,Y.SUMSQ],[bC,Y.SUMX2MY2],[yC,Y.SUMX2PY2],[RC,Y.SUMXMY2],[pC,Y.TAN],[NC,Y.TANH],[VC,Y.TRUNC]];class OC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"_compareType",$.EQUALS)}setCompareType(e){this._compareType=e}calculate(e,t){return e.isError()?e:t.isError()?t:e.compare(t,this._compareType)}}class sa extends ht{constructor(e){super("");A(this,"_values",[]);this._values=e}static create(e){return new sa(e)}isCube(){return!0}dispose(){this._values.forEach(e=>{e.dispose()}),this._values=[]}sum(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.sum())}),e}max(){let e=y.create(Number.NEGATIVE_INFINITY);return this._values.forEach(t=>{const r=t.max();e.isLessThan(r)&&(e=r)}),e}min(){let e=y.create(Number.POSITIVE_INFINITY);return this._values.forEach(t=>{const r=t.max();e.isGreaterThan(r)&&(e=r)}),e}count(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.count())}),e}countA(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.countA())}),e}countBlank(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.countBlank())}),e}}class MC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isError())return n;if(!n.isArray())return g.create(h.VALUE);t.push(n)}return sa.create(t)}}class SC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:!t.isArray()&&t.getValue()===0?g.create(h.DIV_BY_ZERO):e.divided(t)}}class DC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.minus(t)}}class wC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.multiply(t)}}class PC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.plus(t)}}const lu=[[OC,Le.COMPARE],[SC,Le.DIVIDED],[DC,Le.MINUS],[wC,Le.MULTIPLY],[PC,Le.PLUS],[MC,Le.CUBE]];class LC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let a=0;a<e.length;a++){let u=e[a];if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(u.isArray()){if(u=xC(u),u.isError())return u;if(e[a]=u,t=t.plus(u.sum()),t.isError())return t;r=r.plus(u.count())}else u.isNull()||(t=t.plus(u),r=r.plus(y.create(1)))}if(r.getValue()===0)return g.create(h.NUM);const n=t.divided(r);if(n.isError())return n;let s=y.create(0);for(let a=0;a<e.length;a++){let u=e[a];if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(u.isArray()){if(s=s.plus(u.minus(n).abs().sum()),s.isError())return s}else u.isNull()||(s=s.plus(u.minus(n).abs()))}return s.divided(r)}}function xC(i){const o=[];o[0]=[];let e=null;return i.iterator((t,r,n)=>{if(t!=null&&t.isError())return e=t,!1;t!=null&&t.isNumber()&&o[0].push(t)}),e||Ht(o,1,o[0].length)}class jC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let n=0;n<e.length;n++){let s=e[n];if((s.isString()||s.isBoolean())&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()){if(t=t.plus(s.sum()),t.isError())return t;r=r.plus(s.count())}else s.isNull()||(t=t.plus(s),r=r.plus(y.create(1)))}return t.divided(r)}}class UC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let n=0;n<e.length;n++){let s=e[n];if((s.isString()||s.isBoolean())&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a==null||a.isNull())return!0;let u=a;if(u.isString()&&(u=u.convertToNumberObjectValue(),u.isError()&&(u=y.create(0))),u.isBoolean()&&(u=u.convertToNumberObjectValue()),u.isError())return t=u,!1;t=t.plus(u),r=r.plus(y.create(1))}),t.isError())return t}else s.isNull()||(t=t.plus(s),r=r.plus(y.create(1)))}return t.divided(r)}}class vC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject()),n.isArray()||(n=Ht([[n]],1,1));let s=t;return s.isReferenceObject()&&(s=s.toArrayValueObject()),r&&!(r!=null&&r.isReferenceObject())?g.create(h.NA):(s=s,s.isArray()?s.map(a=>this._handleSingleObject(n,a,r)):this._handleSingleObject(n,s,r))}_handleSingleObject(e,t,r){let n=jn(e,t);const[,s]=mr(`${t.getValue()}`);n=Un(n,e,s);let a=r?this._createRangeReferenceObject(r,e):e;if(!a)return g.create(h.VALUE);if(a.isError())return a;a.isReferenceObject()&&(a=a.toArrayValueObject()),a=a;const u=a.pick(n),c=u.sum(),l=u.count();return c.divided(l)}_createRangeReferenceObject(e,t){const r=e.getRowCount(),n=e.getColumnCount(),s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;if(r===s&&n===a)return e;const{startRow:u,startColumn:c}=e.getRangePosition(),l={startRow:u,startColumn:c,endRow:u+s-1,endColumn:c+a-1};return this.createReferenceObject(e,l)}}class TC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=hr(t),s=Sr(t,e,r,n);if(s)return s;const a=Dr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a),c=u.sum(),l=u.count();return c.divided(l)})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(n)}}class BC extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=s!=null?s:y.create(0),c=a!=null?a:y.create(1);u.isNull()&&(u=y.create(0)),c.isNull()&&(c=y.create(1));const l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),C=O(l,f,r,g.create(h.NA)),_=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.mapValue((p,V,S)=>{const D=d.get(V,S),w=C.get(V,S),P=_.get(V,S),L=E.get(V,S),T=b.get(V,S);return this._handleSignleObject(p,D,w,P,L,T)});return l===1&&f===1?R.get(0,0):R}_handleSignleObject(e,t,r,n,s,a){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;if(a.isError())return a;const{isError:u,errorObject:c,variants:l}=I(e,t,r,n,s,a);if(u)return c;const[f,m,d,C,_,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+C.getValue(),S=+_.getValue(),D=+E.getValue();if(R<=0||p<=0||b<S||b>D||S===D)return g.create(h.NUM);let w;return V?w=to((b-S)/(D-S),R,p):w=Em((b-S)/(D-S),R,p)/(D-S),y.create(w)}}class IC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){let s=n!=null?n:r;s.isNull()&&(s=r);const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,s,g.create(h.NA)),d=c.mapValue((C,_,E)=>{const b=l.get(_,E),R=f.get(_,E),p=m.get(_,E);return C.isError()?C:b.isError()?b:R.isError()?R:p.isError()?p:this._handleSignleObject(C,b,R,p)});return a===1&&u===1?d.get(0,0):d}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),C=+l.getValue(),_=Math.floor(+f.getValue()),E=Math.floor(+m.getValue());if(d<0||C<0||C>1||_<0||_>d||E<0||E<_||E>d)return g.create(h.NUM);let b=0;for(let R=_;R<=E;R++)b+=Ws(R,d,C);return y.create(b)}}class FC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=+l.getValue();if(f<0||m<1||m>10**10)return g.create(h.NUM);let C;return d?C=Qs(f,m):C=bm(f,m),y.create(C)}}class kC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=no(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class $C extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);if(f.isError())return f;if(C.isError())return C;if(_.isError())return _;const{isError:E,errorObject:b,variants:R}=I(f,C,_);if(E)return b;const[p,V,S]=R,D=+p.getValue(),w=+V.getValue(),P=Math.floor(+S.getValue());if(D<=0||D>=1||w<=0||P<1)return g.create(h.NUM);if(P===1)return g.create(h.DIV_BY_ZERO);const L=Math.abs(zs(D/2,P-1)*w/Math.sqrt(P));return y.create(L)});return n===1&&s===1?l.get(0,0):l}}class YC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++){const C=e[d]-a,_=t[d]-u;c+=C*_,l+=C**2,f+=_**2}const m=Math.sqrt(l*f);return m===0?g.create(h.DIV_BY_ZERO):y.create(c/m)}}class HC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){const n=e[r];n.isError()||(n.isArray()?t=t.plus(n.count()):n.isString()?n.convertToNumberObjectValue().isError()||(t=t.plus(y.create(1))):n.isNull()||(t=t.plus(y.create(1))))}return t}}class GC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){let n=e[r];if(n.isError()){t=t.plus(y.create(1));continue}n.isArray()?(n=n.countA(),t=t.plus(n)):n.isNull()||(t=t.plus(y.create(1)))}return t}}class WC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.getValue()===""||e.isNull()?y.create(1):e.isArray()?e.countBlank():y.create(0)}}class QC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()||t.isError()?g.create(h.NA):e.isArray()?t.isArray()?t.mapValue(r=>this._handleSingleObject(e,r)):this._handleSingleObject(e,t):g.create(h.VALUE)}_handleSingleObject(e,t){let r=jn(e,t);const[,n]=mr(`${t.getValue()}`);r=Un(r,e,n);const s=e.pick(r);return this._countA(s)}_countA(e){let t=y.create(0);return e.iterator(r=>{if(r==null)return!0;t=t.plusBy(1)}),t}}class qC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(...e){if(e.length%2!==0||e.some((a,u)=>u%2===0&&!a.isArray()))return g.create(h.VALUE);const{maxRowLength:t,maxColumnLength:r}=hr(e),n=Sr(e,e[0],t,r);if(n)return n;const s=Dr(e,t,r,!0);return this._aggregateResults(s)}_aggregateResults(e){const t=e.map(n=>n.map(s=>XC(s))),r={calculateValueList:t,rowCount:t.length,columnCount:t[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(r)}}function XC(i){let o=0;return i.iterator(e=>{e!=null&&e.isBoolean()&&e.getValue()===!0&&o++}),y.create(o)}class KC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length<=1)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let l=0;l<r;l++)n+=e[l],s+=t[l];const a=n/r,u=s/r;let c=0;for(let l=0;l<r;l++){const f=e[l]-a,m=t[l]-u;c+=f*m}return y.create(c/(r-1))}}class ZC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0,n=!0;for(let u=0;u<e.length;u++){const c=e[u];if(c.isArray()){let l=!1,f=g.create(h.VALUE);if(c.iterator(m=>{const d=this._handleSingleObject(m);if(d.isError())return l=!0,f=d,!1;if(d.isNull())return!0;const C=d.getValue();t.push(C),r+=C,n=!1}),l)return f}else{const l=this._handleSingleObject(c);if(l.isError())return l;if(l.isNull())continue;const f=l.getValue();t.push(f),r+=f,n=!1}}if(n)return g.create(h.NUM);const s=r/t.length;let a=0;for(let u=0;u<t.length;u++)a+=(t[u]-s)**2;return y.create(a)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull()||e.isBoolean())return ae.create();const t=e.getValue();return M.isRealNum(t)?y.create(+t):ae.create()}}class zC extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=Math.floor(+l.getValue()),_=Math.floor(+f.getValue()),E=+m.getValue();if(d<0||C<1||C>10**10||_<1||_>10**10)return g.create(h.NUM);let b;return E?b=qs(d,C,_):b=ym(d,C,_),Number.isNaN(b)||!Number.isFinite(b)?g.create(h.NUM):y.create(b)}}class JC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||f>1||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const C=so(f,m,d);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class e_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=s.getValue();if(a<=-1||a>=1)return g.create(h.NUM);const u=Math.log((1+a)/(1-a))/2;return y.create(u)}}class t_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.exp(2*a)-1,c=Math.exp(2*a)+1;return!Number.isFinite(u)&&u>0&&!Number.isFinite(c)&&c>0?y.create(1):y.create(u/c)}}class Qa extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=t.isArray()?t.getRowCount():1,s=t.isArray()?t.getColumnCount():1,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;let c=t;t.isArray()&&n===1&&s===1&&(c=t.get(0,0));let l=r;return r.isArray()&&a===1&&u===1&&(l=r.get(0,0)),e.isArray()?e.mapValue(f=>this._handleSignleObject(f,c,l,n,s,a,u)):this._handleSignleObject(e,c,l,n,s,a,u)}_handleSignleObject(e,t,r,n,s,a,u){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;let c=e;if(e.isString()&&(c=e.convertToNumberObjectValue()),c.isError())return c;const l=+c.getValue();if((n*s===1||a*u===1)&&(t.isNull()||r.isNull()))return g.create(h.VALUE);if(n*s!==a*u)return g.create(h.NA);const{isError:f,errorObject:m,array1Values:d,array2Values:C,noCalculate:_}=Ge(t,r,n*s,s,u);if(f)return m;if(_)return g.create(h.DIV_BY_ZERO);const E=ao(l,d,C);return Number.isFinite(E)?y.create(E):g.create(h.DIV_BY_ZERO)}}class r_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,values:s}=this._getValues(e);if(r)return n;if(e.isNull()||t.isNull())return g.create(h.VALUE);let{values:a}=this._getValues(t,!0);a.length===0&&(a=[0]);const u=this._getNewBinsArrayValues(a),c=new Array(u.length).fill(0);for(let l=0;l<s.length;l++){const f=s[l],m=u.findIndex(d=>f>d.start&&f<=d.end);c[m]++}return K.createByArray(c.map(l=>[l]))}_getValues(e,t=!1){const r=[],n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;for(let a=0;a<n;a++)for(let u=0;u<s;u++){const c=e.isArray()?e.get(a,u):e;if(c.isError()){if(!t)return{isError:!0,errorObject:c,values:r};continue}if(c.isNull()||c.isBoolean())continue;const l=c.getValue();M.isRealNum(l)&&r.push(+l)}return{isError:!1,errorObject:null,values:r}}_getNewBinsArrayValues(e){const t=e.map((n,s)=>({value:n,index:s})).sort((n,s)=>n.value-s.value),r=[];for(let n=0;n<t.length;n++){const s=t[n].index;if(n===0){r[s]={start:-1/0,end:t[n].value};continue}r[s]={start:t[n-1].value,end:t[n].value}}return r.push({start:t[t.length-1].value,end:1/0}),r}}var U=(i=>(i.AVEDEV="AVEDEV",i.AVERAGE="AVERAGE",i.AVERAGEA="AVERAGEA",i.AVERAGEIF="AVERAGEIF",i.AVERAGEIFS="AVERAGEIFS",i.BETA_DIST="BETA.DIST",i.BETA_INV="BETA.INV",i.BINOM_DIST="BINOM.DIST",i.BINOM_DIST_RANGE="BINOM.DIST.RANGE",i.BINOM_INV="BINOM.INV",i.CHISQ_DIST="CHISQ.DIST",i.CHISQ_DIST_RT="CHISQ.DIST.RT",i.CHISQ_INV="CHISQ.INV",i.CHISQ_INV_RT="CHISQ.INV.RT",i.CHISQ_TEST="CHISQ.TEST",i.CONFIDENCE_NORM="CONFIDENCE.NORM",i.CONFIDENCE_T="CONFIDENCE.T",i.CORREL="CORREL",i.COUNT="COUNT",i.COUNTA="COUNTA",i.COUNTBLANK="COUNTBLANK",i.COUNTIF="COUNTIF",i.COUNTIFS="COUNTIFS",i.COVARIANCE_P="COVARIANCE.P",i.COVARIANCE_S="COVARIANCE.S",i.DEVSQ="DEVSQ",i.EXPON_DIST="EXPON.DIST",i.F_DIST="F.DIST",i.F_DIST_RT="F.DIST.RT",i.F_INV="F.INV",i.F_INV_RT="F.INV.RT",i.F_TEST="F.TEST",i.FISHER="FISHER",i.FISHERINV="FISHERINV",i.FORECAST="FORECAST",i.FORECAST_ETS="FORECAST.ETS",i.FORECAST_ETS_CONFINT="FORECAST.ETS.CONFINT",i.FORECAST_ETS_SEASONALITY="FORECAST.ETS.SEASONALITY",i.FORECAST_ETS_STAT="FORECAST.ETS.STAT",i.FORECAST_LINEAR="FORECAST.LINEAR",i.FREQUENCY="FREQUENCY",i.GAMMA="GAMMA",i.GAMMA_DIST="GAMMA.DIST",i.GAMMA_INV="GAMMA.INV",i.GAMMALN="GAMMALN",i.GAMMALN_PRECISE="GAMMALN.PRECISE",i.GAUSS="GAUSS",i.GEOMEAN="GEOMEAN",i.GROWTH="GROWTH",i.HARMEAN="HARMEAN",i.HYPGEOM_DIST="HYPGEOM.DIST",i.INTERCEPT="INTERCEPT",i.KURT="KURT",i.LARGE="LARGE",i.LINEST="LINEST",i.LOGEST="LOGEST",i.LOGNORM_DIST="LOGNORM.DIST",i.LOGNORM_INV="LOGNORM.INV",i.MAX="MAX",i.MAXA="MAXA",i.MAXIFS="MAXIFS",i.MEDIAN="MEDIAN",i.MIN="MIN",i.MINA="MINA",i.MINIFS="MINIFS",i.MODE_MULT="MODE.MULT",i.MODE_SNGL="MODE.SNGL",i.NEGBINOM_DIST="NEGBINOM.DIST",i.NORM_DIST="NORM.DIST",i.NORM_INV="NORM.INV",i.NORM_S_DIST="NORM.S.DIST",i.NORM_S_INV="NORM.S.INV",i.PEARSON="PEARSON",i.PERCENTILE_EXC="PERCENTILE.EXC",i.PERCENTILE_INC="PERCENTILE.INC",i.PERCENTRANK_EXC="PERCENTRANK.EXC",i.PERCENTRANK_INC="PERCENTRANK.INC",i.PERMUT="PERMUT",i.PERMUTATIONA="PERMUTATIONA",i.PHI="PHI",i.POISSON_DIST="POISSON.DIST",i.PROB="PROB",i.QUARTILE_EXC="QUARTILE.EXC",i.QUARTILE_INC="QUARTILE.INC",i.RANK_AVG="RANK.AVG",i.RANK_EQ="RANK.EQ",i.RSQ="RSQ",i.SKEW="SKEW",i.SKEW_P="SKEW.P",i.SLOPE="SLOPE",i.SMALL="SMALL",i.STANDARDIZE="STANDARDIZE",i.STDEV_P="STDEV.P",i.STDEV_S="STDEV.S",i.STDEVA="STDEVA",i.STDEVPA="STDEVPA",i.STEYX="STEYX",i.T_DIST="T.DIST",i.T_DIST_2T="T.DIST.2T",i.T_DIST_RT="T.DIST.RT",i.T_INV="T.INV",i.T_INV_2T="T.INV.2T",i.T_TEST="T.TEST",i.TREND="TREND",i.TRIMMEAN="TRIMMEAN",i.VAR_P="VAR.P",i.VAR_S="VAR.S",i.VARA="VARA",i.VARPA="VARPA",i.WEIBULL_DIST="WEIBULL.DIST",i.Z_TEST="Z.TEST",i))(U||{});class n_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue();if(a===0||a<0&&a%1===0)return g.create(h.NUM);const u=Qr(a);return Number.isNaN(u)||!Number.isFinite(u)?g.create(h.NUM):y.create(u)}}class qa extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue();if(a<=0)return g.create(h.NUM);const u=rt(a);return Math.abs(u)<1e-15?y.create(0):y.create(u)}}class s_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Pr(a,0,1)-.5;return y.create(u)}}class a_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=1,r=0,n=!1;for(let a=0;a<e.length;a++){const u=e[a];if(u.isArray()){let c=!1,l=g.create(h.VALUE);if(u.iterator(f=>{if(f!=null&&f.isError())return c=!0,l=f,!1;if(f!=null&&f.isNull()||f!=null&&f.isBoolean())return!0;const m=f.getValue();if(!M.isRealNum(m))return!0;+m<=0&&(n=!0),t*=+m,r++}),c)return l}else{if(u.isError())return u;if(u.isString()){const l=u.convertToNumberObjectValue();if(l.isError())return l}if(u.isNull()||u.isBoolean())continue;const c=u.getValue();if(!M.isRealNum(c))continue;+c<=0&&(n=!0),t*=+c,r++}}if(r===0||n)return g.create(h.NUM);const s=t**(1/r);return y.create(s)}}class i_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=this._getValues(e,s,a);if(u instanceof g)return u;const c=this._getKnownXsValues(s,a,t);if(c instanceof g)return c;const l=this._getNewXsValues(c,s,a,r);if(l instanceof g)return l;let f=n!=null?n:k.create(!0);if(f.isArray()&&(f=f.get(0,0)),f.isString()&&(f=f.convertToNumberObjectValue()),f.isError())return f;const m=+f.getValue();return this._getResult(u,c,l,m)}_getResult(e,t,r,n){return e.length===1&&t.length>1||e[0].length===1&&t[0].length>1?this._getResultByMultipleVariables(e,t,r,n):this._getResultBySimpleVariables(e,t,r,n)}_getResultByMultipleVariables(e,t,r,n){const s=e.length===1&&e[0].length>1;let a=[],u=[];s?(a=yt(e).map(_=>_.map(E=>Math.log(E))),u=n?yt(t).map(_=>[..._,1]):yt(t)):(a=e.map(_=>_.map(E=>Math.log(E))),u=n?t.map(_=>[..._,1]):t);const c=yt(u),l=tr(c,u),f=tr(c,a),m=dm(l);if(!m)return g.create(h.NA);const d=tr(m,f).map(_=>_[0]);let C=[];return s?(C=yt(r).map(_=>{const b=(n?[..._,1]:_).reduce((R,p,V)=>R+p*d[V],0);return[Math.exp(b)]}),C=yt(C)):C=r.map(_=>{const b=(n?[..._,1]:_).reduce((R,p,V)=>R+p*d[V],0);return[Math.exp(b)]}),K.createByArray(C)}_getResultBySimpleVariables(e,t,r,n){const s=r.length,a=r[0].length,u=e.flat(),c=t.flat(),l=r.flat(),f=u.map(_=>Math.log(_));let m,d;n?{slope:m,intercept:d}=this._getSlopeAndInterceptOfConstbIsTrue(c,f):{slope:m,intercept:d}=this._getSlopeAndInterceptOfConstbIsFalse(c,f),Number.isNaN(m)&&!n&&(m=0);const C=[];for(let _=0;_<s;_++){const E=[];for(let b=0;b<a;b++){const R=d*m**l[_*a+b];E.push(R)}C.push(E)}return K.createByArray(C)}_getSlopeAndInterceptOfConstbIsTrue(e,t){const r=t.length;let n=0,s=0,a=0,u=0;for(let m=0;m<r;m++)n+=e[m],s+=t[m],a+=e[m]*e[m],u+=e[m]*t[m];const l=(r*u-n*s)/(r*a-n*n),f=1/r*s-l*(1/r)*n;return{slope:Math.exp(l),intercept:Math.exp(f)}}_getSlopeAndInterceptOfConstbIsFalse(e,t){const r=[[...e]],n=[...t];let s=r.length,a=r[0].length,u=Math.min(s,a);const c=new Array(u).fill(0);for(let f=0;f<u;f++){const m=r[f];let d=0;for(let _=0;_<a;_++)d+=m[_]**2;const C=m[f]<0?Math.sqrt(d):-Math.sqrt(d);if(c[f]=C,C!==0){m[f]-=C;for(let _=f+1;_<s;_++){let E=0;for(let b=f;b<a;b++)E-=r[_][b]*m[b];E/=C*m[f];for(let b=f;b<a;b++)r[_][b]-=E*m[b]}}}s=r.length,a=r[0].length,u=Math.min(s,a);const l=new Array(s).fill(0);for(let f=0;f<u;f++){const m=r[f];let d=0;for(let C=0;C<a;C++)d+=n[C]*m[C];d/=c[f]*m[f];for(let C=0;C<a;C++)n[C]+=d*m[C]}for(let f=c.length-1;f>=0;f--){n[f]/=c[f];const m=n[f],d=r[f];l[f]=m;for(let C=0;C<f;C++)n[C]-=m*d[C]}return{slope:Math.exp(l[0]),intercept:Math.exp(0)}}_getKnownXsValues(e,t,r){if(!r||r.isNull())return this._getNumberValuesByRowsColumns(e,t);if(r.isError())return r;const n=r.isArray()?r.getRowCount():1,s=r.isArray()?r.getColumnCount():1;return e===1&&s!==t||t===1&&n!==e||e!==1&&t!==1&&(n!==e||s!==t)?g.create(h.REF):this._getValues(r,n,s)}_getNewXsValues(e,t,r,n){if(!n||n.isNull())return e;if(n.isError())return n;const s=n.isArray()?n.getRowCount():1,a=n.isArray()?n.getColumnCount():1;return t===1&&e.length>1&&s!==e.length||r===1&&e[0].length>1&&a!==e[0].length?g.create(h.REF):this._getValues(n,s,a)}_getValues(e,t,r){const n=[];for(let s=0;s<t;s++){n[s]=[];for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())return g.create(h.VALUE);const c=u.getValue();if(!M.isRealNum(c))return g.create(h.VALUE);n[s].push(+c)}}return n}_getNumberValuesByRowsColumns(e,t){const r=[];let n=1;for(let s=0;s<e;s++){r[s]=[];for(let a=0;a<t;a++)r[s].push(n++)}return r}}class o_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=0,n=!1;for(let a=0;a<e.length;a++){const u=e[a];if(u.isArray()){let c=!1,l=g.create(h.VALUE);if(u.iterator(f=>{if(f!=null&&f.isError())return c=!0,l=f,!1;if(f!=null&&f.isNull()||f!=null&&f.isBoolean())return!0;const m=f.getValue();if(!M.isRealNum(m))return!0;+m<=0&&(n=!0),t+=1/+m,r++}),c)return l}else{if(u.isError())return u;if(u.isString()){const l=u.convertToNumberObjectValue();if(l.isError())return l}if(u.isNull()||u.isBoolean())continue;const c=u.getValue();if(!M.isRealNum(c))continue;+c<=0&&(n=!0),t+=1/+c,r++}}if(r===0)return g.create(h.NA);if(n)return g.create(h.NUM);const s=r/t;return y.create(s)}}class u_ extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,n,g.create(h.NA)),d=O(a,u,s,g.create(h.NA)),C=c.mapValue((_,E,b)=>{const R=l.get(E,b),p=f.get(E,b),V=m.get(E,b),S=d.get(E,b);return _.isError()?_:R.isError()?R:p.isError()?p:V.isError()?V:S.isError()?S:this._handleSignleObject(_,R,p,V,S)});return a===1&&u===1?C.get(0,0):C}_handleSignleObject(e,t,r,n,s){const{isError:a,errorObject:u,variants:c}=I(e,t,r,n,s);if(a)return u;const[l,f,m,d,C]=c,_=Math.floor(+l.getValue()),E=Math.floor(+f.getValue()),b=Math.floor(+m.getValue()),R=Math.floor(+d.getValue()),p=+C.getValue();if(_<0||_>E||_>b||_<E-R+b||E<=0||E>R||b<=0||b>R||R<=0)return g.create(h.NUM);let V;return p?V=Mm(_,E,b,R):V=Ks(_,E,b,R),Number.isNaN(V)&&(V=0),y.create(V)}}class c_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=ao(0,e,t);return Number.isFinite(r)?y.create(r):g.create(h.DIV_BY_ZERO)}}class l_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();M.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=3?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/(r-1));if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**4;const c=r*(r+1)/((r-1)*(r-2)*(r-3))*u-3*(r-1)**2/((r-2)*(r-3));return y.create(c)}}class f_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s;let u=+a.getValue();return u<1||u>e.length?g.create(h.NUM):(u=Math.ceil(u),y.create(e[u-1]))}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>a-s)}}class m_ extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=+l.getValue(),_=+f.getValue(),E=+m.getValue();if(d<=0||_<=0)return g.create(h.NUM);let b;return E?b=oo(d,C,_):b=Sm(d,C,_),y.create(b)}}class h_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.NEGATIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isArray()&&(n=n.max()),n.isError())return n;t=this._validator(t,n)}}return t.getValue()===Number.NEGATIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isLessThan(t);let n=e;return r.getValue()&&(n=t),n}}class g_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.NEGATIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()&&n.iterator(s=>{let a=s;if((a==null||a.isNull()||a.isString())&&(a=y.create(0)),a.isBoolean()&&(a=a.convertToNumberObjectValue()),a.isError())return t=a,!1;t=this._validator(t,a)}),t.isError())return t;t=this._validator(t,n)}}return t.getValue()===Number.NEGATIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isLessThan(t);let n=e;return r.getValue()&&(n=t),n}}class d_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=hr(t),s=Sr(t,e,r,n);if(s)return s;const a=Dr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a);return u.getColumnCount()===0?K.create("0"):u.max()})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(n)}}class C_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{if(u!=null&&u.isError())return s=!0,a=u,!1;if(u!=null&&u.isNull()||u!=null&&u.isBoolean())return!0;const c=u.getValue();if(!M.isRealNum(c))return!0;t.push(+c)}),s)return a}else{if(n.isError())return n;if(n.isNull()||n.isBoolean())continue;if(n.isString()){const a=n.convertToNumberObjectValue();if(a.isError())return a}const s=n.getValue();if(!M.isRealNum(s))continue;t.push(+s)}}return t.length===0?g.create(h.NUM):this._getResult(t.sort((r,n)=>r-n))}_getResult(e){const t=e.length;let r;if(t%2===0){const n=t/2;r=(e[n-1]+e[n])/2}else r=e[Math.floor(t/2)];return y.create(r)}}class __ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.POSITIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isArray()&&(n=n.min()),n.isError())return n;t=this._validator(t,n)}}return t.getValue()===Number.POSITIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isGreaterThan(t);let n=e;return r.getValue()&&(n=t),n}}class A_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.POSITIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()&&n.iterator(s=>{let a=s;if((a==null||a.isNull()||a.isString())&&(a=y.create(0)),a.isBoolean()&&(a=a.convertToNumberObjectValue()),a.isError())return t=a,!1;t=this._validator(t,a)}),t.isError())return t;t=this._validator(t,n)}}return t.getValue()===Number.POSITIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isGreaterThan(t);let n=e;return r.getValue()&&(n=t),n}}class E_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=hr(t),s=Sr(t,e,r,n);if(s)return s;const a=Dr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a);return u.getColumnCount()===0?K.create("0"):u.min()})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(n)}}class b_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t={};let r=0,n=1;for(let s=0;s<e.length;s++){const a=e[s];if(a.isError())return a;if(a.isString()){const l=a.convertToNumberObjectValue();if(l.isError())return l}const u=a.isArray()?a.getRowCount():1,c=a.isArray()?a.getColumnCount():1;for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=a.isArray()?a.get(l,f):a;if(m.isError())return m;if(m.isNull()||m.isBoolean()||m.isString())continue;const d=m.getValue();M.isRealNum(d)&&(t[+d]?(t[+d].count++,t[+d].count>n&&(n=t[+d].count)):t[+d]={count:1,order:r++})}}return r===0||n===1?new g(h.NA):this._getResult(t,n)}_getResult(e,t){const r=Object.entries(e).filter(([n,{count:s}])=>s===t).sort((n,s)=>n[1].order-s[1].order).map(([n])=>+n);return r.length===1?y.create(r[0]):K.createByArray(r.map(n=>[n]))}}class y_ extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),C=Math.floor(+l.getValue()),_=+f.getValue(),E=+m.getValue();if(d<0||C<1||_<=0||_>=1)return g.create(h.NUM);let b;return E?b=wm(d,C,_):b=Zs(d,C,_),y.create(b)}}class R_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=+u.getValue();let f;return l?f=Pr(c,0,1):f=uo(c,0,1),y.create(f)}}class p_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(l===0||f===0)return g.create(h.DIV_BY_ZERO);const m=c/Math.sqrt(l*f);return y.create(m)}}class N_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=+a.getValue(),c=e.length;if(u<1/(c+1)||u>1-1/(c+1))return g.create(h.NUM);const l=u*(c+1)-1,f=Math.floor(l),m=l-f;if(m===0)return y.create(e[f]);const d=e[f]+m*(e[f+1]-e[f]);return y.create(d)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class V_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getValues(e);let s=r!=null?r:y.create(3);s.isNull()&&(s=y.create(3));const a=Math.max(t.isArray()?t.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(t.isArray()?t.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,t,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,C)=>{const _=l.get(d,C);return m.isError()?m:_.isError()?_:this._handleSingleObject(n,m,_)});return a===1&&u===1?f.get(0,0):f}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=I(t,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=Math.floor(+c.getValue()),m=e.length;if(m===0||l<e[0]||l>e[m-1])return g.create(h.NA);if(m===1)return l===e[0]?y.create(1):g.create(h.NA);let d=0,C=!1,_=0;for(;!C&&_<m;)l===e[_]?(d=(_+1)/(m+1),C=!0):l>e[_]&&_+1<m&&l<e[_+1]&&(d=(_+1+(l-e[_])/(e[_+1]-e[_]))/(m+1),C=!0),_++;return C?f<1?g.create(h.NUM):(d=ke(d,f),y.create(d)):g.create(h.NA)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.sort((s,a)=>s-a)}}class O_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const{isError:d,errorObject:C,variants:_}=I(c,m);if(d)return C;const[E,b]=_,R=Math.floor(+E.getValue()),p=Math.floor(+b.getValue());if(R<0||R>=2147483647||p<0||R<p)return g.create(h.NUM);let V=1;for(let S=R-p+1;S<=R;S++)V*=S;return Number.isFinite(V)?y.create(V):g.create(h.NUM)});return r===1&&n===1?u.get(0,0):u}}class M_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const{isError:d,errorObject:C,variants:_}=I(c,m);if(d)return C;const[E,b]=_,R=Math.floor(+E.getValue()),p=Math.floor(+b.getValue());if(R<0||R>=2147483647||p<0)return g.create(h.NUM);if(R===0)return p===0?y.create(1):y.create(0);const V=R**p;return Number.isFinite(V)?y.create(V):g.create(h.NUM)});return r===1&&n===1?u.get(0,0):u}}class S_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.exp(-.5*a*a)/Math.sqrt(2*Math.PI);return y.create(u)}}class D_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a,xRangeValues:u,probRangeValues:c}=this._handleXRangeAndProbRange(e,t);let l=n!=null?n:r;n!=null&&n.isNull()&&(l=r);const f=Math.max(r.isArray()?r.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(r.isArray()?r.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,r,g.create(h.NA)),C=O(f,m,l,g.create(h.NA)),_=d.mapValue((E,b,R)=>{const p=C.get(b,R);return e.isError()?e:t.isError()?t:E.isError()?E:p.isError()?p:s?a:this._handleSignleObject(u,c,E,p)});return f===1&&m===1?_.get(0,0):_}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(r,n);if(s)return a;const[c,l]=u,f=+c.getValue(),m=+l.getValue();if(t.reduce((C,_)=>C+_,0)!==1)return g.create(h.NUM);let d=0;for(let C=0;C<e.length;C++)e[C]>=f&&e[C]<=m&&(d+=t[C]);return y.create(d)}_handleXRangeAndProbRange(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return{isError:!0,errorObject:u,xRangeValues:[],probRangeValues:[]};let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return{isError:!0,errorObject:c,xRangeValues:[],probRangeValues:[]};if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return{isError:!0,errorObject:g.create(h.VALUE),xRangeValues:[],probRangeValues:[]};if(r*n!==s*a)return{isError:!0,errorObject:g.create(h.NA),xRangeValues:[],probRangeValues:[]};const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?{isError:!0,errorObject:f,xRangeValues:[],probRangeValues:[]}:C?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),xRangeValues:[],probRangeValues:[]}:{isError:!1,errorObject:null,xRangeValues:m,probRangeValues:d}}}class w_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<=0||u>=4)return g.create(h.NUM);const c=u/4,l=e.length;if(c<1/(l+1)||c>1-1/(l+1))return g.create(h.NUM);const f=c*(l+1)-1,m=Math.floor(f),d=f-m;if(d===0)return y.create(e[m]);const C=e[m]+d*(e[m+1]-e[m]);return y.create(C)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class P_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),C=m.map((_,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+_.getValue(),V=+R.getValue();return Number.isNaN(p)||Number.isNaN(V)?g.create(h.VALUE):this._getResult(p,V,u)});return l===1&&f===1?C.get(0,0):C}_getResult(e,t,r){const n=r.sort((c,l)=>t?c-l:l-c);let s=n.indexOf(e);const a=[];for(;s>=0;){const c=s+1;a.push(c),s=n.indexOf(e,c)}if(a.length===0)return g.create(h.NA);const u=a.reduce((c,l)=>c+l,0)/a.length;return y.create(u)}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class L_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),C=m.map((_,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+_.getValue(),V=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);const D=u.sort((w,P)=>V?w-P:P-w).indexOf(p);return D===-1?g.create(h.NA):y.create(D+1)});return l===1&&f===1?C.get(0,0):C}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class x_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length===0)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(l===0||f===0)return g.create(h.DIV_BY_ZERO);const m=(c/Math.sqrt(l*f))**2;return y.create(m)}}class j_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();M.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=2?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/(r-1));if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**3;const c=r/((r-1)*(r-2))*u;return y.create(c)}}class U_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();M.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=2?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/r);if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**3;const c=u/r;return y.create(c)}}class v_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let m=0;m<r;m++)n+=e[m],s+=t[m];const a=n/r,u=s/r;let c=0,l=0;for(let m=0;m<r;m++)c+=(e[m]-a)*(t[m]-u),l+=(t[m]-u)**2;if(l===0)return g.create(h.DIV_BY_ZERO);const f=c/l;return y.create(f)}}class T_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s;let u=+a.getValue();return u<1||u>e.length?g.create(h.NUM):(u=Math.floor(u),y.create(e[u-1]))}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class B_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(d<=0)return g.create(h.NUM);const C=(f-m)/d;return y.create(C)}}class I_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.std(1)}}class F_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.std()}}class k_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;if(r<=2)return g.create(h.DIV_BY_ZERO);let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(f===0)return g.create(h.DIV_BY_ZERO);const m=Math.sqrt((l-c**2/f)/(r-2));return Number.isNaN(m)||!Number.isFinite(m)?g.create(h.NUM):y.create(m)}}class $_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=+l.getValue();if(m<1)return g.create(h.NUM);let C;return d?C=Lr(f,m):C=Lm(f,m),Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class Y_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||l<1||l>10**10)return g.create(h.NUM);const f=Lr(-c,l)*2;return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class H_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(l<1||l>10**10)return g.create(h.NUM);const f=Lr(-c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class G_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<=0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=zs(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class W_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=+a.getValue();if(u<0||u>=1)return g.create(h.NUM);const c=ke(e.length*u/2,0)*2,l=e.slice(c/2,e.length-c/2),f=l.reduce((m,d)=>m+d,0)/l.length;return y.create(f)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class Q_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.var(1)}}class q_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.var()}}const fu=[[LC,U.AVEDEV],[jC,U.AVERAGE],[UC,U.AVERAGEA],[vC,U.AVERAGEIF],[TC,U.AVERAGEIFS],[BC,U.BETA_DIST],[lo,U.BETA_INV],[fo,U.BINOM_DIST],[IC,U.BINOM_DIST_RANGE],[mo,U.BINOM_INV],[FC,U.CHISQ_DIST],[ho,U.CHISQ_DIST_RT],[kC,U.CHISQ_INV],[go,U.CHISQ_INV_RT],[Co,U.CHISQ_TEST],[_o,U.CONFIDENCE_NORM],[$C,U.CONFIDENCE_T],[YC,U.CORREL],[HC,U.COUNT],[GC,U.COUNTA],[WC,U.COUNTBLANK],[QC,U.COUNTIF],[qC,U.COUNTIFS],[Ao,U.COVARIANCE_P],[KC,U.COVARIANCE_S],[ZC,U.DEVSQ],[Eo,U.EXPON_DIST],[zC,U.F_DIST],[bo,U.F_DIST_RT],[JC,U.F_INV],[yo,U.F_INV_RT],[Ro,U.F_TEST],[e_,U.FISHER],[t_,U.FISHERINV],[Qa,U.FORECAST],[Qa,U.FORECAST_LINEAR],[r_,U.FREQUENCY],[n_,U.GAMMA],[po,U.GAMMA_DIST],[No,U.GAMMA_INV],[qa,U.GAMMALN],[qa,U.GAMMALN_PRECISE],[s_,U.GAUSS],[a_,U.GEOMEAN],[i_,U.GROWTH],[o_,U.HARMEAN],[u_,U.HYPGEOM_DIST],[c_,U.INTERCEPT],[l_,U.KURT],[f_,U.LARGE],[m_,U.LOGNORM_DIST],[Vo,U.LOGNORM_INV],[h_,U.MAX],[g_,U.MAXA],[d_,U.MAXIFS],[C_,U.MEDIAN],[__,U.MIN],[A_,U.MINA],[E_,U.MINIFS],[b_,U.MODE_MULT],[Oo,U.MODE_SNGL],[y_,U.NEGBINOM_DIST],[Mo,U.NORM_DIST],[So,U.NORM_INV],[R_,U.NORM_S_DIST],[Do,U.NORM_S_INV],[p_,U.PEARSON],[N_,U.PERCENTILE_EXC],[wo,U.PERCENTILE_INC],[V_,U.PERCENTRANK_EXC],[Po,U.PERCENTRANK_INC],[O_,U.PERMUT],[M_,U.PERMUTATIONA],[S_,U.PHI],[Lo,U.POISSON_DIST],[D_,U.PROB],[w_,U.QUARTILE_EXC],[xo,U.QUARTILE_INC],[P_,U.RANK_AVG],[L_,U.RANK_EQ],[x_,U.RSQ],[j_,U.SKEW],[U_,U.SKEW_P],[v_,U.SLOPE],[T_,U.SMALL],[B_,U.STANDARDIZE],[jo,U.STDEV_P],[Uo,U.STDEV_S],[I_,U.STDEVA],[F_,U.STDEVPA],[k_,U.STEYX],[$_,U.T_DIST],[Y_,U.T_DIST_2T],[H_,U.T_DIST_RT],[G_,U.T_INV],[vo,U.T_INV_2T],[To,U.T_TEST],[W_,U.TRIMMEAN],[Bo,U.VAR_P],[Io,U.VAR_S],[Q_,U.VARA],[q_,U.VARPA],[Fo,U.WEIBULL_DIST],[ko,U.Z_TEST]];class X_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r=t!=null?t:y.create(0);if(t!=null&&t.isNull()&&(r=y.create(0)),r.isArray()){const n=r.mapValue(s=>this._handleSingleObject(e,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(e,r)}_handleSingleObject(e,t){const r=this._checkArray(e);if(r.isError())return r;const{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=+u.getValue(),l=e.isArray()?e.getRowCount():1,f=e.isArray()?e.getColumnCount():1;let m="";for(let d=0;d<l;d++)for(let C=0;C<f;C++){const _=e.isArray()?e.get(d,C):e;let E=`${_.getValue()}`;_.isNull()&&(E=""),_.isBoolean()&&(E=E.toLocaleUpperCase()),_.isString()&&c?m+=`"${E}"`:m+=E,d===l-1&&C===f-1||(c?C===f-1?m+=";":m+=",":m+=", ")}return c&&(m=`{${m}}`),m.length>32767?g.create(h.CALC):j.create(m)}_checkArray(e){if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount();return t>1||r>1?e:e.get(0,0)}return e}}class K_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isNull()||e.isBoolean()||e.isNumber())return e;const t=e.getValue().toLocaleString();let r="";for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);s===12288?s=32:s>=65281&&s<=65374&&(s-=65248),r+=String.fromCharCode(s)}return j.create(r)}}class Z_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.abs(Number.parseInt(a.toString(),10)),c=Number.parseFloat((Math.abs(a)-u).toFixed(2));let l="";return u===0?c!==0?l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(c*100)}สตางค์`:l="ศูนย์บาทถ้วน":c===0?l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(u)}บาทถ้วน`:l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(u)}บาท${this._convertNumberToThaiText(c*100)}สตางค์`,j.create(l)}_convertNumberToThaiText(e){const t=["ล้าน","สิบ","ร้อย","พัน","หมื่น","แสน",""],r=["ศูนย์","หนึ่ง","สอง","สาม","สี่","ห้า","หก","เจ็ด","แปด","เก้า"],n=["ลบ","บาท","ถ้วน","สตางค์","ยี่","เอ็ด",","," ","฿"],s=e.toString(),a=s.length;let u="";for(let c=a;c>0;c--){const l=Number.parseInt(s.charAt(a-c),10);let f=r[l];const m=c>1?(c-1)%6:6;if(m===1&&l===2&&(f=n[4]),l===1)switch(m){case 0:case 6:u+=c<a?n[5]:f;break;case 1:break;default:u+=f;break}else if(l===0){m===0&&(u+=t[m]);continue}else u+=f;u+=t[m]}return u}}const z_=Object.values(M.DataStreamTreeTokenType).filter(i=>[M.DataStreamTreeTokenType.TABLE_START,M.DataStreamTreeTokenType.TABLE_ROW_START,M.DataStreamTreeTokenType.TABLE_CELL_START,M.DataStreamTreeTokenType.TABLE_CELL_END,M.DataStreamTreeTokenType.TABLE_ROW_END,M.DataStreamTreeTokenType.TABLE_END,M.DataStreamTreeTokenType.CUSTOM_BLOCK].includes(i));class J_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=Math.floor(+s.getValue());if(a<=0)return g.create(h.VALUE);let u=String.fromCharCode(a);return z_.some(c=>c===u)&&(u=""),j.create(u)}}class eA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isBoolean()||e.isNumber())return e;if(e.isNull())return j.create("");const r=`${e.getValue()}`.replace(/[\0-\x1F]/g,"");return j.create(r)}}class tA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);let t=e.getValue().toLocaleString();if(e.isBoolean()&&(t=t.toLocaleUpperCase()),t==="")return g.create(h.VALUE);const r=t.charCodeAt(0);return y.create(r)}}class rA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="",r=null;for(const n of e)if(n.isArray()){if(n.iterator(s=>{if(s==null||s.isNull())return!0;if(s.isError())return r=s,!1;s.isBoolean()?t+=`${s.getValue()}`.toLocaleUpperCase():(s.isString()||s.isNumber())&&(t+=s.getValue())}),r)return r}else!n.isError()&&!n.isNull()&&(t+=n.getValue());return j.create(t)}}class nA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=0;e.forEach(s=>{if(s.isArray()){const a=s;t=Math.max(t,a.getRowCount()),r=Math.max(r,a.getColumnCount())}else t=Math.max(t,1),r=Math.max(r,1)});let n=null;for(const s of e)n=O(t,r,s,g.create(h.NA)).mapValue((u,c,l)=>{const f=n&&n.get(c,l);if(f!=null&&f.isError())return f;if(u.isError())return u;let m=f==null?void 0:f.getValue(),d=u==null?void 0:u.getValue();f!=null&&f.isBoolean()&&(m=`${m}`.toLocaleUpperCase()),u!=null&&u.isBoolean()&&(d=`${d}`.toLocaleUpperCase());const C=f!=null&&f.isNull()?"":m!=null?m:"",_=u!=null&&u.isNull()?"":d!=null?d:"";return j.create(`${C}${_}`)});return n||g.create(h.VALUE)}}class sA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return j.create("");let t=`${e.getValue()}`;e.isBoolean()&&(t=t.toLocaleUpperCase());let r="";for(let n=0;n<t.length;n++){const s=t.charCodeAt(n);s>=33&&s<=126?r+=String.fromCharCode(s+65248):s===32?r+=" ":r+=t.charAt(n)}return j.create(r)}}class aA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"needsLocale",!0)}calculate(e,t){let r=t!=null?t:y.create(2);r.isNull()&&(r=y.create(2));const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s;let c=+a.getValue(),l=Math.trunc(+u.getValue());if(l>127)return g.create(h.VALUE);l<0&&(`${c}`.length<Math.abs(l)?c=0:c=c<0?-Vt(Math.abs(c),l):Vt(c,l),l=0);const f=Uc(this.getLocale(),c,l);return j.create(f)}}class iA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,ae.create()),a=O(r,n,t,ae.create()),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSingleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSingleObject(e,t){if(e.isNull()||t.isNull()){const a=e.isNull()&&t.isNull();return k.create(a)}let r=`${e.getValue()}`;e.isBoolean()&&(r=r.toLocaleUpperCase());let n=`${t.getValue()}`;t.isBoolean()&&(n=n.toLocaleUpperCase());const s=r===n;return k.create(s)}}const aa=(i,o)=>M.numfmt.format(i,o,{throws:!1}),Me=i=>{let o=`${i.getValue()}`;return i.isNull()&&(o=""),i.isBoolean()&&(o=o.toLocaleUpperCase()),i.isNumber()&&(i.getPattern()!==""?o=aa(i.getPattern(),+i.getValue()):o=`${Ui(+i.getValue())}`),o};class oA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return m.isError()?m:_.isError()?_:E.isError()?E:this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Me(e),s=Me(t),{isError:a,errorObject:u,variants:c}=I(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);return m===-1?g.create(h.VALUE):y.create(m+1)}}function ia(i){let o=0;for(let e=0;e<i.length;e++)o+=Ur(i,e);return o}function Ur(i,o,e="ltr"){return uA(i,o,e)>255?2:1}function Xa(i){return i>=55296&&i<=56319}function Ka(i){return i>=56320&&i<=57343}function Za(i,o){const e=(i&1023)<<10,t=o&1023;return e+t+65536}function uA(i,o,e="ltr"){const t=i.charCodeAt(o);if(e==="ltr"&&Xa(t)&&o+1<i.length){const r=i.charCodeAt(o+1);if(Ka(r))return Za(t,r)}if(e==="rtl"&&Ka(t)&&o-1>=0){const r=i.charCodeAt(o-1);if(Xa(r))return Za(r,t)}return t}class cA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return m.isError()?m:_.isError()?_:E.isError()?E:this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Me(e),s=Me(t),{isError:a,errorObject:u,variants:c}=I(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);if(m===-1)return g.create(h.VALUE);const d=ia(s.substring(0,m))+1;return y.create(d)}}class lA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){let n=t!=null?t:y.create(2);n.isNull()&&(n=y.create(2));let s=r!=null?r:k.create(!1);s.isNull()&&(s=k.create(!1));const a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.mapValue((d,C,_)=>{const E=l.get(C,_),b=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:this._handleSingleObject(d,E,b)});return a===1&&u===1?m.get(0,0):m}_handleSingleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a;let f=+u.getValue(),m=Math.trunc(+c.getValue());const d=+l.getValue();if(m>127)return g.create(h.VALUE);m<0&&(`${f}`.length<Math.abs(m)?f=0:f=f<0?-Vt(Math.abs(f),m):Vt(f,m),m=0);let C=d?"###0":"#,##0";m>0&&(C+=`.${"0".repeat(m)}`);const _=aa(C,f);return j.create(_)}}class fA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Me(e),{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return j.create("");if(c>=r.length)return j.create(r);const l=r.substring(0,c);return j.create(l)}}class mA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,ae.create()),u=O(n,s,r,ae.create()),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Me(e),{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return j.create("");let l=0,f=0,m="";for(;f<c&&l<r.length;)f+=Ur(r,l),m+=r.charAt(l),l++;return j.create(m)}}class hA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleText(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleText(e)}_handleSingleText(e){if(e.isError())return e;const t=Me(e);return y.create(t.length)}}class gA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleText(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleText(e)}_handleSingleText(e){if(e.isError())return e;const t=Me(e),r=ia(t);return y.create(r)}}class dA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return j.create("");const t=`${e.getValue()}`.toLocaleLowerCase();return j.create(t)}}class CA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSingleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSingleObject(e,t,r){const n=Me(e),{isError:s,errorObject:a,variants:u}=I(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);if(e.isNull()||f>n.length||m===0)return j.create("");const d=n.substring(f-1,f-1+m);return j.create(d)}}class _A extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSingleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSingleObject(e,t,r){let n=Me(e);const{isError:s,errorObject:a,variants:u}=I(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);if(e.isNull()||f>n.length||m===0)return j.create("");n=n.substring(f-1);let d=0,C=0,_="";for(;C<m&&d<n.length;)C+=Ur(n,d),_+=n.charAt(d),d++;return j.create(_)}}class AA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:j.create("."),s=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,r!=null&&r.isArray()?r.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,r!=null&&r.isArray()?r.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,n,g.create(h.NA)),l=r?O(s,a,r,g.create(h.NA)):void 0,f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=r?l.get(d,C):void 0;return m.isError()?m:_.isError()?_:E!=null&&E.isError()?E:_.isNull()||E!=null&&E.isNull()?g.create(h.VALUE):m.isNull()?y.create(0):this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){let n=`${e.getValue()}`;n=n.replace(/\s+/g,"");let s=`${t.getValue()}`;t.isBoolean()&&(s=s.toLocaleUpperCase()),s=s.charAt(0);let a;if(r&&(a=`${r.getValue()}`,r.isBoolean()&&(a=a.toLocaleUpperCase()),a=a.charAt(0),s===a))return g.create(h.VALUE);if(n.trim()==="")return y.create(0);if(!n.match(/^\s*[+-]?\s*(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?[ \t]*/))return g.create(h.VALUE);const u=n.split(s);if(u.length>2)return g.create(h.VALUE);let c=u[0].replace(/,/g,"");r&&(c=c.split(a).join(""));let l=0;if(u.length===1){s===","&&(c=c.replace(/\./g,""));let f=0;for(;c.endsWith("%");)c=c.slice(0,-1),f++;f>0?l=+c/100**f:l=+c}else{if(!M.isRealNum(c))return g.create(h.VALUE);let f=u[1],m=0;for(;f.endsWith("%");)f=f.slice(0,-1),m++;const d=`${c}.${f}`;if(!M.isRealNum(d))return g.create(h.VALUE);m>0?l=+d/100**m:l=+d}return Number.isNaN(l)?g.create(h.VALUE):y.create(l)}}class EA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isNull()||e.isBoolean()||e.isNumber())return e;const r=e.getValue().toLocaleString().toLocaleLowerCase().replace(/(^|\b|\W|\d|_)[a-z]/g,n=>n.toLocaleUpperCase());return j.create(r)}}const mu=()=>[{type:4,from:48,to:57}],hu=()=>[{type:7,value:95},{type:4,from:97,to:122},{type:4,from:65,to:90},{type:4,from:48,to:57}],gu=()=>[{type:7,value:9},{type:7,value:10},{type:7,value:11},{type:7,value:12},{type:7,value:13},{type:7,value:32},{type:7,value:160},{type:7,value:5760},{type:4,from:8192,to:8202},{type:7,value:8232},{type:7,value:8233},{type:7,value:8239},{type:7,value:8287},{type:7,value:12288},{type:7,value:65279}],du=()=>({type:3,set:hu(),not:!1}),Cu=()=>({type:3,set:hu(),not:!0}),_u=()=>({type:3,set:mu(),not:!1}),Au=()=>({type:3,set:mu(),not:!0}),Eu=()=>({type:3,set:gu(),not:!1}),bu=()=>({type:3,set:gu(),not:!0}),bA=()=>({type:3,set:[{type:7,value:10},{type:7,value:13},{type:7,value:8232},{type:7,value:8233}],not:!0});function yA(i){const o={type:0,stack:[]};let e=o,t=o.stack;const r=[],n=[];let s=0;const a=f=>{throw new SyntaxError(`Invalid regular expression: /${i}/: Nothing to repeat at column ${f-1}`)},u=pA(i);let c=0,l;for(;c<u.length;)switch(l=u[c++],l){case"\\":if(c===u.length)throw new SyntaxError(`Invalid regular expression: /${i}/: \\ at end of pattern`);switch(l=u[c++],l){case"b":t.push({type:2,value:"b"});break;case"B":t.push({type:2,value:"B"});break;case"w":t.push(du());break;case"W":t.push(Cu());break;case"d":t.push(_u());break;case"D":t.push(Au());break;case"s":t.push(Eu());break;case"S":t.push(bu());break;default:if(/\d/.test(l)){for(;/\d/.test(u[c])&&c<u.length;)l+=u[c++];const f=Number.parseInt(l,10);t.push({type:6,value:f}),n.push({reference:{type:6,value:f},stack:t,index:t.length-1})}else t.push({type:7,value:l.charCodeAt(0)})}break;case"^":t.push({type:2,value:"^"});break;case"$":t.push({type:2,value:"$"});break;case"[":{const f=u[c]==="^";f&&c++;const m=RA(u.slice(c),i);c+=m[1],t.push({type:3,set:m[0],not:f});break}case".":t.push(bA());break;case"(":{const f={type:1,stack:[],remember:!0};if(u[c]==="?"){const m=u[c+1];if(c+=2,m==="=")f.followedBy=!0;else if(m==="!")f.notFollowedBy=!0;else if(m!==":")throw new SyntaxError(`Invalid regular expression: /${i}/: Invalid group, character '${m}' after '?' at column ${c-1}`);f.remember=!1}else s+=1;t.push(f),r.push(e),e=f,t=f.stack;break}case")":if(r.length===0)throw new SyntaxError(`Invalid regular expression: /${i}/: Unmatched ) at column ${c-1}`);e=r.pop(),t=e.options?e.options[e.options.length-1]:e.stack;break;case"|":{e.options||(e.options=[e.stack],delete e.stack);const f=[];e.options.push(f),t=f;break}case"{":{const f=/^(\d+)(,(\d+)?)?\}/.exec(u.slice(c));if(f){t.length===0&&a(c);const m=Number.parseInt(f[1],10),d=f[2]?f[3]?Number.parseInt(f[3],10):1/0:m;c+=f[0].length,t.push({type:5,min:m,max:d,value:t.pop()})}else t.push({type:7,value:123});break}case"?":t.length===0&&a(c),t.push({type:5,min:0,max:1,value:t.pop()});break;case"+":t.length===0&&a(c),t.push({type:5,min:1,max:1/0,value:t.pop()});break;case"*":t.length===0&&a(c),t.push({type:5,min:0,max:1/0,value:t.pop()});break;default:t.push({type:7,value:l.charCodeAt(0)})}if(r.length>0)throw new SyntaxError(`Invalid regular expression: /${i}/: Unterminated group`);return NA(n,s),o}function RA(i,o){let e;const t=[],r=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;for(;(e=r.exec(i))!==null;){let n=null;const[,s,a,u,c,l,f,m,d,C,_]=e;if(s||a||u||c||l||f?n=(()=>{let E={type:3,set:[],not:!1};return s?E=du():a?E=_u():u?E=Eu():c?E=Cu():l?E=Au():f&&(E=bu()),E})():m&&_?n={type:4,from:(d||C).charCodeAt(0),to:_.charCodeAt(_.length-1)}:e[16]&&(n={type:7,value:e[16].charCodeAt(0)}),!n)return[t,r.lastIndex];t.push(n)}throw new SyntaxError(`Invalid regular expression: /${o}/: Unterminated character class`)}function pA(i){return i.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(o,e,t,r,n,s,a)=>{if(t)return o;let u;e?u=8:r?u=Number.parseInt(r,16):n?u=Number.parseInt(n,16):s?u="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):u={0:0,t:9,n:10,v:11,f:12,r:13}[a];const c=String.fromCharCode(u);return/[[\]{}^$.|?*+()]/.test(c)?`\\${c}`:c})}function NA(i,o){for(const e of i.reverse()){const t=e.reference.value;if(o<t){e.reference.type=7;const r=t.toString();if(e.reference.value=Number.parseInt(r,8),!/^[0-7]+$/.test(r)){let n=0;for(;r[n]!=="8"&&r[n]!=="9"&&n<r.length;)n+=1;if(n===0?(e.reference.value=r.charCodeAt(0),n+=1):e.reference.value=Number.parseInt(r.slice(0,n),8),r.length>n){const s=e.stack.splice(e.index+1);for(const a of r.slice(n))e.stack.push({type:7,value:a.charCodeAt(0)});e.stack.push(...s)}}}}}function oa(i,o){if(!VA(i))return{isError:!0,regExp:null};try{const e=new RegExp(i,o?"ug":"u");return OA(e)?{isError:!1,regExp:e}:{isError:!0,regExp:null}}catch{return{isError:!0,regExp:null}}}function VA(i){return!(/\(\?<=.*?\)/g.test(i)&&!/\[.*?(\?<=.*?)\]/g.test(i)||/\(\?<!.*?\)/g.test(i)&&!/\[.*?(\?<!.*?)\]/g.test(i))}function OA(i,o){let t;Object.prototype.toString.call(i)==="[object RegExp]"?t=i.source:i&&typeof i!="string"&&(t=`${i}`);let r;try{r=yA(t)}catch{return!1}let n=0;const s=(a,u)=>{let c=u;if(a.type===5&&(c++,n++,c>1||n>25))return!1;if(a.options){for(const f of a.options)if(!s({stack:f},c))return!1}const l=a.stack||a.value&&a.value.stack;if(!l)return!0;for(const f of l)if(!s(f,c))return!1;return!0};return s(r,0)}class MA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=Js(e,t);if(r)return n;const[a,u]=s;let c=a.getValue();a.isNull()&&(c=""),a.isBoolean()&&(c=c?"TRUE":"FALSE"),c=`${c}`;let l=u.getValue();u.isNull()&&(l=""),u.isBoolean()&&(l=l?"TRUE":"FALSE"),l=`${l}`;const{isError:f,regExp:m}=oa(l,!1);if(f)return g.create(h.REF);const d=c.match(m);if(d===null)return g.create(h.NA);if(d.length>1){const C=d.slice(1).map(_=>j.create(_));return C.length>1?K.create({calculateValueList:[C],rowCount:1,columnCount:C.length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}):C[0]}return j.create(d[0])}}class SA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=Js(e,t);if(r)return n;const[a,u]=s;let c=a.getValue();a.isNull()&&(c=""),a.isBoolean()&&(c=c?"TRUE":"FALSE"),c=`${c}`;let l=u.getValue();u.isNull()&&(l=""),u.isBoolean()&&(l=l?"TRUE":"FALSE"),l=`${l}`;const{isError:f,regExp:m}=oa(l,!1);return f?g.create(h.REF):c.match(m)===null?k.create(!1):k.create(!0)}}class DA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=Js(e,t,r);if(n)return s;const[u,c,l]=a;let f=u.getValue();u.isNull()&&(f=""),u.isBoolean()&&(f=f?"TRUE":"FALSE"),f=`${f}`;let m=c.getValue();c.isNull()&&(m=""),c.isBoolean()&&(m=m?"TRUE":"FALSE"),m=`${m}`;let d=l.getValue();l.isNull()&&(d=""),l.isBoolean()&&(d=d?"TRUE":"FALSE"),d=`${d}`;const{isError:C,regExp:_}=oa(m,!0);if(C)return g.create(h.REF);const E=f.replace(_,d);return j.create(E)}}class wA extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSingleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);const d=Me(e),C=Me(n),_=d.substring(0,f-1)+C+d.substring(f-1+m);return j.create(_)}}class PA extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSingleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);let d=Me(e);const C=Me(n);let _=d.substring(0,f-1);d=d.substring(f-1);let E=0,b=0;for(;b<m&&E<d.length;)b+=Ur(d,E),E++;return _+=C+d.substring(E),j.create(_)}}class LA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=a.get(l,f);if(c.isError())return c;let d=c.getValue();if(c.isNull()&&(d=""),c.isBoolean()&&(d=d?"TRUE":"FALSE"),d+="",m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const C=32767,_=Math.floor(+m.getValue());if(_<0||_>C/d.length)return g.create(h.VALUE);const E=d.repeat(_);return j.create(E)});return r===1&&n===1?u.get(0,0):u}}class xA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Me(e),{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return j.create("");if(c>=r.length)return j.create(r);const l=r.substring(r.length-c);return j.create(l)}}class jA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Me(e),{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return j.create("");let l=r.length-1,f=0,m="";for(;f<c&&l>=0;)f+=Ur(r,l,"rtl"),m=r.charAt(l)+m,l--;return j.create(m)}}class UA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return m.isError()?m:_.isError()?_:E.isError()?E:this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Me(e).toLocaleUpperCase(),s=Me(t).toLocaleUpperCase(),{isError:a,errorObject:u,variants:c}=I(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);return m===-1?g.create(h.VALUE):y.create(m+1)}}class vA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return m.isError()?m:_.isError()?_:E.isError()?E:this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Me(e).toLocaleUpperCase(),s=Me(t).toLocaleUpperCase(),{isError:a,errorObject:u,variants:c}=I(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);if(m===-1)return g.create(h.VALUE);const d=ia(s.substring(0,m))+1;return y.create(d)}}class TA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n!=null&&n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n!=null&&n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=n?O(s,a,n,g.create(h.NA)):void 0,m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_);let R=n?f.get(C,_):void 0;return d.isError()?d:E.isError()?E:b.isError()?b:R!=null&&R.isError()?R:R!=null&&R.isNull()||R!=null&&R.isBoolean()?g.create(h.VALUE):(R!=null&&R.isString()&&(R=R.convertToNumberObjectValue()),R!=null&&R.isError()?R:this._handleSingleObject(d,E,b,R))});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const s=this._getObjectString(e),a=this._getObjectString(t),u=this._getObjectString(r),c=n?Math.floor(+n.getValue()):void 0;if(n&&c<=0)return g.create(h.VALUE);if(a==="")return j.create(s);let l="",f=0;for(let m=0;m<s.length;m++){const d=s.substr(m,a.length);if(d===a||d.length===a.length&&d.trim()===a.trim()){if(f++,f===c){l=s.substr(0,m)+u+s.substr(m+a.length);break}c===void 0&&(l+=u),m+=a.length-1}else c===void 0&&(l+=s[m])}return c&&f<c&&(l=s),j.create(l)}_getObjectString(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}}class BA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return e.isArray()&&(t=e.get(0,0)),t.isError()?t:t.isNull()||t.isBoolean()||t.isNumber()?j.create(""):t}}class IA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.map((u,c,l)=>{if(u.isError())return u;let f=a.get(c,l)||j.create(" ");if(f.isError())return f;if(f.isBoolean())return g.create(h.VALUE);if(u.isBoolean())return u;let m=u.getValue();if(u.isNull()&&(m=0),u.isString()){if(!M.isRealNum(m))return u;m=Number(m)}f.isNull()&&(f=j.create(" "));const d=`${f.getValue()}`,C=aa(d,m);return j.create(d===" "?C.trimEnd():C)})}}class FA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=!1,c=r!=null?r:y.create(1);c.isNull()&&(u=!0,c=y.create(1));const l=!n,f=n!=null?n:y.create(0),m=s!=null?s:y.create(0),d=a!=null?a:g.create(h.NA),C=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1,d.isArray()?d.getRowCount():1),_=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1,d.isArray()?d.getColumnCount():1),E=O(C,_,e,g.create(h.NA)),b=O(C,_,c,g.create(h.NA)),R=O(C,_,f,g.create(h.NA)),p=O(C,_,m,g.create(h.NA)),V=O(C,_,d,g.create(h.NA)),S=this._getResultArray(E,t,b,R,p,V,u,l);return C===1&&_===1?S.get(0,0):S}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{const C=r.get(m,d),_=n.get(m,d),E=s.get(m,d),b=a.get(m,d),R=this._checkVariantsError(f,C,_,E);if(R.isError())return R;const p=this._getStringValue(f),V=this._getDelimiterValue(t);if(V instanceof g)return V;const S=this._getVariantsNumberFloorValue(C,_,E);if(S instanceof g)return S;const[D,w,P]=S;return D===0||w<0||w>1||P<0||P>1?g.create(h.VALUE):V.includes("")?D>0?j.create(p):j.create(""):!u&&Math.abs(D)>p.length?g.create(h.VALUE):V.every(L=>L.length>p.length)?g.create(h.NA):this._getResult(p,V,D,w,P,b,c)})}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return k.create(!0)}_getStringValue(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}_getDelimiterValue(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);if(e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;t.push(this._getStringValue(a))}),r)return n}else{if(e.isError())return e;t.push(this._getStringValue(e))}return t}_getVariantsNumberFloorValue(...e){const t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;const s=Math.floor(+n.getValue());t.push(s)}return t}_getResult(e,t,r,n,s,a,u){let c=n?e.toLocaleLowerCase():e;const l=n?t.map(_=>_.toLocaleLowerCase()):t;let f=0,m=0,d=0;for(let _=0;_<Math.abs(r);_++)if(r<0){const E=l.map(b=>({index:c.lastIndexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>R.index-b.index)[0];if(!E)break;f=E.index,c=c.substr(0,E.index),d=E.length,m++}else{const E=l.map(b=>({index:c.indexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>b.index-R.index)[0];if(!E)break;f+=E.index+d,c=c.substr(E.index+E.length),d=E.length,m++}if(m&&m<Math.abs(r)&&u)return g.create(h.NA);if(!m||m<Math.abs(r))return s?r>0?j.create(""):j.create(e):a;const C=e.substr(f+d);return j.create(C)}}class kA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=!1,c=r!=null?r:y.create(1);c.isNull()&&(u=!0,c=y.create(1));const l=!n,f=n!=null?n:y.create(0),m=s!=null?s:y.create(0),d=a!=null?a:g.create(h.NA),C=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1,d.isArray()?d.getRowCount():1),_=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1,d.isArray()?d.getColumnCount():1),E=O(C,_,e,g.create(h.NA)),b=O(C,_,c,g.create(h.NA)),R=O(C,_,f,g.create(h.NA)),p=O(C,_,m,g.create(h.NA)),V=O(C,_,d,g.create(h.NA)),S=this._getResultArray(E,t,b,R,p,V,u,l);return C===1&&_===1?S.get(0,0):S}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{const C=r.get(m,d),_=n.get(m,d),E=s.get(m,d),b=a.get(m,d),R=this._checkVariantsError(f,C,_,E);if(R.isError())return R;const p=this._getStringValue(f),V=this._getDelimiterValue(t);if(V instanceof g)return V;const S=this._getVariantsNumberFloorValue(C,_,E);if(S instanceof g)return S;const[D,w,P]=S;return D===0||w<0||w>1||P<0||P>1?g.create(h.VALUE):V.includes("")?D>0?j.create(""):j.create(p):!u&&Math.abs(D)>p.length?g.create(h.VALUE):V.every(L=>L.length>p.length)?g.create(h.NA):this._getResult(p,V,D,w,P,b,c)})}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return k.create(!0)}_getStringValue(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}_getDelimiterValue(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);if(e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;t.push(this._getStringValue(a))}),r)return n}else{if(e.isError())return e;t.push(this._getStringValue(e))}return t}_getVariantsNumberFloorValue(...e){const t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;const s=Math.floor(+n.getValue());t.push(s)}return t}_getResult(e,t,r,n,s,a,u){let c=n?e.toLocaleLowerCase():e;const l=n?t.map(_=>_.toLocaleLowerCase()):t;let f=0,m=0,d=0;for(let _=0;_<Math.abs(r);_++)if(r<0){const E=l.map(b=>({index:c.lastIndexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>R.index-b.index)[0];if(!E)break;f=E.index,c=c.substr(0,E.index),m++}else{const E=l.map(b=>({index:c.indexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>b.index-R.index)[0];if(!E)break;f+=E.index+d,c=c.substr(E.index+E.length),d=E.length,m++}if(m&&m<Math.abs(r)&&u)return g.create(h.NA);if(!m||m<Math.abs(r))return s?r>0?j.create(e):j.create(""):a;const C=e.substr(0,f);return j.create(C)}}class $A extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,t,...r){const n=this._getDelimiterValues(e),s=this._getTextValues(r);if(t.isArray()){const u=t.mapValue(c=>this._handleSingleObject(n,c,s));return u.getRowCount()===1&&u.getColumnCount()===1?u.get(0,0):u}const a=t;if(a.isString()){const u=`${a.getValue()}`.toLocaleUpperCase();if(u==="TRUE")return this._handleSingleObject(n,k.create(!0),s);if(u==="FALSE")return this._handleSingleObject(n,k.create(!1),s)}return this._handleSingleObject(n,t,s)}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;if(r instanceof g)return r;const[u]=a,c=+u.getValue();let l=r;c&&(l=r.filter(m=>m!==null));let f="";for(let m=0;m<l.length;m++)l[m]!==null&&(f+=l[m]),m<l.length-1&&(f+=e[m%e.length]);return j.create(f)}_getDelimiterValues(e){const t=[],r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1;for(let s=0;s<r;s++)for(let a=0;a<n;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;let c=`${u.getValue()}`;u.isNull()&&(c=""),u.isBoolean()&&(c=c.toLocaleUpperCase()),t.push(c)}return t}_getTextValues(e){const t=[];for(const r of e){const n=r.isArray()?r.getRowCount():1,s=r.isArray()?r.getColumnCount():1;for(let a=0;a<n;a++)for(let u=0;u<s;u++){const c=r.isArray()?r.get(a,u):r;if(c.isError())return c;if(c.isNull()){t.push(null);continue}let l=`${c.getValue()}`;c.isBoolean()&&(l=l.toLocaleUpperCase()),t.push(l)}}return t}}class YA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=r!=null?r:j.create("\\s");const c=n!=null?n:y.create(0),l=s!=null?s:y.create(0),f=a!=null?a:j.create(h.NA),{_variant:m,values:d}=this._getStringValues(t),{_variant:C,values:_}=this._getStringValues(u,!1);u=C;const E=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),b=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),R=O(E,b,e,g.create(h.NA)),p=O(E,b,c,g.create(h.NA)),V=O(E,b,l,g.create(h.NA)),S=this._getResultArray(R,m,u,p,V,f,d,_);return E===1&&b===1?S.get(0,0):S.map(D=>D.get(0,0))}_getStringValues(e,t=!0){let r=e;const n=[];if(r.isArray())r.iterator(s=>{if(s!=null&&s.isError())return r=s,!1;if(s!=null&&s.isNull()&&t)return r=g.create(h.VALUE),!1;const a=this._getRegExpStringValue(s);if(a==="")return r=g.create(h.VALUE),!1;n.push(a)});else{r.isNull()&&t&&(r=g.create(h.VALUE));const s=this._getRegExpStringValue(r);s===""&&(r=g.create(h.VALUE)),n.push(s)}return{_variant:r,values:n}}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{let C=n.get(m,d),_=s.get(m,d);const E=this._checkVariantsError(f,t,r,C,_);if(E.isError())return E;if(f.isNull())return g.create(h.VALUE);let b=a;if(b.isArray()){const D=b.getRowCount(),w=b.getColumnCount();if(D>1||w>1)return g.create(h.VALUE);b=b.get(0,0)}let R=`${f.getValue()}`;if(f.isBoolean()&&(R=R.toLocaleUpperCase()),C.isString()&&(C=C.convertToNumberObjectValue(),C.isError()))return C;const p=Math.floor(+C.getValue());if(_.isString()&&(_=_.convertToNumberObjectValue(),_.isError()))return _;const V=Math.floor(+_.getValue());if(V<0||V>1)return g.create(h.VALUE);let S=`${b.getValue()}`;return b.isBoolean()&&(S=S.toLocaleUpperCase()),this._getResult(R,u,c,p,V,S)})}_getResult(e,t,r,n,s,a){const u=new RegExp(r.join("|"),`g${s?"i":""}`),c=new RegExp(t.join("|"),`g${s?"i":""}`),l=e.split(u);let f=1,m=l.map(d=>{let C=d.split(c);return n&&(C=C.filter(_=>_!=="")),f=Math.max(f,C.length),C});return m=m.map(d=>{let C=d;return C.length<f&&(C=C.concat(new Array(f-C.length).fill(a))),C}),K.createByArray(m)}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return k.create(!0)}_getRegExpStringValue(e){let t=e.getValue();return e.isNull()&&(t="\\s"),e.isBoolean()&&(t=t?"TRUE":"FALSE"),t+="",this._escapeRegExp(t)}_escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class HA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return j.create("");let t=`${e.getValue()}`;return e.isBoolean()&&(t=t.toLocaleUpperCase()),t=t.trim().replace(/\s+/g," "),j.create(t)}}const GA=Object.values(M.DataStreamTreeTokenType).filter(i=>[M.DataStreamTreeTokenType.TABLE_START,M.DataStreamTreeTokenType.TABLE_ROW_START,M.DataStreamTreeTokenType.TABLE_CELL_START,M.DataStreamTreeTokenType.TABLE_CELL_END,M.DataStreamTreeTokenType.TABLE_ROW_END,M.DataStreamTreeTokenType.TABLE_END,M.DataStreamTreeTokenType.CUSTOM_BLOCK].includes(i));class WA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=Math.floor(+s.getValue());if(a<1||a>1114111)return g.create(h.VALUE);if(a===1114111||a===1114110)return g.create(h.NA);let u=String.fromCharCode(a);return GA.some(c=>c===u)&&(u=""),j.create(u)}}class QA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);let t=e.getValue().toLocaleString();e.isBoolean()&&(t=t.toLocaleUpperCase());const r=t.charCodeAt(0);return y.create(r)}}class qA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return j.create("");const t=`${e.getValue()}`.toLocaleUpperCase();return j.create(t)}}class XA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue(),t.isError()))return t;const r=+t.getValue();return y.create(r)}}class KA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<0||u>1)return g.create(h.VALUE);if(e.isNull())return j.create("");if(e.isBoolean())return e;if(e.isNumber())return y.create(e.getValue());const c=u?`"${e.getValue()}"`:`${e.getValue()}`;return j.create(c)}}const yu=[[K_,ne.ASC],[X_,ne.ARRAYTOTEXT],[Z_,ne.BAHTTEXT],[J_,ne.CHAR],[eA,ne.CLEAN],[tA,ne.CODE],[rA,ne.CONCAT],[nA,ne.CONCATENATE],[sA,ne.DBCS],[aA,ne.DOLLAR],[iA,ne.EXACT],[oA,ne.FIND],[cA,ne.FINDB],[lA,ne.FIXED],[fA,ne.LEFT],[mA,ne.LEFTB],[hA,ne.LEN],[gA,ne.LENB],[dA,ne.LOWER],[CA,ne.MID],[_A,ne.MIDB],[AA,ne.NUMBERVALUE],[MA,ne.REGEXEXTRACT],[SA,ne.REGEXMATCH],[DA,ne.REGEXREPLACE],[EA,ne.PROPER],[wA,ne.REPLACE],[PA,ne.REPLACEB],[LA,ne.REPT],[xA,ne.RIGHT],[jA,ne.RIGHTB],[UA,ne.SEARCH],[vA,ne.SEARCHB],[TA,ne.SUBSTITUTE],[BA,ne.T],[IA,ne.TEXT],[FA,ne.TEXTAFTER],[kA,ne.TEXTBEFORE],[$A,ne.TEXTJOIN],[YA,ne.TEXTSPLIT],[HA,ne.TRIM],[WA,ne.UNICHAR],[QA,ne.UNICODE],[qA,ne.UPPER],[XA,ne.VALUE],[KA,ne.VALUETOTEXT]],Ru=[];var pu=(i=>i)(pu||{});const Nu=[];var Vu=(i=>(i.ENCODEURL="ENCODEURL",i.FILTERXML="FILTERXML",i.WEBSERVICE="WEBSERVICE",i))(Vu||{}),ZA=Object.defineProperty,zA=Object.getOwnPropertyDescriptor,JA=(i,o,e,t)=>{for(var r=t>1?void 0:t?zA(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&ZA(o,e,r),r},Fr=(i,o)=>(e,t)=>o(e,t,i);let mn=class extends M.Disposable{constructor(i,o,e,t){super(),this._commandService=i,this._functionService=o,this._configService=e,this._dataSyncPrimaryController=t,this._initialize()}_initialize(){this._registerCommands(),this._registerFunctions()}_registerCommands(){[Rn,Zr,ps,Ns,en,Vs,Vr,En,bn,yn,pn,Nn,Ai,Ei,Os,hi].forEach(i=>{var o;this._commandService.registerCommand(i),(o=this._dataSyncPrimaryController)==null||o.registerSyncingMutations(i)})}_registerFunctions(){var e;const i=this._configService.getConfig(On),o=[...zi,...$o,...Yo,...Go,...Zo,...zo,...au,...iu,...ou,...uu,...cu,...lu,...fu,...yu,...Ru,...Nu].concat((e=i==null?void 0:i.function)!=null?e:[]).map(t=>{const r=t[0],n=t[1];return new r(n)});this._functionService.registerExecutors(...o)}};mn=JA([Fr(0,M.ICommandService),Fr(1,gt),Fr(2,M.IConfigService),Fr(3,M.Optional(Pu.DataSyncPrimaryController))],mn);var eE=Object.defineProperty,tE=Object.getOwnPropertyDescriptor,rE=(i,o,e,t)=>{for(var r=t>1?void 0:t?tE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&eE(o,e,r),r},kr=(i,o)=>(e,t)=>o(e,t,i);let hn=class extends M.Disposable{constructor(i,o,e){super(),this._commandService=i,this._dependencyManagerService=o,this._featureCalculationManagerService=e,this._initialize()}_initialize(){this._commandExecutedListener(),this._featureCalculationManagerServiceListener()}_featureCalculationManagerServiceListener(){this.disposeWithMe(this._featureCalculationManagerService.onChanged$.subscribe(i=>{const{unitId:o,subUnitId:e,featureIds:t}=i;this._dependencyManagerService.removeFeatureFormulaDependency(o,e,t)}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===yn.id){const o=i.params;if(o==null)return;const{featureIds:e,unitId:t,subUnitId:r}=o;this._dependencyManagerService.removeFeatureFormulaDependency(t,r,e)}else if(i.id===bn.id){const o=i.params;if(o==null)return;const{featureId:e,calculationParam:t}=o,{unitId:r,subUnitId:n}=t;this._dependencyManagerService.removeFeatureFormulaDependency(r,n,[e])}else if(i.id===Nn.id){const o=i.params;if(o==null)return;this._dependencyManagerService.removeOtherFormulaDependency(o.unitId,o.subUnitId,o.formulaIdList)}else if(i.id===pn.id){const o=i.params;if(o==null)return;const e=o.formulaMap,t=[];Object.keys(e).forEach(r=>{t.push(r)}),this._dependencyManagerService.removeOtherFormulaDependency(o.unitId,o.subUnitId,t)}else if(i.id===Rn.id){const o=i.params.formulaData;Object.keys(o).forEach(e=>{const t=o[e];if(t!==void 0){if(t===null){this._dependencyManagerService.clearFormulaDependency(e);return}Object.keys(t).forEach(r=>{const n=t[r];if(n!==void 0){if(n===null)return this._dependencyManagerService.clearFormulaDependency(e,r),!0;new M.ObjectMatrix(n).forValue((s,a)=>{this._dependencyManagerService.removeFormulaDependency(e,r,s,a)})}})}})}else i.id===Vr.id&&this._handleSetDefinedName(i)}))}_handleSetDefinedName(i){const o=i.params;if(o==null)return;const{unitId:e,name:t}=o;this._dependencyManagerService.removeFormulaDependencyByDefinedName(e,t)}};hn=rE([kr(0,M.ICommandService),kr(1,ar),kr(1,wr),kr(2,ar)],hn);var nE=Object.defineProperty,sE=Object.getOwnPropertyDescriptor,aE=(i,o,e,t)=>{for(var r=t>1?void 0:t?sE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&nE(o,e,r),r},za=(i,o)=>(e,t)=>o(e,t,i);let gn=class extends M.Disposable{constructor(i,o){super(),this._commandService=i,this._featureCalculationManagerService=o,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===bn.id){const o=i.params;if(o==null)return;const{featureId:e,calculationParam:t}=o,{unitId:r,subUnitId:n}=t;this._featureCalculationManagerService.register(r,n,e,t)}else if(i.id===yn.id){const o=i.params;if(o==null)return;const{featureIds:e,unitId:t,subUnitId:r}=o;this._featureCalculationManagerService.remove(t,r,e)}}))}};gn=aE([za(0,M.ICommandService),za(1,ar)],gn);var iE=Object.defineProperty,oE=Object.getOwnPropertyDescriptor,uE=(i,o,e,t)=>{for(var r=t>1?void 0:t?oE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&iE(o,e,r),r},ts=(i,o)=>(e,t)=>o(e,t,i);let dn=class extends M.Disposable{constructor(i,o,e){super(),this._commandService=i,this._otherFormulaManagerService=o,this._dependencyManagerService=e,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===pn.id){const o=i.params;if(o==null)return;const e={[o.unitId]:{[o.subUnitId]:o.formulaMap}};this._otherFormulaManagerService.batchRegister(e)}else if(i.id===Nn.id){const o=i.params;if(o==null)return;const e={};o.formulaIdList.forEach(r=>e[r]=!0);const t={[o.unitId]:{[o.subUnitId]:e}};this._otherFormulaManagerService.batchRemove(t)}}))}};dn=uE([ts(0,M.ICommandService),ts(1,vn),ts(2,wr)],dn);class Ou extends M.Disposable{constructor(){super(...arguments);A(this,"_tableMap",new Map);A(this,"_tableOptionMap",new Map)}dispose(){this._tableMap.clear(),this._tableOptionMap.clear()}remove(e,t){var r;(r=this._tableMap.get(e))==null||r.delete(t)}getTableMap(e){return this._tableMap.get(e)}getTableOptionMap(){return this._tableOptionMap}registerTable(e,t,r){var n;this._tableMap.get(e)==null&&this._tableMap.set(e,new Map),(n=this._tableMap.get(e))==null||n.set(t,r)}registerTableOptionMap(e,t){this._tableOptionMap.set(e,t)}}const ua=M.createIdentifier("univer.formula.super-table.service");var cE=Object.defineProperty,lE=Object.getOwnPropertyDescriptor,fE=(i,o,e,t)=>{for(var r=t>1?void 0:t?lE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&cE(o,e,r),r},Ja=(i,o)=>(e,t)=>o(e,t,i);let Cn=class extends M.Disposable{constructor(i,o){super(),this._commandService=i,this._superTableService=o,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===Vr.id){const o=i.params;if(o==null)return;const{unitId:e,tableName:t,reference:r}=o;this._superTableService.registerTable(e,t,r)}else if(i.id===En.id){const o=i.params;if(o==null)return;const{unitId:e,tableName:t}=o;this._superTableService.remove(e,t)}else if(i.id===Os.id){const o=i.params;if(o==null)return;const{tableOption:e,tableOptionType:t}=o;this._superTableService.registerTableOptionMap(e,t)}}))}};Cn=fE([Ja(0,M.ICommandService),Ja(1,ua)],Cn);class Mu extends M.Disposable{constructor(){super(...arguments);A(this,"_dirtyConversionMap",new Map)}dispose(){this._dirtyConversionMap.clear()}remove(e){this._dirtyConversionMap.delete(e)}get(e){return this._dirtyConversionMap.get(e)}has(e){return this._dirtyConversionMap.has(e)}register(e,t){this._dirtyConversionMap.set(e,t)}getDirtyConversionMap(){return this._dirtyConversionMap}}const Su=M.createIdentifier("univer.formula.active-dirty-manager.service");var mE=Object.defineProperty,hE=Object.getOwnPropertyDescriptor,gE=(i,o,e,t)=>{for(var r=t>1?void 0:t?hE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&mE(o,e,r),r},ei=(i,o)=>(e,t)=>o(e,t,i);const dE="UNIVER_ENGINE_FORMULA_PLUGIN";var rs;exports.UniverFormulaEnginePlugin=(rs=class extends M.Plugin{constructor(o=yc,e,t){super(),this._config=o,this._injector=e,this._configService=t;const{...r}=this._config;this._configService.setConfig(On,r)}onStarting(){this._initialize(),this._initializeWithOverride()}onReady(){var o;M.touchDependencies(this._injector,[[mn],[exports.SetDefinedNameController],[Cn]]),(o=this._config)!=null&&o.notExecuteFormula||M.touchDependencies(this._injector,[[dn],[gn],[hn],[exports.CalculateController]])}onRendered(){var o;(o=this._config)!=null&&o.notExecuteFormula||M.touchDependencies(this._injector,[[cn],[un]])}_initialize(){var e;const o=[[gt,{useClass:Ii}],[lr,{useClass:exports.DefinedNamesService}],[Su,{useClass:Mu}],[ua,{useClass:Ou}],[exports.FormulaDataModel],[Vn],[mn],[exports.SetDefinedNameController],[Cn]];(e=this._config)!=null&&e.notExecuteFormula||o.push([vn,{useClass:Qi}],[st,{useClass:exports.FormulaRuntimeService}],[mt,{useClass:exports.FormulaCurrentConfigService}],[ar,{useClass:Wi}],[exports.CalculateController],[dn],[hn],[gn],[exports.Interpreter],[exports.AstTreeBuilder],[exports.Lexer],[js],[exports.FunctionNodeFactory],[exports.LambdaNodeFactory],[Ts],[exports.OperatorNodeFactory],[exports.PrefixNodeFactory],[exports.ReferenceNodeFactory],[exports.SuffixNodeFactory],[exports.UnionNodeFactory],[Bs]),o.forEach(t=>this._injector.add(t))}_initializeWithOverride(){var o;(o=this._config)!=null&&o.notExecuteFormula||[[cn,{useClass:exports.CalculateFormulaService}],[wr,{useClass:Gi}],[un,{useClass:exports.FormulaDependencyGenerator}]].forEach(t=>this._injector.add(t))}},A(rs,"pluginName",dE),rs);exports.UniverFormulaEnginePlugin=gE([ei(1,M.Inject(M.Injector)),ei(2,M.IConfigService)],exports.UniverFormulaEnginePlugin);var CE=Object.defineProperty,_E=Object.getOwnPropertyDescriptor,AE=(i,o,e,t)=>{for(var r=t>1?void 0:t?_E(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&CE(o,e,r),r},ti=(i,o)=>(e,t)=>o(e,t,i);exports.FFormula=class extends M.FBase{constructor(o,e){super(),this._commandService=o,this._injector=e}executeCalculation(){this._commandService.executeCommand(dr.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(dr.SetFormulaCalculationStopMutation.id,{})}calculationStart(o){return this._commandService.onCommandExecuted(e=>{if(e.id===dr.SetFormulaCalculationStartMutation.id){const t=e.params;o(t.forceCalculation)}})}calculationEnd(o){return this._commandService.onCommandExecuted(e=>{if(e.id!==dr.SetFormulaCalculationNotificationMutation.id)return;const t=e.params;t.functionsExecutedState!==void 0&&o(t.functionsExecutedState)})}onCalculationEnd(){return new Promise((o,e)=>{const t=setTimeout(()=>{e(new Error("Calculation end timeout"))},3e4),r=this.calculationEnd(()=>{clearTimeout(t),r.dispose(),o()})})}calculationProcessing(o){return this._commandService.onCommandExecuted(e=>{if(e.id!==dr.SetFormulaCalculationNotificationMutation.id)return;const t=e.params;t.stageInfo!==void 0&&o(t.stageInfo)})}};exports.FFormula=AE([ti(0,M.Inject(M.ICommandService)),ti(1,M.Inject(M.Injector))],exports.FFormula);exports.ActiveDirtyManagerService=Mu;exports.ArrayValueObject=K;exports.AstRootNodeFactory=js;exports.AsyncArrayObject=Bi;exports.AsyncObject=Ti;exports.BaseFunction=N;exports.BaseReferenceObject=Mr;exports.BaseValueObject=ht;exports.BooleanValue=Ot;exports.BooleanValueObject=k;exports.CustomFunction=Fm;exports.DEFAULT_INTERVAL_COUNT=Ki;exports.DependencyManagerBaseService=Hi;exports.DependencyManagerService=Gi;exports.ERROR_TYPE_SET=qt;exports.ErrorType=h;exports.ErrorValueObject=g;exports.FUNCTION_NAMES_ARRAY=Ji;exports.FUNCTION_NAMES_COMPATIBILITY=le;exports.FUNCTION_NAMES_CUBE=Ho;exports.FUNCTION_NAMES_DATABASE=Te;exports.FUNCTION_NAMES_DATE=ye;exports.FUNCTION_NAMES_ENGINEERING=z;exports.FUNCTION_NAMES_FINANCIAL=J;exports.FUNCTION_NAMES_INFORMATION=Ne;exports.FUNCTION_NAMES_LOGICAL=Ve;exports.FUNCTION_NAMES_LOOKUP=me;exports.FUNCTION_NAMES_MATH=Y;exports.FUNCTION_NAMES_STATISTICAL=U;exports.FUNCTION_NAMES_TEXT=ne;exports.FUNCTION_NAMES_UNIVER=pu;exports.FUNCTION_NAMES_WEB=Vu;exports.FeatureCalculationManagerService=Wi;exports.FormulaDependencyTree=Wr;exports.FormulaDependencyTreeType=on;exports.FormulaDependencyTreeVirtual=Es;exports.FormulaExecuteStageType=ze;exports.FormulaExecutedStateType=zt;exports.FunctionService=Ii;exports.FunctionType=ni;exports.IActiveDirtyManagerService=Su;exports.ICalculateFormulaService=cn;exports.IDefinedNamesService=lr;exports.IDependencyManagerService=wr;exports.IFeatureCalculationManagerService=ar;exports.IFormulaCurrentConfigService=mt;exports.IFormulaDependencyGenerator=un;exports.IFormulaRuntimeService=st;exports.IFunctionService=gt;exports.IOtherFormulaManagerService=vn;exports.ISuperTableService=ua;exports.LambdaParameterNodeFactory=Ts;exports.LexerNode=se;exports.LexerTreeBuilder=Vn;exports.NullValueObject=ae;exports.NumberValueObject=y;exports.OtherFormulaManagerService=Qi;exports.PLUGIN_CONFIG_KEY=On;exports.RangeReferenceObject=Rr;exports.RegisterFunctionMutation=hi;exports.RemoveDefinedNameMutation=En;exports.RemoveFeatureCalculationMutation=yn;exports.RemoveOtherFormulaMutation=Nn;exports.RemoveSuperTableMutation=Ei;exports.SetArrayFormulaDataMutation=Zr;exports.SetDefinedNameMutation=Vr;exports.SetDefinedNameMutationFactory=cc;exports.SetFeatureCalculationMutation=bn;exports.SetFormulaCalculationNotificationMutation=en;exports.SetFormulaCalculationResultMutation=Vs;exports.SetFormulaCalculationStartMutation=ps;exports.SetFormulaCalculationStopMutation=Ns;exports.SetFormulaDataMutation=Rn;exports.SetOtherFormulaMutation=pn;exports.SetSuperTableMutation=Ai;exports.SetSuperTableOptionMutation=Os;exports.StringValueObject=j;exports.SuperTableService=Ou;exports.ValueNodeFactory=Bs;exports.ValueObjectFactory=lt;exports.compareToken=$;exports.convertUnitDataToRuntime=ii;exports.deserializeRangeForR1C1=Zi;exports.deserializeRangeWithSheet=Er;exports.deserializeRangeWithSheetWithCache=Yt;exports.functionArray=zi;exports.functionCompatibility=$o;exports.functionCube=Yo;exports.functionDatabase=Go;exports.functionDate=Zo;exports.functionEngineering=zo;exports.functionFinancial=au;exports.functionInformation=iu;exports.functionLogical=ou;exports.functionLookup=uu;exports.functionMath=cu;exports.functionMeta=lu;exports.functionStatistical=fu;exports.functionText=yu;exports.functionUniver=Ru;exports.functionWeb=Nu;exports.generateAstNode=As;exports.generateRandomDependencyTreeId=vt;exports.generateStringWithSequence=as;exports.getAbsoluteRefTypeWitString=Ju;exports.getAbsoluteRefTypeWithSingleString=_r;exports.getRangeWithRefsString=tc;exports.handleNumfmtInCell=wc;exports.handleRefStringInfo=An;exports.includeFormulaLexerToken=ai;exports.initSheetFormulaData=Ri;exports.isFormulaLexerToken=Cr;exports.isInDirtyRange=ri;exports.isReferenceString=mi;exports.isReferenceStringWithEffectiveColumn=Ar;exports.isReferenceStrings=_i;exports.matchRefDrawToken=Uu;exports.matchToken=Q;exports.normalizeSheetName=ju;exports.operatorToken=X;exports.sequenceNodeType=ve;exports.serializeRange=St;exports.serializeRangeToRefString=zr;exports.serializeRangeWithSheet=gi;exports.serializeRangeWithSpreadsheet=di;exports.singleReferenceToGrid=Yr;exports.strip=ds;exports.stripErrorMargin=Ui;
7
+ */var Zt=9e15,Pt=1e9,ls="0123456789abcdef",rn="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",nn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",fs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Zt,maxE:Zt,crypto:!1},Ni,ct,oe=!0,Sn="[DecimalError] ",Dt=Sn+"Invalid argument: ",Vi=Sn+"Precision limit exceeded",Oi=Sn+"crypto unavailable",Mi="[object Decimal]",xe=Math.floor,Se=Math.pow,Yc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Hc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Gc=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Si=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,tt=1e7,te=7,Wc=9007199254740991,Qc=rn.length-1,ms=nn.length-1,v={toStringTag:Mi};v.absoluteValue=v.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),ee(i)};v.ceil=function(){return ee(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(i,o){var e,t=this,r=t.constructor;if(i=new r(i),o=new r(o),!i.s||!o.s)return new r(NaN);if(i.gt(o))throw Error(Dt+o);return e=t.cmp(i),e<0?i:t.cmp(o)>0?o:new r(t)};v.comparedTo=v.cmp=function(i){var o,e,t,r,n=this,s=n.d,a=(i=new n.constructor(i)).d,u=n.s,c=i.s;if(!s||!a)return!u||!c?NaN:u!==c?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-c:0;if(u!==c)return u;if(n.e!==i.e)return n.e>i.e^u<0?1:-1;for(t=s.length,r=a.length,o=0,e=t<r?t:r;o<e;++o)if(s[o]!==a[o])return s[o]>a[o]^u<0?1:-1;return t===r?0:t>r^u<0?1:-1};v.cosine=v.cos=function(){var i,o,e=this,t=e.constructor;return e.d?e.d[0]?(i=t.precision,o=t.rounding,t.precision=i+Math.max(e.e,e.sd())+te,t.rounding=1,e=qc(t,xi(t,e)),t.precision=i,t.rounding=o,ee(ct==2||ct==3?e.neg():e,i,o,!0)):new t(1):new t(NaN)};v.cubeRoot=v.cbrt=function(){var i,o,e,t,r,n,s,a,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(oe=!1,n=l.s*Se(l.s*l,1/3),!n||Math.abs(n)==1/0?(e=Pe(l.d),i=l.e,(n=(i-e.length+1)%3)&&(e+=n==1||n==-2?"0":"00"),n=Se(e,1/3),i=xe((i+1)/3)-(i%3==(i<0?-1:2)),n==1/0?e="5e"+i:(e=n.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),t=new f(e),t.s=l.s):t=new f(n.toString()),s=(i=f.precision)+3;;)if(a=t,u=a.times(a).times(a),c=u.plus(l),t=Re(c.plus(l).times(a),c.plus(u),s+2,1),Pe(a.d).slice(0,s)===(e=Pe(t.d)).slice(0,s))if(e=e.slice(s-3,s+1),e=="9999"||!r&&e=="4999"){if(!r&&(ee(a,i+1,0),a.times(a).times(a).eq(l))){t=a;break}s+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(ee(t,i+1,1),o=!t.times(t).times(t).eq(l));break}return oe=!0,ee(t,i,f.rounding,o)};v.decimalPlaces=v.dp=function(){var i,o=this.d,e=NaN;if(o){if(i=o.length-1,e=(i-xe(this.e/te))*te,i=o[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e};v.dividedBy=v.div=function(i){return Re(this,new this.constructor(i))};v.dividedToIntegerBy=v.divToInt=function(i){var o=this,e=o.constructor;return ee(Re(o,new e(i),0,1,1),e.precision,e.rounding)};v.equals=v.eq=function(i){return this.cmp(i)===0};v.floor=function(){return ee(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(i){return this.cmp(i)>0};v.greaterThanOrEqualTo=v.gte=function(i){var o=this.cmp(i);return o==1||o===0};v.hyperbolicCosine=v.cosh=function(){var i,o,e,t,r,n=this,s=n.constructor,a=new s(1);if(!n.isFinite())return new s(n.s?1/0:NaN);if(n.isZero())return a;e=s.precision,t=s.rounding,s.precision=e+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<32?(i=Math.ceil(r/3),o=(1/wn(4,i)).toString()):(i=16,o="2.3283064365386962890625e-10"),n=sr(s,1,n.times(o),new s(1),!0);for(var u,c=i,l=new s(8);c--;)u=n.times(n),n=a.minus(u.times(l.minus(u.times(l))));return ee(n,s.precision=e,s.rounding=t,!0)};v.hyperbolicSine=v.sinh=function(){var i,o,e,t,r=this,n=r.constructor;if(!r.isFinite()||r.isZero())return new n(r);if(o=n.precision,e=n.rounding,n.precision=o+Math.max(r.e,r.sd())+4,n.rounding=1,t=r.d.length,t<3)r=sr(n,2,r,r,!0);else{i=1.4*Math.sqrt(t),i=i>16?16:i|0,r=r.times(1/wn(5,i)),r=sr(n,2,r,r,!0);for(var s,a=new n(5),u=new n(16),c=new n(20);i--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(c))))}return n.precision=o,n.rounding=e,ee(r,o,e,!0)};v.hyperbolicTangent=v.tanh=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+7,t.rounding=1,Re(e.sinh(),e.cosh(),t.precision=i,t.rounding=o)):new t(e.s)};v.inverseCosine=v.acos=function(){var i,o=this,e=o.constructor,t=o.abs().cmp(1),r=e.precision,n=e.rounding;return t!==-1?t===0?o.isNeg()?et(e,r,n):new e(0):new e(NaN):o.isZero()?et(e,r+4,n).times(.5):(e.precision=r+6,e.rounding=1,o=o.asin(),i=et(e,r+4,n).times(.5),e.precision=r,e.rounding=n,i.minus(o))};v.inverseHyperbolicCosine=v.acosh=function(){var i,o,e=this,t=e.constructor;return e.lte(1)?new t(e.eq(1)?0:NaN):e.isFinite()?(i=t.precision,o=t.rounding,t.precision=i+Math.max(Math.abs(e.e),e.sd())+4,t.rounding=1,oe=!1,e=e.times(e).minus(1).sqrt().plus(e),oe=!0,t.precision=i,t.rounding=o,e.ln()):new t(e)};v.inverseHyperbolicSine=v.asinh=function(){var i,o,e=this,t=e.constructor;return!e.isFinite()||e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,t.rounding=1,oe=!1,e=e.times(e).plus(1).sqrt().plus(e),oe=!0,t.precision=i,t.rounding=o,e.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var i,o,e,t,r=this,n=r.constructor;return r.isFinite()?r.e>=0?new n(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(i=n.precision,o=n.rounding,t=r.sd(),Math.max(t,i)<2*-r.e-1?ee(new n(r),i,o,!0):(n.precision=e=t-r.e,r=Re(r.plus(1),new n(1).minus(r),e+i,1),n.precision=i+4,n.rounding=1,r=r.ln(),n.precision=i,n.rounding=o,r.times(.5))):new n(NaN)};v.inverseSine=v.asin=function(){var i,o,e,t,r=this,n=r.constructor;return r.isZero()?new n(r):(o=r.abs().cmp(1),e=n.precision,t=n.rounding,o!==-1?o===0?(i=et(n,e+4,t).times(.5),i.s=r.s,i):new n(NaN):(n.precision=e+6,n.rounding=1,r=r.div(new n(1).minus(r.times(r)).sqrt().plus(1)).atan(),n.precision=e,n.rounding=t,r.times(2)))};v.inverseTangent=v.atan=function(){var i,o,e,t,r,n,s,a,u,c=this,l=c.constructor,f=l.precision,m=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=ms)return s=et(l,f+4,m).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(f+4<=ms)return s=et(l,f+4,m).times(.5),s.s=c.s,s}for(l.precision=a=f+10,l.rounding=1,e=Math.min(28,a/te+2|0),i=e;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(oe=!1,o=Math.ceil(a/te),t=1,u=c.times(c),s=new l(c),r=c;i!==-1;)if(r=r.times(u),n=s.minus(r.div(t+=2)),r=r.times(u),s=n.plus(r.div(t+=2)),s.d[o]!==void 0)for(i=o;s.d[i]===n.d[i]&&i--;);return e&&(s=s.times(2<<e-1)),oe=!0,ee(s,l.precision=f,l.rounding=m,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&xe(this.e/te)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(i){return this.cmp(i)<0};v.lessThanOrEqualTo=v.lte=function(i){return this.cmp(i)<1};v.logarithm=v.log=function(i){var o,e,t,r,n,s,a,u,c=this,l=c.constructor,f=l.precision,m=l.rounding,d=5;if(i==null)i=new l(10),o=!0;else{if(i=new l(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new l(NaN);o=i.eq(10)}if(e=c.d,c.s<0||!e||!e[0]||c.eq(1))return new l(e&&!e[0]?-1/0:c.s!=1?NaN:e?0:1/0);if(o)if(e.length>1)n=!0;else{for(r=e[0];r%10===0;)r/=10;n=r!==1}if(oe=!1,a=f+d,s=pt(c,a),t=o?sn(l,a+10):pt(i,a),u=Re(s,t,a,1),yr(u.d,r=f,m))do if(a+=10,s=pt(c,a),t=o?sn(l,a+10):pt(i,a),u=Re(s,t,a,1),!n){+Pe(u.d).slice(r+1,r+15)+1==1e14&&(u=ee(u,f+1,0));break}while(yr(u.d,r+=10,m));return oe=!0,ee(u,f,m)};v.minus=v.sub=function(i){var o,e,t,r,n,s,a,u,c,l,f,m,d=this,C=d.constructor;if(i=new C(i),!d.d||!i.d)return!d.s||!i.s?i=new C(NaN):d.d?i.s=-i.s:i=new C(i.d||d.s!==i.s?d:NaN),i;if(d.s!=i.s)return i.s=-i.s,d.plus(i);if(c=d.d,m=i.d,a=C.precision,u=C.rounding,!c[0]||!m[0]){if(m[0])i.s=-i.s;else if(c[0])i=new C(d);else return new C(u===3?-0:0);return oe?ee(i,a,u):i}if(e=xe(i.e/te),l=xe(d.e/te),c=c.slice(),n=l-e,n){for(f=n<0,f?(o=c,n=-n,s=m.length):(o=m,e=l,s=c.length),t=Math.max(Math.ceil(a/te),s)+2,n>t&&(n=t,o.length=1),o.reverse(),t=n;t--;)o.push(0);o.reverse()}else{for(t=c.length,s=m.length,f=t<s,f&&(s=t),t=0;t<s;t++)if(c[t]!=m[t]){f=c[t]<m[t];break}n=0}for(f&&(o=c,c=m,m=o,i.s=-i.s),s=c.length,t=m.length-s;t>0;--t)c[s++]=0;for(t=m.length;t>n;){if(c[--t]<m[t]){for(r=t;r&&c[--r]===0;)c[r]=tt-1;--c[r],c[t]+=tt}c[t]-=m[t]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--e;return c[0]?(i.d=c,i.e=Dn(c,e),oe?ee(i,a,u):i):new C(u===3?-0:0)};v.modulo=v.mod=function(i){var o,e=this,t=e.constructor;return i=new t(i),!e.d||!i.s||i.d&&!i.d[0]?new t(NaN):!i.d||e.d&&!e.d[0]?ee(new t(e),t.precision,t.rounding):(oe=!1,t.modulo==9?(o=Re(e,i.abs(),0,3,1),o.s*=i.s):o=Re(e,i,0,t.modulo,1),o=o.times(i),oe=!0,e.minus(o))};v.naturalExponential=v.exp=function(){return hs(this)};v.naturalLogarithm=v.ln=function(){return pt(this)};v.negated=v.neg=function(){var i=new this.constructor(this);return i.s=-i.s,ee(i)};v.plus=v.add=function(i){var o,e,t,r,n,s,a,u,c,l,f=this,m=f.constructor;if(i=new m(i),!f.d||!i.d)return!f.s||!i.s?i=new m(NaN):f.d||(i=new m(i.d||f.s===i.s?f:NaN)),i;if(f.s!=i.s)return i.s=-i.s,f.minus(i);if(c=f.d,l=i.d,a=m.precision,u=m.rounding,!c[0]||!l[0])return l[0]||(i=new m(f)),oe?ee(i,a,u):i;if(n=xe(f.e/te),t=xe(i.e/te),c=c.slice(),r=n-t,r){for(r<0?(e=c,r=-r,s=l.length):(e=l,t=n,s=c.length),n=Math.ceil(a/te),s=n>s?n+1:s+1,r>s&&(r=s,e.length=1),e.reverse();r--;)e.push(0);e.reverse()}for(s=c.length,r=l.length,s-r<0&&(r=s,e=l,l=c,c=e),o=0;r;)o=(c[--r]=c[r]+l[r]+o)/tt|0,c[r]%=tt;for(o&&(c.unshift(o),++t),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=Dn(c,t),oe?ee(i,a,u):i};v.precision=v.sd=function(i){var o,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Dt+i);return e.d?(o=Di(e.d),i&&e.e+1>o&&(o=e.e+1)):o=NaN,o};v.round=function(){var i=this,o=i.constructor;return ee(new o(i),i.e+1,o.rounding)};v.sine=v.sin=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+Math.max(e.e,e.sd())+te,t.rounding=1,e=Kc(t,xi(t,e)),t.precision=i,t.rounding=o,ee(ct>2?e.neg():e,i,o,!0)):new t(NaN)};v.squareRoot=v.sqrt=function(){var i,o,e,t,r,n,s=this,a=s.d,u=s.e,c=s.s,l=s.constructor;if(c!==1||!a||!a[0])return new l(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(oe=!1,c=Math.sqrt(+s),c==0||c==1/0?(o=Pe(a),(o.length+u)%2==0&&(o+="0"),c=Math.sqrt(o),u=xe((u+1)/2)-(u<0||u%2),c==1/0?o="5e"+u:(o=c.toExponential(),o=o.slice(0,o.indexOf("e")+1)+u),t=new l(o)):t=new l(c.toString()),e=(u=l.precision)+3;;)if(n=t,t=n.plus(Re(s,n,e+2,1)).times(.5),Pe(n.d).slice(0,e)===(o=Pe(t.d)).slice(0,e))if(o=o.slice(e-3,e+1),o=="9999"||!r&&o=="4999"){if(!r&&(ee(n,u+1,0),n.times(n).eq(s))){t=n;break}e+=4,r=1}else{(!+o||!+o.slice(1)&&o.charAt(0)=="5")&&(ee(t,u+1,1),i=!t.times(t).eq(s));break}return oe=!0,ee(t,u,l.rounding,i)};v.tangent=v.tan=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+10,t.rounding=1,e=e.sin(),e.s=1,e=Re(e,new t(1).minus(e.times(e)).sqrt(),i+10,0),t.precision=i,t.rounding=o,ee(ct==2||ct==4?e.neg():e,i,o,!0)):new t(NaN)};v.times=v.mul=function(i){var o,e,t,r,n,s,a,u,c,l=this,f=l.constructor,m=l.d,d=(i=new f(i)).d;if(i.s*=l.s,!m||!m[0]||!d||!d[0])return new f(!i.s||m&&!m[0]&&!d||d&&!d[0]&&!m?NaN:!m||!d?i.s/0:i.s*0);for(e=xe(l.e/te)+xe(i.e/te),u=m.length,c=d.length,u<c&&(n=m,m=d,d=n,s=u,u=c,c=s),n=[],s=u+c,t=s;t--;)n.push(0);for(t=c;--t>=0;){for(o=0,r=u+t;r>t;)a=n[r]+d[t]*m[r-t-1]+o,n[r--]=a%tt|0,o=a/tt|0;n[r]=(n[r]+o)%tt|0}for(;!n[--s];)n.pop();return o?++e:n.shift(),i.d=n,i.e=Dn(n,e),oe?ee(i,f.precision,f.rounding):i};v.toBinary=function(i,o){return ws(this,2,i,o)};v.toDecimalPlaces=v.toDP=function(i,o){var e=this,t=e.constructor;return e=new t(e),i===void 0?e:(Ie(i,0,Pt),o===void 0?o=t.rounding:Ie(o,0,8),ee(e,i+e.e+1,o))};v.toExponential=function(i,o){var e,t=this,r=t.constructor;return i===void 0?e=nt(t,!0):(Ie(i,0,Pt),o===void 0?o=r.rounding:Ie(o,0,8),t=ee(new r(t),i+1,o),e=nt(t,!0,i+1)),t.isNeg()&&!t.isZero()?"-"+e:e};v.toFixed=function(i,o){var e,t,r=this,n=r.constructor;return i===void 0?e=nt(r):(Ie(i,0,Pt),o===void 0?o=n.rounding:Ie(o,0,8),t=ee(new n(r),i+r.e+1,o),e=nt(t,!1,i+t.e+1)),r.isNeg()&&!r.isZero()?"-"+e:e};v.toFraction=function(i){var o,e,t,r,n,s,a,u,c,l,f,m,d=this,C=d.d,_=d.constructor;if(!C)return new _(d);if(c=e=new _(1),t=u=new _(0),o=new _(t),n=o.e=Di(C)-d.e-1,s=n%te,o.d[0]=Se(10,s<0?te+s:s),i==null)i=n>0?o:c;else{if(a=new _(i),!a.isInt()||a.lt(c))throw Error(Dt+a);i=a.gt(o)?n>0?o:c:a}for(oe=!1,a=new _(Pe(C)),l=_.precision,_.precision=n=C.length*te*2;f=Re(a,o,0,1,1),r=e.plus(f.times(t)),r.cmp(i)!=1;)e=t,t=r,r=c,c=u.plus(f.times(r)),u=r,r=o,o=a.minus(f.times(r)),a=r;return r=Re(i.minus(e),t,0,1,1),u=u.plus(r.times(c)),e=e.plus(r.times(t)),u.s=c.s=d.s,m=Re(c,t,n,1).minus(d).abs().cmp(Re(u,e,n,1).minus(d).abs())<1?[c,t]:[u,e],_.precision=l,oe=!0,m};v.toHexadecimal=v.toHex=function(i,o){return ws(this,16,i,o)};v.toNearest=function(i,o){var e=this,t=e.constructor;if(e=new t(e),i==null){if(!e.d)return e;i=new t(1),o=t.rounding}else{if(i=new t(i),o===void 0?o=t.rounding:Ie(o,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(oe=!1,e=Re(e,i,0,o,1).times(i),oe=!0,ee(e)):(i.s=e.s,e=i),e};v.toNumber=function(){return+this};v.toOctal=function(i,o){return ws(this,8,i,o)};v.toPower=v.pow=function(i){var o,e,t,r,n,s,a=this,u=a.constructor,c=+(i=new u(i));if(!a.d||!i.d||!a.d[0]||!i.d[0])return new u(Se(+a,c));if(a=new u(a),a.eq(1))return a;if(t=u.precision,n=u.rounding,i.eq(1))return ee(a,t,n);if(o=xe(i.e/te),o>=i.d.length-1&&(e=c<0?-c:c)<=Wc)return r=wi(u,a,e,t),i.s<0?new u(1).div(r):ee(r,t,n);if(s=a.s,s<0){if(o<i.d.length-1)return new u(NaN);if(i.d[o]&1||(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return e=Se(+a,c),o=e==0||!isFinite(e)?xe(c*(Math.log("0."+Pe(a.d))/Math.LN10+a.e+1)):new u(e+"").e,o>u.maxE+1||o<u.minE-1?new u(o>0?s/0:0):(oe=!1,u.rounding=a.s=1,e=Math.min(12,(o+"").length),r=hs(i.times(pt(a,t+e)),t),r.d&&(r=ee(r,t+5,1),yr(r.d,t,n)&&(o=t+10,r=ee(hs(i.times(pt(a,o+e)),o),o+5,1),+Pe(r.d).slice(t+1,t+15)+1==1e14&&(r=ee(r,t+1,0)))),r.s=s,oe=!0,u.rounding=n,ee(r,t,n))};v.toPrecision=function(i,o){var e,t=this,r=t.constructor;return i===void 0?e=nt(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(Ie(i,1,Pt),o===void 0?o=r.rounding:Ie(o,0,8),t=ee(new r(t),i,o),e=nt(t,i<=t.e||t.e<=r.toExpNeg,i)),t.isNeg()&&!t.isZero()?"-"+e:e};v.toSignificantDigits=v.toSD=function(i,o){var e=this,t=e.constructor;return i===void 0?(i=t.precision,o=t.rounding):(Ie(i,1,Pt),o===void 0?o=t.rounding:Ie(o,0,8)),ee(new t(e),i,o)};v.toString=function(){var i=this,o=i.constructor,e=nt(i,i.e<=o.toExpNeg||i.e>=o.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e};v.truncated=v.trunc=function(){return ee(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var i=this,o=i.constructor,e=nt(i,i.e<=o.toExpNeg||i.e>=o.toExpPos);return i.isNeg()?"-"+e:e};function Pe(i){var o,e,t,r=i.length-1,n="",s=i[0];if(r>0){for(n+=s,o=1;o<r;o++)t=i[o]+"",e=te-t.length,e&&(n+=bt(e)),n+=t;s=i[o],t=s+"",e=te-t.length,e&&(n+=bt(e))}else if(s===0)return"0";for(;s%10===0;)s/=10;return n+s}function Ie(i,o,e){if(i!==~~i||i<o||i>e)throw Error(Dt+i)}function yr(i,o,e,t){var r,n,s,a;for(n=i[0];n>=10;n/=10)--o;return--o<0?(o+=te,r=0):(r=Math.ceil((o+1)/te),o%=te),n=Se(10,te-o),a=i[r]%n|0,t==null?o<3?(o==0?a=a/100|0:o==1&&(a=a/10|0),s=e<4&&a==99999||e>3&&a==49999||a==5e4||a==0):s=(e<4&&a+1==n||e>3&&a+1==n/2)&&(i[r+1]/n/100|0)==Se(10,o-2)-1||(a==n/2||a==0)&&(i[r+1]/n/100|0)==0:o<4?(o==0?a=a/1e3|0:o==1?a=a/100|0:o==2&&(a=a/10|0),s=(t||e<4)&&a==9999||!t&&e>3&&a==4999):s=((t||e<4)&&a+1==n||!t&&e>3&&a+1==n/2)&&(i[r+1]/n/1e3|0)==Se(10,o-3)-1,s}function Hr(i,o,e){for(var t,r=[0],n,s=0,a=i.length;s<a;){for(n=r.length;n--;)r[n]*=o;for(r[0]+=ls.indexOf(i.charAt(s++)),t=0;t<r.length;t++)r[t]>e-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/e|0,r[t]%=e)}return r.reverse()}function qc(i,o){var e,t,r;if(o.isZero())return o;t=o.d.length,t<32?(e=Math.ceil(t/3),r=(1/wn(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),i.precision+=e,o=sr(i,1,o.times(r),new i(1));for(var n=e;n--;){var s=o.times(o);o=s.times(s).minus(s).times(8).plus(1)}return i.precision-=e,o}var Re=function(){function i(t,r,n){var s,a=0,u=t.length;for(t=t.slice();u--;)s=t[u]*r+a,t[u]=s%n|0,a=s/n|0;return a&&t.unshift(a),t}function o(t,r,n,s){var a,u;if(n!=s)u=n>s?1:-1;else for(a=u=0;a<n;a++)if(t[a]!=r[a]){u=t[a]>r[a]?1:-1;break}return u}function e(t,r,n,s){for(var a=0;n--;)t[n]-=a,a=t[n]<r[n]?1:0,t[n]=a*s+t[n]-r[n];for(;!t[0]&&t.length>1;)t.shift()}return function(t,r,n,s,a,u){var c,l,f,m,d,C,_,E,b,R,p,V,S,D,w,P,L,T,B,W,q=t.constructor,ie=t.s==r.s?1:-1,Z=t.d,G=r.d;if(!Z||!Z[0]||!G||!G[0])return new q(!t.s||!r.s||(Z?G&&Z[0]==G[0]:!G)?NaN:Z&&Z[0]==0||!G?ie*0:ie/0);for(u?(d=1,l=t.e-r.e):(u=tt,d=te,l=xe(t.e/d)-xe(r.e/d)),B=G.length,L=Z.length,b=new q(ie),R=b.d=[],f=0;G[f]==(Z[f]||0);f++);if(G[f]>(Z[f]||0)&&l--,n==null?(D=n=q.precision,s=q.rounding):a?D=n+(t.e-r.e)+1:D=n,D<0)R.push(1),C=!0;else{if(D=D/d+2|0,f=0,B==1){for(m=0,G=G[0],D++;(f<L||m)&&D--;f++)w=m*u+(Z[f]||0),R[f]=w/G|0,m=w%G|0;C=m||f<L}else{for(m=u/(G[0]+1)|0,m>1&&(G=i(G,m,u),Z=i(Z,m,u),B=G.length,L=Z.length),P=B,p=Z.slice(0,B),V=p.length;V<B;)p[V++]=0;W=G.slice(),W.unshift(0),T=G[0],G[1]>=u/2&&++T;do m=0,c=o(G,p,B,V),c<0?(S=p[0],B!=V&&(S=S*u+(p[1]||0)),m=S/T|0,m>1?(m>=u&&(m=u-1),_=i(G,m,u),E=_.length,V=p.length,c=o(_,p,E,V),c==1&&(m--,e(_,B<E?W:G,E,u))):(m==0&&(c=m=1),_=G.slice()),E=_.length,E<V&&_.unshift(0),e(p,_,V,u),c==-1&&(V=p.length,c=o(G,p,B,V),c<1&&(m++,e(p,B<V?W:G,V,u))),V=p.length):c===0&&(m++,p=[0]),R[f++]=m,c&&p[0]?p[V++]=Z[P]||0:(p=[Z[P]],V=1);while((P++<L||p[0]!==void 0)&&D--);C=p[0]!==void 0}R[0]||R.shift()}if(d==1)b.e=l,Ni=C;else{for(f=1,m=R[0];m>=10;m/=10)f++;b.e=f+l*d-1,ee(b,a?n+b.e+1:n,s,C)}return b}}();function ee(i,o,e,t){var r,n,s,a,u,c,l,f,m,d=i.constructor;e:if(o!=null){if(f=i.d,!f)return i;for(r=1,a=f[0];a>=10;a/=10)r++;if(n=o-r,n<0)n+=te,s=o,l=f[m=0],u=l/Se(10,r-s-1)%10|0;else if(m=Math.ceil((n+1)/te),a=f.length,m>=a)if(t){for(;a++<=m;)f.push(0);l=u=0,r=1,n%=te,s=n-te+1}else break e;else{for(l=a=f[m],r=1;a>=10;a/=10)r++;n%=te,s=n-te+r,u=s<0?0:l/Se(10,r-s-1)%10|0}if(t=t||o<0||f[m+1]!==void 0||(s<0?l:l%Se(10,r-s-1)),c=e<4?(u||t)&&(e==0||e==(i.s<0?3:2)):u>5||u==5&&(e==4||t||e==6&&(n>0?s>0?l/Se(10,r-s):0:f[m-1])%10&1||e==(i.s<0?8:7)),o<1||!f[0])return f.length=0,c?(o-=i.e+1,f[0]=Se(10,(te-o%te)%te),i.e=-o||0):f[0]=i.e=0,i;if(n==0?(f.length=m,a=1,m--):(f.length=m+1,a=Se(10,te-n),f[m]=s>0?(l/Se(10,r-s)%Se(10,s)|0)*a:0),c)for(;;)if(m==0){for(n=1,s=f[0];s>=10;s/=10)n++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;n!=a&&(i.e++,f[0]==tt&&(f[0]=1));break}else{if(f[m]+=a,f[m]!=tt)break;f[m--]=0,a=1}for(n=f.length;f[--n]===0;)f.pop()}return oe&&(i.e>d.maxE?(i.d=null,i.e=NaN):i.e<d.minE&&(i.e=0,i.d=[0])),i}function nt(i,o,e){if(!i.isFinite())return Li(i);var t,r=i.e,n=Pe(i.d),s=n.length;return o?(e&&(t=e-s)>0?n=n.charAt(0)+"."+n.slice(1)+bt(t):s>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(i.e<0?"e":"e+")+i.e):r<0?(n="0."+bt(-r-1)+n,e&&(t=e-s)>0&&(n+=bt(t))):r>=s?(n+=bt(r+1-s),e&&(t=e-r-1)>0&&(n=n+"."+bt(t))):((t=r+1)<s&&(n=n.slice(0,t)+"."+n.slice(t)),e&&(t=e-s)>0&&(r+1===s&&(n+="."),n+=bt(t))),n}function Dn(i,o){var e=i[0];for(o*=te;e>=10;e/=10)o++;return o}function sn(i,o,e){if(o>Qc)throw oe=!0,e&&(i.precision=e),Error(Vi);return ee(new i(rn),o,1,!0)}function et(i,o,e){if(o>ms)throw Error(Vi);return ee(new i(nn),o,e,!0)}function Di(i){var o=i.length-1,e=o*te+1;if(o=i[o],o){for(;o%10==0;o/=10)e--;for(o=i[0];o>=10;o/=10)e++}return e}function bt(i){for(var o="";i--;)o+="0";return o}function wi(i,o,e,t){var r,n=new i(1),s=Math.ceil(t/te+4);for(oe=!1;;){if(e%2&&(n=n.times(o),Oa(n.d,s)&&(r=!0)),e=xe(e/2),e===0){e=n.d.length-1,r&&n.d[e]===0&&++n.d[e];break}o=o.times(o),Oa(o.d,s)}return oe=!0,n}function Va(i){return i.d[i.d.length-1]&1}function Pi(i,o,e){for(var t,r=new i(o[0]),n=0;++n<o.length;)if(t=new i(o[n]),t.s)r[e](t)&&(r=t);else{r=t;break}return r}function hs(i,o){var e,t,r,n,s,a,u,c=0,l=0,f=0,m=i.constructor,d=m.rounding,C=m.precision;if(!i.d||!i.d[0]||i.e>17)return new m(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(o==null?(oe=!1,u=C):u=o,a=new m(.03125);i.e>-2;)i=i.times(a),f+=5;for(t=Math.log(Se(2,f))/Math.LN10*2+5|0,u+=t,e=n=s=new m(1),m.precision=u;;){if(n=ee(n.times(i),u,1),e=e.times(++l),a=s.plus(Re(n,e,u,1)),Pe(a.d).slice(0,u)===Pe(s.d).slice(0,u)){for(r=f;r--;)s=ee(s.times(s),u,1);if(o==null)if(c<3&&yr(s.d,u-t,d,c))m.precision=u+=10,e=n=a=new m(1),l=0,c++;else return ee(s,m.precision=C,d,oe=!0);else return m.precision=C,s}s=a}}function pt(i,o){var e,t,r,n,s,a,u,c,l,f,m,d=1,C=10,_=i,E=_.d,b=_.constructor,R=b.rounding,p=b.precision;if(_.s<0||!E||!E[0]||!_.e&&E[0]==1&&E.length==1)return new b(E&&!E[0]?-1/0:_.s!=1?NaN:E?0:_);if(o==null?(oe=!1,l=p):l=o,b.precision=l+=C,e=Pe(E),t=e.charAt(0),Math.abs(n=_.e)<15e14){for(;t<7&&t!=1||t==1&&e.charAt(1)>3;)_=_.times(i),e=Pe(_.d),t=e.charAt(0),d++;n=_.e,t>1?(_=new b("0."+e),n++):_=new b(t+"."+e.slice(1))}else return c=sn(b,l+2,p).times(n+""),_=pt(new b(t+"."+e.slice(1)),l-C).plus(c),b.precision=p,o==null?ee(_,p,R,oe=!0):_;for(f=_,u=s=_=Re(_.minus(1),_.plus(1),l,1),m=ee(_.times(_),l,1),r=3;;){if(s=ee(s.times(m),l,1),c=u.plus(Re(s,new b(r),l,1)),Pe(c.d).slice(0,l)===Pe(u.d).slice(0,l))if(u=u.times(2),n!==0&&(u=u.plus(sn(b,l+2,p).times(n+""))),u=Re(u,new b(d),l,1),o==null)if(yr(u.d,l-C,R,a))b.precision=l+=C,c=s=_=Re(f.minus(1),f.plus(1),l,1),m=ee(_.times(_),l,1),r=a=1;else return ee(u,b.precision=p,R,oe=!0);else return b.precision=p,u;u=c,r+=2}}function Li(i){return String(i.s*i.s/0)}function gs(i,o){var e,t,r;for((e=o.indexOf("."))>-1&&(o=o.replace(".","")),(t=o.search(/e/i))>0?(e<0&&(e=t),e+=+o.slice(t+1),o=o.substring(0,t)):e<0&&(e=o.length),t=0;o.charCodeAt(t)===48;t++);for(r=o.length;o.charCodeAt(r-1)===48;--r);if(o=o.slice(t,r),o){if(r-=t,i.e=e=e-t-1,i.d=[],t=(e+1)%te,e<0&&(t+=te),t<r){for(t&&i.d.push(+o.slice(0,t)),r-=te;t<r;)i.d.push(+o.slice(t,t+=te));o=o.slice(t),t=te-o.length}else t-=r;for(;t--;)o+="0";i.d.push(+o),oe&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function Xc(i,o){var e,t,r,n,s,a,u,c,l;if(o.indexOf("_")>-1){if(o=o.replace(/(\d)_(?=\d)/g,"$1"),Si.test(o))return gs(i,o)}else if(o==="Infinity"||o==="NaN")return+o||(i.s=NaN),i.e=NaN,i.d=null,i;if(Hc.test(o))e=16,o=o.toLowerCase();else if(Yc.test(o))e=2;else if(Gc.test(o))e=8;else throw Error(Dt+o);for(n=o.search(/p/i),n>0?(u=+o.slice(n+1),o=o.substring(2,n)):o=o.slice(2),n=o.indexOf("."),s=n>=0,t=i.constructor,s&&(o=o.replace(".",""),a=o.length,n=a-n,r=wi(t,new t(e),n,n*2)),c=Hr(o,e,tt),l=c.length-1,n=l;c[n]===0;--n)c.pop();return n<0?new t(i.s*0):(i.e=Dn(c,l),i.d=c,oe=!1,s&&(i=Re(i,r,a*4)),u&&(i=i.times(Math.abs(u)<54?Se(2,u):x.pow(2,u))),oe=!0,i)}function Kc(i,o){var e,t=o.d.length;if(t<3)return o.isZero()?o:sr(i,2,o,o);e=1.4*Math.sqrt(t),e=e>16?16:e|0,o=o.times(1/wn(5,e)),o=sr(i,2,o,o);for(var r,n=new i(5),s=new i(16),a=new i(20);e--;)r=o.times(o),o=o.times(n.plus(r.times(s.times(r).minus(a))));return o}function sr(i,o,e,t,r){var n,s,a,u,c=i.precision,l=Math.ceil(c/te);for(oe=!1,u=e.times(e),a=new i(t);;){if(s=Re(a.times(u),new i(o++*o++),c,1),a=r?t.plus(s):t.minus(s),t=Re(s.times(u),new i(o++*o++),c,1),s=a.plus(t),s.d[l]!==void 0){for(n=l;s.d[n]===a.d[n]&&n--;);if(n==-1)break}n=a,a=t,t=s,s=n}return oe=!0,s.d.length=l+1,s}function wn(i,o){for(var e=i;--o;)e*=i;return e}function xi(i,o){var e,t=o.s<0,r=et(i,i.precision,1),n=r.times(.5);if(o=o.abs(),o.lte(n))return ct=t?4:1,o;if(e=o.divToInt(r),e.isZero())ct=t?3:2;else{if(o=o.minus(e.times(r)),o.lte(n))return ct=Va(e)?t?2:3:t?4:1,o;ct=Va(e)?t?1:4:t?3:2}return o.minus(r).abs()}function ws(i,o,e,t){var r,n,s,a,u,c,l,f,m,d=i.constructor,C=e!==void 0;if(C?(Ie(e,1,Pt),t===void 0?t=d.rounding:Ie(t,0,8)):(e=d.precision,t=d.rounding),!i.isFinite())l=Li(i);else{for(l=nt(i),s=l.indexOf("."),C?(r=2,o==16?e=e*4-3:o==8&&(e=e*3-2)):r=o,s>=0&&(l=l.replace(".",""),m=new d(1),m.e=l.length-s,m.d=Hr(nt(m),10,r),m.e=m.d.length),f=Hr(l,10,r),n=u=f.length;f[--u]==0;)f.pop();if(!f[0])l=C?"0p+0":"0";else{if(s<0?n--:(i=new d(i),i.d=f,i.e=n,i=Re(i,m,e,t,0,r),f=i.d,n=i.e,c=Ni),s=f[e],a=r/2,c=c||f[e+1]!==void 0,c=t<4?(s!==void 0||c)&&(t===0||t===(i.s<0?3:2)):s>a||s===a&&(t===4||c||t===6&&f[e-1]&1||t===(i.s<0?8:7)),f.length=e,c)for(;++f[--e]>r-1;)f[e]=0,e||(++n,f.unshift(1));for(u=f.length;!f[u-1];--u);for(s=0,l="";s<u;s++)l+=ls.charAt(f[s]);if(C){if(u>1)if(o==16||o==8){for(s=o==16?4:3,--u;u%s;u++)l+="0";for(f=Hr(l,r,o),u=f.length;!f[u-1];--u);for(s=1,l="1.";s<u;s++)l+=ls.charAt(f[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)l="0"+l;l="0."+l}else if(++n>u)for(n-=u;n--;)l+="0";else n<u&&(l=l.slice(0,n)+"."+l.slice(n))}l=(o==16?"0x":o==2?"0b":o==8?"0o":"")+l}return i.s<0?"-"+l:l}function Oa(i,o){if(i.length>o)return i.length=o,!0}function Zc(i){return new this(i).abs()}function zc(i){return new this(i).acos()}function Jc(i){return new this(i).acosh()}function el(i,o){return new this(i).plus(o)}function tl(i){return new this(i).asin()}function rl(i){return new this(i).asinh()}function nl(i){return new this(i).atan()}function sl(i){return new this(i).atanh()}function al(i,o){i=new this(i),o=new this(o);var e,t=this.precision,r=this.rounding,n=t+4;return!i.s||!o.s?e=new this(NaN):!i.d&&!o.d?(e=et(this,n,1).times(o.s>0?.25:.75),e.s=i.s):!o.d||i.isZero()?(e=o.s<0?et(this,t,r):new this(0),e.s=i.s):!i.d||o.isZero()?(e=et(this,n,1).times(.5),e.s=i.s):o.s<0?(this.precision=n,this.rounding=1,e=this.atan(Re(i,o,n,1)),o=et(this,n,1),this.precision=t,this.rounding=r,e=i.s<0?e.minus(o):e.plus(o)):e=this.atan(Re(i,o,n,1)),e}function il(i){return new this(i).cbrt()}function ol(i){return ee(i=new this(i),i.e+1,2)}function ul(i,o,e){return new this(i).clamp(o,e)}function cl(i){if(!i||typeof i!="object")throw Error(Sn+"Object expected");var o,e,t,r=i.defaults===!0,n=["precision",1,Pt,"rounding",0,8,"toExpNeg",-Zt,0,"toExpPos",0,Zt,"maxE",0,Zt,"minE",-Zt,0,"modulo",0,9];for(o=0;o<n.length;o+=3)if(e=n[o],r&&(this[e]=fs[e]),(t=i[e])!==void 0)if(xe(t)===t&&t>=n[o+1]&&t<=n[o+2])this[e]=t;else throw Error(Dt+e+": "+t);if(e="crypto",r&&(this[e]=fs[e]),(t=i[e])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(Oi);else this[e]=!1;else throw Error(Dt+e+": "+t);return this}function ll(i){return new this(i).cos()}function fl(i){return new this(i).cosh()}function ji(i){var o,e,t;function r(n){var s,a,u,c=this;if(!(c instanceof r))return new r(n);if(c.constructor=r,Ma(n)){c.s=n.s,oe?!n.d||n.e>r.maxE?(c.e=NaN,c.d=null):n.e<r.minE?(c.e=0,c.d=[0]):(c.e=n.e,c.d=n.d.slice()):(c.e=n.e,c.d=n.d?n.d.slice():n.d);return}if(u=typeof n,u==="number"){if(n===0){c.s=1/n<0?-1:1,c.e=0,c.d=[0];return}if(n<0?(n=-n,c.s=-1):c.s=1,n===~~n&&n<1e7){for(s=0,a=n;a>=10;a/=10)s++;oe?s>r.maxE?(c.e=NaN,c.d=null):s<r.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[n]):(c.e=s,c.d=[n]);return}else if(n*0!==0){n||(c.s=NaN),c.e=NaN,c.d=null;return}return gs(c,n.toString())}else if(u!=="string")throw Error(Dt+n);return(a=n.charCodeAt(0))===45?(n=n.slice(1),c.s=-1):(a===43&&(n=n.slice(1)),c.s=1),Si.test(n)?gs(c,n):Xc(c,n)}if(r.prototype=v,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=cl,r.clone=ji,r.isDecimal=Ma,r.abs=Zc,r.acos=zc,r.acosh=Jc,r.add=el,r.asin=tl,r.asinh=rl,r.atan=nl,r.atanh=sl,r.atan2=al,r.cbrt=il,r.ceil=ol,r.clamp=ul,r.cos=ll,r.cosh=fl,r.div=ml,r.exp=hl,r.floor=gl,r.hypot=dl,r.ln=Cl,r.log=_l,r.log10=El,r.log2=Al,r.max=bl,r.min=yl,r.mod=Rl,r.mul=pl,r.pow=Nl,r.random=Vl,r.round=Ol,r.sign=Ml,r.sin=Sl,r.sinh=Dl,r.sqrt=wl,r.sub=Pl,r.sum=Ll,r.tan=xl,r.tanh=jl,r.trunc=Ul,i===void 0&&(i={}),i&&i.defaults!==!0)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],o=0;o<t.length;)i.hasOwnProperty(e=t[o++])||(i[e]=this[e]);return r.config(i),r}function ml(i,o){return new this(i).div(o)}function hl(i){return new this(i).exp()}function gl(i){return ee(i=new this(i),i.e+1,3)}function dl(){var i,o,e=new this(0);for(oe=!1,i=0;i<arguments.length;)if(o=new this(arguments[i++]),o.d)e.d&&(e=e.plus(o.times(o)));else{if(o.s)return oe=!0,new this(1/0);e=o}return oe=!0,e.sqrt()}function Ma(i){return i instanceof x||i&&i.toStringTag===Mi||!1}function Cl(i){return new this(i).ln()}function _l(i,o){return new this(i).log(o)}function Al(i){return new this(i).log(2)}function El(i){return new this(i).log(10)}function bl(){return Pi(this,arguments,"lt")}function yl(){return Pi(this,arguments,"gt")}function Rl(i,o){return new this(i).mod(o)}function pl(i,o){return new this(i).mul(o)}function Nl(i,o){return new this(i).pow(o)}function Vl(i){var o,e,t,r,n=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Ie(i,1,Pt),t=Math.ceil(i/te),this.crypto)if(crypto.getRandomValues)for(o=crypto.getRandomValues(new Uint32Array(t));n<t;)r=o[n],r>=429e7?o[n]=crypto.getRandomValues(new Uint32Array(1))[0]:a[n++]=r%1e7;else if(crypto.randomBytes){for(o=crypto.randomBytes(t*=4);n<t;)r=o[n]+(o[n+1]<<8)+(o[n+2]<<16)+((o[n+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(o,n):(a.push(r%1e7),n+=4);n=t/4}else throw Error(Oi);else for(;n<t;)a[n++]=Math.random()*1e7|0;for(t=a[--n],i%=te,t&&i&&(r=Se(10,te-i),a[n]=(t/r|0)*r);a[n]===0;n--)a.pop();if(n<0)e=0,a=[0];else{for(e=-1;a[0]===0;e-=te)a.shift();for(t=1,r=a[0];r>=10;r/=10)t++;t<te&&(e-=te-t)}return s.e=e,s.d=a,s}function Ol(i){return ee(i=new this(i),i.e+1,this.rounding)}function Ml(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Sl(i){return new this(i).sin()}function Dl(i){return new this(i).sinh()}function wl(i){return new this(i).sqrt()}function Pl(i,o){return new this(i).sub(o)}function Ll(){var i=0,o=arguments,e=new this(o[i]);for(oe=!1;e.s&&++i<o.length;)e=e.plus(o[i]);return oe=!0,ee(e,this.precision,this.rounding)}function xl(i){return new this(i).tan()}function jl(i){return new this(i).tanh()}function Ul(i){return ee(i=new this(i),i.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var x=v.constructor=ji(fs);rn=new x(rn);nn=new x(nn);function vl(i,o){const e=i+o;return Number.isSafeInteger(e)?e:new x(i).add(o).toNumber()}function Tl(i,o){const e=i-o;return Number.isSafeInteger(e)?e:new x(i).sub(o).toNumber()}function fr(i,o){const e=i*o;return Number.isSafeInteger(e)?e:new x(i).mul(o).toNumber()}function Bl(i,o){const e=i/o;return Number.isSafeInteger(e)?e:new x(i).div(o).toNumber()}function Vt(i,o){const e=10**Math.trunc(o),t=Pn(i,e);return Math.round(fr(i,e)+t)/e}function ke(i,o){const e=10**Math.trunc(o),t=Pn(i,e);return Math.floor(fr(i,e)+t)/e}function Be(i,o){const e=10**Math.trunc(o),t=Pn(i,e);return Math.ceil(fr(i,e)-t)/e}function Pn(i,o){return Number.EPSILON*Math.max(1,Math.abs(fr(i,o)))}function Sa(i,o){return i-o*Math.floor(i/o)}function Il(i,o){return i**o}function Fl(i){return Math.sqrt(i)}function Da(i,o){return i===o}function kl(i,o){return i>o}function $l(i,o){return i>=o}function Yl(i,o){return i<o}function Hl(i,o){return i<=o}function ds(i,o=15){return Number.parseFloat(i.toPrecision(o))}function Gl(i,o,e=Number.EPSILON){return Math.abs(i-o)<e}function Ui(i,o=12,e=1e-10){const t=ds(i,o);return Gl(i,t,e)?t:ds(i)}function Wl(i){return i-Math.trunc(i)}const _n=class _n extends ht{static create(){return this._instance=this._instance||new _n(0),this._instance}isNull(){return!0}plus(o){return y.create(0).plus(o)}minus(o){return y.create(0).minus(o)}multiply(o){return y.create(0).multiply(o)}divided(o){return y.create(0).divided(o)}mod(o){return y.create(0).mod(o)}compare(o,e){return o.isString()?j.create("").compare(o,e):o.isBoolean()?k.create(!1).compare(o,e):y.create(0).compare(o,e)}concatenateFront(o){return o.isArray()?o.concatenateBack(j.create("")):j.create(this.concatenate(o.getValue(),Je.FRONT))}concatenateBack(o){return o.isArray()?o.concatenateFront(j.create("")):j.create(this.concatenate(o.getValue(),Je.BACK))}plusBy(o){return y.create(0).plusBy(o)}minusBy(o){return y.create(0).minusBy(o)}multiplyBy(o){return y.create(0).multiplyBy(o)}dividedBy(o){return y.create(0).dividedBy(o)}compareBy(o,e){return typeof o=="string"?j.create("").compareBy(o,e):typeof o=="boolean"?k.create(!1).compareBy(o,e):y.create(0).compareBy(o,e)}pow(o){return y.create(0).pow(o)}sqrt(){return y.create(0).sqrt()}cbrt(){return y.create(0).cbrt()}cos(){return y.create(0).cos()}cosh(){return y.create(0).cosh()}acos(){return y.create(0).acos()}acosh(){return y.create(0).acosh()}sin(){return y.create(0).sin()}sinh(){return y.create(0).sinh()}asin(){return y.create(0).asin()}asinh(){return y.create(0).asinh()}tan(){return y.create(0).tan()}tanh(){return y.create(0).tanh()}atan(){return y.create(0).atan()}atan2(o){return y.create(0).atan2(o)}atanh(){return y.create(0).atanh()}log(){return g.create(h.NUM)}log10(){return g.create(h.NUM)}exp(){return y.create(0).exp()}abs(){return y.create(0).abs()}round(o){return y.create(0).round(o)}floor(o){return y.create(0).floor(o)}ceil(o){return y.create(0).ceil(o)}convertToNumberObjectValue(){return y.create(0)}convertToBooleanObjectValue(){return k.create(!1)}};A(_n,"_instance");let ae=_n;const Tt=class Tt extends ht{constructor(e){super(e);A(this,"_value",!1);this._value=e}static create(e){return e?(this._instanceTrue=this._instanceTrue||new Tt(!0),this._instanceTrue):(this._instanceFalse=this._instanceFalse||new Tt(!1),this._instanceFalse)}getValue(){return this._value}isBoolean(){return!0}getNegative(){const e=this.getValue();let t=0;return e&&(t=1),y.create(-t)}getReciprocal(){return this.getValue()?y.create(1):g.create(h.DIV_BY_ZERO)}plus(e){return this._convertToNumber().plus(e)}minus(e){return this._convertToNumber().minus(e)}multiply(e){return this._convertToNumber().multiply(e)}divided(e){return this._convertToNumber().divided(e)}mod(e){return this._convertToNumber().mod(e)}compare(e,t){return e.isArray()?e.compare(this,Ds(t)):e.isNull()?this._convertToNumber().compare(e,t):this.compareBy(e.getValue(),t)}compareBy(e,t){let r=!1;if(typeof e=="string"||typeof e=="number")r=this._compareString(t);else if(typeof e=="boolean"){const n=y.create(e?1:0);return this._convertToNumber().compare(n,t)}return Tt.create(r)}_compareString(e){switch(e){case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!0;case $.EQUALS:case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:case $.NOT_EQUAL:return!1}}concatenateFront(e){return this._convertToNumber().concatenateFront(e)}concatenateBack(e){return this._convertToNumber().concatenateBack(e)}_convertToNumber(){const e=this.getValue();let t=0;return e&&(t=1),y.create(t)}pow(e){return this._convertToNumber().pow(e)}sqrt(){return this._convertToNumber().sqrt()}cbrt(){return this._convertToNumber().cbrt()}cos(){return this._convertToNumber().cos()}cosh(){return this._convertToNumber().cosh()}acos(){return this._convertToNumber().acos()}acosh(){return this._convertToNumber().acosh()}sin(){return this._convertToNumber().sin()}sinh(){return this._convertToNumber().sinh()}asin(){return this._convertToNumber().asin()}asinh(){return this._convertToNumber().asinh()}tan(){return this._convertToNumber().tan()}tanh(){return this._convertToNumber().tanh()}atan(){return this._convertToNumber().atan()}atan2(e){return this._convertToNumber().atan2(e)}atanh(){return this._convertToNumber().atanh()}log(){return this._convertToNumber().log()}log10(){return this._convertToNumber().log10()}exp(){return this._convertToNumber().exp()}abs(){return this._convertToNumber().abs()}round(e){return this._convertToNumber().round(e)}floor(e){return this._convertToNumber().floor(e)}ceil(e){return this._convertToNumber().ceil(e)}convertToNumberObjectValue(){return xn(this.getValue())}convertToBooleanObjectValue(){return this}};A(Tt,"_instanceTrue"),A(Tt,"_instanceFalse");let k=Tt;class y extends ht{constructor(e){super(e);A(this,"_value",0);this._value=Number(e)}static create(e,t=""){const r=new y(e);return t&&r.setPattern(t),r}getValue(){return this._value}setValue(e){this._value=e}isNumber(){return!0}getNegative(){return y.create(0).minus(this)}getReciprocal(){return y.create(1).divided(this)}plus(e){if(e.isArray())return e.plus(this);let t=this.plusBy(e.getValue());if(t.isError())return t;const r=vr(this.getPattern(),e.getPattern(),X.PLUS);return t=y.create(Number(t.getValue()),r),t}equalZero(){return this._value===0}minus(e){if(e.isArray()){const n=e.getNegative();return n.isError()?n:n.plus(this)}let t=this.minusBy(e.getValue());if(t.isError())return t;const r=vr(this.getPattern(),e.getPattern(),X.MINUS);return t=y.create(Number(t.getValue()),r),t}multiply(e){if(e.isArray())return e.multiply(this);let t=this.multiplyBy(e.getValue());if(t.isError())return t;const r=vr(this.getPattern(),e.getPattern(),X.MULTIPLY);return t=y.create(Number(t.getValue()),r),t}divided(e){if(e.isArray()){const n=e.getReciprocal();return n.isError()?n:n.multiply(this)}let t=this.dividedBy(e.getValue());if(t.isError())return t;const r=vr(this.getPattern(),e.getPattern(),X.DIVIDED);return t=y.create(Number(t.getValue()),r),t}mod(e){if(e.isArray())return e.modInverse(this);const t=this.getValue(),r=e.getValue();if(e.isNull())return g.create(h.DIV_BY_ZERO);if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(r===0)return g.create(h.DIV_BY_ZERO);if(!Number.isFinite(t)||!Number.isFinite(r)||Math.abs(r)*11259e8<=Math.abs(t))return g.create(h.NUM);const n=Sa(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}if(typeof r=="boolean"){const n=r?1:0;return n===0?g.create(h.DIV_BY_ZERO):y.create(Sa(t,n))}return this}concatenateFront(e){return e.isArray()?e.concatenateBack(this):j.create(this.concatenate(e.getValue(),Je.FRONT))}concatenateBack(e){return e.isArray()?e.concatenateFront(this):j.create(this.concatenate(e.getValue(),Je.BACK))}compare(e,t){return e.isArray()?e.compare(this,Ds(t)):this.compareBy(e.getValue(),t)}plusBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=vl(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}minusBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=Tl(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}multiplyBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=fr(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}dividedBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);if(r===0)return g.create(h.DIV_BY_ZERO);const n=Bl(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}compareBy(e,t){const r=this.getValue();let n=!1;return typeof e=="string"?n=this._compareString(t):typeof e=="number"?n=this._compareNumber(r,e,t):typeof e=="boolean"&&(n=this._compareBoolean(t)),k.create(n)}_compareString(e){switch(e){case $.EQUALS:case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!1;case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:case $.NOT_EQUAL:return!0}}_compareNumber(e,t,r){return!Number.isFinite(e)||!Number.isFinite(t)?this._compareInfinity(e,t,r):this._compareFiniteNumber(e,t,r)}_compareFiniteNumber(e,t,r){switch(r){case $.EQUALS:return Da(e,t);case $.GREATER_THAN:return kl(e,t);case $.GREATER_THAN_OR_EQUAL:return $l(e,t);case $.LESS_THAN:return Yl(e,t);case $.LESS_THAN_OR_EQUAL:return Hl(e,t);case $.NOT_EQUAL:return!Da(e,t)}}_compareBoolean(e){switch(e){case $.EQUALS:case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!1;case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:case $.NOT_EQUAL:return!0}}pow(e){if(e.isArray())return e.powInverse(this);if(this.isError())return this;const t=this.getValue();let r=e;if(e.isString()&&(r=e.convertToNumberObjectValue()),r.isError())return r;const n=+r.getValue();if(Number.isNaN(n))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(n))return g.create(h.NUM);if(t===0)return n<0?g.create(h.DIV_BY_ZERO):n===0?g.create(h.NUM):y.create(0);const s=Il(t,n);return Number.isFinite(s)?y.create(s):g.create(h.NUM)}sqrt(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Fl(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cbrt(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cbrt(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cos(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cos(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cosh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cosh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}acos(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.acos(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}acosh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.acosh(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}sin(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.sin(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}sinh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.sinh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}asin(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.asin(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}asinh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.asinh(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}tan(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.tan(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}tanh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.tanh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}atan(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.atan(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}atan2(e){if(e.isArray())return e.atan2Inverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);if(t===0&&r===0)return g.create(h.DIV_BY_ZERO);const n=Math.atan2(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Math.atan2(t,r?1:0)):this}atanh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.atanh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}log(){const e=this.getValue();if(typeof e=="number"&&e<=0||!Number.isFinite(e))return g.create(h.NUM);const t=Math.log(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}log10(){const e=this.getValue();if(typeof e=="number"&&e<=0||!Number.isFinite(e))return g.create(h.NUM);const t=Math.log10(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}exp(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.exp(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}abs(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.abs(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}round(e){if(e.isArray())return e.roundInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-Vt(Math.abs(t),r):Vt(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Vt(t,r?1:0)):this}floor(e){if(e.isArray())return e.floorInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-ke(Math.abs(t),r):ke(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(ke(t,r?1:0)):this}ceil(e){if(e.isArray())return e.ceilInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-Be(Math.abs(t),r):Be(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Be(t,r?1:0)):this}convertToNumberObjectValue(){return this}convertToBooleanObjectValue(){return Ln(!0)}_compareInfinity(e,t,r){let n=!1;switch(r){case $.EQUALS:n=e===t;break;case $.GREATER_THAN:n=e>t;break;case $.GREATER_THAN_OR_EQUAL:n=e>=t;break;case $.LESS_THAN:n=e<t;break;case $.LESS_THAN_OR_EQUAL:n=e<=t;break;case $.NOT_EQUAL:n=e!==t;break}return n}}const Ql=1e5,wa=new ft(Ql);class j extends ht{constructor(e){super(e);A(this,"_value");this._value=e}static create(e){const t=wa.get(e);if(t)return t;const r=new j(e);return wa.set(e,r),r}getValue(){return this._value}isString(){return!0}concatenateFront(e){return e.isArray()?e.concatenateBack(this):j.create(this.concatenate(e.getValue(),Je.FRONT))}concatenateBack(e){return e.isArray()?e.concatenateFront(this):j.create(this.concatenate(e.getValue(),Je.BACK))}plus(e){return this.convertToNumberObjectValue().plus(e)}minus(e){return this.convertToNumberObjectValue().minus(e)}multiply(e){return this.convertToNumberObjectValue().multiply(e)}divided(e){return this.convertToNumberObjectValue().divided(e)}compare(e,t,r){return e.isArray()?e.compare(this,Ds(t),r):this.compareBy(e.getValue(),t,r)}compareBy(e,t,r=!1){let n=this.getValue(),s=!1;if(typeof e=="string"){let a=e;if(r||(n=n.toLocaleLowerCase(),a=a.toLocaleLowerCase()),Fc(a))return this._checkWildcard(a,t);s=this._compareString(n,a,t)}else typeof e=="number"?s=this._compareNumber(t):typeof e=="boolean"&&(s=this._compareBoolean(t));return k.create(s)}_compareString(e,t,r){switch(r){case $.EQUALS:return e===t;case $.GREATER_THAN:return e>t;case $.GREATER_THAN_OR_EQUAL:return e>=t;case $.LESS_THAN:return e<t;case $.LESS_THAN_OR_EQUAL:return e<=t;case $.NOT_EQUAL:return e!==t}}_compareNumber(e){switch(e){case $.NOT_EQUAL:case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!0;case $.EQUALS:case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:return!1}}_compareBoolean(e){switch(e){case $.EQUALS:case $.GREATER_THAN:case $.GREATER_THAN_OR_EQUAL:return!1;case $.LESS_THAN:case $.LESS_THAN_OR_EQUAL:case $.NOT_EQUAL:return!0}}convertToNumberObjectValue(){return xn(this.getValue())}convertToBooleanObjectValue(){return k.create(!0)}_checkWildcard(e,t){const r=this.getValue().toLocaleLowerCase(),n=kc(r,e,t);return k.create(n)}}function Ln(i){if(typeof i=="boolean")return k.create(i);let o=!1;if(typeof i=="string"){const e=i.toLocaleUpperCase();e===Ot.TRUE?o=!0:e===Ot.FALSE&&(o=!1)}else i===1?o=!0:o=!1;return k.create(o)}function ql(i){let o=i.toString();return o.charAt(0)==='"'&&o.charAt(o.length-1)==='"'&&(o=o.slice(1,-1),o=o.replace(/""/g,'"')),j.create(o)}function xn(i,o=""){if(typeof i=="boolean"){let e=0;return i&&(e=1),y.create(e,o)}else{if(typeof i=="number")return Number.isFinite(i)?y.create(i,o):g.create(h.NUM);if(M.isRealNum(i))return y.create(Number(i),o)}return g.create(h.VALUE)}function Xl(i){return""}function vi(i=[]){const o=[];for(let e=0;e<i.length;e++){const t=i[e];o[e]==null&&(o[e]=[]);for(let r=0;r<t.length;r++){const n=t[r];o[e][r]=lt.create(n)}}return o}function Kl(i=[]){const o=[];for(let e=0;e<i.length;e++){const t=i[e];o[e]==null&&(o[e]=[]);for(let r=0;r<t.length;r++){const n=t[r];n==null?o[e][r]=null:n.isError()?o[e][r]=n.getErrorType():o[e][r]=n.getValue()}}return o}class K extends ht{constructor(e){super(typeof e=="string"?e:Xl());A(this,"_values",[]);A(this,"_rowCount",-1);A(this,"_columnCount",-1);A(this,"_unitId","");A(this,"_sheetId","");A(this,"_currentRow",-1);A(this,"_currentColumn",-1);A(this,"_sliceCache",new Map);A(this,"_flattenCache");A(this,"_defaultValue",null);A(this,"_flattenPosition");this._values=this._formatValue(e)}static create(e){return new K(e)}static createByArray(e){const r={calculateValueList:vi(e),rowCount:e.length,columnCount:e[0].length||0,unitId:"",sheetId:"",row:-1,column:-1};return new K(r)}dispose(){this._values=[],this._defaultValue=null,this._flattenPosition=null,this._clearCache()}clone(){return this.map(e=>e)}getRowCount(){return this._rowCount}setRowCount(e){this._rowCount=e}getColumnCount(){return this._columnCount}setColumnCount(e){this._columnCount=e}setCurrent(e,t){this._currentRow=e,this._currentColumn=t}setUnitId(e){this._unitId=e}getUnitId(){return this._unitId}setSheetId(e){this._sheetId=e}getSheetId(){return this._sheetId}getCurrentRow(){return this._currentRow}getCurrentColumn(){return this._currentColumn}getArrayValue(){return this._values}setArrayValue(e){this._clearCache(),this._values=e}isArray(){return!0}setDefaultValue(e){this._defaultValue=e}get(e,t){var r;return((r=this._values[e])==null?void 0:r[t])||this._defaultValue}getRealValue(e,t){const r=this._values[e];if(r==null)return null;const n=r[t];return n==null?null:n}getValueOrDefault(e,t){return this.get(e,t)||this._defaultValue}set(e,t,r){if(e>=this._rowCount||t>=this._columnCount)throw new Error("Exceeding array bounds.");this._clearCache(),this._values[e][t]=r}getRangePosition(){const t=this.getRowCount(),r=0,n=this.getColumnCount();return{startRow:0,endRow:t-1,startColumn:r,endColumn:n-1}}iterator(e){var u;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=this.getArrayValue();for(let c=t;c<=r;c++)for(let l=n;l<=s;l++)if(e(((u=a[c])==null?void 0:u[l])||this._defaultValue,c,l)===!1)return}iteratorReverse(e){var u;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=this.getArrayValue();for(let c=r;c>=t;c--)for(let l=s;l>=n;l--)if(e(((u=a[c])==null?void 0:u[l])||this._defaultValue,c,l)===!1)return}getLastTruePosition(){let e;return this.iteratorReverse((t,r,n)=>{if(t!=null&&t.isBoolean()&&t.getValue()===!0)return e={row:r,column:n},!1}),e}getFirstTruePosition(){let e;return this.iterator((t,r,n)=>{if(t!=null&&t.isBoolean()&&t.getValue()===!0)return e={row:r,column:n},!1}),e}getFirstCell(){const{startRow:e,startColumn:t}=this.getRangePosition();return this.get(e,t)||this._defaultValue||ae.create()}getLastCell(){const{endRow:e,endColumn:t}=this.getRangePosition();return this.get(e,t)||this._defaultValue||ae.create()}pick(e){const t=this.pickRaw(e);return this._createNewArray(t,1,t[0].length)}pickRaw(e){const t=e.getRowCount(),r=e.getColumnCount();if(t!==this._rowCount||r!==this._columnCount)return[[ae.create()]];const n=[];n[0]=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.get(s,a);if(!(u==null||u.isError())&&u.getValue()===!0){const c=this.get(s,a);n[0].push(c)}}return n}flatten(){if(this._flattenCache!=null)return this._flattenCache;const e=[];e[0]=[];for(let r=0;r<this._rowCount;r++)for(let n=0;n<this._columnCount;n++){const s=this.get(r,n);e[0].push(s)}const t=this._createNewArray(e,1,e[0].length);return t.setDefaultValue(this._defaultValue),this._flattenCache=t,t}flattenPosition(){if(this._flattenPosition!=null)return this._flattenPosition;const e=[],t=[],r=[],n=[];let s=0;for(let u=0;u<this._rowCount;u++)for(let c=0;c<this._columnCount;c++){const l=this.get(u,c);if(l==null||l.isError()||l.isNull()){s++;continue}l.isString()?(e.push(l),r.push(s++)):(t.push(l),n.push(s++))}const a={stringArray:e,numberArray:t,stringPosition:r,numberPosition:n};return this._flattenPosition=a,a}slice(e,t){let r=0,n=this._rowCount,s=1,a=0,u=this._columnCount,c=1;if(e!=null&&(r=e[0]||0,n=e[1]||this._rowCount,s=e[2]||1),t!=null&&(a=t[0]||0,u=t[1]||this._columnCount,c=t[2]||1),r>=this._rowCount||a>=this._columnCount)return;const l=`${r}_${n}_${s}_${a}_${u}_${c}`,f=this._sliceCache.get(l);if(f!=null)return f;const m=[],d=this._values;let C=0,_=0;for(let p=r;p<n;p+=s){_=0,m[C]==null&&(m[C]=[]);for(let V=a;V<u;V+=c){if(!d[p])return;let S=d[p][V]||this._defaultValue;S==null&&(S=ae.create()),m[C][_]=S,_++}C++}if(m.length===0||m[0].length===0)return;const E=s>1?-1:r+this._currentRow,b=c>1?-1:a+this._currentColumn,R=this._createNewArray(m,m.length,m[0].length,E,b);return R.setDefaultValue(this._defaultValue),this._sliceCache.set(l,R),R}sortByRow(e){const t=this._transposeArray(this._values);t.sort(this._sort(e)),this._clearCache(),this._values=this._transposeArray(t)}sortByColumn(e){this._clearCache(),this._values.sort(this._sort(e))}transpose(){const e=this._transposeArray(this._values),t=this._rowCount,r=this._columnCount,n=this._createNewArray(e,r,t);return n.setDefaultValue(this._defaultValue),n}orderSearch(e,t=Oe.MIN,r=!1,n=!1){let s,a,u,c;const l=(f,m,d)=>{if(f==null)return!0;let C;if(n===!0?C=f.compare(e,$.EQUALS):C=f.isEqual(e),(C==null?void 0:C.getValue())===!0)return s=f,u={row:m,column:d},!1;t===Oe.MAX?f.isGreaterThan(e).getValue()===!0&&(a==null||f.minus(e).abs().isLessThanOrEqual(a.minus(e).abs()).getValue()===!0)&&(a=f,c={row:m,column:d}):t===Oe.MIN&&f.isLessThan(e).getValue()===!0&&(a==null||f.minus(e).abs().isLessThanOrEqual(a.minus(e).abs()).getValue()===!0)&&(a=f,c={row:m,column:d})};if(r?this.iteratorReverse((f,m,d)=>l(f,m,d)):this.iterator((f,m,d)=>l(f,m,d)),s!=null)return u;if(a!=null)return c}binarySearch(e,t=Ut.MIN,r=Oe.MIN){if(e.isError())return;const{stringArray:n,stringPosition:s,numberArray:a,numberPosition:u}=this.flattenPosition();return e.isString()?this._binarySearch(e,n,s,t,r):this._binarySearch(e,a,u,t,r)}_binarySearch(e,t,r,n=Ut.MIN,s=Oe.MIN){const a=tn(),u=Number(e.getValue()),c=!Number.isNaN(u);let l=0,f=t.length-1,m=-1,d=-1,C=-1;for(;l<=f;){const _=Math.floor((l+f)/2),E=t[_];let b;if(E.isNull())b=n===Ut.MIN?1:-1;else{const R=E.getValue();if(c){const p=Number(R);b=Number.isNaN(p)?1:Math.sign(p-u)}else b=a(R.toString().toLocaleLowerCase(),e.getValue().toString().toLocaleLowerCase())}if(n===Ut.MAX&&(b=-b),b===0){m=_;break}b<0?(d=_,l=_+1):(C=_,f=_-1)}if(s===Oe.NORMAL)return m!==-1?r[m]:void 0;if(s===Oe.MIN)return m!==-1?r[m]:n===Ut.MIN?r[d]:r[C];if(s===Oe.MAX)return m!==-1?r[m]:n===Ut.MIN?r[C]:r[d]}sum(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isString()||t.isBoolean()||t.isNull())return!0;if(t.isError())return e=t,!1;e=e.plus(t)}),e}max(){let e=y.create(Number.NEGATIVE_INFINITY);return this.iterator(t=>{if(t==null)return!0;if(t.isError())return e=t,!1;if(t.isString()||t.isNull()||t.isBoolean())return!0;e.isLessThan(t).getValue()&&(e=t)}),e}min(){let e=y.create(Number.POSITIVE_INFINITY);return this.iterator(t=>{if(t==null)return!0;if(t.isError())return e=t,!1;if(t.isString()||t.isNull()||t.isBoolean())return!0;e.isGreaterThan(t).getValue()&&(e=t)}),e}count(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isError()||t.isString()||t.isNull()||t.isBoolean())return!0;e=e.plusBy(1)}),e}countA(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isNull())return!0;e=e.plusBy(1)}),e}countBlank(){let e=y.create(0);return this.iterator(t=>{(t==null||t.isNull()||t.getValue()==="")&&(e=e.plusBy(1))}),e}getNegative(){return K.create("{0}").minus(this)}getReciprocal(){return K.create("{1}").divided(this)}plus(e){return this._batchOperator(e,1)}minus(e){return this._batchOperator(e,0)}multiply(e){return this._batchOperator(e,2)}divided(e){return this._batchOperator(e,3)}mod(e){return this._batchOperator(e,4)}modInverse(e){return this.map(t=>t.isError()?t:e.mod(t))}compare(e,t,r){return this._batchOperator(e,5,t,r)}concatenateFront(e){return this._batchOperator(e,6)}concatenateBack(e){return this._batchOperator(e,7)}map(e){const t=(r,n,s)=>r==null?ae.create():r.isError()?r:e(r,n,s);return this.mapValue(t)}mapValue(e){var s;const t=this._rowCount,r=this._columnCount,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){const l=(s=this._values)==null?void 0:s[a];if(l==null)u[c]=g.create(h.VALUE);else{const f=l[c]||this._defaultValue;f?u[c]=e(f,a,c):u[c]=ae.create()}}n.push(u)}return this._createNewArray(n,t,r)}pow(e){return this._batchOperator(e,8)}powInverse(e){return this.map(t=>t.isError()?t:e.pow(t))}sqrt(){return this.map(e=>e.isError()?e:e.sqrt())}cbrt(){return this.map(e=>e.isError()?e:e.cbrt())}cos(){return this.map(e=>e.isError()?e:e.cos())}cosh(){return this.map(e=>e.isError()?e:e.cosh())}acos(){return this.map(e=>e.isError()?e:e.acos())}acosh(){return this.map(e=>e.isError()?e:e.acosh())}sin(){return this.map(e=>e.isError()?e:e.sin())}sinh(){return this.map(e=>e.isError()?e:e.sinh())}asin(){return this.map(e=>e.isError()?e:e.asin())}asinh(){return this.map(e=>e.isError()?e:e.asinh())}tan(){return this.map(e=>e.isError()?e:e.tan())}tanh(){return this.map(e=>e.isError()?e:e.tanh())}atan(){return this.map(e=>e.isError()?e:e.atan())}atanh(){return this.map(e=>e.isError()?e:e.atanh())}atan2(e){return this._batchOperator(e,12)}atan2Inverse(e){return this.map(t=>t.isError()?t:e.atan2(t))}mean(e=0){const t=this.sum(),r=this.count();return t.divided(e===0?r:r.minusBy(1))}median(){const e=this.flattenPosition().numberArray,t=this._createNewArray([e],1,e.length),r=t.getColumnCount();if(r<=1)return t.get(0,0)||ae.create();if(t.sortByRow(0),r%2===0){const n=t.get(0,r/2)||ae.create(),s=t.get(0,r/2-1)||ae.create();return n.plus(s).divided(y.create(2))}return t.get(0,(r-1)/2)||ae.create()}var(e=0){const t=this.mean(),r=[[]];this.iterator(l=>{if(l==null||l.isError()||l.isString()||l.isBoolean()||l.isNull())return;const f=l.minus(t).pow(y.create(2));f.isError()||r[0].push(f)});const{_unitId:n,_sheetId:s,_currentRow:a,_currentColumn:u}=this;return K.create({calculateValueList:r,rowCount:1,columnCount:r[0].length,unitId:n,sheetId:s,row:a,column:u}).mean(e)}std(e=0){const t=this.var(e);return t.isError()?t:t.sqrt()}log(){return this.map(e=>e.isError()?e:e.log())}log10(){return this.map(e=>e.isError()?e:e.log10())}exp(){return this.map(e=>e.isError()?e:e.exp())}abs(){return this.map(e=>e.isError()?e:e.abs())}round(e){return this._batchOperator(e,9)}roundInverse(e){return this.map(t=>t.isError()?t:e.round(t))}floor(e){return this._batchOperator(e,10)}floorInverse(e){return this.map(t=>t.isError()?t:e.floor(t))}ceil(e){return this._batchOperator(e,11)}ceilInverse(e){return this.map(t=>t.isError()?t:e.ceil(t))}toValue(){return Kl(this._values)}_clearCache(){this._flattenCache=null,this._sliceCache.clear()}_sort(e){const t=tn();return(r,n)=>{const s=r[e],a=n[e];return s==null?1:a==null?-1:s.isError()&&s.isError()?0:s.isError()?1:a.isError()?-1:t(s.getValue(),a.getValue())}}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}_batchOperator(e,t,r,n){const s=[];let a=this._rowCount,u=this._columnCount;if(e.isArray()){const f=e.getRowCount(),m=e.getColumnCount();if(a=Math.max(f,a),u=Math.max(m,u),f===1&&m===1){const d=e.getFirstCell();for(let C=0;C<u;C++)s.push(d)}else if(f===1&&this._columnCount>1){const d=e.getArrayValue();for(let C=0;C<u;C++)s.push(d[0][C])}else return this._batchOperatorArray(e,t,r,n)}else for(let f=0;f<u;f++)s.push(e);const c=[];for(let f=0;f<u;f++){const m=s[f];this._batchOperatorValue(m,f,c,t,r,n)}const l=this._createNewArray(c,a,u);return l.setDefaultValue(k.create(!1)),l}_batchOperatorValue(e,t,r,n,s,a){const u=this._rowCount,c=this.getUnitId(),l=this.getSheetId(),f=this.getCurrentRow(),m=this.getCurrentColumn();if(n===5){const{rowsInCache:d,rowsNotInCache:C}=Et.canUseCache(c,l,t+m,f,f+u-1);if(d.length>0){if(s===$.EQUALS){const _=Et.getCellPositions(c,l,t+m,e.getValue(),d);_!=null&&_.forEach(E=>{if(E<f||E>f+u-1)return;const b=E-f;r[b]==null&&(r[b]=[]),r[b][t]=k.create(!0)})}else{const _=Et.getCellValuePositions(c,l,t+m);_!=null&&_.forEach((E,b)=>{let R=ae.create();qt.has(b)?R=g.create(b):typeof b=="string"?R=j.create(b):typeof b=="number"?R=y.create(b):typeof b=="boolean"&&(R=k.create(b));let p;R.isError()?p=R:e.isError()?p=e:p=R.compare(e,s,a),(p.isError()||p.getValue()===!0)&&E.forEach(V=>{V>=f&&V<=f+u-1&&(r[V-f]==null&&(r[V-f]=[]),r[V-f][t]=p)})})}if(C.length>0)for(const _ of C){const[E,b]=_;for(let R=E;R<=b;R++)this.__batchOperatorRowValue(e,t,r,n,R-f,c,l,f,m,s,a);Et.setContinueBuildingCache(c,l,t+m,E,b)}return}}for(let d=0;d<u;d++)this.__batchOperatorRowValue(e,t,r,n,d,c,l,f,m,s,a);Et.setContinueBuildingCache(c,l,t+m,f,f+u-1)}__batchOperatorRowValue(e,t,r,n,s,a,u,c,l,f,m){const d=this.getValueOrDefault(s,t);if(r[s]==null&&(r[s]=[]),d&&e)if(d.isError())r[s][t]=d;else if(e.isError())r[s][t]=e;else switch(n){case 1:r[s][t]=d.plus(e);break;case 0:r[s][t]=d.minus(e);break;case 2:r[s][t]=d.multiply(e);break;case 3:r[s][t]=d.divided(e);break;case 4:r[s][t]=d.mod(e);break;case 5:f?r[s][t]=d.compare(e,f,m):r[s][t]=g.create(h.VALUE);break;case 6:r[s][t]=d.concatenateFront(e);break;case 7:r[s][t]=d.concatenateBack(e);break;case 8:r[s][t]=d.pow(e);break;case 9:r[s][t]=d.round(e);break;case 10:r[s][t]=d.floor(e);break;case 12:r[s][t]=d.atan2(e);break;case 11:r[s][t]=d.ceil(e);break}else r[s][t]=g.create(h.NA);d!=null&&(d.isError()?Et.set(a,u,t+l,d.getErrorType(),s+c):Et.set(a,u,t+l,d.getValue(),s+c))}_batchOperatorArray(e,t,r,n){let s=e.getRowCount(),a=e.getColumnCount();s<this._rowCount&&(s=this._rowCount),a<this._columnCount&&(a=this._columnCount);const u=[],c=this._checkArrayCalculateType(this),l=this._checkArrayCalculateType(e);for(let f=0;f<s;f++){const m=[];for(let d=0;d<a;d++){let C;c===3?C=this.getValueOrDefault(0,0):c===1?C=this.getValueOrDefault(0,d):c===2?C=this.getValueOrDefault(f,0):C=this.getValueOrDefault(f,d);let _;if(l===3?_=e.getValueOrDefault(0,0):l===1?_=e.getValueOrDefault(0,d):l===2?_=e.getValueOrDefault(f,0):_=e.getValueOrDefault(f,d),C&&_)if(C.isError())m[d]=C;else if(_.isError())m[d]=_;else switch(t){case 1:m[d]=C.plus(_);break;case 0:m[d]=C.minus(_);break;case 2:m[d]=C.multiply(_);break;case 3:m[d]=C.divided(_);break;case 4:m[d]=C.mod(_);break;case 5:r?m[d]=C.compare(_,r,n):m[d]=g.create(h.VALUE);break;case 6:m[d]=C.concatenateFront(_);break;case 7:m[d]=C.concatenateBack(_);break;case 8:m[d]=C.pow(_);break;case 9:m[d]=C.round(_);break;case 12:m[d]=C.atan2(_);break;case 10:m[d]=C.floor(_);break;case 11:m[d]=C.ceil(_);break}else m[d]=g.create(h.NA)}u.push(m)}return this._createNewArray(u,s,a)}_checkArrayCalculateType(e){return e.getRowCount()===1&&e.getColumnCount()===1?3:e.getRowCount()===1?1:e.getColumnCount()===1?2:0}_formatValue(e){if(typeof e!="string")return e=e,this._rowCount=e.rowCount,this._columnCount=e.columnCount,this._unitId=e.unitId,this._sheetId=e.sheetId,this._currentRow=e.row,this._currentColumn=e.column,e.calculateValueList;e=e.slice(1,-1);const t=e.split(";"),r=t.length,n=[];let s=0;for(let a=0;a<r;a++){const c=t[a].split(","),l=c.length;s<l&&(s=l);const f=[];for(let m=0;m<l;m++){const d=c[m].trim();f.push(lt.create(d))}n.push(f)}return this._rowCount=r,this._columnCount=s,n}_createNewArray(e,t,r,n=-1,s=-1){(this._currentColumn===-1||this._currentRow===-1)&&(n=-1,s=-1);const a={calculateValueList:e,rowCount:t,columnCount:r,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:n,column:s};return K.create(a)}}class lt{static create(o){if(o==null)return ae.create();if(typeof o=="boolean")return k.create(o);if(typeof o=="string"){const e=o.toLocaleUpperCase().trim();if(qt.has(e))return g.create(e);if(e===Ot.TRUE||e===Ot.FALSE)return Ln(o);if(M.isRealNum(o))return y.create(Number(o));const{isNumberPattern:t,value:r,pattern:n}=vc(o);if(t)return y.create(r,n);const s=o.replace(/\n/g,"").replace(/\r/g,"");return!Zl(s)&&Ku(s)?K.create(s):ql(o)}return typeof o=="number"?xn(o):g.create(h.VALUE)}}function Zl(i){const o=i.trim();return o.startsWith('"')&&o.endsWith('"')}const zl=1e4,Cs=new ft(zl);class Mr extends Mn{constructor(e){super();A(this,"_forcedSheetId","");A(this,"_forcedSheetName","");A(this,"_defaultSheetId","");A(this,"_rangeData",{startColumn:-1,startRow:-1,endRow:-1,endColumn:-1});A(this,"_unitData",{});A(this,"_unitStylesData",{});A(this,"_defaultUnitId","");A(this,"_forcedUnitId","");A(this,"_runtimeData",{});A(this,"_arrayFormulaCellData",{});A(this,"_runtimeArrayFormulaCellData",{});A(this,"_runtimeFeatureCellData",{});A(this,"_refOffsetX",0);A(this,"_refOffsetY",0);this._token=e}dispose(){this._unitData={},this._unitStylesData={},this._runtimeData={}}getToken(){return this._token}setToken(e){this._token=e}isExceedRange(){const{startRow:e,endRow:t,startColumn:r,endColumn:n}=this.getRangePosition();return e<0||r<0||t>=this.getActiveSheetRowCount()||n>=this.getActiveSheetColumnCount()}setRefOffset(e=0,t=0){this._refOffsetX=e,this._refOffsetY=t}getRefOffset(){return{x:this._refOffsetX,y:this._refOffsetY}}getRangePosition(){let{startRow:e,startColumn:t,endRow:r,endColumn:n}=M.moveRangeByOffset(this._rangeData,this._refOffsetX,this._refOffsetY);return Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Number.isNaN(r)&&(r=this.getActiveSheetRowCount()-1),Number.isNaN(n)&&(n=this.getActiveSheetColumnCount()-1),{...this._rangeData,startRow:e,endRow:r,startColumn:t,endColumn:n}}isReferenceObject(){return!0}iterator(e){const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition();if(this._checkIfWorksheetMiss())return e(g.create(h.VALUE),t,n);const a=this._forcedUnitId||this._defaultUnitId,u=this._forcedSheetId||this._defaultSheetId;for(let c=t;c<=r;c++)for(let l=n;l<=s;l++){if(c<0||l<0)return e(g.create(h.REF),c,l);const f=this.getCellData(c,l);let m=!1;if(M.isNullCell(f)){m=e(null,c,l);continue}let d=this.getCellValueObject(f);if(c===t&&l===n){const C=this.getCellPattern(a,u,c,l);if(C&&d.isNumber()){const _=Number(d.getValue());d=y.create(_,C)}}if(m=e(d,c,l),m===!1)return}}getFirstCell(){const{startRow:e,startColumn:t}=this.getRangePosition(),r=this.getCellData(e,t);if(!r)return y.create(0);let n=this.getCellValueObject(r);const s=this._forcedUnitId||this._defaultUnitId,a=this._forcedSheetId||this._defaultSheetId,u=this.getCellPattern(s,a,e,t);if(u&&n.isNumber()){const c=Number(n.getValue());n=y.create(c,u)}return n}getRangeData(){return this._rangeData}setRangeData(e){this._rangeData=e}getUnitId(){return this._forcedUnitId&&this._forcedUnitId.length>0?this._forcedUnitId:this._defaultUnitId}getSheetId(){return this._forcedSheetId&&this._forcedSheetId.length>0?this._forcedSheetId:this._defaultSheetId}setForcedUnitIdDirect(e){e.length>0&&(this._forcedUnitId=e)}getForcedUnitId(){return this._forcedUnitId}setForcedSheetId(e){var t;this._forcedSheetId=(t=e[this.getUnitId()])==null?void 0:t[this._forcedSheetName]}setForcedSheetIdDirect(e){this._forcedSheetId=e}getForcedSheetId(){return this._forcedSheetId}setForcedSheetName(e){e.length>0&&(this._forcedSheetName=e)}getForcedSheetName(){return this._forcedSheetName}setDefaultSheetId(e){this._defaultSheetId=e}getDefaultSheetId(){return this._defaultSheetId}setDefaultUnitId(e){this._defaultUnitId=e}getDefaultUnitId(){return this._defaultUnitId}getUnitData(){return this._unitData}setUnitData(e){this._unitData=e}getUnitStylesData(){return this._unitStylesData}setUnitStylesData(e){this._unitStylesData=e}getRuntimeData(){return this._runtimeData}setRuntimeData(e){this._runtimeData=e}getArrayFormulaCellData(){return this._arrayFormulaCellData}setArrayFormulaCellData(e){this._arrayFormulaCellData=e}getRuntimeArrayFormulaCellData(){return this._runtimeArrayFormulaCellData}setRuntimeArrayFormulaCellData(e){this._runtimeArrayFormulaCellData=e}getRuntimeFeatureCellData(){return this._runtimeFeatureCellData}setRuntimeFeatureCellData(e){this._runtimeFeatureCellData=e}getActiveSheetRowCount(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.rowCount)||0}getActiveSheetColumnCount(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.columnCount)||0}getRowCount(){return this._rangeData.endRow-this._rangeData.startRow+1}getColumnCount(){return this._rangeData.endColumn-this._rangeData.startColumn+1}getRowData(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.rowData)||{}}getColumnData(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.columnData)||{}}isCell(){return!1}isColumn(){return!1}isRow(){return!1}isRange(){return!1}isTable(){return!1}unionBy(e){return g.create(h.REF)}unionRange(e,t){return{startRow:-1,startColumn:-1,endRow:-1,endColumn:-1}}getCellValueObject(e){const t=Ic(e);if(qt.has(t))return g.create(t);if(e.t===M.CellValueType.NUMBER){const r=this._getPatternByCell(e);return xn(t,r)}return e.t===M.CellValueType.STRING||e.t===M.CellValueType.FORCE_STRING?j.create(t.toString()):e.t===M.CellValueType.BOOLEAN?Ln(t):lt.create(t)}_getPatternByCell(e){var n;const t=this._unitStylesData[this.getUnitId()];if(!t)return"";const r=t.getStyleByCell(e);return((n=r==null?void 0:r.n)==null?void 0:n.pattern)||""}getCellByRow(e){return this.getCellByPosition(e)}getCellByColumn(e){return this.getCellByPosition(void 0,e)}getCurrentActiveSheetData(){var e;return(e=this._unitData[this.getUnitId()])==null?void 0:e[this.getSheetId()]}getCurrentStylesData(){return this._unitStylesData[this.getUnitId()]}getCurrentRuntimeSheetData(){var e,t;return(t=(e=this._runtimeData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCurrentActiveArrayFormulaCellData(){var e,t;return(t=(e=this._arrayFormulaCellData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCurrentRuntimeActiveArrayFormulaCellData(){var e,t;return(t=(e=this._runtimeArrayFormulaCellData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCellData(e,t){const r=this.getCurrentActiveSheetData(),n=this.getCurrentRuntimeSheetData(),s=this.getCurrentActiveArrayFormulaCellData(),a=this.getCurrentRuntimeActiveArrayFormulaCellData();return(n==null?void 0:n.getValue(e,t))||(a==null?void 0:a.getValue(e,t))||this.getRuntimeFeatureCellValue(e,t)||(s==null?void 0:s.getValue(e,t))||(r==null?void 0:r.cellData.getValue(e,t))}getRuntimeFeatureCellValue(e,t){return pi(e,t,this.getSheetId(),this.getUnitId(),this._runtimeFeatureCellData)}getCellByPosition(e,t){let r=e,n=t;r||(r=this._rangeData.startRow),n||(n=this._rangeData.startColumn);const s=this.getCellData(r,n);return s?this.getCellValueObject(s):g.create(h.VALUE)}getCellPattern(e,t,r,n){var c,l,f,m;const s=this._unitStylesData[e];if(!s)return"";const a=(f=(l=(c=this._unitData[e])==null?void 0:c[t])==null?void 0:l.cellData)==null?void 0:f.getValue(r,n);if(!a)return"";const u=s.getStyleByCell(a);return((m=u==null?void 0:u.n)==null?void 0:m.pattern)||""}toArrayValueObject(e=!0){var C;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=`${this.getUnitId()}_${this.getSheetId()}_${t}_${r}_${n}_${s}`,u=Cs.get(a);if(u&&e)return u;const c=r-t+1,l=s-n+1;if(c<0||l<0)return this._getBlankArrayValueObject();const f=new Array(c);this.iterator((_,E,b)=>{const R=E-t,p=b-n;f[R]||(f[R]=new Array(l)),_==null&&(_=ae.create()),f[R][p]=_});const m={calculateValueList:f,rowCount:f.length,columnCount:((C=f[0])==null?void 0:C.length)||0,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:t,column:n},d=K.create(m);return e&&Cs.set(a,d),d}toUnitRange(){return{range:this.getRangePosition(),sheetId:this.getSheetId(),unitId:this.getUnitId()}}_checkIfWorksheetMiss(){return(this._forcedSheetId==null||this._forcedSheetId.length===0)&&this._forcedSheetName.length>0}_getBlankArrayValueObject(){const e={calculateValueList:[],rowCount:0,columnCount:0,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:0,column:0};return K.create(e)}}class Ti extends Mn{constructor(o){super(),this._promise=o}isAsyncObject(){return!0}async getValue(){return this._promise}}class Bi extends Mn{constructor(o){super(),this._promiseList=o}isAsyncArrayObject(){return!0}async getValue(){var t;const o=[];for(let r=0;r<this._promiseList.length;r++){const n=this._promiseList[r];o[r]==null&&(o[r]=[]);for(let s=0;s<n.length;s++){const a=n[s];a.isAsyncObject()?o[r][s]=await a.getValue():o[r][s]=a}}const e={calculateValueList:o,rowCount:o.length,columnCount:((t=o[0])==null?void 0:t.length)||0,unitId:"",sheetId:"",row:0,column:0};return K.create(e)}}class Rr extends Mr{constructor(o,e,t){super(""),this.setRangeData(o),e&&this.setForcedSheetIdDirect(e),t&&this.setForcedUnitIdDirect(t)}isRange(){return!0}}class Ps extends Mr{constructor(o){super(o);const e=Yt(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName),this.setRangeData(e.range)}isCell(){return!0}unionBy(o){if(!o.isCell())return g.create(h.REF);const e=o,t=this.unionRange(this.getRangeData(),e.getRangeData());return this._createRange(t)}unionRange(o,e){const t=o.startRow,r=o.startColumn,n=e.startRow,s=e.startColumn,a={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1};return t>n?(a.startRow=n,a.endRow=t):(a.startRow=t,a.endRow=n),r>s?(a.startColumn=s,a.endColumn=r):(a.startColumn=r,a.endColumn=s),o.startAbsoluteRefType&&(a.startAbsoluteRefType=o.startAbsoluteRefType),e.startAbsoluteRefType&&(a.endAbsoluteRefType=e.startAbsoluteRefType),a}_createRange(o){const e=new Rr(o,this.getForcedSheetId(),this.getForcedUnitId());e.setUnitData(this.getUnitData()),e.setDefaultSheetId(this.getDefaultSheetId()),e.setDefaultUnitId(this.getDefaultUnitId()),e.setRuntimeData(this.getRuntimeData()),e.setUnitStylesData(this.getUnitStylesData()),e.setArrayFormulaCellData(this.getArrayFormulaCellData()),e.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData()),e.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());const{x:t,y:r}=this.getRefOffset();e.setRefOffset(t,r);const n=this.getForcedSheetId();e.setForcedSheetName(this.getForcedSheetName()),n!=null&&e.setForcedSheetIdDirect(n);const s=this.getForcedUnitId();return s&&e.setForcedUnitIdDirect(s),e}}class Ls extends Mr{constructor(o){super(o);const e=Yt(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName);const t={...e.range,startColumn:e.range.startColumn,startRow:Number.NaN,endColumn:e.range.endColumn,endRow:Number.NaN,rangeType:M.RANGE_TYPE.COLUMN};this.setRangeData(t)}isColumn(){return!0}unionBy(o){if(!o.isColumn())return g.create(h.REF);const e=o;if(e.getForcedSheetName()!==void 0&&e.getForcedSheetName()!=="")return g.create(h.REF);const t=this.getRangeData(),r=e.getRangeData(),n=r.startColumn;if(n>=t.startColumn&&n<=t.endColumn)return this;const s=t.startColumn;return n>s?t.endColumn=n:(t.startColumn=n,t.endColumn=s),r.startAbsoluteRefType&&(t.endAbsoluteRefType=r.startAbsoluteRefType),t.rangeType=M.RANGE_TYPE.COLUMN,this.setToken(`${this.getToken()}${Q.COLON}${e.getToken()}`),this}}class xs extends Mr{constructor(o){super(o);const e=Yt(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName);const t={...e.range,startColumn:Number.NaN,startRow:e.range.startRow,endColumn:Number.NaN,endRow:e.range.endRow,rangeType:M.RANGE_TYPE.ROW};this.setRangeData(t)}isRow(){return!0}unionBy(o){if(!o.isRow())return g.create(h.REF);const e=o;if(e.getForcedSheetName()!==void 0&&e.getForcedSheetName()!=="")return g.create(h.REF);const t=this.getRangeData(),r=e.getRangeData(),n=r.startRow;if(n>=t.startRow&&n<=t.endRow)return this;const s=t.startRow;return n>s?t.endRow=n:(t.startRow=n,t.endRow=s),r.startAbsoluteRefType&&(t.endAbsoluteRefType=r.startAbsoluteRefType),t.rangeType=M.RANGE_TYPE.ROW,this.setToken(`${this.getToken()}${Q.COLON}${e.getToken()}`),this}}function O(i,o,e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=[];for(let a=0;a<i;a++){const u=[];for(let c=0;c<o;c++){if(r===1&&n===1){const f=e.isArray()?e.get(0,0):e;u.push(f);continue}if(r===1&&c<n){const f=e.get(0,c);u.push(f);continue}if(n===1&&a<r){const f=e.get(a,0);u.push(f);continue}if(a>=r||c>=n){u.push(t!=null?t:ae.create());continue}const l=e.get(a,c);u.push(l)}s.push(u)}return Ht(s,i,o)}function Ht(i,o,e,t="",r=""){const n={calculateValueList:i,rowCount:o,columnCount:e,unitId:t,sheetId:r,row:-1,column:-1};return K.create(n)}function mr(i){const o=[$.EQUALS,$.NOT_EQUAL,$.GREATER_THAN_OR_EQUAL,$.GREATER_THAN,$.LESS_THAN_OR_EQUAL,$.LESS_THAN];for(const e of o)if(i.startsWith(e)){const t=i.substring(e.length);return[e,lt.create(t)]}return[$.EQUALS,lt.create(i)]}function jn(i,o,e,t){if(!e)if(o.isString()){const r=`${o.getValue()}`,[n,s]=mr(r);e=n,o=s}else e=$.EQUALS;return i.compare(o,e,t)}function Jl(i,o){const e=Math.max(i.isArray()?i.getRowCount():1,o.isArray()?o.getRowCount():1),t=Math.max(i.isArray()?i.getColumnCount():1,o.isArray()?o.getColumnCount():1),r=O(e,t,i),n=O(e,t,o);return r.mapValue((s,a,u)=>{const c=n.get(a,u);return s!=null&&s.isError()?s:c!=null&&c.isError()?c:s!=null&&s.isBoolean()&&(c!=null&&c.isBoolean())?Ln(s.getValue()&&c.getValue()):k.create(!1)})}function ef(i){const o=i.getValue();let e=0;return o&&(e=1),y.create(e)}function Pa(i){return i.isArray()&&i.getRowCount()===1&&i.getColumnCount()===1?!0:i.isReferenceObject()?!!(i.isCell()||i.getRowCount()===1&&i.getColumnCount()===1):(i=i,!!(i.isString()||i.isNumber()||i.isBoolean()||i.isError()||i.isNull()))}function xt(i){const o=i==null?void 0:i.getPattern();let e={};if(o&&(e={s:{n:{pattern:o}}}),i==null)return{v:null,...e};if(i.isError())return{v:i.getErrorType(),t:M.CellValueType.STRING,...e};if(i.isValueObject()){const t=i,r=t.getValue();return t.isNumber()?{v:r,t:M.CellValueType.NUMBER,...e}:t.isBoolean()?{v:r?1:0,t:M.CellValueType.BOOLEAN,...e}:t.isString()?{v:r,t:M.CellValueType.STRING,...e}:t.isNull()?{v:null,...e}:{v:r,t:M.CellValueType.STRING,...e}}}function hr(i){let o=0,e=0;return i.forEach((t,r)=>{if(r%2===1)if(t.isArray()){const n=t;o=Math.max(o,n.getRowCount()),e=Math.max(e,n.getColumnCount())}else o=Math.max(o,1),e=Math.max(e,1)}),{maxRowLength:o,maxColumnLength:e}}function Sr(i,o,e,t){const r=o.getRowCount(),n=o.getColumnCount();for(let s=0;s<i.length;s++){if(s%2===1)continue;const a=i[s],u=a.getRowCount(),c=a.getColumnCount();if(u!==r||c!==n)return O(e,t,g.create(h.VALUE))}return null}function Dr(i,o,e,t=!1){const r=[];for(let n=0;n<i.length;n++){if(n%2===1)continue;const s=i[n],a=i[n+1];O(o,e,a,g.create(h.NA)).iterator((c,l,f)=>{if(!c)return;let m=jn(s,c);const[,d]=mr(`${c.getValue()}`);if(t&&(m=Un(m,s,d)),r[l]===void 0&&(r[l]=[]),r[l][f]===void 0){r[l][f]=m;return}r[l][f]=Jl(r[l][f],m)})}return r}function Un(i,o,e){return i.mapValue((t,r,n)=>{const s=o.get(r,n);return s&&tf(s,e)?t:s!=null&&s.isError()&&e.isError()&&s.getValue()===e.getValue()?k.create(!0):k.create(!1)})}function tf(i,o){if(i.isNumber()&&o.isNumber()||i.isBoolean()&&o.isBoolean())return!0;const e=i.isString()&&i.getValue()==="",t=o.isString()&&o.getValue()==="";return!!((e||i.isNull())&&(t||o.isNull())||i.isString()&&!e&&o.isString()&&!t)}var Gr=(i=>(i[i.CELL=0]="CELL",i[i.COLUMN=1]="COLUMN",i[i.ROW=2]="ROW",i))(Gr||{});const Bt=new Map;function rf(i,o){const e=Bt.get(i);if(e)return e;let t;switch(o){case 0:t=new Ps(i);break;case 1:t=new Ls(i);break;case 2:t=new xs(i);break;default:throw new Error("Unknown reference object type")}return Bt.set(i,t),t}function nf(i,o){const e=`${i.getToken()}:${o.getToken()}`,t=Bt.get(e);if(t){const{x:n,y:s}=i.getRefOffset();return t.setRefOffset(n,s),t}let r=g.create(h.NAME);return(i.isCell()&&o.isCell()||i.isRow()&&o.isRow()||i.isColumn()&&o.isColumn())&&(r=i.unionBy(o),Bt.set(e,r)),r}function sf(){Bt.clear()}var af=Object.defineProperty,of=Object.getOwnPropertyDescriptor,uf=(i,o,e,t)=>{for(var r=t>1?void 0:t?of(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&af(o,e,r),r},cf=(i,o)=>(e,t)=>o(e,t,i),ze=(i=>(i[i.IDLE=0]="IDLE",i[i.START=1]="START",i[i.START_DEPENDENCY=2]="START_DEPENDENCY",i[i.START_CALCULATION=3]="START_CALCULATION",i[i.CURRENTLY_CALCULATING=4]="CURRENTLY_CALCULATING",i[i.START_DEPENDENCY_ARRAY_FORMULA=5]="START_DEPENDENCY_ARRAY_FORMULA",i[i.START_CALCULATION_ARRAY_FORMULA=6]="START_CALCULATION_ARRAY_FORMULA",i[i.CURRENTLY_CALCULATING_ARRAY_FORMULA=7]="CURRENTLY_CALCULATING_ARRAY_FORMULA",i[i.CALCULATION_COMPLETED=8]="CALCULATION_COMPLETED",i))(ze||{}),zt=(i=>(i[i.INITIAL=0]="INITIAL",i[i.STOP_EXECUTION=1]="STOP_EXECUTION",i[i.NOT_EXECUTED=2]="NOT_EXECUTED",i[i.SUCCESS=3]="SUCCESS",i))(zt||{});exports.FormulaRuntimeService=class extends M.Disposable{constructor(e){super();A(this,"_formulaExecuteStage",0);A(this,"_stopState",!1);A(this,"_currentRow",-1);A(this,"_currentColumn",-1);A(this,"_currentRowCount",Number.NEGATIVE_INFINITY);A(this,"_currentColumnCount",Number.NEGATIVE_INFINITY);A(this,"_currentSubUnitId","");A(this,"_currentUnitId","");A(this,"_runtimeData",{});A(this,"_runtimeOtherData",{});A(this,"_unitArrayFormulaRange",{});A(this,"_runtimeArrayFormulaCellData",{});A(this,"_runtimeClearArrayFormulaCellData",{});A(this,"_runtimeFeatureRange",{});A(this,"_runtimeFeatureCellData",{});A(this,"_functionsExecutedState",0);A(this,"_functionDefinitionPrivacyVar",new Map);A(this,"_totalFormulasToCalculate",0);A(this,"_completedFormulasCount",0);A(this,"_totalArrayFormulasToCalculate",0);A(this,"_completedArrayFormulasCount",0);A(this,"_formulaCycleIndex",0);A(this,"_isCycleDependency",!1);this._currentConfigService=e}get currentRow(){return this._currentRow}get currentColumn(){return this._currentColumn}get currentRowCount(){return this._currentRowCount}get currentColumnCount(){return this._currentColumnCount}get currentSubUnitId(){return this._currentSubUnitId}get currentUnitId(){return this._currentUnitId}dispose(){this.reset(),this._runtimeFeatureCellData={},this._runtimeFeatureRange={},this.clearReferenceAndNumberformatCache()}enableCycleDependency(){this._isCycleDependency=!0}disableCycleDependency(){this._isCycleDependency=!1}isCycleDependency(){return this._isCycleDependency}setFormulaCycleIndex(e){this._formulaCycleIndex=e}getFormulaCycleIndex(){return this._formulaCycleIndex}setTotalArrayFormulasToCalculate(e){this._totalArrayFormulasToCalculate=e}getTotalArrayFormulasToCalculate(){return this._totalArrayFormulasToCalculate}setCompletedArrayFormulasCount(e){this._completedArrayFormulasCount=e}getCompletedArrayFormulasCount(){return this._completedArrayFormulasCount}setTotalFormulasToCalculate(e){this._totalFormulasToCalculate=e}getTotalFormulasToCalculate(){return this._totalFormulasToCalculate}setCompletedFormulasCount(e){this._completedFormulasCount=e}getCompletedFormulasCount(){return this._completedFormulasCount}markedAsSuccessfullyExecuted(){this._functionsExecutedState=3}markedAsNoFunctionsExecuted(){this._functionsExecutedState=2}markedAsStopFunctionsExecuted(){this._functionsExecutedState=1}markedAsInitialFunctionsExecuted(){this._functionsExecutedState=0}stopExecution(){this._stopState=!0,this.setFormulaExecuteStage(0)}isStopExecution(){return this._stopState}setFormulaExecuteStage(e){this._formulaExecuteStage=e}getFormulaExecuteStage(){return this._formulaExecuteStage}reset(){this._formulaExecuteStage=0,this._runtimeData={},this._runtimeOtherData={},this._unitArrayFormulaRange={},this._runtimeArrayFormulaCellData={},this._runtimeClearArrayFormulaCellData={},this._functionDefinitionPrivacyVar.clear(),this.markedAsInitialFunctionsExecuted(),this._stopState=!1,this._isCycleDependency=!1,this._totalFormulasToCalculate=0,this._completedFormulasCount=0,this.clearReferenceAndNumberformatCache()}clearReferenceAndNumberformatCache(){Pc(),Tc(),hc(),sf()}setCurrent(e,t,r,n,s,a){this._currentRow=e,this._currentColumn=t,this._currentRowCount=r,this._currentColumnCount=n,this._currentSubUnitId=s,this._currentUnitId=a}clearFunctionDefinitionPrivacyVar(){this._functionDefinitionPrivacyVar.clear()}registerFunctionDefinitionPrivacyVar(e,t){this._functionDefinitionPrivacyVar.set(e,t)}getFunctionDefinitionPrivacyVar(e){return this._functionDefinitionPrivacyVar.get(e)}setRuntimeOtherData(e,t,r,n){const s=this._currentSubUnitId,a=this._currentUnitId;this._runtimeOtherData[a]===void 0&&(this._runtimeOtherData[a]={});const u=this._runtimeOtherData[a];(u[s]===void 0||u[s]===null)&&(u[s]={});const c=u[s];let l=[];if(n.isReferenceObject()||n.isValueObject()&&n.isArray()){const f=n,{startRow:m,startColumn:d}=f.getRangePosition();f.iterator((C,_,E)=>{const b=xt(C),R=_-m,p=E-d;l[R]==null&&(l[R]=[]),l[R][p]=b})}else l=[[xt(n)]];(c[e]===void 0||c[e]===null)&&(c[e]={}),(c[e][r]===void 0||c[e][r]===null)&&(c[e][r]={}),c[e][r][t]=l}setRuntimeData(e){const t=this._currentRow,r=this._currentColumn,n=this._currentRowCount,s=this.currentColumnCount,a=this._currentSubUnitId,u=this._currentUnitId;this._runtimeData[u]==null&&(this._runtimeData[u]={});const c=this._runtimeData[u];c[a]==null&&(c[a]=new M.ObjectMatrix),this._unitArrayFormulaRange[u]==null&&(this._unitArrayFormulaRange[u]={});const l=this._unitArrayFormulaRange[u];(l[a]===null||l[a]===void 0)&&(l[a]={});const f=new M.ObjectMatrix(l[a]);this._runtimeArrayFormulaCellData[u]===void 0&&(this._runtimeArrayFormulaCellData[u]={});const m=this._runtimeArrayFormulaCellData[u];m[a]==null&&(m[a]=new M.ObjectMatrix),this._runtimeClearArrayFormulaCellData[u]===void 0&&(this._runtimeClearArrayFormulaCellData[u]={});const d=this._runtimeClearArrayFormulaCellData[u];d[a]==null&&(d[a]=new M.ObjectMatrix);const C=c[a],_=m[a],E=d[a];if(e.isReferenceObject()||e.isValueObject()&&e.isArray()){const b=e,{startRow:R,startColumn:p,endRow:V,endColumn:S}=b.getRangePosition();if(R===V&&p===S){const w=b.getFirstCell(),P=xt(w);C.setValue(t,r,P),E.setValue(t,r,P);return}const D={startRow:t,startColumn:r,endRow:V-R+t,endColumn:S-p+r};if(f.setValue(t,r,D),this._checkIfArrayFormulaRangeHasData(u,a,t,r,D)||this._checkIfArrayFormulaExceeded(n,s,D)){const w=xt(g.create(h.SPILL));C.setValue(t,r,w),E.setValue(t,r,w);const P=this._currentConfigService.getUnitData();b.iterator((L,T,B)=>{var Z,G;const W=T-R+t,q=B-p+r,ie=(G=(Z=P[u])==null?void 0:Z[a])==null?void 0:G.cellData.getValue(W,q);if(T===R&&B===p)_.setValue(t,r,w);else if(ie!=null)ie.v==null&&(ie.v=""),_.setValue(W,q,ie);else{if(this._isInOtherArrayFormulaRange(u,a,t,r,W,q))return!0;_.setValue(W,q,{v:""})}})}else{const w=g.create(h.SPILL);b.iterator((P,L,T)=>{const B=xt(P);if(L===R&&T===p){if(P!=null&&P.isError()&&P.isEqualType(w))return E.setValue(t,r,{}),C.setValue(t,r,{...xt(w)}),!1;C.setValue(t,r,{...B})}const W=L-R+t,q=T-p+r;_.setValue(W,q,B)})}}else{const b=xt(e);C.setValue(t,r,b),E.setValue(t,r,b)}}getUnitData(){return this._runtimeData}getUnitArrayFormula(){return this._unitArrayFormulaRange}getRuntimeOtherData(){return this._runtimeOtherData}getRuntimeArrayFormulaCellData(){return this._runtimeArrayFormulaCellData}getRuntimeClearArrayFormulaCellData(){return this._runtimeClearArrayFormulaCellData}getRuntimeFeatureRange(){return this._runtimeFeatureRange}setRuntimeFeatureRange(e,t){this._runtimeFeatureRange[e]=t}getRuntimeFeatureCellData(){return this._runtimeFeatureCellData}setRuntimeFeatureCellData(e,t){this._runtimeFeatureCellData[e]=t}getAllRuntimeData(){return{unitData:this.getUnitData(),arrayFormulaRange:this.getUnitArrayFormula(),unitOtherData:this.getRuntimeOtherData(),functionsExecutedState:this._functionsExecutedState,arrayFormulaCellData:this.getRuntimeArrayFormulaCellData(),clearArrayFormulaCellData:this.getRuntimeClearArrayFormulaCellData(),runtimeFeatureRange:this.getRuntimeFeatureRange(),runtimeFeatureCellData:this.getRuntimeFeatureCellData()}}getRuntimeState(){return{totalFormulasToCalculate:this.getTotalFormulasToCalculate(),completedFormulasCount:this.getCompletedFormulasCount(),totalArrayFormulasToCalculate:this.getTotalArrayFormulasToCalculate(),completedArrayFormulasCount:this.getCompletedArrayFormulasCount(),stage:this.getFormulaExecuteStage(),formulaCycleIndex:this.getFormulaCycleIndex()}}_checkIfArrayFormulaRangeHasData(e,t,r,n,s){var d,C,_,E,b,R,p,V,S,D,w;const{startRow:a,startColumn:u,endRow:c,endColumn:l}=s,f=this._currentConfigService.getUnitData(),m=this._currentConfigService.getArrayFormulaCellData();(_=(C=(d=this._unitArrayFormulaRange[e])==null?void 0:d[t])==null?void 0:C[r])==null||_[n];for(let P=a;P<=c;P++)for(let L=u;L<=l;L++){if(P===r&&n===L)continue;const T=(R=(b=(E=this._runtimeData)==null?void 0:E[e])==null?void 0:b[t])==null?void 0:R.getValue(P,L);(V=(p=m==null?void 0:m[e])==null?void 0:p[t])==null||V.getValue(P,L);const B=(w=(D=(S=f==null?void 0:f[e])==null?void 0:S[t])==null?void 0:D.cellData)==null?void 0:w.getValue(P,L),W=this._getRuntimeFeatureCellValue(P,L,t,e);if(!M.isNullCell(T)||this._isInOtherArrayFormulaRange(e,t,r,n,P,L)||!M.isNullCell(B)||!M.isNullCell(W))return!0}return!1}_getRuntimeFeatureCellValue(e,t,r,n){return pi(e,t,r,n,this._runtimeFeatureCellData)}_arrayCellHasData(e){return e==null?!1:e.v!==void 0}_isInOtherArrayFormulaRange(e,t,r,n,s,a){var f;const u=(f=this._currentConfigService.getArrayFormulaRange()[e])==null?void 0:f[t];if(u==null)return!1;let c=!1;return new M.ObjectMatrix(u).forValue((m,d,C)=>{var b,R;if(m===r&&d===n)return;const _=this._isInArrayFormulaRange(C,s,a),E=(R=(b=this._runtimeData[e])==null?void 0:b[t])==null?void 0:R.getValue(m,d);_&&(E==null?void 0:E.v)!==h.SPILL&&(c=!0)}),c}_isInArrayFormulaRange(e,t,r){if(e==null)return!1;const{startRow:n,startColumn:s,endRow:a,endColumn:u}=e;return t>=n&&t<=a&&r>=s&&r<=u}_checkIfArrayFormulaExceeded(e,t,r){return r.endRow>=e||r.endColumn>=t}_isInDirtyRange(e,t,r,n){const s=this._currentConfigService.getDirtyRanges();return s.length===0?!0:ri(s,e,t,r,n)}};exports.FormulaRuntimeService=uf([cf(0,mt)],exports.FormulaRuntimeService);const st=M.createIdentifier("univer.formula.runtime.service");var ue=(i=>(i[i.REFERENCE=1]="REFERENCE",i[i.VALUE=2]="VALUE",i[i.OPERATOR=3]="OPERATOR",i[i.FUNCTION=4]="FUNCTION",i[i.LAMBDA=5]="LAMBDA",i[i.LAMBDA_PARAMETER=6]="LAMBDA_PARAMETER",i[i.ERROR=7]="ERROR",i[i.BASE=8]="BASE",i[i.ROOT=9]="ROOT",i[i.UNION=10]="UNION",i[i.PREFIX=11]="PREFIX",i[i.SUFFIX=12]="SUFFIX",i[i.NULL=13]="NULL",i))(ue||{});const at=new Map([[1,7],[2,9],[3,8],[4,6],[5,1],[6,2],[9,10],[10,3],[11,4],[12,5]]);class Fe{constructor(o){A(this,"_children",[]);A(this,"_definedNames");A(this,"_parent");A(this,"_valueObject");A(this,"_calculateState",!1);A(this,"_async",!1);A(this,"_address",!1);A(this,"_isForcedCalculateFunction",!1);this._token=o}dispose(){var o;this._children.forEach(e=>{e.dispose()}),(o=this._valueObject)==null||o.dispose(),this._valueObject=null,this._children=[],this._definedNames=null,this._parent=null}get nodeType(){return ue.BASE}isAsync(){return this._async}isAddress(){return this._address}isForcedCalculateFunction(){return this._isForcedCalculateFunction}setAsync(){this._async=!0}setAddress(){this._address=!0}getParent(){return this._parent}setParent(o){this._parent=o,o.addChildren(this)}setForcedCalculateFunction(){this._isForcedCalculateFunction=!0}getChildren(){return this._children}addChildren(...o){this._children.push(...o)}getToken(){return this._token}setValue(o){this._valueObject=o}getValue(){return this._valueObject}isCalculated(){return this._calculateState}setCalculated(){this._calculateState=!0}execute(){}setNotEmpty(o=!0){}async executeAsync(){return Promise.resolve(Rt.SUCCESS)}serialize(){const o=this.getToken(),e=this.getChildren(),t=[],r=e.length;for(let s=0;s<r;s++){const a=e[s];t.push(a.serialize())}const n={token:o,nodeType:this.nodeType};return r>0&&(n.children=t),n}hasDefinedName(o){var e;return((e=this._definedNames)==null?void 0:e.includes(o))||!1}setDefinedNames(o){this._definedNames=o}getDefinedNames(){return this._definedNames}}class De extends Fe{constructor(e){super(e);A(this,"_errorValueObject");this._errorValueObject=g.create(e)}get nodeType(){return ue.ERROR}static create(e){return new De(e)}getValue(){return this._errorValueObject}}const it=100;class ot{get zIndex(){return 0}dispose(){}create(o,e,t){let r;return o instanceof se?r=o.getToken():r=o,new Fe(r)}}class _s extends Fe{get nodeType(){return ue.ROOT}execute(){const o=this.getChildren();if(o.length>1){this.setValue(g.create(h.VALUE));return}const e=o[0];e==null?this.setValue(g.create(h.VALUE)):this.setValue(e.getValue())}}class js extends ot{get zIndex(){return at.get(ue.ROOT)||it}checkAndCreateNodeType(o){if(!(o instanceof se))return;if(o.getToken()===Nt)return new _s(Nt)}}const gt=M.createIdentifier("univer.formula-function.service");class Ii extends M.Disposable{constructor(){super(...arguments);A(this,"_functionExecutors",new Map);A(this,"_functionDescriptions",new Map)}dispose(){this._functionExecutors.clear(),this._functionDescriptions.clear()}registerExecutors(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionExecutors.set(r.name,r)}}getExecutors(){return this._functionExecutors}getExecutor(e){return this._functionExecutors.get(e)}hasExecutor(e){return this._functionExecutors.has(e)}unregisterExecutors(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionExecutors.delete(r)}}registerDescriptions(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.set(r.functionName,r)}return M.toDisposable(()=>{for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.delete(r.functionName)}})}getDescriptions(){return this._functionDescriptions}getDescription(e){return this._functionDescriptions.get(e)}hasDescription(e){return this._functionDescriptions.has(e)}unregisterDescriptions(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.delete(r)}}}var Le=(i=>(i.COMPARE="COMPARE",i.DIVIDED="DIVIDED",i.MINUS="MINUS",i.MULTIPLY="MULTIPLY",i.PLUS="PLUS",i.UNION="UNION",i.CUBE="CUBE",i))(Le||{}),lf=Object.defineProperty,ff=Object.getOwnPropertyDescriptor,mf=(i,o,e,t)=>{for(var r=t>1?void 0:t?ff(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&lf(o,e,r),r},La=(i,o)=>(e,t)=>o(e,t,i);class an extends Fe{constructor(o,e,t){super(e),this._runtimeService=o,this._operatorString=e,this._functionExecutor=t}get nodeType(){return ue.PREFIX}execute(){let e=this.getChildren()[0].getValue(),t;if(e==null)throw new Error("object is null");this._operatorString===pe.MINUS?(e.isReferenceObject()&&(e=e.toArrayValueObject()),t=this._functionExecutor.calculate(y.create(0),e)):this._operatorString===pe.AT?t=this._handlerAT(e):t=g.create(h.VALUE),this.setValue(t)}_handlerAT(o){if(!o.isReferenceObject())return g.create(h.VALUE);const e=o;if(e.isCell())return g.create(h.VALUE);const t=this._runtimeService,r=t.currentRow||0,n=t.currentColumn||0,s=e.getRangePosition(),{startRow:a,startColumn:u,endRow:c,endColumn:l}=s;return l!==u&&c!==a||a===c&&u===l?g.create(h.VALUE):c===a&&n>=u&&n<=l?e.getCellByColumn(n):u===l&&r>=a&&r<=c?e.getCellByRow(r):e.isTable()?e.getCellByPosition(r):g.create(h.VALUE)}}exports.PrefixNodeFactory=class extends ot{constructor(o,e){super(),this._functionService=o,this._runtimeService=e}get zIndex(){return at.get(ue.PREFIX)||it}checkAndCreateNodeType(o){if(!(o instanceof se))return;const e=o.getToken(),t=e.trim();if(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"')return;let r="";if(t===pe.MINUS)r=Le.MINUS;else return t===pe.AT?new an(this._runtimeService,t):void 0;const n=this._functionService.getExecutor(r);return n?new an(this._runtimeService,t,n):(console.error(`No function ${e}`),De.create(h.NAME))}};exports.PrefixNodeFactory=mf([La(0,gt),La(1,st)],exports.PrefixNodeFactory);new RegExp(pe.MINUS,"g");new RegExp(pe.AT,"g");function Fi(i,o,e){let t,r,n=i;const s=n.slice(0,2);let a=0;if(s[0]===pe.MINUS){const u=o.getExecutor(Le.MINUS);t=new an(e,pe.MINUS,u),a++}return s[0]===pe.AT&&(r=new an(e,pe.AT),t&&r.setParent(t),a++),a>0&&(n=n.slice(a)),{tokenTrim:n,minusPrefixNode:t,atPrefixNode:r}}var hf=Object.defineProperty,gf=Object.getOwnPropertyDescriptor,df=(i,o,e,t)=>{for(var r=t>1?void 0:t?gf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&hf(o,e,r),r},Kt=(i,o)=>(e,t)=>o(e,t,i);class Cf extends Fe{constructor(o,e,t,r,n,s){super(""),this._functionExecutor=e,this._currentConfigService=t,this._runtimeService=r,this._definedNamesService=n,this._formulaDataModel=s,this._functionExecutor.isAsync()&&this.setAsync(),this._functionExecutor.isAddress()&&this.setAddress(),this._functionExecutor.needsLocale&&this._setLocale(),this._functionExecutor.needsSheetsInfo&&this._setSheetsInfo(),this._functionExecutor.needsFormulaDataModel&&this._functionExecutor.setFormulaDataModel(this._formulaDataModel)}get nodeType(){return ue.FUNCTION}async executeAsync(){const o=[],e=this.getChildren(),t=e.length;this._compatibility();for(let s=0;s<t;s++){const u=e[s].getValue();u!=null&&(u.isReferenceObject()&&!this._functionExecutor.needsReferenceObject?o.push(u.toArrayValueObject()):o.push(u))}const r=this._calculate(o);let n;return r.isAsyncObject()||r.isAsyncArrayObject()?n=await r.getValue():n=r,this._setRefData(n),this.setValue(n),Promise.resolve(Rt.SUCCESS)}execute(){const o=[],e=this.getChildren(),t=e.length;this._compatibility();for(let n=0;n<t;n++){const a=e[n].getValue();a!=null&&(a.isReferenceObject()&&!this._functionExecutor.needsReferenceObject?o.push(a.toArrayValueObject()):o.push(a))}const r=this._calculate(o);this._setRefData(r),this.setValue(r)}_compatibility(){this._lookupCompatibility()}_lookupCompatibility(){const o=this.getChildren(),e=o.length;if(!this._functionExecutor.needsExpandParams||e!==3)return;const t=o[1].getValue(),r=o[2].getValue();if(!(t!=null&&t.isReferenceObject())&&!(r!=null&&r.isReferenceObject()))return;let n,s;if(t!=null&&t.isReferenceObject()){const C=t.getRangeData(),{startRow:_,startColumn:E,endRow:b,endColumn:R}=C;n=b-_+1,s=R-E+1}else n=t!=null&&t.isArray()?t.getRowCount():1,s=t!=null&&t.isArray()?t.getColumnCount():1;const a=r.getRangeData(),{startRow:u,startColumn:c,endRow:l,endColumn:f}=a,m=l-u+1,d=f-c+1;n!==m&&(a.endRow+=n-m),s!==d&&(a.endColumn+=s-d)}_calculate(o){var n;const{minParams:e,maxParams:t}=this._functionExecutor;if(e!==-1&&t!==-1&&(o.length<e||o.length>t))return g.create(h.NA);let r;if(this._setRefInfo(),this._functionExecutor.isCustom()){const s=this._functionExecutor.calculateCustom(...o.map(a=>a.isArray()?a.toValue():a.getValue()));if(typeof s!="object"||s==null)r=lt.create(s);else{const a=vi(s);r=K.create({calculateValueList:a,rowCount:a.length,columnCount:((n=a[0])==null?void 0:n.length)||0,unitId:"",sheetId:"",row:-1,column:-1})}}else this._functionExecutor.isAddress()&&this._setDefinedNamesForFunction(),r=this._functionExecutor.calculate(...o);return r}_setDefinedNamesForFunction(){const o=this._currentConfigService.getExecuteUnitId();if(o==null)return;const e=this._definedNamesService.getDefinedNameMap(o);e!=null&&this._functionExecutor.setDefinedNames(e)}_setRefInfo(){const{currentUnitId:o,currentSubUnitId:e,currentRow:t,currentColumn:r}=this._runtimeService;if(this._functionExecutor.setRefInfo(o,e,t,r),this._functionExecutor.needsSheetRowColumnCount){const{rowCount:n,columnCount:s}=this._currentConfigService.getSheetRowColumnCount(o,e);this._functionExecutor.setSheetRowColumnCount(n,s)}}_setRefData(o){if(!o.isReferenceObject())return;const e=o;e.setForcedSheetId(this._currentConfigService.getSheetNameMap()),e.setUnitData(this._currentConfigService.getUnitData()),e.setArrayFormulaCellData(this._currentConfigService.getArrayFormulaCellData()),e.setRuntimeData(this._runtimeService.getUnitData()),e.setRuntimeArrayFormulaCellData(this._runtimeService.getRuntimeArrayFormulaCellData()),e.setRuntimeFeatureCellData(this._runtimeService.getRuntimeFeatureCellData())}_setLocale(){this._functionExecutor.setLocale(this._currentConfigService.getLocale())}_setSheetsInfo(){this._functionExecutor.setSheetsInfo(this._currentConfigService.getSheetsInfo())}}class _f extends Fe{constructor(o="Error"){super(o)}get nodeType(){return ue.FUNCTION}async executeAsync(){return this.setValue(g.create(h.NAME)),Promise.resolve(Rt.SUCCESS)}execute(){this.setValue(g.create(h.NAME))}}exports.FunctionNodeFactory=class extends ot{constructor(o,e,t,r,n,s){super(),this._functionService=o,this._currentConfigService=e,this._runtimeService=t,this._definedNamesService=r,this._injector=n,this._formulaDataModel=s}get zIndex(){return at.get(ue.FUNCTION)||it}create(o){const e=this._functionService.getExecutor(o);return e?new Cf(o,e,this._currentConfigService,this._runtimeService,this._definedNamesService,this._formulaDataModel):(console.error(`No function ${o}`),De.create(h.NAME))}checkAndCreateNodeType(o){if(typeof o=="string")return;const e=o.getToken(),{tokenTrim:t,minusPrefixNode:r,atPrefixNode:n}=Fi(e.trim(),this._functionService,this._runtimeService);if(!Number.isNaN(Number(t))&&!this._isParentUnionNode(o))return De.create(h.VALUE);const s=t.toUpperCase();if(this._functionService.hasExecutor(s)){const a=this.create(s);return n?a.setParent(n):r&&a.setParent(r),a}}_isParentUnionNode(o){var e,t;return((t=(e=o.getParent())==null?void 0:e.getParent())==null?void 0:t.getToken())===Q.COLON}};exports.FunctionNodeFactory=df([Kt(0,gt),Kt(1,mt),Kt(2,st),Kt(3,lr),Kt(4,M.Inject(M.Injector)),Kt(5,M.Inject(exports.FormulaDataModel))],exports.FunctionNodeFactory);var Af=Object.defineProperty,Ef=Object.getOwnPropertyDescriptor,bf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Ef(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Af(o,e,r),r},yf=(i,o)=>(e,t)=>o(e,t,i);exports.Interpreter=class extends M.Disposable{constructor(o){super(),this._runtimeService=o}async executeAsync(o){if(!o||!o.node)return Promise.resolve(g.create(h.VALUE));const e=o.node,t=o.refOffsetX,r=o.refOffsetY;await this._executeAsync(e,t,r);const n=e.getValue();return n==null?Promise.resolve(g.create(h.VALUE)):Promise.resolve(n)}execute(o){if(!o||!o.node)return g.create(h.VALUE);const e=o.node,t=o.refOffsetX,r=o.refOffsetY;this._execute(e,t,r);const n=e.getValue();return n==null?g.create(h.VALUE):n}executePreCalculateNode(o){return o.execute(),o.getValue()}checkAsyncNode(o){if(o==null)return!1;const e=[];this._checkAsyncNode(o,e);for(let t=0,r=e.length;t<r;t++)if(e[t]===!0)return!0;return!1}_checkAsyncNode(o,e){const t=o.getChildren(),r=t.length;for(let n=0;n<r;n++){const s=t[n];e.push(s.isAsync()),this._checkAsyncNode(s,e)}}async _executeAsync(o,e=0,t=0){if(this._runtimeService.isStopExecution())return Promise.resolve(Rt.ERROR);const r=o.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.getToken().toUpperCase()===br&&a.isEmptyParamFunction()){a.execute();continue}await this._executeAsync(a,e,t)}return o.nodeType===ue.REFERENCE&&o.setRefOffset(e,t),o.nodeType===ue.FUNCTION&&o.isAsync()?await o.executeAsync():o.execute(),Promise.resolve(Rt.SUCCESS)}_execute(o,e=0,t=0){if(this._runtimeService.isStopExecution())return Rt.ERROR;const r=o.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.getToken().toUpperCase()===br&&a.isEmptyParamFunction()){a.execute();continue}this._execute(a,e,t)}return o.nodeType===ue.REFERENCE&&o.setRefOffset(e,t),o.execute(),Rt.SUCCESS}};exports.Interpreter=bf([yf(0,st)],exports.Interpreter);function ki(i){return i instanceof se?i.getToken()===nr:!1}function Rf(i){return i instanceof se?i.getToken()===bi:!1}function Us(i,o,e){const t=i.getChildren(),r=t.length,n=t[0];for(let s=0;s<r;s++){const a=t[s];if(!(ki(n)&&s!==0))if(a instanceof se)Us(a,o,e);else{const u=a.trim();if(e.has(u)){const c=new se;c.setToken(Or),c.setLambdaId(o),c.setLambdaPrivacyVar(e),c.setLambdaParameter(u),t[s]=c}}}}function pf(i){let o=i;for(;o!=null&&o.getParent();)o=o.getParent();return o}function xa(i,o=0,e=0){return{node:i,refOffsetX:o,refOffsetY:e}}function $i(i){if(!i)return;if(i.getToken()!==Or)return i;const o=i,e=o.getCurrentLambdaPrivacyVar(),t=o.getLambdaParameter();if(!e)return;const r=e.get(t);return r==null&&i.getValue()?i:$i(r)}class vs extends ht{constructor(e,t,r){super(0);A(this,"_lambdaPrivacyValueMap",new Map);this._lambdaNode=e,this._interpreter=t,this._lambdaPrivacyVarKeys=r,this._lambdaPrivacyValueMap.clear()}static create(e,t,r){return new vs(e,t,r)}dispose(){this._lambdaPrivacyValueMap.clear(),this._lambdaPrivacyValueMap=new Map,this._lambdaNode=null,this._interpreter=null,this._lambdaPrivacyVarKeys=[]}isLambda(){return!0}execute(...e){const t=this._lambdaPrivacyVarKeys.length;if(e.length!==t||!this._interpreter||!this._lambdaNode)return g.create(h.VALUE);this._setLambdaPrivacyValueMap(e),this._setLambdaNodeValue(this._lambdaNode),this._lambdaNode.setNotEmpty(!1);let r;if(this._interpreter.checkAsyncNode(this._lambdaNode))r=new Ti(this._interpreter.executeAsync(xa(this._lambdaNode)));else{const n=this._interpreter.execute(xa(this._lambdaNode));n.isReferenceObject()?r=n.toArrayValueObject():r=n}return this._lambdaNode.setNotEmpty(!0),r}_setLambdaNodeValue(e){if(!e)return;const t=e.getChildren(),r=t.length;for(let n=0;n<r;n++){const s=t[n];if(s.getToken()===Or){const u=s.getLambdaParameter(),c=this._lambdaPrivacyValueMap.get(u);if(c)s.setValue(c);else{const l=s.getCurrentLambdaPrivacyVar(),f=$i(l.get(u));f!=null&&s.setValue(f.getValue())}continue}this._setLambdaNodeValue(s)}}_setLambdaPrivacyValueMap(e){for(let t=0;t<e.length;t++){const r=e[t],n=this._lambdaPrivacyVarKeys[t];this._lambdaPrivacyValueMap.set(n,r)}}getLambdaPrivacyVarKeys(){return this._lambdaPrivacyVarKeys}}var Nf=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,Of=(i,o,e,t)=>{for(var r=t>1?void 0:t?Vf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Nf(o,e,r),r},ja=(i,o)=>(e,t)=>o(e,t,i);class Mf extends Fe{constructor(e,t,r,n){super(e);A(this,"_isNotEmpty",!0);this._lambdaId=t,this._interpreter=r,this._lambdaPrivacyVarKeys=n}get nodeType(){return ue.LAMBDA}setNotEmpty(e=!1){this._isNotEmpty=e}isEmptyParamFunction(){return this.getChildren().length<2&&this._isNotEmpty}isFunctionParameter(){return this._lambdaId===null}getLambdaId(){return this._lambdaId}execute(){if(this.isEmptyParamFunction())this.setValue(vs.create(this,this._interpreter,this._lambdaPrivacyVarKeys));else{const e=this.getChildren(),t=e.length;this.setValue(e[t-1].getValue())}}}exports.LambdaNodeFactory=class extends ot{constructor(o,e){super(),this._runtimeService=o,this._interpreter=e}get zIndex(){return at.get(ue.LAMBDA)||it}create(o){const e=o.getChildren(),t=e[0];let r=e.slice(1,-1);const n=e[e.length-1];if(!(t instanceof se&&n instanceof se))return De.create(h.NAME);if(t.getToken()===nr){const u=t.getChildren();if(r.length!==u.length)return De.create(h.VALUE)}else r=e.slice(0,-1);const s=M.Tools.generateRandomId(8),a=new Map;for(let u=0;u<r.length;u++){const c=r[u];if(c instanceof se){const l=c.getChildren()[0];c.setToken(bi),a.set(l.trim(),void 0)}else return De.create(h.VALUE)}return this._runtimeService.registerFunctionDefinitionPrivacyVar(s,a),this._updateLambdaStatement(n,s,a),new Mf(o.getToken(),s,this._interpreter,[...a.keys()])}checkAndCreateNodeType(o){if(!(!(o instanceof se)||o.getToken().trim().toUpperCase()!==br))return this.create(o)}_updateLambdaStatement(o,e,t){Us(o,e,t)}};exports.LambdaNodeFactory=Of([ja(0,st),ja(1,M.Inject(exports.Interpreter))],exports.LambdaNodeFactory);function Yi(i){if(!i)return;if(i.getToken()!==Or)return i;const o=i,e=o.getCurrentLambdaPrivacyVar(),t=o.getLambdaParameter();if(e)return Yi(e.get(t))}class Sf extends Fe{constructor(o,e,t){super(o),this._lambdaParameter=e,this._currentLambdaPrivacyVar=t}getLambdaParameter(){return this._lambdaParameter}getCurrentLambdaPrivacyVar(){return this._currentLambdaPrivacyVar}get nodeType(){return ue.LAMBDA_PARAMETER}execute(){const o=Yi(this._currentLambdaPrivacyVar.get(this._lambdaParameter));if(o)this.setValue(o.getValue());else{const e=this.getValue();(e==null||e.isError())&&this.setValue(g.create(h.NAME))}}}class Ts extends ot{get zIndex(){return at.get(ue.LAMBDA_PARAMETER)||it}create(o){const e=o.getFunctionDefinitionPrivacyVar(),t=o.getLambdaParameter();return e?new Sf(o.getToken(),t,e):new De(h.NAME)}checkAndCreateNodeType(o){if(!(!(o instanceof se)||o.getToken().trim()!==Or))return this.create(o)}}class Df extends Fe{constructor(o){super(o),this._operatorString=o}get nodeType(){return ue.NULL}execute(){this.setValue(ae.create())}}var Y=(i=>(i.ABS="ABS",i.ACOS="ACOS",i.ACOSH="ACOSH",i.ACOT="ACOT",i.ACOTH="ACOTH",i.AGGREGATE="AGGREGATE",i.ARABIC="ARABIC",i.ASIN="ASIN",i.ASINH="ASINH",i.ATAN="ATAN",i.ATAN2="ATAN2",i.ATANH="ATANH",i.BASE="BASE",i.CEILING="CEILING",i.CEILING_MATH="CEILING.MATH",i.CEILING_PRECISE="CEILING.PRECISE",i.COMBIN="COMBIN",i.COMBINA="COMBINA",i.COS="COS",i.COSH="COSH",i.COT="COT",i.COTH="COTH",i.CSC="CSC",i.CSCH="CSCH",i.DECIMAL="DECIMAL",i.DEGREES="DEGREES",i.EVEN="EVEN",i.EXP="EXP",i.FACT="FACT",i.FACTDOUBLE="FACTDOUBLE",i.FLOOR="FLOOR",i.FLOOR_MATH="FLOOR.MATH",i.FLOOR_PRECISE="FLOOR.PRECISE",i.GCD="GCD",i.INT="INT",i.ISO_CEILING="ISO.CEILING",i.LCM="LCM",i.LET="LET",i.LN="LN",i.LOG="LOG",i.LOG10="LOG10",i.MDETERM="MDETERM",i.MINVERSE="MINVERSE",i.MMULT="MMULT",i.MOD="MOD",i.MROUND="MROUND",i.MULTINOMIAL="MULTINOMIAL",i.MUNIT="MUNIT",i.ODD="ODD",i.PI="PI",i.POWER="POWER",i.PRODUCT="PRODUCT",i.QUOTIENT="QUOTIENT",i.RADIANS="RADIANS",i.RAND="RAND",i.RANDARRAY="RANDARRAY",i.RANDBETWEEN="RANDBETWEEN",i.ROMAN="ROMAN",i.ROUND="ROUND",i.ROUNDDOWN="ROUNDDOWN",i.ROUNDUP="ROUNDUP",i.SEC="SEC",i.SECH="SECH",i.SERIESSUM="SERIESSUM",i.SEQUENCE="SEQUENCE",i.SIGN="SIGN",i.SIN="SIN",i.SINH="SINH",i.SQRT="SQRT",i.SQRTPI="SQRTPI",i.SUBTOTAL="SUBTOTAL",i.SUM="SUM",i.SUMIF="SUMIF",i.SUMIFS="SUMIFS",i.SUMPRODUCT="SUMPRODUCT",i.SUMSQ="SUMSQ",i.SUMX2MY2="SUMX2MY2",i.SUMX2PY2="SUMX2PY2",i.SUMXMY2="SUMXMY2",i.TAN="TAN",i.TANH="TANH",i.TRUNC="TRUNC",i))(Y||{}),ne=(i=>(i.ASC="ASC",i.ARRAYTOTEXT="ARRAYTOTEXT",i.BAHTTEXT="BAHTTEXT",i.CHAR="CHAR",i.CLEAN="CLEAN",i.CODE="CODE",i.CONCAT="CONCAT",i.CONCATENATE="CONCATENATE",i.DBCS="DBCS",i.DOLLAR="DOLLAR",i.EXACT="EXACT",i.FIND="FIND",i.FINDB="FINDB",i.FIXED="FIXED",i.LEFT="LEFT",i.LEFTB="LEFTB",i.LEN="LEN",i.LENB="LENB",i.LOWER="LOWER",i.MID="MID",i.MIDB="MIDB",i.NUMBERVALUE="NUMBERVALUE",i.PHONETIC="PHONETIC",i.PROPER="PROPER",i.REGEXEXTRACT="REGEXEXTRACT",i.REGEXMATCH="REGEXMATCH",i.REGEXREPLACE="REGEXREPLACE",i.REPLACE="REPLACE",i.REPLACEB="REPLACEB",i.REPT="REPT",i.RIGHT="RIGHT",i.RIGHTB="RIGHTB",i.SEARCH="SEARCH",i.SEARCHB="SEARCHB",i.SUBSTITUTE="SUBSTITUTE",i.T="T",i.TEXT="TEXT",i.TEXTAFTER="TEXTAFTER",i.TEXTBEFORE="TEXTBEFORE",i.TEXTJOIN="TEXTJOIN",i.TEXTSPLIT="TEXTSPLIT",i.TRIM="TRIM",i.UNICHAR="UNICHAR",i.UNICODE="UNICODE",i.UPPER="UPPER",i.VALUE="VALUE",i.VALUETOTEXT="VALUETOTEXT",i.CALL="CALL",i.EUROCONVERT="EUROCONVERT",i.REGISTER_ID="REGISTER.ID",i))(ne||{}),wf=Object.defineProperty,Pf=Object.getOwnPropertyDescriptor,Lf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Pf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&wf(o,e,r),r},xf=(i,o)=>(e,t)=>o(e,t,i);class jf extends Fe{constructor(o,e){super(o),this._functionExecutor=e}get nodeType(){return ue.OPERATOR}execute(){const o=this.getChildren();this._functionExecutor.name===Le.COMPARE&&this._functionExecutor.setCompareType(this.getToken());const e=o[0],t=o[1];let r=e==null?void 0:e.getValue(),n=t==null?void 0:t.getValue();const s=this.getToken();if((r==null||n==null)&&s!==X.MINUS&&s!==X.PLUS){this.setValue(g.create(h.VALUE));return}r==null&&(r=ae.create()),n==null&&(n=ae.create()),r.isReferenceObject()&&(r=r.toArrayValueObject()),n.isReferenceObject()&&(n=n.toArrayValueObject()),this.setValue(this._functionExecutor.calculate(r,n))}}exports.OperatorNodeFactory=class extends ot{constructor(o){super(),this._functionService=o}get zIndex(){return at.get(ue.OPERATOR)||it}create(o){let e="";const t=o;t===X.PLUS?e=Le.PLUS:t===X.MINUS?e=Le.MINUS:t===X.MULTIPLY?e=Le.MULTIPLY:t===X.DIVIDED?e=Le.DIVIDED:t===X.CONCATENATE?e=ne.CONCATENATE:t===X.POWER?e=Y.POWER:Lu.has(t)&&(e=Le.COMPARE);const r=this._functionService.getExecutor(e);return r?new jf(t,r):(console.error(`No function ${o}`),De.create(h.NAME))}checkAndCreateNodeType(o){if(o instanceof se)return;const e=o.trim();if(!(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"')&&At.has(e))return this.create(e)}};exports.OperatorNodeFactory=Lf([xf(0,gt)],exports.OperatorNodeFactory);var Uf=Object.defineProperty,vf=Object.getOwnPropertyDescriptor,Tf=(i,o,e,t)=>{for(var r=t>1?void 0:t?vf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Uf(o,e,r),r},Xn=(i,o)=>(e,t)=>o(e,t,i);class Kn extends Fe{constructor(e,t,r,n,s=!1){super(r);A(this,"_refOffsetX",0);A(this,"_refOffsetY",0);this._currentConfigService=e,this._runtimeService=t,this._referenceObjectType=n,this._isPrepareMerge=s}get nodeType(){return ue.REFERENCE}execute(){const e=this._currentConfigService,t=this._runtimeService,r=rf(this.getToken(),this._referenceObjectType);r.setDefaultUnitId(t.currentUnitId),r.setDefaultSheetId(t.currentSubUnitId),r.setForcedSheetId(e.getSheetNameMap()),r.setUnitData(e.getUnitData()),r.setArrayFormulaCellData(e.getArrayFormulaCellData()),r.setRuntimeData(t.getUnitData()),r.setUnitStylesData(e.getUnitStylesData()),r.setRuntimeArrayFormulaCellData(t.getRuntimeArrayFormulaCellData()),r.setRuntimeFeatureCellData(t.getRuntimeFeatureCellData());const{x:n,y:s}=this.getRefOffset();r.setRefOffset(n,s),!this._isPrepareMerge&&r.isExceedRange()?this.setValue(g.create(h.NAME)):this.setValue(r)}setRefOffset(e=0,t=0){this._refOffsetX=e,this._refOffsetY=t}getRefOffset(){return{x:this._refOffsetX,y:this._refOffsetY}}}exports.ReferenceNodeFactory=class extends ot{constructor(o,e,t){super(),this._currentConfigService=o,this._formulaRuntimeService=e,this._functionService=t}get zIndex(){return at.get(ue.REFERENCE)||it}checkAndCreateNodeType(o){var f,m;let e=!1,t,r=!1;o instanceof se?(e=!0,t=o.getToken().trim(),((m=(f=o.getParent())==null?void 0:f.getParent())==null?void 0:m.getToken().trim())===Q.COLON&&(r=!0)):t=o.trim();const n=this._currentConfigService,s=this._formulaRuntimeService,{tokenTrim:a,minusPrefixNode:u,atPrefixNode:c}=Fi(t,this._functionService,s);if(!e&&a.charAt(0)==='"'&&a.charAt(a.length-1)==='"')return;let l;if(Nr(a)?l=new Kn(n,s,a,Gr.CELL,r):e&&this._checkParentIsUnionOperator(o)&&(li(a)?l=new Kn(n,s,a,Gr.ROW,r):fi(a)&&(l=new Kn(n,s,a,Gr.COLUMN,r))),l)return c?l.setParent(c):u&&l.setParent(u),l}_checkParentIsUnionOperator(o){var e,t;return((t=(e=o.getParent())==null?void 0:e.getParent())==null?void 0:t.getToken().trim())===Q.COLON}};exports.ReferenceNodeFactory=Tf([Xn(0,mt),Xn(1,st),Xn(2,gt)],exports.ReferenceNodeFactory);var Bf=Object.defineProperty,If=Object.getOwnPropertyDescriptor,Ff=(i,o,e,t)=>{for(var r=t>1?void 0:t?If(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Bf(o,e,r),r},Zn=(i,o)=>(e,t)=>o(e,t,i);class Ua extends Fe{constructor(o,e,t,r){super(t),this._currentConfigService=o,this._lexer=e,this._operatorString=t,this._functionExecutor=r}get nodeType(){return ue.SUFFIX}execute(){let e=this.getChildren()[0].getValue(),t;if(e==null)throw new Error("object is null");if(this._operatorString===He.PERCENTAGE){if(e.isReferenceObject()&&(e=e.toArrayValueObject()),t=this._functionExecutor.calculate(e,y.create(100)),t.isNumber()){const r=Number(t.getValue());t=y.create(r,"0.00%")}}else this._operatorString===He.POUND?t=this._handlerPound(e):t=g.create(h.VALUE);this.setValue(t)}_handlerPound(o){var u,c,l,f;if(!o.isReferenceObject()||!o.isCell())return g.create(h.VALUE);const e=o,t=e.getRangePosition(),r=e.getUnitId(),n=e.getSheetId(),s=this._currentConfigService.getFormulaData(),a=(f=(l=(c=(u=s==null?void 0:s[r])==null?void 0:u[n])==null?void 0:c[t.startRow])==null?void 0:l[t.startColumn])==null?void 0:f.f;return a&&this._lexer.treeBuilder(a),g.create(h.VALUE)}}exports.SuffixNodeFactory=class extends ot{constructor(o,e,t){super(),this._functionService=o,this._lexer=e,this._currentConfigService=t}get zIndex(){return at.get(ue.SUFFIX)||it}checkAndCreateNodeType(o){if(!(o instanceof se))return;const e=o.getToken().trim();if(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"')return;let t="";if(e===He.PERCENTAGE)t=Le.DIVIDED;else return e===He.POUND?new Ua(this._currentConfigService,this._lexer,e):void 0;const r=this._functionService.getExecutor(t);return r?new Ua(this._currentConfigService,this._lexer,e,r):(console.error(`No function ${o}`),De.create(h.NAME))}};exports.SuffixNodeFactory=Ff([Zn(0,gt),Zn(1,M.Inject(exports.Lexer)),Zn(2,mt)],exports.SuffixNodeFactory);var kf=Object.defineProperty,$f=Object.getOwnPropertyDescriptor,Yf=(i,o,e,t)=>{for(var r=t>1?void 0:t?$f(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&kf(o,e,r),r},Hf=(i,o)=>(e,t)=>o(e,t,i);class Gf extends Fe{constructor(o){super(o)}get nodeType(){return ue.UNION}execute(){const o=this.getChildren(),e=o[0],t=o[1],r=e.getValue(),n=t.getValue();if(r==null||n==null)throw new Error("leftNode and rightNode");let s;this.getToken()===Q.COLON?s=this._unionFunction(r,n):s=g.create(h.NAME),this.setValue(s)}_unionFunction(o,e){return o.isError()||e.isError()||!o.isReferenceObject()||!e.isReferenceObject()?g.create(h.REF):(o=o,e=e,nf(o,e))}}exports.UnionNodeFactory=class extends ot{constructor(o){super(),this._functionService=o}get zIndex(){return at.get(ue.UNION)||it}create(o){return new Gf(o)}checkAndCreateNodeType(o){if(!(o instanceof se))return;const t=o.getToken().trim();if(!(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"')&&t===Q.COLON)return this.create(t)}};exports.UnionNodeFactory=Yf([Hf(0,gt)],exports.UnionNodeFactory);class Wf extends Fe{constructor(o){super(o)}get nodeType(){return ue.VALUE}execute(){this.setValue(lt.create(this.getToken()))}}class Bs extends ot{get zIndex(){return at.get(ue.VALUE)||it}_checkValueNode(o){if(Number.isNaN(Number(o))){const e=o.trim(),t=e.charAt(0),r=e.charAt(e.length-1);if(qt.has(e))return this.create(e);if(t==='"'&&r==='"')return this.create(e);if(t==="{"&&r==="}")return this.create(e);const n=e.toUpperCase();if(n===Ot.TRUE||n===Ot.FALSE)return this.create(n)}else return this.create(o)}create(o){return new Wf(o)}checkAndCreateNodeType(o){if(!(o instanceof se))return this._checkValueNode(o)}}var Qf=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,Xf=(i,o,e,t)=>{for(var r=t>1?void 0:t?qf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Qf(o,e,r),r},Ze=(i,o)=>(e,t)=>o(e,t,i);exports.AstTreeBuilder=class extends M.Disposable{constructor(e,t,r,n,s,a,u,c,l,f,m){super();A(this,"_astNodeFactoryList",[]);this._runtimeService=e,this._astRootNodeFactory=t,this._functionNodeFactory=r,this._lambdaNodeFactory=n,this._lambdaParameterNodeFactory=s,this._operatorNodeFactory=a,this._prefixNodeFactory=u,this._referenceNodeFactory=c,this._suffixNodeFactory=l,this._unionNodeFactory=f,this._valueNodeFactory=m,this._initializeAstNode()}dispose(){this._astNodeFactoryList.forEach(e=>{e.dispose()}),this._astNodeFactoryList=[]}parse(e){const t=new _s(Nt),r=this._parse(e,t);return e.hasDefinedNames()&&(r==null||r.setDefinedNames(e.getDefinedNames())),r}_lambdaParameterHandler(e,t){if(t.getLambdaId==null)return De.create(h.VALUE);const r=t.getLambdaId(),n=new _s(Nt),s=this._runtimeService.getFunctionDefinitionPrivacyVar(r);if(!s)return!1;const a=[...s.keys()],u=e.getChildren(),c=u.length;for(let l=0;l<c;l++){const f=u[l];if(f instanceof se){Us(f,r,s),this._parse(f,n);const d=n.getChildren()[l];d!=null&&s.set(a[l],d)}else return!1}return n.setParent(t),t}_changeLetToLambda(e){const t=e.getChildren(),r=t.length;if(r%2!==1||r===0)return;const n=new se;n.setToken(br);const s=new se;s.setToken(nr);const a=[...t];for(let c=0;c<r;c++){const l=a[c];if(!(l instanceof se))return;c%2===0?l.changeToParent(n):l.changeToParent(s)}n.addChildrenFirst(s),s.setParent(n);const u=e.getParent();return u==null||u.replaceChild(e,n),n}_parse(e,t){const r=e.getChildren(),n=r.length,s=[];let a=null;const u=e.getToken().trim().toUpperCase();if(u===lc){const f=this._changeLetToLambda(e);return f!=null?this._parse(f,t):De.create(h.ERROR)}if(u===ut){if(a=t,n===0)return new Df(Nt).setParent(t),a}else{if(u===nr){let f=this._lambdaParameterHandler(e,t);return f===!1&&(f=De.create(h.ERROR)),f}if(a=this._checkAstNode(e),a==null)return De.create(h.NAME)}const c=r[0];for(let f=0;f<n;f++){const m=r[f];if(ki(c)){if(f!==0&&f!==n-1)continue}else if(Rf(m)&&f!==n-1)continue;let d=null;if(m instanceof se){if(d=this._parse(m,a),d===a)continue}else d=this._checkAstNode(m);if(d==null)return De.create(h.NAME);if(d=pf(d),d==null)return;switch(d.nodeType){case ue.FUNCTION:{const C=d.getToken().trim().toUpperCase();mc.has(C)&&d.setForcedCalculateFunction(),s.push(d);break}case ue.LAMBDA:s.push(d);break;case ue.LAMBDA_PARAMETER:s.push(d);break;case ue.OPERATOR:{const C=s.pop(),_=s.pop();_&&_.setParent(d),C&&C.setParent(d),s.push(d);break}case ue.REFERENCE:s.push(d);break;case ue.ROOT:s.push(d);break;case ue.UNION:s.push(d);break;case ue.VALUE:s.push(d);break;case ue.PREFIX:s.push(d);break;case ue.SUFFIX:s.push(d);break}}const l=s.length;for(let f=0;f<l;f++)s[f].setParent(a);return a}_checkAstNode(e){let t=null;const r=this._astNodeFactoryList.length;for(let n=0;n<r&&(t=this._astNodeFactoryList[n].checkAndCreateNodeType(e),t==null);n++);return t==null?new _f:t}_initializeAstNode(){this._astNodeFactoryList=[this._astRootNodeFactory,this._functionNodeFactory,this._lambdaNodeFactory,this._lambdaParameterNodeFactory,this._operatorNodeFactory,this._prefixNodeFactory,this._referenceNodeFactory,this._suffixNodeFactory,this._unionNodeFactory,this._valueNodeFactory].sort(M.sortRules)}};exports.AstTreeBuilder=Xf([Ze(0,st),Ze(1,M.Inject(js)),Ze(2,M.Inject(exports.FunctionNodeFactory)),Ze(3,M.Inject(exports.LambdaNodeFactory)),Ze(4,M.Inject(Ts)),Ze(5,M.Inject(exports.OperatorNodeFactory)),Ze(6,M.Inject(exports.PrefixNodeFactory)),Ze(7,M.Inject(exports.ReferenceNodeFactory)),Ze(8,M.Inject(exports.SuffixNodeFactory)),Ze(9,M.Inject(exports.UnionNodeFactory)),Ze(10,M.Inject(Bs))],exports.AstTreeBuilder);class Hi extends M.Disposable{constructor(){super(...arguments);A(this,"_otherFormulaData",new Map);A(this,"_featureFormulaData",new Map);A(this,"_formulaData",new Map);A(this,"_definedNameMap",new Map);A(this,"_otherFormulaDataMainData",new Set);A(this,"_dependencyRTreeCache",new M.RTree);A(this,"_dependencyTreeIdLast",0)}buildDependencyTree(e,t){throw new Error("Method not implemented.")}getTreeById(e){throw new Error("Method not implemented.")}getAllTree(){throw new Error("Method not implemented.")}reset(){throw new Error("Method not implemented.")}addOtherFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}removeOtherFormulaDependency(e,t,r){throw new Error("Method not implemented.")}clearOtherFormulaDependency(e,t){throw new Error("Method not implemented.")}addFeatureFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}removeFeatureFormulaDependency(e,t,r){throw new Error("Method not implemented.")}clearFeatureFormulaDependency(e,t){throw new Error("Method not implemented.")}addFormulaDependency(e,t,r,n,s){throw new Error("Method not implemented.")}removeFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}clearFormulaDependency(e,t){throw new Error("Method not implemented.")}removeFormulaDependencyByDefinedName(e,t){throw new Error("Method not implemented.")}searchDependency(e,t){return this._dependencyRTreeCache.bulkSearch(e,t)}_restDependencyTreeId(){this._dependencyTreeIdLast=0}getOtherFormulaDependency(e,t,r){var n,s;return(s=(n=this._otherFormulaData.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}addOtherFormulaDependencyMainData(e){this._otherFormulaDataMainData.add(e)}hasOtherFormulaDataMainData(e){return this._otherFormulaDataMainData.has(e)}_removeDependencyRTreeCacheById(e,t){this._dependencyRTreeCache.removeById(e,t)}getFeatureFormulaDependency(e,t,r){var n,s;return(s=(n=this._featureFormulaData.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}getFormulaDependency(e,t,r,n){var s,a;return(a=(s=this._formulaData.get(e))==null?void 0:s.get(t))==null?void 0:a.getValue(r,n)}addDependencyRTreeCache(e){const t=[];for(let r=0;r<e.rangeList.length;r++){const n=e.rangeList[r],{unitId:s,sheetId:a,range:u}=n;t.push({unitId:s,sheetId:a,range:u,id:e.treeId})}this._dependencyRTreeCache.bulkInsert(t),this._addAllTreeMap(e)}getLastTreeId(){const e=this._dependencyTreeIdLast;return this._dependencyTreeIdLast++,e}_addAllTreeMap(e){throw new Error("Method not implemented.")}_addDefinedName(e,t,r){this._definedNameMap.has(e)||this._definedNameMap.set(e,new Map);const n=this._definedNameMap.get(e);n.has(t)||n.set(t,new Set),n.get(t).add(r)}addFormulaDependencyByDefinedName(e,t){const r=e.treeId,n=(t==null?void 0:t.getDefinedNames())||[];for(const s of n)this._addDefinedName(e.unitId,s,r)}}class Gi extends Hi{constructor(){super(...arguments);A(this,"_allTreeMap",new Map)}dispose(){this.reset()}buildDependencyTree(e,t=[]){const r=this.getAllTree();return e.length===0?(this._buildReverseDependency(r,t),r):(this._buildDependencyTree(r,e),this._buildReverseDependency(r,e),r)}_buildDependencyTree(e,t){const r=new Map;for(let n=0;n<t.length;n++){const s=t[n];r.set(s.treeId,s)}for(let n=0;n<e.length;n++){const s=e[n],a=s.toRTreeItem(),u=this._dependencyRTreeCache.bulkSearch(a);for(const c of u){const l=r.get(c);l&&s!==l&&!l.hasChildren(s.treeId)&&l.pushChildren(s)}}r.clear()}_buildReverseDependency(e,t){const r=new Map;for(let n=0;n<e.length;n++){const s=e[n];r.set(s.treeId,s)}for(let n=0;n<t.length;n++){const s=t[n],a=s.toRTreeItem(),u=this._dependencyRTreeCache.bulkSearch(a);for(const c of u){const l=r.get(c);l&&s!==l&&!l.hasChildren(s.treeId)&&l.pushChildren(s)}}r.clear()}getAllTree(){const e=[];return this._allTreeMap.forEach(t=>{t.resetState(),e.push(t)}),e}getTreeById(e){return this._allTreeMap.get(e)}reset(){this._otherFormulaData.clear(),this._featureFormulaData.clear(),this._formulaData.clear(),this._dependencyRTreeCache.clear(),this._allTreeMap.clear(),this._restDependencyTreeId(),this._otherFormulaDataMainData.clear()}addOtherFormulaDependency(e,t,r,n){this._otherFormulaData.has(e)||this._otherFormulaData.set(e,new Map);const s=this._otherFormulaData.get(e);s.has(t)||s.set(t,new Map);const a=s.get(t);a.has(r)||a.set(r,new M.ObjectMatrix),a.get(r).setValue(n.refOffsetX,n.refOffsetY,n.treeId),this._addAllTreeMap(n)}removeOtherFormulaDependency(e,t,r){const n=this._otherFormulaData.get(e);if(n&&n.has(t)){const s=n.get(t);r.forEach(a=>{const u=s.get(a);u!=null&&(u.forValue((c,l,f)=>{this._removeDependencyRTreeCache(f),this.clearDependencyForTree(this._allTreeMap.get(f)),this._removeAllTreeMap(f)}),s.delete(a),this._otherFormulaDataMainData.delete(a))}),s.size===0&&n.delete(t),n.size===0&&this._otherFormulaData.delete(e)}}clearOtherFormulaDependency(e,t){const r=this._otherFormulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t);for(const s of n.keys()){const a=n.get(s);a!=null&&(a.forValue((u,c,l)=>{const f=this._allTreeMap.get(l);f&&(this.clearDependencyForTree(f),this._removeAllTreeMap(l))}),this._otherFormulaDataMainData.delete(s))}n.clear()}else if(r){for(const n of r.keys()){const s=r.get(n);this._removeDependencyRTreeCacheById(e,n);for(const a of s.keys()){const u=s.get(a);u!=null&&(u.forValue((c,l,f)=>{const m=this._allTreeMap.get(f);m&&(this.clearDependencyForTree(m),this._removeAllTreeMap(f))}),this._otherFormulaDataMainData.delete(a))}}this._otherFormulaData.delete(e)}}addFeatureFormulaDependency(e,t,r,n){this._featureFormulaData.has(e)||this._featureFormulaData.set(e,new Map);const s=this._featureFormulaData.get(e);s.has(t)||s.set(t,new Map),s.get(t).set(r,n.treeId),this._addAllTreeMap(n)}removeFeatureFormulaDependency(e,t,r){const n=this._featureFormulaData.get(e);if(n&&n.has(t)){const s=n.get(t);r.forEach(a=>{const u=s.get(a);u!=null&&(this._removeDependencyRTreeCache(u),s.delete(a),this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u))})}}clearFeatureFormulaDependency(e,t){const r=this._featureFormulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t),n.forEach(s=>{s!=null&&(this.clearDependencyForTree(this._allTreeMap.get(s)),this._removeAllTreeMap(s))}),n.clear()}else r&&(r.forEach((n,s)=>{this._removeDependencyRTreeCacheById(e,s),n.forEach(a=>{a!=null&&(this.clearDependencyForTree(this._allTreeMap.get(a)),this._removeAllTreeMap(a))})}),this._featureFormulaData.delete(e))}addFormulaDependency(e,t,r,n,s){this._formulaData.has(e)||this._formulaData.set(e,new Map);const a=this._formulaData.get(e);a.has(t)||a.set(t,new M.ObjectMatrix),a.get(t).setValue(r,n,s.treeId),this._addAllTreeMap(s)}removeFormulaDependency(e,t,r,n){const s=this._formulaData.get(e);if(s&&s.has(t)){const a=s.get(t),u=a.getValue(r,n);if(u==null)return;this._removeDependencyRTreeCache(u),a.realDeleteValue(r,n),this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u)}}clearFormulaDependency(e,t){const r=this._formulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t),n.forValue((s,a,u)=>{if(u==null)return!0;this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u)}),n.reset()}else r&&(r.forEach((n,s)=>{this._removeDependencyRTreeCacheById(e,s),n.forValue((a,u,c)=>{if(c==null)return!0;this.clearDependencyForTree(this._allTreeMap.get(c)),this._removeAllTreeMap(c)})}),this._formulaData.delete(e))}clearDependencyForTree(e){if(e==null)return;const t=e.parents,r=e.children,n=this._allTreeMap;for(const s of t){const a=n.get(s);a==null||a.children.delete(e.treeId)}for(const s of r){const a=n.get(s);a==null||a.parents.delete(e.treeId)}e.dispose()}_removeDependencyRTreeCache(e){if(e==null)return;const t=this._allTreeMap.get(e);if(t){const r=[];for(let n=0;n<t.rangeList.length;n++){const s=t.rangeList[n],{unitId:a,sheetId:u,range:c}=s;r.push({unitId:a,sheetId:u,range:c,id:e})}this._dependencyRTreeCache.bulkRemove(r)}}removeFormulaDependencyByDefinedName(e,t){const r=this._definedNameMap.get(e);if(r){const n=r.get(t);if(n){for(const s of n)this._removeDependencyRTreeCache(s),this.clearDependencyForTree(this._allTreeMap.get(s)),this._removeAllTreeMap(s);n.clear()}}}_removeAllTreeMap(e){e!=null&&this._allTreeMap.delete(e)}_addAllTreeMap(e){this._allTreeMap.set(e.treeId,e)}}const wr=M.createIdentifier("univer.formula.dependency-manager.service");class Wi extends M.Disposable{constructor(){super(...arguments);A(this,"_referenceExecutorMap",new Map);A(this,"_onChanged$",new Jt.Subject);A(this,"onChanged$",this._onChanged$.asObservable())}dispose(){this._referenceExecutorMap.clear()}remove(e,t,r){r.forEach(n=>{var s,a;(a=(s=this._referenceExecutorMap.get(e))==null?void 0:s.get(t))==null||a.delete(n)}),this._onChanged$.next({unitId:e,subUnitId:t,featureIds:r})}get(e,t,r){var n,s;return(s=(n=this._referenceExecutorMap.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}has(e,t,r){var n,s;return!!((s=(n=this._referenceExecutorMap.get(e))==null?void 0:n.get(t))!=null&&s.has(r))}register(e,t,r,n){let s=this._referenceExecutorMap.get(e);s||(s=new Map,this._referenceExecutorMap.set(e,s));let a=s.get(t);a||(a=new Map,s.set(t,a)),this._onChanged$.next({unitId:e,subUnitId:t,featureIds:[r]}),a.set(r,n)}getReferenceExecutorMap(){return this._referenceExecutorMap}}const ar=M.createIdentifier("univer.formula.feature-calculation-manager.service");class Qi extends M.Disposable{constructor(){super(...arguments);A(this,"_otherFormulaData",{})}dispose(){this._otherFormulaData={}}remove(e){var s,a,u;const{unitId:t,subUnitId:r,formulaId:n}=e;(u=(a=(s=this._otherFormulaData)==null?void 0:s[t])==null?void 0:a[r])==null||delete u[n]}get(e){var s,a;const{unitId:t,subUnitId:r,formulaId:n}=e;return(a=(s=this._otherFormulaData[t])==null?void 0:s[r])==null?void 0:a[n]}has(e){var s,a;const{unitId:t,subUnitId:r,formulaId:n}=e;return((a=(s=this._otherFormulaData[t])==null?void 0:s[r])==null?void 0:a[n])!=null}register(e){const{unitId:t,subUnitId:r,formulaId:n,item:s}=e;this._otherFormulaData[t]||(this._otherFormulaData[t]={}),this._otherFormulaData[t][r]||(this._otherFormulaData[t][r]={}),this._otherFormulaData[t][r][n]=s}batchRegister(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{const s=r[n];if(s==null)return!0;Object.keys(s).forEach(a=>{const u=s[a];if(u==null)return!0;this.register({unitId:t,subUnitId:n,formulaId:a,item:u})})})})}batchRemove(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{const s=r[n];if(s==null)return!0;Object.keys(s).forEach(a=>{this.remove({unitId:t,subUnitId:n,formulaId:a})})})})}getOtherFormulaData(){return this._otherFormulaData}}const vn=M.createIdentifier("univer.formula.other-formula-manager.service"),Kf=5e3,va=new ft(Kf);function As(i,o,e,t,r){let n=va.get(`${i}${o}`);if(n&&!qi(n,r))return n;const s=e.treeBuilder(o);if(qt.has(s))return De.create(s);if(n=t.parse(s),n==null)throw new Error("astNode is null");return va.set(`${i}${o}`,n),n}function qi(i,o){const e=o.getDirtyDefinedNameMap(),t=o.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++){const a=r[n];if(i.hasDefinedName(a))return!0}}return!1}function Zf(i,o,e){return!!(o!=null&&qi(o,e))}var on=(i=>(i[i.NORMAL_FORMULA=0]="NORMAL_FORMULA",i[i.OTHER_FORMULA=1]="OTHER_FORMULA",i[i.FEATURE_FORMULA=2]="FEATURE_FORMULA",i))(on||{});class Xi{constructor(){A(this,"_state",0);A(this,"treeId");A(this,"children",new Set);A(this,"parents",new Set)}resetState(){this._state=0}setAdded(){this._state=1}isAdded(){return this._state===1}setSkip(){this._state=2}isSkip(){return this._state===2}pushChildren(o){this.children.add(o.treeId),o._pushParent(this)}hasChildren(o){return this.children.has(o)}_pushParent(o){this.parents.add(o.treeId)}}class Es extends Xi{constructor(){super(...arguments);A(this,"refTree");A(this,"refOffsetX",-1);A(this,"refOffsetY",-1);A(this,"isCache",!1);A(this,"isDirty",!1);A(this,"getDirtyData");A(this,"featureId")}get isVirtual(){return!0}get row(){return this.refTree==null?-1:this.refTree.row+this.refOffsetY}get column(){return this.refTree==null?-1:this.refTree.column+this.refOffsetX}get rowCount(){return this.refTree==null?0:this.refTree.rowCount}get columnCount(){return this.refTree==null?0:this.refTree.columnCount}get unitId(){return this.refTree==null?"":this.refTree.unitId}get subUnitId(){return this.refTree==null?"":this.refTree.subUnitId}get formula(){var e,t;return(t=(e=this.refTree)==null?void 0:e.formula)!=null?t:""}get nodeData(){return{node:this.node,refOffsetX:this.refOffsetX,refOffsetY:this.refOffsetY}}get node(){var e;return(e=this.refTree)==null?void 0:e.node}dispose(){this.refTree=null}get rangeList(){const e=[];if(this.refTree==null)return[];for(let t=0;t<this.refTree.rangeList.length;t++){const r=this.refTree.rangeList[t];e.push({unitId:r.unitId,sheetId:r.sheetId,range:M.moveRangeByOffset(r.range,this.refOffsetX,this.refOffsetY)})}return e}toRTreeItem(){const e=this.row,t=this.column;return[{unitId:this.unitId,sheetId:this.subUnitId,range:{startRow:e,startColumn:t,endRow:e,endColumn:t}}]}inRangeData(e){const t=e.startRow,r=e.startColumn,n=e.endRow,s=e.endColumn,a=this.row,u=this.column;return!(a<t||a>n||u<r||u>s)}dependencySheetName(e){return this.refTree==null?!1:this.refTree.dependencySheetName(e)}isExcludeRange(e){var r;const t=this.rangeList;if(t.length===0)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c,range:l}=a,f=(r=e==null?void 0:e[u])==null?void 0:r[c];let{startRow:m,endRow:d,startColumn:C,endColumn:_}=l;Number.isNaN(m)&&(m=0),Number.isNaN(C)&&(C=0),Number.isNaN(d)&&(d=Number.POSITIVE_INFINITY),Number.isNaN(_)&&(_=Number.POSITIVE_INFINITY);let E=!1;if(f==null||f.forValue((b,R)=>{if(b>=m&&b<=d&&R>=C&&R<=_)return E=!0,!1}),E)return!0}return!1}get formulaId(){return this.refTree==null?"":this.refTree.formulaId}}class Wr extends Xi{constructor(e){super();A(this,"isCache",!1);A(this,"featureId");A(this,"featureDirtyRanges",[]);A(this,"refOffsetX",0);A(this,"refOffsetY",0);A(this,"type",0);A(this,"formulaId");A(this,"subUnitId","");A(this,"unitId","");A(this,"rangeList",[]);A(this,"formula","");A(this,"row",-1);A(this,"column",-1);A(this,"rowCount",Number.NEGATIVE_INFINITY);A(this,"columnCount",Number.NEGATIVE_INFINITY);A(this,"isDirty",!1);A(this,"node");A(this,"getDirtyData");this.treeId=e}get isVirtual(){return!1}get nodeData(){return{node:this.node,refOffsetX:0,refOffsetY:0}}toJson(){return{formula:this.formula,refOffsetX:this.refOffsetX,refOffsetY:this.refOffsetY}}dispose(){this.featureDirtyRanges=[],this.rangeList=[],this.getDirtyData=null}inRangeData(e){const t=e.startRow,r=e.startColumn,n=e.endRow,s=e.endColumn,a=this.row,u=this.column;return!(a<t||a>n||u<r||u>s)}dependencySheetName(e){var r;const t=this.rangeList;if(t.length===0||e==null)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c}=a;if(((r=e[u])==null?void 0:r[c])!=null)return!0}return!1}isExcludeRange(e){var r;const t=this.rangeList;if(t.length===0)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c,range:l}=a,f=(r=e==null?void 0:e[u])==null?void 0:r[c];let{startRow:m,endRow:d,startColumn:C,endColumn:_}=l;Number.isNaN(m)&&(m=0),Number.isNaN(C)&&(C=0),Number.isNaN(d)&&(d=Number.POSITIVE_INFINITY),Number.isNaN(_)&&(_=Number.POSITIVE_INFINITY);let E=!1;if(f==null||f.forValue((b,R)=>{if(b>=m&&b<=d&&R>=C&&R<=_)return E=!0,!1}),E)return!0}return!1}pushRangeList(e){this.rangeList.push(...e)}shouldBePushRangeList(){return this.rangeList.length===0&&this.type!==2}toRTreeItem(){if(this.featureId!=null)return this.featureDirtyRanges;const e=this.row,t=this.column;return[{unitId:this.unitId,sheetId:this.subUnitId,range:{startRow:e,startColumn:t,endRow:e,endColumn:t}}]}}var zf=Object.defineProperty,Jf=Object.getOwnPropertyDescriptor,em=(i,o,e,t)=>{for(var r=t>1?void 0:t?Jf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&zf(o,e,r),r},_t=(i,o)=>(e,t)=>o(e,t,i);function vt(i){return i.getLastTreeId()||0}const un=M.createIdentifier("engine-formula.dependency-generator");exports.FormulaDependencyGenerator=class extends M.Disposable{constructor(e,t,r,n,s,a,u,c){super();A(this,"_updateRangeFlattenCache",new Map);this._currentConfigService=e,this._runtimeService=t,this._otherFormulaManagerService=r,this._featureCalculationManagerService=n,this._interpreter=s,this._astTreeBuilder=a,this._lexer=u,this._dependencyManagerService=c}dispose(){this._updateRangeFlattenCache.clear()}async generate(){this._updateRangeFlatten();const e=this._currentConfigService.getFormulaData(),t=this._otherFormulaManagerService.getOtherFormulaData(),r=this._currentConfigService.getClearDependencyTreeCache();r!=null&&Object.keys(r).forEach(f=>{f!=null&&Object.keys(r[f]).forEach(m=>{m!=null&&(this._dependencyManagerService.clearOtherFormulaDependency(f,m),this._dependencyManagerService.clearFeatureFormulaDependency(f,m),this._dependencyManagerService.clearFormulaDependency(f,m))})});const n=this._currentConfigService.getUnitData(),s=await this._generateTreeList(e,t,n),a=this._getUpdateTreeListAndMakeDependency(s);let u=this._calculateRunList(a);return this._dependencyFeatureCalculation(u)&&(u.forEach(f=>{f.resetState()}),u=this._calculateRunList(u)),this._checkIsCycleDependency(u)&&this._runtimeService.enableCycleDependency(),Promise.resolve(u)}_dependencyFeatureCalculation(e){const t=this._featureCalculationManagerService.getReferenceExecutorMap();if(t.size===0)return;this._clearFeatureCalculationNode(e);let r=!1;return t.forEach((n,s)=>{n.forEach((a,u)=>{a.forEach((c,l)=>{const{unitId:f,subUnitId:m,getDirtyData:d}=c,C=d(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData()),_=this._convertDirtyRangesToUnitRange(C.dirtyRanges),E=this._intersectFeatureCalculation(_,e,{unitId:f,subUnitId:m,featureId:l});if(E.length>0){let b=this._getExistTreeList({unitId:f,subUnitId:m,featureId:l},e);b==null&&(b=this._getFeatureFormulaTree(l,vt(this._dependencyManagerService),c),e.push(b)),b.parents=new Set,E.forEach(R=>{R.hasChildren(b.treeId)||R.pushChildren(b)}),r=!0}})})}),r}_clearFeatureCalculationNode(e){const t=this._featureCalculationManagerService.getReferenceExecutorMap();e.forEach(r=>{var a,u,c,l;const n=new Set;for(const f of r.children){const m=this._dependencyManagerService.getTreeById(f);m&&(m.featureId&&(u=(a=t.get(r.unitId))==null?void 0:a.get(r.subUnitId))!=null&&u.has(m.featureId)||n.add(f))}r.children=n;const s=new Set;for(const f of r.parents){const m=this._dependencyManagerService.getTreeById(f);m&&(m.featureId&&(l=(c=t.get(r.unitId))==null?void 0:c.get(r.subUnitId))!=null&&l.has(m.featureId)||s.add(f))}r.parents=s})}_convertDirtyRangesToUnitRange(e){const t=[];for(const r in e){const n=e[r];for(const s in n){const a=n[s];for(const u of a)t.push({unitId:r,sheetId:s,range:u})}}return t}_intersectFeatureCalculation(e,t,r){const n=[],s=this._dependencyManagerService.searchDependency(e);for(let a=0,u=t.length;a<u;a++){const c=t[a];if(c.unitId===r.unitId&&c.subUnitId===r.subUnitId&&c.featureId===r.featureId)continue;s.has(c.treeId)&&n.push(c)}return n}_getExistTreeList(e,t){const{unitId:r,subUnitId:n,featureId:s}=e;for(let a=0,u=t.length;a<u;a++){const c=t[a];if(c.unitId===r&&c.subUnitId===n&&c.featureId===s)return c}}_isCyclicUtil(e,t,r){const n=this._dependencyManagerService.getTreeById(e);if(n==null)return!1;if(!t.has(n.treeId)){t.add(n.treeId),r.add(n.treeId);for(const s of n.children)if(!t.has(s)&&this._isCyclicUtil(s,t,r)||r.has(s))return!0}return r.delete(n.treeId),!1}_checkIsCycleDependency(e){const t=new Set,r=new Set;for(let n=0,s=e.length;n<s;n++){const a=e[n];if(this._isCyclicUtil(a.treeId,t,r)===!0)return!0}return!1}async _generateTreeList(e,t,r){const n=Object.keys(e),s=Object.keys(t),a=[];this._currentConfigService.isForceCalculate()&&this._dependencyManagerService.reset(),this._registerFormulas(n,e,r,a),this._registerOtherFormulas(t,s,a),this._registerFeatureFormulas(a);for(let c=0,l=a.length;c<l;c++){const f=a[c],m=f.node;if(m==null||(f.isDirty=this._includeTree(f,m),f.isVirtual))continue;this._runtimeService.setCurrent(f.row,f.column,f.rowCount,f.columnCount,f.subUnitId,f.unitId);const d=await this._getRangeListByNode({node:m,refOffsetX:f.refOffsetX,refOffsetY:f.refOffsetY});f.pushRangeList(d)}for(let c=0,l=a.length;c<l;c++){const f=a[c];f.isCache||this._dependencyManagerService.addDependencyRTreeCache(f)}return a}_registerFeatureFormulas(e){this._featureCalculationManagerService.getReferenceExecutorMap().forEach((r,n)=>{r.forEach((s,a)=>{s.forEach((u,c)=>{const l=this._dependencyManagerService.getFeatureFormulaDependency(u.unitId,u.subUnitId,c);e.push(this._getFeatureFormulaTree(c,l,u))})})})}_getFeatureFormulaTree(e,t,r){const{unitId:n,subUnitId:s,dependencyRanges:a,getDirtyData:u}=r,c=t||vt(this._dependencyManagerService),l=new Wr(c);l.unitId=n,l.subUnitId=s,l.rangeList=a,l.getDirtyData=u;const f=u(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData()),m=this._convertDirtyRangesToUnitRange(f.dirtyRanges);return l.featureDirtyRanges=m,l.featureId=e,l.type=on.FEATURE_FORMULA,this._dependencyManagerService.addFeatureFormulaDependency(n,s,e,l),this._dependencyManagerService.getFeatureFormulaDependency(r.unitId,r.subUnitId,e)&&(l.isCache=!0),l}_registerOtherFormulas(e,t,r){for(const n of t){const s=e[n];if(s==null)continue;const a=Object.keys(s);for(const u of a){const c=s[u];if(c==null)continue;const l=Object.keys(c);for(const f of l){const m=this._dependencyManagerService.hasOtherFormulaDataMainData(f),d=c[f],{f:C,ranges:_}=d;let E=!1;m&&(E=!0);const b=As(n,C,this._lexer,this._astTreeBuilder,this._currentConfigService),{firstRow:R,firstColumn:p}=this._getFirstCellOfRange(_),V=this._dependencyManagerService.getOtherFormulaDependency(n,u,f),S=(V==null?void 0:V.getValue(0,0))||vt(this._dependencyManagerService),D=new Wr(S);for(let w=0;w<_.length;w++){const P=_[w],{startRow:L,startColumn:T,endRow:B,endColumn:W}=P;for(let q=L;q<=B;q++)for(let ie=T;ie<=W;ie++){const Z=ie-p,G=q-R;if(Z===0&&G===0){D.node=b,D.formula=C,D.unitId=n,D.subUnitId=u,D.formulaId=f,D.type=on.OTHER_FORMULA,D.isCache=E,r.push(D),this._dependencyManagerService.addOtherFormulaDependency(n,u,f,D),this._dependencyManagerService.addFormulaDependencyByDefinedName(D);continue}const ce=new Es;ce.treeId=(V==null?void 0:V.getValue(Z,G))||vt(this._dependencyManagerService),ce.refTree=D,ce.refOffsetX=Z,ce.refOffsetY=G,ce.isCache=E,this._dependencyManagerService.addOtherFormulaDependency(n,u,f,ce),this._dependencyManagerService.addFormulaDependencyByDefinedName(ce),r.push(ce)}}this._dependencyManagerService.addOtherFormulaDependencyMainData(f)}}}}_getFirstCellOfRange(e){const t=e[0];return{firstRow:t.startRow,firstColumn:t.startColumn}}_registerFormulas(e,t,r,n){for(const s of e){const a=t[s];if(a==null)continue;const u=Object.keys(a);for(const c of u){const l=new M.ObjectMatrix(a[c]||{}),f=new Map;l.forValue((m,d,C)=>{if(C==null)return!0;const{x:_=0,y:E=0,si:b}=C;if(!(_===0&&E===0&&b!=null))return!0;const R=this._createFDtree(s,c,m,d,r,C),p=this._dependencyManagerService.getFormulaDependency(s,c,m,d);p!=null?R.treeId=p:(this._dependencyManagerService.addFormulaDependency(s,c,m,d,R),this._dependencyManagerService.addFormulaDependencyByDefinedName(R)),f.set(b,R),n.push(R)}),l.forValue((m,d,C)=>{if(C==null)return!0;const{x:_=0,y:E=0,si:b}=C;if(_===0&&E===0&&b!=null)return!0;let R;if(b&&f.has(b)){const V=f.get(b);R=this._createVirtualFDtree(V,C)}else R=this._createFDtree(s,c,m,d,r,C);const p=this._dependencyManagerService.getFormulaDependency(s,c,m,d);p!=null?R.treeId=p:(this._dependencyManagerService.addFormulaDependency(s,c,m,d,R),this._dependencyManagerService.addFormulaDependencyByDefinedName(R)),n.push(R)}),f.clear()}}}_createFDtree(e,t,r,n,s,a){const{f:u,x:c=0,y:l=0}=a,f=new Wr(vt(this._dependencyManagerService)),m=s[e][t],d=As(e,u,this._lexer,this._astTreeBuilder,this._currentConfigService);return f.node=d,f.formula=u,f.unitId=e,f.subUnitId=t,f.row=r,f.column=n,f.rowCount=m.rowCount,f.columnCount=m.columnCount,f}_createVirtualFDtree(e,t){const{x:r=0,y:n=0}=t,s=new Es;return s.treeId=vt(this._dependencyManagerService),s.refTree=e,s.refOffsetX=r,s.refOffsetY=n,s}_updateRangeFlatten(){const e=this._currentConfigService.isForceCalculate(),t=this._currentConfigService.getDirtyRanges();if(!e){this._updateRangeFlattenCache.clear();for(let r=0;r<t.length;r++){const n=t[r],s=n.range,a=n.sheetId,u=n.unitId;this._addFlattenCache(u,a,s)}}}_addFlattenCache(e,t,r){let n=this._updateRangeFlattenCache.get(e);n==null&&(n=new Map,this._updateRangeFlattenCache.set(e,n));let s=n.get(t);s==null&&(s=[],n.set(t,s)),s.push(r)}_isPreCalculateNode(e){return e.nodeType===ue.UNION||e.nodeType===ue.PREFIX&&e.getToken()===pe.AT||e.nodeType===ue.SUFFIX&&e.getToken()===He.POUND}_nodeTraversalRef(e,t){const r=e.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(this._isPreCalculateNode(a)){t.push(a);continue}else a.nodeType===ue.REFERENCE&&t.push(a);this._nodeTraversalRef(a,t)}}_nodeTraversalReferenceFunction(e,t){const r=e.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.nodeType===ue.FUNCTION&&a.isAddress()){t.push(a);continue}this._nodeTraversalReferenceFunction(a,t)}}async _executeNode(e,t=0,r=0){let n;const s={node:e,refOffsetX:t,refOffsetY:r};return this._interpreter.checkAsyncNode(e)?n=await this._interpreter.executeAsync(s):n=this._interpreter.execute(s),n}async _getRangeListByNode(e){const t=[],r=[],n=e.refOffsetX,s=e.refOffsetY,a=e.node;if(a==null)return[];this._nodeTraversalRef(a,t),this._nodeTraversalReferenceFunction(a,r);const u=[];for(let c=0,l=t.length;c<l;c++){const f=t[c],d=(await this._executeNode(f,n,s)).toUnitRange();u.push(d),f.setValue(null)}for(let c=0,l=r.length;c<l;c++){const f=r[c],d=(await this._executeNode(f,n,s)).toUnitRange();u.push(d),f.setValue(null)}return u}_getUpdateTreeListAndMakeDependency(e){const t=[],r=new Set,n=this._currentConfigService.isForceCalculate(),s=this._currentConfigService.getDirtyRanges(),a=this._dependencyManagerService.searchDependency(s),u=this._dependencyManagerService.buildDependencyTree(e);for(const c of u){const l=c.treeId;(n||c.isDirty||c.dependencySheetName(this._currentConfigService.getDirtyNameMap())||a.has(l)&&!c.isExcludeRange(this._currentConfigService.getExcludedRange()))&&!r.has(l)&&(t.push(c),r.add(l))}return t}_includeTreeFeature(e){var s,a;const t=e.unitId,r=e.subUnitId,n=e.featureId;if(n!=null){const u=this._currentConfigService.getDirtyUnitFeatureMap();if(((a=(s=u==null?void 0:u[t])==null?void 0:s[r])==null?void 0:a[n])!=null)return!0}return!1}_includeOtherFormula(e){var s,a;const t=e.unitId,r=e.subUnitId,n=e.formulaId;if(n!=null){const u=this._currentConfigService.getDirtyUnitOtherFormulaMap();if(((a=(s=u==null?void 0:u[t])==null?void 0:s[r])==null?void 0:a[n])!=null)return!0}return!1}_detectForcedRecalculationNode(e,t){return t==null?!1:this._detectForcedRecalculationNodeRecursion(t)}_detectForcedRecalculationNodeRecursion(e){if(e.isForcedCalculateFunction())return!0;const t=e.getChildren();for(let r=0,n=t.length;r<n;r++){const s=t[r];if(this._detectForcedRecalculationNodeRecursion(s))return!0}return!1}_includeTree(e,t){var l,f,m;const r=e.unitId,n=e.subUnitId;if(this._detectForcedRecalculationNode(e,t)===!0||this._includeTreeFeature(e)===!0||this._includeOtherFormula(e)===!0||Zf(e,t,this._currentConfigService)===!0)return!0;const s=(f=(l=this._currentConfigService.getExcludedRange())==null?void 0:l[r])==null?void 0:f[n];if((s==null?void 0:s.getValue(e.row,e.column))!=null)return!1;if(((m=this._currentConfigService.getDirtyNameMap()[r])==null?void 0:m[n])!=null)return!0;if(!this._updateRangeFlattenCache.has(r))return!1;const u=this._updateRangeFlattenCache.get(r);if(!u.has(n))return!1;const c=u.get(n);for(const d of c)if(e.inRangeData(d))return!0;return!1}_calculateRunList(e){const t=e,r=[],n=[];for(;t.length>0;){const s=t.pop();if(!(s===void 0||s.isSkip())){if(s.isAdded()){r.push(s),s.setSkip();continue}n.length=0;for(const a of s.parents){const u=this._dependencyManagerService.getTreeById(a);if(!u)throw new Error("ParentDependencyTree object is null");u.isAdded()||s.isSkip()||n.push(u)}n.length===0?(r.push(s),s.setSkip()):(s.setAdded(),t.push(s,...n))}}return r}};exports.FormulaDependencyGenerator=em([_t(0,mt),_t(1,st),_t(2,vn),_t(3,ar),_t(4,M.Inject(exports.Interpreter)),_t(5,M.Inject(exports.AstTreeBuilder)),_t(6,M.Inject(exports.Lexer)),_t(7,wr)],exports.FormulaDependencyGenerator);var tm=Object.defineProperty,rm=Object.getOwnPropertyDescriptor,nm=(i,o,e,t)=>{for(var r=t>1?void 0:t?rm(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&tm(o,e,r),r},jt=(i,o)=>(e,t)=>o(e,t,i);const sm=1,Ki=500,cn=M.createIdentifier("engine-formula.calculate-formula.service");exports.CalculateFormulaService=class extends M.Disposable{constructor(e,t,r,n,s,a,u){super();A(this,"_executionInProgressListener$",new Jt.Subject);A(this,"executionInProgressListener$",this._executionInProgressListener$.asObservable());A(this,"_executionCompleteListener$",new Jt.Subject);A(this,"executionCompleteListener$",this._executionCompleteListener$.asObservable());this._configService=e,this._lexer=t,this._currentConfigService=r,this._runtimeService=n,this._formulaDependencyGenerator=s,this._interpreter=a,this._astTreeBuilder=u}stopFormulaExecution(){this._runtimeService.stopExecution()}setRuntimeFeatureCellData(e,t){this._runtimeService.setRuntimeFeatureCellData(e,t)}setRuntimeFeatureRange(e,t){this._runtimeService.setRuntimeFeatureRange(e,t)}async execute(e){this._runtimeService.setFormulaExecuteStage(ze.START),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._currentConfigService.load(e),this._runtimeService.reset();const t=this._configService.getConfig("CYCLE_REFERENCE_COUNT")||sm;for(let r=0;r<t&&(this._runtimeService.setFormulaCycleIndex(r),await this._execute(),Cs.clear(),!!this._runtimeService.isCycleDependency());r++);this._runtimeService.setFormulaExecuteStage(ze.CALCULATION_COMPLETED),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData()),Et.clear(),this._runtimeService.reset()}async _execute(){const e=await this._apply();if(e==null)return;const{arrayFormulaRange:t,runtimeFeatureRange:r}=e,{dirtyRanges:n,excludedCell:s}=this._getArrayFormulaDirtyRangeAndExcludedRange(t,r);return n==null||n.length===0||(this._currentConfigService.loadDirtyRangesAndExcludedCell(n,s),await this._apply(!0)),!0}_getArrayFormulaDirtyRangeAndExcludedRange(e,t){const r=[],n={};return Object.keys(e).forEach(s=>{const a=e[s];if(a==null)return!0;Object.keys(a).forEach(u=>{const c=new M.ObjectMatrix(a[u]);if(c==null)return!0;const l=new M.ObjectMatrix;c.forValue((f,m,d)=>{l.setValue(f,m,!0),r.push({unitId:s,sheetId:u,range:d})}),n[s]==null&&(n[s]={}),n[s][u]=l})}),Object.keys(t).forEach(s=>{const a=t[s];Object.keys(a).forEach(u=>{const c=a[u];if(c==null)return!0;Object.keys(c).forEach(l=>{const f=c[l];if(f==null)return!0;for(const m of f)r.push({unitId:u,sheetId:l,range:m})})})}),{dirtyRanges:r,excludedCell:n}}async _apply(e=!1){e?this._runtimeService.setFormulaExecuteStage(ze.START_DEPENDENCY_ARRAY_FORMULA):this._runtimeService.setFormulaExecuteStage(ze.START_DEPENDENCY),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());const t=(await this._formulaDependencyGenerator.generate()).reverse(),r=this._interpreter;e?(this._runtimeService.setFormulaExecuteStage(ze.START_CALCULATION_ARRAY_FORMULA),this._runtimeService.setTotalArrayFormulasToCalculate(t.length)):(this._runtimeService.setFormulaExecuteStage(ze.START_CALCULATION),this._runtimeService.setTotalFormulasToCalculate(t.length)),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());let n=[];const s=this._configService.getConfig(On),a=(s==null?void 0:s.intervalCount)||Ki,u=t.length;for(let c=0;c<u;c++){const l=t[c],f=l.nodeData,m=l.getDirtyData;if(c%a===0&&(await new Promise(C=>{const _=M.requestImmediateMacroTask(C);n.push(_)}),e?(this._runtimeService.setFormulaExecuteStage(ze.CURRENTLY_CALCULATING_ARRAY_FORMULA),this._runtimeService.setCompletedArrayFormulasCount(c+1)):(this._runtimeService.setFormulaExecuteStage(ze.CURRENTLY_CALCULATING),this._runtimeService.setCompletedFormulasCount(c+1)),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._runtimeService.isStopExecution()||f==null&&m==null)){this._runtimeService.setFormulaExecuteStage(ze.IDLE),this._runtimeService.markedAsStopFunctionsExecuted(),this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData());return}this._runtimeService.setCurrent(l.row,l.column,l.rowCount,l.columnCount,l.subUnitId,l.unitId);let d;if(m!=null&&l.featureId!=null){const{runtimeCellData:C,dirtyRanges:_}=m(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData());this._runtimeService.setRuntimeFeatureCellData(l.featureId,C),this._runtimeService.setRuntimeFeatureRange(l.featureId,_)}else f!=null&&(r.checkAsyncNode(f.node)?d=await r.executeAsync(f):d=r.execute(f),l.formulaId!=null?this._runtimeService.setRuntimeOtherData(l.formulaId,l.refOffsetX,l.refOffsetY,d):this._runtimeService.setRuntimeData(d))}return n.forEach(c=>c()),n=[],u>0?this._runtimeService.markedAsSuccessfullyExecuted():e||this._runtimeService.markedAsNoFunctionsExecuted(),this._runtimeService.getAllRuntimeData()}calculate(e,t=!0){const r=this._lexer.treeBuilder(e,t);if(Object.values(h).includes(r))return De.create(r);const n=this._astTreeBuilder.parse(r);n==null||n.serialize()}};exports.CalculateFormulaService=nm([jt(0,M.IConfigService),jt(1,M.Inject(exports.Lexer)),jt(2,mt),jt(3,st),jt(4,un),jt(5,M.Inject(exports.Interpreter)),jt(6,M.Inject(exports.AstTreeBuilder))],exports.CalculateFormulaService);var am=Object.defineProperty,im=Object.getOwnPropertyDescriptor,om=(i,o,e,t)=>{for(var r=t>1?void 0:t?im(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&am(o,e,r),r},zn=(i,o)=>(e,t)=>o(e,t,i);exports.CalculateController=class extends M.Disposable{constructor(o,e,t){super(),this._commandService=o,this._calculateFormulaService=e,this._formulaDataModel=t,this._initialize()}_initialize(){this._commandExecutedListener(),this._initialExecuteFormulaListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(o.id===Ns.id)this._calculateFormulaService.stopFormulaExecution();else if(o.id===Rn.id){const e=o.params.formulaData;this._formulaDataModel.mergeFormulaData(e)}else if(o.id===ps.id){const e=o.params;this._calculate(e)}else if(o.id===Zr.id){const e=o.params;if(e==null)return;const{arrayFormulaRange:t,arrayFormulaCellData:r}=e;this._formulaDataModel.setArrayFormulaRange(t),this._formulaDataModel.setArrayFormulaCellData(r)}}))}async _calculate(o){const{forceCalculation:e=!1,dirtyRanges:t=[],dirtyNameMap:r={},dirtyDefinedNameMap:n={},dirtyUnitFeatureMap:s={},dirtyUnitOtherFormulaMap:a={},clearDependencyTreeCache:u={}}=o,c=this._formulaDataModel.getFormulaData(),l=this._formulaDataModel.getArrayFormulaCellData(),f=this._formulaDataModel.getArrayFormulaRange();this._calculateFormulaService.execute({formulaData:c,arrayFormulaCellData:l,arrayFormulaRange:f,forceCalculate:e,dirtyRanges:t,dirtyNameMap:r,dirtyDefinedNameMap:n,dirtyUnitFeatureMap:s,dirtyUnitOtherFormulaMap:a,clearDependencyTreeCache:u})}_initialExecuteFormulaListener(){this._calculateFormulaService.executionCompleteListener$.subscribe(o=>{const e=o.functionsExecutedState;switch(e){case zt.NOT_EXECUTED:break;case zt.STOP_EXECUTION:break;case zt.SUCCESS:this._applyResult(o);break;case zt.INITIAL:break}this._commandService.executeCommand(en.id,{functionsExecutedState:e},{onlyLocal:!0})}),this._calculateFormulaService.executionInProgressListener$.subscribe(o=>{this._commandService.executeCommand(en.id,{stageInfo:o},{onlyLocal:!0})})}async _applyResult(o){const{unitData:e,unitOtherData:t,arrayFormulaRange:r,arrayFormulaCellData:n,clearArrayFormulaCellData:s}=o;if(!e){console.error("No sheetData from Formula Engine!");return}r&&(this._formulaDataModel.clearPreviousArrayFormulaCellData(s),this._formulaDataModel.mergeArrayFormulaCellData(n),this._formulaDataModel.mergeArrayFormulaRange(r),this._commandService.executeCommand(Zr.id,{arrayFormulaRange:this._formulaDataModel.getArrayFormulaRange(),arrayFormulaCellData:this._formulaDataModel.getArrayFormulaCellData()},{onlyLocal:!0})),this._commandService.executeCommand(Vs.id,{unitData:Fu(e),unitOtherData:t},{onlyLocal:!0})}};exports.CalculateController=om([zn(0,M.ICommandService),zn(1,cn),zn(2,M.Inject(exports.FormulaDataModel))],exports.CalculateController);var um=Object.defineProperty,cm=Object.getOwnPropertyDescriptor,lm=(i,o,e,t)=>{for(var r=t>1?void 0:t?cm(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&um(o,e,r),r},Ta=(i,o)=>(e,t)=>o(e,t,i);exports.SetDefinedNameController=class extends M.Disposable{constructor(o,e){super(),this._commandService=o,this._definedNamesService=e,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(o.id===Vr.id){const e=o.params;if(e==null)return;const{id:t,unitId:r,name:n,formulaOrRefString:s,comment:a,hidden:u,localSheetId:c}=e;this._definedNamesService.registerDefinedName(r,{id:t,name:n.trim(),formulaOrRefString:s.trim(),comment:a==null?void 0:a.trim(),hidden:u,localSheetId:c})}else if(o.id===En.id){const e=o.params;if(e==null)return;const{unitId:t,id:r}=e;this._definedNamesService.removeDefinedName(t,r)}}))}};exports.SetDefinedNameController=lm([Ta(0,M.ICommandService),Ta(1,lr)],exports.SetDefinedNameController);const Ba=/[\[\]]/g;function Ia(i,o){if(Ba.test(i)){const e=Number(i.replace(Ba,""));return o+e}return Number(i)-1}function Jn(i,o=0,e=0){i=i.toLocaleUpperCase();const t=i.split(/[RC]/),r=t[1],n=t[2],s=Ia(r,o),a=Ia(n,e);return{row:s,column:a,absoluteRefType:M.AbsoluteRefType.NONE}}function Zi(i,o=0,e=0){const{refBody:t,sheetName:r,unitId:n}=An(i),s=t.indexOf(":");if(s===-1){const _=Jn(t,o,e),E=_.row,b=_.column,R=_.absoluteRefType;return{unitId:n,sheetName:r,range:{startRow:E,startColumn:b,endRow:E,endColumn:b,startAbsoluteRefType:R,endAbsoluteRefType:R}}}const a=t.substring(0,s),u=t.substring(s+1),c=Jn(a,o,e),l=Jn(u,o,e),f=c.row,m=c.column,d=l.row,C=l.column;return{unitId:n,sheetName:r,range:{startRow:f,startColumn:m,endRow:d,endColumn:C,startAbsoluteRefType:c.absoluteRefType,endAbsoluteRefType:l.absoluteRefType}}}function fm(i){const o=Tr(i.startRow,i.startAbsoluteRefType,!0),e=Tr(i.startColumn,i.startAbsoluteRefType,!1),t=Tr(i.endRow,i.endAbsoluteRefType,!0),r=Tr(i.endColumn,i.endAbsoluteRefType,!1);return o===t&&e===r?`R${o}C${e}`:`R${o}C${e}:R${t}C${r}`}function Tr(i,o=M.AbsoluteRefType.ALL,e){switch(i+=1,o){case M.AbsoluteRefType.ALL:return`${i}`;case M.AbsoluteRefType.ROW:return e?`${i}`:`[${i}]`;case M.AbsoluteRefType.COLUMN:return e?`[${i}]`:`${i}`;case M.AbsoluteRefType.NONE:return`[${i}]`}}const zi=[];var Ji=(i=>i)(Ji||{});class N{constructor(o){A(this,"_unitId");A(this,"_subUnitId");A(this,"_row",-1);A(this,"_column",-1);A(this,"_definedNames");A(this,"_locale");A(this,"_sheetOrder");A(this,"_sheetNameMap");A(this,"_formulaDataModel");A(this,"_rowCount",-1);A(this,"_columnCount",-1);A(this,"needsExpandParams",!1);A(this,"needsReferenceObject",!1);A(this,"needsLocale",!1);A(this,"needsSheetsInfo",!1);A(this,"needsFormulaDataModel",!1);A(this,"needsSheetRowColumnCount",!1);A(this,"minParams",-1);A(this,"maxParams",-1);this._name=o}get name(){return this._name}get unitId(){return this._unitId}get subUnitId(){return this._subUnitId}get row(){return this._row}get column(){return this._column}dispose(){}getDefinedName(o){var t;const e=this._definedNames;return e==null?null:(t=Array.from(Object.values(e)).filter(r=>r.name===o))==null?void 0:t[0]}setDefinedNames(o){this._definedNames=o}getLocale(){return this._locale}setLocale(o){this._locale=o}getSheetsInfo(){return{sheetOrder:this._sheetOrder,sheetNameMap:this._sheetNameMap}}setSheetsInfo({sheetOrder:o,sheetNameMap:e}){this._sheetOrder=o,this._sheetNameMap=e}setFormulaDataModel(o){this._formulaDataModel=o}setSheetRowColumnCount(o,e){this._rowCount=o,this._columnCount=e}isAsync(){return!1}isAddress(){return!1}isCustom(){return!1}setRefInfo(o,e,t,r){this._unitId=o,this._subUnitId=e,this._row=t,this._column=r}calculateCustom(...o){return null}calculate(...o){return g.create(h.VALUE)}checkArrayType(o){return o.isReferenceObject()||o.isValueObject()&&o.isArray()}getIndexNumValue(o,e=1){let t=o;if(t.isArray()&&(t=t.getFirstCell()),t.isBoolean())return t.getValue()===!1?g.create(h.VALUE):e;if(t.isString()){const r=Number(t.getValue());return Number.isNaN(r)?g.create(h.REF):r}else if(t.isNumber())return t.getValue();return g.create(h.VALUE)}getZeroOrOneByOneDefault(o){if(o==null)return 1;let e=1;if(o.isArray()&&(o=o.getFirstCell()),o.isBoolean())o.getValue()===!1&&(e=0);else{if(o.isString())return;o.isNumber()&&o.getValue()===0&&(e=0)}return e}getMatchTypeValue(o){if(o==null)return 1;let e=1;if(o.isArray()&&(o=o.getFirstCell()),o.isBoolean())o.getValue()===!1&&(e=0);else{if(o.isString())return;if(o.isNumber()){const t=o.getValue();t<=0&&(e=t)}}return e}binarySearch(o,e,t,r,n){const s=e.binarySearch(o,r,n);if(s==null)return g.create(h.NA);let a;return t.getRowCount()===1?a=t.get(0,s)||ae.create():a=t.get(s,0)||ae.create(),a.isNull()?y.create(0):a}_getOneFirstByRaw(o){return o.length===0?g.create(h.NA):o[0][0]||g.create(h.NA)}_getOneLastByRaw(o){return o.length===0?g.create(h.NA):o[o.length-1][o[0].length-1]||g.create(h.NA)}equalSearch(o,e,t,r=!0){const n=t.pickRaw(e.isEqual(o));return r?this._getOneFirstByRaw(n):this._getOneLastByRaw(n)}fuzzySearch(o,e,t,r=!0){const n=t.pickRaw(e.compare(o,$.EQUALS));return r?this._getOneFirstByRaw(n):this._getOneLastByRaw(n)}orderSearch(o,e,t,r=Oe.MIN,n=!1){const s=e.orderSearch(o,r,n);if(s==null)return g.create(h.NA);const a=t.get(s.row,s.column)||ae.create();return a.isNull()?g.create(h.NA):a}binarySearchExpand(o,e,t,r=0,n,s){const a=e.binarySearch(o,n,s);return a==null?g.create(h.NA):r===0?t.slice([a,a+1]):t.slice(void 0,[a,a+1])}equalSearchExpand(o,e,t,r=!0,n=0){const s=e.isEqual(o);let a;return r?a=s.getFirstTruePosition():a=s.getLastTruePosition(),a==null?g.create(h.NA):n===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}fuzzySearchExpand(o,e,t,r=!0,n=0){const s=e.compare(o,$.EQUALS);let a;return r?a=s.getFirstTruePosition():a=s.getLastTruePosition(),a==null?g.create(h.NA):n===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}orderSearchExpand(o,e,t,r=Oe.MIN,n=!1,s=0){const a=e.orderSearch(o,r,n);return a==null?g.create(h.NA):s===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}flattenArray(o,e=!0){const t=[];t[0]=[];for(let r=0;r<o.length;r++){let n=o[r];if((n.isString()||n.isBoolean()||n.isNull())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()){let s;if(n.iterator(a=>{if(a==null||a.isNull()||e&&(a.isString()||a.isBoolean()))return!0;if(a=this._includingLogicalValuesAndText(a),a.isError())return s=a,!1;t[0].push(a)}),s!=null&&s.isError())return s}else t[0].push(n)}return Ht(t,1,t[0].length)}_includingLogicalValuesAndText(o){if(o.isBoolean()&&(o=ef(o)),o.isString()){const e=Number(o.getValue());o=y.create(Number.isNaN(e)?0:e)}return o}createReferenceObject(o,e){const t=o.getForcedUnitId(),r=o.getForcedSheetId()||"",n=o.getForcedSheetName(),a=zr({unitId:t,sheetName:n,range:e});let u;return Nr(a)?u=new Ps(a):li(a)?u=new xs(a):fi(a)?u=new Ls(a):u=new Rr(e,r,t),this._setReferenceDefault(o,u)}_setReferenceDefault(o,e){return this.unitId==null||this.subUnitId==null?g.create(h.REF):(e.setDefaultUnitId(this.unitId),e.setDefaultSheetId(this.subUnitId),e.setUnitData(o.getUnitData()),e.setRuntimeData(o.getRuntimeData()),e.setArrayFormulaCellData(o.getArrayFormulaCellData()),e.setRuntimeArrayFormulaCellData(o.getRuntimeArrayFormulaCellData()),e)}}var ir;(i=>{const o=.636619772;function e(n,s){let a=0;for(let u=0;u<n.length;++u)a=s*a+n[u];return a}function t(n,s,a,u,c){if(s===0)return a;if(s===1)return u;const l=2/n;let f=a,m=u,d=u;for(let C=1;C<s;++C)d=m*C*l+c*f,f=m,m=d;return d}function r(n,s,a,u){return function(l,f){if(a){if(l===0)return a===1?-1/0:1/0;if(l<0)return Number.NaN}if(f===0)return n(l);if(f===1)return s(l);if(f<0)return Number.NaN;const m=f|0,d=n(l),C=s(l);return t(l,m,d,C,u)}}i.besselj=(()=>{const n=[-184.9052456,77392.33017,-1121442418e-2,6516196407e-1,-13362590354,57568490574],s=[1,267.8532712,59272.64853,9494680718e-3,1029532985,57568490411],a=[2093887211e-16,-2073370639e-15,2734510407e-14,-.001098628627,1],u=[-934935152e-16,7621095161e-16,-6911147651e-15,.0001430488765,-.01562499995];function c(_){let E=0,b=0,R=0,p=_*_;if(_<8)b=e(n,p),R=e(s,p),E=b/R;else{const V=_-.785398164;p=64/p,b=e(a,p),R=e(u,p),E=Math.sqrt(o/_)*(Math.cos(V)*b-Math.sin(V)*R*8/_)}return E}const l=[-30.16036606,15704.4826,-2972611439e-3,2423968531e-1,-7895059235,72362614232],f=[1,376.9991397,99447.43394,1858330474e-2,2300535178,144725228442],m=[-240337019e-15,2457520174e-15,-3516396496e-14,.00183105,1],d=[105787412e-15,-88228987e-14,8449199096e-15,-.0002002690873,.04687499995];function C(_){let E=0,b=0,R=0,p=_*_;const V=Math.abs(_)-2.356194491;return Math.abs(_)<8?(b=_*e(l,p),R=e(f,p),E=b/R):(p=64/p,b=e(m,p),R=e(d,p),E=Math.sqrt(o/Math.abs(_))*(Math.cos(V)*b-Math.sin(V)*R*8/Math.abs(_)),_<0&&(E=-E)),E}return function _(E,b){const R=Math.round(b);if(!Number.isFinite(E))return Number.isNaN(E)?E:0;if(R<0)return(R%2?-1:1)*_(E,-R);if(E<0)return(R%2?-1:1)*_(-E,R);if(R===0)return c(E);if(R===1)return C(E);if(E===0)return 0;let p=0;if(E>R)p=t(E,R,c(E),C(E),-1);else{const V=2*Math.floor((R+Math.floor(Math.sqrt(40*R)))/2);let S=!1,D=0,w=0,P=1,L=0;const T=2/E;for(let B=V;B>0;B--)if(L=B*T*P-D,D=P,P=L,Math.abs(P)>1e10&&(P*=1e-10,D*=1e-10,p*=1e-10,w*=1e-10),S&&(w+=P),S=!S,B===R&&(p=D),V-B>100&&p===0)return Number.NaN;w=2*w-P,p/=w}return p}})(),i.bessely=(()=>{const n=[228.4622733,-86327.92757,1087988129e-2,-5123598036e-1,7062834065,-2957821389],s=[1,226.1030244,47447.2647,7189466438e-3,7452499648e-1,40076544269],a=[2093887211e-16,-2073370639e-15,2734510407e-14,-.001098628627,1],u=[-934945152e-16,7621095161e-16,-6911147651e-15,.0001430488765,-.01562499995];function c(_){let E=0,b=0,R=0,p=_*_;const V=_-.785398164;return _<8?(b=e(n,p),R=e(s,p),E=b/R+o*(0,i.besselj)(_,0)*Math.log(_)):(p=64/p,b=e(a,p),R=e(u,p),E=Math.sqrt(o/_)*(Math.sin(V)*b+Math.cos(V)*R*8/_)),E}const l=[8511.937935,-4237922726e-3,7349264551e-1,-51534381390,127527439e4,-4900604943e3],f=[1,354.9632885,102042.605,2245904002e-2,3733650367,424441966400,249958057e5],m=[-240337019e-15,2457520174e-15,-3516396496e-14,.00183105,1],d=[105787412e-15,-88228987e-14,8449199096e-15,-.0002002690873,.04687499995];function C(_){let E=0,b=0,R=0,p=_*_;const V=_-2.356194491;return _<8?(b=_*e(l,p),R=e(f,p),E=b/R+o*((0,i.besselj)(_,1)*Math.log(_)-1/_)):(p=64/p,b=e(m,p),R=e(d,p),E=Math.sqrt(o/_)*(Math.sin(V)*b+Math.cos(V)*R*8/_)),E}return r(c,C,1,-1)})(),i.besseli=(()=>{const n=[.0045813,.0360768,.2659732,1.2067492,3.0899424,3.5156229,1],s=[.00392377,-.01647633,.02635537,-.02057706,.00916281,-.00157565,.00225319,.01328592,.39894228];function a(f){return f<=3.75?e(n,f*f/(3.75*3.75)):Math.exp(Math.abs(f))/Math.sqrt(Math.abs(f))*e(s,3.75/Math.abs(f))}const u=[32411e-8,.00301532,.02658733,.15084934,.51498869,.87890594,.5],c=[-.00420059,.01787654,-.02895312,.02282967,-.01031555,.00163801,-.00362018,-.03988024,.39894228];function l(f){return f<3.75?f*e(u,f*f/(3.75*3.75)):(f<0?-1:1)*Math.exp(Math.abs(f))/Math.sqrt(Math.abs(f))*e(c,3.75/Math.abs(f))}return function f(m,d){const C=Math.round(d);if(C===0)return a(m);if(C===1)return l(m);if(C<0)return Number.NaN;if(Math.abs(m)===0)return 0;if(m===1/0)return 1/0;let _=0,E;const b=2/Math.abs(m);let R=0,p=1,V=0;const S=2*Math.round((C+Math.round(Math.sqrt(40*C)))/2);for(E=S;E>0;E--)if(V=E*b*p+R,R=p,p=V,Math.abs(p)>1e10&&(p*=1e-10,R*=1e-10,_*=1e-10),E===C&&(_=R),S-E>100&&_===0)return Number.NaN;return _*=f(m,0)/p,m<0&&C%2?-_:_}})(),i.besselk=(()=>{const n=[74e-7,1075e-7,.00262698,.0348859,.23069756,.4227842,-.57721566],s=[53208e-8,-.0025154,.00587872,-.01062446,.02189568,-.07832358,1.25331414];function a(f){return f<=2?-Math.log(f/2)*(0,i.besseli)(f,0)+e(n,f*f/4):Math.exp(-f)/Math.sqrt(f)*e(s,2/f)}const u=[-4686e-8,-.00110404,-.01919402,-.18156897,-.67278579,.15443144,1],c=[-68245e-8,.00325614,-.00780353,.01504268,-.0365562,.23498619,1.25331414];function l(f){return f<=2?Math.log(f/2)*(0,i.besseli)(f,1)+1/f*e(u,f*f/4):Math.exp(-f)/Math.sqrt(f)*e(c,2/f)}return r(a,l,2,1)})()})(ir||(ir={}));function Is(i){return/^[01]{1,10}$/.test(i)}function Fs(i){return/^[0-7]{1,10}$/.test(i)}function ks(i){return/^[0-9A-Fa-f]{1,10}$/.test(i)}function Ft(i){if(i===0)return 0;const o=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18];let e=i,t=!1;e<0&&(e=-e,t=!0);const r=2/(2+e),n=4*r-2;let s=0,a=0,u;for(let l=o.length-1;l>0;l--)u=s,s=n*s-a+o[l],a=u;const c=r*Math.exp(-e*e+.5*(o[0]+n*s)-a);return t?c-1:1-c}function $s(i){return 1-Ft(i)}function mm(i){if(i>=2)return-100;if(i<=0)return 100;const o=i<1?i:2-i,e=Math.sqrt(-2*Math.log(o/2));let t=-.70711*((2.30753+e*.27061)/(1+e*(.99229+e*.04481))-e);for(let r=0;r<2;r++){const n=$s(t)-o;t+=n/(1.1283791670955126*Math.exp(-t*t)-t*n)}return i<1?t:-t}function er(i,o=1){let e=Math.floor(i);if(i<0)return Number.NaN;let t=1;for(;e>1&&Number.isFinite(t);)t*=e,e-=o;return t}function kt(i,o){const e=Math.min(i-o,o);let t=1;for(let r=1;r<=e&&Number.isFinite(t);r++)t*=i-r+1,t/=r;return t}function bs(i,o){let e=Math.floor(i),t=Math.floor(o);for(;t!==0;){const r=t;t=e%t,e=r}return e}function Fa(i,o){const e=bs(i,o);return e===0?0:Math.abs(i*o)/e}function Tn(i){const o=i.length;if(o===1)return i[0][0];if(o===2)return i[0][0]*i[1][1]-i[0][1]*i[1][0];let e=0;for(let t=0;t<o;t++)e+=(t%2===0?1:-1)*i[0][t]*Tn(eo(i,0,t));return e}function hm(i){const o=Tn(i);return o===0?null:i.length===1?[[1/o]]:gm(i).map(r=>r.map(n=>n/o))}function eo(i,o,e){return i.filter((t,r)=>r!==o).map(t=>t.filter((r,n)=>n!==e))}function gm(i){const o=i.length,e=Array.from({length:o},()=>new Array(o).fill(0));for(let t=0;t<o;t++)for(let r=0;r<o;r++){const n=(t+r)%2===0?1:-1;e[r][t]=n*Tn(eo(i,t,r))}return e}function tr(i,o){return i.map(e=>o[0].map((t,r)=>e.reduce((n,s,a)=>n+s*o[a][r],0)))}function yt(i){return i[0].map((o,e)=>i.map(t=>t[e]))}function dm(i){const o=Cm(i);if(!o)return null;const{matrixU:e,matrixS:t,matrixV:r}=o,n=yt(e),s=Array.from({length:t.length},()=>new Array(i[0].length).fill(0)),a=Math.max(i.length,i[0].length)*Number.EPSILON*t[0];for(let u=0;u<t.length;u++)Math.abs(t[u])>a&&(s[u][u]=1/t[u]);return tr(r,tr(s,n))}function Cm(i){const o=yt(i),e=o.length,t=o[0].length;if(e<t)return null;const r=new Array(t).fill(0),n=new Array(t).fill(0),s=Array.from({length:t},()=>new Array(t).fill(0));let a=Number.EPSILON,u=0,c=0,l=0;for(let _=0;_<t;_++){if(r[_]=u,c=es(o,_,e,_,_),c<=1e-64/a)u=0;else{u=Math.sqrt(c),o[_][_]>=0&&(u=-u);const b=o[_][_]*u-c;o[_][_]-=u;for(let R=_+1;R<t;R++){c=es(o,_,e,_,R);for(let p=_;p<e;p++)o[p][R]+=c/b*o[p][_]}}if(n[_]=u,c=ka(o,_+1,t,_,_),c<=1e-64/a)u=0;else{u=Math.sqrt(c),o[_][_+1]>=0&&(u=-u);const b=o[_][_+1]*u-c;o[_][_+1]-=u;for(let R=_+1;R<t;R++)r[R]=o[_][R]/b;for(let R=_+1;R<e;R++){c=ka(o,_+1,t,R,_);for(let p=_+1;p<t;p++)o[R][p]+=c*r[p]}}const E=Math.abs(n[_])+Math.abs(r[_]);E>l&&(l=E)}let f=0;for(let _=t-1;_>=0;_--){if(u!==0){for(let E=f;E<t;E++)s[E][_]=o[_][E]/(u*o[_][_+1]);for(let E=f;E<t;E++){c=0;for(let b=f;b<t;b++)c+=o[_][b]*s[b][E];for(let b=f;b<t;b++)s[b][E]+=c*s[b][_]}}for(let E=f;E<t;E++)s[_][E]=0,s[E][_]=0;s[_][_]=1,u=r[_],f=_}for(let _=t-1;_>=0;_--){u=n[_];for(let E=_+1;E<t;E++)o[_][E]=0;if(u!==0){for(let E=_+1;E<t;E++){c=es(o,_+1,e,_,E);for(let b=_;b<e;b++)o[b][E]+=c/(o[_][_]*u)*o[b][_]}for(let E=_;E<e;E++)o[E][_]/=u}else for(let E=_;E<e;E++)o[E][_]=0;o[_][_]+=1}a*=l;let m=0,d=0,C=0;for(let _=t-1;_>=0;_--)for(let E=0;E<50;E++){let b=!1,R=_;for(;R>=0;R--){if(Math.abs(r[R])<=a){b=!0;break}if(Math.abs(n[R-1])<=a)break}if(!b){let D=0,w=1;for(let P=R;P<_+1&&(m=w*r[P],d=n[P],r[P]*=D,!(Math.abs(m)<=a));P++){C=Br(m,d),n[P]=C,D=d/C,w=-m/C;for(let L=0;L<e;L++){const T=o[L][R-1],B=o[L][P];o[L][R-1]=T*D+B*w,o[L][P]=-T*w+B*D}}}if(R===_){if(n[_]<0){n[_]=-n[_];for(let D=0;D<t;D++)s[D][_]=-s[D][_]}break}if(E>=49)return null;let p=n[R];m=((n[_-1]-n[_])*(n[_-1]+n[_])+(r[_-1]-r[_])*(r[_-1]+r[_]))/(2*r[_]*n[_-1]),C=Br(m,1),m<0?m=((p-n[_])*(p+n[_])+r[_]*(n[_-1]/(m-C)-r[_]))/p:m=((p-n[_])*(p+n[_])+r[_]*(n[_-1]/(m+C)-r[_]))/p;let V=1,S=1;for(let D=R+1;D<_+1;D++){let w=r[D],P=n[D];d=S*w,w*=V,C=Br(m,d),r[D-1]=C,V=m/C,S=d/C,m=p*V+w*S,d=P*S,w=-p*S+w*V,P*=V;for(let L=0;L<t;L++){const T=s[L][D-1],B=s[L][D];s[L][D-1]=T*V+B*S,s[L][D]=-T*S+B*V}C=Br(m,d),n[D-1]=C,V=m/C,S=d/C,m=V*w+S*P,p=-S*w+V*P;for(let L=0;L<e;L++){const T=o[L][D-1],B=o[L][D];o[L][D-1]=T*V+B*S,o[L][D]=-T*S+B*V}}r[R]=0,r[_]=m,n[_]=p}for(let _=0;_<n.length;_++)n[_]<a&&(n[_]=0);for(let _=0;_<t;_++)for(let E=_-1;E>=0;E--)if(n[E]<n[_]){const b=n[E];n[E]=n[_],n[_]=b;for(let R=0;R<o.length;R++){const p=o[R][_];o[R][_]=o[R][E],o[R][E]=p}for(let R=0;R<s.length;R++){const p=s[R][_];s[R][_]=s[R][E],s[R][E]=p}_=E}return{matrixU:o,matrixS:n,matrixV:s}}function Br(i,o){let e=0;return Math.abs(i)>Math.abs(o)?(e=o/i,Math.abs(i)*Math.sqrt(1+e*e)):o!==0?(e=i/o,Math.abs(o)*Math.sqrt(1+e*e)):0}function es(i,o,e,t,r){let n=0;for(let s=o;s<e;s++)n+=i[s][t]*i[s][r];return n}function ka(i,o,e,t,r){let n=0;for(let s=o;s<e;s++)n+=i[t][s]*i[r][s];return n}const Ir=new Map([["I",1],["V",5],["X",10],["L",50],["C",100],["D",500],["M",1e3]]),_m=new Map([[1,"I"],[4,"IV"],[5,"V"],[9,"IX"],[10,"X"],[40,"XL"],[45,"VL"],[49,"IL"],[50,"L"],[90,"XC"],[95,"VC"],[99,"IC"],[100,"C"],[400,"CD"],[450,"LD"],[490,"XD"],[495,"VD"],[499,"ID"],[500,"D"],[900,"CM"],[950,"LM"],[990,"XM"],[995,"VM"],[999,"IM"],[1e3,"M"]]),Am=[[1,4,5,9,10,40,50,90,100,400,500,900,1e3,4e3],[1,4,5,9,10,40,45,50,90,95,100,400,450,500,900,950,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,500,900,950,990,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,495,500,900,950,990,995,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,495,499,500,900,950,990,995,999,1e3,4e3]];function to(i,o,e){return i<=0?0:i>=1?1:Bn(i,o,e)}function Em(i,o,e){return i<=0||i>=1?0:o===1&&e===1?1:o<512&&e<512?i**(o-1)*(1-i)**(e-1)/Hs(o,e):Math.exp((o-1)*Math.log(i)+(e-1)*Math.log(1-i)-Gs(o,e))}function Ys(i,o,e){if(i<=0)return 0;if(i>=1)return 1;const t=1e-8;let r;if(o>=1&&e>=1){const c=i<.5?i:1-i,l=Math.sqrt(-2*Math.log(c));r=(2.30753+l*.27061)/(1+l*(.99229+l*.04481))-l,i<.5&&(r=-r);const f=(r*r-3)/6,m=2/(1/(2*o-1)+1/(2*e-1)),d=r*Math.sqrt(f+m)/m-(1/(2*e-1)-1/(2*o-1))*(f+5/6-2/(3*m));r=o/(o+e*Math.exp(2*d))}else{const c=Math.exp(o*Math.log(o/(o+e)))/o,l=Math.exp(e*Math.log(e/(o+e)))/e,f=c+l;i<c/f?r=(o*f*i)**(1/o):r=1-(e*f*(1-i))**(1/e)}const n=-Gs(o,e);let s,a,u;for(let c=0;c<10;c++){if(r===0||r===1)return r;if(s=Bn(r,o,e)-i,a=Math.exp((o-1)*Math.log(r)+(e-1)*Math.log(1-r)+n),u=s/a,r-=a=u/(1-.5*Math.min(1,u*((o-1)/r-(e-1)/(1-r)))),r<=0&&(r=.5*(r+a)),r>=1&&(r=.5*(r+a+1)),Math.abs(a)<t*r&&c>0)break}return r}function Bn(i,o,e){const t=i===0||i===1?0:Math.exp(rt(o+e)-rt(o)-rt(e)+o*Math.log(i)+e*Math.log(1-i));return i<(o+1)/(o+e+2)?t*$a(i,o,e)/o:1-t*$a(1-i,e,o)/e}function $a(i,o,e){let n=1-(o+e)*i/(o+1);Math.abs(n)<1e-8&&(n=1e-8),n=1/n;let s=1,a=n;for(let u=1;u<=100;u++){let c=u*(e-u)*i/((o-1+u*2)*(o+u*2));if(n=1+c*n,Math.abs(n)<1e-8&&(n=1e-8),s=1+c/s,Math.abs(s)<1e-8&&(s=1e-8),n=1/n,a*=n*s,c=-(o+u)*(o+e+u)*i/((o+u*2)*(o+1+u*2)),n=1+c*n,Math.abs(n)<1e-8&&(n=1e-8),s=1+c/s,Math.abs(s)<1e-8&&(s=1e-8),n=1/n,a*=n*s,Math.abs(n*s-1)<1e-8)break}return a}function Hs(i,o){return i+o>170?Math.exp(Gs(i,o)):Qr(i)*Qr(o)/Qr(i+o)}function Gs(i,o){return rt(i)+rt(o)-rt(i+o)}function ro(i,o,e){if(i<0)return 0;if(i>=o)return 1;if(e<0||e>1||o<=0)return Number.NaN;let t=0;for(let r=0;r<=i;r++)t+=Ws(r,o,e);return t}function Ws(i,o,e){return e===0||e===1?o*e===i?1:0:kt(o,i)*e**i*(1-e)**(o-i)}function Qs(i,o){return i<=0?0:Xs(o/2,i/2)}function bm(i,o){return i<0?0:i===0&&o===2?.5:Math.exp((o/2-1)*Math.log(i)-i/2-o/2*Math.log(2)-rt(o/2))}function no(i,o){return i<=0?0:i>=1?1/0:2*io(i,o/2)}function qs(i,o,e){return i<0?0:Bn(o*i/(o*i+e),o/2,e/2)}function ym(i,o,e){if(i<0)return 0;if(i===0&&o<2)return 1/0;if(i===0&&o===2)return 1;let t=1/Hs(o/2,e/2);return t*=(o/e)**(o/2),t*=i**(o/2-1),t*=(1+o/e*i)**(-(o+e)/2),t}function so(i,o,e){return i<=0?0:i>=1?1/0:e/(o*(1/Ys(i,o/2,e/2)-1))}function Rm(i,o){return i<0?0:1-Math.exp(-o*i)}function pm(i,o){return i<0?0:o*Math.exp(-o*i)}function ao(i,o,e){const t=o.length;let r=0,n=0;for(let m=0;m<t;m++)r+=o[m],n+=e[m];const s=r/t,a=n/t;let u=0,c=0;for(let m=0;m<t;m++)u+=(o[m]-s)*(e[m]-a),c+=(e[m]-a)**2;if(c===0)return 1/0;const l=u/c;return s-l*a+l*i}function Qr(i){const o=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],e=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535];let t=0,r=i;if(i>171.6243769536076)return 1/0;if(r<=0){const f=r%1+36e-17;if(f)t=(r&1?-1:1)*Math.PI/Math.sin(Math.PI*f),r=1-r;else return 1/0}const n=r;let s=0,a;r<1?a=r++:a=(r-=s=(r|0)-1)-1;let u=0,c=0;for(let f=0;f<8;++f)u=(u+o[f])*a,c=c*a+e[f];let l=u/c+1;if(n<r)l/=n;else if(n>r)for(let f=0;f<s;++f)l*=r,r++;return t&&(l=t/l),l}function Nm(i,o,e){return i<=0?0:Xs(o,i/e)}function Vm(i,o,e){return i<0?0:i===0&&o===1?1/e:Math.exp((o-1)*Math.log(i)-i/e-rt(o)-o*Math.log(e))}function Om(i,o,e){return i<=0?0:i>=1?1/0:e*io(i,o)}function rt(i){const o=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];let e=i,t=i+5.5;t-=(i+.5)*Math.log(t);let r=1.000000000190015;for(let n=0;n<6;n++)r+=o[n]/++e;return-t+Math.log(2.5066282746310007*r/i)}function Xs(i,o){if(o<0||i<=0)return Number.NaN;const e=1e-30,t=-~(Math.log(i>=1?i:1/i)*8.5+i*.4+17),r=rt(i),n=Math.exp(-o+i*Math.log(o)-r);let s=i,a=1/i,u=a;if(o<i+1){if(n===0)return 0;for(let d=1;d<=t&&(a+=u*=o/++s,!(Math.abs(u)<Math.abs(a)*e));d++);return a*n}if(n===0)return 1;let c=o+1-i,l=1/e,f=1/c,m=f;for(let d=1;d<=t;d++){const C=-d*(d-i);if(c+=2,f=C*f+c,Math.abs(f)<e&&(f=e),l=c+C/l,Math.abs(l)<e&&(l=e),f=1/f,m*=f*l,Math.abs(f*l-1)<e)break}return 1-m*n}function io(i,o){if(i<=0)return 0;if(i>=1)return Math.max(100,o+100*Math.sqrt(o));let e;if(o>1){const a=i<.5?i:1-i,u=Math.sqrt(-2*Math.log(a));e=(2.30753+u*.27061)/(1+u*(.99229+u*.04481))-u,i<.5&&(e=-e),e=Math.max(.001,o*(1-1/(9*o)-e/(3*Math.sqrt(o)))**3)}else{const a=1-o*(.253+o*.12);i<a?e=(i/a)**(1/o):e=1-Math.log(1-(i-a)/(1-a))}const t=1e-8,r=rt(o);let n,s;for(let a=0;a<12;a++){if(e<=0)return 0;if(n=Xs(o,e)-i,o>1?s=Math.exp((o-1)*(Math.log(o-1)-1)-r)*Math.exp(-(e-(o-1))+(o-1)*(Math.log(e)-Math.log(o-1))):s=Math.exp(-e+(o-1)*Math.log(e)-r),s!==0&&(s=n/s/(1-.5*Math.min(1,n/s*((o-1)/e-1)))),e-=s,e<=0&&(e=.5*(e+s)),Math.abs(s)<t*e)break}return e}function Mm(i,o,e,t){let r=0;for(let n=0;n<=i;n++)r+=Ks(n,o,e,t);return r}function Ks(i,o,e,t){return o-i>t-e?0:kt(e,i)*kt(t-e,o-i)/kt(t,o)}function oo(i,o,e){return i<0?0:.5+.5*Ft((Math.log(i)-o)/Math.sqrt(2*e*e))}function Sm(i,o,e){return i<=0?0:Math.exp(-Math.log(i)-.5*Math.log(2*Math.PI)-Math.log(e)-(Math.log(i)-o)**2/(2*e*e))}function Dm(i,o,e){return Math.exp(In(i,o,e))}function wm(i,o,e){if(i<0)return 0;let t=0;for(let r=0;r<=i;r++)t+=Zs(r,o,e);return t}function Zs(i,o,e){return i<0?0:kt(i+o-1,o-1)*e**o*(1-e)**i}function Pr(i,o,e){return .5*(1+Ft((i-o)/Math.sqrt(2*e*e)))}function uo(i,o,e){return Math.exp(-.5*Math.log(2*Math.PI)-Math.log(e)-(i-o)**2/(2*e*e))}function In(i,o,e){return-1.4142135623730951*e*mm(2*i)+o}function Pm(i,o){let e=0;for(let t=0;t<=i;t++)e+=co(t,o);return e}function co(i,o){return Math.exp(-o)*o**i/er(i)}function Lr(i,o){const e=.5*Bn(o/(i**2+o),o/2,.5);return i<0?e:1-e}function Lm(i,o){const e=(1+i**2/o)**(-(o+1)/2);return 1/(Math.sqrt(o)*Hs(.5,o/2))*e}function zs(i,o){let e=Ys(2*Math.min(i,1-i),.5*o,.5);return e=Math.sqrt(o*(1-e)/e),i>.5?e:-e}function Ge(i,o,e,t,r){const n=[],s=[];let a=!0;for(let u=0;u<e;u++){const c=Math.floor(u/t),l=u%t,f=Math.floor(u/r),m=u%r,d=i.isArray()?i.get(c,l):i,C=o.isArray()?o.get(f,m):o;if(d.isError())return{isError:!0,errorObject:d,array1Values:n,array2Values:s,noCalculate:a};if(C.isError())return{isError:!0,errorObject:C,array1Values:n,array2Values:s,noCalculate:a};if(d.isNull()||C.isNull()||d.isBoolean()||C.isBoolean())continue;const _=d.getValue(),E=C.getValue();!M.isRealNum(_)||!M.isRealNum(E)||(n.push(+_),s.push(+E),a=!1)}return{isError:!1,errorObject:null,array1Values:n,array2Values:s,noCalculate:a}}function rr(i){let o=i;if(i.isArray()){const e=i.getRowCount(),t=i.getColumnCount();if(e>1||t>1)return g.create(h.VALUE);o=i.get(0,0)}return o.isError(),o}function Js(...i){for(let o=0;o<i.length;o++){const e=rr(i[o]);if(e.isError())return{isError:!0,errorObject:e};i[o]=e}return{isError:!1,variants:i}}function H(...i){for(let o=0;o<i.length;o++){const e=rr(i[o]);if(e.isError())return{isError:!0,errorObject:e};if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE)};i[o]=e}return{isError:!1,variants:i}}function je(...i){for(let o=0;o<i.length;o++){let e=i[o];if(e.isError())return{isError:!0,errorObject:e};if(e.isNull())return{isError:!0,errorObject:g.create(h.NA)};if(e=rr(i[o]),e.isError())return{isError:!0,errorObject:e};if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE)};i[o]=e}return{isError:!1,variants:i}}function I(...i){for(let o=0;o<i.length;o++){let e=i[o];if(e.isString()&&(e=e.convertToNumberObjectValue()),e.isError())return{isError:!0,errorObject:e};i[o]=e}return{isError:!1,variants:i}}class lo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=n!=null?n:y.create(0),u=s!=null?s:y.create(1);a.isNull()&&(a=y.create(0)),u.isNull()&&(u=y.create(1));const c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.mapValue((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p);return this._handleSignleObject(b,V,S,D,w)});return c===1&&l===1?E.get(0,0):E}_handleSignleObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;const{isError:a,errorObject:u,variants:c}=I(e,t,r,n,s);if(a)return u;const[l,f,m,d,C]=c,_=+l.getValue(),E=+f.getValue(),b=+m.getValue(),R=+d.getValue(),p=+C.getValue();if(E<=0||b<=0||_<=0||_>=1||R>=p)return g.create(h.NUM);const V=Ys(_,E,b)*(p-R)+R;return y.create(V)}}class fo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),C=Math.floor(+l.getValue()),_=+f.getValue(),E=+m.getValue();if(d<0||d>C||_<0||_>1)return g.create(h.NUM);let b;return E?b=ro(d,C,_):b=Ws(d,C,_),y.create(b)}}class mo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=+c.getValue(),d=+l.getValue();if(f<0||m<=0||m>=1||d<=0||d>=1)return g.create(h.NUM);let C=0;for(;C<=f&&!(ro(C,f,m)>=d);)C++;return y.create(C)}}class ho extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||l<1||l>10**10)return g.create(h.NUM);const f=1-Qs(c,l);return y.create(f)}}class go extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=no(1-c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Co extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.NA);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d,r,n)}_getResult(e,t,r,n){let s=0;for(let c=0;c<e.length;c++){if(t[c]===0)return g.create(h.DIV_BY_ZERO);s+=(e[c]-t[c])**2/t[c]}let a=(r-1)*(n-1);r===1?a=n-1:n===1&&(a=r-1);const u=1-Qs(s,a);return y.create(u)}}class _o extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);if(f.isError())return f;if(C.isError())return C;if(_.isError())return _;const{isError:E,errorObject:b,variants:R}=I(f,C,_);if(E)return b;const[p,V,S]=R,D=+p.getValue(),w=+V.getValue(),P=Math.floor(+S.getValue());if(D<=0||D>=1||w<=0||P<1)return g.create(h.NUM);const L=Math.abs(In(D/2,0,1)*w/Math.sqrt(P));return y.create(L)});return n===1&&s===1?l.get(0,0):l}}class Ao extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length===0)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let l=0;l<r;l++)n+=e[l],s+=t[l];const a=n/r,u=s/r;let c=0;for(let l=0;l<r;l++){const f=e[l]-a,m=t[l]-u;c+=f*m}return y.create(c/r)}}class Eo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<0||m<=0)return g.create(h.NUM);let C;return d?C=Rm(f,m):C=pm(f,m),y.create(C)}}class bo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const C=1-qs(f,m,d);return y.create(C)}}class yo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||f>1||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const C=so(1-f,m,d);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class Ro extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variance:s,ns1:a}=this._getValues(e);if(r)return n;const{isError:u,errorObject:c,variance:l,ns1:f}=this._getValues(t);if(u)return c;let m=2*(1-qs(s/l,a,f));return m>1&&(m=2-m),y.create(m)}_getValues(e){let t=0,r=0;const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;if(n===1&&s===1){const f=e.isArray()?e.get(0,0):e;return f.isError()?{isError:!0,errorObject:f,variance:t,ns1:r}:f.isNull()?{isError:!0,errorObject:g.create(h.VALUE),variance:t,ns1:r}:{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r}}const a=[];let u=0;for(let f=0;f<n;f++)for(let m=0;m<s;m++){const d=e.isArray()?e.get(f,m):e;if(d.isError())return{isError:!0,errorObject:d,variance:t,ns1:r};if(d.isNull()||d.isBoolean())continue;const C=d.getValue();M.isRealNum(C)&&(a.push(+C),u+=+C)}if(a.length<=1)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r};const c=u/a.length;let l=0;for(let f=0;f<a.length;f++)l+=(a[f]-c)**2;return r=a.length-1,t=l/r,t===0?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r}:{isError:!1,errorObject:null,variance:t,ns1:r}}}class po extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=+l.getValue(),_=+f.getValue(),E=+m.getValue();if(d<0||C<=0||_<=0)return g.create(h.NUM);let b;return E?b=Nm(d,C,_):b=Vm(d,C,_),y.create(b)}}class No extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<0||f>1||m<=0||d<=0)return g.create(h.NUM);const C=Om(f,m,d);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class Vo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||f>=1||d<=0)return g.create(h.NUM);const C=Dm(f,m,d);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class Oo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t={};let r=0,n=1;for(let s=0;s<e.length;s++){const a=e[s];if(a.isError())return a;if(a.isString()){const l=a.convertToNumberObjectValue();if(l.isError())return l}const u=a.isArray()?a.getRowCount():1,c=a.isArray()?a.getColumnCount():1;for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=a.isArray()?a.get(l,f):a;if(m.isError())return m;if(m.isNull()||m.isBoolean()||m.isString())continue;const d=m.getValue();M.isRealNum(d)&&(t[+d]?(t[+d].count++,t[+d].count>n&&(n=t[+d].count)):t[+d]={count:1,order:r++})}}return r===0||n===1?new g(h.NA):this._getResult(t,n)}_getResult(e,t){const r=Object.entries(e).filter(([n,{count:s}])=>s===t).sort((n,s)=>n[1].order-s[1].order).map(([n])=>+n);return y.create(r[0])}}class Mo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=+l.getValue(),_=+f.getValue(),E=+m.getValue();if(_<=0)return g.create(h.NUM);let b;return E?b=Pr(d,C,_):b=uo(d,C,_),y.create(b)}}class So extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||f>=1||d<=0)return g.create(h.NUM);const C=In(f,m,d);return y.create(C)}}class Do extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSignleObject(r));return e.getRowCount()===1&&e.getColumnCount()===1?t.get(0,0):t}return this._handleSignleObject(e)}_handleSignleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue();if(a<=0||a>=1)return g.create(h.NUM);const u=In(a,0,1);return y.create(u)}}class wo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=+a.getValue(),c=e.length;if(u<0||u>1)return g.create(h.NUM);const l=u*(c-1),f=Math.floor(l),m=l-f;if(m===0)return y.create(e[f]);const d=e[f]+m*(e[f+1]-e[f]);return y.create(d)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class Po extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getValues(e);let s=r!=null?r:y.create(3);s.isNull()&&(s=y.create(3));const a=Math.max(t.isArray()?t.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(t.isArray()?t.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,t,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,C)=>{const _=l.get(d,C);return m.isError()?m:_.isError()?_:this._handleSingleObject(n,m,_)});return a===1&&u===1?f.get(0,0):f}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=I(t,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=Math.floor(+c.getValue()),m=e.length;if(m===0||l<e[0]||l>e[m-1])return g.create(h.NA);if(m===1)return l===e[0]?y.create(1):g.create(h.NA);let d=0,C=!1,_=0;for(;!C&&_<m;)l===e[_]?(d=_/(m-1),C=!0):l>e[_]&&_+1<m&&l<e[_+1]&&(d=(_+(l-e[_])/(e[_+1]-e[_]))/(m-1),C=!0),_++;return C?f<1?g.create(h.NUM):(d=ke(d,f),y.create(d)):g.create(h.NA)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.sort((s,a)=>s-a)}}class Lo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=+c.getValue(),d=+l.getValue();if(f<0||m<0)return g.create(h.NUM);let C;return d?C=Pm(f,m):C=co(f,m),y.create(C)}}class xo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<0||u>4)return g.create(h.NUM);const c=u/4,l=e.length,f=c*(l-1),m=Math.floor(f),d=f-m;if(d===0)return y.create(e[m]);const C=e[m]+d*(e[m+1]-e[m]);return y.create(C)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class jo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.std()}}class Uo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.std(1)}}class vo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<=0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=Math.abs(zs(c/2,l));return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class To extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a,array1Values:u,array2Values:c}=this._handleArray1AndArray2(e,t),l=this._getArrayValues(e),f=this._getArrayValues(t),m=Math.max(r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),d=Math.max(r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),C=O(m,d,r,g.create(h.NA)),_=O(m,d,n,g.create(h.NA)),E=C.mapValue((b,R,p)=>{const V=_.get(R,p);if(e.isError())return e;if(t.isError())return t;if(b.isError())return b;if(V.isError())return V;const{isError:S,errorObject:D,variants:w}=I(b,V);if(S)return D;const[P,L]=w,T=Math.floor(+P.getValue()),B=Math.floor(+L.getValue());return![1,2].includes(T)||![1,2,3].includes(B)?g.create(h.NUM):B===1&&s?a:B!==1&&l instanceof g?l:B!==1&&f instanceof g?f:this._handleSignleObject(B===1?u:l,B===1?c:f,T,B)});return m===1&&d===1?E.get(0,0):E}_handleSignleObject(e,t,r,n){if(e.length<2||t.length<2)return g.create(h.DIV_BY_ZERO);const{isError:s,errorObject:a,x:u,degFreedom:c}=this._getTDistParamByArrayValues(e,t,n);if(s)return a;let l=Lr(-u,c);return r===2&&(l*=2),Number.isNaN(l)||!Number.isFinite(l)?g.create(h.NUM):y.create(l)}_getArrayValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()){if(t*r===1)return g.create(h.VALUE);continue}u.isBoolean()||u.isString()||n.push(+u.getValue())}return n}_handleArray1AndArray2(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return{isError:!0,errorObject:u,array1Values:[],array2Values:[]};let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return{isError:!0,errorObject:c,array1Values:[],array2Values:[]};if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return{isError:!0,errorObject:g.create(h.VALUE),array1Values:[],array2Values:[]};if(r*n!==s*a)return{isError:!0,errorObject:g.create(h.NA),array1Values:[],array2Values:[]};const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?{isError:!0,errorObject:f,array1Values:[],array2Values:[]}:C||m.length<2?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),array1Values:[],array2Values:[]}:{isError:!1,errorObject:null,array1Values:m,array2Values:d}}_getTDistParamByArrayValues(e,t,r){return r===1?this._getTDistParamByType1(e,t):r===2?this._getTDistParamByType2(e,t):this._getTDistParamByType3(e,t)}_getTDistParamByType1(e,t){const r=e.length;let n=0,s=0,a=0;for(let m=0;m<r;m++)n+=e[m],s+=t[m],a+=(e[m]-t[m])**2;const u=n-s,c=r*a-u**2,l=r-1;return c===0?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:l}:{isError:!1,errorObject:null,x:Math.abs(u)*Math.sqrt(l/c),degFreedom:l}}_getTDistParamByType2(e,t){const r=e.length,n=t.length;let s=0,a=0;for(let E=0;E<r;E++)s+=e[E],a+=e[E]**2;let u=0,c=0;for(let E=0;E<n;E++)u+=t[E],c+=t[E]**2;const l=a-s**2/r,f=c-u**2/n,m=Math.sqrt(l+f);if(m===0)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:0};const d=r-1+n-1,C=Math.sqrt(r*n*d/(r+n));return{isError:!1,errorObject:null,x:Math.abs(s/r-u/n)/m*C,degFreedom:d}}_getTDistParamByType3(e,t){const r=e.length,n=t.length;let s=0,a=0;for(let _=0;_<r;_++)s+=e[_],a+=e[_]**2;let u=0,c=0;for(let _=0;_<n;_++)u+=t[_],c+=t[_]**2;const l=(a-s**2/r)/(r*(r-1)),f=(c-u**2/n)/(n*(n-1));if(l+f===0)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:0};const m=l/(l+f),d=Math.abs(s/r-u/n)/Math.sqrt(l+f),C=1/(m**2/(r-1)+(1-m)**2/(n-1));return{isError:!1,errorObject:null,x:d,degFreedom:C}}}class Bo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.var()}}class Io extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.var(1)}}class Fo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=+l.getValue(),_=+f.getValue(),E=+m.getValue();if(d<0||C<=0||_<=0)return g.create(h.NUM);const b=Math.exp(-((d/_)**C));let R;return E?R=1-b:R=C/_**C*d**(C-1)*b,Number.isNaN(R)||!Number.isFinite(R)?g.create(h.NUM):y.create(R)}}class ko extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getArrayValues(e),s=Math.max(t.isArray()?t.getRowCount():1,r!=null&&r.isArray()?r.getRowCount():1),a=Math.max(t.isArray()?t.getColumnCount():1,r!=null&&r.isArray()?r.getColumnCount():1),u=O(s,a,t,g.create(h.NA)),c=r?O(s,a,r,g.create(h.NA)):void 0,l=u.mapValue((f,m,d)=>{if(n instanceof g)return n;if(f.isError())return f;const C=r?c.get(m,d):void 0;return C!=null&&C.isError()?C:n.length===0?g.create(h.NA):n.length===1?g.create(h.DIV_BY_ZERO):this._handleSignleObject(n,f,C)});return s===1&&a===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=+u.getValue(),l=e.length;let f=0,m=0;for(let E=0;E<l;E++)f+=e[E],m+=e[E]**2;let d=0;if(r!==void 0){const{isError:E,errorObject:b,variants:R}=I(r);if(E)return b;const[p]=R;d=+p.getValue()}else{const E=f/l;d=Math.sqrt((m-2*E*f+l*E**2)/(l-1))}if(d<=0)return g.create(h.NUM);const C=(f/l-c)/(d/Math.sqrt(l)),_=1-Pr(C,0,1);return Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):y.create(_)}_getArrayValues(e){const t=[],r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1;for(let s=0;s<r;s++)for(let a=0;a<n;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&t.push(+c)}return t}}class xm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=n!=null?n:y.create(0),u=s!=null?s:y.create(1);a.isNull()&&(a=y.create(0)),u.isNull()&&(u=y.create(1));const c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.mapValue((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p);return this._handleSignleObject(b,V,S,D,w)});return c===1&&l===1?E.get(0,0):E}_handleSignleObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;const{isError:a,errorObject:u,variants:c}=I(e,t,r,n,s);if(a)return u;const[l,f,m,d,C]=c,_=+l.getValue(),E=+f.getValue(),b=+m.getValue(),R=+d.getValue(),p=+C.getValue();if(E<=0||b<=0||_<R||_>p||R===p)return g.create(h.NUM);const V=to((_-R)/(p-R),E,b);return y.create(V)}}var le=(i=>(i.BETADIST="BETADIST",i.BETAINV="BETAINV",i.BINOMDIST="BINOMDIST",i.CHIDIST="CHIDIST",i.CHIINV="CHIINV",i.CHITEST="CHITEST",i.CONFIDENCE="CONFIDENCE",i.COVAR="COVAR",i.CRITBINOM="CRITBINOM",i.EXPONDIST="EXPONDIST",i.FDIST="FDIST",i.FINV="FINV",i.FTEST="FTEST",i.GAMMADIST="GAMMADIST",i.GAMMAINV="GAMMAINV",i.HYPGEOMDIST="HYPGEOMDIST",i.LOGINV="LOGINV",i.LOGNORMDIST="LOGNORMDIST",i.MODE="MODE",i.NEGBINOMDIST="NEGBINOMDIST",i.NORMDIST="NORMDIST",i.NORMINV="NORMINV",i.NORMSDIST="NORMSDIST",i.NORMSINV="NORMSINV",i.PERCENTILE="PERCENTILE",i.PERCENTRANK="PERCENTRANK",i.POISSON="POISSON",i.QUARTILE="QUARTILE",i.RANK="RANK",i.STDEV="STDEV",i.STDEVP="STDEVP",i.TDIST="TDIST",i.TINV="TINV",i.TTEST="TTEST",i.VAR="VAR",i.VARP="VARP",i.WEIBULL="WEIBULL",i.ZTEST="ZTEST",i))(le||{});class jm extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),C=Math.floor(+l.getValue()),_=Math.floor(+f.getValue()),E=Math.floor(+m.getValue());if(d<0||d>C||d>_||d<C-E+_||C<=0||C>E||_<=0||_>E||E<=0)return g.create(h.NUM);let b=Ks(d,C,_,E);return Number.isNaN(b)&&(b=0),y.create(b)}}class Um extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||d<=0)return g.create(h.NUM);const C=oo(f,m,d);return y.create(C)}}class vm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=Math.floor(+c.getValue()),d=+l.getValue();if(f<0||m<1||d<=0||d>=1)return g.create(h.NUM);const C=Zs(f,m,d);return y.create(C)}}class Tm extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSignleObject(r));return e.getRowCount()===1&&e.getColumnCount()===1?t.get(0,0):t}return this._handleSignleObject(e)}_handleSignleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Pr(a,0,1);return y.create(u)}}class Bm extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),C=m.map((_,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+_.getValue(),V=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);const D=u.sort((w,P)=>V?w-P:P-w).indexOf(p);return D===-1?g.create(h.NA):y.create(D+1)});return l===1&&f===1?C.get(0,0):C}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class Im extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||m<1||m>10**10||d<1||d>2)return g.create(h.NUM);let C=Lr(-f,m);return d===2&&(C*=2),Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}const $o=[[xm,le.BETADIST],[lo,le.BETAINV],[fo,le.BINOMDIST],[ho,le.CHIDIST],[go,le.CHIINV],[Co,le.CHITEST],[_o,le.CONFIDENCE],[Ao,le.COVAR],[mo,le.CRITBINOM],[Eo,le.EXPONDIST],[bo,le.FDIST],[yo,le.FINV],[Ro,le.FTEST],[po,le.GAMMADIST],[No,le.GAMMAINV],[jm,le.HYPGEOMDIST],[Um,le.LOGNORMDIST],[Vo,le.LOGINV],[Oo,le.MODE],[vm,le.NEGBINOMDIST],[Mo,le.NORMDIST],[So,le.NORMINV],[Tm,le.NORMSDIST],[Do,le.NORMSINV],[wo,le.PERCENTILE],[Po,le.PERCENTRANK],[Lo,le.POISSON],[xo,le.QUARTILE],[Bm,le.RANK],[Uo,le.STDEV],[jo,le.STDEVP],[Im,le.TDIST],[vo,le.TINV],[To,le.TTEST],[Io,le.VAR],[Bo,le.VARP],[Fo,le.WEIBULL],[ko,le.ZTEST]],Yo=[];var Ho=(i=>(i.CUBEKPIMEMBER="CUBEKPIMEMBER",i.CUBEMEMBER="CUBEMEMBER",i.CUBEMEMBERPROPERTY="CUBEMEMBERPROPERTY",i.CUBERANKEDMEMBER="CUBERANKEDMEMBER",i.CUBESET="CUBESET",i.CUBESETCOUNT="CUBESETCOUNT",i.CUBEVALUE="CUBEVALUE",i))(Ho||{});class Fm extends N{isCustom(){return!0}}function We(i){const o=[];if(i.isError())return{isError:!0,errorObject:i,databaseValues:o};const e=i.isArray()?i.getRowCount():1,t=i.isArray()?i.getColumnCount():1;if(e<2)return{isError:!0,errorObject:g.create(h.VALUE),databaseValues:o};for(let r=0;r<e;r++){const n=[];for(let s=0;s<t;s++){const a=i.get(r,s);if(a.isNull()){n.push(null);continue}let u=`${a.getValue()}`;if(a.isBoolean()&&(u=u.toLocaleUpperCase()),a.isNumber()||M.isRealNum(u)){n.push(+u);continue}n.push(u)}o.push(n)}return{isError:!1,errorObject:null,databaseValues:o}}function Qe(i,o){let e=-1;if(i.isError())return{isError:!0,errorObject:i,fieldIndex:e};const t=i.isArray()?i.getRowCount():1,r=i.isArray()?i.getColumnCount():1;if(t>1||r>1)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};const n=i.isArray()?i.get(0,0):i;let s=`${n.getValue()}`;if(n.isNull()?s=0:n.isBoolean()?s=n.getValue()?1:0:(n.isNumber()||M.isRealNum(s))&&(s=Math.floor(+s)),typeof s=="number"){if(s<1||s>o[0].length)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};e=s-1}else if(e=o[0].findIndex(a=>a===null?!1:`${a}`.toLocaleLowerCase()===s.toLocaleLowerCase()),e===-1)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};return{isError:!1,errorObject:null,fieldIndex:e}}function qe(i){const o=[];if(i.isError())return{isError:!0,errorObject:i,criteriaValues:o};const e=i.isArray()?i.getRowCount():1,t=i.isArray()?i.getColumnCount():1;if(e<2)return{isError:!0,errorObject:g.create(h.VALUE),criteriaValues:o};for(let r=0;r<e;r++){const n=[];for(let s=0;s<t;s++){const a=i.get(r,s);if(a.isNull()){n.push(null);continue}const u=`${a.getValue()}`;if(a.isBoolean()){n.push(a.getValue()?1:0);continue}if(a.isNumber()||M.isRealNum(u)){n.push(+u);continue}n.push(u)}o.push(n)}return{isError:!1,errorObject:null,criteriaValues:o}}function Xe(i,o,e){const t=i.length,r=i[0].length,n={};let s=!1;for(let a=1;a<t;a++){let u=!0;for(let c=0;c<r;c++){const l=i[a][c];if(l===null)continue;let f=n[c];if(f===void 0){const m=i[0][c];f=o[0].findIndex(d=>d===null||m===null?!1:`${d}`.toLocaleLowerCase()===`${m}`.toLocaleLowerCase()),n[c]=f}if(f===-1&&(typeof l=="string"||l===0)){u=!1;break}else if(f>-1){const m=o[e][f];if(m===null){u=!1;break}const[d,C]=mr(`${l}`);if(!lt.create(`${m}`).compare(C,d).getValue()){u=!1;break}}}if(u){s=!0;break}}return s}class km extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Xe(d,a,E)&&(C+=b,_++)}return _===0?g.create(h.DIV_BY_ZERO):y.create(C/_)}}class $m extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0;for(let _=1;_<a.length;_++)typeof a[_][l]=="number"&&Xe(d,a,_)&&C++;return y.create(C)}}class Ym extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0;for(let _=1;_<a.length;_++){const E=a[_][l];E!=null&&Xe(d,a,_)&&C++}return y.create(C)}}class Hm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];b!=null&&Xe(d,a,E)&&(C++,_=E)}return C===0?g.create(h.VALUE):C>1?g.create(h.NUM):e.get(_,l)}}class Gm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=-1/0,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Xe(d,a,E)&&(C=Math.max(C,b),_++)}return _===0?y.create(0):y.create(C)}}class Wm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=1/0,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Xe(d,a,E)&&(C=Math.min(C,b),_++)}return _===0?y.create(0):y.create(C)}}class Qm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=1,_=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Xe(d,a,E)&&(C*=b,_++)}return _===0?y.create(0):y.create(C)}}class qm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const C=[];let _=0,E=0;for(let V=1;V<a.length;V++){const S=a[V][l];typeof S=="number"&&Xe(d,a,V)&&(C.push(S),_+=S,E++)}if(E<=1)return g.create(h.DIV_BY_ZERO);const b=_/E;let R=0;for(let V=0;V<E;V++)R+=(C[V]-b)**2;const p=Math.sqrt(R/(E-1));return y.create(p)}}class Xm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const C=[];let _=0,E=0;for(let V=1;V<a.length;V++){const S=a[V][l];typeof S=="number"&&Xe(d,a,V)&&(C.push(S),_+=S,E++)}if(E===0)return g.create(h.DIV_BY_ZERO);const b=_/E;let R=0;for(let V=0;V<E;V++)R+=(C[V]-b)**2;const p=Math.sqrt(R/E);return y.create(p)}}class Km extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let C=0;for(let _=1;_<a.length;_++){const E=a[_][l];typeof E=="number"&&Xe(d,a,_)&&(C+=E)}return y.create(C)}}class Zm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const C=[];let _=0,E=0;for(let V=1;V<a.length;V++){const S=a[V][l];typeof S=="number"&&Xe(d,a,V)&&(C.push(S),_+=S,E++)}if(E<=1)return g.create(h.DIV_BY_ZERO);const b=_/E;let R=0;for(let V=0;V<E;V++)R+=(C[V]-b)**2;const p=R/(E-1);return y.create(p)}}class zm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const C=[];let _=0,E=0;for(let V=1;V<a.length;V++){const S=a[V][l];typeof S=="number"&&Xe(d,a,V)&&(C.push(S),_+=S,E++)}if(E===0)return g.create(h.DIV_BY_ZERO);const b=_/E;let R=0;for(let V=0;V<E;V++)R+=(C[V]-b)**2;const p=R/E;return y.create(p)}}var Te=(i=>(i.DAVERAGE="DAVERAGE",i.DCOUNT="DCOUNT",i.DCOUNTA="DCOUNTA",i.DGET="DGET",i.DMAX="DMAX",i.DMIN="DMIN",i.DPRODUCT="DPRODUCT",i.DSTDEV="DSTDEV",i.DSTDEVP="DSTDEVP",i.DSUM="DSUM",i.DVAR="DVAR",i.DVARP="DVARP",i))(Te||{});const Go=[[km,Te.DAVERAGE],[$m,Te.DCOUNT],[Ym,Te.DCOUNTA],[Hm,Te.DGET],[Gm,Te.DMAX],[Wm,Te.DMIN],[Qm,Te.DPRODUCT],[qm,Te.DSTDEV],[Xm,Te.DSTDEVP],[Km,Te.DSUM],[Zm,Te.DVAR],[zm,Te.DVARP]];var ye=(i=>(i.DATE="DATE",i.DATEDIF="DATEDIF",i.DATEVALUE="DATEVALUE",i.DAY="DAY",i.DAYS="DAYS",i.DAYS360="DAYS360",i.EDATE="EDATE",i.EOMONTH="EOMONTH",i.HOUR="HOUR",i.ISOWEEKNUM="ISOWEEKNUM",i.MINUTE="MINUTE",i.MONTH="MONTH",i.NETWORKDAYS="NETWORKDAYS",i.NETWORKDAYS_INTL="NETWORKDAYS.INTL",i.NOW="NOW",i.SECOND="SECOND",i.TIME="TIME",i.TIMEVALUE="TIMEVALUE",i.TODAY="TODAY",i.WEEKDAY="WEEKDAY",i.WEEKNUM="WEEKNUM",i.WORKDAY="WORKDAY",i.WORKDAY_INTL="WORKDAY.INTL",i.YEAR="YEAR",i.YEARFRAC="YEARFRAC",i))(ye||{});const ea="yyyy/mm/dd;@",Jm="yyyy/mm/dd hh:mm",eh="h:mm A/P";function Ee(i){const o=new Date(Date.UTC(1900,0,1)),e=new Date(Date.UTC(1900,1,28)),t=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate());let r=(t-o.getTime())/(1e3*3600*24);return t>e.getTime()&&(r+=1),Math.floor(r)+1}function Fn(i){const o=new Date(Date.UTC(1900,0,1,0,0,0)),e=new Date(Date.UTC(1900,1,28,0,0,0));let r=(i.getTime()-o.getTime())/(1e3*3600*24);return i>e&&(r+=1),r+1}function re(i){const o=new Date(Date.UTC(1900,0,1)),e=new Date(Date.UTC(1900,1,28));let t=Math.floor(i)-1;return t>(e.getTime()-o.getTime())/(1e3*3600*24)&&(t-=1),new Date(o.getTime()+t*(1e3*3600*24))}function ta(i){const o=new Date(Date.UTC(1900,0,1,0,0,0)),e=new Date(Date.UTC(1900,1,28,0,0,0));let t=i-1;return t>(e.getTime()-o.getTime())/(1e3*3600*24)&&(t-=1),t<0&&(t=i),new Date(o.getTime()+t*(1e3*3600*24))}function ra(i){if(!/^\d{4}[-/](0?[1-9]|1[012])[-/](0?[1-9]|[12][0-9]|3[01])$/.test(i))return!1;const e=i.replace(/-/g,"/").replace(/T.+/,""),t=new Date(`${e}`);if(Number.isNaN(t.getTime()))return!1;const r=t.getFullYear(),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=`${r}-${n}-${s}`;return i.replace(/\//g,"-").split("-").map(c=>c.padStart(2,"0")).join("-")===a}function Ya(i){return M.numfmt.parseDate(i)}function Wo(i){return M.numfmt.parseValue(i)}function Ha(i){return M.numfmt.parseTime(i)}function Qo(i){return M.numfmt.isDate(i)}const qo={1:[6,0],2:[0,1],3:[1,2],4:[2,3],5:[3,4],6:[4,5],7:[5,6],11:[0],12:[1],13:[2],14:[3],15:[4],16:[5],17:[6]};function pr(i){return!!(typeof i=="string"&&/^[0|1]{7}/.test(i)||qo[Number(i)])}function Xo(i){if(!pr(i))return[];if(typeof i=="string"&&/^[0|1]{7}/.test(i)){const o=[];for(let e=1;e<=i.length;e++)`${i[e-1]}`=="1"&&(e===i.length?o.push(0):o.push(e));return o}return qo[Number(i)]||[]}function ln(i,o,e=1,t){const r=Xo(e),n=Math.floor(i),s=Math.floor(o),a=s>n?n:s;let u=0;const c=Math.abs(Math.floor(o)-Math.floor(i))+1;for(let l=0;l<c;l++){const f=a+l;if(t&&t.length>0&&t.some(d=>Math.floor(d)===f))continue;const m=Gt(f);r.includes(m)||u++}return s>n?u:-u}function fn(i,o,e=1,t){const r=Xo(e),n=Math.floor(i);let s=n,a=Math.abs(o);for(let u=1;u<=a;u++){const c=o<0?n-u:n+u;if(c<0)return g.create(h.NUM);if(t&&t.length>0&&t.some(f=>Math.floor(f)===c)){a++;continue}const l=Gt(c);if(r.includes(l)){a++;continue}s=c}return s}function F(i){if(i.isError())return i;const o=i.getValue();if(i.isString()){let e;if(Ya(`${o}`))e=Ya(`${o}`).v;else if(Ha(`${o}`))e=Ha(`${o}`).v;else if(M.isRealNum(o))e=+o;else return g.create(h.VALUE);return e instanceof Date&&(e=Fn(e)),+e<0||+e>2958465?g.create(h.NUM):+e}else{const e=+i.getValue();return e<0||e>2958465?g.create(h.NUM):e}}function Gt(i){const o=Math.floor(i)===60;let e=re(i);const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())).getTime(),r=new Date(Date.UTC(1900,1,28)).getTime();return!o&&t<=r&&(e=new Date(t-24*3600*1e3)),new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())).getUTCDay()}function Ce(i,o,e){switch(e){case 0:return th(i,o);case 1:return rh(i,o);case 2:return{days:Math.abs(o-i),yearDays:360};case 3:return{days:Math.abs(o-i),yearDays:365};case 4:return nh(i,o);default:return{days:Math.abs(o-i),yearDays:365}}}function th(i,o){const e=re(i),t=i>0?e.getUTCFullYear():1900,r=i>0?e.getUTCMonth()+1:1;let n=i>0?e.getUTCDate():0,s=re(o),a=o>0?s.getUTCFullYear():1900,u=o>0?s.getUTCMonth()+1:1,c=o>0?s.getUTCDate():0;r===2?re(i+1).getUTCMonth()+1===3&&(n=30):n===31&&(n=30),c===31&&(n<30?(s=re(o+1),a=s.getUTCFullYear(),u=s.getUTCMonth()+1,c=s.getUTCDate()):c=30);const l=(a-t)*360,f=o>=i?30-n:-n,m=o>=i?c:c-30,d=(o>=i?u-r-1:u-r+1)*30;return{days:Math.abs(l+f+m+d),yearDays:360}}function rh(i,o){const e=re(i),t=i>0?e.getUTCFullYear():1900,r=re(o),n=o>0?r.getUTCFullYear():1900,s=Math.abs(o-i),a=Math.abs(n-t)+1;let u,c;if(n<t){const l=new Date(Date.UTC(n,0,1)),f=new Date(Date.UTC(t,11,31));u=Ee(l),c=Ee(f),n===1900&&(u+=1)}else{const l=new Date(Date.UTC(t,0,1)),f=new Date(Date.UTC(n,11,31));u=Ee(l),c=Ee(f),t===1900&&(u+=1)}return{days:s,yearDays:(c-u+1)/a}}function nh(i,o){const e=re(i),t=i>0?e.getUTCFullYear():1900,r=i>0?e.getUTCMonth()+1:1;let n=i>0?e.getUTCDate():0;const s=re(o),a=o>0?s.getUTCFullYear():1900,u=o>0?s.getUTCMonth()+1:1;let c=o>0?s.getUTCDate():0;n===31&&(n=30),c===31&&(c=30);const l=(a-t)*360,f=o>=i?30-n:-n,m=o>=i?c:c-30,d=(o>=i?u-r-1:u-r+1)*30;return{days:Math.abs(l+f+m+d),yearDays:360}}function sh(i){return i%4===0&&i%100!==0||i%400===0}function ah(i){return i%4===0&&i%100!==0||i%400===0||i===1900}const ih=[31,29,31,30,31,30,31,31,30,31,30,31],oh=[31,28,31,30,31,30,31,31,30,31,30,31];function xr(i,o){return sh(i)?ih[o]:oh[o]}function kn(i){return ah(i)?366:365}function Ko(i,o){switch(o){case 0:case 2:case 4:return 360;case 1:return kn(re(i).getUTCFullYear());case 3:return 365;default:return-1}}function or(i,o,e){return xr(i,o)===e}function ur(i,o){let e=i.getUTCFullYear(),t=i.getUTCMonth();const r=i.getUTCDate();return or(e,t,r)?(i.setUTCDate(1),i.setUTCMonth(i.getUTCMonth()+o),e=i.getUTCFullYear(),t=i.getUTCMonth(),i.setUTCDate(xr(e,t))):i.setUTCMonth(i.getUTCMonth()+o),i}class uh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e),u=O(n,s,t),c=O(n,s,r);return a.map((l,f,m)=>{const d=u.get(f,m)||ae.create(),C=c.get(f,m)||ae.create();if(l.isError())return l;if(d.isError())return d;if(C.isError())return C;if(l.isString()||d.isString()||C.isString())return g.create(h.VALUE);let _=+l.getValue();const E=Math.floor(+d.getValue()),b=+C.getValue();if(_<0||_>9999)return g.create(h.NUM);_>=0&&_<1899&&(_+=1900);const R=new Date(_,E-1,b),p=Ee(R);return p<0?g.create(h.NUM):y.create(p,ea)})}}class ch extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t,a=r;if(n.isArray()&&(n=n.get(0,0)),s.isArray()&&(s=s.get(0,0)),a.isArray()&&(a=a.get(0,0)),n.isError())return n;if(s.isError())return s;if(a.isError())return a;const u=F(n);if(typeof u!="number")return u;const c=F(s);return typeof c!="number"?c:c<u||!a.isString()?g.create(h.NUM):this._getResultByUnit(u,c,a)}_getResultByUnit(e,t,r){const n=re(e),s=n.getUTCFullYear(),a=n.getUTCMonth()+1,u=n.getUTCDate(),c=re(t),l=c.getUTCFullYear(),f=c.getUTCMonth()+1,m=c.getUTCDate(),d=`${r.getValue()}`.toLocaleUpperCase();let C=0,_;switch(d){case"Y":C=l-s,(f<a||f===a&&m<u)&&(C-=1);break;case"M":C=(l-s)*12+f-a,m<u&&(C-=1);break;case"D":C=Math.floor(t)-Math.floor(e);break;case"MD":C=m-u,m<u&&(_=new Date(Date.UTC(l,f-1,0)),C+=xr(_.getUTCFullYear(),_.getUTCMonth()));break;case"YM":C=f-a,(f<a||f===a&&m<u)&&(C+=12),m<u&&(C-=1);break;case"YD":_=new Date(Date.UTC(s,f-1,m)),(f<a||f===a&&m<u)&&(_=new Date(Date.UTC(s+1,f-1,m))),C=Math.floor(Ee(_))-Math.floor(e);break;default:return g.create(h.NUM)}return y.create(C)}}class lh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isString()){const t=`${e.getValue()}`,r=Wo(t);if(r){let{v:n,z:s}=r;if(s&&Qo(s))return n instanceof Date&&(n=Fn(n)),y.create(Math.trunc(+n))}}return g.create(h.VALUE)}}class fh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t;const r=e.getValue();if(e.isString()){if(!ra(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+e.getValue();if(a<0)return g.create(h.NUM);if(a===0)return y.create(0);t=re(a)}const n=t.getDate();return y.create(n)}}class mh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t),u=s.map((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const d=F(c);if(typeof d!="number")return d;const C=F(m);if(typeof C!="number")return C;const _=Math.floor(d)-Math.floor(C);return y.create(_)});return r===1&&n===1?u.get(0,0):u}}class hh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:k.create(!1);if(e.isError())return e;if(t.isError())return t;if(n.isError())return n;const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.map((m,d,C)=>{const _=c.get(d,C);let E=l.get(d,C);if(m.isError())return m;const b=F(m);if(typeof b!="number")return b;if(_.isError())return _;const R=F(_);if(typeof R!="number")return R;if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;const p=+E.getValue(),{days:V}=Ce(b,R,p?4:0),S=R>=b?V:-V;return y.create(S)});return s===1&&a===1?f.get(0,0):f}}class gh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.map((u,c,l)=>{const f=a.get(c,l)||ae.create();if(u.isError())return u;if(f.isError())return f;if(u.isString()||u.isBoolean()||f.isString()||f.isBoolean())return g.create(h.VALUE);const m=+u.getValue();if(m<0)return g.create(h.NUM);const d=Math.floor(+f.getValue()),C=re(m),_=C.getUTCFullYear(),E=C.getUTCMonth()+d,b=C.getUTCDate(),R=new Date(Date.UTC(_,E,b)),p=Ee(R);return y.create(p,ea)})}}class dh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e,n=t;if(r.isArray()){const d=r.getRowCount(),C=r.getColumnCount();if(d>1||C>1)return g.create(h.VALUE);r=r.get(0,0)}if(n.isArray()){const d=n.getRowCount(),C=n.getColumnCount();if(d>1||C>1)return g.create(h.VALUE);n=n.get(0,0)}if(r.isError())return r;if(n.isError())return n;const s=F(r);if(typeof s!="number")return s;if(n.isBoolean())return g.create(h.VALUE);const a=re(s),u=s>0?a.getUTCFullYear():1900,c=s>0?a.getUTCMonth():0,l=Math.floor(+n.getValue());if(Number.isNaN(l))return g.create(h.VALUE);const f=new Date(Date.UTC(u,c+l+1,0)),m=Ee(f);return y.create(m)}}class Ch extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=F(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ta(t).getUTCHours();return y.create(n)}}class _h extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=F(e);if(typeof t!="number")return t;const r=re(t),n=t>0?r.getUTCFullYear():1900;let s=new Date(Date.UTC(n,0,1)),a=Ee(s),u=Gt(a),c;u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u),t<c&&(s=new Date(Date.UTC(n-1,0,1)),a=Ee(s),u=Gt(a),u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u));const l=Math.ceil((t-c+1)/7);return y.create(l)}}class Ah extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=F(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ta(t).getUTCMinutes();return y.create(n)}}class Eh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;let t;const r=e.getValue();if(e.isString()){if(!ra(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+e.getValue();if(a<0)return g.create(h.NUM);if(a===0)return y.create(1);t=re(a)}const n=t.getUTCMonth()+1;return y.create(n)}}class bh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t;if(n.isArray()){const l=n.getRowCount(),f=n.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(s.isArray()){const l=s.getRowCount(),f=s.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(r!=null&&r.isError())return r;if(n.isBoolean()||s.isBoolean())return g.create(h.VALUE);const a=F(n);if(typeof a!="number")return a;const u=F(s);if(typeof u!="number")return u;if(r)return this._getResultByHolidays(a,u,r);const c=ln(a,u);return y.create(c)}_getResultByHolidays(e,t,r){const n=[];if(r!=null&&r.isArray()){const a=r.getRowCount(),u=r.getColumnCount();for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=r.get(c,l);if(f.isBoolean())return g.create(h.VALUE);const m=F(f);if(typeof m!="number")return m;n.push(m)}}else{if(r.isBoolean())return g.create(h.VALUE);const a=F(r);if(typeof a!="number")return a;n.push(a)}const s=ln(e,t,1,n);return y.create(s)}}class yh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){return e.isError()?e:t.isError()?t:r!=null&&r.isError()?r:n!=null&&n.isError()?n:r!=null&&r.isArray()?r.map(s=>this._handleSingleObject(e,t,s,n)):this._handleSingleObject(e,t,r,n)}_handleSingleObject(e,t,r,n){let s=e,a=t;if(s.isArray()){const m=s.getRowCount(),d=s.getColumnCount();if(m>1||d>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(a.isArray()){const m=a.getRowCount(),d=a.getColumnCount();if(m>1||d>1)return g.create(h.VALUE);a=a.get(0,0)}if(a.isError())return a;let u=1;if(r){if(u=r.getValue(),r.isBoolean()&&(u=+u),r.isString()&&!pr(u))return g.create(h.VALUE);if(!pr(u))return g.create(h.NUM)}if(s.isBoolean()||a.isBoolean())return g.create(h.VALUE);const c=F(s);if(typeof c!="number")return c;const l=F(a);if(typeof l!="number")return l;if(n)return this._getResultByHolidays(c,l,u,n);const f=ln(c,l,u);return y.create(f)}_getResultByHolidays(e,t,r,n){const s=[];if(n!=null&&n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=n.get(l,f);if(m.isBoolean())return g.create(h.VALUE);const d=F(m);if(typeof d!="number")return d;s.push(d)}}else{if(n.isBoolean())return g.create(h.VALUE);const u=F(n);if(typeof u!="number")return u;s.push(u)}const a=ln(e,t,r,s);return y.create(a)}}class Rh extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){const e=new Date,t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())),r=Fn(t);return y.create(r,Jm)}}class ph extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=F(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ta(t).getUTCSeconds();return y.create(n)}}class Nh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e),u=O(n,s,t),c=O(n,s,r);return a.map((l,f,m)=>this._calculateTime(l,u,c,f,m))}_calculateTime(e,t,r,n,s){let a=e,u=t.get(n,s)||ae.create(),c=r.get(n,s)||ae.create();if((a.isString()||a.isBoolean())&&(a=a.convertToNumberObjectValue()),(u.isString()||u.isBoolean())&&(u=u.convertToNumberObjectValue()),(c.isString()||c.isBoolean())&&(c=c.convertToNumberObjectValue()),a.isError())return a;if(u.isError())return u;if(c.isError())return c;let l=Math.floor(+a.getValue()),f=Math.floor(+u.getValue()),m=Math.floor(+c.getValue());if(l<0||f<0||m<0||l>32767||f>32767||m>32767)return g.create(h.NUM);f+=Math.floor(m/60),m%=60,l+=Math.floor(f/60),f%=60,l%=24;const C=(l*3600+f*60+m)/86400;return y.create(C,eh)}}class Vh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isString()){const t=`${e.getValue()}`,r=Wo(t);if(r){let{v:n,z:s}=r;if(s&&Qo(s))return n instanceof Date&&(n=Fn(n)),y.create(Wl(+n))}}return g.create(h.VALUE)}}class Oh extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){const e=Ee(new Date);return y.create(e,ea)}}class Mh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"_returnTypeMap",{1:[1,2,3,4,5,6,7],2:[7,1,2,3,4,5,6],3:[6,0,1,2,3,4,5],11:[7,1,2,3,4,5,6],12:[6,7,1,2,3,4,5],13:[5,6,7,1,2,3,4],14:[4,5,6,7,1,2,3],15:[3,4,5,6,7,1,2],16:[2,3,4,5,6,7,1],17:[1,2,3,4,5,6,7]})}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{const d=u.get(f,m);return this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(r.isError())return r;const n=F(e);if(typeof n!="number")return n;if(r.isString()&&(r=r.convertToNumberObjectValue(),r.isError()))return r;const s=Math.floor(+r.getValue());if(!this._returnTypeMap[s])return g.create(h.NUM);const a=Gt(n),u=this._returnTypeMap[s][a];return y.create(u)}}class Sh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"_returnTypeMap",{1:0,2:1,11:1,12:2,13:3,14:4,15:5,16:6,17:0,21:4})}calculate(e,t){let r=e,n=t!=null?t:y.create(1);if(r.isArray()){const u=r.getRowCount(),c=r.getColumnCount();if(u>1||c>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;if(n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();if(u>1||c>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean())return g.create(h.VALUE);const s=F(r);if(typeof s!="number")return s;if(n.isBoolean())return g.create(h.VALUE);const a=Math.floor(+n.getValue());return Number.isNaN(a)?g.create(h.VALUE):a in this._returnTypeMap?this._getResult(s,a):g.create(h.NUM)}_getResult(e,t){const r=re(e),n=e>0?r.getUTCFullYear():1900;let s=new Date(Date.UTC(n,0,1)),a=Ee(s),u=Gt(a),c;if(t===21)u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u),e<c&&(s=new Date(Date.UTC(n-1,0,1)),a=Ee(s),u=Gt(a),u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u));else{const f=this._returnTypeMap[t];u<f?c=a-(u+7-f):c=a-(u-f)}const l=Math.ceil((e-c+1)/7);return y.create(l)}}class Dh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t;if(n.isArray()){const l=n.getRowCount(),f=n.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(s.isArray()){const l=s.getRowCount(),f=s.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(r!=null&&r.isError())return r;if(n.isBoolean()||s.isBoolean())return g.create(h.VALUE);const a=F(n);if(typeof a!="number")return a;const u=+s.getValue();if(Number.isNaN(u))return g.create(h.VALUE);if(r)return this._getResultByHolidays(a,u,r);const c=fn(a,u);return typeof c!="number"?c:y.create(c)}_getResultByHolidays(e,t,r){const n=[];if(r!=null&&r.isArray()){const a=r.getRowCount(),u=r.getColumnCount();for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=r.get(c,l);if(f.isBoolean())return g.create(h.VALUE);const m=F(f);if(typeof m!="number")return m;n.push(m)}}else{if(r.isBoolean())return g.create(h.VALUE);const a=F(r);if(typeof a!="number")return a;n.push(a)}const s=fn(e,t,1,n);return typeof s!="number"?s:y.create(s)}}class wh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){return e.isError()?e:t.isError()?t:r!=null&&r.isError()?r:n!=null&&n.isError()?n:r!=null&&r.isArray()?r.map(s=>this._handleSingleObject(e,t,s,n)):this._handleSingleObject(e,t,r,n)}_handleSingleObject(e,t,r,n){const s=r!=null?r:y.create(1),a=this._checkArrayError(e);if(a.isError())return a;const u=this._checkArrayError(t);if(u.isError())return u;if(a.isBoolean()||u.isBoolean())return g.create(h.VALUE);const c=F(e);if(typeof c!="number")return c;const l=+t.getValue();if(Number.isNaN(l))return g.create(h.VALUE);let f=s.getValue();if(s.isBoolean()&&(f=+f),s.isString()&&(!pr(f)||f==="1111111"))return g.create(h.VALUE);if(!pr(f))return g.create(h.NUM);if(n)return this._getResultByHolidays(c,l,f,n);const m=fn(c,l,f);return typeof m!="number"?m:y.create(m)}_checkArrayError(e){let t=e;if(t.isArray()){const r=t.getRowCount(),n=t.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=t.get(0,0)}return t.isError(),t}_getResultByHolidays(e,t,r,n){const s=[];if(n!=null&&n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=n.get(l,f);if(m.isBoolean())return g.create(h.VALUE);const d=F(m);if(typeof d!="number")return d;s.push(d)}}else{if(n.isBoolean())return g.create(h.VALUE);const u=F(n);if(typeof u!="number")return u;s.push(u)}const a=fn(e,t,r,s);return typeof a!="number"?a:y.create(a)}}class Ph extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;let t;const r=e.getValue();if(e.isString()){if(!ra(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+r;if(a<0)return g.create(h.NUM);if(a===0)return y.create(1900);t=re(a)}const n=t.getUTCFullYear();return y.create(n)}}class Lh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:y.create(0);const s=rr(e);if(s.isError())return s;const a=rr(t);if(a.isError())return a;if(n=rr(n),n.isError())return n;if(s.isBoolean()||a.isBoolean()||n.isBoolean())return g.create(h.VALUE);const u=F(s);if(typeof u!="number")return u;const c=F(a);if(typeof c!="number")return c;const l=Math.floor(+n.getValue());if(Number.isNaN(l))return g.create(h.VALUE);if(l<0||l>4)return g.create(h.NUM);const{days:f,yearDays:m}=Ce(u,c,l),d=f/m;return y.create(d)}}const Zo=[[uh,ye.DATE],[ch,ye.DATEDIF],[lh,ye.DATEVALUE],[fh,ye.DAY],[mh,ye.DAYS],[hh,ye.DAYS360],[gh,ye.EDATE],[dh,ye.EOMONTH],[Ch,ye.HOUR],[_h,ye.ISOWEEKNUM],[Ah,ye.MINUTE],[Eh,ye.MONTH],[bh,ye.NETWORKDAYS],[yh,ye.NETWORKDAYS_INTL],[Rh,ye.NOW],[ph,ye.SECOND],[Nh,ye.TIME],[Vh,ye.TIMEVALUE],[Oh,ye.TODAY],[Mh,ye.WEEKDAY],[Sh,ye.WEEKNUM],[Dh,ye.WORKDAY],[wh,ye.WORKDAY_INTL],[Ph,ye.YEAR],[Lh,ye.YEARFRAC]];var z=(i=>(i.BESSELI="BESSELI",i.BESSELJ="BESSELJ",i.BESSELK="BESSELK",i.BESSELY="BESSELY",i.BIN2DEC="BIN2DEC",i.BIN2HEX="BIN2HEX",i.BIN2OCT="BIN2OCT",i.BITAND="BITAND",i.BITLSHIFT="BITLSHIFT",i.BITOR="BITOR",i.BITRSHIFT="BITRSHIFT",i.BITXOR="BITXOR",i.COMPLEX="COMPLEX",i.CONVERT="CONVERT",i.DEC2BIN="DEC2BIN",i.DEC2HEX="DEC2HEX",i.DEC2OCT="DEC2OCT",i.DELTA="DELTA",i.ERF="ERF",i.ERF_PRECISE="ERF.PRECISE",i.ERFC="ERFC",i.ERFC_PRECISE="ERFC.PRECISE",i.GESTEP="GESTEP",i.HEX2BIN="HEX2BIN",i.HEX2DEC="HEX2DEC",i.HEX2OCT="HEX2OCT",i.IMABS="IMABS",i.IMAGINARY="IMAGINARY",i.IMARGUMENT="IMARGUMENT",i.IMCONJUGATE="IMCONJUGATE",i.IMCOS="IMCOS",i.IMCOSH="IMCOSH",i.IMCOT="IMCOT",i.IMCSC="IMCSC",i.IMCSCH="IMCSCH",i.IMDIV="IMDIV",i.IMEXP="IMEXP",i.IMLN="IMLN",i.IMLOG10="IMLOG10",i.IMLOG2="IMLOG2",i.IMPOWER="IMPOWER",i.IMPRODUCT="IMPRODUCT",i.IMREAL="IMREAL",i.IMSEC="IMSEC",i.IMSECH="IMSECH",i.IMSIN="IMSIN",i.IMSINH="IMSINH",i.IMSQRT="IMSQRT",i.IMSUB="IMSUB",i.IMSUM="IMSUM",i.IMTAN="IMTAN",i.OCT2BIN="OCT2BIN",i.OCT2DEC="OCT2DEC",i.OCT2HEX="OCT2HEX",i))(z||{});class xh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besseli(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class jh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besselj(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Uh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besselk(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class vh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.bessely(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Th extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!Is(a))return g.create(h.NUM);let u;return a.length===10&&a.substring(0,1)==="1"?u=Number.parseInt(a.substring(1),2)-512:u=Number.parseInt(a,2),y.create(u)}}class Bh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Is(c))return g.create(h.NUM);let l;if(c.length===10&&c.substring(0,1)==="1")l=(0xfffffffe00+Number.parseInt(c.substring(1),2)).toString(16);else if(l=Number.parseInt(c,2).toString(16),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l.toLocaleUpperCase())}}class Ih extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Is(c))return g.create(h.NUM);let l;if(c.length===10&&c.substring(0,1)==="1")l=(1073741312+Number.parseInt(c.substring(1),2)).toString(8);else if(l=Number.parseInt(c,2).toString(8),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l)}}class Fh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue(),_=+d.getValue();if(C<0||_<0||Math.floor(C)!==C||Math.floor(_)!==_||C>0xffffffffffff||_>0xffffffffffff)return g.create(h.NUM);const E=C&_;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class kh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue();let _=+d.getValue();if(C<0||Math.floor(C)!==C||C>0xffffffffffff||Math.abs(_)>53)return g.create(h.NUM);_=Math.trunc(_);const E=Number(_>=0?BigInt(C)<<BigInt(_):BigInt(C)>>BigInt(-_));return E>0xffffffffffff?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class $h extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue(),_=+d.getValue();if(C<0||_<0||Math.floor(C)!==C||Math.floor(_)!==_||C>0xffffffffffff||_>0xffffffffffff)return g.create(h.NUM);const E=Number(BigInt(C)|BigInt(_));return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Yh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue();let _=+d.getValue();if(C<0||Math.floor(C)!==C||C>0xffffffffffff||Math.abs(_)>53)return g.create(h.NUM);_=Math.trunc(_);const E=Number(_>=0?BigInt(C)>>BigInt(_):BigInt(C)<<BigInt(-_));return E>0xffffffffffff?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Hh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue(),_=+d.getValue();if(C<0||_<0||Math.floor(C)!==C||Math.floor(_)!==_||C>0xffffffffffff||_>0xffffffffffff)return g.create(h.NUM);const E=C^_;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}x.prototype.cos=function(){const i=this.toNumber();return new x(Math.cos(i))};let de=class fe{constructor(o){A(this,"_inumber","");A(this,"_realNum",0);A(this,"_iNum",0);A(this,"_suffix","");A(this,"_isError",!1);if(`${o}`.trim()===""){this._isError=!0;return}this._inumber=o,this._getImReal(),this._getImAginary(),this._getImSuffix()}static getComplex(o,e,t){const r=new x(o).toSignificantDigits(15).toNumber(),n=new x(e).toSignificantDigits(15).toNumber(),s=t===""?"i":t;let a;if(r===0&&n===0)a=0;else if(r===0)a=n===1?s:`${n}${s}`;else if(n===0)a=r;else{const u=n>0?"+":"",c=n===1?s:`${n}${s}`;a=`${r}${u}${c}`}return a}static createByComplexStr(o,e,t){const r=fe.getComplex(o,e,t);return new fe(r)}_getImReal(){if(this._inumber===0||this._inumber==="0"){this._realNum=0;return}const o=`${this._inumber}`;if(["i","+i","1i","+1i","-i","-1i","j","+j","1j","+1j","-j","-1j"].indexOf(o)>=0){this._realNum=0;return}let e=o.indexOf("+"),t=o.indexOf("-");e===0&&(e=o.indexOf("+",1)),t===0&&(t=o.indexOf("-",1));const r=o.substring(o.length-1,o.length),n=r==="i"||r==="j";if(e>=0||t>=0){if(!n){this._isError=!0;return}e>=0?Number.isNaN(+o.substring(0,e))||Number.isNaN(+o.substring(e+1,o.length-1))?this._isError=!0:this._realNum=+o.substring(0,e):Number.isNaN(+o.substring(0,t))||Number.isNaN(+o.substring(t+1,o.length-1))?this._isError=!0:this._realNum=+o.substring(0,t)}else n?Number.isNaN(+o.substring(0,o.length-1))?this._isError=!0:this._realNum=0:Number.isNaN(+o)?this._isError=!0:this._realNum=+o}_getImAginary(){if(this._isError)return;if(this._inumber===0||this._inumber==="0"){this._iNum=0;return}let o=`${this._inumber}`;if(["i","j"].indexOf(o)>=0){this._iNum=1;return}o=o.replace("+i","+1i").replace("-i","-1i").replace("+j","+1j").replace("-j","-1j");let e=o.indexOf("+"),t=o.indexOf("-");e===0&&(e=o.indexOf("+",1)),t===0&&(t=o.indexOf("-",1));const r=o.substring(o.length-1,o.length),n=r==="i"||r==="j";if(e>=0||t>=0){if(!n){this._isError=!0;return}e>=0?Number.isNaN(+o.substring(0,e))||Number.isNaN(+o.substring(e+1,o.length-1))?this._isError=!0:this._iNum=+o.substring(e+1,o.length-1):Number.isNaN(+o.substring(0,t))||Number.isNaN(+o.substring(t+1,o.length-1))?this._isError=!0:this._iNum=-+o.substring(t+1,o.length-1)}else n?Number.isNaN(+o.substring(0,o.length-1))?this._isError=!0:this._iNum=+o.substring(0,o.length-1):Number.isNaN(+o)?this._isError=!0:this._iNum=0}_getImSuffix(){const o=`${this._inumber}`,e=o.substring(o.length-1);this._suffix=e==="i"||e==="j"?e:""}getRealNum(){return this._realNum}getINum(){return this._iNum}getSuffix(){return this._suffix}isError(){return this._isError}toString(){return fe.getComplex(this._realNum,this._iNum,this._suffix)}isDifferentSuffixes(o){const e=o.getSuffix();return this._suffix===""||e===""?!1:this._suffix!==e}Abs(){return x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))).toSignificantDigits(16).toNumber()}Argument(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2)));let e=x.acos(new x(this._realNum).div(o)).toSignificantDigits(16).toNumber();return this._iNum<0&&(e=-e),e}Conjugate(){return fe.getComplex(this._realNum,-this._iNum,this._suffix)}Cos(){if(this._iNum){const o=x.cos(this._realNum).mul(x.cosh(this._iNum)).toNumber(),e=x.sin(this._realNum).mul(x.sinh(this._iNum)).negated().toNumber();return fe.getComplex(o,e,this._suffix)}else{const o=x.cos(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Cosh(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return this._isError=!0,"";if(this._iNum){const o=x.cosh(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.sinh(this._realNum).mul(x.sin(this._iNum)).toNumber();return fe.getComplex(o,e,this._suffix)}else{const o=x.cosh(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Cot(){if(this._iNum){const o=x.cosh(this._iNum*2).sub(x.cos(this._realNum*2)),e=x.sin(this._realNum*2).div(o).toNumber(),t=x.sinh(this._iNum*2).div(o).negated().toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.tan(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Csc(){if(this._iNum){const o=x.cosh(this._iNum*2).sub(x.cos(this._realNum*2)),e=x.sin(this._realNum).mul(x.cosh(this._iNum)).mul(2).div(o).toNumber(),t=x.cos(this._realNum).mul(x.sinh(this._iNum)).mul(-2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.sin(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Csch(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return fe.getComplex(0,0,this._suffix);if(this._iNum){const o=x.cosh(this._realNum*2).sub(x.cos(this._iNum*2)),e=x.sinh(this._realNum).mul(x.cos(this._iNum)).mul(2).div(o).toNumber(),t=x.cosh(this._realNum).mul(x.sin(this._iNum)).mul(-2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.sinh(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Div(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=r.mul(r).add(n.mul(n)),a=e.mul(r).add(t.mul(n)).div(s).toNumber(),u=t.mul(r).sub(e.mul(n)).div(s).toNumber(),c=this._suffix===""?o.getSuffix():this._suffix;return fe.getComplex(a,u,c)}Exp(){if(!Number.isFinite(Math.exp(this._realNum)))return this._isError=!0,"";const o=x.exp(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.exp(this._realNum).mul(x.sin(this._iNum)).toNumber();return fe.getComplex(o,e,this._suffix)}Ln(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.ln(o).toNumber(),t=x.acos(new x(this._realNum).div(o)).toNumber();return fe.getComplex(e,t,this._suffix)}Log10(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.ln(o);let t=x.acos(new x(this._realNum).div(o));this._iNum<0&&(t=t.negated());const r=x.ln(10),n=new x(0),s=r.mul(r).add(n.mul(n)),a=e.mul(r).add(t.mul(n)).div(s).toNumber(),u=t.mul(r).sub(e.mul(n)).div(s).toNumber();return fe.getComplex(a,u,this._suffix)}Log2(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.ln(o);let t=x.acos(new x(this._realNum).div(o));this._iNum<0&&(t=t.negated());const r=x.ln(2),n=new x(0),s=r.mul(r).add(n.mul(n)),a=e.mul(r).add(t.mul(n)).div(s).toNumber(),u=t.mul(r).sub(e.mul(n)).div(s).toNumber();return fe.getComplex(a,u,this._suffix)}Power(o){if(this._realNum===0&&this._iNum===0)return o>0?fe.getComplex(this._realNum,this._iNum,this._suffix):(this._isError=!0,"");let e=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),t=x.acos(new x(this._realNum).div(e));this._iNum<0&&(t=t.negated()),e=x.pow(e,o),t=t.mul(o);const r=x.cos(t).mul(e).toNumber(),n=x.sin(t).mul(e).toNumber();return!Number.isFinite(r)||!Number.isFinite(n)?(this._isError=!0,""):fe.getComplex(r,n,this._suffix)}Product(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.mul(r).sub(t.mul(n)).toNumber(),a=e.mul(n).add(t.mul(r)).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return fe.getComplex(s,a,u)}Sec(){if(this._iNum){const o=x.cosh(this._iNum*2).add(x.cos(this._realNum*2)),e=x.cos(this._realNum).mul(x.cosh(this._iNum)).mul(2).div(o).toNumber(),t=x.sin(this._realNum).mul(x.sinh(this._iNum)).mul(2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.cos(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Sech(){if(!Number.isFinite(Math.sinh(this._realNum*2))||!Number.isFinite(Math.cosh(this._realNum*2)))return fe.getComplex(0,0,this._suffix);if(this._iNum){const o=x.cosh(this._realNum*2).add(x.cos(this._iNum*2)),e=x.cosh(this._realNum).mul(x.cos(this._iNum)).mul(2).div(o).toNumber(),t=x.sinh(this._realNum).mul(x.sin(this._iNum)).mul(-2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.cosh(this._realNum)).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Sin(){if(this._iNum){const o=x.sin(this._realNum).mul(x.cosh(this._iNum)).toNumber(),e=x.cos(this._realNum).mul(x.sinh(this._iNum)).toNumber();return fe.getComplex(o,e,this._suffix)}else{const o=x.sin(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Sinh(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return this._isError=!0,"";if(this._iNum){const o=x.sinh(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.cosh(this._realNum).mul(x.sin(this._iNum)).toNumber();return fe.getComplex(o,e,this._suffix)}else{const o=x.sinh(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}Sqrt(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.sqrt(o);let t=x.acos(new x(this._realNum).div(o));this._iNum<0&&(t=t.negated());const r=e.mul(x.cos(t.div(2).toNumber())).toNumber(),n=e.mul(x.sin(t.div(2))).toNumber();return fe.getComplex(r,n,this._suffix)}Sub(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.sub(r).toNumber(),a=t.sub(n).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return fe.getComplex(s,a,u)}Sum(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.add(r).toNumber(),a=t.add(n).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return fe.getComplex(s,a,u)}Tan(){if(this._iNum){const o=x.cos(this._realNum*2).add(x.cosh(this._iNum*2)),e=x.sin(this._realNum*2).div(o).toNumber(),t=x.sinh(this._iNum*2).div(o).toNumber();return fe.getComplex(e,t,this._suffix)}else{const o=x.tan(this._realNum).toNumber();return fe.getComplex(o,this._iNum,this._suffix)}}};class Gh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:j.create("i"),{isError:s,errorObject:a,variants:u}=H(e,t,n);if(s)return a;const[c,l,f]=u,m=+c.getValue(),d=+l.getValue(),C=`${f.getValue()}`;if(Number.isNaN(m)||Number.isNaN(d)||C!=="i"&&C!=="j")return g.create(h.VALUE);const _=de.getComplex(m,d,C);return typeof _=="number"?y.create(_):j.create(_)}}class Wh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"_units",[["a.u. of action","?",null,"action",!1,!1,105457168181818e-48],["a.u. of charge","e",null,"electric_charge",!1,!1,160217653141414e-33],["a.u. of energy","Eh",null,"energy",!1,!1,435974417757576e-32],["a.u. of length","a?",null,"length",!1,!1,529177210818182e-25],["a.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["a.u. of time","?/Eh",null,"time",!1,!1,241888432650516e-31],["admiralty knot","admkn",null,"speed",!1,!0,.514773333],["ampere","A",null,"electric_current",!0,!1,1],["ampere per meter","A/m",null,"magnetic_field_intensity",!0,!1,1],["ångström","Å",["ang"],"length",!1,!0,1e-10],["are","ar",null,"area",!1,!0,100],["astronomical unit","ua",null,"length",!1,!1,149597870691667e-25],["bar","bar",null,"pressure",!1,!1,1e5],["barn","b",null,"area",!1,!1,1e-28],["becquerel","Bq",null,"radioactivity",!0,!1,1],["bit","bit",["b"],"information",!1,!0,1],["btu","BTU",["btu"],"energy",!1,!0,1055.05585262],["byte","byte",null,"information",!1,!0,8],["candela","cd",null,"luminous_intensity",!0,!1,1],["candela per square metre","cd/m?",null,"luminance",!0,!1,1],["centigrade","C",["cel"],"temperature",!0,!1,1],["cubic ångström","ang3",["ang^3"],"volume",!1,!0,1e-30],["cubic foot","ft3",["ft^3"],"volume",!1,!0,.028316846592],["cubic inch","in3",["in^3"],"volume",!1,!0,16387064e-12],["cubic light-year","ly3",["ly^3"],"volume",!1,!0,846786664623715e-61],["cubic metre","m3",["m^3"],"volume",!0,!0,1],["cubic mile","mi3",["mi^3"],"volume",!1,!0,416818182544058e-5],["cubic nautical mile","Nmi3",["Nmi^3"],"volume",!1,!0,6352182208],["cubic Pica","Pica3",["Picapt3","Pica^3","Picapt^3"],"volume",!1,!0,758660370370369e-22],["cubic yard","yd3",["yd^3"],"volume",!1,!0,.764554857984],["cup","cup",null,"volume",!1,!0,.0002365882365],["dalton","Da",["u"],"mass",!1,!1,166053886282828e-41],["day","d",["day"],"time",!1,!0,86400],["degree","°",null,"angle",!1,!1,.0174532925199433],["dyne","dyn",["dy"],"force",!1,!0,1e-5],["electronvolt","eV",["ev"],"energy",!1,!0,1.60217656514141],["ell","ell",null,"length",!1,!0,1.143],["erg","erg",["e"],"energy",!1,!0,1e-7],["fahrenheit","F",["fah"],"temperature",!0,!1,1],["fluid ounce","oz",null,"volume",!1,!0,295735295625e-16],["foot","ft",null,"length",!1,!0,.3048],["foot-pound","flb",null,"energy",!1,!0,1.3558179483314],["gal","Gal",null,"acceleration",!1,!1,.01],["gallon","gal",null,"volume",!1,!0,.003785411784],["gauss","G",["ga"],"magnetic_flux_density",!1,!0,1],["grain","grain",null,"mass",!1,!0,647989e-10],["gram","g",null,"mass",!1,!0,.001],["gray","Gy",null,"absorbed_dose",!0,!1,1],["gross registered ton","GRT",["regton"],"volume",!1,!0,2.8316846592],["hectare","ha",null,"area",!1,!0,1e4],["henry","H",null,"inductance",!0,!1,1],["hertz","Hz",null,"frequency",!0,!1,1],["horsepower","HP",["h"],"power",!1,!0,745.69987158227],["horsepower-hour","HPh",["hh","hph"],"energy",!1,!0,2684519538e-3],["hour","h",["hr"],"time",!1,!0,3600],["imperial gallon (U.K.)","uk_gal",null,"volume",!1,!0,.00454609],["imperial hundredweight","lcwt",["uk_cwt","hweight"],"mass",!1,!0,50.802345],["imperial quart (U.K)","uk_qt",null,"volume",!1,!0,.0011365225],["imperial ton","brton",["uk_ton","LTON"],"mass",!1,!0,1016.046909],["inch","in",null,"length",!1,!0,.0254],["international acre","uk_acre",null,"area",!1,!0,4046.8564224],["IT calorie","cal",null,"energy",!1,!0,4.1868],["joule","J",null,"energy",!0,!0,1],["katal","kat",null,"catalytic_activity",!0,!1,1],["kelvin","K",["kel"],"temperature",!0,!0,1],["kilogram","kg",null,"mass",!0,!0,1],["knot","kn",null,"speed",!1,!0,.514444444444444],["light-year","ly",null,"length",!1,!0,9460730472580800],["litre","L",["l","lt"],"volume",!1,!0,.001],["lumen","lm",null,"luminous_flux",!0,!1,1],["lux","lx",null,"illuminance",!0,!1,1],["maxwell","Mx",null,"magnetic_flux",!1,!1,1e-18],["measurement ton","MTON",null,"volume",!1,!0,1.13267386368],["meter per hour","m/h",["m/hr"],"speed",!1,!0,.00027777777777778],["meter per second","m/s",["m/sec"],"speed",!0,!0,1],["meter per second squared","m?s??",null,"acceleration",!0,!1,1],["parsec","pc",["parsec"],"length",!1,!0,0x6da012f958ee1c],["meter squared per second","m?/s",null,"kinematic_viscosity",!0,!1,1],["metre","m",null,"length",!0,!0,1],["miles per hour","mph",null,"speed",!1,!0,.44704],["millimetre of mercury","mmHg",null,"pressure",!1,!1,133.322],["minute","?",null,"angle",!1,!1,.000290888208665722],["minute","min",["mn"],"time",!1,!0,60],["modern teaspoon","tspm",null,"volume",!1,!0,5e-6],["mole","mol",null,"amount_of_substance",!0,!1,1],["morgen","Morgen",null,"area",!1,!0,2500],["n.u. of action","?",null,"action",!1,!1,105457168181818e-48],["n.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["n.u. of speed","c?",null,"speed",!1,!1,299792458],["n.u. of time","?/(me?c??)",null,"time",!1,!1,128808866778687e-35],["nautical mile","M",["Nmi"],"length",!1,!0,1852],["newton","N",null,"force",!0,!0,1],["œrsted","Oe ",null,"magnetic_field_intensity",!1,!1,79.5774715459477],["ohm","Ω",null,"electric_resistance",!0,!1,1],["ounce mass","ozm",null,"mass",!1,!0,.028349523125],["pascal","Pa",null,"pressure",!0,!1,1],["pascal second","Pa?s",null,"dynamic_viscosity",!0,!1,1],["pferdestärke","PS",null,"power",!1,!0,735.49875],["phot","ph",null,"illuminance",!1,!1,1e-4],["pica (1/6 inch)","pica",null,"length",!1,!0,.00035277777777778],["pica (1/72 inch)","Pica",["Picapt"],"length",!1,!0,.00423333333333333],["poise","P",null,"dynamic_viscosity",!1,!1,.1],["pond","pond",null,"force",!1,!0,.00980665],["pound force","lbf",null,"force",!1,!0,4.4482216152605],["pound mass","lbm",null,"mass",!1,!0,.45359237],["quart","qt",null,"volume",!1,!0,.000946352946],["radian","rad",null,"angle",!0,!1,1],["rankine","Rank",null,"temperature",!1,!0,1],["reaumur","Reau",null,"temperature",!1,!0,1],["second","?",null,"angle",!1,!1,484813681109536e-20],["second","s",["sec"],"time",!0,!0,1],["short hundredweight","cwt",["shweight"],"mass",!1,!0,45.359237],["siemens","S",null,"electrical_conductance",!0,!1,1],["sievert","Sv",null,"equivalent_dose",!0,!1,1],["slug","sg",null,"mass",!1,!0,14.59390294],["square ångström","ang2",["ang^2"],"area",!1,!0,1e-20],["square foot","ft2",["ft^2"],"area",!1,!0,.09290304],["square inch","in2",["in^2"],"area",!1,!0,64516e-8],["square light-year","ly2",["ly^2"],"area",!1,!0,895054210748189e17],["square meter","m?",null,"area",!0,!0,1],["square mile","mi2",["mi^2"],"area",!1,!0,2589988110336e-6],["square nautical mile","Nmi2",["Nmi^2"],"area",!1,!0,3429904],["square Pica","Pica2",["Picapt2","Pica^2","Picapt^2"],"area",!1,!0,1792111111111e-17],["square yard","yd2",["yd^2"],"area",!1,!0,.83612736],["statute mile","mi",null,"length",!1,!0,1609.344],["steradian","sr",null,"solid_angle",!0,!1,1],["stilb","sb",null,"luminance",!1,!1,1e-4],["stokes","St",null,"kinematic_viscosity",!1,!1,1e-4],["stone","stone",null,"mass",!1,!0,6.35029318],["tablespoon","tbs",null,"volume",!1,!0,147868e-10],["teaspoon","tsp",null,"volume",!1,!0,492892e-11],["tesla","T",null,"magnetic_flux_density",!0,!0,1],["thermodynamic calorie","c",null,"energy",!1,!0,4.184],["ton","ton",null,"mass",!1,!0,907.18474],["tonne","t",null,"mass",!1,!1,1e3],["U.K. pint","uk_pt",null,"volume",!1,!0,.00056826125],["U.S. bushel","bushel",null,"volume",!1,!0,.03523907],["U.S. oil barrel","barrel",null,"volume",!1,!0,.158987295],["U.S. pint","pt",["us_pt"],"volume",!1,!0,.000473176473],["U.S. survey mile","survey_mi",null,"length",!1,!0,1609.347219],["U.S. survey/statute acre","us_acre",null,"area",!1,!0,4046.87261],["volt","V",null,"voltage",!0,!1,1],["watt","W",null,"power",!0,!0,1],["watt-hour","Wh",["wh"],"energy",!1,!0,3600],["weber","Wb",null,"magnetic_flux",!0,!1,1],["yard","yd",null,"length",!1,!0,.9144],["year","yr",null,"time",!1,!0,31557600]]);A(this,"_binaryPrefixes",{Yi:["yobi",80,12089258196146292e8,"Yi","yotta"],Zi:["zebi",70,11805916207174113e5,"Zi","zetta"],Ei:["exbi",60,1152921504606847e3,"Ei","exa"],Pi:["pebi",50,0x4000000000000,"Pi","peta"],Ti:["tebi",40,1099511627776,"Ti","tera"],Gi:["gibi",30,1073741824,"Gi","giga"],Mi:["mebi",20,1048576,"Mi","mega"],ki:["kibi",10,1024,"ki","kilo"]});A(this,"_unitPrefixes",{Y:["yotta",1e24,"Y"],Z:["zetta",1e21,"Z"],E:["exa",1e18,"E"],P:["peta",1e15,"P"],T:["tera",1e12,"T"],G:["giga",1e9,"G"],M:["mega",1e6,"M"],k:["kilo",1e3,"k"],h:["hecto",100,"h"],e:["dekao",10,"e"],d:["deci",.1,"d"],c:["centi",.01,"c"],m:["milli",.001,"m"],u:["micro",1e-6,"u"],n:["nano",1e-9,"n"],p:["pico",1e-12,"p"],f:["femto",1e-15,"f"],a:["atto",1e-18,"a"],z:["zepto",1e-21,"z"],y:["yocto",1e-24,"y"]})}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=H(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=`${c.getValue()}`,d=`${l.getValue()}`;if(Number.isNaN(f))return g.create(h.VALUE);let C,_=1,E,b=1;const{_from:R,_to:p}=this._lookupFromAndToUnits(m,d);if(C=R,E=p,C===null){const{_from:S,_fromMultiplier:D}=this._lookupFromPrefix(m);C=S,_=D}if(E===null){const{_to:S,_toMultiplier:D}=this._lookupToPrefix(d);E=S,b=D}if(C===null||E===null||C[3]!==E[3])return g.create(h.NA);let V;return C[3]==="temperature"?(V=this._getTemperatureConversion(f,C[1],E[1]),V=+V.toFixed(2)):V=f*C[6]*_/(E[6]*b),y.create(V)}_lookupFromAndToUnits(e,t){let r=null,n=null,s;for(let a=0;a<this._units.length;a++)s=this._units[a][2]===null?[]:this._units[a][2],(this._units[a][1]===e||s.indexOf(e)>=0)&&(r=this._units[a]),(this._units[a][1]===t||s.indexOf(t)>=0)&&(n=this._units[a]);return{_from:r,_to:n}}_lookupFromPrefix(e){let t=null,r=1,n=e,s;const a=this._binaryPrefixes[e.substring(0,2)];let u=this._unitPrefixes[e.substring(0,1)];e.substring(0,2)==="da"&&(u=["dekao",10,"da"]),a?(r=a[2],n=e.substring(2)):u&&(r=u[1],n=e.substring(u[2].length));for(let c=0;c<this._units.length;c++)s=this._units[c][2]===null?[]:this._units[c][2],(this._units[c][1]===n||s.indexOf(n)>=0)&&(t=this._units[c]);return{_from:t,_fromMultiplier:r}}_lookupToPrefix(e){let t=null,r=1,n=e,s;const a=this._binaryPrefixes[e.substring(0,2)];let u=this._unitPrefixes[e.substring(0,1)];e.substring(0,2)==="da"&&(u=["dekao",10,"da"]),a?(r=a[2],n=e.substring(2)):u&&(r=u[1],n=e.substring(u[2].length));for(let c=0;c<this._units.length;c++)s=this._units[c][2]===null?[]:this._units[c][2],(this._units[c][1]===n||s.indexOf(n)>=0)&&(t=this._units[c]);return{_to:t,_toMultiplier:r}}_getTemperatureConversion(e,t,r){switch(t){case"C":return this._centigradeConversion(e,r);case"F":return this._fahrenheitConversion(e,r);case"K":return this._kelvinConversion(e,r);case"Rank":return this._rankineConversion(e,r);case"Reau":return this._reaumurConversion(e,r);default:return e}}_centigradeConversion(e,t){switch(t){case"F":return e*9/5+32;case"K":return e+273.15;case"Rank":return(e+273.15)*9/5;case"Reau":return e*4/5;default:return e}}_fahrenheitConversion(e,t){switch(t){case"C":return(e-32)*5/9;case"K":return(e-32)*5/9+273.15;case"Rank":return e+459.67;case"Reau":return(e-32)*4/9;default:return e}}_kelvinConversion(e,t){switch(t){case"C":return e-273.15;case"F":return(e-273.15)*9/5+32;case"Rank":return e*9/5;case"Reau":return(e-273.15)*4/5;default:return e}}_rankineConversion(e,t){switch(t){case"C":return(e-491.67)*5/9;case"F":return e-459.67;case"K":return e*5/9;case"Reau":return(e-491.67)*4/9;default:return e}}_reaumurConversion(e,t){switch(t){case"C":return e*5/4;case"F":return e*9/4+32;case"K":return e*5/4+273.15;case"Rank":return e*9/4+491.67;default:return e}}}class Qh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,3}$/.test(`${c}`)||c<-512||c>511)return g.create(h.NUM);let l;if(c<0){const f=(512+c).toString(2);l=`1${"0".repeat(9-f.length)}${f}`}else if(l=Number.parseInt(`${c}`,10).toString(2),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l)}}class qh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,12}$/.test(`${c}`)||c<-549755813888||c>549755813887)return g.create(h.NUM);let l;if(c<0)l=(1099511627776+c).toString(16);else if(l=Number.parseInt(`${c}`,10).toString(16),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l.toLocaleUpperCase())}}class Xh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=H(t);if(f)return m;const[C]=d;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,9}$/.test(`${c}`)||c<-536870912||c>536870911)return g.create(h.NUM);let l;if(c<0)l=(1073741824+c).toString(8);else if(l=Number.parseInt(`${c}`,10).toString(8),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return j.create(l)}}class Kh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),{isError:n,errorObject:s,variants:a}=H(e,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);const m=l===f?1:0;return y.create(m)}}class Zh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r;if(t){const{isError:n,errorObject:s,variants:a}=H(e,t);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);r=Ft(f)-Ft(l)}else{const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=+u.getValue();if(Number.isNaN(c))return g.create(h.VALUE);r=Ft(c)}return y.create(r)}}class zh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=Ft(a);return y.create(u)}}class Jh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=$s(a);return y.create(u)}}class eg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=$s(a);return y.create(u)}}class tg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);const r=t!=null?t:y.create(0),{isError:n,errorObject:s,variants:a}=H(e,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);const m=l>=f?1:0;return y.create(m)}}class rg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:d,errorObject:C,variants:_}=H(t);if(d)return C;const[E]=_;if(r=Math.floor(+E.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!ks(c))return g.create(h.NUM);const l=c.length===10&&c.substring(0,1).toLocaleUpperCase()==="F",f=l?Number.parseInt(c,16)-1099511627776:Number.parseInt(c,16);if(f<-512||f>511)return g.create(h.NUM);let m;if(l){const d=(512+f).toString(2);m=`1${"0".repeat(9-d.length)}${d}`}else if(m=f.toString(2),t){if(r<m.length)return g.create(h.NUM);m="0".repeat(r-m.length)+m}return j.create(m)}}class ng extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!ks(a))return g.create(h.NUM);let u=Number.parseInt(a,16);return u>=549755813888&&(u-=1099511627776),y.create(u)}}class sg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:m,errorObject:d,variants:C}=H(t);if(m)return d;const[_]=C;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!ks(c))return g.create(h.NUM);const l=Number.parseInt(c,16);if(l>536870911&&l<0xffe0000000)return g.create(h.NUM);let f;if(l>=0xffe0000000)f=(l-0xffc0000000).toString(8);else if(f=l.toString(8),t){if(r<f.length)return g.create(h.NUM);f="0".repeat(r-f.length)+f}return j.create(f)}}class ag extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Abs();return y.create(c)}}class ig extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.getINum();return y.create(c)}}class og extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);if(u.getRealNum()===0&&u.getINum()===0)return g.create(h.DIV_BY_ZERO);const c=u.Argument();return y.create(c)}}class ug extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Conjugate();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class cg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Cos();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class lg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Cosh();return u.isError()?g.create(h.NUM):typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class fg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Cot();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class mg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Csc();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class hg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Csch();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class gg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=`${u.getValue()}`,f=new de(c),m=new de(l);if(f.isError()||m.isError()||f.isDifferentSuffixes(m)||m.getRealNum()===0&&m.getINum()===0)return g.create(h.NUM);const d=f.Div(m);return typeof d=="number"||M.isRealNum(d)?y.create(+d):j.create(d)}}class dg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Exp();return u.isError()?g.create(h.NUM):typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Cg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Ln();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class _g extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Log10();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Ag extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Log2();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Eg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=new de(c);if(l.isError())return g.create(h.NUM);const f=+u.getValue();if(Number.isNaN(f))return g.create(h.VALUE);const m=l.Power(f);return l.isError()?g.create(h.NUM):typeof m=="number"||M.isRealNum(m)?y.create(+m):j.create(m)}}class bg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="";for(let r=0;r<e.length;r++){if(t instanceof g)return t;const n=e[r];if(n.isArray()){let s=!1,a;if(n.iterator(u=>{if(t=this._handleSingleObject(u,t),t instanceof g)return s=!0,a=t,!1}),s)return a}else t=this._handleSingleObject(n,t)}return t instanceof g?t:typeof t=="number"||M.isRealNum(t)?y.create(+t):j.create(t)}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);const n=`${e.getValue()}`;if(typeof t!="number"&&!t){const s=new de(n);if(s.isError())return g.create(h.NUM);r=s.toString()}else{const s=new de(t),a=new de(n);if(s.isError()||a.isError())return g.create(h.NUM);if(s.isDifferentSuffixes(a))return g.create(h.VALUE);r=s.Product(a)}return r}}class yg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.getRealNum();return y.create(c)}}class Rg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Sec();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class pg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Sech();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Ng extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Sin();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Vg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Sinh();return u.isError()?g.create(h.NUM):typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Og extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);if(u.getRealNum()===0&&u.getINum()===0)return y.create(0);const c=u.Sqrt();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class Mg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=`${u.getValue()}`,f=new de(c),m=new de(l);if(f.isError()||m.isError()||f.isDifferentSuffixes(m))return g.create(h.NUM);const d=f.Sub(m);return typeof d=="number"||M.isRealNum(d)?y.create(+d):j.create(d)}}class Sg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="";for(let r=0;r<e.length;r++){if(t instanceof g)return t;const n=e[r];if(n.isArray()){let s=!1,a;if(n.iterator(u=>{if(t=this._handleSingleObject(u,t),t instanceof g)return s=!0,a=t,!1}),s)return a}else t=this._handleSingleObject(n,t)}return t instanceof g?t:typeof t=="number"||M.isRealNum(t)?y.create(+t):j.create(t)}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);const n=`${e.getValue()}`;if(typeof t!="number"&&!t){const s=new de(n);if(s.isError())return g.create(h.NUM);r=s.toString()}else{const s=new de(t),a=new de(n);if(s.isError()||a.isError())return g.create(h.NUM);if(s.isDifferentSuffixes(a))return g.create(h.VALUE);r=s.Sum(a)}return r}}class Dg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new de(a);if(u.isError())return g.create(h.NUM);const c=u.Tan();return typeof c=="number"||M.isRealNum(c)?y.create(+c):j.create(c)}}class wg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:d,errorObject:C,variants:_}=H(t);if(d)return C;const[E]=_;if(r=Math.floor(+E.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Fs(c))return g.create(h.NUM);const l=c.length===10&&c.substring(0,1)==="7",f=l?Number.parseInt(c,8)-1073741824:Number.parseInt(c,8);if(f<-512||f>511)return g.create(h.NUM);let m;if(l){const d=(512+f).toString(2);m=`1${"0".repeat(9-d.length)}${d}`}else if(m=f.toString(2),t){if(r<m.length)return g.create(h.NUM);m="0".repeat(r-m.length)+m}return j.create(m)}}class Pg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=H(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!Fs(a))return g.create(h.NUM);let u=Number.parseInt(a,8);return u>=536870912&&(u-=1073741824),y.create(u)}}class Lg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:m,errorObject:d,variants:C}=H(t);if(m)return d;const[_]=C;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Fs(c))return g.create(h.NUM);const l=Number.parseInt(c,8);let f;if(l>=536870912)f=`ff${(l+3221225472).toString(16)}`;else if(f=l.toString(16),t){if(r<f.length)return g.create(h.NUM);f="0".repeat(r-f.length)+f}return j.create(f.toLocaleUpperCase())}}const zo=[[xh,z.BESSELI],[jh,z.BESSELJ],[Uh,z.BESSELK],[vh,z.BESSELY],[Th,z.BIN2DEC],[Bh,z.BIN2HEX],[Ih,z.BIN2OCT],[Fh,z.BITAND],[kh,z.BITLSHIFT],[$h,z.BITOR],[Yh,z.BITRSHIFT],[Hh,z.BITXOR],[Gh,z.COMPLEX],[Wh,z.CONVERT],[Qh,z.DEC2BIN],[qh,z.DEC2HEX],[Xh,z.DEC2OCT],[Kh,z.DELTA],[Zh,z.ERF],[zh,z.ERF_PRECISE],[Jh,z.ERFC],[eg,z.ERFC_PRECISE],[tg,z.GESTEP],[rg,z.HEX2BIN],[ng,z.HEX2DEC],[sg,z.HEX2OCT],[ag,z.IMABS],[ig,z.IMAGINARY],[og,z.IMARGUMENT],[ug,z.IMCONJUGATE],[cg,z.IMCOS],[lg,z.IMCOSH],[fg,z.IMCOT],[mg,z.IMCSC],[hg,z.IMCSCH],[gg,z.IMDIV],[dg,z.IMEXP],[Cg,z.IMLN],[_g,z.IMLOG10],[Ag,z.IMLOG2],[Eg,z.IMPOWER],[bg,z.IMPRODUCT],[yg,z.IMREAL],[Rg,z.IMSEC],[pg,z.IMSECH],[Ng,z.IMSIN],[Vg,z.IMSINH],[Og,z.IMSQRT],[Mg,z.IMSUB],[Sg,z.IMSUM],[Dg,z.IMTAN],[wg,z.OCT2BIN],[Pg,z.OCT2DEC],[Lg,z.OCT2HEX]];var J=(i=>(i.ACCRINT="ACCRINT",i.ACCRINTM="ACCRINTM",i.AMORDEGRC="AMORDEGRC",i.AMORLINC="AMORLINC",i.COUPDAYBS="COUPDAYBS",i.COUPDAYS="COUPDAYS",i.COUPDAYSNC="COUPDAYSNC",i.COUPNCD="COUPNCD",i.COUPNUM="COUPNUM",i.COUPPCD="COUPPCD",i.CUMIPMT="CUMIPMT",i.CUMPRINC="CUMPRINC",i.DB="DB",i.DDB="DDB",i.DISC="DISC",i.DOLLARDE="DOLLARDE",i.DOLLARFR="DOLLARFR",i.DURATION="DURATION",i.EFFECT="EFFECT",i.FV="FV",i.FVSCHEDULE="FVSCHEDULE",i.INTRATE="INTRATE",i.IPMT="IPMT",i.IRR="IRR",i.ISPMT="ISPMT",i.MDURATION="MDURATION",i.MIRR="MIRR",i.NOMINAL="NOMINAL",i.NPER="NPER",i.NPV="NPV",i.ODDFPRICE="ODDFPRICE",i.ODDFYIELD="ODDFYIELD",i.ODDLPRICE="ODDLPRICE",i.ODDLYIELD="ODDLYIELD",i.PDURATION="PDURATION",i.PMT="PMT",i.PPMT="PPMT",i.PRICE="PRICE",i.PRICEDISC="PRICEDISC",i.PRICEMAT="PRICEMAT",i.PV="PV",i.RATE="RATE",i.RECEIVED="RECEIVED",i.RRI="RRI",i.SLN="SLN",i.SYD="SYD",i.TBILLEQ="TBILLEQ",i.TBILLPRICE="TBILLPRICE",i.TBILLYIELD="TBILLYIELD",i.VDB="VDB",i.XIRR="XIRR",i.XNPV="XNPV",i.YIELD="YIELD",i.YIELDDISC="YIELDDISC",i.YIELDMAT="YIELDMAT",i))(J||{});function $n(i,o,e,t){const r=wt(i,o,e),{days:n}=Ce(r,i,t);return n}function $e(i,o,e,t){let r;if(t===1){const n=wt(i,o,e);let s=re(n);s=ur(s,12/e);const a=Ee(s);n<0&&e===1?r=365:r=a-n}else t===3?r=365/e:r=360/e;return r}function Jo(i,o,e){const t=re(i);let r=re(o);for(r.setUTCFullYear(t.getUTCFullYear()),r<t&&r.setUTCFullYear(r.getUTCFullYear()+1);r>t;)r=ur(r,-12/e);return r=ur(r,12/e),Ee(r)}function Wt(i,o,e){let t=0;const r=re(i);let n=re(o);for(;n>r;)n=ur(n,-12/e),t++;return t}function wt(i,o,e){const t=re(i);let r=re(o);for(r.setUTCFullYear(t.getUTCFullYear()),r<t&&r.setUTCFullYear(r.getUTCFullYear()+1);r>t;)r=ur(r,-12/e);return Ee(r)}function eu(i,o,e,t,r,n){const s=$n(i,o,r,n),a=$e(i,o,r,n),u=Wt(i,o,r),c=(a-s)/a-1,l=t/r+1,f=e*100/r;let m=0,d=0;for(let E=1;E<=u;E++){const b=E+c,R=f/l**b;m+=b*R,d+=R}const C=u+c,_=100/l**C;return m+=C*_,d+=_,m/d/r}function jr(i,o,e,t,r){let n;if(i===0)n=(e+t)/o;else{const s=(1+i)**o;n=r===1?(t*i/(s-1)+e*i/(1-1/s))/(1+i):t*i/(s-1)+e*i/(1-1/s)}return-n}function Qt(i,o,e,t,r){let n;if(i===0)n=t+e*o;else{if(i===-1&&o===0)return Number.NaN;const s=(1+i)**o;n=r===1?t*s+e*(1+i)*(s-1)/i:t*s+e*(s-1)/i}return-n}function tu(i,o,e,t,r,n){const s=jr(i,e,t,r,n);return(o===1?n===1?0:-t:n===1?Qt(i,o-2,s,t,1)-s:Qt(i,o-1,s,t,0))*i}function ru(i,o){let e=0;for(let t=1;t<=o.length;t++)e+=o[t-1]/(1+i)**t;return e}function nu(i,o,e,t,r,n,s,a,u){const c=It(e,t,u),l=$e(i,t,a,u);return c<l?xg(i,o,e,t,r,n,s,a,u,c,l):jg(i,o,e,t,r,n,s,a,u,l)}function xg(i,o,e,t,r,n,s,a,u,c,l){let f=0;const m=Wt(i,o,a),d=It(i,t,u);f+=s/(1+n/a)**(m-1+d/l),f+=100*r/a*c/l/(1+n/a)**(d/l);for(let _=2;_<=m;_++)f+=100*r/a/(1+n/a)**(_-1+d/l);const C=It(e,i,u);return f-=100*r/a*C/l,f}function jg(i,o,e,t,r,n,s,a,u,c){let l=0;const f=Wt(t,o,a),m=Ug(t,i,12/a,!0);let d;if(u===2||u===3){const R=Jo(i,t,a);d=It(i,R,u)}else{const R=wt(i,t,a),{days:p}=Ce(R,i,u);d=c-p}l+=s/(1+n/a)**(f+m+d/c);const C=Wt(e,t,a);let _=t,E=0,b=0;for(let R=C;R>=1;R--){const p=$t(_,-12/a,!1),V=u===1?It(p,_,u):c,S=R>1?V:It(e,_,u);E+=S/V;const D=e>p?e:p,w=i<_?i:_,P=It(D,w,u);b+=P/V,_=p}l+=100*r/a*E/(1+n/a)**(m+d/c);for(let R=1;R<=f;R++)l+=100*r/a/(1+n/a)**(R+m+d/c);return l-=100*r/a*b,l}function It(i,o,e){const{days:t}=Ce(i,o,e);return i<o?t:0}function su(i,o,e){const t=re(i),r=t.getUTCFullYear(),n=t.getUTCMonth(),s=t.getUTCDate(),a=or(r,n,s),u=re(o),c=u.getUTCFullYear(),l=u.getUTCMonth(),f=u.getUTCDate(),m=or(c,l,f);return!(s!==f&&!(a&&m)||Math.abs((c-r)*12+(l-n))%(12/e)!==0)}function gr(i,o,e){return wt(i,o,e)>=0}function $t(i,o,e){let t=re(i);if(t=ur(t,o),e){const r=t.getUTCFullYear(),n=t.getUTCMonth(),s=xr(r,n);t.setUTCDate(s)}return Ee(t)}function Ug(i,o,e,t){const r=re(i),n=re(o),s=r.getUTCFullYear(),a=r.getUTCMonth(),u=r.getUTCDate(),c=n.getUTCFullYear(),l=n.getUTCMonth(),f=n.getUTCDate(),m=or(s,a,u),d=!m&&a!==1&&u>28&&u<xr(s,a)?or(c,l,f):m,C=$t(o,0,d);let _=+t-0+ +(o<C),E=$t(C,e,d);for(;!(e>0?E>=o:E<=o);)E=$t(E,e,d),_++;return _}function na(i,o){let n=1,s=0,a=i,u;for(;n>1e-7&&s<500;){const c=(o(a+1e-7)-o(a-1e-7))/2e-7;u=a-o(a)/c,s++,n=Math.abs(u-a),a=u}return Number.isNaN(a)||Math.abs(a)===1/0||s===500?vg(i,o):a}function vg(i,o){const r=Number.MAX_VALUE,n=-1,s=1.6;let a=i-.01<=n?n+1e-7:i-.01,u=i+.01>=r?r-1e-7:i+.01,c,l,f=0;if(i<=n||i>=r)return g.create(h.NUM);for(let E=0;E<60;E++){c=a<=n?n+1e-7:a,l=u>=r?r-1e-7:u;const b=o(c),R=o(l);if(b*R<=0)break;if(b*R>0)a=c+s*(c-l),u=l+s*(l-c);else return g.create(h.NUM);if(E===59)return g.create(h.NUM)}c=c,l=l;let m=o(c);const d=o(l);let C,_;if(Math.abs(m)<1e-7||Math.abs(d)<1e-7)return g.create(h.NUM);do _=c+(l-c)/2,C=o(_),m*C<0?l=_:c=_,m=o(c),f++;while(Math.abs(C)>1e-7&&f<60);return _}function qr(i,o,e,t,r,n,s){const a=Wt(i,o,n),u=$e(i,o,n,s),c=$n(i,o,n,s);if(a===1){const m=u-c,d=100*e/n+r,C=t/n*m/u+1,_=100*e/n*c/u;return d/C-_}const l=u-c;let f=r/(1+t/n)**(a-1+l/u);for(let m=1;m<=a;m++)f+=100*e/n/(1+t/n)**(m-1+l/u);return f-=100*e/n*c/u,f}function ys(i,o,e,t,r){let n=0,s=r/e;s>=1?(s=1,n=t===1?i:0):n=i*(1-s)**(t-1);const a=i*(1-s)**t;let u=0;return a<o?u=n-o:u=n-a,u<0&&(u=0),u}class Tg extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",8)}calculate(e,t,r,n,s,a,u,c){const l=u!=null?u:y.create(0),f=c!=null?c:k.create(!0),{isError:m,errorObject:d,variants:C}=H(e,t,r,n,s,a,l);if(m)return d;const[_,E,b,R,p,V,S]=C,D=F(_);if(typeof D!="number")return D;const w=F(E);if(typeof w!="number")return w;const P=F(b);if(typeof P!="number")return P;const L=+R.getValue(),T=+p.getValue(),B=Math.floor(+V.getValue()),W=Math.floor(+S.getValue()),q=+f.getValue();return Number.isNaN(L)||Number.isNaN(T)||Number.isNaN(B)||Number.isNaN(W)||Number.isNaN(q)?g.create(h.VALUE):L<=0||T<=0||![1,2,4].includes(B)||W<0||W>4||Math.floor(D)>=Math.floor(P)?g.create(h.NUM):this._getResult(D,w,P,L,T,B,W,q)}_getResult(e,t,r,n,s,a,u,c){let l=wt(e,t,a);if(l<=0)return y.create(0);l=wt(r,t,a);const f=12/a,m=re(t),d=m.getUTCFullYear(),C=m.getUTCMonth(),_=m.getUTCDate(),E=or(d,C,_);let b=$t(t,-f,E);if(r>t&&c)for(b=t;b<r;)b=$t(b,f,E);let R=e>b?e:b,{days:p}=Ce(R,r,u);if(l>=e){const{days:L}=Ce(R,r,u?4:0);p=L}r<R&&(p=-p);let V=$e(b,t,a,u),S=p/V,D=b,w=e;for(;D>e;){w=D,D=$t(D,-f,E),R=e>D?e:D;const{days:L}=Ce(R,w,u);if(u===0)w>=R||e<=D?p=L:p=-L,V=$e(D,w,a,u);else if(p=w<R?-L:L,u===3)V=365/a;else{const{days:T}=Ce(D,w,u);V=w<D?-T:T}S+=e<=D?c?1:0:p/V}const P=s*n/a*S;return y.create(P)}}class Bg extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=H(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>Math.floor(b))return g.create(h.NUM);if(Math.floor(E)===Math.floor(b))return y.create(0);const{days:S,yearDays:D}=Ce(E,b,V),w=p*R*S/D;return y.create(w)}}class Ig extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){const c=u!=null?u:y.create(0),{isError:l,errorObject:f,variants:m}=H(e,t,r,n,s,a,c);if(l)return f;const[d,C,_,E,b,R,p]=m,V=F(C);if(typeof V!="number")return V;const S=F(_);if(typeof S!="number")return S;const D=+d.getValue(),w=+E.getValue();let P=+b.getValue();const L=+R.getValue(),T=Math.floor(+p.getValue());return Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(T)?g.create(h.VALUE):D<=0||w<0||D<w||Math.floor(V)>Math.floor(S)||P<0||L<=0||![0,1,3,4].includes(T)?g.create(h.NUM):(P>1?P=Math.floor(P):P=Math.ceil(P),this._getResult(D,V,S,w,P,L,T))}_getResult(e,t,r,n,s,a,u){const c=e-n,l=e*a,{days:f,yearDays:m}=Ce(t,r,u),d=f/m,C=Math.ceil(c/l-d);if(C<0)return y.create(0);let _=l;return s===0?_=l*d:s===C?_=c-l*(d+s-1):s>C&&(_=0),y.create(_)}}class Fg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);const R=$n(C,_,E,b);return y.create(R)}}class kg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);const R=$e(C,_,E,b);return y.create(R)}}class $g extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);const R=re(C),p=re(_);for(p.setUTCFullYear(R.getUTCFullYear()),p<R&&p.setUTCFullYear(p.getUTCFullYear()+1);p>R;)p.setUTCMonth(p.getUTCMonth()-12/E);p.setUTCMonth(p.getUTCMonth()+12/E);const V=Ee(p),{days:S}=Ce(C,V,b);return y.create(S)}}class Yg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);const R=Jo(C,_,E);return y.create(R)}}class Hg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_)||wt(C,_,E)<0)return g.create(h.NUM);const p=Wt(C,_,E);return y.create(p)}}class Gg extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=H(e,t,r,s);if(a)return u;const[l,f,m,d]=c,C=F(l);if(typeof C!="number")return C;const _=F(f);if(typeof _!="number")return _;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(C)>=Math.floor(_))return g.create(h.NUM);let R=wt(C,_,E);return R<0&&(R=0),y.create(R)}}class Wg extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=H(e,t,r,n,s,a);if(u)return c;const[f,m,d,C,_,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+C.getValue(),S=+_.getValue(),D=+E.getValue();return Number.isNaN(b)||Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D)?g.create(h.VALUE):b<=0||R<=0||p<=0||V<1||S<1||V>S||V>R||S>R||![0,1].includes(D)?g.create(h.NUM):Math.trunc(V)!==V&&Math.trunc(S)!==S&&Math.trunc(V)===Math.trunc(S)?y.create(0):this._getResult(b,R,p,V,S,D)}_getResult(e,t,r,n,s,a){const u=jr(e,t,r,0,a);let c=0,l=Math.ceil(n);l===1&&(a===0&&(c=-r),l++);let f=!1;for(let m=l;m<=s;m++){const d=a===1?Qt(e,m-2,u,r,1):Qt(e,m-1,u,r,0);if(d===0){f=!0;break}c+=a===1?d-u:d}return c*=e,(c<u*(s-n+1)||f)&&(c=u*(s-n+1)),y.create(c)}}class Qg extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=H(e,t,r,n,s,a);if(u)return c;const[f,m,d,C,_,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+C.getValue(),S=+_.getValue(),D=+E.getValue();return Number.isNaN(b)||Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D)?g.create(h.VALUE):b<=0||R<=0||p<=0||V<1||S<1||V>S||![0,1].includes(D)?g.create(h.NUM):Math.trunc(V)!==V&&Math.trunc(S)!==S&&Math.trunc(V)===Math.trunc(S)?y.create(0):this._getResult(b,R,p,V,S,D)}_getResult(e,t,r,n,s,a){const u=jr(e,t,r,0,a);let c=0,l=Math.ceil(n);l===1&&(c=a===0?u+r*e:u,l++);for(let f=l;f<=s;f++)c+=a===1?u-(Qt(e,f-2,u,r,1)-u)*e:u-Qt(e,f-1,u,r,0)*e;return y.create(c)}}class qg extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(12);a.isNull()&&(a=y.create(12));const u=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,a.isArray()?a.getRowCount():1),c=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,a.isArray()?a.getColumnCount():1),l=O(u,c,e,g.create(h.NA)),f=O(u,c,t,g.create(h.NA)),m=O(u,c,r,g.create(h.NA)),d=O(u,c,n,g.create(h.NA)),C=O(u,c,a,g.create(h.NA)),_=l.map((E,b,R)=>{const p=f.get(b,R),V=m.get(b,R),S=d.get(b,R),D=C.get(b,R),{isError:w,errorObject:P,variants:L}=I(E,p,V,S,D);if(w)return P;const[T,B,W,q,ie]=L,Z=+T.getValue(),G=+B.getValue(),ce=+W.getValue();let ge=+q.getValue();const Ae=Math.floor(+ie.getValue());return Z<0||G<0||ce<=0||ge<=0||Math.floor(ge)>Math.floor(ce)||Ae<1||Ae>12?g.create(h.NUM):(ge<1&&(ge=1),ge=Math.floor(ge),this._getResult(Z,G,ce,ge,Ae,b,R))});return u===1&&c===1?_.get(0,0):_}_getResult(e,t,r,n,s,a,u){const c=+(1-(t/e)**(1/r)).toFixed(3),l=e*c*s/12;let f=l,m=0;const d=n===r?r-1:n;for(let _=2;_<=d;_++)m=(e-f)*c,f+=m;let C;return n===1?C=l:n===r?C=(e-f)*c:C=m,Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):a===0&&u===0?y.create(C,Ye(this.getLocale())):y.create(C)}}class Xg extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(2);a.isNull()&&(a=y.create(2));const u=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,a.isArray()?a.getRowCount():1),c=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,a.isArray()?a.getColumnCount():1),l=O(u,c,e,g.create(h.NA)),f=O(u,c,t,g.create(h.NA)),m=O(u,c,r,g.create(h.NA)),d=O(u,c,n,g.create(h.NA)),C=O(u,c,a,g.create(h.NA)),_=l.map((E,b,R)=>{const p=f.get(b,R),V=m.get(b,R),S=d.get(b,R),D=C.get(b,R),{isError:w,errorObject:P,variants:L}=I(E,p,V,S,D);if(w)return P;const[T,B,W,q,ie]=L,Z=+T.getValue(),G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue();if(Z<0||G<0||ce<=0||ge<=0||ge>ce||Ae<=0)return g.create(h.NUM);const be=ys(Z,G,ce,ge,Ae);return Number.isNaN(be)||!Number.isFinite(be)?g.create(h.NUM):b===0&&R===0?y.create(be,Ye(this.getLocale())):y.create(be)});return u===1&&c===1?_.get(0,0):_}}class Kg extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=H(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>=Math.floor(b))return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=(p-R)/p*(D/S);return y.create(w)}}class Zg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);if(l>=0&&l<1)return g.create(h.DIV_BY_ZERO);l=Number.parseInt(`${l}`,10);let f=Number.parseInt(`${c}`,10);f+=c%1*10**Math.ceil(Math.log(l)/Math.LN10)/l;const m=10**(Math.ceil(Math.log(l)/Math.LN2)+1);return f=Math.round(f*m)/m,y.create(f)}}class zg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);if(l>=0&&l<1)return g.create(h.DIV_BY_ZERO);l=Number.parseInt(`${l}`,10);let f=Number.parseInt(`${c}`,10);return f+=c%1*10**-Math.ceil(Math.log(l)/Math.LN10)*l,y.create(f)}}class Jg extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,C,_,E,b]=f,R=F(m);if(typeof R!="number")return R;const p=F(d);if(typeof p!="number")return p;const V=+C.getValue(),S=+_.getValue(),D=Math.floor(+E.getValue()),w=Math.floor(+b.getValue());if(Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);if(V<0||S<0||![1,2,4].includes(D)||w<0||w>4||Math.floor(R)>=Math.floor(p)||R<=0||p<=366)return g.create(h.NUM);const P=eu(R,p,V,S,D,w);return y.create(P)}}class e1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(c<=0||l<1)return g.create(h.NUM);l=Number.parseInt(`${l}`,10);const f=(1+c/l)**l-1;return y.create(f)}}class t1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p),{isError:P,errorObject:L,variants:T}=I(b,V,S,D,w);if(P)return L;const[B,W,q,ie,Z]=T,G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue(),be=+Z.getValue(),he=Qt(G,ce,ge,Ae,be?1:0);return Number.isNaN(he)||!Number.isFinite(he)?g.create(h.NUM):R===0&&p===0?y.create(he,Ye(this.getLocale())):y.create(he)});return c===1&&l===1?E.get(0,0):E}}class r1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e);if(r)return n;const[a]=s,u=+a.getValue();if(Number.isNaN(u))return g.create(h.VALUE);let c=u;if(t.isArray()){const l=t.getArrayValue().flat();for(let f=0;f<l.length;f++){const m=l[f];if(m.isBoolean())return g.create(h.VALUE);const d=+m.getValue();if(Number.isNaN(d))return g.create(h.VALUE);c*=1+d}}else{if(t.isBoolean())return g.create(h.VALUE);const l=+t.getValue();if(Number.isNaN(l))return g.create(h.VALUE);c*=1+l}return y.create(c)}}class n1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=H(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>=Math.floor(b))return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=(p-R)/R*(D/S);return y.create(w)}}class s1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a){const u=s!=null?s:y.create(0),c=a!=null?a:y.create(0),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),C=O(l,f,r,g.create(h.NA)),_=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.map((p,V,S)=>{const D=d.get(V,S),w=C.get(V,S),P=_.get(V,S),L=E.get(V,S),T=b.get(V,S),{isError:B,errorObject:W,variants:q}=I(p,D,w,P,L,T);if(B)return W;const[ie,Z,G,ce,ge,Ae]=q,be=+ie.getValue(),he=+Z.getValue(),Ue=+G.getValue(),dt=+ce.getValue(),Xt=+ge.getValue(),Ct=+Ae.getValue();if(he<1||Math.floor(he)>Math.ceil(Ue))return g.create(h.NUM);const Ke=tu(be,he,Ue,dt,Xt,Ct?1:0);return Number.isNaN(Ke)||!Number.isFinite(Ke)?g.create(h.NUM):V===0&&S===0?y.create(Ke,Ye(this.getLocale())):y.create(Ke)});return l===1&&f===1?R.get(0,0):R}}class a1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r=t!=null?t:y.create(.1);return r.isNull()&&(r=y.create(.1)),r.isArray()?r.map((n,s,a)=>this._handleSingleObject(e,n,s,a)):this._handleSingleObject(e,r)}_handleSingleObject(e,t,r=0,n=0){if(e.isError())return e;if(t.isError())return t;if(e.isNull())return g.create(h.VALUE);if(!e.isArray())return g.create(h.NUM);const{_values:s,valuesHasError:a}=this._getValues(e);if(a)return g.create(h.VALUE);let u=t;if(u.isString()&&(u=u.convertToNumberObjectValue(),u.isError()))return u;const c=+u.getValue(),{positive:l,negative:f}=this._checkValues(s);if(!l||!f)return g.create(h.NUM);const m=na(c,d=>ru(d,s));return typeof m!="number"?m:r===0&&n===0?y.create(m,"0%"):y.create(m)}_getValues(e){const t=[];let r=!1;return e.iterator(n=>{const s=n;if(s.isError())return r=!0,!1;if(s.isNull()||s.isBoolean())return!0;const a=+s.getValue();if(Number.isNaN(a))return!0;t.push(a)}),{_values:t,valuesHasError:r}}_checkValues(e){let t=!1,r=!1;for(let n=0;n<e.length;n++)e[n]>0&&(t=!0),e[n]<0&&(r=!0);return{positive:t,negative:r}}}class i1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.map((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_),{isError:p,errorObject:V,variants:S}=I(d,E,b,R);if(p)return V;const[D,w,P,L]=S,T=+D.getValue(),B=+w.getValue(),W=+P.getValue(),q=+L.getValue();if(W===0)return g.create(h.DIV_BY_ZERO);const ie=q*T*(B/W-1);return y.create(ie)});return s===1&&a===1?m.get(0,0):m}}class o1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,C,_,E,b]=f,R=F(m);if(typeof R!="number")return R;const p=F(d);if(typeof p!="number")return p;const V=+C.getValue(),S=+_.getValue(),D=Math.floor(+E.getValue()),w=Math.floor(+b.getValue());if(Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);if(V<0||S<0||![1,2,4].includes(D)||w<0||w>4||Math.floor(R)>=Math.floor(p))return g.create(h.NUM);let P=eu(R,p,V,S,D,w);return P/=1+S/D,y.create(P)}}class u1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{_values:n,numberValues:s,positive:a,negative:u}=this._getValues(e),c=Math.max(t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),l=Math.max(t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),f=O(c,l,t,g.create(h.NA)),m=O(c,l,r,g.create(h.NA)),d=f.map((C,_,E)=>{const b=m.get(_,E);if(e.isError())return e;if(b.isError())return b;if(n.isError())return n;if(!a||!u)return g.create(h.DIV_BY_ZERO);const R=+C.getValue(),p=+b.getValue();if(Number.isNaN(R)||Number.isNaN(p))return g.create(h.VALUE);if(p===-1)return g.create(h.DIV_BY_ZERO);const V=this._getResult(s,R,p);return _===0&&E===0?y.create(V,"0%"):y.create(V)});return c===1&&l===1?d.get(0,0):d}_getValues(e){let t=e,r=[],n=!1,s=!1;if(!e.isError())if(e.isNull())t=g.create(h.VALUE);else if(!e.isArray())t=g.create(h.DIV_BY_ZERO);else{const{numberValues:a,valuesHasError:u,errorObject:c,positive:l,negative:f}=this._checkValues(e);u&&(t=c),r=a,n=l,s=f}return{_values:t,numberValues:r,positive:n,negative:s}}_checkValues(e){const t=[];let r=!1,n=g.create(h.VALUE),s=!1,a=!1;return e.iterator(u=>{const c=u;if(c.isError())return r=!0,n=c,!1;if(c.isNull()||c.isBoolean())return!0;const l=+c.getValue();if(Number.isNaN(l))return!0;l>0&&(s=!0),l<0&&(a=!0),t.push(l)}),{numberValues:t,valuesHasError:r,errorObject:n,positive:s,negative:a}}_getResult(e,t,r){const n=e.length,s=[],a=[];for(let d=0;d<n;d++)e[d]>0?a.push(e[d]):e[d]<0&&s.push(e[d]);const u=this._npv(r,e,"positive"),c=this._npv(t,e,"negative"),l=-u*(1+r)**n,f=c*(1+t);return(l/f)**(1/(n-1))-1}_npv(e,t,r){let n=0;for(let s=1;s<=t.length;s++){const a=t[s-1];(r==="positive"&&a>0||r==="negative"&&a<0)&&(n+=a/(1+e)**s)}return n}}class c1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(c<=0||l<1)return g.create(h.NUM);l=Number.parseInt(`${l}`,10);const f=((c+1)**(1/l)-1)*l;return y.create(f)}}class l1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p),{isError:P,errorObject:L,variants:T}=I(b,V,S,D,w);if(P)return L;const[B,W,q,ie,Z]=T,G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue();let be=+Z.getValue();if(be=be?1:0,G===0&&ce===0)return g.create(h.DIV_BY_ZERO);let he;if(G===0)he=-(ge+Ae)/ce;else{const Ue=ce*(1+G*be)-Ae*G,dt=ge*G+ce*(1+G*be);he=Math.log(Ue/dt)/Math.log(1+G)}return Number.isNaN(he)||!Number.isFinite(he)?g.create(h.NUM):y.create(he)});return c===1&&l===1?E.get(0,0):E}}class f1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsLocale",!0)}calculate(e,...t){if(e.isError())return e;const{isError:r,errorObject:n,values:s}=this._getValues(t);return e.isArray()?e.map((a,u,c)=>this._handleSingleObject(a,r,n,s,u,c)):this._handleSingleObject(e,r,n,s)}_handleSingleObject(e,t,r,n,s=0,a=0){let u=e;if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(t)return r;const c=+e.getValue(),l=ru(c,n);return Number.isNaN(l)||Math.abs(l)===1/0?g.create(h.DIV_BY_ZERO):s===0&&a===0?y.create(l,Ye(this.getLocale())):y.create(l)}_getValues(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isError())return{isError:!0,errorObject:n};if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{const c=u;if(c.isError())return s=!0,a=c,!1;if(c.isNull()||c.isBoolean())return!0;const l=+c.getValue();if(Number.isNaN(l))return!0;t.push(l)}),s)return{isError:s,errorObject:a}}else{const s=+n.getValue();if(Number.isNaN(s))return{isError:!0,errorObject:g.create(h.VALUE)};t.push(s)}}return{isError:!1,values:t}}}class m1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c,l){let f=l!=null?l:y.create(0);f.isNull()&&(f=y.create(0));const{isError:m,errorObject:d,variants:C}=je(e,t,r,n,s,a,u,c,f);if(m)return d;const[_,E,b,R,p,V,S,D,w]=C,P=F(_);if(typeof P!="number")return P;const L=F(E);if(typeof L!="number")return L;const T=F(b);if(typeof T!="number")return T;const B=F(R);if(typeof B!="number")return B;const W=+p.getValue(),q=+V.getValue(),ie=+S.getValue(),Z=Math.floor(+D.getValue()),G=Math.floor(+w.getValue());if(Number.isNaN(W)||Number.isNaN(q)||Number.isNaN(ie)||Number.isNaN(Z)||Number.isNaN(G))return g.create(h.VALUE);if(W<0||q<0||ie<=0||![1,2,4].includes(Z)||G<0||G>4||!this._validDate(L,B,P,T,Z))return g.create(h.NUM);const ce=nu(P,L,T,B,W,q,ie,Z,G);return y.create(ce)}_validDate(e,t,r,n,s){return this._getDateCorrectOrder(e,t,r,n)&&su(e,t,s)&&gr(n,e,s)}_getDateCorrectOrder(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&Math.floor(r)>Math.floor(n)}}class h1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c,l){let f=l!=null?l:y.create(0);f.isNull()&&(f=y.create(0));const{isError:m,errorObject:d,variants:C}=je(e,t,r,n,s,a,u,c,f);if(m)return d;const[_,E,b,R,p,V,S,D,w]=C,P=F(_);if(typeof P!="number")return P;const L=F(E);if(typeof L!="number")return L;const T=F(b);if(typeof T!="number")return T;const B=F(R);if(typeof B!="number")return B;const W=+p.getValue(),q=+V.getValue(),ie=+S.getValue(),Z=Math.floor(+D.getValue()),G=Math.floor(+w.getValue());return Number.isNaN(W)||Number.isNaN(q)||Number.isNaN(ie)||Number.isNaN(Z)||Number.isNaN(G)?g.create(h.VALUE):W<0||q<=0||ie<=0||![1,2,4].includes(Z)||G<0||G>4||!this._validDate(L,B,P,T,Z)?g.create(h.NUM):this._getResult(P,L,T,B,W,q,ie,Z,G)}_validDate(e,t,r,n,s){return this._getDateCorrectOrder(e,t,r,n)&&su(e,t,s)&&gr(n,e,s)}_getDateCorrectOrder(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&Math.floor(r)>Math.floor(n)}_getResult(e,t,r,n,s,a,u,c,l){const{days:f}=Ce(e,t,l),m=(s*f*100-(a-100))/((a-100)*.25*(1+2*f)+f*100);function d(_){return a-nu(e,t,r,n,s,_,u,c,l)}const C=na(m,_=>d(_));return typeof C!="number"?C:y.create(C)}}class g1 extends N{constructor(){super(...arguments);A(this,"minParams",7);A(this,"maxParams",8)}calculate(e,t,r,n,s,a,u,c){let l=c!=null?c:y.create(0);l.isNull()&&(l=y.create(0));const{isError:f,errorObject:m,variants:d}=je(e,t,r,n,s,a,u,l);if(f)return m;const[C,_,E,b,R,p,V,S]=d,D=F(C);if(typeof D!="number")return D;const w=F(_);if(typeof w!="number")return w;const P=F(E);if(typeof P!="number")return P;const L=+b.getValue(),T=+R.getValue(),B=+p.getValue(),W=Math.floor(+V.getValue()),q=Math.floor(+S.getValue());if(Number.isNaN(L)||Number.isNaN(T)||Number.isNaN(B)||Number.isNaN(W)||Number.isNaN(q))return g.create(h.VALUE);if(L<0||T<0||B<=0||![1,2,4].includes(W)||q<0||q>4||!this._validDate(w,D,P,W))return g.create(h.NUM);const ie=this._getResult(D,w,P,L,T,B,W,q);return y.create(ie)}_validDate(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&gr(r,e,n)}_getResult(e,t,r,n,s,a,u,c){const l=this._getCoupDate(t,r,u),f=this._getFrac(r,e,l,u,c),m=this._getFrac(r,t,l,u,c),d=this._getFrac(e,t,l,u,c);return(a*u+100*n*(m-f*(1+s*d/u)))/(s*d+u)}_getCoupDate(e,t,r){const n=re(e),s=re(t);for(s.setUTCFullYear(n.getUTCFullYear()),s>n&&s.setUTCFullYear(s.getUTCFullYear()-1);s<n;)s.setUTCMonth(s.getUTCMonth()+12/r);return Ee(s)}_getFrac(e,t,r,n,s){const a=re(e),u=re(t),c=re(r);for(c.setUTCFullYear(a.getUTCFullYear()),c<a&&c.setUTCFullYear(c.getUTCFullYear()+1);c>a;)c.setUTCMonth(c.getUTCMonth()-12/n);let l=Ee(c);c.setUTCMonth(c.getUTCMonth()+12/n);let f=Ee(c);if(f>=t){const{days:p}=Ce(e,t,s),V=$e(l,f,n,s);return p/V}const{days:m}=Ce(e,f,s),d=$e(l,f,n,s);let C=m/d;const _=re(f),E=re(f);for(E.setUTCMonth(E.getUTCMonth()+12/n);E<u;)_.setUTCMonth(_.getUTCMonth()+12/n),E.setUTCMonth(E.getUTCMonth()+12/n),C+=1;l=Ee(_),f=Ee(E);const{days:b}=Ce(l,t,s),R=$e(l,f,n,s);return C+=b/R,C}}class d1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c){let l=c!=null?c:y.create(0);l.isNull()&&(l=y.create(0));const{isError:f,errorObject:m,variants:d}=je(e,t,r,n,s,a,u,l);if(f)return m;const[C,_,E,b,R,p,V,S]=d,D=F(C);if(typeof D!="number")return D;const w=F(_);if(typeof w!="number")return w;const P=F(E);if(typeof P!="number")return P;const L=+b.getValue(),T=+R.getValue(),B=+p.getValue(),W=Math.floor(+V.getValue()),q=Math.floor(+S.getValue());if(Number.isNaN(L)||Number.isNaN(T)||Number.isNaN(B)||Number.isNaN(W)||Number.isNaN(q))return g.create(h.VALUE);if(L<0||T<=0||B<=0||![1,2,4].includes(W)||q<0||q>4||!this._validDate(w,D,P,W))return g.create(h.NUM);const ie=this._getResult(D,w,P,L,T,B,W,q);return y.create(ie)}_validDate(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&gr(r,e,n)}_getResult(e,t,r,n,s,a,u,c){const l=this._getCoupDate(t,r,u),f=this._getFrac(r,e,l,u,c),m=this._getFrac(r,t,l,u,c),d=this._getFrac(e,t,l,u,c);return(u*(a-s)+100*n*(m-f))/(d*s+100*n*f*d/u)}_getCoupDate(e,t,r){const n=re(e),s=re(t);for(s.setUTCFullYear(n.getUTCFullYear()),s>n&&s.setUTCFullYear(s.getUTCFullYear()-1);s<n;)s.setUTCMonth(s.getUTCMonth()+12/r);return Ee(s)}_getFrac(e,t,r,n,s){const a=re(e),u=re(t),c=re(r);for(c.setUTCFullYear(a.getUTCFullYear()),c<a&&c.setUTCFullYear(c.getUTCFullYear()+1);c>a;)c.setUTCMonth(c.getUTCMonth()-12/n);let l=Ee(c);c.setUTCMonth(c.getUTCMonth()+12/n);let f=Ee(c);if(f>=t){const{days:p}=Ce(e,t,s),V=$e(l,f,n,s);return p/V}const{days:m}=Ce(e,f,s),d=$e(l,f,n,s);let C=m/d;const _=re(f),E=re(f);for(E.setUTCMonth(E.getUTCMonth()+12/n);E<u;)_.setUTCMonth(_.getUTCMonth()+12/n),E.setUTCMonth(E.getUTCMonth()+12/n),C+=1;l=Ee(_),f=Ee(E);const{days:b}=Ce(l,t,s),R=$e(l,f,n,s);return C+=b/R,C}}class C1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d),{isError:E,errorObject:b,variants:R}=I(f,C,_);if(E)return b;const[p,V,S]=R,D=+p.getValue(),w=+V.getValue(),P=+S.getValue();if(D<=-1)return g.create(h.NUM);const L=(Math.log(P)-Math.log(w))/Math.log(1+D);return Number.isNaN(L)||!Number.isFinite(L)?g.create(h.NUM):y.create(L)});return n===1&&s===1?l.get(0,0):l}}class _1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p),{isError:P,errorObject:L,variants:T}=I(b,V,S,D,w);if(P)return L;const[B,W,q,ie,Z]=T,G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue(),be=+Z.getValue();if(G<=-1)return g.create(h.NUM);const he=jr(G,ce,ge,Ae,be?1:0);return Number.isNaN(he)||!Number.isFinite(he)?g.create(h.NUM):R===0&&p===0?y.create(he,Ye(this.getLocale())):y.create(he)});return c===1&&l===1?E.get(0,0):E}}class A1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a){const u=s!=null?s:y.create(0),c=a!=null?a:y.create(0),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),C=O(l,f,r,g.create(h.NA)),_=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.map((p,V,S)=>{const D=d.get(V,S),w=C.get(V,S),P=_.get(V,S),L=E.get(V,S),T=b.get(V,S),{isError:B,errorObject:W,variants:q}=I(p,D,w,P,L,T);if(B)return W;const[ie,Z,G,ce,ge,Ae]=q,be=+ie.getValue(),he=+Z.getValue(),Ue=+G.getValue(),dt=+ce.getValue(),Xt=+ge.getValue(),Ct=+Ae.getValue();if(he<1||Math.floor(he)>Math.ceil(Ue)||he-Ue>=1)return g.create(h.NUM);const Ke=jr(be,Ue,dt,Xt,Ct?1:0)-tu(be,he,Ue,dt,Xt,Ct?1:0);return Number.isNaN(Ke)||!Number.isFinite(Ke)?g.create(h.NUM):V===0&&S===0?y.create(Ke,Ye(this.getLocale())):y.create(Ke)});return l===1&&f===1?R.get(0,0):R}}class E1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){let c=u!=null?u:y.create(0);c.isNull()&&(c=y.create(0));const{isError:l,errorObject:f,variants:m}=je(e,t,r,n,s,a,c);if(l)return f;const[d,C,_,E,b,R,p]=m,V=F(d);if(typeof V!="number")return V;const S=F(C);if(typeof S!="number")return S;const D=+_.getValue(),w=+E.getValue(),P=+b.getValue(),L=Math.floor(+R.getValue()),T=Math.floor(+p.getValue());if(Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(T))return g.create(h.VALUE);if(D<0||w<0||P<=0||![1,2,4].includes(L)||T<0||T>4||V>=S||!gr(V,S,L))return g.create(h.NUM);const B=qr(V,S,D,w,P,L,T);return y.create(B)}}class b1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=p-R*p*S/D;return y.create(w)}}class y1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,C,_,E,b]=f,R=F(m);if(typeof R!="number")return R;const p=F(d);if(typeof p!="number")return p;const V=F(C);if(typeof V!="number")return V;const S=+_.getValue(),D=+E.getValue(),w=Math.floor(+b.getValue());if(Number.isNaN(S)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);const P=this._getDateCorrectOrder(p,R,V);if(S<0||D<0||w<0||w>4||!P)return g.create(h.NUM);const L=Ko(R,w),{days:T}=Ce(R,p,w),{days:B}=Ce(V,p,w),{days:W}=Ce(V,R,w),q=(100+B/L*S*100)/(1+T/L*D)-W/L*S*100;return y.create(q)}_getDateCorrectOrder(e,t,r){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)}}class R1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),C=O(c,l,a,g.create(h.NA)),_=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),S=d.get(R,p),D=C.get(R,p),w=_.get(R,p),{isError:P,errorObject:L,variants:T}=I(b,V,S,D,w);if(P)return L;const[B,W,q,ie,Z]=T,G=+B.getValue(),ce=+W.getValue(),ge=+q.getValue(),Ae=+ie.getValue();let be=+Z.getValue();be=be?1:0;const he=G===0?-ge*ce-Ae:((1-(1+G)**ce)/G*ge*(1+G*be)-Ae)/(1+G)**ce;return Number.isNaN(he)||!Number.isFinite(he)?g.create(h.NUM):R===0&&p===0?y.create(he,Ye(this.getLocale())):y.create(he)});return c===1&&l===1?E.get(0,0):E}}class p1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const u=n!=null?n:y.create(0),c=s!=null?s:y.create(0),l=a!=null?a:y.create(.1),f=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,e,g.create(h.NA)),C=O(f,m,t,g.create(h.NA)),_=O(f,m,r,g.create(h.NA)),E=O(f,m,u,g.create(h.NA)),b=O(f,m,c,g.create(h.NA)),R=O(f,m,l,g.create(h.NA)),p=d.map((V,S,D)=>{const w=C.get(S,D),P=_.get(S,D),L=E.get(S,D),T=b.get(S,D),B=R.get(S,D),{isError:W,errorObject:q,variants:ie}=I(V,w,P,L,T,B);if(W)return q;const[Z,G,ce,ge,Ae,be]=ie,he=+Z.getValue(),Ue=+G.getValue(),dt=+ce.getValue(),Xt=+ge.getValue();let Ct=+Ae.getValue();const Ke=+be.getValue();return Ct=Ct?1:0,he<=0||Ue>=0?g.create(h.NUM):this._getResult(he,Ue,dt,Xt,Ct,Ke,S,D)});return f===1&&m===1?p.get(0,0):p}_getResult(e,t,r,n,s,a,u,c){let m=a;for(let d=0;d<20;d++){if(m<=-1)return g.create(h.NUM);let C,_;if(Math.abs(m)<1e-10?C=r*(1+e*m)+t*(1+m*s)*e+n:(_=(1+m)**e,C=r*_+t*(1/m+s)*(_-1)+n),Math.abs(C)<1e-10)break;let E;if(Math.abs(m)<1e-10)E=r*e+t*s*e;else{_=(1+m)**e;const b=e*(1+m)**(e-1);E=r*b+t*(1/m+s)*b+t*(-1/(m*m))*(_-1)}m-=C/E}return u===0&&c===0?y.create(m,"0%"):y.create(m)}}class N1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=R/(1-p*S/D);return w<0?g.create(h.NUM):y.create(w)}}class V1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d),{isError:E,errorObject:b,variants:R}=I(f,C,_);if(E)return b;const[p,V,S]=R,D=+p.getValue(),w=+V.getValue(),P=+S.getValue();if(D<=0)return g.create(h.NUM);if(w===0&&P===0)return y.create(0);const L=(P/w)**(1/D)-1;return Number.isNaN(L)||!Number.isFinite(L)||P/w<0?g.create(h.NUM):y.create(L)});return n===1&&s===1?l.get(0,0):l}}class O1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsLocale",!0)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);if(C.isError())return C;if(_.isError())return _;const E=+f.getValue(),b=+C.getValue(),R=+_.getValue();if(Number.isNaN(E)||Number.isNaN(b)||Number.isNaN(R))return g.create(h.VALUE);if(R===0)return g.create(h.DIV_BY_ZERO);const p=(E-b)/R;return m===0&&d===0?y.create(p,Ye(this.getLocale())):y.create(p)});return n===1&&s===1?l.get(0,0):l}}class M1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4);A(this,"needsLocale",!0)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.map((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);if(E.isError())return E;if(b.isError())return b;if(R.isError())return R;const p=+d.getValue(),V=+E.getValue(),S=+b.getValue(),D=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(S)||Number.isNaN(D))return g.create(h.VALUE);if(V<0||S<=0||D>S)return g.create(h.NUM);const w=(p-V)*(S-D+1)*2/(S*(S+1));return C===0&&_===0?y.create(w,Ye(this.getLocale())):y.create(w)});return s===1&&a===1?m.get(0,0):m}}class S1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=F(u);if(typeof f!="number")return f;const m=F(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const C=Math.floor(m)-Math.floor(f),E=re(f).getUTCFullYear(),b=kn(E);if(C>b)return g.create(h.NUM);let R=365*d/(360-d*C);if(C>182){const p=100*(1-d*C/360),V=C/365;if(R=(-V+Math.sqrt(V*V-(V*2-1)*(1-100/p)))/(V-.5),Number.isNaN(R))return g.create(h.NUM)}return R<0?g.create(h.NUM):y.create(R)}}class D1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsLocale",!0)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=F(u);if(typeof f!="number")return f;const m=F(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const C=Math.floor(m)-Math.floor(f),E=re(f).getUTCFullYear(),b=kn(E);if(C>b)return g.create(h.NUM);const R=100*(1-d*C/360);return R<0?g.create(h.NUM):y.create(R,Ye(this.getLocale()))}}class w1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=F(u);if(typeof f!="number")return f;const m=F(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const C=Math.floor(m)-Math.floor(f),E=re(f).getUTCFullYear(),b=kn(E);if(C>b)return g.create(h.NUM);const R=(100-d)/d*360/C;return y.create(R)}}class P1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",7);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a,u){let c=a!=null?a:y.create(2);c.isNull()&&(c=y.create(2));let l=u!=null?u:k.create(!1);l.isNull()&&(l=k.create(!1));const f=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,e,g.create(h.NA)),C=O(f,m,t,g.create(h.NA)),_=O(f,m,r,g.create(h.NA)),E=O(f,m,n,g.create(h.NA)),b=O(f,m,s,g.create(h.NA)),R=O(f,m,c,g.create(h.NA)),p=O(f,m,l,g.create(h.NA));return this._getResultArray(d,C,_,E,b,R,p,f,m)}_getResultArray(e,t,r,n,s,a,u,c,l){const f=e.map((m,d,C)=>{const _=t.get(d,C),E=r.get(d,C),b=n.get(d,C),R=s.get(d,C),p=a.get(d,C),V=u.get(d,C),{isError:S,errorObject:D,variants:w}=I(m,_,E,b,R,p,V);if(S)return D;const[P,L,T,B,W,q,ie]=w,Z=+P.getValue(),G=+L.getValue(),ce=+T.getValue(),ge=+B.getValue(),Ae=+W.getValue(),be=+q.getValue(),he=+ie.getValue();if(Z<0||G<0||ce<0||ge<0||Ae<0||Ae>ce||ge>Ae||be<0)return g.create(h.NUM);if(ce===0&&ge===0&&Ae===0)return g.create(h.DIV_BY_ZERO);const Ue=this._getResult(Z,G,ce,ge,Ae,be,he);return d===0&&C===0?y.create(Ue,Ye(this.getLocale())):y.create(Ue)});return c===1&&l===1?f.get(0,0):f}_getResult(e,t,r,n,s,a,u){const c=Math.floor(n),l=Math.ceil(s);let f=0;if(e<t){if(n>=1||u)return f;const m=Math.abs(e-t);return f=m*(s-n)>m?m:m*(s-n),-f}if(u)for(let m=c+1;m<=l;m++){let d=ys(e,t,r,m,a);m===c+1?d*=Math.min(s,c+1)-n:m===l&&(d*=s+1-l),f+=d}else{const m=e-this._getVdb(e,t,r,r,n,a);f=this._getVdb(m,t,r,r-n,s-n,a)}return f}_getVdb(e,t,r,n,s,a){const u=Math.ceil(s);let c=0,l=e-t,f=0,m=0,d=!1;for(let C=1;C<=u;C++){if(d)m=f;else{const _=ys(e,t,r,C,a);f=l/(n-(C-1)),f>_?(m=f,d=!0):(m=_,l-=_)}C===u&&(m*=s+1-u),c+=m}return c}}class L1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:n,errorObejct:s,_values:a,_dates:u}=this._checkErrors(e,t);if(n)return s;let c=r!=null?r:y.create(.1);c.isNull()&&(c=y.create(.1));const{isError:l,errorObject:f,variants:m}=H(c);if(l)return f;const[d]=m,C=+d.getValue();if(Number.isNaN(C))return g.create(h.VALUE);const{positive:_,negative:E}=this._checkValues(a);if(!_||!E||(a==null?void 0:a.length)!==(u==null?void 0:u.length)||C<0)return g.create(h.NUM);const b=na(C,R=>this._iterF(a,u,R));return typeof b!="number"?b:y.create(b)}_checkErrors(e,t){if(e.isError())return{isError:!0,errorObejct:e};if(t.isError())return{isError:!0,errorObejct:t};const{isError:r,errorObejct:n,_values:s}=this._checkErrorValues(e);if(r)return{isError:r,errorObejct:n};const{isError:a,errorObejct:u,_dates:c}=this._checkErrorDates(t);return a?{isError:a,errorObejct:u}:{isError:!1,_values:s,_dates:c}}_checkErrorValues(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;t.push(u)}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_values:t}}else{const r=e.getValue();return e.isBoolean()||e.isString()&&!M.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkErrorDates(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{if(s!=null&&s.isError())return r=!0,n=s,!1;if(s!=null&&s.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const a=+s.getValue();if(Number.isNaN(a))return r=!0,n=g.create(h.VALUE),!1;if(a<0)return r=!0,n=g.create(h.NUM),!1;t.push(Math.floor(a))}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_dates:t}}else{const r=e.getValue();return e.isBoolean()||e.isString()&&!M.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:+r<0?{isError:!0,errorObejct:g.create(h.NUM)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkValues(e){let t=!1,r=!1;for(let n=0;n<e.length;n++)e[n]>0&&(t=!0),e[n]<0&&(r=!0);return{positive:t,negative:r}}_iterF(e,t,r){return e.reduce((n,s,a)=>n+s/(1+r)**((t[a]-t[0])/365),0)}}class x1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isNull()||t.isNull()||r.isNull())return g.create(h.NA);const{isError:n,errorObject:s,variants:a}=H(e);if(n)return s;const[u]=a,c=+u.getValue();if(Number.isNaN(c))return g.create(h.VALUE);let{isError:l,errorObejct:f,_values:m,_dates:d}=this._checkErrors(t,r);if(l)return f;if(m=m,d=d,c<0||m.length!==d.length)return g.create(h.NUM);let C=0;const _=d[0];for(let E=0;E<d.length;E++){const b=d[E],R=m[E];C+=R/(1+c)**((b-_)/365)}return y.create(C)}_checkErrors(e,t){if(e.isError())return{isError:!0,errorObejct:e};if(t.isError())return{isError:!0,errorObejct:t};const{isError:r,errorObejct:n,_values:s}=this._checkErrorValues(e);if(r)return{isError:r,errorObejct:n};const{isError:a,errorObejct:u,_dates:c}=this._checkErrorDates(t);return a?{isError:a,errorObejct:u}:{isError:!1,_values:s,_dates:c}}_checkErrorValues(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isNull()||a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;t.push(u)}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_values:t}}else{const r=e.getValue();return e.isNull()||e.isBoolean()||e.isString()&&!M.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkErrorDates(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isNull()||a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;if(u<0)return r=!0,n=g.create(h.NUM),!1;t.push(Math.floor(u))}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_dates:t}}else{const r=e.getValue();return e.isNull()||e.isBoolean()||e.isString()&&!M.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:+r<0?{isError:!0,errorObejct:g.create(h.NUM)}:{isError:!0,errorObejct:g.create(h.NA)}}}}class j1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){let c=u!=null?u:y.create(0);c.isNull()&&(c=y.create(0));const{isError:l,errorObject:f,variants:m}=je(e,t,r,n,s,a,c);if(l)return f;const[d,C,_,E,b,R,p]=m,V=F(d);if(typeof V!="number")return V;const S=F(C);if(typeof S!="number")return S;const D=+_.getValue(),w=+E.getValue(),P=+b.getValue(),L=Math.floor(+R.getValue()),T=Math.floor(+p.getValue());if(Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(T))return g.create(h.VALUE);if(D<0||w<=0||P<=0||![1,2,4].includes(L)||T<0||T>4||V>=S||!gr(V,S,L))return g.create(h.NUM);const B=this._getResult(V,S,D,w,P,L,T);return y.create(B)}_getResult(e,t,r,n,s,a,u){if(Wt(e,t,a)>1){let E=r||.01,b=qr(e,t,r,E,s,a,u),R=b-n;for(let p=0;p<100&&Math.abs(R)>1e-7;p++)b=qr(e,t,r,1.01*E,s,a,u),E+=-R/(b-n-R)*E*.01,R=qr(e,t,r,E,s,a,u)-n;return E}const l=$n(e,t,a,u),f=$e(e,t,a,u),{days:m}=Ce(e,t,u),d=n/100+l/f*r/a;return(s/100+r/a-d)/d*a*f/m}}class U1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,C,_]=l,E=F(f);if(typeof E!="number")return E;const b=F(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+C.getValue(),V=Math.floor(+_.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:S,yearDays:D}=Ce(E,b,V),w=(p/R-1)/(S/D);return y.create(w)}}class v1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,C,_,E,b]=f,R=F(m);if(typeof R!="number")return R;const p=F(d);if(typeof p!="number")return p;const V=F(C);if(typeof V!="number")return V;const S=+_.getValue(),D=+E.getValue(),w=Math.floor(+b.getValue());if(Number.isNaN(S)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);const P=this._getDateCorrectOrder(p,R,V);if(S<0||D<=0||w<0||w>4||!P)return g.create(h.NUM);const L=Ko(R,w),{days:T}=Ce(R,p,w),{days:B}=Ce(V,p,w),{days:W}=Ce(V,R,w),q=((1+B/L*S)/(D/100+W/L*S)-1)/(T/L);return y.create(q)}_getDateCorrectOrder(e,t,r){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)}}const au=[[Tg,J.ACCRINT],[Bg,J.ACCRINTM],[Ig,J.AMORLINC],[Fg,J.COUPDAYBS],[kg,J.COUPDAYS],[$g,J.COUPDAYSNC],[Yg,J.COUPNCD],[Hg,J.COUPNUM],[Gg,J.COUPPCD],[Wg,J.CUMIPMT],[Qg,J.CUMPRINC],[qg,J.DB],[Xg,J.DDB],[Kg,J.DISC],[Zg,J.DOLLARDE],[zg,J.DOLLARFR],[Jg,J.DURATION],[e1,J.EFFECT],[t1,J.FV],[r1,J.FVSCHEDULE],[n1,J.INTRATE],[s1,J.IPMT],[a1,J.IRR],[i1,J.ISPMT],[o1,J.MDURATION],[u1,J.MIRR],[c1,J.NOMINAL],[l1,J.NPER],[f1,J.NPV],[m1,J.ODDFPRICE],[h1,J.ODDFYIELD],[g1,J.ODDLPRICE],[d1,J.ODDLYIELD],[C1,J.PDURATION],[_1,J.PMT],[A1,J.PPMT],[E1,J.PRICE],[b1,J.PRICEDISC],[y1,J.PRICEMAT],[R1,J.PV],[p1,J.RATE],[N1,J.RECEIVED],[V1,J.RRI],[O1,J.SLN],[M1,J.SYD],[S1,J.TBILLEQ],[D1,J.TBILLPRICE],[w1,J.TBILLYIELD],[P1,J.VDB],[L1,J.XIRR],[x1,J.XNPV],[j1,J.YIELD],[U1,J.YIELDDISC],[v1,J.YIELDMAT]];class T1 extends N{constructor(){super(...arguments);A(this,"needsReferenceObject",!0);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isError())return r;if(r.isReferenceObject()&&(r=r.toArrayValueObject()),r.isArray()){const n=r.getRowCount(),s=r.getColumnCount();if(n===1&&s===1){const a=r.get(0,0);return this._handleSingleObject(a,t)}return r.map(a=>a.isError()?a:this._handleSingleObject(a,t,!0))}return this._handleSingleObject(r,t)}_handleSingleObject(e,t,r=!1){let n=t;if(n.isError())return n;if(!n.isReferenceObject())return g.create(h.NA);const s=n.getCurrentActiveSheetData(),{columnData:a,defaultColumnWidth:u}=s;n=n.toArrayValueObject();const c=n.getCurrentRow(),l=n.getCurrentColumn();n=n.getFirstCell();const f=`${e.getValue()}`;let m;switch(f.toLocaleLowerCase()){case"address":return j.create(`$${M.Tools.chatAtABC(l)}$${c+1}`);case"col":return y.create(l+1);case"color":return y.create(0);case"contents":return n;case"filename":return g.create(h.VALUE);case"format":return j.create("G");case"parentheses":return y.create(0);case"prefix":return j.create("");case"protect":return y.create(1);case"row":return y.create(c+1);case"type":return m="v",n.isNull()&&(m="b"),n.isString()&&(m="l"),j.create(m);case"width":return this._getWidthResult(a,u,l,r);default:return g.create(h.VALUE)}}_getWidthResult(e,t,r,n){var u;let s=(u=e[r])==null?void 0:u.w;if(!s&&s!==0&&(s=t),n)return y.create(s);const a=[[s,s===t]];return K.createByArray(a)}}class B1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"_errorTypeValueMap",new Map([[h.NULL,1],[h.DIV_BY_ZERO,2],[h.VALUE,3],[h.REF,4],[h.NAME,5],[h.NUM,6],[h.NA,7],[h.CONNECT,8],[h.CALC,14]]))}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=e.getValue(),r=this._errorTypeValueMap.get(t);return r?y.create(r):g.create(h.NA)}}var Ne=(i=>(i.CELL="CELL",i.ERROR_TYPE="ERROR.TYPE",i.INFO="INFO",i.ISBLANK="ISBLANK",i.ISERR="ISERR",i.ISERROR="ISERROR",i.ISEVEN="ISEVEN",i.ISFORMULA="ISFORMULA",i.ISLOGICAL="ISLOGICAL",i.ISNA="ISNA",i.ISNONTEXT="ISNONTEXT",i.ISNUMBER="ISNUMBER",i.ISODD="ISODD",i.ISOMITTED="ISOMITTED",i.ISREF="ISREF",i.ISTEXT="ISTEXT",i.N="N",i.NA="NA",i.SHEET="SHEET",i.SHEETS="SHEETS",i.TYPE="TYPE",i))(Ne||{});class I1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isNull()?k.create(!0):e.isArray()?e.mapValue(t=>t.isNull()?k.create(!0):k.create(!1)):k.create(!1)}}class F1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.getValue()===h.NA?k.create(!1):e.isError()?k.create(!0):e.isArray()?e.mapValue(t=>t.getValue()===h.NA?k.create(!1):t.isError()?k.create(!0):k.create(!1)):k.create(!1)}}class k1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?k.create(!0):e.isArray()?e.mapValue(t=>t.isError()?k.create(!0):k.create(!1)):k.create(!1)}}class $1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isError())return t;if(t.isBoolean())return g.create(h.VALUE);const r=Math.trunc(+t.getValue());if(Number.isNaN(r))return g.create(h.VALUE);const n=r%2===0;return k.create(n)}}class Y1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){var u;if(e.isError())return e;if(!e.isReferenceObject())return g.create(h.NA);const t=(u=e.getCurrentActiveSheetData())==null?void 0:u.cellData.getMatrix(),{startRow:r,startColumn:n}=e.getRangePosition(),s=e.toArrayValueObject(),a=s.mapValue((c,l,f)=>{var d;const m=(d=t==null?void 0:t[r+l])==null?void 0:d[n+f];return m!=null&&m.f||m!=null&&m.si?k.create(!0):k.create(!1)});return s.getRowCount()===1&&s.getColumnCount()===1?a.get(0,0):a}}class H1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isBoolean()?k.create(!0):e.isArray()?e.mapValue(t=>t.isBoolean()?k.create(!0):k.create(!1)):k.create(!1)}}class G1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.getValue()===h.NA?k.create(!0):e.isArray()?e.mapValue(t=>t.getValue()===h.NA?k.create(!0):k.create(!1)):k.create(!1)}}class W1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return!e.isArray()&&!e.isString()?k.create(!0):e.isArray()?e.mapValue(t=>t.isString()?k.create(!1):k.create(!0)):k.create(!1)}}class Q1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isNumber()?k.create(!0):e.isArray()?e.mapValue(t=>t.isNumber()?k.create(!0):k.create(!1)):k.create(!1)}}class q1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isError())return t;if(t.isBoolean())return g.create(h.VALUE);const r=Math.trunc(+t.getValue());if(Number.isNaN(r))return g.create(h.VALUE);const n=r%2!==0;return k.create(n)}}class X1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){return e.isReferenceObject()?k.create(!0):k.create(!1)}}class K1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isString()?k.create(!0):e.isArray()?e.mapValue(t=>t.isString()?k.create(!0):k.create(!1)):k.create(!1)}}class Z1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(e.isArray()&&(t=e.get(0,0)),t.isError())return t;if(t.isString())return y.create(0);const r=+t.getValue();return y.create(r)}}class z1 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return g.create(h.NA)}}class J1 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1);A(this,"needsReferenceObject",!0);A(this,"needsSheetsInfo",!0)}calculate(e){var u;if(e!=null&&e.isError())return e;const{sheetOrder:t,sheetNameMap:r}=this.getSheetsInfo();if(!e){const c=t.findIndex(l=>l===this.subUnitId);return y.create(c+1)}if(e.isReferenceObject()){const c=e.getForcedSheetId(),l=e.getDefaultSheetId(),f=t.findIndex(m=>c?m===c:m===l);return y.create(f+1)}if(e.isArray())return g.create(h.NA);const n=`${e.getValue()}`.toLocaleLowerCase(),s=(u=Object.entries(r).find(([c,l])=>l.toLocaleLowerCase()===n))==null?void 0:u[0];if(!s)return g.create(h.NA);const a=t.findIndex(c=>c===s);return y.create(a+1)}}class e0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0);A(this,"needsSheetsInfo",!0)}calculate(){const{sheetOrder:e}=this.getSheetsInfo();return y.create(e.length)}}class t0 extends N{constructor(){super(...arguments);A(this,"needsReferenceObject",!0);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isReferenceObject()){const t=e.getRowCount(),r=e.getColumnCount();if(t===1&&r===1){const n=e.getFirstCell();if(n.isError())return y.create(16);if(n.isBoolean())return y.create(4);if(n.isString())return y.create(2);if(n.isNumber()||n.isNull())return y.create(1)}else return y.create(64)}else{if(e.isArray())return y.create(64);if(e.isError())return y.create(16);if(e.isBoolean())return y.create(4);if(e.isString())return y.create(2);if(e.isNumber()||e.isNull())return y.create(1)}return y.create(128)}}const iu=[[T1,Ne.CELL],[B1,Ne.ERROR_TYPE],[I1,Ne.ISBLANK],[F1,Ne.ISERR],[k1,Ne.ISERROR],[$1,Ne.ISEVEN],[Y1,Ne.ISFORMULA],[H1,Ne.ISLOGICAL],[G1,Ne.ISNA],[W1,Ne.ISNONTEXT],[Q1,Ne.ISNUMBER],[q1,Ne.ISODD],[X1,Ne.ISREF],[K1,Ne.ISTEXT],[Z1,Ne.N],[z1,Ne.NA],[J1,Ne.SHEET],[e0,Ne.SHEETS],[t0,Ne.TYPE]];class r0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=!0,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(t=t&&!!a.getValue(),r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(t=t&&!!s.getValue(),r=!1)}return r?g.create(h.VALUE):k.create(t)}}class n0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"needsReferenceObject",!0)}calculate(e,t){let r=e,n=null;if(e.isReferenceObject()&&(r=e.toArrayValueObject(),n=e),r.isError())return r;if(t.isError())return t;if(!(t.isValueObject()&&t.isLambda()&&t.getLambdaPrivacyVarKeys().length===1))return g.create(h.VALUE);const s=t,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;r=O(a,u,r);const c=[[]];for(let l=0;l<u;l++){const f=[];for(let C=0;C<a;C++){const _=r.get(C,l);f.push([_])}let m=K.create({calculateValueList:f,rowCount:a,columnCount:1,unitId:"",sheetId:"",row:0,column:0});if(n){const{startRow:C,startColumn:_}=n.getRangePosition(),E={startRow:C,startColumn:_+l,endRow:C+a-1,endColumn:_+l};m=this.createReferenceObject(n,E)}let d=s.execute(m);if(d.isArray()){const C=d.getRowCount(),_=d.getColumnCount();if(C>1||_>1)return g.create(h.CALC);d=d.get(0,0)}d.isNull()&&(d=y.create(0)),c[0].push(d)}return u===1?c[0][0]:K.create({calculateValueList:c,rowCount:1,columnCount:u,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class s0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"needsReferenceObject",!0)}calculate(e,t){let r=e,n=null;if(e.isReferenceObject()&&(r=e.toArrayValueObject(),n=e),r.isError())return r;if(t.isError())return t;if(!(t.isValueObject()&&t.isLambda()&&t.getLambdaPrivacyVarKeys().length===1))return g.create(h.VALUE);const s=t,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;r=O(a,u,r);const c=[];for(let l=0;l<a;l++){const f=[[]];for(let C=0;C<u;C++){const _=r.get(l,C);f[0].push(_)}let m=K.create({calculateValueList:f,rowCount:1,columnCount:u,unitId:"",sheetId:"",row:0,column:0});if(n){const{startRow:C,startColumn:_}=n.getRangePosition(),E={startRow:C+l,startColumn:_,endRow:C+l,endColumn:_+u-1};m=this.createReferenceObject(n,E)}let d=s.execute(m);if(d.isArray()){const C=d.getRowCount(),_=d.getColumnCount();if(C>1||_>1)return g.create(h.CALC);d=d.get(0,0)}d.isNull()&&(d=y.create(0)),c.push([d])}return a===1?c[0][0]:K.create({calculateValueList:c,rowCount:a,columnCount:1,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class a0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return k.create(!1)}}var Ve=(i=>(i.AND="AND",i.BYCOL="BYCOL",i.BYROW="BYROW",i.FALSE="FALSE",i.IF="IF",i.IFERROR="IFERROR",i.IFNA="IFNA",i.IFS="IFS",i.LAMBDA="LAMBDA",i.LET="LET",i.MAKEARRAY="MAKEARRAY",i.MAP="MAP",i.NOT="NOT",i.OR="OR",i.REDUCE="REDUCE",i.SCAN="SCAN",i.SWITCH="SWITCH",i.TRUE="TRUE",i.XOR="XOR",i))(Ve||{});class i0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r=k.create(!1)){const n=this._getSingleValueObject(e);if(n.isError())return n;if(!n.isArray())return n.getValue()?t:r;const s=Math.max(n.isArray()?n.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),a=Math.max(n.isArray()?n.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),u=O(s,a,n),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA));return u.map((f,m,d)=>{if(f.isNull())return g.create(h.NA);{const C=c.get(m,d)||ae.create(),_=l.get(m,d)||ae.create();return this._calculateSingleCell(f,C,_)}})}_getSingleValueObject(e){return e.isArray()&&e.getRowCount()===1&&e.getColumnCount()===1?e.getFirstCell():e}_calculateSingleCell(e,t,r){return e.isNull()?g.create(h.NA):e.getValue()?t.isNull()?g.create(h.NA):t:r.isNull()?g.create(h.NA):r}}class o0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;if(!e.isArray())return e.isError()?t:e;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.iterator((u,c,l)=>{u!=null&&u.isError()&&s.set(c,l,a.get(c,l))}),s}}class u0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError()&&e.getErrorType()!==h.NA)return e;if(t.isError())return t;if(!e.isArray())return e.isError()&&e.getErrorType()===h.NA?t:e;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.iterator((u,c,l)=>{u!=null&&u.isError()&&u.getErrorType()===h.NA&&s.set(c,l,a.get(c,l))}),s}}class c0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(...e){if(e.length%2!==0)return g.create(h.NA);for(let a=0;a<e.length;a++)if(e[a].isError())return e[a];const t=Math.max(...e.map(a=>a.isArray()?a.getRowCount():1)),r=Math.max(...e.map(a=>a.isArray()?a.getColumnCount():1)),n=e.map(a=>O(t,r,a,g.create(h.NA))),s=n[0].map((a,u,c)=>{for(let l=0;l<n.length;l+=2){const f=n[l].get(u,c)||ae.create(),m=n[l+1].get(u,c)||ae.create();if(f.isNull())continue;if(f.isError())return f;const d=f.getValue();if(f.isString()){if(`${d}`.toLocaleUpperCase()==="TRUE")return m;if(`${d}`.toLocaleUpperCase()==="FALSE")continue;return g.create(h.VALUE)}if(+d)return m.isNull()?g.create(h.NA):m}return g.create(h.NA)});return t===1&&r===1?s.get(0,0):s}}class l0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){return g.create(h.VALUE)}}class f0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(...e){return g.create(h.VALUE)}}class m0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(...e){const t=this.getIndexNumValue(e[0]);if(typeof t!="number")return t;const r=this.getIndexNumValue(e[1]);if(typeof r!="number")return r;if(!(e[2].isValueObject()&&e[2].isLambda()))return g.create(h.VALUE);const n=e[2],s=[];for(let a=0;a<t;a++){s[a]==null&&(s[a]=[]);for(let u=0;u<r;u++){let c=n.execute(y.create(a+1),y.create(u+1));c.isArray()&&(c=c.get(0,0)),s[a][u]=c}}return new Bi(s)}isAsync(){return!0}}let h0=class extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}calculate(...e){const t=[];let r=null,n=0,s=0;for(let u=0;u<e.length;u++){const c=e[u];let l=c;if(l.isReferenceObject()&&(l=c.toArrayValueObject()),l.isError())return l;if(u===e.length-1){if(!(c.isValueObject()&&c.isLambda()))return g.create(h.VALUE);r=c}else t.push(c),n=Math.max(n,l.isArray()?l.getRowCount():1),s=Math.max(s,l.isArray()?l.getColumnCount():1)}const a=this._getResultArray(t,r,n,s);return a instanceof g?a:n===1&&s===1?a[0][0]:K.create({calculateValueList:a,rowCount:n,columnCount:s,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getResultArray(e,t,r,n){const s=[];for(let a=0;a<r;a++){const u=[];for(let c=0;c<n;c++){const l=[];let f=!1;for(let d=0;d<e.length;d++){let C=e[d],_=null;if(C.isReferenceObject()&&(_=C,C=C.toArrayValueObject()),!C.isArray())if(a===0&&c===0){l.push(_||C);continue}else{u.push(g.create(h.NA)),f=!0;break}let E=C.get(a,c);if(!E){u.push(g.create(h.NA)),f=!0;break}if(_){const{startRow:b,startColumn:R}=_.getRangePosition(),p={startRow:b+a,startColumn:R+c,endRow:b+a,endColumn:R+c};E=this.createReferenceObject(_,p)}l.push(E)}if(f||l.length===0)continue;let m=t.execute(...l);if(m.isArray()){const d=m.getRowCount(),C=m.getColumnCount();if(d>1||C>1)return g.create(h.CALC);m=m.get(0,0)}m.isNull()&&(m=y.create(0)),u.push(m)}s.push(u)}return s}};class g0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;const t=+e.getValue();return Number.isNaN(t)?g.create(h.VALUE):k.create(!t)}}class d0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=!1,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(t=t||!!a.getValue(),r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(t=t||!!s.getValue(),r=!1)}return r?new g(h.VALUE):new k(t)}}class C0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n,s;e.isReferenceObject()?(n=e.toArrayValueObject(),s=e):(n=e,s=null);let a,u;return t.isReferenceObject()?(a=t.toArrayValueObject(),u=t):(a=t,u=null),n.isArray()?n.mapValue(c=>this._handleSingleValueObject(c,a,r,s,u)):this._handleSingleValueObject(n,a,r,s,u)}_handleSingleValueObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(!(r.isValueObject()&&r.isLambda()&&r.getLambdaPrivacyVarKeys().length===2))return g.create(h.VALUE);const a=r,u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;let l=e;n&&(l=n);for(let f=0;f<u;f++)for(let m=0;m<c;m++){let d=t.isArray()?t.get(f,m):t;if(d.isError())return d;if(s){const{startRow:_,startColumn:E}=s.getRangePosition(),b={startRow:_+f,startColumn:E+m,endRow:_+f,endColumn:E+m};d=this.createReferenceObject(s,b)}let C=a.execute(l,d);if(C.isError())return C;C.isNull()&&(C=y.create(0)),l=C}return l.isReferenceObject()?l.toArrayValueObject():l}}class _0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e,s=null;e.isReferenceObject()&&(n=e.toArrayValueObject(),s=e),n=n;let a=t,u=null;if(t.isReferenceObject()&&(a=t.toArrayValueObject(),u=t),a=a,n.isError())return n;if(a.isError())return a;if(r.isError())return r;if(!(r.isValueObject()&&r.isLambda()&&r.getLambdaPrivacyVarKeys().length===2))return g.create(h.VALUE);if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.CALC);n=n.get(0,0)}return this._getResult(n,a,r,s,u)}_getResult(e,t,r,n,s){const a=[],u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;let l=e;n&&(l=n);for(let f=0;f<u;f++){const m=[];for(let d=0;d<c;d++){if(l.isError()){m.push(l);continue}let C=t.isArray()?t.get(f,d):t;if(C.isError()){l=C,m.push(C);continue}if(s){const{startRow:E,startColumn:b}=s.getRangePosition(),R={startRow:E+f,startColumn:b+d,endRow:E+f,endColumn:b+d};C=this.createReferenceObject(s,R)}let _=r.execute(l,C);if(_.isArray()){const E=_.getRowCount(),b=_.getColumnCount();if(E>1||b>1)return g.create(h.CALC);_=_.get(0,0)}_.isNull()&&(_=y.create(0)),l=_,m.push(_)}a.push(m)}return u===1&&c===1?a[0][0]:K.create({calculateValueList:a,rowCount:u,columnCount:c,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class A0 extends N{constructor(){super(...arguments);A(this,"minParams",3)}calculate(e,...t){if(e.isError())return e;const r=t.length%2!==0,n=r?t[t.length-1]:ae.create();return!e.isArray()&&!t.some(s=>s.isArray())?this._handleNonArrayInputs(e,t,n,r):this._handleArrayInputs(e,t,n,r)}_handleNonArrayInputs(e,t,r,n){for(let s=0;s<t.length-(n?1:0);s+=2){const a=t[s],u=t[s+1];if(!a.isNull()){if(a.isError())return a;if(`${e.getValue()}`.toLocaleLowerCase()===`${a.getValue()}`.toLocaleLowerCase())return u.isNull()?g.create(h.NA):u}}return r.isNull()?g.create(h.NA):r}_handleArrayInputs(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,...t.map(f=>f.isArray()?f.getRowCount():1),r.isArray()?r.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,...t.map(f=>f.isArray()?f.getColumnCount():1),r.isArray()?r.getColumnCount():1),u=O(s,a,e),c=t.map(f=>O(s,a,f,g.create(h.NA))),l=O(s,a,r,g.create(h.NA));return u.map((f,m,d)=>{for(let _=0;_<c.length-(n?1:0);_+=2){const E=c[_].get(m,d)||ae.create(),b=c[_+1].get(m,d)||ae.create();if(!E.isNull()){if(E.isError()||f.isError())return E.isError()?E:f;if(`${f.getValue()}`.toLocaleLowerCase()===`${E.getValue()}`.toLocaleLowerCase())return b.isNull()?g.create(h.NA):b}}const C=l.get(m,d)||ae.create();return C.isNull()?g.create(h.NA):C})}}class E0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return k.create(!0)}}class b0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(a.getValue()&&t++,r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(s.getValue()&&t++,r=!1)}return r?g.create(h.VALUE):k.create(t%2===1)}}const ou=[[r0,Ve.AND],[n0,Ve.BYCOL],[s0,Ve.BYROW],[a0,Ve.FALSE],[i0,Ve.IF],[o0,Ve.IFERROR],[u0,Ve.IFNA],[c0,Ve.IFS],[l0,Ve.LAMBDA],[f0,Ve.LET],[m0,Ve.MAKEARRAY],[h0,Ve.MAP],[g0,Ve.NOT],[d0,Ve.OR],[C0,Ve.REDUCE],[_0,Ve.SCAN],[A0,Ve.SWITCH],[E0,Ve.TRUE],[b0,Ve.XOR]];class y0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",5)}calculate(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;const a=r!=null?r:y.create(1),u=n!=null?n:k.create(!0),c=s!=null?s:j.create(""),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),C=O(l,f,a,g.create(h.NA)),_=O(l,f,u,g.create(h.NA)),E=O(l,f,c,g.create(h.NA));return m.map((b,R,p)=>{const V=d.get(R,p)||g.create(h.NA),S=C.get(R,p)||g.create(h.NA),D=_.get(R,p)||g.create(h.NA),w=E.get(R,p)||g.create(h.NA);return b.isError()?b:V.isError()?V:S.isError()?S:D.isError()?D:w.isError()?w:this._calculateSingleCell(b,V,S,D,w)})}_calculateSingleCell(e,t,r,n,s){const a=Number.parseInt(`${Number(e.getValue())-1}`),u=Number.parseInt(`${Number(t.getValue())-1}`),c=Number.parseInt(`${Number(r.getValue())}`);if(Number.isNaN(a)||Number.isNaN(u)||Number.isNaN(c)||c<1||c>4)return g.create(h.VALUE);const l=R0(c),f=this.getZeroOrOneByOneDefault(n),m=`${s.getValue()}`,d=Jr(m)?`'${m}'`:m,C={startRow:a,startColumn:u,endRow:a,endColumn:u,startAbsoluteRefType:l,endAbsoluteRefType:l},_=n&&!f?fm(C):St(C);return j.create(d!==""?`${d}!${_}`:_)}}function R0(i){switch(i){case 1:return M.AbsoluteRefType.ALL;case 2:return M.AbsoluteRefType.ROW;case 3:return M.AbsoluteRefType.COLUMN;case 4:return M.AbsoluteRefType.NONE;default:return M.AbsoluteRefType.ALL}}class p0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){return e.isReferenceObject()?y.create(1):g.create(h.VALUE)}}class N0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}isAddress(){return!0}calculate(e,...t){let r=e;if(r.isError())return r;if(r.isReferenceObject()&&(r=r.toArrayValueObject()),!r.isArray()){const c=r.convertToNumberObjectValue();return c.isError()?c:t[Math.trunc(+c.getValue())-1]||g.create(h.VALUE)}let n=r.isArray()?r.getRowCount():1,s=r.isArray()?r.getColumnCount():1;t.forEach((c,l)=>{if(c.isArray()){const f=c;n=Math.max(n,f.getRowCount()),s=Math.max(s,f.getColumnCount())}else n=Math.max(n,1),s=Math.max(s,1)});const a=O(n,s,r,g.create(h.NA)),u=t.map(c=>{let l=c;return l.isReferenceObject()&&(l=l.toArrayValueObject()),O(n,s,l,g.create(h.NA))});return a.map((c,l,f)=>{if(c.isError())return c;const m=c.convertToNumberObjectValue();if(m.isError())return m;const d=u[Math.trunc(+m.getValue())-1];let C=(d==null?void 0:d.get(l,f))||g.create(h.VALUE);return C!=null&&C.isNull()&&(C=y.create(0)),C})}}class V0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=[];for(let a=0;a<t.length;a++){let u=t[a];if(u.isArray()){const f=u.getRowCount(),m=u.getColumnCount();if(f>1||m>1)return g.create(h.VALUE);u=u.get(0,0)}if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;const c=Math.trunc(+u.getValue());if(c===0||Math.abs(c)>n)return g.create(h.VALUE);let l=e;n>1&&(c<0?l=e.slice(void 0,[c+n,c+1+n]):l=e.slice(void 0,[c-1,c]));for(let f=0;f<r;f++)s[f]||(s[f]=[]),e.isArray()?s[f].push(l.get(f,0)):s[f].push(e)}return K.create({calculateValueList:s,rowCount:s.length,columnCount:s[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class O0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=e.isArray()?e.getRowCount():1,n=[];for(let s=0;s<t.length;s++){let a=t[s];if(a.isArray()){const l=a.getRowCount(),f=a.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);a=a.get(0,0)}if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return a;const u=Math.trunc(+a.getValue());if(u===0||Math.abs(u)>r)return g.create(h.VALUE);let c=e;r>1&&(u<0?c=e.slice([u+r,u+1+r]):c=e.slice([u-1,u])),e.isArray()?n.push(c.getArrayValue()[0]):n.push([e])}return K.create({calculateValueList:n,rowCount:n.length,columnCount:n[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class M0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1)}calculate(e){if(e==null)return y.create(this.column+1);if(e.isError())return e;if(!e.isArray())return g.create(h.NA);const t=e.getCurrentColumn(),r=e.getColumnCount(),n=[];for(let a=0;a<r;a++)n.push(y.create(t+a+1));const s={calculateValueList:[n],rowCount:1,columnCount:r,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(s)}}class S0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isString()||e.isNumber()||e.isBoolean())return y.create(1);if(!e.isArray())return g.create(h.NA);const t=e.getColumnCount();return y.create(t)}}class D0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(0),s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA));if(u>1||c>1)return l.mapValue((R,p,V)=>{const S=f.get(p,V);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:D,errorObject:w}=this._checkRowsColumns(R,S,s,a);return D?w:e.isArray()?g.create(h.VALUE):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const m=t.isArray()?t.get(0,0):t,d=n.isArray()?n.get(0,0):n,{isError:C,errorObject:_,rowsValue:E,columnsValue:b}=this._checkRowsColumns(m,d,s,a);return C?_:this._getResultArray(e,E,b,s,a)}_checkRowsColumns(e,t,r,n){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};const s=Math.trunc(+e.getValue()),a=Math.trunc(+t.getValue());return Number.isNaN(s)||Number.isNaN(a)?{isError:!0,errorObject:g.create(h.VALUE)}:Math.abs(s)>=r||Math.abs(a)>=n?{isError:!0,errorObject:g.create(h.CALC)}:{isError:!1,rowsValue:s,columnsValue:a}}_getResultArray(e,t,r,n,s){const a=t>=0?[t,n]:[0,n+t],u=r>=0?[r,s]:[0,s+r];let c;return t===0&&r===0?c=e:t===0?c=e.slice(void 0,u):r===0?c=e.slice(a,void 0):c=e.slice(a,u),c=c.map(l=>l.isNull()?y.create(0):l),n-t===1&&s-r===1?c.get(0,0):c}}class w0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1;let u=t,c=r!=null?r:y.create(a);const l=n!=null?n:g.create(h.NA);t.isNull()&&(u=y.create(s)),c.isNull()&&(c=y.create(a));const f=Math.max(u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),m=Math.max(u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),d=O(f,m,u,g.create(h.NA)),C=O(f,m,c,g.create(h.NA));if(f>1||m>1)return d.mapValue((D,w,P)=>{const L=C.get(w,P);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:T,errorObject:B}=this._checkRowsColumnsPadWith(D,L,l,s,a);return T?B:e.isArray()?e.get(0,0):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const _=u.isArray()?u.get(0,0):u,E=c.isArray()?c.get(0,0):c,{isError:b,errorObject:R,rowsValue:p,columnsValue:V,padWithObject:S}=this._checkRowsColumnsPadWith(_,E,l,s,a);return b?R:this._getResultArray(e,p,V,S,s,a)}_checkRowsColumnsPadWith(e,t,r,n,s){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};const a=Math.trunc(+e.getValue()),u=Math.trunc(+t.getValue());if(Number.isNaN(a)||Number.isNaN(u))return{isError:!0,errorObject:g.create(h.VALUE)};if(Math.abs(a)<n||Math.abs(u)<s)return{isError:!0,errorObject:g.create(h.VALUE)};let c=r;if(r.isArray()){const l=r.getRowCount(),f=r.getColumnCount();if(l>1||f>1)return{isError:!0,errorObject:g.create(h.VALUE)};c=r.get(0,0)}return{isError:!1,rowsValue:a,columnsValue:u,padWithObject:c}}_getResultArray(e,t,r,n,s,a){let u=[];e.isArray()?u=e.map(f=>f.isNull()?y.create(0):f).getArrayValue():u=[[e]];const c=Math.max(0,t-s),l=Math.max(0,r-a);for(let f=0;f<c;f++)u.push(new Array(a).fill(n));for(let f=0;f<l;f++)u.forEach(m=>{m.push(n)});return t===1&&r===1?u[0][0]:K.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class P0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:g.create(h.CALC);if(e.isError())return e;if(t.isError())return t;const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;return u>1&&c>1||u===1&&c!==a||c===1&&u!==s?g.create(h.VALUE):s===1&&a===1?this._getResultArrayByR1C1(e,t,n):u===1?c!==a?g.create(h.VALUE):this._getResultArrayByR1(s,a,e,t,n):c===1?u!==s?g.create(h.VALUE):this._getResultArrayByC1(s,a,e,t,n):n}_getResultArrayByR1C1(e,t,r){let n=e,s=t;return n.isArray()&&(n=n.get(0,0)),s.isArray()&&(s=s.get(0,0)),s.isString()&&(s=s.convertToNumberObjectValue()),s.isError()?s:+s.getValue()?n:r}_getResultArrayByR1(e,t,r,n,s){const a=[];for(let u=0;u<t;u++){let c=n.get(0,u);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;if(+c.getValue())for(let f=0;f<e;f++){a[f]||(a[f]=[]);const m=r.get(f,u);a[f].push(m)}}return a.length===0?s:K.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getResultArrayByC1(e,t,r,n,s){const a=[];for(let u=0;u<e;u++){let c=n.get(u,0);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;if(!+c.getValue())continue;const f=[];for(let m=0;m<t;m++){const d=r.get(u,m);f.push(d)}a.push(f)}return a.length===0?s:K.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class L0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0);A(this,"needsFormulaDataModel",!0)}calculate(e){var f,m;if(!e.isReferenceObject())return g.create(h.NA);const t=e.getUnitId(),r=e.getSheetId(),s=(m=(f=e.getUnitData()[t])==null?void 0:f[r])==null?void 0:m.cellData,{startRow:a,startColumn:u}=e.getRangePosition(),l=e.toArrayValueObject().mapValue((d,C,_)=>{const E=s.getValue(a+C,u+_);if(E!=null&&E.f||E!=null&&E.si){const b=this._formulaDataModel.getFormulaStringByCell(a+C,u+_,r,t);return j.create(b)}return g.create(h.NA)});return l.getRowCount()===1&&l.getColumnCount()===1?l.get(0,0):l}}var me=(i=>(i.ADDRESS="ADDRESS",i.AREAS="AREAS",i.CHOOSE="CHOOSE",i.CHOOSECOLS="CHOOSECOLS",i.CHOOSEROWS="CHOOSEROWS",i.COLUMN="COLUMN",i.COLUMNS="COLUMNS",i.DROP="DROP",i.EXPAND="EXPAND",i.FILTER="FILTER",i.FORMULATEXT="FORMULATEXT",i.GETPIVOTDATA="GETPIVOTDATA",i.HLOOKUP="HLOOKUP",i.HSTACK="HSTACK",i.HYPERLINK="HYPERLINK",i.IMAGE="IMAGE",i.INDEX="INDEX",i.INDIRECT="INDIRECT",i.LOOKUP="LOOKUP",i.MATCH="MATCH",i.OFFSET="OFFSET",i.ROW="ROW",i.ROWS="ROWS",i.RTD="RTD",i.SORT="SORT",i.SORTBY="SORTBY",i.TAKE="TAKE",i.TOCOL="TOCOL",i.TOROW="TOROW",i.TRANSPOSE="TRANSPOSE",i.UNIQUE="UNIQUE",i.VLOOKUP="VLOOKUP",i.VSTACK="VSTACK",i.WRAPCOLS="WRAPCOLS",i.WRAPROWS="WRAPROWS",i.XLOOKUP="XLOOKUP",i.XMATCH="XMATCH",i))(me||{});class x0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray()||r.isError()||n!=null&&n.isError())return g.create(h.NA);const s=this.getZeroOrOneByOneDefault(n);if(s==null)return g.create(h.VALUE);const a=this.getIndexNumValue(r);if(a instanceof g)return a;const u=t.slice([0,1]),c=t.slice([a-1,a]);return u==null||c==null?g.create(h.REF):e.isArray()?e.map(l=>this._handleSingleObject(l,u,c,s)):this._handleSingleObject(e,u,c,s)}_handleSingleObject(e,t,r,n){return n===0?this.equalSearch(e,t,r):this.binarySearch(e,t,r)}}class j0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=Math.max(...e.map(n=>n.isArray()?n.getRowCount():1)),r=[];for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<t;c++){r[c]||(r[c]=[]);for(let l=0;l<u;l++){let f=s;s.isArray()&&(f=s.get(c,l)),c>a-1||!f?r[c].push(g.create(h.NA)):r[c].push(f)}}}return K.create({calculateValueList:r,rowCount:r.length,columnCount:r[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class U0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4);A(this,"needsReferenceObject",!0)}calculate(e,t,r,n){if(e.isError())return e;if(t!=null&&t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;let s=0,a=0;if(e.isValueObject())s=1,a=1;else if(e.isReferenceObject()){const{startRow:d,endRow:C,startColumn:_,endColumn:E}=e.getRangePosition();s=C-d+1,a=E-_+1}else return g.create(h.VALUE);let u,c;s===1&&a>1&&r==null?(c=t!=null?t:y.create(0),u=y.create(0)):(u=t!=null?t:y.create(0),c=r!=null?r:y.create(0));let l=n!=null?n:y.create(1);u.isReferenceObject()&&(u=u.toArrayValueObject()),c.isReferenceObject()&&(c=c.toArrayValueObject()),l.isReferenceObject()&&(l=l.toArrayValueObject());const f=Math.max(u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1);if(u=u,c=c,l=l,f===1&&m===1)return this._calculateSingleCell(e,u,c,l);{const d=O(f,m,u,g.create(h.NA)),C=O(f,m,c,g.create(h.NA)),_=O(f,m,l,g.create(h.NA));return d.map((E,b,R)=>{const p=C.get(b,R)||ae.create(),V=_.get(b,R)||ae.create(),S=this._calculateSingleCell(e,E,p,V);return S.isReferenceObject()?S.toArrayValueObject().getFirstCell():S})}}_calculateSingleCell(e,t,r,n){if(t.isError())return t;const s=this._getNumberValue(t);if(s===void 0||s<0)return g.create(h.VALUE);if(r.isError())return r;const a=this._getNumberValue(r);if(a===void 0||a<0)return g.create(h.VALUE);if(n.isError())return n;const u=this._getAreaNumberValue(n);return u===void 0||u<1?g.create(h.VALUE):e.isReferenceObject()?this._getReferenceObject(e,s,a,u):e.isValueObject()&&s===1&&a===1?e:g.create(h.REF)}_getNumberValue(e){if(e==null)return 0;let t=0;if(e.isBoolean())e.getValue()===!0&&(t=1);else{if(e.isString())return;e.isNumber()?t=Math.floor(e.getValue()):e.isNull()&&(t=0)}return t}_getAreaNumberValue(e){if(e==null)return 1;let t=0;if(e.isBoolean())e.getValue()===!0&&(t=1);else{if(e.isString())return;e.isNumber()?t=Math.floor(e.getValue()):e.isNull()&&(t=0)}return t}_getReferenceObject(e,t,r,n){const{startRow:s,endRow:a,startColumn:u,endColumn:c}=e.getRangePosition();let l=0,f=0,m=0,d=0;if(t===0?(l=s,f=a):l=f=s+t-1,r===0?(m=u,d=c):m=d=u+r-1,l>a||m>c)return g.create(h.REF);const C={startRow:l,startColumn:m,endRow:f,endColumn:d};return this.createReferenceObject(e,C)}}class v0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}isAddress(){return!0}calculate(e,t){if(e.isError())return e;if(t!=null&&t.isError())return t;let r=this.getZeroOrOneByOneDefault(t);r==null&&(r=1);let n=e;if(e.isArray()){const s=e.getRowCount(),a=e.getColumnCount();if(s>1||a>1)return e.map(()=>g.create(h.VALUE));n=e.getFirstCell()}return this._handleSingleObject(n,r)}_handleSingleObject(e,t){const r=`${e.getValue()}`;if(r.trim()==="")return g.create(h.REF);const n=this._convertToDefinedName(r);if(t===0){const f=Zi(n),{range:m,sheetName:d,unitId:C}=f,_=new Rr(m);return _.setForcedUnitIdDirect(C),_.setForcedSheetName(d),this._setDefault(_)}if(Nr(n))return this._setDefault(new Ps(n));if(ui(n))return this._setDefault(new xs(n));if(ci(n))return this._setDefault(new Ls(n));const s=Yt(n),{range:a,sheetName:u,unitId:c}=s;if(Number.isNaN(a.startRow)||a.endRow+1>1048576||Number.isNaN(a.startColumn)||a.endColumn+1>16384)return g.create(h.REF);const l=new Rr(a);return l.setForcedUnitIdDirect(c),l.setForcedSheetName(u),this._setDefault(l)}_setDefault(e){return this.unitId==null||this.subUnitId==null?g.create(h.REF):(e.setDefaultUnitId(this.unitId),e.setDefaultSheetId(this.subUnitId),e)}_convertToDefinedName(e){const t=this.getDefinedName(e);if(t==null)return e;const r=t.formulaOrRefString;return r==null?e:r.startsWith(X.EQUALS)?r.slice(1):r}}class T0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsExpandParams",!0)}calculate(e,t,r){return e.isError()?e:t.isError()?g.create(h.REF):t.isArray()?r!=null&&r.isError()?r:t.getColumnCount()===1||t.getRowCount()===1?r!=null&&!r.isArray()?g.create(h.REF):this._handleVector(e,t,r):this._handleArray(e,t):g.create(h.VALUE)}_handleVector(e,t,r){let n=r;if(n==null)n=t;else if(n.getRowCount()!==t.getRowCount()||n.getColumnCount()!==t.getColumnCount())return g.create(h.REF);return e.isArray()?e.map(s=>this.binarySearch(s,t,n)):this.binarySearch(e,t,n)}_handleArray(e,t){const r=t.getRowCount(),n=t.getColumnCount();let s,a;return n>r?(s=t.slice([0,1]),a=t.slice([r-1,r])):(s=t.slice(void 0,[0,1]),a=t.slice(void 0,[n-1,n])),s==null||a==null?g.create(h.VALUE):e.isArray()?e.map(u=>this.binarySearch(u,s,a)):this.binarySearch(e,s,a)}}class B0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray())return g.create(h.VALUE);const n=t.getRowCount(),s=t.getColumnCount();if(n!==1&&s!==1||r!=null&&r.isError())return g.create(h.NA);const a=this.getMatchTypeValue(r);return a==null?g.create(h.VALUE):e.isArray()?e.map(u=>this._handleSingleObject(u,t,a)):this._handleSingleObject(e,t,a)}_handleSingleObject(e,t,r){const n=this._getSearchModeValue(r),s=t.orderSearch(e,n);if(s==null)return g.create(h.NA);if(s instanceof g)return s;const a=t.getRowCount()===1?s.column+1:s.row+1;return y.create(a)}_getSearchModeValue(e){switch(e){case 1:return Oe.MIN;case 0:return Oe.NORMAL;case-1:return Oe.MAX}}}class I0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsReferenceObject",!0)}isAddress(){return!0}calculate(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;if(!e.isReferenceObject())return g.create(h.VALUE);const a=e.getRowCount(),u=e.getColumnCount();let c=t;c.isReferenceObject()&&(c=c.toArrayValueObject());let l=r;l.isReferenceObject()&&(l=l.toArrayValueObject());let f=n!=null?n:y.create(a);f.isReferenceObject()&&(f=f.toArrayValueObject()),f.isNull()&&(f=y.create(a));let m=s!=null?s:y.create(u);m.isReferenceObject()&&(m=m.toArrayValueObject()),m.isNull()&&(m=y.create(u));const d=Math.max(c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1),C=Math.max(c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1);if(c=c,l=l,f=f,m=m,d===1&&C===1)return c=c.isArray()?c.get(0,0):c,l=l.isArray()?l.get(0,0):l,f=f.isArray()?f.get(0,0):f,m=m.isArray()?m.get(0,0):m,this._handleSingleObject(e,c,l,f,m);const _=O(d,C,c,g.create(h.NA)),E=O(d,C,l,g.create(h.NA)),b=O(d,C,f,g.create(h.NA)),R=O(d,C,m,g.create(h.NA));return _.mapValue((p,V,S)=>{const D=E.get(V,S),w=b.get(V,S),P=R.get(V,S);return p.isError()?p:D.isError()?D:w.isError()?w:P.isError()?P:this._handleSingleObject(e,p,D,w,P,!0)})}_handleSingleObject(e,t,r,n,s,a=!1){const{startRow:u,startColumn:c}=e.getRangePosition();let l=t;if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;let f=r;if(f.isString()&&(f=f.convertToNumberObjectValue()),f.isError())return f;const m=+l.getValue(),d=+f.getValue();if(typeof m!="number"||typeof d!="number")return g.create(h.VALUE);const C=u+m,_=c+d;if(C<0||_<0)return g.create(h.REF);const E=this.getIndexNumValue(n),b=this.getIndexNumValue(s);if(typeof E!="number"||typeof b!="number")return g.create(h.VALUE);if(E===0||b===0)return g.create(h.REF);const R=E>0?C+E-1:C+E+1,p=b>0?_+b-1:_+b+1;if(R<0||p<0)return g.create(h.REF);if(a)return g.create(h.VALUE);const V=C<R?C:R,S=_<p?_:p,D=C>R?C:R,w=_>p?_:p,P={startRow:V,startColumn:S,endRow:D,endColumn:w};return this.createReferenceObject(e,P)}}class F0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1)}calculate(e){if(e==null)return y.create(this.row+1);if(e.isError())return e;if(!e.isArray())return g.create(h.NA);const t=e.getCurrentRow(),r=e.getRowCount(),n=[];for(let a=0;a<r;a++)n.push([y.create(t+a+1)]);const s={calculateValueList:n,rowCount:r,columnCount:1,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(s)}}class k0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isString()||e.isNumber()||e.isBoolean())return y.create(1);if(!e.isArray())return g.create(h.NA);const t=e.getRowCount();return y.create(t)}}class $0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const s=t!=null?t:y.create(1),a=r!=null?r:y.create(1),u=n!=null?n:k.create(!1);if(u.isArray()){const c=u.getRowCount(),l=u.getColumnCount();if(c===1&&l===1){const f=u.get(0,0);return this._handleSingleObject(e,s,a,f)}return u.map(f=>{const m=this._handleSingleObject(e,s,a,f);return m.isArray()?m.get(0,0):m})}return this._handleSingleObject(e,s,a,u)}_handleSingleObject(e,t,r,n){if(e.isError())return e;const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=this._checkArrayError(t);if(u.isError())return u;const c=Math.floor(+u.getValue());if(c<1)return g.create(h.VALUE);const l=this._checkArrayError(r);if(l.isError())return l;const f=Math.floor(+l.getValue());if(f!==-1&&f!==1)return g.create(h.VALUE);let m=n;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;if(!e.isArray()||s===1&&a===1)return e;const d=+m.getValue();return this._getResult(e,c,f,d,s,a)}_checkArrayError(e){let t=e;if(t.isArray()){const r=t.getRowCount(),n=t.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=t.get(0,0)}return t.isString()&&(t=t.convertToNumberObjectValue()),t}_getResult(e,t,r,n,s,a){if(n){if(t>s)return g.create(h.VALUE);const u=e.transpose().getArrayValue();return u.sort(this._sort(t-1,r)),K.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}).transpose()}else{if(t>a)return g.create(h.VALUE);const u=e.getArrayValue();return u.sort(this._sort(t-1,r)),K.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}_sort(e,t=1){const r=tn();return t===1?this._sortAsc(e,r):this._sortDesc(e,r)}_sortAsc(e,t){return(r,n)=>{const s=r[e],a=n[e];if(s==null||s.isNull())return 1;if(a==null||a.isNull())return-1;if(s.isError()&&a.isError())return 0;if(s.isError())return 1;if(a.isError())return-1;const u=s.getValue(),c=a.getValue();return s.isBoolean()&&u===!0?1:a.isBoolean()&&c===!0?-1:s.isBoolean()&&u===!1?1:a.isBoolean()&&c===!1?-1:s.isNumber()&&a.isNumber()?+u-+c:t(u,c)}}_sortDesc(e,t){return(r,n)=>{const s=r[e],a=n[e];if(s==null||s.isNull())return 1;if(a==null||a.isNull())return-1;if(s.isError()&&a.isError())return 0;if(s.isError())return-1;if(a.isError())return 1;const u=s.getValue(),c=a.getValue();return s.isBoolean()&&u===!0?-1:a.isBoolean()&&c===!0?1:s.isBoolean()&&u===!1?-1:a.isBoolean()&&c===!1?1:s.isNumber()&&a.isNumber()?+c-+u:t(c,u)}}}class Y0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){t.length===1&&t.push(y.create(1));const r=this._getVariantsError(e,...t),{maxRowLength:n,maxColumnLength:s}=hr(t);if(r.isError()){const c=O(n,s,r);return n===1&&s===1?c.get(0,0):c}const a=t.map((c,l)=>l%2===0?c:O(n,s,c,g.create(h.NA))),u=this._getResultArray(e,a,n,s);return n===1&&s===1?u[0][0]:K.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getVariantsError(e,...t){if(e.isError())return e;for(let u=0;u<t.length;u++){const c=t[u];if(c.isError())return c}if(t.length<2||t.length%2!==0)return g.create(h.VALUE);const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t[0].isArray()?t[0].getRowCount():1,a=t[0].isArray()?t[0].getColumnCount():1;if((s>1||a>1)&&(s>1&&a>1||s===1&&a!==n||a===1&&s!==r))return g.create(h.VALUE);for(let u=2;u<t.length;u++){if(u%2===1)continue;const c=t[u].isArray()?t[u].getRowCount():1,l=t[u].isArray()?t[u].getColumnCount():1;if(c!==s||l!==a)return g.create(h.VALUE)}return k.create(!0)}_getResultArray(e,t,r,n){const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=t[0].isArray()?t[0].getRowCount():1,c=t[0].isArray()?t[0].getColumnCount():1,l=[];for(let f=0;f<r;f++){l[f]=[];for(let m=0;m<n;m++){const{isError:d,errorObject:C,byArrays:_,sortOrders:E}=this._getByArraysAndSortOrders(t,f,m,c);if(d){l[f].push(C);continue}if(!e.isArray()||s===1&&a===1){l[f].push(e);continue}let b=e.getArrayValue();u===1&&c===1||(u===1?(b=b.concat(_),b=this._transposeArray(b),b.sort(this._sort(s,E)),b=this._transposeArray(b).slice(0,s)):c===1&&(b=this._transposeArray(b),b=b.concat(_),b=this._transposeArray(b),b.sort(this._sort(a,E)),b=b.map(p=>p.slice(0,a))));const R=K.create({calculateValueList:b,rowCount:b.length,columnCount:b[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column});if(r>1||n>1){l[f].push(R.get(0,0));continue}l[f].push(R)}}return l}_getByArraysAndSortOrders(e,t,r,n){const s=[],a=[];let u=!1,c=null;for(let l=0;l<e.length;l++){if(l%2===1)continue;const f=e[l];let m=e[l+1].get(t,r);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError()){u=!0,c=m;break}const d=Math.floor(+m.getValue());if(d!==-1&&d!==1){u=!0,c=g.create(h.VALUE);break}if(a.push(d),f.isArray()){let C=f.getArrayValue();n===1&&(C=this._transposeArray(C)),s.push(C[0])}else s.push([f])}return{isError:u,errorObject:c,byArrays:s,sortOrders:a}}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}_sort(e,t){const r=tn();return(n,s)=>{let a=n[e],u=s[e],c=this._compare(a,u,t[0],r);if(c===0&&t.length>1){for(let l=1;l<t.length;l++)if(a=n[e+l],u=s[e+l],c=this._compare(a,u,t[l],r),c!==0)return c}return c}}_compare(e,t,r,n){return r===1?this._asc(e,t,n):this._desc(e,t,n)}_asc(e,t,r){if(e==null||e.isNull())return 1;if(t==null||t.isNull())return-1;if(e.isError()&&t.isError())return 0;if(e.isError())return 1;if(t.isError())return-1;const n=e.getValue(),s=t.getValue();return e.isBoolean()&&n===!0?1:t.isBoolean()&&s===!0?-1:e.isBoolean()&&n===!1?1:t.isBoolean()&&s===!1?-1:e.isNumber()&&t.isNumber()?+n-+s:r(n,s)}_desc(e,t,r){if(e==null||e.isNull())return 1;if(t==null||t.isNull())return-1;if(e.isError()&&t.isError())return 0;if(e.isError())return-1;if(t.isError())return 1;const n=e.getValue(),s=t.getValue();return e.isBoolean()&&n===!0?-1:t.isBoolean()&&s===!0?1:e.isBoolean()&&n===!1?-1:t.isBoolean()&&s===!1?1:e.isNumber()&&t.isNumber()?+s-+n:r(s,n)}}class H0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;let a=t,u=r!=null?r:y.create(s);t.isNull()&&(a=y.create(n)),u.isNull()&&(u=y.create(s));const c=Math.max(a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,a,g.create(h.NA)),m=O(c,l,u,g.create(h.NA));if(c>1||l>1)return f.mapValue((p,V,S)=>{const D=m.get(V,S);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:w,errorObject:P}=this._checkRowsColumns(p,D,n,s);return w?P:e.isArray()?g.create(h.VALUE):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const d=a.isArray()?a.get(0,0):a,C=u.isArray()?u.get(0,0):u,{isError:_,errorObject:E,rowsValue:b,columnsValue:R}=this._checkRowsColumns(d,C,n,s);return _?E:this._getResultArray(e,b,R,n,s)}_checkRowsColumns(e,t,r,n){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};let s=Math.trunc(+e.getValue()),a=Math.trunc(+t.getValue());return Number.isNaN(s)||Number.isNaN(a)?{isError:!0,errorObject:g.create(h.VALUE)}:Math.abs(s)===0||Math.abs(a)===0?{isError:!0,errorObject:g.create(h.CALC)}:(s>r&&(s=r),a>n&&(a=n),{isError:!1,rowsValue:s,columnsValue:a})}_getResultArray(e,t,r,n,s){if(!e.isArray())return e;const a=t>=0?[0,t]:[n+t,n],u=r>=0?[0,r]:[s+r,s];let c;return t===n&&r===s?c=e:t===n?c=e.slice(void 0,u):r===s?c=e.slice(a,void 0):c=e.slice(a,u),c=c.map(l=>l.isNull()?y.create(0):l),t===1&&r===1?c.get(0,0):c}}class G0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(0),s=r!=null?r:k.create(!1),a=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,n,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,C)=>{const _=l.get(d,C);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(m.isError())return m;if(_.isError())return _;const E=Math.trunc(+m.getValue()),b=+_.getValue();if(Number.isNaN(E)||E<0||E>3||Number.isNaN(b))return g.create(h.VALUE);if(!e.isArray())return e;let R=[];return b?R=this._getArrayValueByColumn(e,E):R=this._getArrayValueByRow(e,E),R.length===0?g.create(h.CALC):a>1||u>1||R.length===1?R[0]:K.create({calculateValueList:R.map(p=>[p]),rowCount:R.length,columnCount:1,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return a===1&&u===1?f.get(0,0):f}_getArrayValueByColumn(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<s;u++)for(let c=0;c<n;c++){const l=r.get(c,u);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_getArrayValueByRow(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){const l=r.get(u,c);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_isIgnore(e,t){switch(t){case 0:return!1;case 1:return e.isNull();case 2:return e.isError();case 3:return e.isNull()||e.isError();default:return!1}}}class W0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(0),s=r!=null?r:k.create(!1),a=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,n,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,C)=>{const _=l.get(d,C);if(e.isError())return e;if(m.isError())return m;if(_.isError())return _;const E=Math.trunc(+m.getValue()),b=+_.getValue();if(Number.isNaN(E)||E<0||E>3||Number.isNaN(b)||e.isNull())return g.create(h.VALUE);if(!e.isArray())return e;let R=[];return b?R=this._getArrayValueByColumn(e,E):R=this._getArrayValueByRow(e,E),R.length===0?g.create(h.CALC):a>1||u>1||R.length===1?R[0]:K.create({calculateValueList:[R],rowCount:1,columnCount:R.length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return a===1&&u===1?f.get(0,0):f}_getArrayValueByColumn(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<s;u++)for(let c=0;c<n;c++){const l=r.get(c,u);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_getArrayValueByRow(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){const l=r.get(u,c);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_isIgnore(e,t){switch(t){case 0:return!1;case 1:return e.isNull();case 2:return e.isError();case 3:return e.isNull()||e.isError();default:return!1}}}class Q0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount();return t===1&&r===1?e.get(0,0):e.transpose()}return e}}class q0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:k.create(!1),s=r!=null?r:k.create(!1),a=e.isArray()?e.getRowCount():1,u=e.isArray()?e.getColumnCount():1,c=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),l=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),f=O(c,l,n,g.create(h.NA)),m=O(c,l,s,g.create(h.NA)),d=f.map((C,_,E)=>{let b=C,R=m.get(_,E);if(e.isError())return e;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+b.getValue(),V=+R.getValue();let S;return!p&&a===1||p&&u===1?S=e:S=this._getResult(e,p,V),(c>1||l>1)&&(S!=null&&S.isArray())?S.get(0,0):S});return c===1&&l===1?d.get(0,0):d}_getResult(e,t,r){const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;let a=e.getArrayValue(),u=n,c=s;t&&(a=this._transposeArray(a),u=s,c=n);const l=this._getRepeatRows(a,u,c);if(l.length>0){const f=[];l.forEach(m=>{m.forEach((d,C)=>{(C!==0||r)&&f.push(d)})}),a=a.filter((m,d)=>!f.includes(d))}return a.length===0?g.create(h.CALC):(t&&(a=this._transposeArray(a)),K.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}))}_getRepeatRows(e,t,r){let n=[];for(let s=0;s<r;s++)if(s===0){const a=new Array(t).fill(null).map((u,c)=>({r:c,valueObject:e[c][s]}));n=this._getRepeatRowsByObjects(a)}else{if(n.length===0)break;let a=[];n.forEach(u=>{const c=u.map(f=>({r:f,valueObject:e[f][s]})),l=this._getRepeatRowsByObjects(c);a=a.concat(l)}),n=a}return n}_getRepeatRowsByObjects(e){const t=new Map;return e.forEach(r=>{const n=r.r,s=r.valueObject;let a=s.getValue();if(s.isNull()?a=null:s.isString()&&M.isRealNum(a)&&(a=+a),!t.has(a))t.set(a,[n]);else{const u=t.get(a);u.push(n),t.set(a,u)}}),Array.from(t.values()).filter(r=>r.length>1)}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}}class X0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return t;if(!t.isArray())return g.create(h.VALUE);if(r.isError())return r;if(n!=null&&n.isError())return n;const s=n!=null?n:k.create(!0);return Pa(e)&&Pa(s)&&r.isArray()?this._handleArrayColIndexNum(e,t,r,s):this._handleNonArrayColIndexNum(e,t,r,s)}_handleArrayColIndexNum(e,t,r,n){const s=e.isArray()?e.getFirstCell():e,a=this.getZeroOrOneByOneDefault(n);if(a==null)return g.create(h.VALUE);let u;const c=[];return r.iterator((l,f,m)=>{if(l==null)return u=g.create(h.VALUE),!1;const d=this._handleTableArray(s,t,l,a);if(d.isError())return u=d,!1;c[f]===void 0&&(c[f]=[]),c[f][m]=d}),u||Ht(c,c.length,c[0].length,this.unitId||"",this.subUnitId||"")}_handleNonArrayColIndexNum(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e),c=O(s,a,n);return u.map((l,f,m)=>{if(l.isError())return l;const d=c.get(f,m);if(d==null)return g.create(h.VALUE);if(d.isError())return d;const C=this.getZeroOrOneByOneDefault(d);return C==null?g.create(h.VALUE):this._handleTableArray(l,t,r,C)})}_handleTableArray(e,t,r,n){let s=this.getIndexNumValue(r);if(s instanceof g)return s;if(s=Math.floor(s),s<1)return g.create(h.VALUE);const a=t.slice(void 0,[0,1]);if(a==null)return g.create(h.VALUE);const u=t.slice(void 0,[s-1,s]);return u==null?g.create(h.REF):this._handleSingleObject(e,a,u,n)}_handleSingleObject(e,t,r,n){return n===0?this.equalSearch(e,t,r):this.binarySearch(e,t,r)}}class K0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=Math.max(...e.map(n=>n.isArray()?n.getColumnCount():1)),r=[];for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++){const l=[];for(let f=0;f<t;f++){let m=s;s.isArray()&&(m=s.get(c,f)),f>u-1||!m?l.push(g.create(h.NA)):l.push(m)}r.push(l)}}return K.create({calculateValueList:r,rowCount:r.length,columnCount:r[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class Z0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:g.create(h.NA);n.isNull()&&(n=g.create(h.NA));const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA)),m=l.mapValue((d,C,_)=>{const E=f.get(C,_);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(d.isError())return d;const b=Math.trunc(+d.getValue());if(s>1&&a>1||Number.isNaN(b))return g.create(h.VALUE);if(b<1)return g.create(h.NUM);const R=e.isArray()?e.getArrayValue().flat():[e],p=this._getWrapArray(R,b,E);return u>1||c>1||p.length===1&&p[0].length===1?p[0][0]:K.create({calculateValueList:p,rowCount:p.length,columnCount:p[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return u===1&&c===1?m.get(0,0):m}_getWrapArray(e,t,r){const n=Math.ceil(e.length/t),s=n>1?t:e.length,a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){a[c]||(a[c]=[]);const l=u*s+c;l<e.length?a[c].push(e[l].isNull()?y.create(0):e[l]):a[c].push(r)}return a}}class z0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:g.create(h.NA);n.isNull()&&(n=g.create(h.NA));const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA)),m=l.mapValue((d,C,_)=>{const E=f.get(C,_);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(d.isError())return d;const b=Math.trunc(+d.getValue());if(s>1&&a>1||Number.isNaN(b))return g.create(h.VALUE);if(b<1)return g.create(h.NUM);const R=e.isArray()?e.getArrayValue().flat():[e],p=this._getWrapArray(R,b,E);return u>1||c>1||p.length===1&&p[0].length===1?p[0][0]:K.create({calculateValueList:p,rowCount:p.length,columnCount:p[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return u===1&&c===1?m.get(0,0):m}_getWrapArray(e,t,r){const n=Math.ceil(e.length/t),s=n>1?t:e.length,a=[];for(let u=0;u<n;u++){const c=[];for(let l=0;l<s;l++){const f=u*s+l;f<e.length?c.push(e[f].isNull()?y.create(0):e[f]):c.push(r)}a.push(c)}return a}}class J0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){if(e.isError())return e;if(t.isError()||r.isError())return g.create(h.REF);if(!t.isArray()||!r.isArray())return g.create(h.VALUE);const u=t.getRowCount(),c=t.getColumnCount(),l=r.getRowCount(),f=r.getColumnCount();if(u!==1&&c!==1||u===1&&c>1&&c!==f||c===1&&u>1&&u!==l)return g.create(h.VALUE);if(n!=null&&n.isError()||s!=null&&s.isError()||a!=null&&a.isError())return g.create(h.NA);const m=n!=null?n:g.create(h.NA),d=this.getIndexNumValue(s||y.create(0));if(d instanceof g)return d;const C=this.getIndexNumValue(a||y.create(1));return C instanceof g?C:this._getResult(e,t,r,m,d,C,u,c,l,f)}_getResult(e,t,r,n,s,a,u,c,l,f){const m=e.isArray()?e.getRowCount():1,d=e.isArray()?e.getColumnCount():1;if(m>1||d>1){let b;return u===1?b=r.slice([0,1]):b=r.slice(void 0,[0,1]),b==null?g.create(h.NA):e.map(R=>{const p=this._checkErrorCombination(s,a);if(p)return p;const V=this._handleSingleObject(R,t,b,s,a);return V.isError()?n:V})}const C=e.isArray()?e.get(0,0):e;if(c===f&&u===l){const b=this._checkErrorCombination(s,a);if(b)return b;const R=this._handleSingleObject(C,t,r,s,a);return R.isError()?n:R}let _=0;c===f&&(_=1);const E=this._handleExpandObject(C,t,r,s,a,_);return E==null?g.create(h.NA):E}_handleExpandObject(e,t,r,n,s,a=0){if((s===2||s===-2)&&n!==2){const u=cs(s),c=us(n);return this.binarySearchExpand(e,t,r,a,u,c)}return n===2?this.fuzzySearchExpand(e,t,r,s!==-1,a):n===-1||n===1?this.orderSearchExpand(e,t,r,n===1?Oe.MAX:Oe.MIN,s===-1,a):this.equalSearchExpand(e,t,r,s!==-1,a)}_handleSingleObject(e,t,r,n,s){if((s===2||s===-2)&&n!==2){const a=cs(s),u=us(n);return this.binarySearch(e,t,r,a,u)}return n===2?this.fuzzySearch(e,t,r,s!==-1):n===-1||n===1?this.orderSearch(e,t,r,n===1?Oe.MAX:Oe.MIN,s===-1):this.equalSearch(e,t,r,s!==-1)}_checkErrorCombination(e,t){return e===2&&(t===-2||t===2)?g.create(h.VALUE):null}}class ed extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray())return g.create(h.VALUE);const s=t.getRowCount(),a=t.getColumnCount();if(s!==1&&a!==1)return g.create(h.VALUE);if(r!=null&&r.isError()||n!=null&&n.isError())return g.create(h.NA);const u=this.getIndexNumValue(r||y.create(0));if(u instanceof g)return u;const c=this.getIndexNumValue(n||y.create(1));return c instanceof g?c:e.isArray()?e.map(l=>this._handleSingleObject(l,t,u,c)):this._handleSingleObject(e,t,u,c)}_handleSingleObject(e,t,r,n){let s;if((n===2||n===-2)&&r!==2){const a=cs(n),u=us(r);s=t.binarySearch(e,a,u)}else if(r===2){const a=t.compare(e,$.EQUALS);let u;if(n!==-1?u=a.getFirstTruePosition():u=a.getLastTruePosition(),u==null)return g.create(h.NA);s=t.getRowCount()===1?u.column:u.row}else if(r===-1||r===1){const a=t.orderSearch(e,r===1?Oe.MAX:Oe.MIN,n===-1);if(a==null)return g.create(h.NA);if(a instanceof g)return a;s=t.getRowCount()===1?a.column:a.row}else{const a=t.isEqual(e);let u;if(n!==-1?u=a.getFirstTruePosition():u=a.getLastTruePosition(),u==null)return g.create(h.NA);s=t.getRowCount()===1?u.column:u.row}return s==null?g.create(h.NA):y.create(s+1)}}const uu=[[y0,me.ADDRESS],[p0,me.AREAS],[N0,me.CHOOSE],[V0,me.CHOOSECOLS],[O0,me.CHOOSEROWS],[M0,me.COLUMN],[S0,me.COLUMNS],[D0,me.DROP],[w0,me.EXPAND],[P0,me.FILTER],[L0,me.FORMULATEXT],[x0,me.HLOOKUP],[j0,me.HSTACK],[U0,me.INDEX],[v0,me.INDIRECT],[T0,me.LOOKUP],[B0,me.MATCH],[I0,me.OFFSET],[F0,me.ROW],[k0,me.ROWS],[$0,me.SORT],[Y0,me.SORTBY],[H0,me.TAKE],[G0,me.TOCOL],[W0,me.TOROW],[Q0,me.TRANSPOSE],[q0,me.UNIQUE],[X0,me.VLOOKUP],[K0,me.VSTACK],[Z0,me.WRAPCOLS],[z0,me.WRAPROWS],[J0,me.XLOOKUP],[ed,me.XMATCH]];class td extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.abs()}}class rd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.acos()}}class nd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.acosh()}}class sd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.isArray()?t.map(r=>r.isError()?r:Ga(r)):Ga(t)}}function Ga(i){let o=i.getValue();if(i.isBoolean()&&(o=o?1:0),!Number.isFinite(o))return g.create(h.VALUE);o=Number(o);let e=Math.atan(1/o);return o<0&&(e+=Math.PI),Number.isNaN(e)?g.create(h.VALUE):y.create(e)}class ad extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.isArray()?t.map(r=>r.isError()?r:Wa(r)):Wa(t)}}function Wa(i){let o=i.getValue();if(i.isBoolean()&&(o=o?1:0),!Number.isFinite(o))return g.create(h.VALUE);if(o=Number(o),Math.abs(o)<=1)return g.create(h.NUM);const e=1/2*Math.log((o+1)/(o-1));return Number.isNaN(e)?g.create(h.VALUE):y.create(e)}class id extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return y.create(0);if(e.isBoolean()||e.isNumber())return g.create(h.VALUE);let t=e.getValue().toLocaleString().toLocaleUpperCase();if(t.length>255)return g.create(h.VALUE);const r=t.startsWith("-");r&&(t=t.slice(1));let n=0;for(let s=0;s<t.length;s++){const a=Ir.get(t[s])||0,u=Ir.get(t[s+1])||0,c=Ir.get(t[s+2])||0,l=Ir.get(t[s+3])||0;if(!a||c>=u&&c>a||a===u&&a===c&&a===l||a===u/2)return g.create(h.VALUE);a<u?n-=a:n+=a}return y.create(r?-n:n)}}class od extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.asin()}}class ud extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.asinh()}}class cd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.atan()}}class ld extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e,n=t;return r.isString()&&(r=r.convertToNumberObjectValue()),r.isError()?r:(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:n.atan2(r))}}class fd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.atanh()}}class md extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(0);if(e.isError())return e;if(t.isError())return t;if(n.isError())return n;const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.map((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return this._handleSingleObject(m,_,E)});return f.getRowCount()===1&&f.getColumnCount()===1?f.getArrayValue()[0][0]:f}_handleSingleObject(e,t,r){let n=e;if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;let s=t;if(s.isString()&&(s=s.convertToNumberObjectValue()),s.isError())return s;let a=r;if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return a;const u=Math.floor(+n.getValue()),c=Math.floor(+s.getValue()),l=Math.floor(+a.getValue());if(u<0||u>=2**53||c<2||c>36||l<0)return g.create(h.NUM);let f=u.toString(c);return f.length<l&&(f=new Array(l-f.length+1).join("0")+f),j.create(f.toLocaleUpperCase())}}class hd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+m.getValue(),_=+d.getValue();if(C>0&&_<0)return g.create(h.NUM);if(C===0||_===0)return y.create(0);const E=Be(C/_,0)*_;return y.create(E)});return u.getRowCount()===1&&u.getColumnCount()===1?u.getArrayValue()[0][0]:u}}class gd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(1),s=r!=null?r:y.create(0);if(e.isError())return e;if(n.isError())return n;if(s.isError())return s;const a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.map((d,C,_)=>{let E=d,b=l.get(C,_),R=f.get(C,_);if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+E.getValue(),V=+b.getValue(),S=+R.getValue();return p===0||V===0?y.create(0):this._getResult(p,V,S)});return a===1&&u===1?m.get(0,0):m}_getResult(e,t,r){let n;return e<0&&r!==0?n=(t<0?Be(Math.abs(e)/Math.abs(t),0):-Be(Math.abs(e)/t,0))*t:n=(t<0?-Be(e/Math.abs(t),0):Be(e/t,0))*t,y.create(n)}}class dd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),C=l;if(C.isString()&&(C=C.convertToNumberObjectValue()),C.isError())return C;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+C.getValue(),E=+d.getValue();if(_===0||E===0)return y.create(0);const b=(E<0?-Be(_/Math.abs(E),0):Be(_/E,0))*E;return y.create(b)});return n===1&&s===1?c.get(0,0):c}}class Cd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),d.isString()&&(d=d.convertToNumberObjectValue()),m.isError())return m;if(d.isError())return d;const C=Math.floor(+m.getValue()),_=Math.floor(+d.getValue());if(C<0||_<0||C<_)return g.create(h.NUM);const E=kt(C,_);return Number.isNaN(E)||!Number.isFinite(E)?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class _d extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),d.isString()&&(d=d.convertToNumberObjectValue()),m.isError())return m;if(d.isError())return d;const C=Math.floor(+m.getValue()),_=Math.floor(+d.getValue());if(C<0||_<0||C===0&&C<_)return g.create(h.NUM);const E=kt(C+_-1,C-1);return Number.isNaN(E)||!Number.isFinite(E)?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Ad extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.cos()}}class Ed extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.cosh()}}class bd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):r===0?g.create(h.DIV_BY_ZERO):t.tan().getReciprocal()}}class yd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:+t.getValue()===0?g.create(h.DIV_BY_ZERO):t.tanh().getReciprocal()}}class Rd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):r===0?g.create(h.DIV_BY_ZERO):t.sin().getReciprocal()}}class pd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return r===0?g.create(h.DIV_BY_ZERO):!Number.isNaN(r)&&!Number.isFinite(Math.sinh(r))?y.create(0):t.sinh().getReciprocal()}}class Nd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{if(c.isError())return c;let m=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const d=`${c.getValue()}`,C=Math.floor(+m.getValue());if(M.isRealNum(d)&&(+d<0||+d>=2**53||!Number.isInteger(+d))||d.toLocaleLowerCase()==="true"||d.toLocaleLowerCase()==="false"||C<2||C>36)return g.create(h.NUM);if(d.replace(/\s/g,"")==="")return y.create(0);if(!this._isValidCharForRadix(d,C))return g.create(h.NUM);const _=Number.parseInt(d,C);return Number.isNaN(_)?g.create(h.NUM):y.create(_)});return r===1&&n===1?u.get(0,0):u}_isValidCharForRadix(e,t){for(const r of e){const n=r.toUpperCase().charCodeAt(0);if(t<=10&&!(n>=48&&n<48+t)||t>10&&!(n>=48&&n<58||n>=65&&n<65+t-10))return!1}return!0}}class Vd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=r*(180/Math.PI);return Number.isNaN(n)?g.create(h.VALUE):y.create(n)}}class Od extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=(r<0?-Be(Math.abs(r)/2,0):Be(r/2,0))*2;return Number.isNaN(n)?g.create(h.VALUE):n===0?y.create(0):y.create(n)}}class Md extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.exp()}}class Sd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue()),n=er(r);return Number.isNaN(n)||!Number.isFinite(n)?g.create(h.NUM):y.create(n)}}class Dd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(e.isArray()){const r=e.getRowCount(),n=e.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=e.get(0,0)}return this._handleSingleObject(t)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue()),n=er(r,2);return Number.isNaN(n)||!Number.isFinite(n)?g.create(h.NUM):y.create(n)}}class wd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=a.get(l,f),d=c;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const C=+d.getValue(),_=+m.getValue();if(C>0&&_<0)return g.create(h.NUM);if(C===0)return y.create(0);if(_===0)return g.create(h.DIV_BY_ZERO);const E=ke(C/_,0)*_;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Pd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(1),s=r!=null?r:y.create(0),a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.map((d,C,_)=>{let E=d,b=l.get(C,_),R=f.get(C,_);if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+E.getValue(),V=+b.getValue(),S=+R.getValue();if(p===0||V===0)return y.create(0);let D;return p<0&&S!==0?D=(V<0?ke(Math.abs(p)/Math.abs(V),0):-ke(Math.abs(p)/V,0))*V:D=(V<0?-ke(p/Math.abs(V),0):ke(p/V,0))*V,y.create(D)});return a===1&&u===1?m.get(0,0):m}}class Ld extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),C=l;if(C.isString()&&(C=C.convertToNumberObjectValue()),C.isError())return C;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+C.getValue(),E=+d.getValue();if(_===0||E===0)return y.create(0);const b=(E<0?-ke(_/Math.abs(E),0):ke(_/E,0))*E;return y.create(b)});return n===1&&s===1?c.get(0,0):c}}class xd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];if(!n.isNull())if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{if(u!=null&&u.isNull())return!0;const{isError:c,errorObject:l,number:f}=this._handleSingleObject(u);if(c)return s=!0,a=l,!1;t=bs(t,f)}),s)return a}else{const{isError:s,errorObject:a,number:u}=this._handleSingleObject(n);if(s)return a;t=bs(t,u)}}return y.create(t)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0||r>=2**53?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class jd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue());return y.create(r)}}class Ud extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=1,r=!0;for(let n=0;n<e.length;n++){const s=e[n];if(!s.isNull())if(s.isArray()){let a=!1,u=g.create(h.VALUE);if(s.iterator(c=>{if(c!=null&&c.isNull())return!0;const{isError:l,errorObject:f,number:m}=this._handleSingleObject(c);if(l)return a=!0,u=f,!1;t=Fa(t,m),r=!1}),a)return u}else{const{isError:a,errorObject:u,number:c}=this._handleSingleObject(s);if(a)return u;t=Fa(t,c),r=!1}}return r?y.create(0):Number.isNaN(t)||!Number.isFinite(t)||t>=2**53?g.create(h.VALUE):y.create(t)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class vd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.log()}}class Td extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(10);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),C=l;if(C.isString()&&(C=C.convertToNumberObjectValue()),C.isError())return C;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+C.getValue(),E=+d.getValue();if(_<=0||E<=0)return g.create(h.NUM);const b=Math.log(E);if(b===0)return g.create(h.DIV_BY_ZERO);const R=Math.log(_)/b;return y.create(R)});return n===1&&s===1?c.get(0,0):c}}class Bd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.log10()}}class Id extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){let l=e.isArray()?e.get(a,c):e;if(l.isError())return l;if(l.isNull()||l.isBoolean())return g.create(h.VALUE);if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;const f=+l.getValue();u.push(f)}n.push(u)}if(t!==r)return g.create(h.VALUE);const s=Tn(n);return y.create(s)}}class Fd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){let l=e.isArray()?e.get(a,c):e;if(l.isError())return l;if(l.isNull()||l.isBoolean())return g.create(h.VALUE);if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;const f=+l.getValue();u.push(f)}n.push(u)}if(t!==r)return g.create(h.VALUE);const s=hm(n);return s===null?g.create(h.NUM):K.createByArray(s)}}class kd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;if(n!==s)return g.create(h.VALUE);const u=this._getMatrix(e,r,n),c=this._getMatrix(t,s,a);if(u instanceof g)return u;if(c instanceof g)return c;const l=tr(u,c);return K.createByArray(l)}_getMatrix(e,t,r){const n=[];for(let s=0;s<t;s++){const a=[];for(let u=0;u<r;u++){let c=e.isArray()?e.get(s,u):e;if(c.isError())return c;if(c.isNull()||c.isBoolean())return g.create(h.VALUE);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;const l=+c.getValue();a.push(l)}n.push(a)}return n}}class $d extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.mod(n)}}class Yd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isArray()){const c=r.getRowCount(),l=r.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;let n=t;if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean()||n.isBoolean())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(Number.isNaN(s)||Number.isNaN(a))return g.create(h.VALUE);if(a===0)return y.create(0);if(s>0&&a<0||s<0&&a>0)return g.create(h.NUM);const u=Vt(s/a,0)*a;return y.create(u)}}class Hd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=1;for(let s=0;s<e.length;s++){const a=e[s];if(!a.isNull())if(a.isArray()){let u=!1,c=g.create(h.VALUE);if(a.iterator(l=>{if(l!=null&&l.isNull())return!0;const{isError:f,errorObject:m,number:d}=this._handleSingleObject(l);if(f)return u=!0,c=m,!1;if(t+=d,t>170)return u=!0,c=g.create(h.NUM),!1;r*=er(d)}),u)return c}else{const{isError:u,errorObject:c,number:l}=this._handleSingleObject(a);if(u)return c;if(t+=l,t>170)return g.create(h.NUM);r*=er(l)}}const n=er(t)/r;return y.create(n)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class Gd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount(),n=e.mapValue(s=>{const a=this._handleSingleObject(s);return a.isError()?a:t>1||r>1?a.get(0,0):a});return t===1&&r===1?n.get(0,0):n}return this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue());if(r<=0)return g.create(h.VALUE);const n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<r;a++)n[s][a]=s===a?1:0}return K.createByArray(n)}}class Wd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);let n=r<0?-Be(Math.abs(r),0):Be(r,0);return Number.isNaN(n)?g.create(h.VALUE):(Math.abs(n)%2===0&&(r<0?n--:n++),y.create(n))}}class Qd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return y.create(Math.PI)}}class qd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.pow(n)}}class Xd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(1);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isArray()&&(n=this._multiplyArray(n)),n.isError())return n;if(t=t.multiply(n),t.isError())return t}}return t}_multiplyArray(e){let t=y.create(1);return e.iterator(r=>{if(r==null||r.isString()||r.isBoolean()||r.isNull())return!0;if(r.isError())return t=r,!1;t=t.multiply(r)}),t}}class Kd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=H(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=+u.getValue();if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l===0)return g.create(h.DIV_BY_ZERO);const f=Math.trunc(c/l);return y.create(f)}}class Zd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=r*(Math.PI/180);return Number.isNaN(n)?g.create(h.VALUE):y.create(n)}}class zd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return y.create(Math.random())}}class Jd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",5);A(this,"needsSheetRowColumnCount",!0)}calculate(e,t,r,n,s){if(e!=null&&e.isError())return e;if(t!=null&&t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;const a=e!=null?e:y.create(1),u=t!=null?t:y.create(1),c=r!=null?r:y.create(0),l=n!=null?n:y.create(1),f=s!=null?s:y.create(0);return this._calculateResult(a,u,c,l,f)}_calculateResult(e,t,r,n,s){const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1);if(a===1&&u===1)return this._calculateSingleCell(e,t,r,n,s);const c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,n,g.create(h.NA)),d=O(a,u,s,g.create(h.NA));return c.map((C,_,E)=>{const b=l.get(_,E),R=f.get(_,E),p=m.get(_,E),V=d.get(_,E),S=this._handleError(C,b,R,p,V);if(S.errorObject)return S.errorObject;let{minValue:D,maxValue:w,wholeNumberValue:P}=S,L;return P?(D=Math.ceil(D),w=Math.floor(w),L=Math.floor(Math.random()*(w-D+1))+D):L=Math.random()*(w-D)+D,L<D||L>w?g.create(h.VALUE):y.create(L)})}_calculateSingleCell(e,t,r,n,s){let a=e;a.isArray()&&(a=a.get(0,0));let u=t;u.isArray()&&(u=u.get(0,0));let c=r;c.isArray()&&(c=c.get(0,0));let l=n;l.isArray()&&(l=l.get(0,0));let f=s;f.isArray()&&(f=f.get(0,0));const m=this._handleError(a,u,c,l,f);if(m.errorObject)return m.errorObject;let{rowsValue:d,columnsValue:C,minValue:_,maxValue:E,wholeNumberValue:b}=m;if(b&&(_=Math.ceil(_),E=Math.floor(E),_>E))return g.create(h.VALUE);const R=[];for(let p=0;p<d;p++){const V=[];for(let S=0;S<C;S++)b?V.push(Math.floor(Math.random()*(E-_+1))+_):V.push(Math.random()*(E-_)+_);R.push(V)}return d===1&&C===1?y.create(R[0][0]):K.createByArray(R)}_handleError(e,t,r,n,s){let a=e;if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return{errorObject:a};let u=t;if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return{errorObject:u};let c=r;if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return{errorObject:c};let l=n;if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return{errorObject:l};let f=s;return f.isString()&&(f=f.convertToNumberObjectValue()),f.isError()?{errorObject:f}:this._getValue(a,u,c,l,f)}_getValue(e,t,r,n,s){const a=Math.floor(+e.getValue()),u=Math.floor(+t.getValue());if(a===0||u===0)return{errorObject:g.create(h.CALC)};const c=this._rowCount-this.row,l=this._columnCount-this.column;if(a<0||u<0||a*u>10**7)return{errorObject:g.create(h.VALUE)};if(a>c||u>l)return{errorObject:g.create(h.REF)};const f=+r.getValue(),m=+n.getValue(),d=+s.getValue();return f>m?{errorObject:g.create(h.VALUE)}:d&&(!Number.isInteger(f)||!Number.isInteger(m))?{errorObject:g.create(h.VALUE)}:{rowsValue:a,columnsValue:u,minValue:f,maxValue:m,wholeNumberValue:d}}}class eC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isArray()){const c=r.getRowCount(),l=r.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;let n=t;if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean()||n.isBoolean())return g.create(h.VALUE);let s=+r.getValue(),a=+n.getValue();if(Number.isNaN(s)||Number.isNaN(a))return g.create(h.VALUE);if(s>a)return g.create(h.NUM);s=Math.ceil(s),a=Math.floor(a);const u=Math.floor(Math.random()*(a-s+1))+s;return y.create(u)}}class tC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e);if(r)return n;const[a]=s;let u=Math.floor(+a.getValue()),c=t;if(c.isString()&&(c=c.convertToNumberObjectValue(),c.isError()))return c;let l=Math.floor(+c.getValue());if(c.isBoolean()&&(l=c.getValue()?0:4),u<0||u>3999||l<0||l>4)return g.create(h.VALUE);const f=Am[l];let m=f.length-1,d="";for(;u>0;){m=this._binarySearch(u,0,m,f);const C=f[m];u-=C,d+=_m.get(C)}return j.create(d)}_binarySearch(e,t,r,n){let s=t,a=r;for(;a-s>1;){const u=Math.floor((s+a)/2),c=n[u];if(c===e)return u;c>e?a=u:s=u}return s!==a&&n[a]<=e?a:s}}class rC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.round(n)}}class nC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.floor(n)}}class sC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.ceil(n)}}class aC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):t.cos().getReciprocal()}}class iC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Number.isFinite(Math.cosh(r))?Math.abs(r)>=2**27?g.create(h.NUM):t.cosh().getReciprocal():y.create(0)}}class oC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4);A(this,"needsSheetRowColumnCount",!0)}calculate(e,t,r,n){let s=e,a=t!=null?t:y.create(1),u=r!=null?r:y.create(1),c=n!=null?n:y.create(1);s.isNull()&&(s=y.create(1)),a.isNull()&&(a=y.create(1)),u.isNull()&&(u=y.create(1)),c.isNull()&&(c=y.create(1));const l=Math.max(s.isArray()?s.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(s.isArray()?s.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,s,g.create(h.NA)),d=O(l,f,a,g.create(h.NA)),C=O(l,f,u,g.create(h.NA)),_=O(l,f,c,g.create(h.NA)),E=m.mapValue((b,R,p)=>{const V=d.get(R,p),S=C.get(R,p),D=_.get(R,p);return b.isError()?b:V.isError()?V:S.isError()?S:D.isError()?D:this._getResult(b,V,S,D,l,f)});return l===1&&f===1?E.get(0,0):E}_getResult(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=I(e,t,r,n);if(u)return c;const[f,m,d,C]=l,_=Math.floor(+f.getValue()),E=Math.floor(+m.getValue()),b=+d.getValue(),R=+C.getValue();if(_<0||E<0||_*E>10**7)return g.create(h.VALUE);if(_===0||E===0)return g.create(h.CALC);const p=this._rowCount-this.row,V=this._columnCount-this.column;if(_>p||E>V)return g.create(h.REF);const S=[];for(let D=0;D<_;D++){S[D]=[];for(let w=0;w<E;w++)S[D][w]=b+(D*E+w)*R}return s>1||a>1?y.create(S[0][0]):K.createByArray(S)}}class uC extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isNull()||t.isNull()||r.isNull()||n.isNull())return g.create(h.NA);const{isError:s,errorObject:a,variants:u}=H(e,t,r);if(s)return a;const{isError:c,errorObject:l,variants:f}=I(...u);if(c)return l;const[m,d,C]=f,_=+m.getValue(),E=+d.getValue(),b=+C.getValue(),R=[];if(n.isArray()){let V=!1,S=g.create(h.VALUE);if(n.iterator(D=>{const{isError:w,errorObject:P,coefficientsObject:L}=this._handleSingleObject(D);if(w)return V=!0,S=P,!1;const T=+L.getValue();R.push(T)}),V)return S}else{const{isError:V,errorObject:S,coefficientsObject:D}=this._handleSingleObject(n);if(V)return S;const w=+D.getValue();R.push(w)}let p=0;for(let V=0;V<R.length;V++)p+=R[V]*_**(E+V*b);return Number.isNaN(p)||!Number.isFinite(p)?g.create(h.NUM):y.create(p)}_handleSingleObject(e){if(e.isError())return{isError:!0,errorObject:e,coefficientsObject:null};if(e!=null&&e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),coefficientsObject:null};let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?{isError:!0,errorObject:t,coefficientsObject:null}:{isError:!1,errorObject:null,coefficientsObject:t}}}class cC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue();return a>0?y.create(1):a<0?y.create(-1):y.create(0)}}class lC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sin()}}class fC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sinh()}}class mC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sqrt()}}class hC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(r<0)return g.create(h.NUM);const n=Math.sqrt(r*Math.PI);return y.create(n)}}class gC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}calculate(e,...t){if(e.isError())return e;if(e.isReferenceObject()){const r=[];return e.iterator((n,s,a)=>{r[s]==null&&(r[s]=[]),r[s][a]=this._handleSingleObject(n,...t)}),Ht(r,r.length,r[0].length)}return this._handleSingleObject(e,...t)}_handleSingleObject(e,...t){const r=this._getIndexNumValue(e);let n;if(r instanceof g)return r;switch(r){case 1:n=this._average(!1,...t);break;case 2:n=this._count(!1,...t);break;case 3:n=this._counta(!1,...t);break;case 4:n=this._max(!1,...t);break;case 5:n=this._min(!1,...t);break;case 6:n=this._product(!1,...t);break;case 7:n=this._stdev(!1,...t);break;case 8:n=this._stdevp(!1,...t);break;case 9:n=this._sum(!1,...t);break;case 10:n=this._var(!1,...t);break;case 11:n=this._varp(!1,...t);break;case 101:n=this._average(!0,...t);break;case 102:n=this._count(!0,...t);break;case 103:n=this._counta(!0,...t);break;case 104:n=this._max(!0,...t);break;case 105:n=this._min(!0,...t);break;case 106:n=this._product(!0,...t);break;case 107:n=this._stdev(!0,...t);break;case 108:n=this._stdevp(!0,...t);break;case 109:n=this._sum(!0,...t);break;case 110:n=this._var(!0,...t);break;case 111:n=this._varp(!0,...t);break;default:n=g.create(h.VALUE)}return n}_getIndexNumValue(e){const t=e?Number(e.getValue()):0;if(Number.isNaN(t))return g.create(h.VALUE);const r=Math.floor(t);return r>=1&&r<=11||r>=101&&r<=111?r:g.create(h.VALUE)}_average(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:r.mean()}_count(e,...t){let r=y.create(0);for(let n=0;n<t.length;n++){const s=t[n];if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();s.iterator((u,c)=>{if(e&&this._isRowHidden(a,c))return!0;u!=null&&u.isNumber()&&(r=r.plusBy(1))})}return r}_counta(e,...t){let r=y.create(0);for(let n=0;n<t.length;n++){const s=t[n];if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();s.iterator((u,c)=>{if(e&&this._isRowHidden(a,c)||u==null||u.isNull())return!0;r=r.plusBy(1)})}return r}_max(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?y.create(0):r.max()}_min(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?y.create(0):r.min()}_product(e,...t){const r=this._flattenRefArray(e,...t);if(r.isError())return r;if(this._isBlankArrayObject(r))return y.create(0);let n=y.create(1);return r.iterator(s=>{n=n.multiply(s)}),n}_stdev(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.std(1)}_stdevp(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.std()}_sum(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:r.sum()}_var(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.var(1)}_varp(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.var()}_flattenRefArray(e,...t){const r=[];r[0]=[];for(let n=0;n<t.length;n++){const s=t[n];if(s.isError())return s;if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();let u;if(s.iterator((c,l)=>{if(e&&this._isRowHidden(a,l)||c==null||c.isNull()||c.isString()||c.isBoolean())return!0;if(c.isError())return u=c,!1;r[0].push(c)}),u!=null&&u.isError())return u}return Ht(r,1,r[0].length)}_isRowHidden(e,t){const r=e[t];return r?r.hd===M.BooleanNumber.TRUE:!1}_isBlankArrayObject(e){return e.getArrayValue()[0].length===0}}class dC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()||(n.isArray()&&(n=n.sum()),n.isError()))return n;if(t=t.plus(n),t.isError())return t}return t}}class CC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=t;if(t.isReferenceObject()&&(n=t.toArrayValueObject()),n.isArray()){const s=n.mapValue(a=>this._handleSingleObject(e,a,r));return s.getRowCount()===1&&s.getColumnCount()===1?s.get(0,0):s}return this._handleSingleObject(e,n,r)}_handleSingleObject(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;if(!e.isReferenceObject()||r&&!r.isReferenceObject())return g.create(h.VALUE);const n=e.toArrayValueObject();let s=jn(n,t);const[,a]=mr(`${t.getValue()}`);s=Un(s,n,a);const u=n.getRowCount(),c=n.getColumnCount();let l=n;if(r){l=r.toArrayValueObject();const f=l.getRowCount(),m=l.getColumnCount();if(u!==f||c!==m){const d=r.getRangeData();d.endRow=d.startRow+u-1,d.endColumn=d.startColumn+c-1,r.setRangeData(d),l=r.toArrayValueObject()}}return l.pick(s).sum()}}class _C extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;if(!e.isArray()||t.length<2||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=hr(t),s=Sr(t,e,r,n);if(s)return s;const a=Dr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>e.pick(a).sum())),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(n)}}class AC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=this._initArray1(e);if(t.length>0){const n=r.getRowCount(),s=r.getColumnCount();let a=this._getResultArrayByArray1(n,s,r);if(a instanceof g)return a;a=a;for(let c=0;c<t.length;c++){if(t[c].isError())return t[c];let l=1,f=1;if(t[c].isArray()&&(l=t[c].getRowCount(),f=t[c].getColumnCount()),l!==n||f!==s)return g.create(h.VALUE);for(let m=0;m<n;m++){const d=[];for(let C=0;C<s;C++){let _=t[c];if(t[c].isArray()&&(_=t[c].get(m,C)),_.isError())return _;const E=_.getValue();!E||!M.isRealNum(E)?d.push(0):d.push(+E*a[m][C])}a[m]=d}}const u=a.reduce((c,l)=>c.concat(l)).reduce((c,l)=>c+l,0);return y.create(u)}else return r.sum()}_initArray1(e){let t=e;return t.isArray()||(t=K.create({calculateValueList:[[t]],rowCount:1,columnCount:1,unitId:"",sheetId:"",row:0,column:0})),t}_getResultArrayByArray1(e,t,r){const n=[];for(let s=0;s<e;s++){const a=[];for(let u=0;u<t;u++){const c=r.get(s,u);if(c.isError())return c;const l=c.getValue();!l||!M.isRealNum(l)?a.push(0):a.push(+l)}n.push(a)}return n}}class EC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);const r=y.create(2);for(let n=0;n<e.length;n++){let s=e[n];if(s.isString()&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()?s.iterator(a=>{if(a==null||a.isString()||a.isBoolean()||a.isNull())return!0;if(a.isError())return t=a,!1;t=t.plus(a.pow(r))}):t=t.plus(s.pow(r)),t.isError())return t}return t}}class bC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ae.create();const d=[],C=[];let _=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),S=+p.getValue();d.push(V),C.push(S),_+=V**2-S**2}),m.isError()?m:d.length===0||C.length===0?g.create(h.DIV_BY_ZERO):y.create(_)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!M.isRealNum(s)||r.isBoolean()||n.isString()&&!M.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=s**2-a**2;return y.create(u)}}class yC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ae.create();const d=[],C=[];let _=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),S=+p.getValue();d.push(V),C.push(S),_+=V**2+S**2}),m.isError()?m:d.length===0||C.length===0?g.create(h.DIV_BY_ZERO):y.create(_)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!M.isRealNum(s)||r.isBoolean()||n.isString()&&!M.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=s**2+a**2;return y.create(u)}}class RC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ae.create();const d=[],C=[];let _=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),S=+p.getValue();d.push(V),C.push(S),_+=(V-S)**2}),m.isError()?m:d.length===0||C.length===0?g.create(h.DIV_BY_ZERO):y.create(_)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!M.isRealNum(s)||r.isBoolean()||n.isString()&&!M.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=(s-a)**2;return y.create(u)}}class pC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.tan()}}class NC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.tanh()}}class VC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),C=l;if(C.isString()&&(C=C.convertToNumberObjectValue()),C.isError())return C;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+C.getValue(),E=+d.getValue(),b=10**Math.trunc(E),R=Pn(_,b),p=Math.trunc(fr(_,b)+R)/b;return y.create(p)});return n===1&&s===1?c.get(0,0):c}}const cu=[[td,Y.ABS],[rd,Y.ACOS],[nd,Y.ACOSH],[sd,Y.ACOT],[ad,Y.ACOTH],[id,Y.ARABIC],[od,Y.ASIN],[ud,Y.ASINH],[cd,Y.ATAN],[ld,Y.ATAN2],[fd,Y.ATANH],[md,Y.BASE],[hd,Y.CEILING],[gd,Y.CEILING_MATH],[dd,Y.CEILING_PRECISE],[Cd,Y.COMBIN],[_d,Y.COMBINA],[Ad,Y.COS],[Ed,Y.COSH],[bd,Y.COT],[yd,Y.COTH],[Rd,Y.CSC],[pd,Y.CSCH],[Nd,Y.DECIMAL],[Vd,Y.DEGREES],[Od,Y.EVEN],[Md,Y.EXP],[Sd,Y.FACT],[Dd,Y.FACTDOUBLE],[wd,Y.FLOOR],[Pd,Y.FLOOR_MATH],[Ld,Y.FLOOR_PRECISE],[xd,Y.GCD],[jd,Y.INT],[Ud,Y.LCM],[vd,Y.LN],[Td,Y.LOG],[Bd,Y.LOG10],[Id,Y.MDETERM],[Fd,Y.MINVERSE],[kd,Y.MMULT],[$d,Y.MOD],[Yd,Y.MROUND],[Hd,Y.MULTINOMIAL],[Gd,Y.MUNIT],[Wd,Y.ODD],[Qd,Y.PI],[qd,Y.POWER],[Xd,Y.PRODUCT],[Kd,Y.QUOTIENT],[Zd,Y.RADIANS],[zd,Y.RAND],[Jd,Y.RANDARRAY],[eC,Y.RANDBETWEEN],[tC,Y.ROMAN],[rC,Y.ROUND],[nC,Y.ROUNDDOWN],[sC,Y.ROUNDUP],[aC,Y.SEC],[iC,Y.SECH],[uC,Y.SERIESSUM],[oC,Y.SEQUENCE],[cC,Y.SIGN],[lC,Y.SIN],[fC,Y.SINH],[mC,Y.SQRT],[hC,Y.SQRTPI],[gC,Y.SUBTOTAL],[dC,Y.SUM],[CC,Y.SUMIF],[_C,Y.SUMIFS],[AC,Y.SUMPRODUCT],[EC,Y.SUMSQ],[bC,Y.SUMX2MY2],[yC,Y.SUMX2PY2],[RC,Y.SUMXMY2],[pC,Y.TAN],[NC,Y.TANH],[VC,Y.TRUNC]];class OC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"_compareType",$.EQUALS)}setCompareType(e){this._compareType=e}calculate(e,t){return e.isError()?e:t.isError()?t:e.compare(t,this._compareType)}}class sa extends ht{constructor(e){super("");A(this,"_values",[]);this._values=e}static create(e){return new sa(e)}isCube(){return!0}dispose(){this._values.forEach(e=>{e.dispose()}),this._values=[]}sum(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.sum())}),e}max(){let e=y.create(Number.NEGATIVE_INFINITY);return this._values.forEach(t=>{const r=t.max();e.isLessThan(r)&&(e=r)}),e}min(){let e=y.create(Number.POSITIVE_INFINITY);return this._values.forEach(t=>{const r=t.max();e.isGreaterThan(r)&&(e=r)}),e}count(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.count())}),e}countA(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.countA())}),e}countBlank(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.countBlank())}),e}}class MC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isError())return n;if(!n.isArray())return g.create(h.VALUE);t.push(n)}return sa.create(t)}}class SC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:!t.isArray()&&t.getValue()===0?g.create(h.DIV_BY_ZERO):e.divided(t)}}class DC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.minus(t)}}class wC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.multiply(t)}}class PC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.plus(t)}}const lu=[[OC,Le.COMPARE],[SC,Le.DIVIDED],[DC,Le.MINUS],[wC,Le.MULTIPLY],[PC,Le.PLUS],[MC,Le.CUBE]];class LC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let a=0;a<e.length;a++){let u=e[a];if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(u.isArray()){if(u=xC(u),u.isError())return u;if(e[a]=u,t=t.plus(u.sum()),t.isError())return t;r=r.plus(u.count())}else u.isNull()||(t=t.plus(u),r=r.plus(y.create(1)))}if(r.getValue()===0)return g.create(h.NUM);const n=t.divided(r);if(n.isError())return n;let s=y.create(0);for(let a=0;a<e.length;a++){let u=e[a];if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(u.isArray()){if(s=s.plus(u.minus(n).abs().sum()),s.isError())return s}else u.isNull()||(s=s.plus(u.minus(n).abs()))}return s.divided(r)}}function xC(i){const o=[];o[0]=[];let e=null;return i.iterator((t,r,n)=>{if(t!=null&&t.isError())return e=t,!1;t!=null&&t.isNumber()&&o[0].push(t)}),e||Ht(o,1,o[0].length)}class jC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let n=0;n<e.length;n++){let s=e[n];if((s.isString()||s.isBoolean())&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()){if(t=t.plus(s.sum()),t.isError())return t;r=r.plus(s.count())}else s.isNull()||(t=t.plus(s),r=r.plus(y.create(1)))}return t.divided(r)}}class UC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let n=0;n<e.length;n++){let s=e[n];if((s.isString()||s.isBoolean())&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a==null||a.isNull())return!0;let u=a;if(u.isString()&&(u=u.convertToNumberObjectValue(),u.isError()&&(u=y.create(0))),u.isBoolean()&&(u=u.convertToNumberObjectValue()),u.isError())return t=u,!1;t=t.plus(u),r=r.plus(y.create(1))}),t.isError())return t}else s.isNull()||(t=t.plus(s),r=r.plus(y.create(1)))}return t.divided(r)}}class vC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject()),n.isArray()||(n=Ht([[n]],1,1));let s=t;return s.isReferenceObject()&&(s=s.toArrayValueObject()),r&&!(r!=null&&r.isReferenceObject())?g.create(h.NA):(s=s,s.isArray()?s.map(a=>this._handleSingleObject(n,a,r)):this._handleSingleObject(n,s,r))}_handleSingleObject(e,t,r){let n=jn(e,t);const[,s]=mr(`${t.getValue()}`);n=Un(n,e,s);let a=r?this._createRangeReferenceObject(r,e):e;if(!a)return g.create(h.VALUE);if(a.isError())return a;a.isReferenceObject()&&(a=a.toArrayValueObject()),a=a;const u=a.pick(n),c=u.sum(),l=u.count();return c.divided(l)}_createRangeReferenceObject(e,t){const r=e.getRowCount(),n=e.getColumnCount(),s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;if(r===s&&n===a)return e;const{startRow:u,startColumn:c}=e.getRangePosition(),l={startRow:u,startColumn:c,endRow:u+s-1,endColumn:c+a-1};return this.createReferenceObject(e,l)}}class TC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=hr(t),s=Sr(t,e,r,n);if(s)return s;const a=Dr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a),c=u.sum(),l=u.count();return c.divided(l)})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(n)}}class BC extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=s!=null?s:y.create(0),c=a!=null?a:y.create(1);u.isNull()&&(u=y.create(0)),c.isNull()&&(c=y.create(1));const l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),C=O(l,f,r,g.create(h.NA)),_=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.mapValue((p,V,S)=>{const D=d.get(V,S),w=C.get(V,S),P=_.get(V,S),L=E.get(V,S),T=b.get(V,S);return this._handleSignleObject(p,D,w,P,L,T)});return l===1&&f===1?R.get(0,0):R}_handleSignleObject(e,t,r,n,s,a){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;if(a.isError())return a;const{isError:u,errorObject:c,variants:l}=I(e,t,r,n,s,a);if(u)return c;const[f,m,d,C,_,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+C.getValue(),S=+_.getValue(),D=+E.getValue();if(R<=0||p<=0||b<S||b>D||S===D)return g.create(h.NUM);let w;return V?w=to((b-S)/(D-S),R,p):w=Em((b-S)/(D-S),R,p)/(D-S),y.create(w)}}class IC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){let s=n!=null?n:r;s.isNull()&&(s=r);const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,s,g.create(h.NA)),d=c.mapValue((C,_,E)=>{const b=l.get(_,E),R=f.get(_,E),p=m.get(_,E);return C.isError()?C:b.isError()?b:R.isError()?R:p.isError()?p:this._handleSignleObject(C,b,R,p)});return a===1&&u===1?d.get(0,0):d}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),C=+l.getValue(),_=Math.floor(+f.getValue()),E=Math.floor(+m.getValue());if(d<0||C<0||C>1||_<0||_>d||E<0||E<_||E>d)return g.create(h.NUM);let b=0;for(let R=_;R<=E;R++)b+=Ws(R,d,C);return y.create(b)}}class FC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=+l.getValue();if(f<0||m<1||m>10**10)return g.create(h.NUM);let C;return d?C=Qs(f,m):C=bm(f,m),y.create(C)}}class kC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=no(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class $C extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);if(f.isError())return f;if(C.isError())return C;if(_.isError())return _;const{isError:E,errorObject:b,variants:R}=I(f,C,_);if(E)return b;const[p,V,S]=R,D=+p.getValue(),w=+V.getValue(),P=Math.floor(+S.getValue());if(D<=0||D>=1||w<=0||P<1)return g.create(h.NUM);if(P===1)return g.create(h.DIV_BY_ZERO);const L=Math.abs(zs(D/2,P-1)*w/Math.sqrt(P));return y.create(L)});return n===1&&s===1?l.get(0,0):l}}class YC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++){const C=e[d]-a,_=t[d]-u;c+=C*_,l+=C**2,f+=_**2}const m=Math.sqrt(l*f);return m===0?g.create(h.DIV_BY_ZERO):y.create(c/m)}}class HC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){const n=e[r];n.isError()||(n.isArray()?t=t.plus(n.count()):n.isString()?n.convertToNumberObjectValue().isError()||(t=t.plus(y.create(1))):n.isNull()||(t=t.plus(y.create(1))))}return t}}class GC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){let n=e[r];if(n.isError()){t=t.plus(y.create(1));continue}n.isArray()?(n=n.countA(),t=t.plus(n)):n.isNull()||(t=t.plus(y.create(1)))}return t}}class WC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.getValue()===""||e.isNull()?y.create(1):e.isArray()?e.countBlank():y.create(0)}}class QC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()||t.isError()?g.create(h.NA):e.isArray()?t.isArray()?t.mapValue(r=>this._handleSingleObject(e,r)):this._handleSingleObject(e,t):g.create(h.VALUE)}_handleSingleObject(e,t){let r=jn(e,t);const[,n]=mr(`${t.getValue()}`);r=Un(r,e,n);const s=e.pick(r);return this._countA(s)}_countA(e){let t=y.create(0);return e.iterator(r=>{if(r==null)return!0;t=t.plusBy(1)}),t}}class qC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(...e){if(e.length%2!==0||e.some((a,u)=>u%2===0&&!a.isArray()))return g.create(h.VALUE);const{maxRowLength:t,maxColumnLength:r}=hr(e),n=Sr(e,e[0],t,r);if(n)return n;const s=Dr(e,t,r,!0);return this._aggregateResults(s)}_aggregateResults(e){const t=e.map(n=>n.map(s=>XC(s))),r={calculateValueList:t,rowCount:t.length,columnCount:t[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(r)}}function XC(i){let o=0;return i.iterator(e=>{e!=null&&e.isBoolean()&&e.getValue()===!0&&o++}),y.create(o)}class KC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length<=1)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let l=0;l<r;l++)n+=e[l],s+=t[l];const a=n/r,u=s/r;let c=0;for(let l=0;l<r;l++){const f=e[l]-a,m=t[l]-u;c+=f*m}return y.create(c/(r-1))}}class ZC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0,n=!0;for(let u=0;u<e.length;u++){const c=e[u];if(c.isArray()){let l=!1,f=g.create(h.VALUE);if(c.iterator(m=>{const d=this._handleSingleObject(m);if(d.isError())return l=!0,f=d,!1;if(d.isNull())return!0;const C=d.getValue();t.push(C),r+=C,n=!1}),l)return f}else{const l=this._handleSingleObject(c);if(l.isError())return l;if(l.isNull())continue;const f=l.getValue();t.push(f),r+=f,n=!1}}if(n)return g.create(h.NUM);const s=r/t.length;let a=0;for(let u=0;u<t.length;u++)a+=(t[u]-s)**2;return y.create(a)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull()||e.isBoolean())return ae.create();const t=e.getValue();return M.isRealNum(t)?y.create(+t):ae.create()}}class zC extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=Math.floor(+l.getValue()),_=Math.floor(+f.getValue()),E=+m.getValue();if(d<0||C<1||C>10**10||_<1||_>10**10)return g.create(h.NUM);let b;return E?b=qs(d,C,_):b=ym(d,C,_),Number.isNaN(b)||!Number.isFinite(b)?g.create(h.NUM):y.create(b)}}class JC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||f>1||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const C=so(f,m,d);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class e_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=s.getValue();if(a<=-1||a>=1)return g.create(h.NUM);const u=Math.log((1+a)/(1-a))/2;return y.create(u)}}class t_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.exp(2*a)-1,c=Math.exp(2*a)+1;return!Number.isFinite(u)&&u>0&&!Number.isFinite(c)&&c>0?y.create(1):y.create(u/c)}}class Qa extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=t.isArray()?t.getRowCount():1,s=t.isArray()?t.getColumnCount():1,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;let c=t;t.isArray()&&n===1&&s===1&&(c=t.get(0,0));let l=r;return r.isArray()&&a===1&&u===1&&(l=r.get(0,0)),e.isArray()?e.mapValue(f=>this._handleSignleObject(f,c,l,n,s,a,u)):this._handleSignleObject(e,c,l,n,s,a,u)}_handleSignleObject(e,t,r,n,s,a,u){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;let c=e;if(e.isString()&&(c=e.convertToNumberObjectValue()),c.isError())return c;const l=+c.getValue();if((n*s===1||a*u===1)&&(t.isNull()||r.isNull()))return g.create(h.VALUE);if(n*s!==a*u)return g.create(h.NA);const{isError:f,errorObject:m,array1Values:d,array2Values:C,noCalculate:_}=Ge(t,r,n*s,s,u);if(f)return m;if(_)return g.create(h.DIV_BY_ZERO);const E=ao(l,d,C);return Number.isFinite(E)?y.create(E):g.create(h.DIV_BY_ZERO)}}class r_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,values:s}=this._getValues(e);if(r)return n;if(e.isNull()||t.isNull())return g.create(h.VALUE);let{values:a}=this._getValues(t,!0);a.length===0&&(a=[0]);const u=this._getNewBinsArrayValues(a),c=new Array(u.length).fill(0);for(let l=0;l<s.length;l++){const f=s[l],m=u.findIndex(d=>f>d.start&&f<=d.end);c[m]++}return K.createByArray(c.map(l=>[l]))}_getValues(e,t=!1){const r=[],n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;for(let a=0;a<n;a++)for(let u=0;u<s;u++){const c=e.isArray()?e.get(a,u):e;if(c.isError()){if(!t)return{isError:!0,errorObject:c,values:r};continue}if(c.isNull()||c.isBoolean())continue;const l=c.getValue();M.isRealNum(l)&&r.push(+l)}return{isError:!1,errorObject:null,values:r}}_getNewBinsArrayValues(e){const t=e.map((n,s)=>({value:n,index:s})).sort((n,s)=>n.value-s.value),r=[];for(let n=0;n<t.length;n++){const s=t[n].index;if(n===0){r[s]={start:-1/0,end:t[n].value};continue}r[s]={start:t[n-1].value,end:t[n].value}}return r.push({start:t[t.length-1].value,end:1/0}),r}}var U=(i=>(i.AVEDEV="AVEDEV",i.AVERAGE="AVERAGE",i.AVERAGEA="AVERAGEA",i.AVERAGEIF="AVERAGEIF",i.AVERAGEIFS="AVERAGEIFS",i.BETA_DIST="BETA.DIST",i.BETA_INV="BETA.INV",i.BINOM_DIST="BINOM.DIST",i.BINOM_DIST_RANGE="BINOM.DIST.RANGE",i.BINOM_INV="BINOM.INV",i.CHISQ_DIST="CHISQ.DIST",i.CHISQ_DIST_RT="CHISQ.DIST.RT",i.CHISQ_INV="CHISQ.INV",i.CHISQ_INV_RT="CHISQ.INV.RT",i.CHISQ_TEST="CHISQ.TEST",i.CONFIDENCE_NORM="CONFIDENCE.NORM",i.CONFIDENCE_T="CONFIDENCE.T",i.CORREL="CORREL",i.COUNT="COUNT",i.COUNTA="COUNTA",i.COUNTBLANK="COUNTBLANK",i.COUNTIF="COUNTIF",i.COUNTIFS="COUNTIFS",i.COVARIANCE_P="COVARIANCE.P",i.COVARIANCE_S="COVARIANCE.S",i.DEVSQ="DEVSQ",i.EXPON_DIST="EXPON.DIST",i.F_DIST="F.DIST",i.F_DIST_RT="F.DIST.RT",i.F_INV="F.INV",i.F_INV_RT="F.INV.RT",i.F_TEST="F.TEST",i.FISHER="FISHER",i.FISHERINV="FISHERINV",i.FORECAST="FORECAST",i.FORECAST_ETS="FORECAST.ETS",i.FORECAST_ETS_CONFINT="FORECAST.ETS.CONFINT",i.FORECAST_ETS_SEASONALITY="FORECAST.ETS.SEASONALITY",i.FORECAST_ETS_STAT="FORECAST.ETS.STAT",i.FORECAST_LINEAR="FORECAST.LINEAR",i.FREQUENCY="FREQUENCY",i.GAMMA="GAMMA",i.GAMMA_DIST="GAMMA.DIST",i.GAMMA_INV="GAMMA.INV",i.GAMMALN="GAMMALN",i.GAMMALN_PRECISE="GAMMALN.PRECISE",i.GAUSS="GAUSS",i.GEOMEAN="GEOMEAN",i.GROWTH="GROWTH",i.HARMEAN="HARMEAN",i.HYPGEOM_DIST="HYPGEOM.DIST",i.INTERCEPT="INTERCEPT",i.KURT="KURT",i.LARGE="LARGE",i.LINEST="LINEST",i.LOGEST="LOGEST",i.LOGNORM_DIST="LOGNORM.DIST",i.LOGNORM_INV="LOGNORM.INV",i.MAX="MAX",i.MAXA="MAXA",i.MAXIFS="MAXIFS",i.MEDIAN="MEDIAN",i.MIN="MIN",i.MINA="MINA",i.MINIFS="MINIFS",i.MODE_MULT="MODE.MULT",i.MODE_SNGL="MODE.SNGL",i.NEGBINOM_DIST="NEGBINOM.DIST",i.NORM_DIST="NORM.DIST",i.NORM_INV="NORM.INV",i.NORM_S_DIST="NORM.S.DIST",i.NORM_S_INV="NORM.S.INV",i.PEARSON="PEARSON",i.PERCENTILE_EXC="PERCENTILE.EXC",i.PERCENTILE_INC="PERCENTILE.INC",i.PERCENTRANK_EXC="PERCENTRANK.EXC",i.PERCENTRANK_INC="PERCENTRANK.INC",i.PERMUT="PERMUT",i.PERMUTATIONA="PERMUTATIONA",i.PHI="PHI",i.POISSON_DIST="POISSON.DIST",i.PROB="PROB",i.QUARTILE_EXC="QUARTILE.EXC",i.QUARTILE_INC="QUARTILE.INC",i.RANK_AVG="RANK.AVG",i.RANK_EQ="RANK.EQ",i.RSQ="RSQ",i.SKEW="SKEW",i.SKEW_P="SKEW.P",i.SLOPE="SLOPE",i.SMALL="SMALL",i.STANDARDIZE="STANDARDIZE",i.STDEV_P="STDEV.P",i.STDEV_S="STDEV.S",i.STDEVA="STDEVA",i.STDEVPA="STDEVPA",i.STEYX="STEYX",i.T_DIST="T.DIST",i.T_DIST_2T="T.DIST.2T",i.T_DIST_RT="T.DIST.RT",i.T_INV="T.INV",i.T_INV_2T="T.INV.2T",i.T_TEST="T.TEST",i.TREND="TREND",i.TRIMMEAN="TRIMMEAN",i.VAR_P="VAR.P",i.VAR_S="VAR.S",i.VARA="VARA",i.VARPA="VARPA",i.WEIBULL_DIST="WEIBULL.DIST",i.Z_TEST="Z.TEST",i))(U||{});class n_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue();if(a===0||a<0&&a%1===0)return g.create(h.NUM);const u=Qr(a);return Number.isNaN(u)||!Number.isFinite(u)?g.create(h.NUM):y.create(u)}}class qa extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue();if(a<=0)return g.create(h.NUM);const u=rt(a);return Math.abs(u)<1e-15?y.create(0):y.create(u)}}class s_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Pr(a,0,1)-.5;return y.create(u)}}class a_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=1,r=0,n=!1;for(let a=0;a<e.length;a++){const u=e[a];if(u.isArray()){let c=!1,l=g.create(h.VALUE);if(u.iterator(f=>{if(f!=null&&f.isError())return c=!0,l=f,!1;if(f!=null&&f.isNull()||f!=null&&f.isBoolean())return!0;const m=f.getValue();if(!M.isRealNum(m))return!0;+m<=0&&(n=!0),t*=+m,r++}),c)return l}else{if(u.isError())return u;if(u.isString()){const l=u.convertToNumberObjectValue();if(l.isError())return l}if(u.isNull()||u.isBoolean())continue;const c=u.getValue();if(!M.isRealNum(c))continue;+c<=0&&(n=!0),t*=+c,r++}}if(r===0||n)return g.create(h.NUM);const s=t**(1/r);return y.create(s)}}class i_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=this._getValues(e,s,a);if(u instanceof g)return u;const c=this._getKnownXsValues(s,a,t);if(c instanceof g)return c;const l=this._getNewXsValues(c,s,a,r);if(l instanceof g)return l;let f=n!=null?n:k.create(!0);if(f.isArray()&&(f=f.get(0,0)),f.isString()&&(f=f.convertToNumberObjectValue()),f.isError())return f;const m=+f.getValue();return this._getResult(u,c,l,m)}_getResult(e,t,r,n){return e.length===1&&t.length>1||e[0].length===1&&t[0].length>1?this._getResultByMultipleVariables(e,t,r,n):this._getResultBySimpleVariables(e,t,r,n)}_getResultByMultipleVariables(e,t,r,n){const s=e.length===1&&e[0].length>1;let a=[],u=[];s?(a=yt(e).map(_=>_.map(E=>Math.log(E))),u=n?yt(t).map(_=>[..._,1]):yt(t)):(a=e.map(_=>_.map(E=>Math.log(E))),u=n?t.map(_=>[..._,1]):t);const c=yt(u),l=tr(c,u),f=tr(c,a),m=dm(l);if(!m)return g.create(h.NA);const d=tr(m,f).map(_=>_[0]);let C=[];return s?(C=yt(r).map(_=>{const b=(n?[..._,1]:_).reduce((R,p,V)=>R+p*d[V],0);return[Math.exp(b)]}),C=yt(C)):C=r.map(_=>{const b=(n?[..._,1]:_).reduce((R,p,V)=>R+p*d[V],0);return[Math.exp(b)]}),K.createByArray(C)}_getResultBySimpleVariables(e,t,r,n){const s=r.length,a=r[0].length,u=e.flat(),c=t.flat(),l=r.flat(),f=u.map(_=>Math.log(_));let m,d;n?{slope:m,intercept:d}=this._getSlopeAndInterceptOfConstbIsTrue(c,f):{slope:m,intercept:d}=this._getSlopeAndInterceptOfConstbIsFalse(c,f),Number.isNaN(m)&&!n&&(m=0);const C=[];for(let _=0;_<s;_++){const E=[];for(let b=0;b<a;b++){const R=d*m**l[_*a+b];E.push(R)}C.push(E)}return K.createByArray(C)}_getSlopeAndInterceptOfConstbIsTrue(e,t){const r=t.length;let n=0,s=0,a=0,u=0;for(let m=0;m<r;m++)n+=e[m],s+=t[m],a+=e[m]*e[m],u+=e[m]*t[m];const l=(r*u-n*s)/(r*a-n*n),f=1/r*s-l*(1/r)*n;return{slope:Math.exp(l),intercept:Math.exp(f)}}_getSlopeAndInterceptOfConstbIsFalse(e,t){const r=[[...e]],n=[...t];let s=r.length,a=r[0].length,u=Math.min(s,a);const c=new Array(u).fill(0);for(let f=0;f<u;f++){const m=r[f];let d=0;for(let _=0;_<a;_++)d+=m[_]**2;const C=m[f]<0?Math.sqrt(d):-Math.sqrt(d);if(c[f]=C,C!==0){m[f]-=C;for(let _=f+1;_<s;_++){let E=0;for(let b=f;b<a;b++)E-=r[_][b]*m[b];E/=C*m[f];for(let b=f;b<a;b++)r[_][b]-=E*m[b]}}}s=r.length,a=r[0].length,u=Math.min(s,a);const l=new Array(s).fill(0);for(let f=0;f<u;f++){const m=r[f];let d=0;for(let C=0;C<a;C++)d+=n[C]*m[C];d/=c[f]*m[f];for(let C=0;C<a;C++)n[C]+=d*m[C]}for(let f=c.length-1;f>=0;f--){n[f]/=c[f];const m=n[f],d=r[f];l[f]=m;for(let C=0;C<f;C++)n[C]-=m*d[C]}return{slope:Math.exp(l[0]),intercept:Math.exp(0)}}_getKnownXsValues(e,t,r){if(!r||r.isNull())return this._getNumberValuesByRowsColumns(e,t);if(r.isError())return r;const n=r.isArray()?r.getRowCount():1,s=r.isArray()?r.getColumnCount():1;return e===1&&s!==t||t===1&&n!==e||e!==1&&t!==1&&(n!==e||s!==t)?g.create(h.REF):this._getValues(r,n,s)}_getNewXsValues(e,t,r,n){if(!n||n.isNull())return e;if(n.isError())return n;const s=n.isArray()?n.getRowCount():1,a=n.isArray()?n.getColumnCount():1;return t===1&&e.length>1&&s!==e.length||r===1&&e[0].length>1&&a!==e[0].length?g.create(h.REF):this._getValues(n,s,a)}_getValues(e,t,r){const n=[];for(let s=0;s<t;s++){n[s]=[];for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())return g.create(h.VALUE);const c=u.getValue();if(!M.isRealNum(c))return g.create(h.VALUE);n[s].push(+c)}}return n}_getNumberValuesByRowsColumns(e,t){const r=[];let n=1;for(let s=0;s<e;s++){r[s]=[];for(let a=0;a<t;a++)r[s].push(n++)}return r}}class o_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=0,n=!1;for(let a=0;a<e.length;a++){const u=e[a];if(u.isArray()){let c=!1,l=g.create(h.VALUE);if(u.iterator(f=>{if(f!=null&&f.isError())return c=!0,l=f,!1;if(f!=null&&f.isNull()||f!=null&&f.isBoolean())return!0;const m=f.getValue();if(!M.isRealNum(m))return!0;+m<=0&&(n=!0),t+=1/+m,r++}),c)return l}else{if(u.isError())return u;if(u.isString()){const l=u.convertToNumberObjectValue();if(l.isError())return l}if(u.isNull()||u.isBoolean())continue;const c=u.getValue();if(!M.isRealNum(c))continue;+c<=0&&(n=!0),t+=1/+c,r++}}if(r===0)return g.create(h.NA);if(n)return g.create(h.NUM);const s=r/t;return y.create(s)}}class u_ extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,n,g.create(h.NA)),d=O(a,u,s,g.create(h.NA)),C=c.mapValue((_,E,b)=>{const R=l.get(E,b),p=f.get(E,b),V=m.get(E,b),S=d.get(E,b);return _.isError()?_:R.isError()?R:p.isError()?p:V.isError()?V:S.isError()?S:this._handleSignleObject(_,R,p,V,S)});return a===1&&u===1?C.get(0,0):C}_handleSignleObject(e,t,r,n,s){const{isError:a,errorObject:u,variants:c}=I(e,t,r,n,s);if(a)return u;const[l,f,m,d,C]=c,_=Math.floor(+l.getValue()),E=Math.floor(+f.getValue()),b=Math.floor(+m.getValue()),R=Math.floor(+d.getValue()),p=+C.getValue();if(_<0||_>E||_>b||_<E-R+b||E<=0||E>R||b<=0||b>R||R<=0)return g.create(h.NUM);let V;return p?V=Mm(_,E,b,R):V=Ks(_,E,b,R),Number.isNaN(V)&&(V=0),y.create(V)}}class c_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=ao(0,e,t);return Number.isFinite(r)?y.create(r):g.create(h.DIV_BY_ZERO)}}class l_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();M.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=3?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/(r-1));if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**4;const c=r*(r+1)/((r-1)*(r-2)*(r-3))*u-3*(r-1)**2/((r-2)*(r-3));return y.create(c)}}class f_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s;let u=+a.getValue();return u<1||u>e.length?g.create(h.NUM):(u=Math.ceil(u),y.create(e[u-1]))}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>a-s)}}class m_ extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),C=+l.getValue(),_=+f.getValue(),E=+m.getValue();if(d<=0||_<=0)return g.create(h.NUM);let b;return E?b=oo(d,C,_):b=Sm(d,C,_),y.create(b)}}class h_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.NEGATIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isArray()&&(n=n.max()),n.isError())return n;t=this._validator(t,n)}}return t.getValue()===Number.NEGATIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isLessThan(t);let n=e;return r.getValue()&&(n=t),n}}class g_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.NEGATIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()&&n.iterator(s=>{let a=s;if((a==null||a.isNull()||a.isString())&&(a=y.create(0)),a.isBoolean()&&(a=a.convertToNumberObjectValue()),a.isError())return t=a,!1;t=this._validator(t,a)}),t.isError())return t;t=this._validator(t,n)}}return t.getValue()===Number.NEGATIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isLessThan(t);let n=e;return r.getValue()&&(n=t),n}}class d_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=hr(t),s=Sr(t,e,r,n);if(s)return s;const a=Dr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a);return u.getColumnCount()===0?K.create("0"):u.max()})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(n)}}class C_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{if(u!=null&&u.isError())return s=!0,a=u,!1;if(u!=null&&u.isNull()||u!=null&&u.isBoolean())return!0;const c=u.getValue();if(!M.isRealNum(c))return!0;t.push(+c)}),s)return a}else{if(n.isError())return n;if(n.isNull()||n.isBoolean())continue;if(n.isString()){const a=n.convertToNumberObjectValue();if(a.isError())return a}const s=n.getValue();if(!M.isRealNum(s))continue;t.push(+s)}}return t.length===0?g.create(h.NUM):this._getResult(t.sort((r,n)=>r-n))}_getResult(e){const t=e.length;let r;if(t%2===0){const n=t/2;r=(e[n-1]+e[n])/2}else r=e[Math.floor(t/2)];return y.create(r)}}class __ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.POSITIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isArray()&&(n=n.min()),n.isError())return n;t=this._validator(t,n)}}return t.getValue()===Number.POSITIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isGreaterThan(t);let n=e;return r.getValue()&&(n=t),n}}class A_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.POSITIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()&&n.iterator(s=>{let a=s;if((a==null||a.isNull()||a.isString())&&(a=y.create(0)),a.isBoolean()&&(a=a.convertToNumberObjectValue()),a.isError())return t=a,!1;t=this._validator(t,a)}),t.isError())return t;t=this._validator(t,n)}}return t.getValue()===Number.POSITIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isGreaterThan(t);let n=e;return r.getValue()&&(n=t),n}}class E_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=hr(t),s=Sr(t,e,r,n);if(s)return s;const a=Dr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a);return u.getColumnCount()===0?K.create("0"):u.min()})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return K.create(n)}}class b_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t={};let r=0,n=1;for(let s=0;s<e.length;s++){const a=e[s];if(a.isError())return a;if(a.isString()){const l=a.convertToNumberObjectValue();if(l.isError())return l}const u=a.isArray()?a.getRowCount():1,c=a.isArray()?a.getColumnCount():1;for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=a.isArray()?a.get(l,f):a;if(m.isError())return m;if(m.isNull()||m.isBoolean()||m.isString())continue;const d=m.getValue();M.isRealNum(d)&&(t[+d]?(t[+d].count++,t[+d].count>n&&(n=t[+d].count)):t[+d]={count:1,order:r++})}}return r===0||n===1?new g(h.NA):this._getResult(t,n)}_getResult(e,t){const r=Object.entries(e).filter(([n,{count:s}])=>s===t).sort((n,s)=>n[1].order-s[1].order).map(([n])=>+n);return r.length===1?y.create(r[0]):K.createByArray(r.map(n=>[n]))}}class y_ extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),C=Math.floor(+l.getValue()),_=+f.getValue(),E=+m.getValue();if(d<0||C<1||_<=0||_>=1)return g.create(h.NUM);let b;return E?b=wm(d,C,_):b=Zs(d,C,_),y.create(b)}}class R_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=+u.getValue();let f;return l?f=Pr(c,0,1):f=uo(c,0,1),y.create(f)}}class p_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(l===0||f===0)return g.create(h.DIV_BY_ZERO);const m=c/Math.sqrt(l*f);return y.create(m)}}class N_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=+a.getValue(),c=e.length;if(u<1/(c+1)||u>1-1/(c+1))return g.create(h.NUM);const l=u*(c+1)-1,f=Math.floor(l),m=l-f;if(m===0)return y.create(e[f]);const d=e[f]+m*(e[f+1]-e[f]);return y.create(d)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class V_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getValues(e);let s=r!=null?r:y.create(3);s.isNull()&&(s=y.create(3));const a=Math.max(t.isArray()?t.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(t.isArray()?t.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,t,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,C)=>{const _=l.get(d,C);return m.isError()?m:_.isError()?_:this._handleSingleObject(n,m,_)});return a===1&&u===1?f.get(0,0):f}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=I(t,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=Math.floor(+c.getValue()),m=e.length;if(m===0||l<e[0]||l>e[m-1])return g.create(h.NA);if(m===1)return l===e[0]?y.create(1):g.create(h.NA);let d=0,C=!1,_=0;for(;!C&&_<m;)l===e[_]?(d=(_+1)/(m+1),C=!0):l>e[_]&&_+1<m&&l<e[_+1]&&(d=(_+1+(l-e[_])/(e[_+1]-e[_]))/(m+1),C=!0),_++;return C?f<1?g.create(h.NUM):(d=ke(d,f),y.create(d)):g.create(h.NA)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.sort((s,a)=>s-a)}}class O_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const{isError:d,errorObject:C,variants:_}=I(c,m);if(d)return C;const[E,b]=_,R=Math.floor(+E.getValue()),p=Math.floor(+b.getValue());if(R<0||R>=2147483647||p<0||R<p)return g.create(h.NUM);let V=1;for(let S=R-p+1;S<=R;S++)V*=S;return Number.isFinite(V)?y.create(V):g.create(h.NUM)});return r===1&&n===1?u.get(0,0):u}}class M_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const{isError:d,errorObject:C,variants:_}=I(c,m);if(d)return C;const[E,b]=_,R=Math.floor(+E.getValue()),p=Math.floor(+b.getValue());if(R<0||R>=2147483647||p<0)return g.create(h.NUM);if(R===0)return p===0?y.create(1):y.create(0);const V=R**p;return Number.isFinite(V)?y.create(V):g.create(h.NUM)});return r===1&&n===1?u.get(0,0):u}}class S_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.exp(-.5*a*a)/Math.sqrt(2*Math.PI);return y.create(u)}}class D_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a,xRangeValues:u,probRangeValues:c}=this._handleXRangeAndProbRange(e,t);let l=n!=null?n:r;n!=null&&n.isNull()&&(l=r);const f=Math.max(r.isArray()?r.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(r.isArray()?r.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,r,g.create(h.NA)),C=O(f,m,l,g.create(h.NA)),_=d.mapValue((E,b,R)=>{const p=C.get(b,R);return e.isError()?e:t.isError()?t:E.isError()?E:p.isError()?p:s?a:this._handleSignleObject(u,c,E,p)});return f===1&&m===1?_.get(0,0):_}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(r,n);if(s)return a;const[c,l]=u,f=+c.getValue(),m=+l.getValue();if(t.reduce((C,_)=>C+_,0)!==1)return g.create(h.NUM);let d=0;for(let C=0;C<e.length;C++)e[C]>=f&&e[C]<=m&&(d+=t[C]);return y.create(d)}_handleXRangeAndProbRange(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return{isError:!0,errorObject:u,xRangeValues:[],probRangeValues:[]};let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return{isError:!0,errorObject:c,xRangeValues:[],probRangeValues:[]};if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return{isError:!0,errorObject:g.create(h.VALUE),xRangeValues:[],probRangeValues:[]};if(r*n!==s*a)return{isError:!0,errorObject:g.create(h.NA),xRangeValues:[],probRangeValues:[]};const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?{isError:!0,errorObject:f,xRangeValues:[],probRangeValues:[]}:C?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),xRangeValues:[],probRangeValues:[]}:{isError:!1,errorObject:null,xRangeValues:m,probRangeValues:d}}}class w_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<=0||u>=4)return g.create(h.NUM);const c=u/4,l=e.length;if(c<1/(l+1)||c>1-1/(l+1))return g.create(h.NUM);const f=c*(l+1)-1,m=Math.floor(f),d=f-m;if(d===0)return y.create(e[m]);const C=e[m]+d*(e[m+1]-e[m]);return y.create(C)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class P_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),C=m.map((_,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+_.getValue(),V=+R.getValue();return Number.isNaN(p)||Number.isNaN(V)?g.create(h.VALUE):this._getResult(p,V,u)});return l===1&&f===1?C.get(0,0):C}_getResult(e,t,r){const n=r.sort((c,l)=>t?c-l:l-c);let s=n.indexOf(e);const a=[];for(;s>=0;){const c=s+1;a.push(c),s=n.indexOf(e,c)}if(a.length===0)return g.create(h.NA);const u=a.reduce((c,l)=>c+l,0)/a.length;return y.create(u)}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class L_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),C=m.map((_,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+_.getValue(),V=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);const D=u.sort((w,P)=>V?w-P:P-w).indexOf(p);return D===-1?g.create(h.NA):y.create(D+1)});return l===1&&f===1?C.get(0,0):C}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class x_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length===0)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(l===0||f===0)return g.create(h.DIV_BY_ZERO);const m=(c/Math.sqrt(l*f))**2;return y.create(m)}}class j_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();M.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=2?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/(r-1));if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**3;const c=r/((r-1)*(r-2))*u;return y.create(c)}}class U_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();M.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=2?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/r);if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**3;const c=u/r;return y.create(c)}}class v_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let m=0;m<r;m++)n+=e[m],s+=t[m];const a=n/r,u=s/r;let c=0,l=0;for(let m=0;m<r;m++)c+=(e[m]-a)*(t[m]-u),l+=(t[m]-u)**2;if(l===0)return g.create(h.DIV_BY_ZERO);const f=c/l;return y.create(f)}}class T_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s;let u=+a.getValue();return u<1||u>e.length?g.create(h.NUM):(u=Math.floor(u),y.create(e[u-1]))}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class B_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(d<=0)return g.create(h.NUM);const C=(f-m)/d;return y.create(C)}}class I_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.std(1)}}class F_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.std()}}class k_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:C}=Ge(e,t,r*n,n,a);return l?f:C?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;if(r<=2)return g.create(h.DIV_BY_ZERO);let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(f===0)return g.create(h.DIV_BY_ZERO);const m=Math.sqrt((l-c**2/f)/(r-2));return Number.isNaN(m)||!Number.isFinite(m)?g.create(h.NUM):y.create(m)}}class $_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSignleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=+l.getValue();if(m<1)return g.create(h.NUM);let C;return d?C=Lr(f,m):C=Lm(f,m),Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}}class Y_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||l<1||l>10**10)return g.create(h.NUM);const f=Lr(-c,l)*2;return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class H_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(l<1||l>10**10)return g.create(h.NUM);const f=Lr(-c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class G_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<=0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=zs(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class W_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=+a.getValue();if(u<0||u>=1)return g.create(h.NUM);const c=ke(e.length*u/2,0)*2,l=e.slice(c/2,e.length-c/2),f=l.reduce((m,d)=>m+d,0)/l.length;return y.create(f)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();M.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class Q_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.var(1)}}class q_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.var()}}const fu=[[LC,U.AVEDEV],[jC,U.AVERAGE],[UC,U.AVERAGEA],[vC,U.AVERAGEIF],[TC,U.AVERAGEIFS],[BC,U.BETA_DIST],[lo,U.BETA_INV],[fo,U.BINOM_DIST],[IC,U.BINOM_DIST_RANGE],[mo,U.BINOM_INV],[FC,U.CHISQ_DIST],[ho,U.CHISQ_DIST_RT],[kC,U.CHISQ_INV],[go,U.CHISQ_INV_RT],[Co,U.CHISQ_TEST],[_o,U.CONFIDENCE_NORM],[$C,U.CONFIDENCE_T],[YC,U.CORREL],[HC,U.COUNT],[GC,U.COUNTA],[WC,U.COUNTBLANK],[QC,U.COUNTIF],[qC,U.COUNTIFS],[Ao,U.COVARIANCE_P],[KC,U.COVARIANCE_S],[ZC,U.DEVSQ],[Eo,U.EXPON_DIST],[zC,U.F_DIST],[bo,U.F_DIST_RT],[JC,U.F_INV],[yo,U.F_INV_RT],[Ro,U.F_TEST],[e_,U.FISHER],[t_,U.FISHERINV],[Qa,U.FORECAST],[Qa,U.FORECAST_LINEAR],[r_,U.FREQUENCY],[n_,U.GAMMA],[po,U.GAMMA_DIST],[No,U.GAMMA_INV],[qa,U.GAMMALN],[qa,U.GAMMALN_PRECISE],[s_,U.GAUSS],[a_,U.GEOMEAN],[i_,U.GROWTH],[o_,U.HARMEAN],[u_,U.HYPGEOM_DIST],[c_,U.INTERCEPT],[l_,U.KURT],[f_,U.LARGE],[m_,U.LOGNORM_DIST],[Vo,U.LOGNORM_INV],[h_,U.MAX],[g_,U.MAXA],[d_,U.MAXIFS],[C_,U.MEDIAN],[__,U.MIN],[A_,U.MINA],[E_,U.MINIFS],[b_,U.MODE_MULT],[Oo,U.MODE_SNGL],[y_,U.NEGBINOM_DIST],[Mo,U.NORM_DIST],[So,U.NORM_INV],[R_,U.NORM_S_DIST],[Do,U.NORM_S_INV],[p_,U.PEARSON],[N_,U.PERCENTILE_EXC],[wo,U.PERCENTILE_INC],[V_,U.PERCENTRANK_EXC],[Po,U.PERCENTRANK_INC],[O_,U.PERMUT],[M_,U.PERMUTATIONA],[S_,U.PHI],[Lo,U.POISSON_DIST],[D_,U.PROB],[w_,U.QUARTILE_EXC],[xo,U.QUARTILE_INC],[P_,U.RANK_AVG],[L_,U.RANK_EQ],[x_,U.RSQ],[j_,U.SKEW],[U_,U.SKEW_P],[v_,U.SLOPE],[T_,U.SMALL],[B_,U.STANDARDIZE],[jo,U.STDEV_P],[Uo,U.STDEV_S],[I_,U.STDEVA],[F_,U.STDEVPA],[k_,U.STEYX],[$_,U.T_DIST],[Y_,U.T_DIST_2T],[H_,U.T_DIST_RT],[G_,U.T_INV],[vo,U.T_INV_2T],[To,U.T_TEST],[W_,U.TRIMMEAN],[Bo,U.VAR_P],[Io,U.VAR_S],[Q_,U.VARA],[q_,U.VARPA],[Fo,U.WEIBULL_DIST],[ko,U.Z_TEST]];class X_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r=t!=null?t:y.create(0);if(t!=null&&t.isNull()&&(r=y.create(0)),r.isArray()){const n=r.mapValue(s=>this._handleSingleObject(e,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(e,r)}_handleSingleObject(e,t){const r=this._checkArray(e);if(r.isError())return r;const{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=+u.getValue(),l=e.isArray()?e.getRowCount():1,f=e.isArray()?e.getColumnCount():1;let m="";for(let d=0;d<l;d++)for(let C=0;C<f;C++){const _=e.isArray()?e.get(d,C):e;let E=`${_.getValue()}`;_.isNull()&&(E=""),_.isBoolean()&&(E=E.toLocaleUpperCase()),_.isString()&&c?m+=`"${E}"`:m+=E,d===l-1&&C===f-1||(c?C===f-1?m+=";":m+=",":m+=", ")}return c&&(m=`{${m}}`),m.length>32767?g.create(h.CALC):j.create(m)}_checkArray(e){if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount();return t>1||r>1?e:e.get(0,0)}return e}}class K_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isNull()||e.isBoolean()||e.isNumber())return e;const t=e.getValue().toLocaleString();let r="";for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);s===12288?s=32:s>=65281&&s<=65374&&(s-=65248),r+=String.fromCharCode(s)}return j.create(r)}}class Z_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.abs(Number.parseInt(a.toString(),10)),c=Number.parseFloat((Math.abs(a)-u).toFixed(2));let l="";return u===0?c!==0?l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(c*100)}สตางค์`:l="ศูนย์บาทถ้วน":c===0?l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(u)}บาทถ้วน`:l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(u)}บาท${this._convertNumberToThaiText(c*100)}สตางค์`,j.create(l)}_convertNumberToThaiText(e){const t=["ล้าน","สิบ","ร้อย","พัน","หมื่น","แสน",""],r=["ศูนย์","หนึ่ง","สอง","สาม","สี่","ห้า","หก","เจ็ด","แปด","เก้า"],n=["ลบ","บาท","ถ้วน","สตางค์","ยี่","เอ็ด",","," ","฿"],s=e.toString(),a=s.length;let u="";for(let c=a;c>0;c--){const l=Number.parseInt(s.charAt(a-c),10);let f=r[l];const m=c>1?(c-1)%6:6;if(m===1&&l===2&&(f=n[4]),l===1)switch(m){case 0:case 6:u+=c<a?n[5]:f;break;case 1:break;default:u+=f;break}else if(l===0){m===0&&(u+=t[m]);continue}else u+=f;u+=t[m]}return u}}const z_=Object.values(M.DataStreamTreeTokenType).filter(i=>[M.DataStreamTreeTokenType.TABLE_START,M.DataStreamTreeTokenType.TABLE_ROW_START,M.DataStreamTreeTokenType.TABLE_CELL_START,M.DataStreamTreeTokenType.TABLE_CELL_END,M.DataStreamTreeTokenType.TABLE_ROW_END,M.DataStreamTreeTokenType.TABLE_END,M.DataStreamTreeTokenType.CUSTOM_BLOCK].includes(i));class J_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=Math.floor(+s.getValue());if(a<=0)return g.create(h.VALUE);let u=String.fromCharCode(a);return z_.some(c=>c===u)&&(u=""),j.create(u)}}class eA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isBoolean()||e.isNumber())return e;if(e.isNull())return j.create("");const r=`${e.getValue()}`.replace(/[\0-\x1F]/g,"");return j.create(r)}}class tA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);let t=e.getValue().toLocaleString();if(e.isBoolean()&&(t=t.toLocaleUpperCase()),t==="")return g.create(h.VALUE);const r=t.charCodeAt(0);return y.create(r)}}class rA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="",r=null;for(const n of e)if(n.isArray()){if(n.iterator(s=>{if(s==null||s.isNull())return!0;if(s.isError())return r=s,!1;s.isBoolean()?t+=`${s.getValue()}`.toLocaleUpperCase():(s.isString()||s.isNumber())&&(t+=s.getValue())}),r)return r}else!n.isError()&&!n.isNull()&&(t+=n.getValue());return j.create(t)}}class nA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=0;e.forEach(s=>{if(s.isArray()){const a=s;t=Math.max(t,a.getRowCount()),r=Math.max(r,a.getColumnCount())}else t=Math.max(t,1),r=Math.max(r,1)});let n=null;for(const s of e)n=O(t,r,s,g.create(h.NA)).mapValue((u,c,l)=>{const f=n&&n.get(c,l);if(f!=null&&f.isError())return f;if(u.isError())return u;let m=f==null?void 0:f.getValue(),d=u==null?void 0:u.getValue();f!=null&&f.isBoolean()&&(m=`${m}`.toLocaleUpperCase()),u!=null&&u.isBoolean()&&(d=`${d}`.toLocaleUpperCase());const C=f!=null&&f.isNull()?"":m!=null?m:"",_=u!=null&&u.isNull()?"":d!=null?d:"";return j.create(`${C}${_}`)});return n||g.create(h.VALUE)}}class sA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return j.create("");let t=`${e.getValue()}`;e.isBoolean()&&(t=t.toLocaleUpperCase());let r="";for(let n=0;n<t.length;n++){const s=t.charCodeAt(n);s>=33&&s<=126?r+=String.fromCharCode(s+65248):s===32?r+=" ":r+=t.charAt(n)}return j.create(r)}}class aA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"needsLocale",!0)}calculate(e,t){let r=t!=null?t:y.create(2);r.isNull()&&(r=y.create(2));const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(e,t);if(r)return n;const[a,u]=s;let c=+a.getValue(),l=Math.trunc(+u.getValue());if(l>127)return g.create(h.VALUE);l<0&&(`${c}`.length<Math.abs(l)?c=0:c=c<0?-Vt(Math.abs(c),l):Vt(c,l),l=0);const f=Uc(this.getLocale(),c,l);return j.create(f)}}class iA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,ae.create()),a=O(r,n,t,ae.create()),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSingleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSingleObject(e,t){if(e.isNull()||t.isNull()){const a=e.isNull()&&t.isNull();return k.create(a)}let r=`${e.getValue()}`;e.isBoolean()&&(r=r.toLocaleUpperCase());let n=`${t.getValue()}`;t.isBoolean()&&(n=n.toLocaleUpperCase());const s=r===n;return k.create(s)}}const aa=(i,o)=>M.numfmt.format(i,o,{throws:!1}),Me=i=>{let o=`${i.getValue()}`;return i.isNull()&&(o=""),i.isBoolean()&&(o=o.toLocaleUpperCase()),i.isNumber()&&(i.getPattern()!==""?o=aa(i.getPattern(),+i.getValue()):o=`${Ui(+i.getValue())}`),o};class oA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return m.isError()?m:_.isError()?_:E.isError()?E:this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Me(e),s=Me(t),{isError:a,errorObject:u,variants:c}=I(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);return m===-1?g.create(h.VALUE):y.create(m+1)}}function ia(i){let o=0;for(let e=0;e<i.length;e++)o+=Ur(i,e);return o}function Ur(i,o,e="ltr"){return uA(i,o,e)>255?2:1}function Xa(i){return i>=55296&&i<=56319}function Ka(i){return i>=56320&&i<=57343}function Za(i,o){const e=(i&1023)<<10,t=o&1023;return e+t+65536}function uA(i,o,e="ltr"){const t=i.charCodeAt(o);if(e==="ltr"&&Xa(t)&&o+1<i.length){const r=i.charCodeAt(o+1);if(Ka(r))return Za(t,r)}if(e==="rtl"&&Ka(t)&&o-1>=0){const r=i.charCodeAt(o-1);if(Xa(r))return Za(r,t)}return t}class cA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return m.isError()?m:_.isError()?_:E.isError()?E:this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Me(e),s=Me(t),{isError:a,errorObject:u,variants:c}=I(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);if(m===-1)return g.create(h.VALUE);const d=ia(s.substring(0,m))+1;return y.create(d)}}class lA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){let n=t!=null?t:y.create(2);n.isNull()&&(n=y.create(2));let s=r!=null?r:k.create(!1);s.isNull()&&(s=k.create(!1));const a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.mapValue((d,C,_)=>{const E=l.get(C,_),b=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:this._handleSingleObject(d,E,b)});return a===1&&u===1?m.get(0,0):m}_handleSingleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=I(e,t,r);if(n)return s;const[u,c,l]=a;let f=+u.getValue(),m=Math.trunc(+c.getValue());const d=+l.getValue();if(m>127)return g.create(h.VALUE);m<0&&(`${f}`.length<Math.abs(m)?f=0:f=f<0?-Vt(Math.abs(f),m):Vt(f,m),m=0);let C=d?"###0":"#,##0";m>0&&(C+=`.${"0".repeat(m)}`);const _=aa(C,f);return j.create(_)}}class fA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Me(e),{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return j.create("");if(c>=r.length)return j.create(r);const l=r.substring(0,c);return j.create(l)}}class mA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,ae.create()),u=O(n,s,r,ae.create()),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Me(e),{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return j.create("");let l=0,f=0,m="";for(;f<c&&l<r.length;)f+=Ur(r,l),m+=r.charAt(l),l++;return j.create(m)}}class hA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleText(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleText(e)}_handleSingleText(e){if(e.isError())return e;const t=Me(e);return y.create(t.length)}}class gA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleText(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleText(e)}_handleSingleText(e){if(e.isError())return e;const t=Me(e),r=ia(t);return y.create(r)}}class dA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return j.create("");const t=`${e.getValue()}`.toLocaleLowerCase();return j.create(t)}}class CA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSingleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSingleObject(e,t,r){const n=Me(e),{isError:s,errorObject:a,variants:u}=I(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);if(e.isNull()||f>n.length||m===0)return j.create("");const d=n.substring(f-1,f-1+m);return j.create(d)}}class _A extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const C=u.get(m,d),_=c.get(m,d);return f.isError()?f:C.isError()?C:_.isError()?_:this._handleSingleObject(f,C,_)});return n===1&&s===1?l.get(0,0):l}_handleSingleObject(e,t,r){let n=Me(e);const{isError:s,errorObject:a,variants:u}=I(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);if(e.isNull()||f>n.length||m===0)return j.create("");n=n.substring(f-1);let d=0,C=0,_="";for(;C<m&&d<n.length;)C+=Ur(n,d),_+=n.charAt(d),d++;return j.create(_)}}class AA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:j.create("."),s=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,r!=null&&r.isArray()?r.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,r!=null&&r.isArray()?r.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,n,g.create(h.NA)),l=r?O(s,a,r,g.create(h.NA)):void 0,f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=r?l.get(d,C):void 0;return m.isError()?m:_.isError()?_:E!=null&&E.isError()?E:_.isNull()||E!=null&&E.isNull()?g.create(h.VALUE):m.isNull()?y.create(0):this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){let n=`${e.getValue()}`;n=n.replace(/\s+/g,"");let s=`${t.getValue()}`;t.isBoolean()&&(s=s.toLocaleUpperCase()),s=s.charAt(0);let a;if(r&&(a=`${r.getValue()}`,r.isBoolean()&&(a=a.toLocaleUpperCase()),a=a.charAt(0),s===a))return g.create(h.VALUE);if(n.trim()==="")return y.create(0);if(!n.match(/^\s*[+-]?\s*(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?[ \t]*/))return g.create(h.VALUE);const u=n.split(s);if(u.length>2)return g.create(h.VALUE);let c=u[0].replace(/,/g,"");r&&(c=c.split(a).join(""));let l=0;if(u.length===1){s===","&&(c=c.replace(/\./g,""));let f=0;for(;c.endsWith("%");)c=c.slice(0,-1),f++;f>0?l=+c/100**f:l=+c}else{if(!M.isRealNum(c))return g.create(h.VALUE);let f=u[1],m=0;for(;f.endsWith("%");)f=f.slice(0,-1),m++;const d=`${c}.${f}`;if(!M.isRealNum(d))return g.create(h.VALUE);m>0?l=+d/100**m:l=+d}return Number.isNaN(l)?g.create(h.VALUE):y.create(l)}}class EA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isNull()||e.isBoolean()||e.isNumber())return e;const r=e.getValue().toLocaleString().toLocaleLowerCase().replace(/(^|\b|\W|\d|_)[a-z]/g,n=>n.toLocaleUpperCase());return j.create(r)}}const mu=()=>[{type:4,from:48,to:57}],hu=()=>[{type:7,value:95},{type:4,from:97,to:122},{type:4,from:65,to:90},{type:4,from:48,to:57}],gu=()=>[{type:7,value:9},{type:7,value:10},{type:7,value:11},{type:7,value:12},{type:7,value:13},{type:7,value:32},{type:7,value:160},{type:7,value:5760},{type:4,from:8192,to:8202},{type:7,value:8232},{type:7,value:8233},{type:7,value:8239},{type:7,value:8287},{type:7,value:12288},{type:7,value:65279}],du=()=>({type:3,set:hu(),not:!1}),Cu=()=>({type:3,set:hu(),not:!0}),_u=()=>({type:3,set:mu(),not:!1}),Au=()=>({type:3,set:mu(),not:!0}),Eu=()=>({type:3,set:gu(),not:!1}),bu=()=>({type:3,set:gu(),not:!0}),bA=()=>({type:3,set:[{type:7,value:10},{type:7,value:13},{type:7,value:8232},{type:7,value:8233}],not:!0});function yA(i){const o={type:0,stack:[]};let e=o,t=o.stack;const r=[],n=[];let s=0;const a=f=>{throw new SyntaxError(`Invalid regular expression: /${i}/: Nothing to repeat at column ${f-1}`)},u=pA(i);let c=0,l;for(;c<u.length;)switch(l=u[c++],l){case"\\":if(c===u.length)throw new SyntaxError(`Invalid regular expression: /${i}/: \\ at end of pattern`);switch(l=u[c++],l){case"b":t.push({type:2,value:"b"});break;case"B":t.push({type:2,value:"B"});break;case"w":t.push(du());break;case"W":t.push(Cu());break;case"d":t.push(_u());break;case"D":t.push(Au());break;case"s":t.push(Eu());break;case"S":t.push(bu());break;default:if(/\d/.test(l)){for(;/\d/.test(u[c])&&c<u.length;)l+=u[c++];const f=Number.parseInt(l,10);t.push({type:6,value:f}),n.push({reference:{type:6,value:f},stack:t,index:t.length-1})}else t.push({type:7,value:l.charCodeAt(0)})}break;case"^":t.push({type:2,value:"^"});break;case"$":t.push({type:2,value:"$"});break;case"[":{const f=u[c]==="^";f&&c++;const m=RA(u.slice(c),i);c+=m[1],t.push({type:3,set:m[0],not:f});break}case".":t.push(bA());break;case"(":{const f={type:1,stack:[],remember:!0};if(u[c]==="?"){const m=u[c+1];if(c+=2,m==="=")f.followedBy=!0;else if(m==="!")f.notFollowedBy=!0;else if(m!==":")throw new SyntaxError(`Invalid regular expression: /${i}/: Invalid group, character '${m}' after '?' at column ${c-1}`);f.remember=!1}else s+=1;t.push(f),r.push(e),e=f,t=f.stack;break}case")":if(r.length===0)throw new SyntaxError(`Invalid regular expression: /${i}/: Unmatched ) at column ${c-1}`);e=r.pop(),t=e.options?e.options[e.options.length-1]:e.stack;break;case"|":{e.options||(e.options=[e.stack],delete e.stack);const f=[];e.options.push(f),t=f;break}case"{":{const f=/^(\d+)(,(\d+)?)?\}/.exec(u.slice(c));if(f){t.length===0&&a(c);const m=Number.parseInt(f[1],10),d=f[2]?f[3]?Number.parseInt(f[3],10):1/0:m;c+=f[0].length,t.push({type:5,min:m,max:d,value:t.pop()})}else t.push({type:7,value:123});break}case"?":t.length===0&&a(c),t.push({type:5,min:0,max:1,value:t.pop()});break;case"+":t.length===0&&a(c),t.push({type:5,min:1,max:1/0,value:t.pop()});break;case"*":t.length===0&&a(c),t.push({type:5,min:0,max:1/0,value:t.pop()});break;default:t.push({type:7,value:l.charCodeAt(0)})}if(r.length>0)throw new SyntaxError(`Invalid regular expression: /${i}/: Unterminated group`);return NA(n,s),o}function RA(i,o){let e;const t=[],r=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;for(;(e=r.exec(i))!==null;){let n=null;const[,s,a,u,c,l,f,m,d,C,_]=e;if(s||a||u||c||l||f?n=(()=>{let E={type:3,set:[],not:!1};return s?E=du():a?E=_u():u?E=Eu():c?E=Cu():l?E=Au():f&&(E=bu()),E})():m&&_?n={type:4,from:(d||C).charCodeAt(0),to:_.charCodeAt(_.length-1)}:e[16]&&(n={type:7,value:e[16].charCodeAt(0)}),!n)return[t,r.lastIndex];t.push(n)}throw new SyntaxError(`Invalid regular expression: /${o}/: Unterminated character class`)}function pA(i){return i.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(o,e,t,r,n,s,a)=>{if(t)return o;let u;e?u=8:r?u=Number.parseInt(r,16):n?u=Number.parseInt(n,16):s?u="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):u={0:0,t:9,n:10,v:11,f:12,r:13}[a];const c=String.fromCharCode(u);return/[[\]{}^$.|?*+()]/.test(c)?`\\${c}`:c})}function NA(i,o){for(const e of i.reverse()){const t=e.reference.value;if(o<t){e.reference.type=7;const r=t.toString();if(e.reference.value=Number.parseInt(r,8),!/^[0-7]+$/.test(r)){let n=0;for(;r[n]!=="8"&&r[n]!=="9"&&n<r.length;)n+=1;if(n===0?(e.reference.value=r.charCodeAt(0),n+=1):e.reference.value=Number.parseInt(r.slice(0,n),8),r.length>n){const s=e.stack.splice(e.index+1);for(const a of r.slice(n))e.stack.push({type:7,value:a.charCodeAt(0)});e.stack.push(...s)}}}}}function oa(i,o){if(!VA(i))return{isError:!0,regExp:null};try{const e=new RegExp(i,o?"ug":"u");return OA(e)?{isError:!1,regExp:e}:{isError:!0,regExp:null}}catch{return{isError:!0,regExp:null}}}function VA(i){return!(/\(\?<=.*?\)/g.test(i)&&!/\[.*?(\?<=.*?)\]/g.test(i)||/\(\?<!.*?\)/g.test(i)&&!/\[.*?(\?<!.*?)\]/g.test(i))}function OA(i,o){let t;Object.prototype.toString.call(i)==="[object RegExp]"?t=i.source:i&&typeof i!="string"&&(t=`${i}`);let r;try{r=yA(t)}catch{return!1}let n=0;const s=(a,u)=>{let c=u;if(a.type===5&&(c++,n++,c>1||n>25))return!1;if(a.options){for(const f of a.options)if(!s({stack:f},c))return!1}const l=a.stack||a.value&&a.value.stack;if(!l)return!0;for(const f of l)if(!s(f,c))return!1;return!0};return s(r,0)}class MA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=Js(e,t);if(r)return n;const[a,u]=s;let c=a.getValue();a.isNull()&&(c=""),a.isBoolean()&&(c=c?"TRUE":"FALSE"),c=`${c}`;let l=u.getValue();u.isNull()&&(l=""),u.isBoolean()&&(l=l?"TRUE":"FALSE"),l=`${l}`;const{isError:f,regExp:m}=oa(l,!1);if(f)return g.create(h.REF);const d=c.match(m);if(d===null)return g.create(h.NA);if(d.length>1){const C=d.slice(1).map(_=>j.create(_));return C.length>1?K.create({calculateValueList:[C],rowCount:1,columnCount:C.length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}):C[0]}return j.create(d[0])}}class SA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=Js(e,t);if(r)return n;const[a,u]=s;let c=a.getValue();a.isNull()&&(c=""),a.isBoolean()&&(c=c?"TRUE":"FALSE"),c=`${c}`;let l=u.getValue();u.isNull()&&(l=""),u.isBoolean()&&(l=l?"TRUE":"FALSE"),l=`${l}`;const{isError:f,regExp:m}=oa(l,!1);return f?g.create(h.REF):c.match(m)===null?k.create(!1):k.create(!0)}}class DA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=Js(e,t,r);if(n)return s;const[u,c,l]=a;let f=u.getValue();u.isNull()&&(f=""),u.isBoolean()&&(f=f?"TRUE":"FALSE"),f=`${f}`;let m=c.getValue();c.isNull()&&(m=""),c.isBoolean()&&(m=m?"TRUE":"FALSE"),m=`${m}`;let d=l.getValue();l.isNull()&&(d=""),l.isBoolean()&&(d=d?"TRUE":"FALSE"),d=`${d}`;const{isError:C,regExp:_}=oa(m,!0);if(C)return g.create(h.REF);const E=f.replace(_,d);return j.create(E)}}class wA extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSingleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);const d=Me(e),C=Me(n),_=d.substring(0,f-1)+C+d.substring(f-1+m);return j.create(_)}}class PA extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_),R=f.get(C,_);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSingleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=I(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);let d=Me(e);const C=Me(n);let _=d.substring(0,f-1);d=d.substring(f-1);let E=0,b=0;for(;b<m&&E<d.length;)b+=Ur(d,E),E++;return _+=C+d.substring(E),j.create(_)}}class LA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=a.get(l,f);if(c.isError())return c;let d=c.getValue();if(c.isNull()&&(d=""),c.isBoolean()&&(d=d?"TRUE":"FALSE"),d+="",m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const C=32767,_=Math.floor(+m.getValue());if(_<0||_>C/d.length)return g.create(h.VALUE);const E=d.repeat(_);return j.create(E)});return r===1&&n===1?u.get(0,0):u}}class xA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Me(e),{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return j.create("");if(c>=r.length)return j.create(r);const l=r.substring(r.length-c);return j.create(l)}}class jA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Me(e),{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return j.create("");let l=r.length-1,f=0,m="";for(;f<c&&l>=0;)f+=Ur(r,l,"rtl"),m=r.charAt(l)+m,l--;return j.create(m)}}class UA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return m.isError()?m:_.isError()?_:E.isError()?E:this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Me(e).toLocaleUpperCase(),s=Me(t).toLocaleUpperCase(),{isError:a,errorObject:u,variants:c}=I(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);return m===-1?g.create(h.VALUE):y.create(m+1)}}class vA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,C)=>{const _=c.get(d,C),E=l.get(d,C);return m.isError()?m:_.isError()?_:E.isError()?E:this._handleSingleObject(m,_,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Me(e).toLocaleUpperCase(),s=Me(t).toLocaleUpperCase(),{isError:a,errorObject:u,variants:c}=I(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);if(m===-1)return g.create(h.VALUE);const d=ia(s.substring(0,m))+1;return y.create(d)}}class TA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n!=null&&n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n!=null&&n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=n?O(s,a,n,g.create(h.NA)):void 0,m=u.mapValue((d,C,_)=>{const E=c.get(C,_),b=l.get(C,_);let R=n?f.get(C,_):void 0;return d.isError()?d:E.isError()?E:b.isError()?b:R!=null&&R.isError()?R:R!=null&&R.isNull()||R!=null&&R.isBoolean()?g.create(h.VALUE):(R!=null&&R.isString()&&(R=R.convertToNumberObjectValue()),R!=null&&R.isError()?R:this._handleSingleObject(d,E,b,R))});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const s=this._getObjectString(e),a=this._getObjectString(t),u=this._getObjectString(r),c=n?Math.floor(+n.getValue()):void 0;if(n&&c<=0)return g.create(h.VALUE);if(a==="")return j.create(s);let l="",f=0;for(let m=0;m<s.length;m++){const d=s.substr(m,a.length);if(d===a||d.length===a.length&&d.trim()===a.trim()){if(f++,f===c){l=s.substr(0,m)+u+s.substr(m+a.length);break}c===void 0&&(l+=u),m+=a.length-1}else c===void 0&&(l+=s[m])}return c&&f<c&&(l=s),j.create(l)}_getObjectString(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}}class BA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return e.isArray()&&(t=e.get(0,0)),t.isError()?t:t.isNull()||t.isBoolean()||t.isNumber()?j.create(""):t}}class IA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.map((u,c,l)=>{if(u.isError())return u;let f=a.get(c,l)||j.create(" ");if(f.isError())return f;if(f.isBoolean())return g.create(h.VALUE);if(u.isBoolean())return u;let m=u.getValue();if(u.isNull()&&(m=0),u.isString()){if(!M.isRealNum(m))return u;m=Number(m)}f.isNull()&&(f=j.create(" "));const d=`${f.getValue()}`,C=aa(d,m);return j.create(d===" "?C.trimEnd():C)})}}class FA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=!1,c=r!=null?r:y.create(1);c.isNull()&&(u=!0,c=y.create(1));const l=!n,f=n!=null?n:y.create(0),m=s!=null?s:y.create(0),d=a!=null?a:g.create(h.NA),C=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1,d.isArray()?d.getRowCount():1),_=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1,d.isArray()?d.getColumnCount():1),E=O(C,_,e,g.create(h.NA)),b=O(C,_,c,g.create(h.NA)),R=O(C,_,f,g.create(h.NA)),p=O(C,_,m,g.create(h.NA)),V=O(C,_,d,g.create(h.NA)),S=this._getResultArray(E,t,b,R,p,V,u,l);return C===1&&_===1?S.get(0,0):S}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{const C=r.get(m,d),_=n.get(m,d),E=s.get(m,d),b=a.get(m,d),R=this._checkVariantsError(f,C,_,E);if(R.isError())return R;const p=this._getStringValue(f),V=this._getDelimiterValue(t);if(V instanceof g)return V;const S=this._getVariantsNumberFloorValue(C,_,E);if(S instanceof g)return S;const[D,w,P]=S;return D===0||w<0||w>1||P<0||P>1?g.create(h.VALUE):V.includes("")?D>0?j.create(p):j.create(""):!u&&Math.abs(D)>p.length?g.create(h.VALUE):V.every(L=>L.length>p.length)?g.create(h.NA):this._getResult(p,V,D,w,P,b,c)})}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return k.create(!0)}_getStringValue(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}_getDelimiterValue(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);if(e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;t.push(this._getStringValue(a))}),r)return n}else{if(e.isError())return e;t.push(this._getStringValue(e))}return t}_getVariantsNumberFloorValue(...e){const t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;const s=Math.floor(+n.getValue());t.push(s)}return t}_getResult(e,t,r,n,s,a,u){let c=n?e.toLocaleLowerCase():e;const l=n?t.map(_=>_.toLocaleLowerCase()):t;let f=0,m=0,d=0;for(let _=0;_<Math.abs(r);_++)if(r<0){const E=l.map(b=>({index:c.lastIndexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>R.index-b.index)[0];if(!E)break;f=E.index,c=c.substr(0,E.index),d=E.length,m++}else{const E=l.map(b=>({index:c.indexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>b.index-R.index)[0];if(!E)break;f+=E.index+d,c=c.substr(E.index+E.length),d=E.length,m++}if(m&&m<Math.abs(r)&&u)return g.create(h.NA);if(!m||m<Math.abs(r))return s?r>0?j.create(""):j.create(e):a;const C=e.substr(f+d);return j.create(C)}}class kA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=!1,c=r!=null?r:y.create(1);c.isNull()&&(u=!0,c=y.create(1));const l=!n,f=n!=null?n:y.create(0),m=s!=null?s:y.create(0),d=a!=null?a:g.create(h.NA),C=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1,d.isArray()?d.getRowCount():1),_=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1,d.isArray()?d.getColumnCount():1),E=O(C,_,e,g.create(h.NA)),b=O(C,_,c,g.create(h.NA)),R=O(C,_,f,g.create(h.NA)),p=O(C,_,m,g.create(h.NA)),V=O(C,_,d,g.create(h.NA)),S=this._getResultArray(E,t,b,R,p,V,u,l);return C===1&&_===1?S.get(0,0):S}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{const C=r.get(m,d),_=n.get(m,d),E=s.get(m,d),b=a.get(m,d),R=this._checkVariantsError(f,C,_,E);if(R.isError())return R;const p=this._getStringValue(f),V=this._getDelimiterValue(t);if(V instanceof g)return V;const S=this._getVariantsNumberFloorValue(C,_,E);if(S instanceof g)return S;const[D,w,P]=S;return D===0||w<0||w>1||P<0||P>1?g.create(h.VALUE):V.includes("")?D>0?j.create(""):j.create(p):!u&&Math.abs(D)>p.length?g.create(h.VALUE):V.every(L=>L.length>p.length)?g.create(h.NA):this._getResult(p,V,D,w,P,b,c)})}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return k.create(!0)}_getStringValue(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}_getDelimiterValue(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);if(e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;t.push(this._getStringValue(a))}),r)return n}else{if(e.isError())return e;t.push(this._getStringValue(e))}return t}_getVariantsNumberFloorValue(...e){const t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;const s=Math.floor(+n.getValue());t.push(s)}return t}_getResult(e,t,r,n,s,a,u){let c=n?e.toLocaleLowerCase():e;const l=n?t.map(_=>_.toLocaleLowerCase()):t;let f=0,m=0,d=0;for(let _=0;_<Math.abs(r);_++)if(r<0){const E=l.map(b=>({index:c.lastIndexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>R.index-b.index)[0];if(!E)break;f=E.index,c=c.substr(0,E.index),m++}else{const E=l.map(b=>({index:c.indexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>b.index-R.index)[0];if(!E)break;f+=E.index+d,c=c.substr(E.index+E.length),d=E.length,m++}if(m&&m<Math.abs(r)&&u)return g.create(h.NA);if(!m||m<Math.abs(r))return s?r>0?j.create(e):j.create(""):a;const C=e.substr(0,f);return j.create(C)}}class $A extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,t,...r){const n=this._getDelimiterValues(e),s=this._getTextValues(r);if(t.isArray()){const u=t.mapValue(c=>this._handleSingleObject(n,c,s));return u.getRowCount()===1&&u.getColumnCount()===1?u.get(0,0):u}const a=t;if(a.isString()){const u=`${a.getValue()}`.toLocaleUpperCase();if(u==="TRUE")return this._handleSingleObject(n,k.create(!0),s);if(u==="FALSE")return this._handleSingleObject(n,k.create(!1),s)}return this._handleSingleObject(n,t,s)}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=I(t);if(n)return s;if(r instanceof g)return r;const[u]=a,c=+u.getValue();let l=r;c&&(l=r.filter(m=>m!==null));let f="";for(let m=0;m<l.length;m++)l[m]!==null&&(f+=l[m]),m<l.length-1&&(f+=e[m%e.length]);return j.create(f)}_getDelimiterValues(e){const t=[],r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1;for(let s=0;s<r;s++)for(let a=0;a<n;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;let c=`${u.getValue()}`;u.isNull()&&(c=""),u.isBoolean()&&(c=c.toLocaleUpperCase()),t.push(c)}return t}_getTextValues(e){const t=[];for(const r of e){const n=r.isArray()?r.getRowCount():1,s=r.isArray()?r.getColumnCount():1;for(let a=0;a<n;a++)for(let u=0;u<s;u++){const c=r.isArray()?r.get(a,u):r;if(c.isError())return c;if(c.isNull()){t.push(null);continue}let l=`${c.getValue()}`;c.isBoolean()&&(l=l.toLocaleUpperCase()),t.push(l)}}return t}}class YA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=r!=null?r:j.create("\\s");const c=n!=null?n:y.create(0),l=s!=null?s:y.create(0),f=a!=null?a:j.create(h.NA),{_variant:m,values:d}=this._getStringValues(t),{_variant:C,values:_}=this._getStringValues(u,!1);u=C;const E=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),b=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),R=O(E,b,e,g.create(h.NA)),p=O(E,b,c,g.create(h.NA)),V=O(E,b,l,g.create(h.NA)),S=this._getResultArray(R,m,u,p,V,f,d,_);return E===1&&b===1?S.get(0,0):S.map(D=>D.get(0,0))}_getStringValues(e,t=!0){let r=e;const n=[];if(r.isArray())r.iterator(s=>{if(s!=null&&s.isError())return r=s,!1;if(s!=null&&s.isNull()&&t)return r=g.create(h.VALUE),!1;const a=this._getRegExpStringValue(s);if(a==="")return r=g.create(h.VALUE),!1;n.push(a)});else{r.isNull()&&t&&(r=g.create(h.VALUE));const s=this._getRegExpStringValue(r);s===""&&(r=g.create(h.VALUE)),n.push(s)}return{_variant:r,values:n}}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{let C=n.get(m,d),_=s.get(m,d);const E=this._checkVariantsError(f,t,r,C,_);if(E.isError())return E;if(f.isNull())return g.create(h.VALUE);let b=a;if(b.isArray()){const D=b.getRowCount(),w=b.getColumnCount();if(D>1||w>1)return g.create(h.VALUE);b=b.get(0,0)}let R=`${f.getValue()}`;if(f.isBoolean()&&(R=R.toLocaleUpperCase()),C.isString()&&(C=C.convertToNumberObjectValue(),C.isError()))return C;const p=Math.floor(+C.getValue());if(_.isString()&&(_=_.convertToNumberObjectValue(),_.isError()))return _;const V=Math.floor(+_.getValue());if(V<0||V>1)return g.create(h.VALUE);let S=`${b.getValue()}`;return b.isBoolean()&&(S=S.toLocaleUpperCase()),this._getResult(R,u,c,p,V,S)})}_getResult(e,t,r,n,s,a){const u=new RegExp(r.join("|"),`g${s?"i":""}`),c=new RegExp(t.join("|"),`g${s?"i":""}`),l=e.split(u);let f=1,m=l.map(d=>{let C=d.split(c);return n&&(C=C.filter(_=>_!=="")),f=Math.max(f,C.length),C});return m=m.map(d=>{let C=d;return C.length<f&&(C=C.concat(new Array(f-C.length).fill(a))),C}),K.createByArray(m)}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return k.create(!0)}_getRegExpStringValue(e){let t=e.getValue();return e.isNull()&&(t="\\s"),e.isBoolean()&&(t=t?"TRUE":"FALSE"),t+="",this._escapeRegExp(t)}_escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class HA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return j.create("");let t=`${e.getValue()}`;return e.isBoolean()&&(t=t.toLocaleUpperCase()),t=t.trim().replace(/\s+/g," "),j.create(t)}}const GA=Object.values(M.DataStreamTreeTokenType).filter(i=>[M.DataStreamTreeTokenType.TABLE_START,M.DataStreamTreeTokenType.TABLE_ROW_START,M.DataStreamTreeTokenType.TABLE_CELL_START,M.DataStreamTreeTokenType.TABLE_CELL_END,M.DataStreamTreeTokenType.TABLE_ROW_END,M.DataStreamTreeTokenType.TABLE_END,M.DataStreamTreeTokenType.CUSTOM_BLOCK].includes(i));class WA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=I(e);if(t)return r;const[s]=n,a=Math.floor(+s.getValue());if(a<1||a>1114111)return g.create(h.VALUE);if(a===1114111||a===1114110)return g.create(h.NA);let u=String.fromCharCode(a);return GA.some(c=>c===u)&&(u=""),j.create(u)}}class QA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);let t=e.getValue().toLocaleString();e.isBoolean()&&(t=t.toLocaleUpperCase());const r=t.charCodeAt(0);return y.create(r)}}class qA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return j.create("");const t=`${e.getValue()}`.toLocaleUpperCase();return j.create(t)}}class XA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue(),t.isError()))return t;const r=+t.getValue();return y.create(r)}}class KA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=I(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<0||u>1)return g.create(h.VALUE);if(e.isNull())return j.create("");if(e.isBoolean())return e;if(e.isNumber())return y.create(e.getValue());const c=u?`"${e.getValue()}"`:`${e.getValue()}`;return j.create(c)}}const yu=[[K_,ne.ASC],[X_,ne.ARRAYTOTEXT],[Z_,ne.BAHTTEXT],[J_,ne.CHAR],[eA,ne.CLEAN],[tA,ne.CODE],[rA,ne.CONCAT],[nA,ne.CONCATENATE],[sA,ne.DBCS],[aA,ne.DOLLAR],[iA,ne.EXACT],[oA,ne.FIND],[cA,ne.FINDB],[lA,ne.FIXED],[fA,ne.LEFT],[mA,ne.LEFTB],[hA,ne.LEN],[gA,ne.LENB],[dA,ne.LOWER],[CA,ne.MID],[_A,ne.MIDB],[AA,ne.NUMBERVALUE],[MA,ne.REGEXEXTRACT],[SA,ne.REGEXMATCH],[DA,ne.REGEXREPLACE],[EA,ne.PROPER],[wA,ne.REPLACE],[PA,ne.REPLACEB],[LA,ne.REPT],[xA,ne.RIGHT],[jA,ne.RIGHTB],[UA,ne.SEARCH],[vA,ne.SEARCHB],[TA,ne.SUBSTITUTE],[BA,ne.T],[IA,ne.TEXT],[FA,ne.TEXTAFTER],[kA,ne.TEXTBEFORE],[$A,ne.TEXTJOIN],[YA,ne.TEXTSPLIT],[HA,ne.TRIM],[WA,ne.UNICHAR],[QA,ne.UNICODE],[qA,ne.UPPER],[XA,ne.VALUE],[KA,ne.VALUETOTEXT]],Ru=[];var pu=(i=>i)(pu||{});const Nu=[];var Vu=(i=>(i.ENCODEURL="ENCODEURL",i.FILTERXML="FILTERXML",i.WEBSERVICE="WEBSERVICE",i))(Vu||{}),ZA=Object.defineProperty,zA=Object.getOwnPropertyDescriptor,JA=(i,o,e,t)=>{for(var r=t>1?void 0:t?zA(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&ZA(o,e,r),r},Fr=(i,o)=>(e,t)=>o(e,t,i);let mn=class extends M.Disposable{constructor(i,o,e,t){super(),this._commandService=i,this._functionService=o,this._configService=e,this._dataSyncPrimaryController=t,this._initialize()}_initialize(){this._registerCommands(),this._registerFunctions()}_registerCommands(){[Rn,Zr,ps,Ns,en,Vs,Vr,En,bn,yn,pn,Nn,Ai,Ei,Os,hi].forEach(i=>{var o;this._commandService.registerCommand(i),(o=this._dataSyncPrimaryController)==null||o.registerSyncingMutations(i)})}_registerFunctions(){var e;const i=this._configService.getConfig(On),o=[...zi,...$o,...Yo,...Go,...Zo,...zo,...au,...iu,...ou,...uu,...cu,...lu,...fu,...yu,...Ru,...Nu].concat((e=i==null?void 0:i.function)!=null?e:[]).map(t=>{const r=t[0],n=t[1];return new r(n)});this._functionService.registerExecutors(...o)}};mn=JA([Fr(0,M.ICommandService),Fr(1,gt),Fr(2,M.IConfigService),Fr(3,M.Optional(Pu.DataSyncPrimaryController))],mn);var eE=Object.defineProperty,tE=Object.getOwnPropertyDescriptor,rE=(i,o,e,t)=>{for(var r=t>1?void 0:t?tE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&eE(o,e,r),r},kr=(i,o)=>(e,t)=>o(e,t,i);let hn=class extends M.Disposable{constructor(i,o,e){super(),this._commandService=i,this._dependencyManagerService=o,this._featureCalculationManagerService=e,this._initialize()}_initialize(){this._commandExecutedListener(),this._featureCalculationManagerServiceListener()}_featureCalculationManagerServiceListener(){this.disposeWithMe(this._featureCalculationManagerService.onChanged$.subscribe(i=>{const{unitId:o,subUnitId:e,featureIds:t}=i;this._dependencyManagerService.removeFeatureFormulaDependency(o,e,t)}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===yn.id){const o=i.params;if(o==null)return;const{featureIds:e,unitId:t,subUnitId:r}=o;this._dependencyManagerService.removeFeatureFormulaDependency(t,r,e)}else if(i.id===bn.id){const o=i.params;if(o==null)return;const{featureId:e,calculationParam:t}=o,{unitId:r,subUnitId:n}=t;this._dependencyManagerService.removeFeatureFormulaDependency(r,n,[e])}else if(i.id===Nn.id){const o=i.params;if(o==null)return;this._dependencyManagerService.removeOtherFormulaDependency(o.unitId,o.subUnitId,o.formulaIdList)}else if(i.id===pn.id){const o=i.params;if(o==null)return;const e=o.formulaMap,t=[];Object.keys(e).forEach(r=>{t.push(r)}),this._dependencyManagerService.removeOtherFormulaDependency(o.unitId,o.subUnitId,t)}else if(i.id===Rn.id){const o=i.params.formulaData;Object.keys(o).forEach(e=>{const t=o[e];if(t!==void 0){if(t===null){this._dependencyManagerService.clearFormulaDependency(e);return}Object.keys(t).forEach(r=>{const n=t[r];if(n!==void 0){if(n===null)return this._dependencyManagerService.clearFormulaDependency(e,r),!0;new M.ObjectMatrix(n).forValue((s,a)=>{this._dependencyManagerService.removeFormulaDependency(e,r,s,a)})}})}})}else i.id===Vr.id&&this._handleSetDefinedName(i)}))}_handleSetDefinedName(i){const o=i.params;if(o==null)return;const{unitId:e,name:t}=o;this._dependencyManagerService.removeFormulaDependencyByDefinedName(e,t)}};hn=rE([kr(0,M.ICommandService),kr(1,ar),kr(1,wr),kr(2,ar)],hn);var nE=Object.defineProperty,sE=Object.getOwnPropertyDescriptor,aE=(i,o,e,t)=>{for(var r=t>1?void 0:t?sE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&nE(o,e,r),r},za=(i,o)=>(e,t)=>o(e,t,i);let gn=class extends M.Disposable{constructor(i,o){super(),this._commandService=i,this._featureCalculationManagerService=o,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===bn.id){const o=i.params;if(o==null)return;const{featureId:e,calculationParam:t}=o,{unitId:r,subUnitId:n}=t;this._featureCalculationManagerService.register(r,n,e,t)}else if(i.id===yn.id){const o=i.params;if(o==null)return;const{featureIds:e,unitId:t,subUnitId:r}=o;this._featureCalculationManagerService.remove(t,r,e)}}))}};gn=aE([za(0,M.ICommandService),za(1,ar)],gn);var iE=Object.defineProperty,oE=Object.getOwnPropertyDescriptor,uE=(i,o,e,t)=>{for(var r=t>1?void 0:t?oE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&iE(o,e,r),r},ts=(i,o)=>(e,t)=>o(e,t,i);let dn=class extends M.Disposable{constructor(i,o,e){super(),this._commandService=i,this._otherFormulaManagerService=o,this._dependencyManagerService=e,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===pn.id){const o=i.params;if(o==null)return;const e={[o.unitId]:{[o.subUnitId]:o.formulaMap}};this._otherFormulaManagerService.batchRegister(e)}else if(i.id===Nn.id){const o=i.params;if(o==null)return;const e={};o.formulaIdList.forEach(r=>e[r]=!0);const t={[o.unitId]:{[o.subUnitId]:e}};this._otherFormulaManagerService.batchRemove(t)}}))}};dn=uE([ts(0,M.ICommandService),ts(1,vn),ts(2,wr)],dn);class Ou extends M.Disposable{constructor(){super(...arguments);A(this,"_tableMap",new Map);A(this,"_tableOptionMap",new Map)}dispose(){this._tableMap.clear(),this._tableOptionMap.clear()}remove(e,t){var r;(r=this._tableMap.get(e))==null||r.delete(t)}getTableMap(e){return this._tableMap.get(e)}getTableOptionMap(){return this._tableOptionMap}registerTable(e,t,r){var n;this._tableMap.get(e)==null&&this._tableMap.set(e,new Map),(n=this._tableMap.get(e))==null||n.set(t,r)}registerTableOptionMap(e,t){this._tableOptionMap.set(e,t)}}const ua=M.createIdentifier("univer.formula.super-table.service");var cE=Object.defineProperty,lE=Object.getOwnPropertyDescriptor,fE=(i,o,e,t)=>{for(var r=t>1?void 0:t?lE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&cE(o,e,r),r},Ja=(i,o)=>(e,t)=>o(e,t,i);let Cn=class extends M.Disposable{constructor(i,o){super(),this._commandService=i,this._superTableService=o,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===Vr.id){const o=i.params;if(o==null)return;const{unitId:e,tableName:t,reference:r}=o;this._superTableService.registerTable(e,t,r)}else if(i.id===En.id){const o=i.params;if(o==null)return;const{unitId:e,tableName:t}=o;this._superTableService.remove(e,t)}else if(i.id===Os.id){const o=i.params;if(o==null)return;const{tableOption:e,tableOptionType:t}=o;this._superTableService.registerTableOptionMap(e,t)}}))}};Cn=fE([Ja(0,M.ICommandService),Ja(1,ua)],Cn);class Mu extends M.Disposable{constructor(){super(...arguments);A(this,"_dirtyConversionMap",new Map)}dispose(){this._dirtyConversionMap.clear()}remove(e){this._dirtyConversionMap.delete(e)}get(e){return this._dirtyConversionMap.get(e)}has(e){return this._dirtyConversionMap.has(e)}register(e,t){this._dirtyConversionMap.set(e,t)}getDirtyConversionMap(){return this._dirtyConversionMap}}const Su=M.createIdentifier("univer.formula.active-dirty-manager.service");var mE=Object.defineProperty,hE=Object.getOwnPropertyDescriptor,gE=(i,o,e,t)=>{for(var r=t>1?void 0:t?hE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&mE(o,e,r),r},ei=(i,o)=>(e,t)=>o(e,t,i);const dE="UNIVER_ENGINE_FORMULA_PLUGIN";var rs;exports.UniverFormulaEnginePlugin=(rs=class extends M.Plugin{constructor(o=yc,e,t){super(),this._config=o,this._injector=e,this._configService=t;const{...r}=this._config;this._configService.setConfig(On,r)}onStarting(){this._initialize(),this._initializeWithOverride()}onReady(){var o;M.touchDependencies(this._injector,[[mn],[exports.SetDefinedNameController],[Cn]]),(o=this._config)!=null&&o.notExecuteFormula||M.touchDependencies(this._injector,[[dn],[gn],[hn],[exports.CalculateController]])}onRendered(){var o;(o=this._config)!=null&&o.notExecuteFormula||M.touchDependencies(this._injector,[[cn],[un]])}_initialize(){var e;const o=[[gt,{useClass:Ii}],[lr,{useClass:exports.DefinedNamesService}],[Su,{useClass:Mu}],[ua,{useClass:Ou}],[exports.FormulaDataModel],[Vn],[mn],[exports.SetDefinedNameController],[Cn]];(e=this._config)!=null&&e.notExecuteFormula||o.push([vn,{useClass:Qi}],[st,{useClass:exports.FormulaRuntimeService}],[mt,{useClass:exports.FormulaCurrentConfigService}],[ar,{useClass:Wi}],[exports.CalculateController],[dn],[hn],[gn],[exports.Interpreter],[exports.AstTreeBuilder],[exports.Lexer],[js],[exports.FunctionNodeFactory],[exports.LambdaNodeFactory],[Ts],[exports.OperatorNodeFactory],[exports.PrefixNodeFactory],[exports.ReferenceNodeFactory],[exports.SuffixNodeFactory],[exports.UnionNodeFactory],[Bs]),o.forEach(t=>this._injector.add(t))}_initializeWithOverride(){var o;(o=this._config)!=null&&o.notExecuteFormula||[[cn,{useClass:exports.CalculateFormulaService}],[wr,{useClass:Gi}],[un,{useClass:exports.FormulaDependencyGenerator}]].forEach(t=>this._injector.add(t))}},A(rs,"pluginName",dE),rs);exports.UniverFormulaEnginePlugin=gE([ei(1,M.Inject(M.Injector)),ei(2,M.IConfigService)],exports.UniverFormulaEnginePlugin);var CE=Object.defineProperty,_E=Object.getOwnPropertyDescriptor,AE=(i,o,e,t)=>{for(var r=t>1?void 0:t?_E(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&CE(o,e,r),r},ti=(i,o)=>(e,t)=>o(e,t,i);exports.FFormula=class extends M.FBase{constructor(o,e){super(),this._commandService=o,this._injector=e}executeCalculation(){this._commandService.executeCommand(dr.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(dr.SetFormulaCalculationStopMutation.id,{})}calculationStart(o){return this._commandService.onCommandExecuted(e=>{if(e.id===dr.SetFormulaCalculationStartMutation.id){const t=e.params;o(t.forceCalculation)}})}calculationEnd(o){return this._commandService.onCommandExecuted(e=>{if(e.id!==dr.SetFormulaCalculationNotificationMutation.id)return;const t=e.params;t.functionsExecutedState!==void 0&&o(t.functionsExecutedState)})}onCalculationEnd(){return new Promise((o,e)=>{const t=setTimeout(()=>{e(new Error("Calculation end timeout"))},3e4),r=this.calculationEnd(()=>{clearTimeout(t),r.dispose(),o()})})}calculationProcessing(o){return this._commandService.onCommandExecuted(e=>{if(e.id!==dr.SetFormulaCalculationNotificationMutation.id)return;const t=e.params;t.stageInfo!==void 0&&o(t.stageInfo)})}};exports.FFormula=AE([ti(0,M.Inject(M.ICommandService)),ti(1,M.Inject(M.Injector))],exports.FFormula);exports.ActiveDirtyManagerService=Mu;exports.ArrayValueObject=K;exports.AstRootNodeFactory=js;exports.AsyncArrayObject=Bi;exports.AsyncObject=Ti;exports.BaseFunction=N;exports.BaseReferenceObject=Mr;exports.BaseValueObject=ht;exports.BooleanValue=Ot;exports.BooleanValueObject=k;exports.CustomFunction=Fm;exports.DEFAULT_INTERVAL_COUNT=Ki;exports.DependencyManagerBaseService=Hi;exports.DependencyManagerService=Gi;exports.ERROR_TYPE_SET=qt;exports.ErrorType=h;exports.ErrorValueObject=g;exports.FUNCTION_NAMES_ARRAY=Ji;exports.FUNCTION_NAMES_COMPATIBILITY=le;exports.FUNCTION_NAMES_CUBE=Ho;exports.FUNCTION_NAMES_DATABASE=Te;exports.FUNCTION_NAMES_DATE=ye;exports.FUNCTION_NAMES_ENGINEERING=z;exports.FUNCTION_NAMES_FINANCIAL=J;exports.FUNCTION_NAMES_INFORMATION=Ne;exports.FUNCTION_NAMES_LOGICAL=Ve;exports.FUNCTION_NAMES_LOOKUP=me;exports.FUNCTION_NAMES_MATH=Y;exports.FUNCTION_NAMES_STATISTICAL=U;exports.FUNCTION_NAMES_TEXT=ne;exports.FUNCTION_NAMES_UNIVER=pu;exports.FUNCTION_NAMES_WEB=Vu;exports.FeatureCalculationManagerService=Wi;exports.FormulaDependencyTree=Wr;exports.FormulaDependencyTreeType=on;exports.FormulaDependencyTreeVirtual=Es;exports.FormulaExecuteStageType=ze;exports.FormulaExecutedStateType=zt;exports.FunctionService=Ii;exports.FunctionType=ni;exports.IActiveDirtyManagerService=Su;exports.ICalculateFormulaService=cn;exports.IDefinedNamesService=lr;exports.IDependencyManagerService=wr;exports.IFeatureCalculationManagerService=ar;exports.IFormulaCurrentConfigService=mt;exports.IFormulaDependencyGenerator=un;exports.IFormulaRuntimeService=st;exports.IFunctionService=gt;exports.IOtherFormulaManagerService=vn;exports.ISuperTableService=ua;exports.LambdaParameterNodeFactory=Ts;exports.LexerNode=se;exports.LexerTreeBuilder=Vn;exports.NullValueObject=ae;exports.NumberValueObject=y;exports.OtherFormulaManagerService=Qi;exports.PLUGIN_CONFIG_KEY=On;exports.RangeReferenceObject=Rr;exports.RegisterFunctionMutation=hi;exports.RemoveDefinedNameMutation=En;exports.RemoveFeatureCalculationMutation=yn;exports.RemoveOtherFormulaMutation=Nn;exports.RemoveSuperTableMutation=Ei;exports.SetArrayFormulaDataMutation=Zr;exports.SetDefinedNameMutation=Vr;exports.SetDefinedNameMutationFactory=cc;exports.SetFeatureCalculationMutation=bn;exports.SetFormulaCalculationNotificationMutation=en;exports.SetFormulaCalculationResultMutation=Vs;exports.SetFormulaCalculationStartMutation=ps;exports.SetFormulaCalculationStopMutation=Ns;exports.SetFormulaDataMutation=Rn;exports.SetOtherFormulaMutation=pn;exports.SetSuperTableMutation=Ai;exports.SetSuperTableOptionMutation=Os;exports.StringValueObject=j;exports.SuperTableService=Ou;exports.ValueNodeFactory=Bs;exports.ValueObjectFactory=lt;exports.compareToken=$;exports.convertUnitDataToRuntime=ii;exports.deserializeRangeForR1C1=Zi;exports.deserializeRangeWithSheet=Er;exports.deserializeRangeWithSheetWithCache=Yt;exports.functionArray=zi;exports.functionCompatibility=$o;exports.functionCube=Yo;exports.functionDatabase=Go;exports.functionDate=Zo;exports.functionEngineering=zo;exports.functionFinancial=au;exports.functionInformation=iu;exports.functionLogical=ou;exports.functionLookup=uu;exports.functionMath=cu;exports.functionMeta=lu;exports.functionStatistical=fu;exports.functionText=yu;exports.functionUniver=Ru;exports.functionWeb=Nu;exports.generateAstNode=As;exports.generateRandomDependencyTreeId=vt;exports.generateStringWithSequence=as;exports.getAbsoluteRefTypeWitString=Ju;exports.getAbsoluteRefTypeWithSingleString=_r;exports.getRangeWithRefsString=tc;exports.handleNumfmtInCell=wc;exports.handleRefStringInfo=An;exports.includeFormulaLexerToken=ai;exports.initSheetFormulaData=Ri;exports.isFormulaLexerToken=Cr;exports.isInDirtyRange=ri;exports.isReferenceString=mi;exports.isReferenceStringWithEffectiveColumn=Ar;exports.isReferenceStrings=_i;exports.matchRefDrawToken=Uu;exports.matchToken=Q;exports.normalizeSheetName=ju;exports.operatorToken=X;exports.sequenceNodeType=ve;exports.serializeRange=St;exports.serializeRangeToRefString=zr;exports.serializeRangeWithSheet=gi;exports.serializeRangeWithSpreadsheet=di;exports.singleReferenceToGrid=Yr;exports.strip=ds;exports.stripErrorMargin=Ui;