UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines 617 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("kendo.drawing.cmn.chunk.js"),require("kendo.date-math.cmn.chunk.js"),require("kendo.common.cmn.chunk.js"),require("kendo.jszip-esm.cmn.chunk.js")):"function"==typeof define&&define.amd?define(["exports","kendo.drawing.cmn.chunk.min","kendo.date-math.cmn.chunk.min","kendo.common.cmn.chunk.min","kendo.jszip-esm.cmn.chunk.min"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.SpreadsheetCommonCmnChunk={}),e.kendo._globals.DrawingCmnChunk,e.kendo._globals.DateMathCmnChunk,e.kendo._globals.CommonCmnChunk,e.kendo._globals.JszipEsmCmnChunk)}(this,(function(e,t,r,n,s){function i(e){const t=Math.floor(e/26)-1;return(t>=0?i(t):"")+String.fromCharCode(65+e%26)}function o(e){return/^[a-z_][a-z0-9_]*$/i.test(e)?e:"'"+e.replace(/\x27/g,"\\'")+"'"}function a(e,t,r,n){let s="";return++t,isFinite(t)?null==n||2&n||(t="$"+t):t="",isFinite(r)?(s=i(r),null==n||1&n||(s="$"+s)):r="",e?o(e)+"!"+s+t:s+t}class u{constructor(){this.type="ref",this.sheet=""}clone(){return this}hasSheet(){return this._hasSheet}simplify(){return this}setSheet(e,t){return this.sheet=e,null!=t&&(this._hasSheet=t),this}absolute(e,t){return this}relative(...e){return this}adjust(e,t,r,n,s,i,o){return this}toString(){return this.relative(0,0,3,3).print(0,0)}forEach(e,t){e.call(t,this)}map(e,t){return e.call(t,this)}intersect(e){return this}intersects(e){return this.intersect(e)!==h}isCell(){return!1}toRow(e){return this}toColumn(e){return this}first(){return this}lastRange(){return this}size(){return 1}rangeAt(e){return this}nextRangeIndex(e){return 0}previousRangeIndex(e){return 0}eq(e){let t=this,r=e;if(t===h||r===h)return t===r;if((r instanceof c||r instanceof f&&!(t instanceof c))&&(t=e,r=this),t instanceof c)return r=r.simplify(),r instanceof c&&t.row==r.row&&t.col==r.col&&t.sheet==r.sheet;if(t instanceof f){if(r instanceof f)return r.topLeft.eq(t.topLeft)&&r.bottomRight.eq(t.bottomRight);if(r instanceof p)return r.single()&&t.eq(r.refs[0])}else if(t instanceof p&&r instanceof p){const e=t.refs,n=r.refs;if(e.length!=n.length)return!1;for(let t=0,r=e.length;t<r;t++)if(!e[t].eq(n[t]))return!1;return!0}return t===r}concat(e){return new p([this,e])}replaceAt(e,t){return t}forEachColumnIndex(e){this.forEachAxisIndex("col",e)}forEachRowIndex(e){this.forEachAxisIndex("row",e)}forEachRow(e){}forEachColumn(e){}forEachAxisIndex(e,t){let r=[];this["row"===e?"forEachRow":"forEachColumn"]((function(t){let n=t.first()[e];-1===r.indexOf(n)&&r.push(n)})),r.sort((function(e,t){return e>t?1:e<t?-1:0})).forEach(t)}valid(){return!1}renameSheet(e,t){if(this.sheet&&this.sheet.toLowerCase()==e.toLowerCase())return this.sheet=t,!0}}u.display=a;const h=new class extends u{print(){return"#NULL!"}eq(e){return e===this}forEach(){}};class l extends u{constructor(e){super(),this.name=e,this.ref="name"}clone(){return new l(this.name).setSheet(this.sheet,this.hasSheet())}print(){let e=o(this.name);return this.hasSheet()&&(e=o(this.sheet)+"!"+e),e}}class c extends u{constructor(e,t,r){super(),this.row=e,this.col=t,this.rel=r||0,this.ref="cell"}clone(){return new c(this.row,this.col,this.rel).setSheet(this.sheet,this.hasSheet())}intersect(e){return e instanceof c?this.eq(e)?this:h:e.intersect(this)}print(e,t,r){let n,s=this.col,i=this.row,u=this.rel;if(null==e&&u){let e=this.hasSheet()?o(this.sheet)+"!":"";return s=isFinite(s)?1&u?"C["+s+"]":"C"+(s+1):"",i=isFinite(i)?2&u?"R["+i+"]":"R"+(i+1):"",e+i+s}return n=this.absolute(e,t),r?(i=n.row%1048576,s=n.col%16384,i<0&&(i+=1048576),s<0&&(s+=16384),a(this._hasSheet&&this.sheet,i,s,u)):n.valid()?a(this._hasSheet&&this.sheet,n.row,n.col,u):"#REF!"}absolute(e,t){let r=this.clone();return 3&r.rel?(1&r.rel&&(r.col=(r.col+t)%16384),2&r.rel&&(r.row=(r.row+e)%1048576),r.rel=0,r):r}toRangeRef(){return new f(this,this)}relative(e,t,r){null==r&&(r=this.rel);let n=2&r?this.row-e:this.row,s=1&r?this.col-t:this.col;return new c(n,s,r).setSheet(this.sheet,this.hasSheet())}height(){return 1}width(){return 1}toString(){return a(null,this.row,this.col,3)}isCell(){return!0}leftColumn(){return this}rightColumn(){return this}topRow(){return this}bottomRow(){return this}forEachRow(e){e(this.toRangeRef())}forEachColumn(e){e(this.toRangeRef())}adjust(e,t,r,n,s,i,o){let a=this.absolute(e,t);if(s){if(a.row>=i){if(o<0&&a.row<i-o)return h;a.row+=o}}else if(a.col>=i){if(o<0&&a.col<i-o)return h;a.col+=o}return null!=r&&null!=n&&(a=a.relative(r,n,this.rel)),a}valid(){if(this.rel)throw new Error("valid() called on relative reference");let e=this.col,t=this.row;return!(isFinite(e)&&e<0||isFinite(t)&&t<0)}}class f extends u{constructor(e,t){super(),this.ref="range",e._hasSheet&&t._hasSheet&&e.sheet.toLowerCase()!=t.sheet.toLowerCase()&&(this.endSheet=t.sheet),this.topLeft=new c(e.row,e.col,e.rel),this.bottomRight=new c(t.row,t.col,t.rel),this.normalize()}clone(){return new f(this.topLeft.clone(),this.bottomRight.clone()).setSheet(this.sheet,this.hasSheet())}_containsRange(e){return this._containsCell(e.topLeft)&&this._containsCell(e.bottomRight)}_containsCell(e){return e.sheet==this.sheet&&e.row>=this.topLeft.row&&e.col>=this.topLeft.col&&e.row<=this.bottomRight.row&&e.col<=this.bottomRight.col}contains(e){if(e instanceof Array){let t=this;return e.some((function(e){return Boolean(t.contains(e))}))}return e instanceof c?this._containsCell(e):e instanceof f&&this._containsRange(e)}_intersectRange(e){if(this.sheet!=e.sheet)return h;let t=this.topLeft.col,r=this.topLeft.row,n=this.bottomRight.col,s=this.bottomRight.row,i=e.topLeft.col,o=e.topLeft.row,a=e.bottomRight.col,u=e.bottomRight.row;return t<=a&&i<=n&&r<=u&&o<=s?new f(new c(Math.max(r,o),Math.max(t,i)),new c(Math.min(s,u),Math.min(n,a))).setSheet(this.sheet,this.hasSheet()):h}intersect(e){return e instanceof c?this._containsCell(e)?e:h:e instanceof f?this._intersectRange(e).simplify():e instanceof p?e.intersect(this):h}simplify(){return this.isCell()?new c(this.topLeft.row,this.topLeft.col,this.topLeft.rel).setSheet(this.sheet,this.hasSheet()):this}normalize(){let e,t=this.topLeft,r=this.bottomRight,n=t.row,s=t.col,i=r.row,o=r.col,a=2&t.rel,u=1&t.rel,h=2&r.rel,l=1&r.rel,f=!1;return a===h&&u===l&&(n>i&&(f=!0,e=n,n=i,i=e,e=a,a=h,h=e),s>o&&(f=!0,e=s,s=o,o=e,e=u,u=l,l=e),f&&(this.topLeft=new c(n,s,u|a),this.bottomRight=new c(i,o,l|h))),this}print(e,t,r){if(r||this.absolute(e,t).valid()){let n=this.topLeft.print(e,t,r)+":"+this.bottomRight.print(e,t,r);return this.hasSheet()&&(n=o(this.sheet)+(this.endSheet?":"+o(this.endSheet):"")+"!"+n),n}return"#REF!"}absolute(e,t){return new f(this.topLeft.absolute(e,t),this.bottomRight.absolute(e,t)).setSheet(this.sheet,this.hasSheet())}relative(e,t,r,n){return null==n&&(n=r),new f(this.topLeft.relative(e,t,r),this.bottomRight.relative(e,t,n)).setSheet(this.sheet,this.hasSheet())}height(){if(this.topLeft.rel!=this.bottomRight.rel)throw new Error("Mixed relative/absolute references");return this.bottomRight.row-this.topLeft.row+1}width(){if(this.topLeft.rel!=this.bottomRight.rel)throw new Error("Mixed relative/absolute references");return this.bottomRight.col-this.topLeft.col+1}collapse(){return this.topLeft.toRangeRef()}leftColumn(){return new f(this.topLeft,new c(this.bottomRight.row,this.topLeft.col))}rightColumn(){return new f(new c(this.topLeft.row,this.bottomRight.col),this.bottomRight)}topRow(){return new f(this.topLeft,new c(this.topLeft.row,this.bottomRight.col))}bottomRow(){return new f(new c(this.bottomRight.row,this.topLeft.col),this.bottomRight)}toRangeRef(){return this}toRow(e){return e+=Math.max(0,this.topLeft.row),new f(new c(e,this.topLeft.col),new c(e,this.bottomRight.col)).setSheet(this.sheet,this.hasSheet())}toColumn(e){return e+=Math.max(0,this.topLeft.col),new f(new c(this.topLeft.row,e),new c(this.bottomRight.row,e)).setSheet(this.sheet,this.hasSheet())}toCell(e,t){return e+=Math.max(0,this.topLeft.row),t+=Math.max(0,this.topLeft.col),new c(e,t,0).setSheet(this.sheet,this.hasSheet())}forEachRow(e){let t=this.topLeft.row,r=this.bottomRight.row,n=this.topLeft.col,s=this.bottomRight.col;for(let i=t;i<=r;i++)e(new f(new c(i,n),new c(i,s)))}forEachColumn(e){let t=this.topLeft.row,r=this.bottomRight.row,n=this.topLeft.col,s=this.bottomRight.col;for(let i=n;i<=s;i++)e(new f(new c(t,i),new c(r,i)))}intersecting(e){return e.filter((e=>e.toRangeRef().intersects(this)))}union(e,t){let r=this.intersecting(e),n=this.topLeft.row,s=this.topLeft.col,i=this.bottomRight.row,o=this.bottomRight.col,a=!1;r.forEach((function(e){(e=e.toRangeRef()).topLeft.row<n&&(a=!0,n=e.topLeft.row),e.topLeft.col<s&&(a=!0,s=e.topLeft.col),e.bottomRight.row>i&&(a=!0,i=e.bottomRight.row),e.bottomRight.col>o&&(a=!0,o=e.bottomRight.col),t&&t(e)}));let u=new f(new c(n,s),new c(i,o));return a?u.union(e,t):u}resize(e){let t=Math.max.bind(Math,0);function r(e){return e||0}let n=this.topLeft.row+r(e.top),s=this.topLeft.col+r(e.left),i=this.bottomRight.row+r(e.bottom),o=this.bottomRight.col+r(e.right);return s<0&&o<0||n<0&&i<0?h:n<=i&&s<=o?new f(new c(t(n),t(s)),new c(t(i),t(o))):h}move(e,t){return new f(new c(this.topLeft.row+e,this.topLeft.col+t),new c(this.bottomRight.row+e,this.bottomRight.col+t))}first(){return this.topLeft.clone().setSheet(this.sheet,this.hasSheet())}isCell(){return!this.endSheet&&this.topLeft.eq(this.bottomRight)}toString(){return this.topLeft+":"+this.bottomRight}adjust(e,t,r,n,s,i,o){let a=this.topLeft.adjust(e,t,r,n,s,i,o),u=this.bottomRight.adjust(e,t,r,n,s,i,o);return a===h&&u===h?h:(a===h?(a=this.topLeft.absolute(e,t),s?a.row=i:a.col=i,null!=r&&null!=n&&(a=a.relative(r,n,this.topLeft.rel))):u===h&&(u=this.bottomRight.absolute(e,t),s?u.row=i-1:u.col=i-1,null!=r&&null!=n&&(u=u.relative(r,n,this.bottomRight.rel))),new f(a,u).setSheet(this.sheet,this.hasSheet()).simplify())}valid(){return this.topLeft.valid()&&this.bottomRight.valid()}}class p extends u{constructor(e){super(),this.refs=e,this.length=e.length}clone(){return new p(this.refs.slice())}intersect(e){let t=[];for(let r=0;r<this.length;++r){let n=e.intersect(this.refs[r]);n!==h&&t.push(n)}return t.length>0?new p(t).simplify():h}simplify(){let e=new p(this.refs.reduce((function(e,t){return(t=t.simplify())!==h&&e.push(t),e}),[]));return e.empty()?h:e.single()?e.refs[0]:e}absolute(e,t){return new p(this.refs.map((function(r){return r.absolute(e,t)})))}forEach(e,t){this.refs.forEach((function(r){r instanceof p?r.forEach(e,t):e.call(t,r)}),t)}toRangeRef(){return this.refs[0].toRangeRef()}contains(e){return this.refs.some((function(t){return t.contains(e)}))}map(e,t){let r=[];return this.forEach((function(n){r.push(e.call(t,n))})),new p(r)}first(){return this.refs[0].first()}lastRange(){return this.refs[this.length-1]}size(){return this.length}single(){return 1==this.length}empty(){return 0===this.length}isCell(){return this.single()&&this.refs[0].isCell()}rangeAt(e){return this.refs[e]}nextRangeIndex(e){return e===this.length-1?0:e+1}previousRangeIndex(e){return 0===e?this.length-1:e-1}concat(e){return new p(this.refs.concat([e]))}print(e,t,r){return this.refs.map((function(n){return n.print(e,t,r)})).join(",")}replaceAt(e,t){let r=this.refs.slice();return r.splice(e,1,t),new p(r)}leftColumn(){return this.map((function(e){return e.leftColumn()}))}rightColumn(){return this.map((function(e){return e.rightColumn()}))}topRow(){return this.map((function(e){return e.topRow()}))}bottomRow(){return this.map((function(e){return e.bottomRow()}))}forEachRow(e){this.forEach((function(t){t.forEachRow(e)}))}forEachColumn(e){this.forEach((function(t){t.forEachColumn(e)}))}adjust(e,t,r,n,s,i,o){return this.map((function(a){return a.adjust(e,t,r,n,s,i,o)})).simplify()}toString(){return this.refs.map((function(e){return e.toString()})).join(", ")}valid(){for(let e=this.refs.length;--e>=0;)if(this.refs[e].valid())return!1;return!0}renameSheet(e,t){this.refs.forEach((function(r){r.renameSheet(e,t)}))}}const d=new c(0,0),g=new f(new c(0,0),new c(1/0,1/0));g.print=function(){return"#SHEET"};const m={view:{nameBox:"Name Box",errors:{modifyMerged:"Cannot change part of a merged cell.",openUnsupported:"Unsupported format. Please select an .xlsx file.",shiftingNonblankCells:"Cannot insert cells due to data loss possibility. Select another insert location or delete the data from the end of your worksheet.",insertColumnWhenRowIsSelected:"Cannot insert column when all columns are selected.",insertRowWhenColumnIsSelected:"Cannot insert row when all rows are selected.",filterRangeContainingMerges:"Cannot create a filter within a range containing merges",sortRangeContainingMerges:"Cannot sort a range containing merges",cantSortMultipleSelection:"Cannot sort multiple selection",cantSortNullRef:"Cannot sort empty selection",cantSortMixedCells:"Cannot sort range containing cells of mixed shapes",validationError:"The value that you entered violates the validation rules set on the cell.",cannotModifyDisabled:"Cannot modify disabled cells.",insertRowBelowLastRow:"Cannot insert row below the last row.",insertColAfterLastCol:"Cannot insert column to the right of the last column."},tabs:{home:"Home",insert:"Insert",data:"Data"}},menus:{cut:"Cut",copy:"Copy",paste:"Paste",merge:"Merge",unmerge:"Unmerge",delete:"Delete",hide:"Hide",unhide:"Unhide",bringToFront:"Bring to front",sendToBack:"Send to back"},workbook:{defaultSheetName:"Sheet"}},v={name:"Spreadsheet",toolbar:!0,sheetsbar:!0,rows:200,columns:50,rowHeight:20,columnWidth:64,headerHeight:20,headerWidth:32,excel:{fileName:"Workbook.xlsx",forceProxy:!1,proxyURL:""},messages:m,pdf:{area:"workbook",fileName:"Workbook.pdf",proxyURL:"",paperSize:"a4",landscape:!0,margin:null,title:null,author:null,subject:null,keywords:null,creator:"Kendo UI PDF Generator",date:null},defaultCellStyle:{fontFamily:"Arial",fontSize:12},useCultureDecimals:!1,locale:"en"},y={recalc:!0,selection:!0,activeCell:!0,layout:!0,sheetSelection:!0,resize:!0,editorChange:!1,editorClose:!1},w=46,b=9,_=13,A=38,C=40,x=33,k=34,M=121,E=122,F=66,R=73,S=85,N=78,L=72,D=65,U=82,V=new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function $(e){let t=Object.create(null);return function(){let r="";for(let e=arguments.length;--e>=0;)r+=":"+arguments[e];return r in t?t[r]:t[r]=e.apply(this,arguments)}}function B(e,t){try{return e.call(t,(function(e){throw new r(e)}))}catch(e){if(e instanceof r)return e.value;throw e}function r(e){this.value=e}}const I={undefined:e=>e},T=/\[(?:(\d+)|['"](.*?)['"])\]|((?:(?!\[.*?\]|\.).)+)/g;function z(e,t){const r=e+t;if(I[r])return I[r];const n=[];return e.replace(T,((e,t,r,s)=>{n.push(q(t)?t:r||s)})),I[r]=e=>{let r=e;for(let e=0;e<n.length;e++)if(r=r[n[e]],!q(r)&&t)return r;return r},I[r]}function H(e){let t=1,r=arguments.length;for(t=1;t<r;t++)P(e,arguments[t]);return e}function P(e,t){let r,n,s,i;for(r in t)"__proto__"!==r&&"constructor"!==r&&(n=t[r],s=typeof n,n instanceof Date?e[r]=new Date(n.getTime()):X(n?.clone)?e[r]=n.clone():"object"===s&&null!==n&&G(n)?(i=e[r],"object"==typeof i&&null!==i||(e[r]={}),P(e[r],n)):"undefined"!==s&&(e[r]=n));return e}const O={},j=function(e){if(!isNaN(O._scrollbar)&&!e)return O._scrollbar;let t,r=document.createElement("div");return r.style.overflow="scroll",r.style.overflowX="hidden",r.style.zoom="1",r.style.clear="both",r.style.display="block",r.innerHTML="&nbsp;",document.body.appendChild(r),O._scrollbar=t=r.offsetWidth-r.scrollWidth,document.body.removeChild(r),t};const W=function(e,t){t.parentNode.insertBefore(e,t.nextSibling)},q=e=>null!=e,Y=e=>e&&e.getTime,J=e=>"string"==typeof e,X=e=>"function"==typeof e,G=function(e){if(!e||"[object Object]"!==toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t.constructor===Object};class K{constructor(e){if(e instanceof K)return e;this.code=e}toString(){return"#"+this.code+("NAME"===this.code?"?":"!")}}let Q={};const Z=e=>{if(!e)return Q;Q=e},ee=()=>Z().localeInfo();let te={runtime:{FUNCS:Object.create(null)}},re=te.runtime.FUNCS;class ne{constructor(e,t,r,n){this.callback=e,this.formula=t,this.ss=r,this.parent=n}resolve(e){var t=this;e instanceof u?t.resolveCells([e],(function(){t._resolve(e)})):t._resolve(e)}error(e){return new K(e)}_resolve(e){e=void 0===e?null:Array.isArray(e)?this.asMatrix(e):le(e);var t=this.formula;t.arrayFormulaRange?e=this.asMatrix(e)||this.asMatrix([[e]]):e instanceof f&&(e=this._arrayArg(e)),t.value=e,this.ss.onFormula(t)&&this.callback&&this.callback.call(t,e)}resolveCells(e,t){var r=this,n=[];if(function e(t){for(var n=0;n<t.length;++n){var s=t[n];s instanceof u&&o(r.getRefCells(s)),Array.isArray(s)&&e(s)}}(e),!n.length)return t.call(r);for(var s=n.length,i=0;i<n.length;++i)n[i].exec(r.ss,(function(){--s||t.call(r)}),r);function o(e){for(var t=0;t<e.length;++t){var r=e[t];r.formula&&n.push(r.formula)}return!0}}cellValues(e,t){for(var r=[],n=0;n<e.length;++n){var s=e[n];s instanceof u?(s=this.getRefData(s,t),r=r.concat(s)):Array.isArray(s)?r=r.concat(this.cellValues(s,t)):s instanceof ie?r=r.concat(this.cellValues(s.data,t)):r.push(s)}return r}fetchName(e,t){var r=this.formula,n=this.ss.nameValue(e,r.sheet,r.row,r.col);if(n instanceof ae){n=n.clone(r.sheet,r.row,r.col,!0);var s=new te.ValidationFormulaContext(this.ss.workbook);n.exec(s,t,this)}else n instanceof u&&((n=n.absolute(r.row,r.col))instanceof f&&this.ss.isMerged(n)&&(n=n.topLeft),n.sheet||(n.sheet=r.sheet)),t(null==n?new K("NAME"):n)}force(e){return e instanceof u?this.getRefData(e):e}func(e,t,r){e=e.toLowerCase();var n=re[e];if(n)return n.call(this,t,r);t(new K("NAME"))}bool(e){return e instanceof u&&(e=this.getRefData(e)),"string"==typeof e?"true"==e.toLowerCase():"number"==typeof e?0!==e:"boolean"==typeof e?e:null!=e}_arrayArg(e){var t=this.formula;return!t.arrayFormulaRange&&e instanceof f?1==e.height()&&t.col>=e.topLeft.col&&t.col<=e.bottomRight.col?this.getRefData(new c(e.topLeft.row,t.col).setSheet(e.sheet)):1==e.width()&&t.row>=e.topLeft.row&&t.row<=e.bottomRight.row?this.getRefData(new c(t.row,e.topLeft.col).setSheet(e.sheet)):new K("VALUE"):this.asMatrix(e)}asMatrix(e){if(e instanceof ie)return e;let t=this;if(e instanceof f){let r=e.topLeft,n=r.row,s=r.col,i=t.getRefCells(e),o=new ie(t);return isFinite(e.width())&&(o.width=e.width()),isFinite(e.height())&&(o.height=e.height()),isFinite(n)||(n=0),isFinite(s)||(s=0),i.forEach((function(e){o.set(e.row-n,e.col-s,e.value)})),o}if(Array.isArray(e)&&e.length>0){let r=new ie(t),n=0;return e.forEach((function(e){let s=0,i=1;e.forEach((function(e){let o=e instanceof f;e instanceof u&&!o&&(e=t.getRefData(e)),(o||Array.isArray(e))&&(e=t.asMatrix(e)),e instanceof ie?(e.each((function(e,t,i){r.set(n+t,s+i,e)})),i=Math.max(i,e.height),s+=e.width):("string"==typeof e&&e.length&&!isNaN(e)&&(e=Number(e)),r.set(n,s++,e))})),n+=i})),r}}getRefCells(e,t,r){var n=this.formula;return this.ss.getRefCells(e,t,n.sheet,n.row,n.col,r)}getRefData(e,t){var r=this.formula;return this.ss.getData(e,r.sheet,r.row,r.col,t)}workbook(){return this.ss.workbook}}function se(e,t,r){for(var n=r(e),s=e;++e<t;){var i=r(e);i>n&&(n=i,s=e)}return s}class ie{constructor(e){this.context=e,this.height=0,this.width=0,this.data=[]}clone(){var e=new ie(this.context);return e.height=this.height,e.width=this.width,e.data=this.data.map((function(e){return e.slice()})),e}get(e,t){var r=this.data[e],n=r?r[t]:null;return n instanceof u?this.context.getRefData(n):n}getNA(e,t){return 1==this.height&&(e=0),1==this.width&&(t=0),e<this.height&&t<this.width?this.get(e,t):new K("N/A")}set(e,t,r){if("__proto__"!==t&&"constructor"!==t&&"prototype"!==t&&"__proto__"!==e&&"constructor"!==e&&"prototype"!==e){var n=this.data[e];null==n&&(n=this.data[e]=[]),n[t]=r,e>=this.height&&(this.height=e+1),t>=this.width&&(this.width=t+1)}}each(e,t){for(var r=0;r<this.height;++r)for(var n=0;n<this.width;++n){var s=this.get(r,n);if((t||null!=s)&&void 0!==(s=e.call(this.context,s,r,n)))return s}}map(e,t){var r=new ie(this.context);return this.each((function(t,n,s){r.set(n,s,e.call(this,t,n,s))}),t),r}eachRow(e){for(var t=0;t<this.height;++t){var r=e.call(this.context,t);if(void 0!==r)return r}}eachCol(e){for(var t=0;t<this.width;++t){var r=e.call(this.context,t);if(void 0!==r)return r}}mapRow(e){var t=new ie(this.context);return this.eachRow((function(r){t.set(r,0,e.call(this.context,r))})),t}mapCol(e){var t=new ie(this.context);return this.eachCol((function(r){t.set(0,r,e.call(this.context,r))})),t}toString(){return JSON.stringify(this.data)}transpose(){var e=new ie(this.context);return this.each((function(t,r,n){e.set(n,r,t)})),e}unit(e){this.width=this.height=e;for(var t=this.data=new Array(e),r=e;--r>=0;)for(var n=t[r]=new Array(e),s=e;--s>=0;)n[s]=r==s?1:0;return this}multiply(e){for(var t=this,r=new ie(t.context),n=0;n<t.height;++n)for(var s=0;s<e.width;++s){for(var i=0,o=0;o<t.width;++o){var a=t.get(n,o),u=e.get(o,s);if("number"!=typeof a||"number"!=typeof u)throw new K("VALUE");i+=a*u}r.set(n,s,i)}return r}adds(e,t){for(var r=this,n=new ie(r.context),s=t?-1:1,i=0;i<r.height;++i)for(var o=0;o<r.width;++o){var a=r.get(i,o),u=e.get(i,o);n.set(i,o,a+s*u)}return n}determinant(){var e,t,r,n,s=this.clone().data,i=s.length,o=1;for(e=0;e<i;e++){for(t=e;t<i&&!s[t][e];t++);if(t==i)return 0;if(t!=e)for(o=-o,n=e;n<i;n++){var a=s[e][n];s[e][n]=s[t][n],s[t][n]=a}for(r=e+1;r<i;r++)for(n=e+1;n<i;n++)s[r][n]-=s[e][n]*s[r][e]/s[e][e];o*=s[e][e]}return o}inverse(){let e,t=this.width,r=this.augment(new ie(this.context).unit(t)),n=r.data;for(let r=0;r<t;++r){let s=se(r,t,(function(e){return n[e][r]}));if(!n[s][r])return null;r!=s&&(e=n[r],n[r]=n[s],n[s]=e);for(let e=r+1;e<t;++e){for(let s=r+1;s<2*t;++s)n[e][s]-=n[r][s]*n[e][r]/n[r][r];n[e][r]=0}}for(let e=0;e<t;++e)for(let r=n[e][e],s=0;s<2*t;++s)n[e][s]/=r;for(let e=t;--e>=0;)for(let r=e;--r>=0;)if(n[r][e])for(let s=2*t;--s>=t;)n[r][s]-=n[e][s]*n[r][e];return r.slice(0,t,t,t)}augment(e){var t=this.clone(),r=t.width;return e.each((function(e,n,s){t.set(n,s+r,e)})),t}slice(e,t,r,n){for(var s=new ie(this.context),i=0;i<r;++i)for(var o=0;o<n;++o)s.set(i,o,this.get(e+i,t+o));return s}}function oe(e,t){if(e.constructor!==t.constructor)return!1;if(e instanceof c)return e.sheet==t.sheet&&e.row==t.row&&e.col==t.col&&e.rel==t.rel;if(e instanceof f)return oe(e.topLeft,t.topLeft)&&oe(e.bottomRight,t.bottomRight)&&e.endSheet==t.endSheet;if(e instanceof p){var r=e.refs.length;if(r!=t.refs.length)return!1;for(;--r>=0;)if(!oe(e.refs[r],t.refs[r]))return!1}return!0}let ae=class e{constructor(e,t,r,n,s,i,o){this.refs=e,this.handler=t,this.print=r,this.absrefs=null,this.sheet=n,this.row=s,this.col=i,this.onReady=[],this.pending=!1,this.arrayFormulaRange=o}setArrayFormulaRange(e){this.arrayFormulaRange=e.clone().setSheet(this.sheet)}clone(t,r,n,s){var i=t.toLowerCase(),o=this.refs,a=this.arrayFormulaRange;return(s||i!=this.sheet.toLowerCase())&&(o=o.map((function(e){return e.hasSheet()||e.sheet&&e.sheet.toLowerCase()==i||(e=e.clone().setSheet(t)),e})),a&&(a=a.clone().setSheet(t))),new e(o,this.handler,this.print,t,r,n,a)}deepClone(){var t=this.refs.map((function(e){return e.clone()}));return new e(t,this.handler,this.print,this.sheet,this.row,this.col,this.arrayFormulaRange)}resolve(e){this.pending=!1,this.onReady.forEach((function(t){t(e)}))}exec(e,t,r){if("value"in this)t&&t(this.value);else{t&&this.onReady.push(t);for(var n=new ne(this.resolve,this,e,r),s=0;r;){if(r.formula===this)return this.pending=!1,void n.resolve(new K("CIRCULAR"));r=r.parent,++s}if(this.pending)return;this.pending=!0;var i=function(){this.absrefs||(this.absrefs=this.refs.map((function(e){return e.absolute(this.row,this.col)}),this)),this.handler.call(n)}.bind(this);s<20?i():setTimeout(i,0)}}reset(){this.onReady=[],this.pending=!1,delete this.value}renameSheet(e,t){e=e.toLowerCase(),this.absrefs=null,this.sheet.toLowerCase()==e&&(this.sheet=t),this.refs.forEach((function(r){r.renameSheet(e,t)}))}adjust(t,r,n,s){t=t.toLowerCase();var i=this.row,o=this.col,a=this.sheet.toLowerCase(),u=!1;a==t&&("row"==r&&i>=n&&(this.row+=s,u=!0),"col"==r&&o>=n&&(this.col+=s,u=!0));var l=this.row,c=this.col;this.absrefs=null;var f=this.refs,p=u;this.refs=f.map((function(e){var t=g(e);return p||oe(t,e)||(p=!0),t}));var d=this.arrayFormulaRange;if(d&&(this.arrayFormulaRange=g(d),p||oe(d,this.arrayFormulaRange)||(p=!0)),p)return new e(f,this.handler,this.print,this.sheet,i,o,d);function g(e){return e===h?e:e.sheet.toLowerCase()!=t?(u&&("row"==r&&i>=n&&(e=e.relative(s,0)),"col"==r&&o>=n&&(e=e.relative(0,s))),e):e.adjust(i,o,l,c,"row"==r,n,s)}}toString(){return this.print(this.row,this.col)}};function ue(e,t){var r,n,s,i="function arrayArgs(args) { var xargs = [], width = 0, height = 0, arrays = [], i = 0; ",o="function resolve(args, callback) { var toResolve = [], i = 0; ",a="'use strict'; function check(args) { var stack = [], tmp, xargs = [], i = 0, m, err = 'VALUE'; ",u=!1,h=!1,l=!1;return a+=t.map((function e(t){r=t[0];var s="{ ";if(Array.isArray(r))i+="while (i < args.length) { ",o+="while (i < args.length) { ",s+="xargs.push(tmp = []); stack.push(xargs); xargs = tmp; ",s+="while (i < args.length) { ",s+=t.map(e).join(""),s+="} ",s+="xargs = stack.pop(); ",o+="} ",i+="} ";else if("+"==r)i+="while (i < args.length) { ",o+="while (i < args.length) { ",s+="if (i >= args.length) return new CalcError('N/A'); ",s+="xargs.push(tmp = []); stack.push(xargs); xargs = tmp; ",s+="do { ",s+=t.slice(1).map(e).join(""),s+="} while (i < args.length); ",s+="xargs = stack.pop(); ",o+="} ",i+="} ";else if("?"==r)s+="if (!("+p(t[1])+")) return new CalcError(err); ";else{var a=t[1];if(Array.isArray(a)&&/^#?collect/.test(a[0])){var u=/!$/.test(a[0]),f=a[2];c(),s+="try {var $"+r+" = this.cellValues(args.slice(i",f&&(s+=", i + "+f),s+=")"+(u?",true":"")+").reduce(function(ret, $"+r+"){ ","#"!=a[0].charAt(0)&&(s+="if ($"+r+" instanceof CalcError) throw $"+r+"; "),s+="if ("+p(a[1])+") ret.push($"+r+"); ",s+="return ret; ",s+="}.bind(this), []); ",s+=f?"i += "+f+"; ":"i = args.length; ",s+="xargs.push($"+r+")} catch(ex) { if (ex instanceof CalcError) return ex; throw ex; } ",o+="toResolve.push(args.slice(i)); "}else if("rest"==a)s+="xargs.push(args.slice(i)); i = args.length; ";else{(h=/^\*/.test(r))&&(l=!0,r=r.substr(1)),s+="var $"+r+" = args[i++]; ";var d=!1;/!$/.test(a)?(a=a.substr(0,a.length-1),d=!0):s+="if ($"+r+" instanceof CalcError) return $"+r+"; ",s+=function(e,t){n=!1;var s="if (!("+p(e)+")) { ";n&&!t&&(s+=" if ($"+r+" instanceof CalcError) return $"+r+"; ");n||(o+="i++; ");i+=h?"var $"+r+" = this._arrayArg(args[i]); if ($"+r+") { xargs.push($"+r+"); width = Math.max(width, $"+r+".width); height = Math.max(height, $"+r+".height); arrays.push(true) } else { xargs.push(args[i]); arrays.push(false); } i++; ":"xargs.push(args[i++]); arrays.push(false); ";return s+="return new CalcError(err); } "}(a,d)+"xargs.push($"+r+"); "}}return s+="} "})).join(""),a+="if (i < args.length) return new CalcError('N/A'); ",a+="return xargs; } ",i+="return { args: xargs, width: width, height: height, arrays: arrays }; } ",u?(o+="this.resolveCells(toResolve, callback); } ",s=new Function("kendo","CalcError","round",a+o+i+" return { resolve: resolve, check: check, arrayArgs: arrayArgs };")):s=new Function("kendo","CalcError","round",a+" return { check: check };"),s=s(te.kendo,K,he),l||delete s.arrayArgs,s;function c(){return n?"$"+r:(u=!0,n=!0,o+="toResolve.push(args[i++]); ","($"+r+" = this.force($"+r+"))")}function f(e){return"("+(e?"(typeof "+c()+" == 'number' ? ($"+r+" = round($"+r+"), true) : false) || ":"(typeof "+c()+" == 'number') || ")+"(typeof $"+r+" == 'boolean' ? ($"+r+" = +$"+r+", true) : false) || (typeof $"+r+" == 'string' && !/^(?:=|true|false)/i.test($"+r+") ? (tmp = kendo.spreadsheet.calc.parse(0, 0, 0, $"+r+"), /^date|number|percent$/.test(tmp.type) ? ($"+r+" = +tmp.value, true) : false) : false))"}function p(e){if(Array.isArray(e)){if("or"==e[0])return"("+e.slice(1).map(p).join(") || (")+")";if("and"==e[0])return"("+e.slice(1).map(p).join(") && (")+")";if("values"==e[0])return"("+e.slice(1).map((function(e){return c()+" === "+e})).join(") || (")+")";if("null"==e[0])return"("+p("null")+" ? (($"+r+" = "+e[1]+"), true) : false)";if("between"==e[0]||"[between]"==e[0])return"("+c()+" >= "+e[1]+" && $"+r+" <= "+e[2]+" ? true : ((err = 'NUM'), false))";if("(between)"==e[0])return"("+c()+" > "+e[1]+" && $"+r+" < "+e[2]+" ? true : ((err = 'NUM'), false))";if("(between]"==e[0])return"("+c()+" > "+e[1]+" && $"+r+" <= "+e[2]+" ? true : ((err = 'NUM'), false))";if("[between)"==e[0])return"("+c()+" >= "+e[1]+" && $"+r+" < "+e[2]+" ? true : ((err = 'NUM'), false))";if("assert"==e[0]){var t=e[2]||"N/A";return"(("+e[1]+") ? true : (err = "+JSON.stringify(t)+", false))"}if("not"==e[0])return"!("+p(e[1])+")";throw new Error("Unknown array type condition: "+e[0])}if("number"==e||"datetime"==e)return f(!0);if("number!"==e)return"(typeof "+c()+" == 'number' ? ($"+r+" = round($"+r+"), true) : false)";if("integer"==e||"date"==e)return"("+f()+" && (($"+r+" |= 0), true))";if("divisor"==e)return"("+f(!0)+" && ($"+r+" == 0 ? ((err = 'DIV/0'), false) : true))";if("number+"==e)return"("+f(!0)+" && ($"+r+" >= 0 ? true : ((err = 'NUM'), false)))";if("integer+"==e)return"("+f()+" && (($"+r+" |= 0) >= 0 ? true : ((err = 'NUM'), false)))";if("number++"==e)return"("+f(!0)+" && ($"+r+" > 0 ? true : ((err = 'NUM'), false)))";if("integer++"==e)return"("+f()+" && (($"+r+" |= 0) > 0 ? true : ((err = 'NUM'), false)))";if("string"==e)return"((typeof "+c()+" == 'string' || typeof $"+r+" == 'boolean' || typeof $"+r+" == 'number') ? ($"+r+" += '', true) : ($"+r+" === undefined ? (($"+r+" = ''), true) : false))";if("boolean"==e)return"(typeof "+c()+" == 'boolean')";if("logical"==e)return"(typeof "+c()+" == 'boolean' || (typeof $"+r+" == 'number' ? ($"+r+" = !!$"+r+", true) : false))";if("matrix"==e)return c(),"((m = this.asMatrix($"+r+")) ? ($"+r+" = m) : false)";if("#matrix"==e)return"((m = this.asMatrix($"+r+")) ? ($"+r+" = m) : false)";if("ref"==e)return"($"+r+" instanceof kendo.spreadsheet.Ref)";if("area"==e)return"($"+r+" instanceof kendo.spreadsheet.CellRef || $"+r+" instanceof kendo.spreadsheet.RangeRef)";if("cell"==e)return"($"+r+" instanceof kendo.spreadsheet.CellRef)";if("null"==e)return"("+c()+" == null)";if("anyvalue"==e)return"("+c()+" != null && i <= args.length)";if("forced"==e)return"("+c()+", i <= args.length)";if("anything"==e)return"(i <= args.length)";if("blank"==e)return"("+c()+" == null || $"+r+" === '')";throw new Error("Can't check for type: "+e)}}function he(e,t){return e===parseInt(e,10)?e:+e.toPrecision(t||16)}function le(e,t){return"number"==typeof e?he(e,t):e}function ce(e,t,r){if(r instanceof K)return r;try{return t.apply(e,r)}catch(e){if(e instanceof K)return e;throw e}}function fe(e,t,r,n){return function(s,i){function o(){if(n){let t=n.call(this,i);if(i=t.args,t.width>0&&t.height>0){let n=new ie(this);for(let s=0;s<t.height;++s)for(let o=0;o<t.width;++o){let a=[];for(let e=0;e<i.length;++e)t.arrays[e]?a[e]=i[e].getNA(s,o):a[e]=i[e];a=r.call(this,a),n.set(s,o,ce(this,e,a))}return s(n)}}let t=r.call(this,i);s(ce(this,e,t))}t?t.call(this,i,o):o.call(this)}}function pe(e,t,r,n){return function(s,i){function o(){if(n){let t=n.call(this,i);if(i=t.args,t.width>0&&t.height>0){let n=new ie(this),o=t.width*t.height,a=function(e,t){return function(r){if(n.set(e,t,r),--o,0===o)return s(n)}};for(let u=0;u<t.height&&o>0;++u)for(let h=0;h<t.width&&o>0;++h){let l=[];for(let e=0;e<i.length;++e)t.arrays[e]?l[e]=i[e].getNA(u,h):l[e]=i[e];if(l=r.call(this,l),l instanceof K){if(n.set(u,h,l),--o,0===o)return s(n)}else l.unshift(a(u,h)),e.apply(this,l)}return}}let t=r.call(this,i);t instanceof K?s(t):(t.unshift(s),e.apply(this,t))}t?t.call(this,i,o):o.call(this)}}function de(e,t,r){return(1461*(e+4800+((++t-14)/12|0))/4|0)+(367*(t-2-12*((t-14)/12|0))/12|0)-(3*((e+4900+((t-14)/12|0))/100|0)/4|0)+r-32075}re.if=function(e,t){var r=this,n=t[0],s=t[1],i=t[2];this.resolveCells([n],(function(){var t=r.asMatrix(n);t?s((function(n){i((function(s){var i=r.asMatrix(n),o=r.asMatrix(s);e(t.map((function(e,t,a){return e instanceof K?e:r.bool(e)?i?i.get(t,a):n:o?o.get(t,a):s})))}))})):(n=this.force(n))instanceof K?e(n):r.bool(n)?s(e):i(e)}))},re["φ"]=function(e){e((1+Math.sqrt(5))/2)};var ge=de(1900,0,-1),me=[31,28,31,30,31,30,31,31,30,31,30,31],ve=[[0,31,59,90,120,151,181,212,243,273,304,334],[0,31,60,91,121,152,182,213,244,274,305,335]];function ye(e){return e%4?0:e%100?1:e%400?0:1}function we(e,t){return ye(e)&&1==t?29:me[t]}function be(e){return r=(t=(0|e)+ge)+68569,a=(r=(r-=(146097*(n=4*r/146097|0)+3)/4|0)-(1461*(i=4e3*(r+1)/1461001|0)/4|0)+31)-(2447*(s=80*r/2447|0)/80|0),o=s+2-12*(r=s/11|0),{year:u=100*(n-49)+i+r,month:--o,date:a,day:(t+1)%7,ord:ve[ye(u)][o]+a};var t,r,n,s,i,o,a,u}function _e(e,t,r){return de(e,t,r)-ge}var Ae=6e4,Ce=36e5;function xe(e){var t=e-(0|e);t<0&&t++;var r=Math.round(864e5*t),n=Math.floor(r/Ce);r-=n*Ce;var s=Math.floor(r/Ae);r-=s*Ae;var i=Math.floor(r/1e3);return{hours:n,minutes:s,seconds:i,milliseconds:r-=1e3*i}}function ke(e,t,r,n){return(e+(t+(r+n/1e3)/60)/60)/24}class Me{constructor(e,t){this.message=e,this.pos=t}toString(){return this.message}}function Ee(){this.node=null}function Fe(){}te.runtime.CalcError=K,te.runtime.Formula=ae,te.runtime.Matrix=ie,te.runtime.packDate=_e,te.runtime.unpackDate=be,te.runtime.packTime=ke,te.runtime.unpackTime=xe,te.runtime.serialToDate=function(e){var t=be(e),r=xe(e);return new Date(t.year,t.month,t.date,r.hours,r.minutes,r.seconds,r.milliseconds)},te.runtime.dateToSerial=function(e){var t=ke(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds());return(e=_e(e.getFullYear(),e.getMonth(),e.getDate()))<0?e-1+t:e+t},te.runtime.daysInMonth=we,te.runtime.validDate=function(e,t,r){return t>=1&&t<=12&&r>=1&&r<=we(e,t-1)},te.runtime.isLeapYear=ye,te.runtime.daysInYear=function(e){return ye(e)?366:365},te.runtime.parseDate=function(e,t){t&&(t=te.formatting.makeDateFormat(t));const r=Z().parseDate;return r(e,t)||r(e)||r(e,["MMMM dd yyyy","MMMM dd yy","MMM dd yyyy","MMM dd yy","dd MMMM yyyy","dd MMMM yy","dd MMM yyyy","dd MMM yy","MMMM dd, yyyy","MMMM dd, yy","MMM dd, yyyy","MMM dd, yy","MMMM dd","MMM dd","MMMM yyyy","MMM yyyy","dd MMMM","dd MMM"])},te.runtime.limitPrecision=he,te.runtime.defineBuiltinFunction=function(e,t,r,n){re[e]=t?pe(n,r.resolve,r.check,r.arrayArgs):fe(n,r.resolve,r.check,r.arrayArgs)},te.runtime.defineAlias=function(e,t){var r=re[t];if(!r)throw new Error("Function "+t+" is not yet defined");r.kendoSpreadsheetAliases||(r.kendoSpreadsheetAliases=[t]),r.kendoSpreadsheetAliases.push(e),re[e]=r},te.runtime.InputStream=function(e){let t=0;return{next:r,peek:n,eof:s,croak:i,readWhile:function(e){let t="";for(;!s()&&e(n(),t);)t+=r();return t},readEscaped:function(e){let t=!1,n="";for(;!s();){let s=r();if(t)n+=s,t=!1;else if("\\"===s)t=!0;else{if(s===e)break;n+=s}}return n},lookingAt:function(r){return r.exec(e.substr(t))},skip:function(r){if("string"==typeof r)e.substr(t,r.length)!==r&&i("Expected "+r),o(r.length);else if(r instanceof RegExp){let n=r.exec(e.substr(t));if(n)return o(n[0].length),n}else o(r[0].length)},forward:o,pos:function(){return t}};function r(){return e.charAt(t++)}function n(){return e.charAt(t)}function s(){return""===n()}function i(r){throw new Me(r+" (input: "+e+")",t)}function o(e){for(;e-- >0;)r()}},te.runtime.ParseError=Me,Ee.prototype={remove:function(){this.node.parentNode&&this.node.parentNode.removeChild(this.node),this.attr={}},attr:{},text:function(){return""}},Fe.prototype={nodeName:"#null",attr:{style:{}},children:[],remove:function(){}};let Re=new Fe;function Se(e,t,r){this.nodeName=e,this.attr=t||{},this.children=r||[]}function Ne(e){this.nodeValue=String(e)}function Le(e){this.html=e}function De(e){return new Le(e)}function Ue(e,t,r){return new Se(e,t,r)}function Ve(e){return new Ne(e)}function $e(e){this.root=e,this.children=[]}Se.prototype=new Ee,Se.prototype.appendTo=function(e){let t="string"==typeof this.nodeName?document.createElement(this.nodeName):this.nodeName,r=this.children;for(let e=0;e<r.length;e++)r[e].render(t,Re);return e.appendChild(t),t},Se.prototype.render=function(e,t){let r;if(t.nodeName!==this.nodeName)t.remove(),r=this.appendTo(e);else{let n;r=t.node;let s=this.children,i=s.length,o=t.children,a=o.length;if(Math.abs(a-i)>2)return void this.render({appendChild:function(r){e.replaceChild(r,t.node)}},Re);for(n=0;n<i;n++)s[n].render(r,o[n]||Re);for(n=i;n<a;n++)o[n].remove()}this.node=r,this.syncAttributes(t.attr),this.removeAttributes(t.attr)},Se.prototype.syncAttributes=function(e){let t=this.attr;for(let r in t){let n=t[r],s=e[r];"style"===r?this.setStyle(n,s):n!==s&&this.setAttribute(r,n,s)}},Se.prototype.setStyle=function(e,t){let r,n=this.node;if(t)for(r in e)e[r]!==t[r]&&(n.style[r]=e[r]);else for(r in e)n.style[r]=e[r]},Se.prototype.removeStyle=function(e){let t=this.attr.style||{},r=this.node;for(let n in e)void 0===t[n]&&(r.style[n]="")},Se.prototype.removeAttributes=function(e){let t=this.attr;for(let r in e)"style"===r?this.removeStyle(e.style):void 0===t[r]&&this.removeAttribute(r)},Se.prototype.removeAttribute=function(e){let t=this.node;"style"===e?t.style.cssText="":"className"===e?t.className="":t.removeAttribute(e)},Se.prototype.setAttribute=function(e,t){let r=this.node;void 0!==r[e]?r[e]=t:r.setAttribute(e,t)},Se.prototype.text=function(){let e="";for(let t=0;t<this.children.length;++t)e+=this.children[t].text();return e},Ne.prototype=new Ee,Ne.prototype.nodeName="#text",Ne.prototype.render=function(e,t){let r;t.nodeName!==this.nodeName?(t.remove(),r=document.createTextNode(this.nodeValue),e.appendChild(r)):(r=t.node,this.nodeValue!==t.nodeValue&&r.parentNode&&(r.nodeValue=this.nodeValue)),this.node=r},Ne.prototype.text=function(){return this.nodeValue},Le.prototype={nodeName:"#html",attr:{},remove:function(){for(let e=0;e<this.nodes.length;e++){let t=this.nodes[e];t.parentNode&&t.parentNode.removeChild(t)}},render:function(e,t){if(t.nodeName!==this.nodeName||t.html!==this.html){t.remove();let r=e.lastChild;!function(e,t){const r=document.createElement("div");r.innerHTML=t;for(;r.firstChild;)e.appendChild(r.firstChild)}(e,this.html),this.nodes=[];for(let t=r?r.nextSibling:e.firstChild;t;t=t.nextSibling)this.nodes.push(t)}else this.nodes=t.nodes.slice(0)}},$e.prototype={html:De,element:Ue,text:Ve,render:function(e){let t,r,n=this.children;for(t=0,r=e.length;t<r;t++){let r=n[t];r?r.node&&r.node.parentNode||(r.remove(),r=Re):r=Re,e[t].render(this.root,r)}for(t=r;t<n.length;t++)n[t].remove();this.children=e}};const Be={html:De,text:Ve,element:Ue,Tree:$e,Node:Ee};let Ie=/^\[(black|green|white|blue|magenta|yellow|cyan|red)\]/i,Te=/^\[(<=|>=|<>|<|>|=)(-?[0-9.]+)\]/;function ze(e){e=te.runtime.InputStream(e);let t,r=[],n=!1;for(;!e.eof();){let e=u();r.push(e),e.cond&&(n=!0)}return n||(1===r.length?r[0].cond="num":2===r.length?(r[0].cond={op:">=",value:0},r[1].cond={op:"<",value:0}):r.length>=3&&(r[0].cond={op:">",value:0},r[1].cond={op:"<",value:0},r[2].cond={op:"=",value:0},r.length>3&&(r[3].cond="text",r=r.slice(0,4)))),r;function s(){let t=e.skip(Ie);if(t)return t[1].toLowerCase()}function i(){let t,r=[],n=null;for(;!e.eof()&&(t=a());)"date"===t.type?n&&/^(el)?time$/.test(n.type)&&"h"===n.part&&"m"===t.part&&t.format<3&&(t.type="time"):/^(el)?time$/.test(t.type)&&"s"===t.part&&n&&"date"===n.type&&"m"===n.part&&n.format<3&&(n.type="time"),/^(?:str|space|fill)$/.test(t.type)||(n=t),r.push(t);return r}function o(t){if("date"!==t.type||"m"===t.part&&t.format<3){let r=e.skip(/^\.(0+)/);r&&(t.fraction=r[1].length,"date"===t.type&&(t.type="time"))}return t}function a(){let r,n;if(n=e.skip(/^([#0?]+)(?:,([#0?]+))+/))return{type:"digit",sep:!0,format:n[1]+n[2],decimal:t};if(n=e.skip(/^[#0?]+/))return{type:"digit",sep:!1,format:n[0],decimal:t};if(n=e.skip(/^(e)([+-])/i))return{type:"exp",ch:n[1],sign:n[2]};if(n=e.skip(/^(d{1,4}|m{1,5}|yyyy|yy|y)/i))return n=n[1].toLowerCase(),o({type:"date",part:n.charAt(0),format:n.length});if(n=e.skip(/^(hh?|ss?)/i))return n=n[1].toLowerCase(),o({type:"time",part:n.charAt(0),format:n.length});if(n=e.skip(/^\[(hh?|mm?|ss?)\]/i))return n=n[1].toLowerCase(),o({type:"eltime",part:n.charAt(0),format:n.length});if(n=e.skip(/^(a[.]?m[.]?\/p[.]?m[.]?|a\/p)/i))return n=n[1].split("/"),{type:"ampm",am:n[0],pm:n[1]};switch(r=e.next()){case";":return null;case"\\":return{type:"str",value:e.next()};case'"':return{type:"str",value:e.readEscaped(r)};case"@":return{type:"text"};case"_":return{type:"space",value:e.next()};case"*":return{type:"fill",value:e.next()};case".":return e.lookingAt(/^\s*[#0?]/)?(t=!0,{type:"dec"}):{type:"str",value:"."};case"%":return{type:"percent"};case",":return{type:"comma"}}return{type:"str",value:r}}function u(){t=!1;let r=s(),n=function(){let t=e.skip(Te);if(t){let e=parseFloat(t[2]);if(!isNaN(e))return{op:t[1],value:e,custom:!0}}}();return!r&&n&&(r=s()),{color:r,cond:n,body:i()}}}let He={unpackDate:te.runtime.unpackDate,unpackTime:te.runtime.unpackTime,date:function(e,t,r,n){switch(r){case"d":switch(n){case 1:return t.date;case 2:return qe(t.date,2,"0");case 3:return e.calendar.days.format.abbreviated[t.day];case 4:return e.calendar.days.format.wide[t.day]}break;case"m":switch(n){case 1:return t.month+1;case 2:return qe(t.month+1,2,"0");case 3:return e.calendar.months.format.abbreviated[t.month];case 4:return e.calendar.months.format.wide[t.month];case 5:return e.calendar.months.format.narrow[t.month]}break;case"y":switch(n){case 1:case 4:return t.year;case 2:return t.year%100}}return"##"},time:function(e,t,r,n,s){let i,o;switch(t){case"h":i=qe(n?e.hours%12||12:e.hours,r,"0"),s&&(o=(e.minutes+(e.seconds+e.milliseconds/1e3)/60)/60);break;case"m":i=qe(e.minutes,r,"0"),s&&(o=(e.seconds+e.milliseconds/1e3)/60);break;case"s":i=qe(e.seconds,r,"0"),s&&(o=e.milliseconds/1e3)}return o&&(i+=He.toFixed(o,s).replace(/^0+/,"")),i},eltime:function(e,t,r,n){let s,i;switch(t){case"h":s=24*e;break;case"m":s=24*e*60;break;case"s":s=24*e*60*60}return n&&(i=s-(0|s)),s=qe(0|s,r,"0"),i&&(s+=He.toFixed(i,n).replace(/^0+/,"")),s},fill:function(e){return e},formatInt:function(e,t,r,n,s){t=He.toFixed(t,n).replace(/\..*$/,"");let i=r[r.length-1];n>0&&"0"!=i[r.length-1]&&("0"===t?t="":"-0"===t&&(t="-"));let o,a=!1,u=t.length-1,h=[],l=0;function c(t,r){s&&l&&l%3==0&&/^[0-9]$/.test(t)&&(o=e.numbers.symbols.group+o),r&&"-"===t&&(a=!0,t="0"),o=t+o,l++}for(let e=r.length;--e>=0;){let n=r[e];o="";for(let e=n.length;--e>=0;){let r=n.charAt(e);u<0?"0"==r?c("0"):"?"==r&&c(" "):("0"==t&&"?"==r?c(" "):"0"==r?c(t.charAt(u),!0):c(t.charAt(u)),u--)}if(0===e)for(;u>=0;)c(t.charAt(u--));h.unshift(o)}return a&&(h[0]="-"+h[0]),h},formatDec:function(e,t,r){let n=(e=He.toFixed(e,r)).indexOf(".");e=n>=0?e.substr(n+1).replace(/0+$/,""):"";let s=0,i=[];for(let r=0;r<t.length;++r){let n=t[r],o="";for(let t=0;t<n.length;++t){let r=n.charAt(t);s<e.length?o+=e.charAt(s++):"0"==r?o+="0":"?"==r&&(o+=" ")}i.push(o)}return i},toFixed:function(e,t){return function e(r,n){if(!isFinite(r))return"#NUM!";if(r<0)return"-"+e(-r);if(0===t)return String(Math.round(r));if(r===Math.round(r)&&!/e/i.test(String(r)))return r.toFixed(t);let s=function(e){let t,r,n,s=String(e).toLowerCase(),i=s.indexOf(".");i<0?(i=s.indexOf("e"),i<0?(t=s,r=""):(t=s.substr(0,i),r=s.substr(i))):(t=s.substr(0,i),r=s.substr(i+1));if(n=/(\d*)e([-+]?\d+)/.exec(r)){let e=parseInt(n[2],10);e>=0?(r=function(e,t,r){e+="";for(;e.length<t;)e+=r;return e}(n[1],e,"0"),t+=r.substr(0,e),r=r.substr(e)):(t=qe(t,-e,"0"),r=t.substr(e)+n[1],t=t.substr(0,t.length+e))}return{intpart:t||"0",decpart:r}}(r),i=s.intpart,o=s.decpart;if(o.length<=t){for(;o.length<t;)o+="0";return i+"."+o}if(n)return i+"."+o.substr(0,t);let a=Math.pow(10,t);return e(Math.round(r*a)/a,!0)}(Number(e.toFixed(14)))}};function Pe(e){let t=function(e){let t=0;return{next:function(){return e[t++]},eof:function(){return t>=e.length},ahead:function(r,n){if(t+r<=e.length){let s=n.apply(null,e.slice(t,t+r));return s&&(t+=r),s}},restart:function(){t=0}}}(e.body),r=!1,n=!1,s=!1,i=0,o=/[\$\xA2-\xA5\u058F\u060B\u09F2\u09F3\u09FB\u0AF1\u0BF9\u0E3F\u17DB\u20A0-\u20BD\uA838\uFDFC\uFE69\uFF04\uFFE0\uFFE1\uFFE5\uFFE6]/,a=0,u=!1,h=0,l=[],c=[],f=e.cond;function p(e,t){("digit"===e.type&&"comma"===t.type||"comma"===e.type&&e.hidden&&"comma"===t.type)&&(t.hidden=!0,a++)}for(;!t.eof();){t.ahead(2,p);let e=t.next();"percent"===e.type?i++:"digit"===e.type?e.decimal?(h+=e.format.length,c.push(e.format)):(l.push(e.format),e.sep&&(u=!0)):"time"===e.type?n=!0:"date"===e.type?r=!0:"ampm"===e.type&&(s=n=!0)}return function(p,d,g){let m,v,y,w,b;if("text"===f){if(!("string"==typeof d||d instanceof K))return!1}else if("num"===f){if("number"!=typeof d)return!1}else if(f){if("number"!=typeof d)return!1;if(!function(e,t,r){switch(e.op){case"=":return t==r;case"<":return t<r;case">":return t>r;case"<=":return t<=r;case">=":return t>=r}throw new Error(`Unknown condition operator: ${JSON.stringify(e)}`)}(f,d,f.value))return!1;f.custom||(d=Math.abs(d))}if((i>0||a>0||l.length||c.length||r||n)&&"number"!=typeof d)return!1;e.color&&(p.color=e.color),i>0&&(d*=Math.pow(100,i)),a>0&&(d/=Math.pow(1e3,a)),l.length&&(m=He.formatInt(g,d,l,h,u),y=parseInt(m[0])<0),c.length&&(v=He.formatDec(d,c,h)),(l.length||c.length)&&(p.type="number"),r&&(w=He.unpackDate(d)),n&&(b=He.unpackTime(d)),(r||n)&&(p.type="date");let _=!1,A="";for(t.restart();!t.eof();){let e=t.next();"dec"===e.type?A+=g.numbers.symbols.decimal:"comma"!==e.type||e.hidden?"percent"===e.type?(p.type="percent",A+=g.numbers.symbols.percentSign):"str"===e.type?(o.test(e.value)&&(p.type="currency",y&&(A+="-",_=!0)),A+=e.value):"text"===e.type?(p.type="text",A+=d):"space"===e.type?(A&&p.body.push(A),A="",p.body.push(e)):"fill"===e.type?A+=He.fill(e.value):"digit"===e.type?(y&&m[0]&&_&&(m[0]=m[0].replace("-","")),A+=e.decimal?v.shift():m.shift()):"date"===e.type?A+=He.date(g,w,e.part,e.format):"time"===e.type?A+=He.time(b,e.part,e.format,s,e.fraction):"eltime"===e.type?A+=He.eltime(d,e.part,e.format,e.fraction):"ampm"===e.type&&(A+=b.hours<12?e.am:e.pm):A+=","}return A&&p.body.push(A),!0}}let Oe=Pe({cond:"text",body:[{type:"text"}]}),je=$((function(e){let t=ze(e).map(Pe);return t.push(Oe),function(e,r=ee()){let n={body:[]};for(let s=0;s<t.length&&!t[s](n,e,r);++s);return n}})),We=$((function(e){let t,r=ze(e),n=!1,s=!1;for(let e=0;e<r.length;++e){t=r[e];for(let e=0;e<t.body.length;++e)/^(?:date|time|ampm)$/.test(t.body[e].type)&&(n=!0,"ampm"===t.body[e].type&&(s=!0));if(n)break}return n?t.body.map((function(e){if("digit"===e.type)return e.sep?e.format.charAt(0)+","+e.format.substr(1):e.format;if("exp"===e.type)return e.ch+e.sign;if("date"===e.type||"time"===e.type){let t=e.part;return"date"===e.type&&/^m/.test(t)?t="M":"time"===e.type&&/^h/.test(t)&&(s||(t=t.toUpperCase())),function(e,t){t.fraction&&(e+=qe("",Math.max(t.fraction,3),"f"));return e}(qe("",e.format,t),e)}return"ampm"===e.type?"tt":"str"===e.type?e.value:"space"===e.type?" ":"dec"===e.type?".":"percent"===e.type?"%":"comma"===e.type?",":""})).join(""):null}));function qe(e,t,r){for(e+="";e.length<t;)e=r+e;return e}function Ye(e){let t=e.body,r="";for(let e=0;e<t.length;++e){let n=t[e];"string"==typeof n?r+=n:"space"===n.type&&(r+=" ")}return r}const Je={compile:je,parse:ze,format:function(e,t,r){let n=je(t)(e,r),s=Be.element("span");s.__dataType=n.type;let i=n.body;n.color&&(s.attr.style={color:n.color});for(let e=0;e<i.length;++e){let t=i[e];"string"==typeof t?s.children.push(Be.text(t)):"space"===t.type&&s.children.push(Be.element("span",{style:{visibility:"hidden"}},[Be.text(t.value)]))}return s},text:function(e,t,r){return Ye(je(t)(e,r))},textAndColor:function(e,t,r){let n=je(t)(e,r);return{text:Ye(n),color:n.color,type:n.type}},type:function(e,t,r){return je(t)(e,r).type},adjustDecimals:function(e,t){let r=ze(e);var n;return n=t,r.forEach((function(e){let t=n;if("text"===e.cond)return;let r=e.body,s=!1,i=r.length;for(;0!==t&&--i>=0;){let e=r[i];if("digit"===e.type){if(e.decimal){if(s=!0,t>0)e.format+=qe("",t,"0");else if(t<0){let r=e.format.length;e.format=e.format.substr(0,r+t),t+=r-e.format.length}if(0===e.format.length)for(r.splice(i,1);--i>=0;){if(e=r[i],"digit"===e.type&&e.decimal){++i;break}if("dec"===e.type){r.splice(i,1);break}}}if(t>0)break}}!s&&t>0&&r.splice(i+1,0,{type:"dec"},{type:"digit",sep:!1,decimal:!0,format:qe("",t,"0")})})),function(e){return e.map((function(e){let t="";return e.color&&(t+="["+e.color+"]"),e.cond&&"text"!==e.cond&&"num"!==e.cond&&(t+="["+e.cond.op+e.cond.value+"]"),t+=e.body.map(r).join(""),t})).join(";");function t(e,t){return t.fraction&&(e+="."+qe("",t.fraction,"0")),e}function r(e){return"digit"===e.type?e.sep?e.format.charAt(0)+","+e.format.substr(1):e.format:"exp"===e.type?e.ch+e.sign:"date"===e.type||"time"===e.type?t(qe("",e.format,e.part),e):"eltime"===e.type?t("["+qe("",e.format,e.part)+"]",e):"ampm"===e.type?e.am+"/"+e.pm:"str"===e.type?JSON.stringify(e.value):"text"===e.type?"@":"space"===e.type?"_"+e.value:"fill"===e.type?"*"+e.value:"dec"===e.type?".":"percent"===e.type?"%":"comma"===e.type?",":void 0}}(r)},makeDateFormat:We},Xe=function(e,t,r,n,s){const i={};return i.spreadsheet={calc:e,CalcError:t,Ref:r,CellRef:n,RangeRef:s},i.culture=()=>ee(),i}(te,K,u,c,f);te.kendo=Xe,te.formatting=Je;let Ge=Object.create(null),Ke=Object.create(null);var Qe;(Qe=[[":"],[" "],[","],["%"],["^"],["*","/"],["+","-"],["&"],["=","<",">","<=",">=","<>"]]).forEach((function(e,t){e.forEach((function(e){Ge[e]=Qe.length-t,Ke[","===e?";":e]=Qe.length-t}))}));let Ze=Ge,et={DEC:".",ARG:",",COL:","};function tt(e){et.DEC=e,et.ARG=","===e?";":",",et.COL=","===e?"\\":",",Ze=","===e?Ke:Ge}te.withDecimalSeparator=function(e,t){if(et.DEC===e)return t();let r=et.DEC;tt(e);try{return t()}finally{tt(r)}},te._separators=et;let rt={type:"bool",value:!0},nt={type:"bool",value:!1};function st(e){e=e.toUpperCase();let t=0;for(let r=0;r<e.length;++r)t=26*t+e.charCodeAt(r)-64;return t-1}function it(e){return parseInt(e,10)-1}function ot(e,t,r,n){let s=[],i=(n=mt(n,{row:t,col:r})).is;return{type:"exp",ast:u(!0),refs:s,sheet:e,row:t,col:r};function o(e){return e.index=s.length,s.push(e),e}function a(e,t,r){if(i(e,t))return n.next();{let s=n.peek();s?n.croak("Expected "+e+" «"+t+"» but found "+s.type+" «"+s.value+"»"):r||n.croak("Expected "+e+" «"+t+"»")}}function u(e){return f((t=h(),i("punc","(")||i("ref")||i("num")||i("func")?{type:"binary",op:" ",left:t,right:u(!1)}:t),0,e);var t}function h(){let t;var r,s;return i("ref")?((s=n.next()).hasSheet()||s.setSheet(e),t=o(s)):i("func")?t=function(){let e=n.next();e=e.value,a("punc","(");let t=[];for(;!i("punc",")");)if(i("op",et.ARG))t.push({type:"null"}),n.next();else{if(t.push(u(!1)),n.eof()||i("punc",")"))break;a("op",et.ARG)}return a("punc",")",!0),{type:"func",func:e,args:t}}():i("punc","(")?(n.next(),t=u(!0),a("punc",")",!0)):i("punc","{")?(n.next(),t=function(){let e=[],t=[e],r=!0;for(;!n.eof()&&!i("punc","}");)r?r=!1:i(null,";")?(t.push(e=[]),n.next()):a(null,et.COL),e.push(u(!1));return{type:"matrix",value:t}}(),a("punc","}",!0)):i("num")||i("str")||i("error")?t=n.next():i("sym")?t="TRUE"===(r=n.next()).upper||"FALSE"===r.upper?"TRUE"===r.upper?rt:nt:o(new l(r.value)):i("op","+")||i("op","-")?t={type:"prefix",op:n.next().value,exp:h()}:n.peek()?i("punc","[")?n.croak("External reference not supported"):n.croak("Parse error"):n.croak("Incomplete expression"),c(t)}function c(e){return i("op","%")?(n.next(),c({type:"postfix",op:"%",exp:e})):e}function f(e,t,r){let s=i("op");if(s&&(r||s.value!==et.ARG)){let i=Ze[s.value];if(i>t){n.next();let o=f(h(),i,r);return f({type:"binary",op:";"===s.value?",":s.value,left:e,right:o},t,r)}}return e}}function at(e){return function(t,r,n){return function(e,t,r,n,s){return function e(o,a,u){switch(o.type){case"num":return"."==te._separators.DEC?JSON.stringify(o.value):JSON.stringify(o.value).replace(".",te._separators.DEC);case"bool":return o.value;case"error":return"#"+o.value;case"str":return JSON.stringify(o.value);case"ref":return h((()=>t[o.index].print(r,n,s)));case"prefix":return h((()=>o.op+e(o.exp,o,Ze[o.op])));case"postfix":return h((()=>e(o.exp,o,Ze[o.op])+o.op));case"binary":return h((()=>{let t=i(e(o.left,o,Ze[o.op]),o.left instanceof l&&":"===o.op),r=i(e(o.right,o,Ze[o.op]),o.right instanceof l&&":"===o.op);return/^[,;]/.test(o.op)?t+te._separators.ARG+r:t+o.op+r}));case"func":return o.func+"("+o.args.map((t=>e(t,o,0))).join(te._separators.ARG+" ")+")";case"matrix":return"{ "+o.value.map((t=>t.map((t=>e(t,o,0))).join(te._separators.COL))).join("; ")+" }";case"null":return""}throw new Error("Cannot print node "+o.type);function h(e){let t=o.op,r=Ze[t]<u||!u&&","===t||"prefix"===a.type&&u===Ze[t]&&"-"===a.op||"binary"===a.type&&u===Ze[t]&&o===a.right;return i(e(),r)}}(e.ast,e,0);function i(e,t){return t?"("+e+")":e}}(e,this.refs,t,r,n)}}function ut(e,t,r){return 0===t.length?r(!0):1===t.length?ft(e,t[0],(t=>r(e.bool(t)))):ft(e,t[0],(n=>e.bool(n)?ut(e,t.slice(1),r):r(!1)))}function ht(e,t,r){return 0===t.length?r(!1):1===t.length?ft(e,t[0],(t=>r(e.bool(t)))):ft(e,t[0],(n=>e.bool(n)?r(!0):ht(e,t.slice(1),r)))}function lt(e,t,r){switch(t.func.toLowerCase()){case"if":return function(e,t,r,n,s){return ft(e,t,(t=>e.func("if",s,[t,t=>ft(e,r,t),t=>ft(e,n,t)])))}(e,t.args[0],t.args[1]||rt,t.args[2]||nt,r);case"and":return ut(e,t.args,r);case"or":return ht(e,t.args,r);case"true":return r(!0);case"false":return r(!1)}return ct(e,t.args,0,(n=>e.func(t.func,r,n)))}function ct(e,t,r,n,s=[]){return r===t.length?n(s):ft(e,t[r],(i=>(s[r]=i,ct(e,t,r+1,n,s))))}function ft(e,t,r){switch(t.type){case"ref":return function(e,t,r){return"name"===t.ref?e.fetchName(t,r):r(e.formula.absrefs[t.index])}(e,t,r);case"num":case"str":case"null":case"bool":return r(t.value);case"error":return r(e.error(t.value));case"prefix":case"postfix":return function(e,t,r){return ft(e,t.exp,(n=>e.func("unary"+t.op,r,[n])))}(e,t,r);case"binary":return function(e,t,r){return ft(e,t.left,(n=>ft(e,t.right,(s=>e.func("binary"+t.op,r,[n,s])))))}(e,t,r);case"func":return lt(e,t,r);case"matrix":return function(e,{value:t},r){let n=[];return function s(i){return i===t.length?r(n):ct(e,t[i],0,(e=>(n[i]=e,s(i+1))))}(0)}(e,t,r)}throw new Error("Cannot evaluate "+t.type)}let pt=Object.create(null);function dt(e){let t=at(e),r=t.call(e),n=pt[r];return n?n.clone(e.sheet,e.row,e.col):(n=new te.runtime.Formula(e.refs,function({ast:e}){return function(){return ft(this,e,(e=>this.resolve(e)))}}(e),t,e.sheet,e.row,e.col),pt[r]=n.clone(e.sheet,e.row,e.col),n)}function gt(e){return e}function mt(e,t){e=function(e,t){let r=[],n=0,s=e.readWhile;return{next:b,peek:w,eof:C,croak:e.croak,ahead:_,skip:A};function i(e){return/[0-9]/i.test(e)}function o(e){return/[a-z$_]/i.test(e)||function(e){return V.test(e)}(e)}function a(e){return o(e)||i(e)||"."===e}function u(e){return e in Ze}function h(e){return"\\!;(){}[]".indexOf(e)>=0}function l(){let e=!1,t=s((function(t){return t===et.DEC?!e&&(e=!0,!0):i(t)}));return t===et.DEC?{type:"punc",value:et.DEC}:{type:"num",value:parseFloat(t.replace(et.DEC,"."))}}function c(t,r){return{type:"sym",value:t,upper:t.toUpperCase(),space:vt(e.peek()),quote:r}}function f(e,t,r){if(!e&&!t&&!r)return null;if(!e&&!r||e&&r){let r=t?parseInt(t,10):0;return e?r:r-1}}function p(){let t=e.lookingAt(/^R(\[)?(-?[0-9]+)?(\])?C(\[)?(-?[0-9]+)?(\])?/i);if(t){let r=f(t[1],t[2],t[3]),n=f(t[4],t[5],t[6]);if(null!=r&&null!=n)return e.skip(t),{type:"rc",row:r,col:n,rel:(t[4]||!(t[4]||t[5]||t[6])?1:0)|(t[1]||!(t[1]||t[2]||t[3])?2:0)}}return c(s(a))}function d(){return e.next(),{type:"str",value:e.readEscaped('"')}}function g(){return e.next(),c(e.readEscaped("'"),!0)}function m(){return{type:"op",value:s((function(e,t){return t+e in Ze}))}}function v(){return{type:"punc",value:e.next()}}function y(){if(e.eof())return null;let r,n=e.peek();return'"'===n?d():"'"===n?g():i(n)||n===et.DEC?l():o(n)?p():u(n)?m():h(n)?v():(r=e.lookingAt(/^#([a-z\/]+)[?!]?/i))?(e.skip(r),{type:"error",value:r[1]}):(t.forEditor||e.croak("Can't handle character with code: "+n.charCodeAt(0)),{type:"error",value:e.next()})}function w(){for(;r.length<=n;){s(vt);let n=e.pos(),i=y();t.forEditor&&i&&(i.begin=n,i.end=e.pos()),r.push(i)}return r[n]}function b(){let e=w();return e&&n++,e}function _(e,t){let r=n,s=[];for(;e-- >0;)s.push(b()||yt);return n=r,t.apply(s,s)}function A(e){n+=e}function C(){return null==w()}}(te.runtime.InputStream(e),t);let r=e.ahead,n=e.skip,s=null,i=null!=t.row&&null!=t.col?function(e){return 1&e.rel&&(e.col-=t.col),2&e.rel&&(e.row-=t.row),e}:gt,o=t.forEditor?function(e,t,r){return e.begin=t.begin,e.end=r.end,e}:gt;return{peek:a,next:function(){if(null!=s){let e=s;return s=null,e}return u()},croak:e.croak,eof:e.eof,is:function(e,t){let r=a();return null==r||null!=e&&r.type!==e||null!=t&&r.value!==t?null:r}};function a(){return null==s&&(s=u()),s}function u(){let t,n=e.peek();return n&&("sym"!==n.type&&"rc"!==n.type&&"num"!==n.type||(t=r(8,p)||r(6,d)||r(6,g)||r(4,m)||r(4,v)||r(2,y)||r(2,w)),t||(t=e.next())),t}function h(r,n){if("rc"===r.type)return!r.rel||t.forEditor||null!=t.row&&null!=t.col||e.croak("Cannot read relative cell in RC notation"),new c(r.row,r.col,r.rel);if("num"===r.type)return r.value<=1048577?i(new c(it(r.value),n?-1/0:1/0,2)):null;let s=r.value,o=/^(\$)?([a-z]+)(\$)?(\d+)$/i.exec(s);if(o){let e=it(o[4]),t=st(o[2]);return e<=1048576&&t<=16383?i(new c(it(o[4]),st(o[2]),(o[1]?0:1)|(o[3]?0:2))):null}let a="$"===s.charAt(0);if(a&&(s=s.substr(1)),/^\d+$/.test(s)){if(it(s)<=1048576)return i(new c(it(s),n?-1/0:1/0,a?0:2))}else{if(st(s)<=16383)return i(new c(n?-1/0:1/0,st(s),a?0:1))}}function p(e,t,r,s,i,a,u,l){if("sym"===e.type&&"op"===t.type&&":"===t.value&&"sym"===r.type&&"punc"===s.type&&"!"===s.value&&("sym"===i.type||"rc"===i.type||"num"===i.type&&i.value==i.value|0)&&"op"===a.type&&":"===a.value&&("sym"===u.type||"rc"===u.type||"num"===u.type&&u.value==u.value|0)&&u.type===i.type&&("punc"!==l.type||"("!==l.value||u.space)){let t=h(i,!0),s=h(u,!1);if(t&&s)return n(7),o(new f(t.setSheet(e.value,!0),s.setSheet(r.value,!0)).setSheet(e.value,!0),e,u)}}function d(e,t,r,s,i,a){if("sym"===e.type&&"op"===t.type&&":"===t.value&&"sym"===r.type&&"punc"===s.type&&"!"===s.value&&("sym"===i.type||"rc"===i.type||"num"===i.type&&i.value==i.value|0)&&("punc"!==a.type||"("!==a.value||i.space)){let t=h(i);if(t){n(5);let s=t.clone();return o(new f(t.setSheet(e.value,!0),s.setSheet(r.value,!0)).setSheet(e.value,!0),e,i)}}}function g(e,t,r,s,i,a){if("sym"===e.type&&"punc"===t.type&&"!"===t.value&&("sym"===r.type||"rc"===r.type||"num"===r.type&&r.value==r.value|0)&&"op"===s.type&&":"===s.value&&("sym"===i.type||"rc"===i.type||"num"===i.type&&i.value==i.value|0)&&("punc"!==a.type||"("!==a.value||i.space)){let t=h(r,!0),s=h(i,!1);if(t&&s)return n(5),o(new f(t,s).setSheet(e.value,!0),e,i)}}function m(e,t,r,s){if("sym"===e.type&&"punc"===t.type&&"!"===t.value&&("sym"===r.type||"rc"===r.type||"num"===r.type&&r.value==r.value|0)&&("punc"!==s.type||"("!==s.value||r.space)){n(3);let t=h(r);return t&&isFinite(t.row)||(t=new l(r.value)),o(t.setSheet(e.value,!0),e,r)}}function v(e,t,r,s){if(("sym"===e.type||"rc"===e.type||"num"===e.type&&e.value==e.value|0)&&"op"===t.type&&":"===t.value&&("sym"===r.type||"rc"===r.type||"num"===r.type&&r.value==r.value|0)&&("punc"!==s.type||"("!==s.value||r.space)){let t=h(e,!0),s=h(r,!1);if(t&&s)return n(3),o(new f(t,s),e,r)}}function y(e,t){if(("sym"===e.type||"rc"===e.type)&&("punc"!==t.type||"("!==t.value||e.space)){let t=h(e);if(t&&isFinite(t.row)&&isFinite(t.col))return n(1),o(t,e,e)}}function w(e,t){if("sym"===e.type&&"punc"===t.type&&"("===t.value&&!e.space)return e.type="func",n(1),e}}function vt(e){return" \t\r\n ​".indexOf(e)>=0}let yt={type:"eof"};let wt=[],bt=te.registerFormatParser=function(e){wt.push(e)};te.parse=function(e,t,r,n,s){if(n instanceof Date)return{type:"date",value:te.runtime.dateToSerial(n)};if("number"==typeof n)return{type:"number",value:n};if("boolean"==typeof n)return{type:"boolean",value:n};if(/^'/.test(n+=""))return{type:"string",value:n.substr(1)};if(/^-?[0-9]+%$/.test(n)){let e=n.substr(0,n.length-1),t=parseFloat(e);if(!isNaN(t)&&t===e)return{type:"percent",value:t/100}}if(/^=/.test(n))return n=n.substr(1),/\S/.test(n)?ot(e,t,r,n):{type:"string",value:"="+n};for(let e=0;e<wt.length;++e){let t=wt[e](n,s);if(t)return t}if("true"===n.toLowerCase())return{type:"boolean",value:!0};if("false"===n.toLowerCase())return{type:"boolean",value:!1};let i=te.runtime.parseDate(n,s);if(i)return{type:"date",value:te.runtime.dateToSerial(i)};let o=parseFloat(n);return!isNaN(o)&&n.length>0&&o===n?(s=null,o!==Math.floor(o)&&(s="0."+String(o).split(".")[1].replace(/\d/g,"0")),{type:"number",value:o,format:s}):{type:"string",value:n}},te.parseNameDefinition=function(e,t){let r=ot(null,0,0,e);if(!(r.ast instanceof l))throw new te.runtime.ParseError("Invalid name: "+e);if(r=r.ast,!(t instanceof u)){let e=ot(r.sheet,0,0,t);t=e.ast instanceof u?e.ast:/^(?:str|num|bool|error)$/.test(e.ast.type)?e.ast.value:dt(e)}return{name:r,value:t}},te.parseFormula=ot,te.parseReference=function(e,t){if("#sheet"===e.toLowerCase())return g;e:{let t;if(t=/^(\$)?([a-z]+)(\$)?(\d+)$/i.exec(e)){let e=it(t[4]),r=st(t[2]);if(e<1048576&&r<16384)return new c(it(t[4]),st(t[2]));break e}let r=mt(e,{}),n=[];for(;;){let e=r.next();if(e instanceof c)e.rel=0;else{if(!(e instanceof f))break e;e.topLeft.rel=0,e.bottomRight.rel=0}if(n.push(e),r.eof())break;if(!r.is("op",et.ARG))break e;r.next()}return 1===n.length?n[0]:new p(n)}if(!t)throw new Error("Cannot parse reference: "+e)},te.compile=dt,te.parseSqref=function(e,t,r){e=mt(e,{row:t=t||0,col:r=r||0});let n=[];for(;!e.eof();){let s=e.next();if("ref"!==s.type)throw new te.runtime.ParseError("Expecting a reference but got: "+JSON.stringify(s));n.push(s.absolute(t,r))}return n},te.tokenize=function(e,t,r){let n=[];for(e=mt(e,{forEditor:!0,row:t,col:r});!e.eof();)n.push(i());let s=n[0];return"op"===s.type&&"="===s.value&&(s.type="startexp"),n;function i(){let n=e.next();return"sym"===n.type?"TRUE"===n.upper?(n.type="bool",n.value=!0):"FALSE"===n.upper&&(n.type="bool",n.value=!1):"ref"===n.type&&(n={type:"ref",ref:null!=t&&null!=r?n.absolute(t,r):n,begin:n.begin,end:n.end}),n}},bt((function(e,t){let r,n=0,s="";if(t||(t=ee().calendar.patterns.d),r=/^(\d+)([-/.])(\d+)\2(\d{2}(?:\d{2})?)(\s*)/.exec(e)){let i=parseInt(r[1],10),o=r[2],a=parseInt(r[3],10),u=parseInt(r[4],10);u<30?u+=2e3:u<100&&(u+=1900);let h=!t||t.indexOf("M")<t.indexOf("d");if(i>12||!h){let e=i;i=a,a=e,h=!1}if(!te.runtime.validDate(u,i,a))return null;n=te.runtime.packDate(u,i-1,a),n<0&&n--,s=h?["mm","dd","yyyy"].join(o):["dd","mm","yyyy"].join(o),s+=r[5],e=e.substr(r[0].length)}if(r=/^(\d+):(\d+)$/.exec(e)){let e=parseInt(r[1],10),t=parseInt(r[2],10);return{type:"date",format:s+"hh:mm",value:n+te.runtime.packTime(e,t,0,0)}}if(r=/^(\d+):(\d+)(\.\d+)$/.exec(e)){let e=parseInt(r[1],10),t=parseInt(r[2],10),i=1e3*parseFloat(r[3]);return{type:"date",format:s+"mm:ss.00",value:n+te.runtime.packTime(0,e,t,i)}}if(r=/^(\d+):(\d+):(\d+)$/.exec(e)){let e=parseInt(r[1],10),t=parseInt(r[2],10),i=parseInt(r[3],10);return{type:"date",format:s+"hh:mm:ss",value:n+te.runtime.packTime(e,t,i,0)}}if(r=/^(\d+):(\d+):(\d+)(\.\d+)$/.exec(e)){let e=parseInt(r[1],10),t=parseInt(r[2],10),i=parseInt(r[3],10),o=1e3*parseFloat(r[4]);return{type:"date",format:s+"hh:mm:ss.00",value:n+te.runtime.packTime(e,t,i,o)}}})),bt((function(e){let t,r;const n=Z();var s=n.localeInfo().numbers;let i=s.symbols.group,o=s.symbols.decimal,a=s.localeCurrency;!a&&n.localeCurrency&&(a=n.localeCurrency());let u=s.currencies[a].symbol,h=function(e,t){let r=e+t,n=_t[r];n||(n="^(\\d+(COM\\d{3})*(DOT\\d+)?)",n=n.replace(/DOT/g,"\\"+t).replace(/COM/g,"\\"+e),n=new RegExp(n),_t[r]=n);return n}(i,o),l=new RegExp("^\\s*\\"+u+"\\s*"),c=1,f="",p="",d=!1,g=!1;if((e=te.runtime.InputStream(e.replace(/^\s+|\s+$/g,""))).skip(/^-\s*/)&&(c=-1),(t=e.skip(l))&&(d=!0,f+='"'+t[0]+'"'),e.skip(/^-\s*/)){if(c<0)return null;c=-1}if(!(r=e.skip(h)))return null;if(f+="0",t=e.skip(l)){if(d)return null;d=!0,p='"'+t[0]+'"'}if(!d&&(t=e.skip(/^\s*%\s*/))&&(g=!0,p=t[0]),!e.eof())return null;(r[2]||d)&&(f=f.replace("0","#"),f+=",0"),r[3]&&(f+="."+At("0",r[3].length-1));let m=r[0].replace(new RegExp("\\"+i,"g"),"").replace(new RegExp("\\"+o,"g"),".");return m=parseFloat(m),g&&(m/=100),f+=p,d&&(f+=";-"+f),{type:"number",currency:d,format:f,value:c*m}})),bt((function(e){let t;if(t=/^([0-9]*)\.([0-9]+)(\s*%)$/.exec(e))return{type:"number",value:parseFloat(e)/100,format:"0."+At("0",t[2].length)+t[3]}}));let _t={};function At(e,t){let r="";for(;t-- >0;)r+=e;return r}class Ct{constructor(e){this.workbook=e}getRefCells(e,t,r,n,s,i){let o,a,h,d;if(e instanceof c)return o=this.workbook.sheetByName(e.sheet),o&&e.valid()?(a=o.formula(e),h=o.range(e.row,e.col).value(),i||null!=a||null!=h?[{formula:a,value:h,row:e.row,col:e.col,sheet:e.sheet,hidden:!!t&&(0===o.columnWidth(e.col)||0===o.rowHeight(e.row))}]:[]):[{value:new K("REF")}];if(e instanceof f){d=this.workbook.sheetIndex(e.sheet);let r=[],n=d;if(e.endSheet&&(n=this.workbook.sheetIndex(e.endSheet),d>n)){let e=d;d=n,n=e}if(d<0||n<0||!e.valid())return[{value:new K("REF")}];for(;d<=n;){o=this.workbook.sheetByIndex(d++);let n=o._grid.normalize(e.topLeft),s=o._grid.normalize(e.bottomRight),u=o._grid.cellRefIndex(n),l=o._grid.cellRefIndex(s),c=o._properties.iterator("value",u,l);for(let e=n.col;e<=s.col;++e)for(let u=n.row;u<=s.row;++u){let n=o._grid.index(u,e);a=o._properties.get("formula",n),h=c.at(n),(i||null!=a||null!=h)&&r.push({formula:a,value:h,row:u,col:e,sheet:o.name(),hidden:!!t&&(0===o.columnWidth(e)||0===o.rowHeight(u))})}}return r}if(e instanceof p){let i=[];for(d=0;d<e.refs.length;++d)i=i.concat(this.getRefCells(e.refs[d],t,r,n,s));return i}if(e instanceof l){let i=this.nameValue(e,r,n,s);return i instanceof u?this.getRefCells(i,t,r,n,s):[{value:null==i?new K("NAME"):i}]}return[]}isMerged(e){return this.workbook.sheetByName(e.sheet).isMerged(e)}nameValue(e,t,r,n){let s;return e.hasSheet()?s=this.workbook.nameValue(this._displayString(e.print())):(e=e.clone().setSheet(t,!0),s=this.workbook.nameValue(this._displayString(e.print())),null==s&&(s=this.workbook.nameValue(this._displayString(e.name))),null==s&&(s=this.workbook.nameValue(e.print())||this.workbook.nameValue(e.name))),s instanceof u&&(s=s.absolute(r,n)),s}getData(e,t,r,n,s){let i=e instanceof c;e instanceof l&&(i=this.workbook.nameValue(e.name)instanceof c);let o=this.getRefCells(e,!1,t,r,n,s).map((function(e){let t=e.value;return t instanceof te.runtime.Formula&&(t=t.value),t}));return i?o[0]:o}onFormula(e){let t=this.workbook.sheetByName(e.sheet),r=e.row,n=e.col,s=e.value;if(t.formula({row:r,col:n})!==e)return!1;let i=e.arrayFormulaRange;if(i){let e,r,n=s.width,o=s.height;t.forEach(i,(function(i,a){void 0===e&&(e=i,r=a);let u,h=i-e,l=a-r;u=h<o&&l<n?s.get(h,l):new K("N/A"),t._value(i,a,u)}))}else s instanceof u&&(s=this.getData(s,e.sheet,r,n),Array.isArray(s)&&(s=s[0]),void 0===s&&(s=null)),s instanceof te.runtime.Matrix&&(s=s.get(0,0)),t._value(r,n,s);return clearTimeout(t._formulaContextRefresh),t._formulaContextRefresh=setTimeout((function(){t.batch((function(){}),{layout:!0})}),50),!0}_displayString(e){return/^[a-z_][a-z0-9_]*$/i.test(e)?e:"'"+e.replace(/\x27/g,"\\'")+"'"}}class xt extends Ct{onFormula(){return!0}}te.ValidationFormulaContext=xt;let kt={8:"backspace",9:"tab",13:"enter",27:"esc",37:"left",38:"up",39:"right",40:"down",35:"end",36:"home",32:"spacebar",33:"pageup",34:"pagedown",46:"delete",113:":edit"};class Mt{constructor(e,t,r){if(this._handlers={},this.target=e,this._observer=t||window,this.keyDownProxy=this.keyDown.bind(this),this.mouseProxy=this.mouse.bind(this),this.touchProxy=this.touch.bind(this),this.threshold=5,this._pressLocation=null,this._attachEvent(e,"keydown",this.keyDownProxy),this._attachEvent(e,"contextmenu mousedown cut copy paste scroll wheel click dblclick focus",this.mouseProxy),this._attachEvent(e,"touchmove touchend",this.touchProxy),this._attachEvent(document.documentElement,"mousemove mouseup",this.mouseProxy),this._attachEvent(document.documentElement,"touchmove touchend",this.touchProxy),r)for(let e in r)this.on(e,r[e])}_attachEvent(e,t,r){t.split(" ").forEach((t=>{e.addEventListener(t,r)}))}_removeEvent(e,t,r){t.split(" ").forEach((t=>{e.removeEventListener(t,r)}))}keyDown(e){(!e.altKey||"n"!==e.key&&"h"!==e.key&&"a"!==e.key)&&this.handleEvent(e,function(e){let t=e.keyCode,r=kt[t];return!r&&function(e){return e>47&&e<58||e>64&&e<91||e>95&&e<112||e>185&&e<193||e>218&&e<223||229===e}(t)&&(r=":alphanum"),!r&&e.key&&1===e.key.length&&(r=":alphanum"),r}(e))}touch(e){this.handleEvent(e,e.type)}mouse(e){let t;e.which?t=3===e.which:e.button&&(t=2===e.button);let r=e.type;if("mousedown"===r&&(t?r="rightmousedown":this._pressLocation={x:e.pageX,y:e.pageY}),"mouseup"===r&&(t||(this._pressLocation=null)),"mousemove"===r&&this._pressLocation){let t=this._pressLocation.x-e.pageX,n=this._pressLocation.y-e.pageY;Math.sqrt(t*t+n*n)>this.threshold&&(r="mousedrag")}this.handleEvent(e,r)}handleEvent(e,t){let r="";e.mod=navigator.platform.toUpperCase().indexOf("MAC")>=0?e.metaKey:e.ctrlKey&&!e.altKey,e.altKey&&(r+="alt+"),e.shiftKey&&(r+="shift+"),e.ctrlKey&&(r+="ctrl+"),r+=t;let n=this._handlers["*+"+t];n&&n.call(this._observer,e,r);let s=this._handlers[r];s&&s.call(this._observer,e,r)}on(e,t){let r=this._handlers;"string"==typeof t&&(t=this._observer[t]),"string"==typeof e&&(e=e.split(",")),e.forEach((function(e){r[e]=t}))}destroy(){this._removeEvent(this.target,"keydown",this.keyDownProxy),this._removeEvent(this.target,"contextmenu mousedown cut copy paste scroll wheel click dblclick focus",this.mouseProxy),this._removeEvent(this.target,"touchmove touchend",this.touchProxy),this._removeEvent(document.documentElement,"mousemove mouseup",this.mouseProxy),this._removeEvent(document.documentElement,"touchmove touchend",this.touchProxy)}}let Et=/:alphanum$/,Ft={up:"up",down:"down",left:"left",right:"right",home:"first-col",end:"last-col","ctrl+left":"word-left","ctrl+right":"word-right","ctrl+up":"word-up","ctrl+down":"word-down","ctrl+home":"first","ctrl+end":"last",pageup:"prev-page",pagedown:"next-page"},Rt={tab:"next","shift+tab":"previous",enter:"lower","shift+enter":"upper",delete:"clearContents",backspace:"clearContents","shift+:alphanum":"edit","alt+:alphanum":"edit",":alphanum":"edit","ctrl+:alphanum":"ctrl","alt+ctrl+:alphanum":"edit",":edit":"edit"},St={wheel:"onWheel","*+mousedown":"onMouseDown",contextmenu:"onContextMenu","*+mousedrag":"onMouseDrag","*+mouseup":"onMouseUp","*+dblclick":"onDblClick",mousemove:"onMouseMove"},Nt={pageup:"onPageUp",pagedown:"onPageDown",mouseup:"onMouseUp","*+cut":"onCut","*+paste":"onPaste","*+copy":"onCopy"},Lt={esc:"onEditorEsc",enter:"onEditorBlur","alt+enter":"insertNewline","shift+enter":"onEditorBlur",tab:"onEditorBlur","shift+tab":"onEditorBlur","shift+ctrl+enter":"onEditorArrayFormula"},Dt=Object.assign({focus:"onEditorBarFocus"},Lt),Ut=Object.assign({focus:"onEditorCellFocus"},Lt),Vt={cell:"range",rowheader:"row",columnheader:"column",topcorner:"sheet",autofill:"autofill"},$t=[],Bt=[],It=[];for(let e in Ft)$t.push(e),Bt.push("shift+"+e);for(let e in Rt)It.push(e);Nt[$t]="onAction",Nt[Bt]="onShiftAction",Nt[It]="onEntryAction",Ut[$t]="onEditorAction",Ut[Bt]="onEditorShiftAction";class Tt{constructor(e,t){this.view=e,this.workbook(t),this.container=e.container,this.clipboardElement=e.clipboard,this.scroller=e.scroller,this.tabstrip=e.tabstrip,this.sheetsbar=e.sheetsbar,e.nameEditor.bind("enter",this.onNameEditorEnter.bind(this)),e.nameEditor.bind("cancel",this.onNameEditorCancel.bind(this)),e.nameEditor.bind("select",this.onNameEditorSelect.bind(this)),e.nameEditor.bind("delete",this.onNameEditorDelete.bind(this)),this.editor=e.editor,this.editor.bind("change",this.onEditorChange.bind(this)),this.editor.bind("activate",this.onEditorActivate.bind(this)),this.editor.bind("deactivate",this.onEditorDeactivate.bind(this)),this.editor.bind("update",this.onEditorUpdate.bind(this)),this.listener=new Mt(this.container,this,St),this.scrollHandler=this.onScroll.bind(this),this.mouseDownHandler=this.onMouseDown.bind(this),e.scroller.addEventListener("scroll",this.scrollHandler),e.scroller.addEventListener("mousedown",this.mouseDownHandler),this._enableEditorEvents(),this.sheetsbar&&(this.sheetsbar.bind("select",this.onSheetBarSelect.bind(this)),this.sheetsbar.bind("reorder",this.onSheetBarReorder.bind(this)),this.sheetsbar.bind("rename",this.onSheetBarRename.bind(this)),this.sheetsbar.bind("remove",this.onSheetBarRemove.bind(this)))}executeCommand(e){return this._execute(e)}_enableEditorEvents(e){void 0===e||e?(this.keyListener=new Mt(this.clipboardElement,this,Nt),this.barKeyListener=new Mt(this.editor.barElement(),this,Dt),this.inputKeyListener=new Mt(this.editor.cellElement(),this,Ut)):(this.keyListener.destroy(),this.barKeyListener.destroy(),this.inputKeyListener.destroy())}_execute(e){let t=this._workbook.execute(e);return"EditCommand"!==e.command||t||this._workbook.trigger("change",{editorClose:!0}),t&&(this._preventNavigation=!0,"error"===t.reason?(this.editor.deactivate(!0),this.view.showError(t,function(){}.bind(this))):this.view.openDialog(t.reason)),t}_activeTooltip(){return this._workbook.activeSheet().activeCell().simplify().toString()}onContextMenuSelect(e){let t;switch(e.item.getAttribute("data-action")){case"cut":t={command:"ToolbarCutCommand",options:{workbook:this._workbook}};break;case"copy":t={command:"ToolbarCopyCommand",options:{workbook:this._workbook}};break;case"paste":t={command:"ToolbarPasteCommand",options:{workbook:this._workbook}};break;case"delete-drawing":t={command:"DeleteDrawingCommand",options:{drawing:this.navigator._sheet._activeDrawing}};break;case"bring-to-front":t={command:"BringToFrontCommand",options:{drawing:this.navigator._sheet._activeDrawing}};break;case"send-to-back":t={command:"SendToBackCommand",options:{drawing:this.navigator._sheet._activeDrawing}};break;case"unmerge":t={command:"MergeCellCommand",options:{value:"unmerge"}};break;case"merge":this.view.openDialog("merge");break;case"hide-row":t={command:"HideLineCommand",options:{axis:"row"}};break;case"hide-column":t={command:"HideLineCommand",options:{axis:"column"}};break;case"unhide-row":t={command:"UnHideLineCommand",options:{axis:"row"}};break;case"unhide-column":t={command:"UnHideLineCommand",options:{axis:"column"}};break;case"delete-row":t={command:"DeleteRowCommand"};break;case"delete-column":t={command:"DeleteColumnCommand"}}t&&this._execute(t)}onSheetBarRemove(e){let t=this._workbook.sheetByName(e.name);t&&this._workbook.removeSheet(t)}destroy(){this.view.scroller.removeEventListener("scroll",this.scrollHandler),this.view.scroller.removeEventListener("mousedown",this.mouseDownHandler),this.listener.destroy(),this._enableEditorEvents(!1),this.keyListener.destroy(),this.inputKeyListener.destroy()}onSheetBarSelect(e){let t,r=this._workbook;if(e.isAddButton){if(this._workbook.trigger("insertSheet"))return;t=r.insertSheet()}else t=r.sheetByName(e.name);if(r.activeSheet().name()!==t.name()){if(this._workbook.trigger("selectSheet",{sheet:t}))return;this.editor.canInsertRef(!1)||this.editor.deactivate(),r.activeSheet(t)}}onSheetBarReorder(e){let t=this._workbook,r=t.sheetByIndex(e.oldIndex),n=t.activeSheet(),s=n.name();if(t.moveSheetToIndex(r,e.newIndex),s!==r.name()){if(t.trigger("selectSheet",{sheet:r}))return void t.activeSheet(n);this.editor.canInsertRef(!1)||this.editor.deactivate(),t.activeSheet(r)}}onSheetBarRename(e){let t=this._workbook.sheetByIndex(e.sheetIndex);this._workbook.sheetByName(e.name)?this.view.showError({reason:"error",type:"duplicateSheetName"}):(this._workbook.renameSheet(t,e.name),this.clipboardElement.focus({preventScroll:!0}))}sheet(e){this.navigator=e.navigator(),this.axisManager=e.axisManager()}workbook(e){this._workbook=e,this.clipboard=e.clipboard(),e.bind("commandRequest",this.onCommandRequest.bind(this))}refresh(){let e=this.editor,t=this._workbook.activeSheet();this._viewPortHeight=this.view.scroller.clientHeight,this.navigator.height(this._viewPortHeight),e.isActive()||this.isEditorDisabled||(e.enable(!1!==t.selection().enable()),this.resetEditorValue());let r=t.selection()._ref.simplify(),n=this._workbook.nameForRef(r,t.name());this.view.nameEditor.value(n.name)}onScroll(){this.view.render({scroll:!0})}onWheel(e){let t=e.deltaX,r=e.deltaY;1===e.deltaMode&&(t*=10,r*=10),this.scrollWith(t,r),e.preventDefault()}onAction(e,t){this._workbook.activeSheet()._activeDrawing=null,this.navigator.moveActiveCell(Ft[t]),e.preventDefault()}onPageUp(){this.scrollDown(-this._viewPortHeight)}onPageDown(){this.scrollDown(this._viewPortHeight)}onEntryAction(e,t){let r=this._workbook.activeSheet();if(e.mod){let t=!0;switch(String.fromCharCode(e.keyCode)){case"A":r._activeDrawing=null,this.navigator.selectAll();break;case"Y":this._workbook.undoRedoStack.redo();break;case"Z":this._workbook.undoRedoStack.undo();break;default:t=!1}t&&e.preventDefault()}else{let n=!1===r.selection().enable(),s=":edit"!==t;if("delete"==t||"backspace"==t)r._activeDrawing?this._execute({command:"DeleteDrawingCommand",options:{drawing:r._activeDrawing}}):n||this._execute({command:"ClearContentCommand"}),e.preventDefault();else if(Et.test(t)||!s){if(r._activeDrawing=null,n)return void e.preventDefault();s&&this.editor.value(""),this.activateEditor(s)}else this.navigator.navigateInSelection(Rt[t]),e.preventDefault()}}onShiftAction(e,t){this.navigator.modifySelection(Ft[t.replace("shift+","")],this.appendSelection),e.preventDefault()}onMouseMove(e){let t=this._workbook.activeSheet();if(t.resizingInProgress()||t.selectionInProgress())return;let r=this.objectAt(e);"columnresizehandle"===r.type||"rowresizehandle"===r.type?t.positionResizeHandle(r.ref):t.removeResizeHandle(),t._renderComment("cell"==r.type?r.ref:null)}onMouseDown(e){let t=this.objectAt(e);if(t.pane&&(this.originFrame=t.pane),this._startResizingDrawing(e,t))return void e.stopPropagation();let r=this._workbook.activeSheet();if(r._activeDrawing=null,"drawing"===t.type)return r._activeDrawing=t.drawing,t.copy=t.drawing.clone(),t.startBox=r.drawingBoundingBox(t.copy),r.startDragging(t),r.triggerChange({dragging:!0}),void e.preventDefault();if("outside"===t.type)return e.preventDefault(),void e.stopPropagation();if("editor"===t.type)return this.onEditorEsc(),this.openCustomEditor(),void e.preventDefault();if(this.editor.canInsertRef(!1)&&t.ref)return this._workbook.activeSheet()._setFormulaSelections(this.editor.highlightedRefs()),this.navigator.startSelection(t.ref,this._selectionMode,this.appendSelection,e.shiftKey,this.view),void e.preventDefault();if(this._preventNavigation=!1,this.editor.deactivate(),!this._preventNavigation){if("columnresizehandle"===t.type||"rowresizehandle"===t.type)return r.startResizing({x:t.x,y:t.y}),void e.preventDefault();if("filtericon"===t.type)return this.openFilterMenu(e),void e.preventDefault();this._selectionMode=Vt[t.type],this.appendSelection=e.mod,this.navigator.startSelection(t.ref,this._selectionMode,this.appendSelection,e.shiftKey,this.view)}}_startResizingDrawing(e){let t=e.target.closest(".k-spreadsheet-drawing-handle");if(t){let r=this.translateCoords(e),n=t.getAttribute("data-direction"),s=this._workbook.activeSheet(),i=s._activeDrawing;return s.startDragging({pane:this.originFrame,drawing:i,copy:i.clone(),startBox:s.drawingBoundingBox(i),resize:n,startX:r.x,startY:r.y}),!0}}onContextMenu(e){let t=this._workbook.activeSheet();if(e.preventDefault(),t.resizingInProgress()||t.draggingInProgress())return;let r=this.objectAt(e);if("columnresizehandle"===r.type||"rowresizehandle"===r.type)return;r.ref?this.navigator.selectForContextMenu(r.ref,Vt[r.type]):"drawing"==r.type&&this.navigator.selectDrawingForContextMenu(r.drawing);let n=this.navigator._sheet.select()instanceof p,s=!1,i=!1;"columnheader"==r.type?s=!n&&this.axisManager.selectionIncludesHiddenColumns():"rowheader"==r.type?s=!n&&this.axisManager.selectionIncludesHiddenRows():"drawing"==r.type||(i=this.navigator.selectionIncludesMergedCells()),this._workbook.trigger("contextmenu",{objectRef:r.ref,targetType:r.type,isComposite:n,showUnhide:s,showUnmerge:i,originalEvent:e})}prevent(e){e.preventDefault()}constrainResize(e,t){let r=this._workbook.activeSheet().resizeHandlePosition();return!r||"outside"===e||"topcorner"===e||t.col<r.col||t.row<r.row}_dragDrawing(e){let t=this._workbook.activeSheet(),r=t.draggingInProgress();if(!r)return!1;let n=this.translateCoords(e),s=r.drawing,i=n.x-r.startX,o=n.y-r.startY;return"SE"==r.resize?r.aspect?Math.abs(i)>Math.abs(o)?(s.width=Math.max(r.copy.width+i,20),s.height=s.width/r.aspect):(s.height=Math.max(r.copy.height+o,20),s.width=s.height*r.aspect):(s.width=Math.max(r.copy.width+i,20),s.height=Math.max(r.copy.height+o,20)):"E"==r.resize?s.width=Math.max(r.copy.width+i,20):"S"==r.resize?s.height=Math.max(r.copy.height+o,20):"N"==r.resize?r.copy.height-o>20&&(s.height=r.copy.height-o,s.offsetY=r.copy.offsetY+o):"W"==r.resize?r.copy.width-i>20&&(s.width=r.copy.width-i,s.offsetX=r.copy.offsetX+i):"NE"==r.resize?(s.width=Math.max(r.copy.width+i,20),r.copy.height-o>20&&(s.height=r.copy.height-o,s.offsetY=r.copy.offsetY+o)):"SW"==r.resize?(s.height=Math.max(r.copy.height+o,20),r.copy.width-i>20&&(s.width=r.copy.width-i,s.offsetX=r.copy.offsetX+i)):"NW"==r.resize?(r.copy.height-o>20&&(s.height=r.copy.height-o,s.offsetY=r.copy.offsetY+o),r.copy.width-i>20&&(s.width=r.copy.width-i,s.offsetX=r.copy.offsetX+i)):(s.offsetX=r.copy.offsetX+i,s.offsetY=r.copy.offsetY+o),t.triggerChange({dragging:!0}),!0}onMouseDrag(e){if("sheet"===this._selectionMode)return;let t={clientX:e.clientX,clientY:e.clientY},r=this._workbook.activeSheet();if(this._dragDrawing(e))return;let n=this.objectAt(t);if(r.resizingInProgress())this.constrainResize(n.type,n.ref)||r.resizeHintPosition({x:n.x,y:n.y});else if("outside"!==n.type){if(this.originFrame===n.pane)this.selectToLocation(t);else{let e=this.originFrame._grid;n.x,e.right,n.y>e.bottom&&this.scrollTop(),n.y<e.top||n.x<e.left?this.startAutoScroll(n,t):this.selectToLocation(t)}e.preventDefault()}else this.startAutoScroll(n)}onMouseUp(e){let t=this._workbook.activeSheet();t.completeResizing(),t.completeDragging(),this.navigator.completeSelection(),this.stopAutoScroll();let r=this.editor.activeEditor();if(!r)return;let n=e.target;for(;n;){if(n===r.element)return;n=n.parentNode}let s=this.objectAt(e);s&&s.ref&&r.canInsertRef(!1)&&(r.refAtPoint(t),t._setFormulaSelections(r.highlightedRefs()))}onDblClick(e){let t=this.objectAt(e),r=!1===this._workbook.activeSheet().selection().enable();if("cell"!==t.type||r)return;let n=this._workbook.activeSheet().selection();this.activateEditor(!n.value()&&!n.formula()),this.onEditorUpdate()}onCut(e){let t=this;setTimeout((function(){t.clipboard.menuInvoked=void 0===e,t._execute({command:"CutCommand",options:{workbook:t.view._workbook,event:e}})}))}clipBoardValue(){return this.clipboardElement.html()}_pasteImage(e){let t=this,r=new window.Image;r.src=window.URL.createObjectURL(e),r.onload=function(){t._execute({command:"InsertImageCommand",options:{blob:e,width:r.width,height:r.height}})},setTimeout((function(){window.URL.revokeObjectURL(r.src)}),10)}onPaste(e){let t=this,r="",n="";if(t.clipboard.menuInvoked=void 0===e,e){let s=e.clipboardData;if(!s||!s.getData){if(window.clipboardData.files&&window.clipboardData.files.length){let e=window.clipboardData.files[0];if(/^image\/(?:png|jpe?g|gif)$/i.test(e.type))return t._pasteImage(e)}return n=window.clipboardData.getData("Text"),n&&(n=n.trim()),t.clipboardElement.empty(),void setTimeout((function(){r=t.clipboardElement.html(),(r||n)&&(t.clipboard.external({html:r,plain:n}),t._execute({command:"PasteCommand",options:{workbook:t.view._workbook,event:e}}))}))}{e.preventDefault();let i=!1,o=!1;if(window.DOMStringList&&s.types instanceof window.DOMStringList?(i=s.types.contains("text/html"),o=s.types.contains("text/plain")):Array.isArray(s.types)?(i=s.types.indexOf("text/html")>=0,o=s.types.indexOf("text/plain")>=0):(i=/text\/html/.test(s.types),o=/text\/plain/.test(s.types)),i&&(r=s.getData("text/html").trim()),o&&(n=s.getData("text/plain").trim()),!r&&!n&&s.items&&s.items.length)for(let e=0;e<s.items.length;++e){let r=s.items[e];if("file"===r.kind&&/^image\/(?:png|jpe?g|gif)$/i.test(r.type))return t._pasteImage(r.getAsFile())}}}else t.clipboard.menuInvoked=!0;(r||n)&&(t.clipboard.external({html:r,plain:n}),t._execute({command:"PasteCommand",options:{workbook:t.view._workbook,event:e}}))}onCopy(e){this.clipboard.menuInvoked=void 0===e,this._execute({command:"CopyCommand",options:{workbook:this.view._workbook,event:e}})}scrollTop(){this.scroller.scrollTop=0}scrollLeft(){this.scroller.scrollLeft=0}scrollDown(e){this.scroller.scrollTop+=e}scrollRight(e){this.scroller.scrollLeft+=e}scrollWith(e,t){this.scroller.scrollTop+=t,this.scroller.scrollLeft+=e}translateCoords(e){let t=this.container.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}objectAt(e,t){if(!e)return;const r=this.translateCoords(e);return this.view.objectAt(r.x,r.y,t)}selectToLocation(e){let t=this.objectAt(e,!0);t.pane&&t.ref&&(this.extendSelection(t),this.lastKnownCellLocation=e,this.originFrame=t.pane),this.stopAutoScroll()}extendSelection(e){this.navigator.extendSelection(e.ref,this._selectionMode)}autoScroll(){let e=this._autoScrollTarget.x,t=this._autoScrollTarget.y,r=this.originFrame._grid,n=this.view.scroller,s=n.scrollLeft,i=n.scrollTop;e<r.left&&this.scrollRight(-8),e>r.right&&this.scrollRight(8),t<r.top&&this.scrollDown(-8),t>r.bottom&&this.scrollDown(8),i===n.scrollTop&&s===n.scrollLeft?this.selectToLocation(this.finalLocation):this.extendSelection(this.objectAt(this.lastKnownCellLocation))}startAutoScroll(e,t){this._scrollInterval||(this._scrollInterval=setInterval(this.autoScroll.bind(this),50)),this.finalLocation=t||this.lastKnownCellLocation,this._autoScrollTarget=e}stopAutoScroll(){clearInterval(this._scrollInterval),this._scrollInterval=null}openCustomEditor(){this.view.openCustomEditor()}openFilterMenu(e){let t=this.objectAt(e),r=this._workbook.activeSheet().filterColumn(t.ref),n=this.view.createFilterMenu(r);n.bind("action",this.onCommandRequest.bind(this)),n.bind("action",n.close.bind(n)),n.openFor(e.target,e)}_saveEditorValue(e){let t=this.editor._range.sheet(),r=this.editor.value();this._workbook.activeSheet()!==t&&(this._workbook.activeSheet()._setFormulaSelections(),this._workbook.activeSheet(t)),t.isInEditMode(!1),this._lastEditorValue=r,this._execute({command:"EditCommand",options:{value:r,arrayFormula:e}})}onEditorChange(){this._saveEditorValue(!1)}onEditorArrayFormula(){this._saveEditorValue(!0),this.editor.deactivate(!0)}onEditorActivate(){let e=this._workbook.activeSheet();e._setFormulaSelections(this.editor.highlightedRefs()),e.isInEditMode(!0)}onEditorDeactivate(){let e=this._workbook.activeSheet();e.isInEditMode(!1),e._setFormulaSelections([])}onEditorUpdate(){this._workbook.activeSheet()._setFormulaSelections(this.editor.highlightedRefs())}onEditorBarFocus(){!1===this._workbook.activeSheet().selection().enable()||this.editor.activate({range:this._workbook.activeSheet().selection(),rect:this.view.activeCellRectangle(),tooltip:this._activeTooltip()})}onEditorCellFocus(){this.editor.scale()}onEditorEsc(){this.resetEditorValue(),this.editor.deactivate(),this.clipboardElement.focus({preventScroll:!0})}insertNewline(e){e.preventDefault(),this.editor.insertNewline()}onEditorBlur(e,t){e.defaultPrevented||this.editor.isFiltered()||(e.preventDefault(),this._preventNavigation=!1,this.editor.deactivate(),this._preventNavigation||(this.clipboardElement.focus({preventScroll:!0}),this.navigator.navigateInSelection(Rt[t])),"tab"===t&&e.preventDefault())}onEditorAction(e,t){if(e.defaultPrevented)return;let r=this.editor,n=this._workbook.activeSheet();this._casualEditing&&/^(?:up|right|down|left)$/.test(t)?(this.deactivateEditor(),this.navigator.moveActiveCell(Ft[t]),e.preventDefault()):r.canInsertRef(!0)&&(this.navigator.moveActiveCell(Ft[t]),r.activeEditor().refAtPoint(n),n._setFormulaSelections(r.highlightedRefs()),e.preventDefault())}onEditorShiftAction(e,t){let r=this.editor,n=this._workbook.activeSheet();r.canInsertRef(!0)&&(this.navigator.modifySelection(Ft[t.replace("shift+","")],this.appendSelection),r.activeEditor().refAtPoint(n),n._setFormulaSelections(r.highlightedRefs()),e.preventDefault())}resetEditorValue(){let e=this._workbook.activeSheet(),t=e.activeCell(),r=this._workbook._inputForRef(t),n=e.range(t).intersectingArrayFormula();n&&(r="="+n.formula),this.editor.value(r,Boolean(n))}activateEditor(e){this._casualEditing=e,this.editor.activate({range:this._workbook.activeSheet().selection(),rect:this.view.activeCellRectangle(),tooltip:this._activeTooltip()}).focus()}deactivateEditor(){this.view.editor.deactivate()}onCommandRequest(e){e.command?this._execute(e):this._workbook.undoRedoStack[e.action]()}onDialogRequest(e){let t={pdfExport:this._workbook.options.pdf,excelExport:this._workbook.options.excel};e.options?H(e.options,t):e.options=t,this.view.openDialog(e.name,e.options)}onNameEditorEnter({value:e}){let t,r=this._workbook,n=r.activeSheet(),s=void 0!==e?e:this.view.nameEditor.value();if(t=te.parseReference(s,!0)||r.nameValue(s),t instanceof u){if(t.sheet&&t.sheet.toLowerCase()!==n.name().toLowerCase()){let e=r.sheetByName(t.sheet);e&&(r.activeSheet(e),n=e)}n.range(t).select()}else t=n.selection()._ref.clone().simplify().setSheet(n.name(),!0),this._execute({command:"DefineNameCommand",options:{name:s,value:t}}),this.clipboardElement.focus({preventScroll:!0})}onNameEditorCancel(){this.clipboardElement.focus({preventScroll:!0})}onNameEditorSelect(e){let t=e.name,r=this._workbook,n=r.activeSheet(),s=r.nameValue(t);if(s instanceof u){if(s.sheet&&s.sheet.toLowerCase()!==n.name().toLowerCase()){let e=r.sheetByName(s.sheet);e&&(r.activeSheet(e),n=e)}n.range(s).select()}else this.clipboardElement.focus({preventScroll:!0})}onNameEditorDelete(e){this._execute({command:"DeleteNameCommand",options:{name:e.name}}),this.clipboardElement.focus({preventScroll:!0})}}class zt{constructor(e,t,r,n){this.level=e,this.value=t,this.left=r,this.right=n}}const Ht={left:void 0,right:void 0,level:0};function Pt(e){let t=e;if(t.left.level===t.level){let e=t;t=t.left,e.left=t.right,t.right=e}return t}function Ot(e){let t=e;if(t.right.right.level===t.level){let e=t;t=t.right,e.right=t.left,t.left=e,t.level+=1}return t}function jt(e,t){return e===Ht?new zt(1,t,Ht,Ht):(e.value.start>t.start?e.left=jt(e.left,t):e.right=jt(e.right,t),Ot(Pt(e)))}function Wt(e,t){let r=e;if(r===Ht)return r;let n=r.value.start-t.start;if(0===n)if(r.left!==Ht&&r.right!==Ht){let e=r.left;for(;e.right!==Ht;)e=e.right;r.value=e.value,r.left=Wt(r.left,r.value)}else r=r.left===Ht?r.right:r.left;else n>0?r.left=Wt(r.left,t):r.right=Wt(r.right,t);return(r.left.level<r.level-1||r.right.level<r.level-1)&&(r.level-=1,r.right.level>r.level&&(r.right.level=r.level),r=Pt(r),r.right=Pt(r.right),r.right.right=Pt(r.right.right),r=Ot(r),r.right=Ot(r.right)),r}Ht.left=Ht,Ht.right=Ht;class qt{constructor(e,t,r){this.start=e,this.end=t,this.value=r}intersects(e){return e.start<=this.end&&e.end>=this.start}clone(){return new qt(this.start,this.end,this.value)}}class Yt{constructor(){this.root=Ht}insert(e){this.root=jt(this.root,e)}remove(e){this.root=Wt(this.root,e)}findrange(e){let t=this.root;for(;t!==Ht;)if(e<t.value.start)t=t.left;else{if(!(e>t.value.end))return t.value;t=t.right}return null}values(){let e=[];return Jt(this.root,e),e}intersecting(e,t){let r=[];return Xt(this.root,new qt(e,t),r),r}map(e){let t=new Yt;return Gt(t,this.root,e),t}forEach(e){Kt(this.root,e)}clone(){return this.map((function(e){return e.clone()}))}first(){let e=this.root;for(;e.left!==Ht;)e=e.left;return e}last(){let e=this.root;for(;e.right!==Ht;)e=e.right;return e}}function Jt(e,t){e!==Ht&&(Jt(e.left,t),t.push(e.value),Jt(e.right,t))}function Xt(e,t,r){if(e===Ht)return;let n=e.value;t.start<n.start&&Xt(e.left,t,r),n.intersects(t)&&r.push(n),t.end>n.end&&Xt(e.right,t,r)}function Gt(e,t,r){t!==Ht&&(Gt(e,t.left,r),e.insert(r(t.value)),Gt(e,t.right,r))}function Kt(e,t){e!==Ht&&(Kt(e.left,t),t(e.value),Kt(e.right,t))}class Qt{constructor(e,t,r){void 0===t?this.tree=e:(this.tree=new Yt,this.tree.insert(new qt(e,t,r)))}values(){return this.tree.values()}map(e){return new Qt(this.tree.map(e))}forEach(e){this.tree.forEach(e)}intersecting(e,t){return this.tree.intersecting(e,t)}first(){return this.tree.first().value}last(){return this.tree.last().value}insert(e,t,r){return this.tree.insert(new qt(e,t,r))}value(e,t,r){let n=e,s=t;if(void 0===r)return void 0===s&&(s=n),this.intersecting(n,s)[0].value;let i=this.tree.intersecting(n-1,s+1);if(i.length){let e=i[0],t=i[i.length-1];e.end<n&&(e.value===r?n=e.start:i.shift()),t.start>s&&(t.value===r?s=t.end:i.pop());for(let e=0,t=i.length;e<t;e++){let t=i[e],o=t.value,a=t.start,u=t.end;this.tree.remove(t),a<n&&(o!==r?this.insert(a,n-1,o):n=a),u>s&&(o!==r?this.insert(s+1,u,o):s=u)}}this.insert(n,s,r)}expandedValues(e,t){let r=this.intersecting(e,t),n=[],s=0;for(let i=e;i<=t;i++)r[s].end<i&&s++,n.push({index:i-e,value:r[s].value});return n}sortedIndices(e,t,r,n){let s=this.expandedValues(e,t),i=function(e,t){return e.value===t.value?e.index-t.index:r(e.value,t.value)};return n&&(i=function(e,t){let s=n[e.index],i=n[t.index];return s.value===i.value?r(e.value,t.value):e.index-t.index}),s.sort(i),s}sort(e,t,r){if(1===this.intersecting(e,t).length)return;let n=this.expandedValues(e,t);for(let t=0,s=r.length;t<s;t++)this.value(t+e,t+e,n[r[t].index].value)}copy(e,t,r){let n,s=this.intersecting(e,t),i=r;for(let r=0,o=s.length;r<o;r++){let o=s[r].start;o<e&&(o=e);let a=s[r].end;a>t&&(a=t),n=i+(a-o),this.value(i,n,s[r].value),i=++n}}iterator(e,t){return new Zt(e,t,this.intersecting(e,t))}getState(){return this.tree.clone()}setState(e){this.tree=e.clone()}toJSON(){return this.values()}fromJSON(e){e.forEach((e=>{this.value(e.start,e.end,e.value)}))}}class Zt{constructor(e,t,r){this.start=e,this.end=t,this.index=0,this.ranges=r}unique(){return this.ranges.map((function(e){return e.value}))}at(e){for(;this.ranges[this.index]&&this.ranges[this.index].end<e;)this.index++;return this.ranges[this.index]&&this.ranges[this.index].value}forEach(e){for(let t=this.start;t<=this.end;t++)e(this.at(t),t);this.index=0}}class er extends Qt{constructor(e,t,r){super(e,t,r),this._defaultValue=r,this.tree=new Yt,this.range=new qt(e,t,r)}intersecting(e,t){let r,n=e,s=this.tree.intersecting(n,t),i=[];if(!s.length)return[this.range];for(let e=0,t=s.length;e<t;e++)r=s[e],r.start>n&&i.push(new qt(n,r.start-1,this.range.value)),i.push(r),n=r.end+1;return r.end<t&&i.push(new qt(r.end+1,t,this.range.value)),i}insert(e,t,r){let n=r;null==n&&(n=this._defaultValue),n!==this.range.value&&this.tree.insert(new qt(e,t,n))}lastRangeStart(){let e=this.tree.root;if(e===Ht)return this.range.start;for(;e.right!==Ht;)e=e.right;return e.value.end+1}}class tr{constructor(e){this.list=e}get(e){return this.parse(this.list.value(e,e))}set(e,t,r){void 0===r&&(r=t,t=e),this.list.value(e,t,r)}parse(e){return e}copy(e,t,r){this.list.copy(e,t,r)}iterator(e,t){return this.list.iterator(e,t)}}class rr extends tr{set(e,t,r){this.list.value(e,t,JSON.stringify(r))}parse(e){return JSON.parse(e)}}const nr=[{property:tr,name:"format",value:null,sortable:!0,serializable:!0},{property:class extends tr{constructor(e,t){super(e),this.formats=t}set(e,t,r){r instanceof Date?(r=te.runtime.dateToSerial(r),this.formats.value(e,t)||this.formats.value(e,t,ee().calendar.patterns.d.replace(/M/g,"m").replace(/'/g,'"').replace(/tt/,"am/pm"))):"number"==typeof r&&(r=te.runtime.limitPrecision(r)),this.list.value(e,t,r)}},name:"value",value:null,sortable:!0,serializable:!0,depends:"format"},{property:tr,name:"formula",value:null,sortable:!0,serializable:!0},{property:tr,name:"background",value:null,sortable:!0,serializable:!0},{property:rr,name:"vBorders",value:null,sortable:!1,serializable:!1},{property:rr,name:"hBorders",value:null,sortable:!1,serializable:!1},{property:rr,name:"dBorders",value:null,sortable:!1,serializable:!0},{property:tr,name:"color",value:null,sortable:!0,serializable:!0},{property:tr,name:"fontFamily",value:null,sortable:!0,serializable:!0},{property:tr,name:"underline",value:null,sortable:!0,serializable:!0},{property:tr,name:"fontSize",value:null,sortable:!0,serializable:!0},{property:tr,name:"italic",value:null,sortable:!0,serializable:!0},{property:tr,name:"bold",value:null,sortable:!0,serializable:!0},{property:tr,name:"textAlign",value:null,sortable:!0,serializable:!0},{property:tr,name:"indent",value:null,sortable:!0,serializable:!0},{property:tr,name:"verticalAlign",value:null,sortable:!0,serializable:!0},{property:tr,name:"wrap",value:null,sortable:!0,serializable:!0},{property:tr,name:"validation",value:null,sortable:!1,serializable:!0},{property:tr,name:"enable",value:null,sortable:!1,serializable:!0},{property:tr,name:"link",value:null,sortable:!0,serializable:!0},{property:tr,name:"editor",value:null,sortable:!0,serializable:!0},{property:tr,name:"comment",value:null,sortable:!0,serializable:!0},{property:tr,name:"html",value:null,sortable:!0,serializable:!0}];class sr{constructor(e,t,r){r=r||{};let n=e*t-1;this.specs=nr,this.rowCount=e,this.columnCount=t,this.cellCount=n,this.properties={},this.lists={},this.specs.forEach((function(e){let t=e.name,s=r[t];void 0===s&&(s=e.value),this.lists[t]=new er(0,n,s),(this.properties[t]=new e.property(this.lists[t],this.lists[e.depends])).spec=e}),this),this.lists.formula.tree.clone=or,this.lists.validation.tree.clone=or}_resize(e,t){let r=this,n=r.rowCount,s=e*t-1;function i(t){return(t/n|0)*e+t%n}function o(e){e.start=i(e.start),e.end=i(e.end)}Object.keys(r.lists).forEach((function(t){let i=r.lists[t];e!==n&&i.forEach(o),i.range.end=s})),r.rowCount=e,r.columnCount=t,r.cellCount=s}getState(){let e={};return this.specs.forEach((function(t){e[t.name]=this.lists[t.name].getState()}),this),e}setState(e){this.specs.forEach((function(t){this.lists[t.name].setState(e[t.name])}),this)}get(e,t){if(void 0===t)return this.lists[e];switch(e){case"borderRight":t+=this.rowCount;case"borderLeft":e="vBorders";break;case"borderBottom":t++;case"borderTop":e="hBorders"}return t>this.cellCount?null:this.properties[e].get(t)}set(e,t,r,n){switch(e){case"borderRight":t+=this.rowCount,r+=this.rowCount;case"borderLeft":e="vBorders";break;case"borderBottom":t++,r++;case"borderTop":e="hBorders"}t<=r&&r<=this.cellCount&&this.properties[e].set(t,r,n)}fromJSON(e,t){for(let r=0;r<this.specs.length;r++){let n=this.specs[r];n.serializable&&void 0!==t[n.name]&&this.set(n.name,e,e,t[n.name],!1)}["borderLeft","borderRight","borderTop","borderBottom"].forEach((function(r){void 0!==t[r]&&this.set(r,e,e,t[r])}),this)}copy(e,t,r){this.specs.forEach((function(n){this.properties[n.name].copy(e,t,r)}),this)}iterator(e,t,r){let n=this.properties[e],s=n.iterator(t,r),i=s.at,o=this.cellCount;return s.at=function(e){return e>o?null:n.parse(i.call(s,e))},s.name=e,s.value=n.spec.value,s}sortable(){return this.specs.filter((function(e){return e.sortable})).map((function(e){return this.lists[e.name]}),this)}iterators(e,t){return this.specs.reduce(function(r,n){return n.serializable&&r.push(this.iterator(n.name,e,t)),r}.bind(this),[])}forEach(e,t,r){let n,s,i=this.iterators(e,t),o=this.iterator("hBorders",e,t+1),a=this.iterator("vBorders",e,t),u=this.iterator("vBorders",e+this.rowCount,t+this.rowCount);function h(e,t,r){let s=t.at(r);s!==t.value&&(n[e]=s)}for(s=e;s<=t;s++){n={};for(let e=0;e<i.length;e++){let t=i[e],r=t.at(s);r!==t.value&&(n[t.name]=r)}h("borderLeft",a,s),h("borderRight",u,s+this.rowCount),h("borderTop",o,s),(s+1)%this.rowCount&&h("borderBottom",o,s+1),r(n)}}forEachProperty(e){for(let t in this.properties)e(this.properties[t])}}function ir(e){return(e=e.clone()).value=e.value.deepClone(),e}function or(){let e=this.map(ir);return e.clone=or,e}const ar=nr.reduce((function(e,t){return t.serializable&&e.push(t.name),e}),["borderTop","borderRight","borderBottom","borderLeft"]);class ur{constructor(e){this.handler=e.handler,this.from=e.from,this.to=e.to,this.dataType=e.dataType,this.comparerType=e.comparerType,this.type=e.type?e.type:"warning",this.allowNulls=!!e.allowNulls,this.fromIsDateValue=!!e.fromIsDateValue,this.toIsDateValue=!!e.toIsDateValue,this.showButton=e.showButton,this.fromIsListValue=!!e.fromIsListValue,this.sheet=e.sheet,this.row=e.row,this.col=e.col,e.tooltipMessageTemplate&&(this.tooltipMessageTemplate=e.tooltipMessageTemplate),e.tooltipTitleTemplate&&(this.tooltipTitleTemplate=e.tooltipTitleTemplate),e.messageTemplate&&(this.messageTemplate=e.messageTemplate),e.titleTemplate&&(this.titleTemplate=e.titleTemplate)}_formatMessages(e){let t=this.from?this.from_value:"",r=this.to?this.to_value:"",n=this.from?this.from.toString():"",s=this.to?this.to.toString():"",i=this.dataType,o=this.type,a=this.comparerType;return Z().format(e,t,r,n,s,i,o,a)}_setMessages(){this.title="",this.message="",this.tooltipTitleTemplate&&(this.tooltipTitle=this._formatMessages(this.tooltipTitleTemplate)),this.tooltipMessageTemplate&&(this.tooltipMessage=this._formatMessages(this.tooltipMessageTemplate)),this.titleTemplate&&(this.title=this._formatMessages(this.titleTemplate)),this.messageTemplate&&(this.message=this._formatMessages(this.messageTemplate))}_getListData(){if(!this.from_value||!this.from_value.data)return[];let e,t,r=this.from_value.data,n=[];for(e=0;e<r.length;e++){let s=r[e];if(s)for(t=0;t<s.length;t++)n.push(s[t])}return n}clone(e,t,r){let n=this._getOptions();n.from&&(n.from=n.from.clone(e,t,r)),n.to&&(n.to=n.to.clone(e,t,r));const s=Object.assign({},n);return s.handler=this.handler,s.sheet=e,s.row=t,s.col=r,new ur(s)}deepClone(){let e=new ur(this);return e.from=e.from.deepClone(),e.to&&(e.to=e.to.deepClone()),e}exec(e,t,r,n){let s=this;function i(t){return t instanceof u&&(t=e.getData(t),Array.isArray(t)&&(t=t[0])),t}let o=function(e){s.from_value=i(e),s.value=s.handler.call(s,t,r),s._setMessages(),n&&n(s.value)};s.to?s.to.exec(e,(function(t){s.to_value=i(t),s.from.exec(e,o)})):s.from.exec(e,o)}reset(){this.from&&this.from.reset(),this.to&&this.to.reset(),delete this.value}adjust(e,t,r,n){let s,i,o,a=this.row,u=this.col;if(this.from&&(s=this.from.adjust(e,t,r,n)),this.to&&(i=this.to.adjust(e,t,r,n)),this.sheet.toLowerCase()===e.toLowerCase())switch(t){case"row":a>=r&&(o=!0,this.row+=n);break;case"col":u>=r&&(o=!0,this.col+=n)}if(o||s||i){let e=new ur(this);return e.from=s,e.to=i,e.row=a,e.col=u,e}}toJSON(){let e=this._getOptions();return e.from&&(e.from=e.from.toString(),"list"===e.dataType&&(e.from=e.from.replace(/^_matrix\((.*)\)$/i,"$1"),delete e.fromIsListValue),"date"===e.dataType&&this.fromIsDateValue&&(e.from=e.from.replace(/^DATEVALUE\("(.*)"\)$/i,"$1"),delete e.fromIsDateValue)),e.to&&(e.to=e.to.toString(),"date"===e.dataType&&this.toIsDateValue&&(e.to=e.to.replace(/^DATEVALUE\("(.*)"\)$/i,"$1"),delete e.toIsDateValue)),e}_getOptions(){return{from:this.from,to:this.to,dataType:this.dataType,type:this.type,comparerType:this.comparerType,row:this.row,col:this.col,sheet:this.sheet,allowNulls:this.allowNulls,fromIsListValue:this.fromIsListValue,fromIsDateValue:this.fromIsDateValue,toIsDateValue:this.toIsDateValue,tooltipMessageTemplate:this.tooltipMessageTemplate,tooltipTitleTemplate:this.tooltipTitleTemplate,messageTemplate:this.messageTemplate,titleTemplate:this.titleTemplate,showButton:this.showButton}}}const hr={compile:function(e,t,r,n){let s,i,o,a;if("string"==typeof n&&(n=JSON.parse(n)),n.from&&("list"!==n.dataType||n.fromIsListValue||(n.from.indexOf("{")>-1&&(n.from=n.from.replace(/\"/g,"").replace(/^\s*\{\s*/,'"').replace(/\s*\}\s*$/,'"')),n.from=`_matrix(${n.from})`,n.fromIsListValue=!0),"date"===n.dataType&&(o=te.runtime.parseDate(n.from),o&&(n.from=`DATEVALUE("${n.from}")`,n.fromIsDateValue=!0)),n.from=te.compile(te.parseFormula(e,t,r,n.from))),n.to&&("date"===n.dataType&&(a=te.runtime.parseDate(n.to),a&&(n.to=`DATEVALUE("${n.to}")`,n.toIsDateValue=!0)),n.to=te.compile(te.parseFormula(e,t,r,n.to))),i="custom"===n.dataType?hr.validationComparers.custom:"list"===n.dataType?hr.validationComparers.list:hr.validationComparers[n.comparerType],!i)throw Z().format("'{0}' comparer is not implemented.",n.comparerType);s=function(e){let t=this.to&&(this.to_value||0===this.to_value)?this.to_value:void 0;if(null===e||""===e)this.allowNulls?this.value=!0:this.value=!1;else if("custom"===this.dataType)this.value=i(e,this.from_value,t);else if("list"===this.dataType){let r=this._getListData();this.value=i(e,r,t)}else this.value=i(e,this.from_value,t);return this.value};const u=Object.assign({},n);return u.handler=s,u.sheet=e,u.row=t,u.col=r,new ur(u)},validationComparers:{greaterThan:function(e,t){return e>t},lessThan:function(e,t){return e<t},between:function(e,t,r){return e>=t&&e<=r},equalTo:function(e,t){return e===t},notEqualTo:function(e,t){return e!==t},greaterThanOrEqualTo:function(e,t){return e>=t},lessThanOrEqualTo:function(e,t){return e<=t},notBetween:function(e,t,r){return e<t||e>r},custom:function(e,t){return t},list:function(e,t){return t.indexOf(e)>-1}}};hr.Validation=ur;const{measureText:lr}=t.u;let cr=["color","fontFamily","underline","italic","bold","textAlign","indent","verticalAlign","background","format","link","editor","borderTop","borderRight","borderBottom","borderLeft","comment","html"],fr=class e{constructor(e,t){this._sheet=t,this._ref=e}clone(){return new e(this._ref.clone(),this._sheet)}skipHiddenCells(){let e=[],t=this,r=t._sheet,n=r.isHiddenRow.bind(r),s=r.isHiddenColumn.bind(r);return t._ref.forEach((function(r){let i=(r=t._normalize(r.toRangeRef())).topLeft,o=r.bottomRight,a=pr(i.row,o.row,n),u=pr(i.col,o.col,s);for(let t=0;t<a.length;++t)for(let r=0;r<u.length;++r)e.push(new f(new c(a[t].begin,u[r].begin),new c(a[t].end,u[r].end)))})),r.range(e.length>1?new p(e):e[0])}_normalize(e){return this._sheet._grid.normalize(e)}_set(e,t,r){let n=this,s=n._sheet;return n._ref.forEach((function(r){let n=r;if(("value"===e||"formula"===e||"link"===e)&&r.topLeft){let e=new c(r.topLeft.row,r.topLeft.col);s.forEachMergedCell((function(t){t.intersects(e)&&(n=e)}))}s._set(n.toRangeRef(),e,t)})),r||s.triggerChange({recalc:"formula"===e||"value"===e||"validation"===e,value:t,range:n,ref:n._ref,isValue:"value"===e}),n}_get(e){return this._sheet._get(this._ref.toRangeRef(),e)}_property(e,t){return void 0===t?this._get(e):this._set(e,t)}value(e){return void 0!==e&&this._set("formula",null,!0),this._property("value",e)}html(e){return this._property("html",e)}resize(t){let r=this._resizedRef(t);return new e(r,this._sheet)}_resizedRef(e){return this._ref.map((function(t){return t.toRangeRef().resize(e)}))}input(e,t){t=Object.assign({arrayFormula:!1},t);let r,n=this._get("format");if(void 0!==e){let s=this._ref.toRangeRef().topLeft;return r=te.parse(this._sheet.name(),s.row,s.col,e,n),this._sheet.batch(function(){let s=null;if("exp"===r.type)s=te.compile(r);else if("@"!==n){let e=n&&Je.type(r.value,n);"date"===r.type&&"date"!==e?this.format(r.format||ee().calendar.patterns.d.replace(/M/g,"m").replace(/'/g,'"').replace(/tt/,"am/pm")):"percent"===r.type&&"percent"!==e?this.format(100*r.value==(100*r.value|0)?"0%":"0.00%"):r.format&&(!n||r.currency||"number"===e&&"number"===r.type&&r.format.length>n.length)&&this.format(r.format)}else"string"!==r.type&&(r.value=e);this.formula(s,t.arrayFormula),s||this.value(r.value)}.bind(this),{recalc:!0,value:e,ref:this._ref,editorChange:this._sheet.isInEditMode(),isValue:!0}),this}{e=this._get("value");let t=this._get("formula"),i=n&&!t&&Je.type(e,n);if(t)e="="+t;else e:{if(n&&"date"===i){let t=Je.text(e,n);if(r=te.parse(null,null,null,t,n),t===Je.text(r.value,n)){e=t;break e}}if("date"===i){const t=Z();e=t.toString(te.runtime.serialToDate(e),ee().calendar.patterns.d,t.locale)}else"percent"===i?e=te.runtime.limitPrecision(100*e)+"%":"string"==typeof e&&(/^[=']/.test(e)||/^(?:true|false)$/i.test(e)||!/^=/.test(s=e)&&/number|percent/.test(te.parse(null,0,0,s).type))?e="'"+e:this._sheet._useCultureDecimals()&&"number"==typeof e&&e!==Math.floor(e)&&(e=String(e).replace(".",ee().numbers.symbols.decimal))}return e}var s}enable(e){return void 0===e?!B((function(e){this._sheet.forEach(this._ref,(function(t,r,n){!1===n.enable&&e(!0)}))}),this):this._property("enable",e)}formula(e,t){let r=this;if(void 0===e){let e=r._get("formula");return e?""+e:null}if(t){let t=this._ref.toRangeRef();(e=r._sheet.range(t.topLeft)._set("formula",e)._get("formula"))&&e.setArrayFormulaRange(t)}else r._set("formula",e);return r}intersectingArrayFormula(){let e=this._ref.clone().simplify().setSheet(this._sheet.name());return B((function(t){this._sheet._forFormulas((function(r){let n=r.arrayFormulaRange;n&&(n=e.intersect(n))!==h&&t({formula:r,intersection:n})}))}),this)}canEditArrayFormula(){let e=this.intersectingArrayFormula();return!e||e.formula.arrayFormulaRange.eq(e.intersection)}validation(e){if(void 0===e){let e=this._get("validation");return e?e.toJSON():null}return this._property("validation",e)}_getValidationState(){let e,t,r=this._ref.toRangeRef(),n=r.topLeft.row,s=r.topLeft.col,i=r.bottomRight.row,o=r.bottomRight.col;for(e=s;e<=o;e++)for(t=n;t<=i;t++){let r=this._sheet._validation(t,e);if(r&&"reject"===r.type&&!1===r.value)return r}return!1}merge(){return this._ref=this._sheet._merge(this._ref),this}unmerge(){let e=this._sheet._mergedCells;return this._ref.forEach((function(t){t.toRangeRef().intersecting(e).forEach((function(t){e.splice(e.indexOf(t),1)}))})),this._sheet.triggerChange({}),this}select(){return this._sheet.select(this._ref),this}values(e){if(this._ref instanceof p)throw new Error("Unsupported for multiple ranges.");if(this._ref===h){if(void 0!==e)throw new Error("Unsupported for NULLREF.");return[]}let t,r,n=this._ref.toRangeRef(),s=n.topLeft.row,i=n.topLeft.col,o=n.bottomRight.row,a=n.bottomRight.col;if(void 0===e){e=new Array(n.height());for(let t=0;t<e.length;t++)e[t]=new Array(n.width());for(t=i;t<=a;t++)for(r=s;r<=o;r++)e[r-s][t-i]=this._sheet._value(r,t);return e}for(this._sheet._set(n,"formula",null),t=i;t<=a;t++)for(r=s;r<=o;r++){let n=e[r-s];if(n){let e=n[t-i];void 0!==e&&this._sheet._value(r,t,e)}}return this._sheet.triggerChange({recalc:!0,ref:n}),this}_properties(e,t){if(this._ref instanceof p)throw new Error("Unsupported for multiple ranges.");if(this._ref===h){if(void 0!==e)throw new Error("Unsupported for NULLREF.");return[]}let r,n,s=this._ref.toRangeRef(),i=s.topLeft.row,o=s.topLeft.col,a=s.bottomRight.row,u=s.bottomRight.col,l=this._sheet;if(void 0===e)return e=new Array(s.height()),l.forEach(s,(function(t,r,n){r-=o,(e[t-=i]||(e[t]=[]))[r]=n})),e;{let h;s=s.clone();let c=function(e){let t=h[e];s.topLeft.row=s.bottomRight.row=n,s.topLeft.col=s.bottomRight.col=r,"value"===e&&l._set(s,"formula",null),l._set(s,e,t)},f=!1;for(r=o;r<=u;r++)if(t||!l.isHiddenColumn(r))for(n=i;n<=a;n++){if(!t&&l.isHiddenRow(n))continue;if(t&&l.isFilteredRow(n))continue;let s=e[n-i];if(s&&(h=s[r-o],h)){const e=Object.keys(h);e.forEach(c),f=f||e.includes("value")}}return l.triggerChange({recalc:!0,ref:this._ref,isValue:f}),this}}clear(e){let t=(e=e||{}).clearAll||!Object.keys(e).length,r=this._sheet,n={recalc:t||e.contentsOnly,ref:this._ref,isValue:!0};return r.batch(function(){n.recalc&&this.formula(null),t&&this.validation(null),(t||e.formatOnly)&&(cr.forEach(function(t){e.keepBorders&&/^border/i.test(t)||this[t](null)}.bind(this)),this.fontSize(null),this.wrap(null),this.unmerge())}.bind(this),n),this}clearContent(){return this.clear({contentsOnly:!0})}clearFormat(){return this.clear({formatOnly:!0})}isSortable(){return!this.cantSort()}cantSort(){if(this._ref instanceof p)return{code:"cantSortMultipleSelection",message:"Unsupported for multiple ranges."};if(this._ref===h)return{code:"cantSortNullRef",message:"Unsupported for NULLREF."};let e=this._sheet._getMergedCells(this._ref.toRangeRef()),t=e.primary,r=e.secondary,n=null,s=null,i={};try{this._sheet.forEach(this,(function(o,a){let u=new c(o,a).print(),h=t[u];if(h){if(null===n)n=h.width(),s=h.height();else if(n!==h.width()||s!==h.height())throw i}else if(!r[u]&&e.hasMerged)throw i}))}catch(e){if(e!==i)throw e;return{code:"cantSortMixedCells",message:"Unsupported for range containing cells of different shapes."}}return!1}sort(e){let t=this.cantSort();if(t)throw new Error(t.message);return void 0===e&&(e={column:0}),e=e instanceof Array?e:[e],this._sheet._sortBy(this._ref.toRangeRef(),e.map((function(e,t){return"number"==typeof e&&(e={column:e}),{index:void 0===e.column?t:e.column,ascending:void 0===e.ascending||e.ascending}}))),this}isFilterable(){return!(this._ref instanceof p)}filter(e){if(this._ref instanceof p)throw new Error("Unsupported for multiple ranges.");return!1===e?this.clearFilters():(e=!0===e?[]:e instanceof Array?e:[e],this._sheet._filterBy(this._ref.toRangeRef(),e.map((function(e,t){return{index:void 0===e.column?void 0===e.index?t:e.index:e.column,filter:e.filter}})))),this}clearFilter(e){this._sheet.clearFilter(e)}clearFilters(){let e=this._sheet.filter(),t=[];if(e){for(let r=0;r<e.columns.length;r++)t.push(e.columns[r].index);this._sheet.batch((function(){this.clearFilter(t),this._filter=null}),{layout:!0,filter:!0})}}hasFilter(){let e=this._sheet.filter();return Boolean(e)}leftColumn(){return new e(this._ref.leftColumn(),this._sheet)}rightColumn(){return new e(this._ref.rightColumn(),this._sheet)}topRow(){return new e(this._ref.topRow(),this._sheet)}bottomRow(){return new e(this._ref.bottomRow(),this._sheet)}column(t){return new e(this._ref.toColumn(t),this._sheet)}row(t){return new e(this._ref.toRow(t),this._sheet)}forEachRow(t){this._ref.forEachRow(function(r){t(new e(r,this._sheet))}.bind(this))}forEachColumn(t){this._ref.forEachColumn(function(r){t(new e(r,this._sheet))}.bind(this))}sheet(){return this._sheet}topLeft(){return this._ref.toRangeRef().topLeft}intersectingMerged(){let e=this._sheet,t=[];return e._mergedCells.forEach(function(e){e.intersects(this._ref)&&t.push(e.toString())}.bind(this)),t}getState(e){let t,r=this._ref.first(),n={ref:r,data:[],origRef:this._ref,rows:this._sheet._rows.getState()};e?t="input"===e?["value","formula"]:"border"===e?["borderLeft","borderTop","borderRight","borderBottom"]:[e]:(t=ar,n.mergedCells=this.intersectingMerged());let s=n.data;return this.forEachCell((function(e,n,i){let o={},a=e-r.row,u=n-r.col;s[a]||(s[a]=[]),s[a][u]=o,t.forEach((function(e){let t=void 0===i[e]?null:i[e];(t instanceof te.runtime.Formula||t instanceof hr.Validation)&&(t=t.deepClone()),o[e]=t}))})),n}setState(e,t){let r=this._sheet,n=this._ref.first(),s=e.ref.row-n.row,i=e.ref.col-n.col,o=t&&!t.isExternal(),a=t&&!o;r.batch(function(){e.mergedCells&&this.unmerge(),t||this._sheet._rows.setState(e.rows);let u=n.row,h=this.hasFilter();e.data.forEach((function(s,i){if(h&&o&&r.isHiddenRow(e.ref.row+i))return;let l=n.col;s.forEach((function(s,c){if(h&&o&&r.isHiddenColumn(e.ref.col+c))return;let f=t?r.range(u,l):r.range(n.row+i,n.col+c);if(f.enable()){for(let e in s)"value"!==e&&(t&&"enable"===e||f._set(e,s[e]));if(!s.formula)if(a)try{null==s.value?f._set("value",null):f.input(s.value)}catch(e){f._set("value",s.value)}else f._set("value",s.value)}l++})),u++})),e.mergedCells&&e.mergedCells.forEach((function(e){e=r._ref(e).relative(s,i,3),r.range(e).merge()}),this)}.bind(this),{recalc:!0,ref:this._ref})}_adjustRowHeight(){let e=this,t=e._sheet,r=t._getMergedCells(e._ref.toRangeRef()),n=r.primary,s=r.secondary;t.batch((function(){e.forEachRow((function(e){let r=e._ref.topLeft.row,i=t.rowHeight(r);i&&(e.forEachCell((function(e,r,o){let a=new c(e,r).print();if(s[a])return;let u,h=n[a];u=h?t._columns.sum(h.topLeft.col,h.bottomRight.col):t.columnWidth(r);let l=o.value;o.format&&null!=l&&(l=Je.format(l,o.format));let f=function(e,t,r,n,s){const i=document.createElement("div");i.style.setProperty("position","absolute","important"),i.style.setProperty("top","-4000px","important"),i.style.setProperty("height","auto","important"),i.style.setProperty("padding","1px 3px","important"),i.style.setProperty("box-sizing","border-box","important"),i.style.setProperty("margin","0","important"),i.style.setProperty("border","1px solid black","important"),i.style.setProperty("line-height","normal","important"),i.style.setProperty("visibility","hidden","important"),i.style.setProperty("white-space","pre-wrap");let o={baselineMarkerSize:0,width:!0===s?t+"px":"auto","font-size":(n||12)+"px","font-family":r||"Arial","white-space":!0===s?"pre-wrap":"pre","overflow-wrap":!0===s?"break-word":"normal","word-wrap":!0===s?"break-word":"normal"};return lr(e,o,{box:i,normalizeText:!1}).height}(l,u,o.fontFamily,o.fontSize,o.wrap);i=Math.max(i,f)})),t.rowHeight(r,i))}))}),{layout:!0})}forEachCell(e){this._ref.forEach(function(t){this._sheet.forEach(t.toRangeRef(),e.bind(this))}.bind(this))}hasValue(){let e=this._sheet._defaultCellStyle;return B((function(t){this.forEachCell((function(r,n,s){for(let r in s){let n=s[r];null!=n&&n!==e[r]&&t(!0)}}))}),this)}wrap(e){return void 0===e?Boolean(this._property("wrap")):(this._property("wrap",e),null!==e&&this._adjustRowHeight(),this)}fontSize(e){return void 0===e?this._property("fontSize"):(this._property("fontSize",e),null!==e&&this._adjustRowHeight(),this)}draw(e,t){this._sheet.draw(this,e,t)}insideBorders(e){return this.insideVerticalBorders(e).insideHorizontalBorders(e)}insideVerticalBorders(e){return this._ref.forEach((function(t){t instanceof f&&t.width()>1&&((t=t.clone()).topLeft.col++,this._sheet.range(t)._set("vBorders",e))}),this),this}insideHorizontalBorders(e){return this._ref.forEach((function(t){t instanceof f&&t.height()>1&&((t=t.clone()).topLeft.row++,this._sheet.range(t)._set("hBorders",e))}),this),this}};function pr(e,t,r){for(;e<=t&&r(e);)e++;if(e>t)return[];for(let n=e+1;n<=t;++n)if(r(n))return[{begin:e,end:n-1}].concat(pr(n+1,t,r));return[{begin:e,end:t}]}cr.forEach((function(e){fr.prototype[e]=function(t){return this._property(e,t)}}));var dr=te.runtime.Formula,gr="incompatibleRanges",mr=fr.FillError=function(e){this.code=e};function vr(e){for(var t=e.length,r=(t+1)/2,n=e.reduce((function(e,t){return e+t}),0)/t,s=0,i=0,o=0;o<t;o++){var a=o+1-r;s+=a*(e[o]-n),i+=a*a}if(!i)return function(t){return e[t%e.length]};var u=s/i,h=n-u*r;return function(e){return h+u*(e+1)}}function yr(e){function t(e){return e.map((function(e){return e.number}))}var r=[],n=e.map((function(e){return e.formula||e.value}));return function(e,t){for(var r,n=null,s=0,i=[],o=0;o<e.length;++o)r=wr(e[o]),i.push(r),null!=n&&r.type!==n.type&&(t(s,o,n.type,i.slice(s,o)),s=o),n=r;t(s,o,n.type,i.slice(s,o))}(n,(function(e,s,i,o){var a,u;if("number"==i)a=vr(u=t(o));else if("string"==i||"formula"==i||"boolean"==i)a=function(e,t){return n[t]};else if(Array.isArray(i))if(1==o.length)a=function(e){return i[(o[0].number+e)%i.length]};else{var h=function(e){for(var t=e[1]-e[0],r=2;r<e.length;++r)if(e[r]-e[r-1]!=t)return null;return t}(t(o));a=null==h?function(e){return o[e%o.length].value}:function(e){var t=o[0].number+h*e;return i[t%i.length]}}else"null"!=i?(1==(u=t(o)).length&&u.push(u[0]+1),u=vr(u),a=function(e,t){return n[t].replace(/^(.*\D0*)\d+$/,"$1"+u(e,t))}):a=function(){return null};for(var l={f:a,begin:e,end:s,len:s-e},c=e;c<s;++c)r[c]=l})),function(t,s){var i,o,a=r[s],u=t/n.length|0,h=t%n.length,l=u*a.len+h-a.begin,c=a.f(l,s),f=(i=e[s],o={},Object.keys(i||{}).forEach((function(e){o[e]=i[e]})),o);return delete f.enable,c instanceof dr?f.formula=c:f.value=c,f}}function wr(e){if("number"==typeof e)return{type:"number",number:e};if("string"==typeof e){var t=function(e){for(var t=e.toLowerCase(),r=function(){const e=ee().calendar;return[e.days.format.abbreviated,e.days.format.wide,e.months.format.abbreviated,e.months.format.wide]}(),n=0;n<r.length;++n)for(var s=r[n],i=s.length;--i>=0;){if(s[i].toLowerCase()==t)return{type:s,number:i,value:e}}}(e);if(t)return t;var r=/^(.*\D0*)(\d+)$/.exec(e);return r?{type:e=e.replace(/^(.*\D0*)\d+$/,"$1-######"),match:r,number:parseFloat(r[2])}:{type:"string"}}if("boolean"==typeof e)return{type:"boolean"};if(null==e)return{type:"null"};if(e instanceof dr)return{type:"formula"};throw window.console.error(e),new Error("Cannot fill data")}function br(e){for(var t=e.length,r=e[0].length,n=[],s=0;s<r;++s){n[s]=[];for(var i=0;i<t;++i)n[s][i]=e[i][s]}return n}fr.prototype._previewFillFrom=function(e,t){var r=this,n=r._sheet;"string"==typeof e&&(e=n.range(e));var s=e._ref.toRangeRef().clone().setSheet(n.name()),i=r._ref.toRangeRef().clone().setSheet(n.name());if(s.intersects(i)){if(s.eq(i))return null;if(i=i.clone(),s.topLeft.eq(i.topLeft))if(s.width()==i.width())i.topLeft.row+=s.height(),t=0;else{if(s.height()!=i.height())throw new mr(gr);i.topLeft.col+=s.width(),t=1}else{if(!s.bottomRight.eq(i.bottomRight))throw new mr(gr);if(s.width()==i.width())i.bottomRight.row-=s.height(),t=2;else{if(s.height()!=i.height())throw new mr(gr);i.bottomRight.col-=s.width(),t=3}}return n.range(i)._previewFillFrom(e,t)}if(null==t)if(s.topLeft.col==i.topLeft.col)t=s.topLeft.row<i.topLeft.row?0:2;else{if(s.topLeft.row!=i.topLeft.row)throw new mr("noFillDirection");t=s.topLeft.col<i.topLeft.col?1:3}var o=1&t,a=2&t;if(o&&s.height()!=i.height()||!o&&s.width()!=i.width())throw new mr(gr);var u,h=e._properties();o?u=i.width():(h=br(h),u=i.height());for(var l=new Array(h.length),c=null,f=0;f<h.length;++f)for(var p=h[f],d=yr(p),g=l[f]=new Array(u),m=0;m<u;++m){var v=a?-m-1:p.length+m,y=a?p.length-m%p.length-1:m%p.length,w=g[a?u-m-1:m]=d(v,y);null!=w.value&&(c=w.value)}return o||(l=br(l)),{props:l,direction:t,dest:r,hint:c}},fr.prototype.fillFrom=function(e,t){var r=this._previewFillFrom(e,t);return r.dest._properties(r.props,!0),r.dest};const _r="string",Ar="function";let Cr=function(){this._defaultPrevented=!0},xr=function(){return!0===this._defaultPrevented};class kr{constructor(){this._events={}}bind(e,t,r){let n,s,i,o,a,u=this,h=typeof e===_r?[e]:e,l=typeof t===Ar;if(void 0===t){for(n in e)u.bind(n,e[n]);return u}for(n=0,s=h.length;n<s;n++)e=h[n],o=l?t:t[e],o&&(r&&(i=o,o=function(){u.unbind(e,o),i.apply(u,arguments)},o.original=i),a=u._events[e]=u._events[e]||[],a.push(o));return u}one(e,t){return this.bind(e,t,!0)}first(e,t){let r,n,s,i,o=this,a=typeof e===_r?[e]:e,u=typeof t===Ar;for(r=0,n=a.length;r<n;r++)e=a[r],s=u?t:t[e],s&&(i=o._events[e]=o._events[e]||[],i.unshift(s));return o}trigger(e,t){let r,n,s=this,i=s._events[e];if(i){for((t=t||{}).sender=s,t._defaultPrevented=!1,t.preventDefault=Cr,t.isDefaultPrevented=xr,i=i.slice(),r=0,n=i.length;r<n;r++)i[r].call(s,t);return!0===t._defaultPrevented}return!1}unbind(e,t){let r,n=this,s=n._events[e];if(void 0===e)n._events={};else if(s)if(t)for(r=s.length-1;r>=0;r--)s[r]!==t&&s[r].original!==t||s.splice(r,1);else n._events[e]=[];return n}}class Mr extends kr{constructor(e,t){super(),this.element=e,this.events=[],this.options=t}setOptions(e){this._setEvents(e),H({},this.options,e)}_setEvents(e){let t,r=this,n=0,s=r.events.length;for(;n<s;n++)t=r.events[n],r.options[t]&&e[t]&&(r.unbind(t,r.options[t]),r._events&&r._events[t]&&delete r._events[t]);r.bind(r.events,e)}resize(e){const t=this.getSize(),r=this._size;(e||(t.width>0||t.height>0)&&(!r||t.width!==r.width||t.height!==r.height))&&(this._size=t,this._resize(t,e),this.trigger("resize",t))}getSize(){return{width:this.element.offsetWidth,height:this.element.offsetHeight}}destroy(){this.unbind()}}class Er extends kr{constructor(e){super(),this.events=["activate","deactivate","change","update"],this.view=e,this.formulaBar=e.formulaBar,this._active=!1,this.barInput=e.formulaBar.formulaInput,this.cellInput=e.formulaInput,this.barInput.syncWith(this.cellInput),this.cellInput.syncWith(this.barInput),this.barInput.bind("keyup",this._triggerUpdate.bind(this)),this.cellInput.bind("keyup",this._triggerUpdate.bind(this)),this.barInput.bind("blur",this._blur.bind(this)),this.cellInput.bind("blur",this._blur.bind(this))}_blur(){this.deactivate()}_triggerUpdate(){this.trigger("update",{value:this.value()})}activeEditor(){let e=null,t=function(){try{return document.activeElement}catch(e){return document.documentElement.activeElement}}();return this.barElement()===t?e=this.barInput:this.cellElement()===t&&(e=this.cellInput),e}activate(e){let t,r,n,s=this.view.element;return this._active=!0,this._rect=e.rect,this._range=e.range,this.cellInput.position(e.rect),this.cellInput.resize(e.rect),this.cellInput.tooltip(e.tooltip),this.cellInput.activeCell=this.barInput.activeCell=this._range.topLeft(),this.cellInput.activeSheet=this.barInput.activeSheet=this._range._sheet,s&&(t=s.offsetWidth,r=s.querySelector(".k-spreadsheet-scroller"),n=r.offsetWidth-r.clientWidth,this.cellInput.element.style.maxWidth=t-n-parseFloat(this.cellInput.element.style.left)+"px"),this.trigger("activate"),this}deactivate(e){let t=this.cellInput;this._active&&(this._active=!1,e||t.value()===this._value||this.trigger("change",{value:t.value(),range:this._range}),this._rect=null,t.hide(),this.trigger("deactivate"))}enable(e){this.barInput.enable(e),this.cellInput.enable(e)}barElement(){return this.barInput.element}cellElement(){return this.cellInput.element}focus(e){"cell"===(e=e||"cell")?(this.cellInput.element.focus(),this.cellInput.end()):this.barInput.focus()}isActive(){return this._active}isFiltered(){return this.barInput.popup.visible()||this.cellInput.popup.visible()}canInsertRef(e){let t=this.activeEditor();return t&&t.canInsertRef(e)}highlightedRefs(){let e=this.activeEditor(),t=[];return e&&(t=e.highlightedRefs()),t}scale(){this.cellInput.scale()}toggleTooltip(e){var t,r;this.cellInput.toggleTooltip((t=this._rect,r=e,t&&(t.top!==r.top||t.left!==r.left)))}value(e,t){if(void 0===e)return this.barInput.value();null===e&&(e=""),this._value=e,this.barInput.value(e),this.cellInput.value(e),this.barInput.element.classList.toggle("k-spreadsheet-array-formula",Boolean(t))}insertNewline(){this.activeEditor().insertNewline(),this.scale()}select(){this.activeEditor().select()}}const Fr=/&/g,Rr=/</g,Sr=/"/g,Nr=/'/g,Lr=/>/g;class Dr{constructor(e,t){this._value=t,this._count=e,this.values=new Qt(0,e-1,t),this._hidden=new Qt(0,e-1,0),this.scrollBarSize=j(),this._refresh()}_resize(e){e>this._count?(this.values.value(this._count,e-1,this._value),this._hidden.value(this._count,e-1,0)):e<this._count&&(this.values.value(e,this._count-1,0),this._hidden.value(e,this._count-1,0)),this._count=e,this._refresh()}adjust(e,t){t<0?(this.values.copy(e-t,this._count-1,e),this._hidden.copy(e-t,this._count-1,e)):(this.values.copy(e,this._count,e+t),this._hidden.copy(e,this._count,e+t),this.values.value(e,e+t-1,this._value),this._hidden.value(e,e+t-1,0)),this._refresh()}toJSON(e,t){let r=[],n=this.values.iterator(0,this._count-1);for(let s=0;s<this._count;s++){let i=n.at(s),o=this._hidden.value(s,s);if(i===this._value&&!o)continue;let a=t[s];if(void 0===a){a=r.length;let n={index:s};n[e]=i,o&&(n.hidden=o),r.push(n),t[s]=a}}return r}fromJSON(e,t){for(let r=0;r<t.length;r++){let n=t[r],s=n.index;void 0===s&&(s=r);let i=n[e];0===i?(this._hidden.value(s,s,n.hidden||this._value),this.value(s,s,0)):this.value(s,s,i)}}hide(e){if(!this.hidden(e)){let t=this.value(e,e);this._hidden.value(e,e,t),this.value(e,e,0)}}hidden(e){return 0!==this._hidden.value(e,e)}includesHidden(e,t){return this._hidden.intersecting(e,t).length>1}nextVisible(e){let t=this._count-1,r=e;for(;++r<=t;)if(!this.hidden(r))return r;return e}nextUntil(e,t){let r=this._count-1,n=e,s=!1;for(;++n<=r;){let e=t(n,s,this.hidden(n));if("number"==typeof e)return e;if(e)break;s=!0}return n-1}nextPage(e,t){return this.index(this.sum(0,e-1)+t)}prevPage(e,t){return this.index(this.sum(0,e)-t)}firstVisible(){let e=this._hidden.first();return 0===e.value?0:e.end+1}lastVisible(){let e=this._hidden.last();return 0===e.value?this._count-1:e.start-1}prevVisible(e){let t=e;for(;--t>=0;)if(!this.hidden(t))return t;return e}prevUntil(e,t){let r=e,n=!1;for(;--r>=0;){let e=t(r,n,this.hidden(r));if("number"==typeof e)return e;if(e)break;n=!0}return r+1}unhide(e){if(this.hidden(e)){let t=this._hidden.value(e,e);this._hidden.value(e,e,0),this.value(e,e,t)}}value(e,t,r){if(void 0===r)return this.values.iterator(e,t).at(0);this.values.value(e,t,r),this._refresh()}sum(e,t){let r=this.values.iterator(e,t),n=0;for(let s=e;s<=t;s++)n+=r.at(s);return n}locate(e,t,r){let n=this.values.iterator(e,t),s=0;for(let i=e;i<=t;i++){if(s+=n.at(i),r(s))return i}return null}visible(e,t){let r=null,n=null,s=!1;t>=this.total+this.scrollBarSize&&(s=!0);let i=this._pixelValues.intersecting(e,t);if(r=i[0],n=i[i.length-1],!r)return{values:this.values.iterator(0,0),offset:0};let o=e-r.start,a=(o/r.value.value|0)+r.value.start,u=o-(a-r.value.start)*r.value.value,h=t-n.start,l=(h/n.value.value|0)+n.value.start;return l>n.value.end&&(l=n.value.end),s&&(u+=n.value.value-(h-(l-n.value.start)*n.value.value)),u=Math.min(-u,0),{values:this.values.iterator(a,l),offset:u}}index(e){let t=0,r=this.values.iterator(0,this._count-1),n=r.at(0);for(;n<e&&t<this._count-1;)n+=r.at(++t);return t}indexVisible(e){let t=this.index(e);return this.hidden(t)&&(t=this.prevVisible(t)),t}_refresh(){let e=0;this._pixelValues=this.values.map((function(t){let r=e;return e+=(t.end-t.start+1)*t.value,new qt(r,e-1,t)})),this.total=e}getState(){return{values:this.values.getState(),hidden:this._hidden.getState(),count:this._count}}setState(e){this.values.setState(e.values),this._hidden.setState(e.hidden);let t=this._count;t>e.count?(this._count=e.count,this._resize(t)):this._refresh()}}class Ur{constructor(e,t,r,n){this._axis=e,this._start=t,this._count=r,this.hasHeader=0===t,this.headerSize=n,this.defaultValue=e._value,this.frozen=r>0}viewSize(e){this._viewSize=e}sum(e,t){return this._axis.sum(e,t-1)}start(){return this.sum(0,this._start)}size(){return this.sum(this._start,this._start+this._count)}index(e,t){return this._axis.index(e+(this.frozen?0:t)-this.headerSize)}indexVisible(e,t){return this._axis.indexVisible(e+(this.frozen?0:t)-this.headerSize)}paneSegment(){let e,t=this.start();return this.hasHeader||(t+=this.headerSize),this.frozen?(e=this.size(),this.hasHeader?e+=this.headerSize:e-=this.headerSize):e=this._viewSize-t,{offset:t,length:e}}visible(e){let t,r=this.start();this.frozen?(t=this.size(),this.hasHeader||(t-=this.headerSize)):(t=this._viewSize-r-this.headerSize,r+=e);let n=this._axis.visible(r,r+t-1);return this.frozen&&(n.offset=0),n.start=r,this.hasHeader&&(n.offset+=this.headerSize,n.start-=this.headerSize),n}contains(e,t){return this.frozen?!(e>this._start+this._count)&&!(t<this._start):t>=this._start}}class Vr{constructor(e,t,r,n){this.left=e,this.top=t,this.width=r,this.height=n,this.right=this.left+this.width,this.bottom=this.top+this.height}offset(e,t){return new Vr(this.left+e,this.top+t,this.width,this.height)}resize(e,t){return new Vr(this.left,this.top,this.width+e,this.height+t)}intersects(e,t){return e instanceof Vr?this.intersectsRect(e):this.left<e&&e<this.left+this.width&&this.top<t&&t<this.top+this.height}intersectsRect(e){let t=this;return t.left<=e.right&&e.left<=t.right&&t.top<=e.bottom&&e.top<=t.bottom}toDiv(e){return Be.element("div",{className:e,style:{width:this.width+"px",height:this.height+"px",top:this.top+"px",left:this.left+"px"}})}}class $r{constructor(e,t,r,n,s,i){this.rowCount=r,this.columnCount=n,this._columns=t,this._rows=e,this._headerHeight=s,this._headerWidth=i}_resize(e,t){this.rowCount=e,this.columnCount=t}isAxis(e){let t=(e=e.toRangeRef()).topLeft,r=e.bottomRight;return 0===t.row&&r.row===this.rowCount-1||0===t.col&&r.col===this.columnCount-1}width(e,t){return this._columns.sum(e,t)}height(e,t){return this._rows.sum(e,t)}totalHeight(){return this._rows.total+this._headerHeight}totalWidth(){return this._columns.total+this._headerWidth}index(e,t){return t*this.rowCount+e}cellRef(e){return new c(e%this.rowCount,e/this.rowCount|0)}rowRef(e){return new f(new c(e,0),new c(e,this.columnCount-1))}colRef(e){return new f(new c(0,e),new c(this.rowCount-1,e))}cellRefIndex(e){return this.index(e.row,e.col)}normalize(e){return e instanceof f?new f(this.normalize(e.topLeft),this.normalize(e.bottomRight)).setSheet(e.sheet,e.hasSheet()):e instanceof p?e.map((function(e){return this.normalize(e)}),this):(e instanceof c&&((e=e.clone()).col=Math.max(0,Math.min(this.columnCount-1,e.col)),e.row=Math.max(0,Math.min(this.rowCount-1,e.row))),e)}rectangle(e){let t=this.normalize(e.topLeft),r=this.normalize(e.bottomRight);return new Vr(this.width(0,t.col-1),this.height(0,t.row-1),this.width(t.col,r.col),this.height(t.row,r.row))}pane(e){return new Br(new Ur(this._rows,e.row,e.rowCount,this._headerHeight),new Ur(this._columns,e.column,e.columnCount,this._headerWidth),this)}rangeDimensions(e){return{rows:this._rows.values.iterator(e.topLeft.row,e.bottomRight.row),columns:this._columns.values.iterator(e.topLeft.col,e.bottomRight.col)}}forEach(e,t){let r=this.normalize(e.topLeft),n=this.normalize(e.bottomRight);for(let e=r.col;e<=n.col;e++)for(let s=r.row;s<=n.row;s++)t(new c(s,e))}trim(e,t){let r=this.normalize(e.topLeft),n=this.normalize(e.bottomRight),s=r.row,i=r.col;for(let e=r.col;e<=n.col;e++){let o=this.index(r.row,e),a=this.index(n.row,e),u=t.tree.intersecting(o,a);if(u.length){let t=this.cellRef(u[u.length-1].end);s=Math.max(s,t.row),i=e}}return new f(e.topLeft,new c(Math.min(s,e.bottomRight.row),i))}}class Br{constructor(e,t,r){this.rows=e,this.columns=t,this._grid=r,this.headerHeight=e.headerSize,this.headerWidth=t.headerSize,this.hasRowHeader=t.hasHeader,this.hasColumnHeader=e.hasHeader}refresh(e,t){this.columns.viewSize(e),this.rows.viewSize(t);let r=this.columns.paneSegment(),n=this.rows.paneSegment();this.left=r.offset,this.top=n.offset,this.right=r.offset+r.length,this.bottom=n.offset+n.length,this.style={top:n.offset+"px",left:r.offset+"px",height:n.length+"px",width:r.length+"px"}}view(e,t){let r=this.rows.visible(t),n=this.columns.visible(e);return{rows:r,columns:n,rowOffset:r.offset,columnOffset:n.offset,mergedCellLeft:n.start,mergedCellTop:r.start,ref:new f(new c(r.values.start,n.values.start),new c(r.values.end,n.values.end))}}contains(e){return this.rows.contains(e.topLeft.row,e.bottomRight.row)&&this.columns.contains(e.topLeft.col,e.bottomRight.col)}index(e,t){return this._grid.index(e,t)}boundingRectangle(e){return this._grid.rectangle(e)}cellRefIndex(e){return this._grid.cellRefIndex(e)}scrollBoundaries(e){let t=this.boundingRectangle(e),r={top:Math.max(0,t.top-this.top+(this.hasColumnHeader?0:this.headerHeight)),left:Math.max(0,t.left-this.left+(this.hasRowHeader?0:this.headerWidth)),right:t.right-this.columns._viewSize+this.headerWidth,bottom:t.bottom-this.rows._viewSize+this.headerHeight},n=this.columns.defaultValue/2,s=this.rows.defaultValue/2;return r.scrollTop=r.top-s,r.scrollBottom=r.bottom+s,r.scrollLeft=r.left-n,r.scrollRight=r.right+n,r}}class Ir{constructor(e,t){this._grid=e,this._lists=t}indices(e,t,r,n){let s=Ir.ascendingComparer;return!1===r&&(s=Ir.descendingComparer),t.sortedIndices(this._grid.cellRefIndex(e.topLeft),this._grid.cellRefIndex(e.bottomRight),s,n)}sortBy(e,t,r,n,s){let i=this.indices(e.toColumn(t),r,n,s);for(let t=e.topLeft.col;t<=e.bottomRight.col;t++){let r=this._grid.index(e.topLeft.row,t),n=this._grid.index(e.bottomRight.row,t);for(let e=0;e<this._lists.length;e++)r<this._lists[e].lastRangeStart()&&this._lists[e].sort(r,n,i)}return i}}Ir.ascendingComparer=function(e,t){if(null===e&&null===t)return 0;if(null===e)return 1;if(null===t)return-1;let r=typeof e,n=typeof t;if("number"===r)return"number"===n?e-t:-1;if("string"===r)switch(n){case"number":return 1;case"string":return e.localeCompare(t);default:return-1}if("boolean"===r)switch(n){case"number":case"string":return 1;case"boolean":return e-t;default:return-1}if(e instanceof K)return t instanceof K?0:1;throw new Error("Cannot compare "+e+" and "+t)},Ir.descendingComparer=function(e,t){return null===e&&null===t?0:null===e?1:null===t?-1:Ir.ascendingComparer(t,e)};class Tr{constructor(e){this._sheet=e}forEachSelectedColumn(e){let t=this._sheet;t.batch((function(){t.select().forEachColumnIndex((function(r,n){e(t,r,n)}))}),{layout:!0,recalc:!0})}forEachSelectedRow(e){let t=this._sheet;t.batch((function(){t.select().forEachRowIndex((function(r,n){e(t,r,n)}))}),{layout:!0,recalc:!0})}includesHiddenColumns(e){return this._sheet._grid._columns.includesHidden(e.topLeft.col,e.bottomRight.col)}includesHiddenRows(e){return this._sheet._grid._rows.includesHidden(e.topLeft.row,e.bottomRight.row)}selectionIncludesHiddenColumns(){return this.includesHiddenColumns(this._sheet.select())}selectionIncludesHiddenRows(){return this.includesHiddenRows(this._sheet.select())}deleteSelectedColumns(){let e=[],t=0;return this.forEachSelectedColumn((function(r,n){if(n-=t,r.isHiddenColumn(n))return;t++;let s=[];e.unshift({index:n,formulas:s,width:r.columnWidth(n)}),r._saveModifiedFormulas(s,(function(){r.deleteColumn(n)}))})),e}deleteSelectedRows(){let e=[],t=0;return this.forEachSelectedRow((function(r,n){if(n-=t,r.isHiddenRow(n))return;t++;let s=[];e.unshift({index:n,formulas:s,height:r.rowHeight(n)}),r._saveModifiedFormulas(s,(function(){r.deleteRow(n)}))})),e}hideSelectedColumns(){this.forEachSelectedColumn((function(e,t){e.hideColumn(t)}));let e=this._sheet,t=e.select().toRangeRef(),r=t.topLeft.col,n=t.bottomRight.col,s=null;for(;;){let t=n<e._columns._count,i=r>=0;if(!i&&!t)break;if(t&&!e.isHiddenColumn(n)){s=n;break}if(i&&!e.isHiddenColumn(r)){s=r;break}r--,n++}null!==s&&(t=new f(new c(0,s),new c(e._rows._count-1,s)),e.range(t).select())}hideSelectedRows(){this.forEachSelectedRow((function(e,t){e.hideRow(t)}));let e=this._sheet,t=e.select().toRangeRef(),r=t.topLeft.row,n=t.bottomRight.row,s=null;for(;;){let t=n<e._rows._count,i=r>=0;if(!i&&!t)break;if(t&&!e.isHiddenRow(n)){s=n;break}if(i&&!e.isHiddenRow(r)){s=r;break}r--,n++}null!==s&&(t=new f(new c(s,0),new c(s,e._columns._count-1)),e.range(t).select())}unhideSelectedColumns(){this.forEachSelectedColumn((function(e,t){e.unhideColumn(t)}))}unhideSelectedRows(){this.forEachSelectedRow((function(e,t){e.unhideRow(t)}))}addColumnLeft(){let e,t=this._sheet,r=0;return t.batch((function(){t.select().forEachColumnIndex((function(n){e||(e=n),t.insertColumn(e),++r}))}),{recalc:!0,layout:!0}),{base:e,count:r}}addColumnRight(){let e,t=this._sheet,r=0;return t.batch((function(){t.select().forEachColumnIndex((function(t){e=t+1,++r}));for(let n=0;n<r;++n)t.insertColumn(e)}),{recalc:!0,layout:!0}),{base:e,count:r}}addRowAbove(){let e,t=this._sheet,r=0,n=t.select();return t.batch((function(){n.forEachRowIndex((function(n){e||(e=n),t.insertRow(e),++r}))}),{recalc:!0,layout:!0}),{base:e,count:r}}addRowBelow(){let e,t=this._sheet,r=0;return t.batch((function(){t.select().forEachRowIndex((function(t){e=t+1,++r}));for(let n=0;n<r;++n)t.insertRow(e)}),{recalc:!0,layout:!0}),{base:e,count:r}}}class zr{constructor(e){this._grid=e}rectIsVertical(e,t,r,n){let s=this._grid.rectangle(e.toRangeRef()),i=this._grid.rectangle(t.toRangeRef());return Math.abs(i[n]-s[n])>Math.abs(s[r]-i[r])}autoFillDest(e,t){let r,n,s,i,o,a=e.topLeft,u=e.bottomRight,h=t.row>=a.row,l=t.col>=a.col;if(r=h?l?4:3:l?2:1,4===r)n=a,s=u,o=t.row>s.row||t.col>s.col,o&&(t=new c(Math.max(t.row,s.row),Math.max(t.col,s.col))),i=this.rectIsVertical(s,t,"right","bottom")?new c(t.row,s.col):new c(s.row,t.col);else if(3===r){let e=new c(a.col,u.row);t.row>u.row&&this.rectIsVertical(e,t,"left","bottom")?(n=a,i=new c(t.row,u.col)):(n=u,i=new c(a.row,t.col))}else if(2===r){let e=new c(a.row,u.col);t.col>u.col&&!this.rectIsVertical(e,t,"right","top")?(n=a,i=new c(u.row,t.col)):(n=u,i=new c(t.row,a.col))}else n=u,i=this.rectIsVertical(a,t,"left","top")?new c(t.row,a.col):new c(a.row,t.col);return this._grid.normalize(new f(n,i))}}class Hr{constructor(e,t,r,n){this.rangeGetter=r,this.prevLeft=function(r){var s=n(this.range(r)),i=this.range(t.prevVisible(s.topLeft[e]));return n(i).topLeft[e]},this.nextRight=function(r){var s=n(this.range(r)),i=this.range(t.nextVisible(s.bottomRight[e]));return n(i).bottomRight[e]},this.nextLeft=function(r){var s=n(this.range(r));return t.nextVisible(s.bottomRight[e])},this.prevRight=function(r){var s=n(this.range(r));return t.prevVisible(s.topLeft[e])}}boundary(e,t){this.top=e,this.bottom=t}range(e){return this.rangeGetter(e,this.top,this.bottom)}}class Pr{constructor(e){this._sheet=e,this.autoFillCalculator=new zr(e._grid),this.colEdge=new Hr("col",this._sheet._grid._columns,this.columnRange.bind(this),this.union.bind(this)),this.rowEdge=new Hr("row",this._sheet._grid._rows,this.rowRange.bind(this),this.union.bind(this))}height(e){this._viewPortHeight=e}union(e){return this._sheet.unionWithMerged(e)}columnRange(e,t,r){return this._sheet._ref(t,e,r-t,1)}rowRange(e,t,r){return this._sheet._ref(e,t,1,r-t)}selectionIncludesMergedCells(){return this._sheet.select().contains(this._sheet._mergedCells)}setSelectionValue(e){var t=this._sheet.selection();setTimeout((function(){t.value(e())}))}selectAll(){this._sheet.select(this._sheet._sheetRef)}select(e,t,r){e=this.refForMode(e,t),r&&(e=this._sheet.select().concat(e)),this._sheet.select(e)}refForMode(e,t){var r=this._sheet._grid;switch(t){case"range":e=r.normalize(e);break;case"row":e=r.rowRef(e.row);break;case"column":e=r.colRef(e.col);break;case"sheet":e=this._sheet._sheetRef}return e}startSelection(e,t,r,n,s){if("autofill"===t)this._sheet.startAutoFill();else if(n&&"range"===t){var i=new f(this._sheet.activeCell().first(),e);this._sheet.select(i,!1,!1),this._sheet.startSelection(s)}else this._sheet.startSelection(s),this.select(e,t,r)}completeSelection(){this._sheet.completeSelection()}selectForContextMenu(e,t){var r=this._sheet;r._activeDrawing=null,r.select().contains(this.refForMode(e,t))||this.select(e,t)}selectDrawingForContextMenu(e){var t=this._sheet;t._activeDrawing=e,t.triggerChange({selection:!0})}modifySelection(e){var t,r=this.determineDirection(e),n=this._sheet,s=this._viewPortHeight,i=n._grid._rows,o=n._grid._columns,a=n.currentOriginalSelectionRange(),u=n.select().toRangeRef(),h=n.activeCell(),l=a.topLeft.clone(),p=a.bottomRight.clone(),d=new c(p.row,l.col);switch(this.colEdge.boundary(u.topLeft.row,u.bottomRight.row),this.rowEdge.boundary(u.topLeft.col,u.bottomRight.col),r){case"expand-left":l.col=this.colEdge.prevLeft(l.col),t=l;break;case"shrink-right":l.col=this.colEdge.nextLeft(l.col),t=l;break;case"expand-right":p.col=this.colEdge.nextRight(p.col),t=p;break;case"shrink-left":p.col=this.colEdge.prevRight(p.col),t=p;break;case"expand-up":l.row=this.rowEdge.prevLeft(l.row),t=l;break;case"shrink-down":l.row=this.rowEdge.nextLeft(l.row),t=l;break;case"expand-down":p.row=this.rowEdge.nextRight(p.row),t=p;break;case"shrink-up":p.row=this.rowEdge.prevRight(p.row),t=p;break;case"expand-page-up":l.row=i.prevPage(l.row,s);break;case"shrink-page-up":p.row=i.prevPage(p.row,s);break;case"expand-page-down":p.row=i.nextPage(p.row,s);break;case"shrink-page-down":l.row=i.nextPage(l.row,s);break;case"first-col":l.col=o.firstVisible(),p.col=h.bottomRight.col,t=l;break;case"last-col":p.col=o.lastVisible(),l.col=h.topLeft.col,t=p;break;case"first-row":l.row=i.firstVisible(),p.row=h.bottomRight.row,t=l;break;case"last-row":p.row=i.lastVisible(),l.row=h.topLeft.row,t=p;break;case"last":p.row=i.lastVisible(),p.col=o.lastVisible(),l=h.topLeft,t=p;break;case"first":l.row=i.firstVisible(),l.col=o.firstVisible(),p=h.bottomRight,t=l;break;case"expand-word-right":p.col=o.nextUntil(p.col,Or(n,p,!0)),t=p;break;case"shrink-word-right":l.col=o.nextUntil(d.col,Or(n,d,!0)),t=l;break;case"expand-word-left":l.col=o.prevUntil(d.col,Or(n,d,!0)),t=l;break;case"shrink-word-left":p.col=o.prevUntil(p.col,Or(n,p,!0)),t=p;break;case"expand-word-up":l.row=i.prevUntil(l.row,Or(n,l,!1)),t=l;break;case"shrink-word-up":p.row=i.prevUntil(p.row,Or(n,p,!1)),t=p;break;case"expand-word-down":p.row=i.nextUntil(p.row,Or(n,p,!1)),t=p;break;case"shrink-word-down":l.row=i.nextUntil(l.row,Or(n,l,!1)),t=l}var g=new f(l,p);this.union(g).intersects(h)?(t&&n.focus(t),this.updateCurrentSelectionRange(g)):this.modifySelection(r.replace("shrink","expand"))}moveActiveCell(e){var t=this._sheet,r=t.activeCell(),n=r.topLeft,s=r.bottomRight,i=t.originalActiveCell(),o=t._grid._rows,a=t._grid._columns,u=i.row,h=i.col;switch(e){case"left":h=a.prevVisible(n.col);break;case"up":u=o.prevVisible(n.row);break;case"right":h=a.nextVisible(s.col);break;case"down":u=o.nextVisible(s.row);break;case"first-col":h=a.firstVisible();break;case"last-col":h=a.lastVisible();break;case"first-row":u=o.firstVisible();break;case"last-row":u=o.lastVisible();break;case"last":u=o.lastVisible(),h=a.lastVisible();break;case"first":u=o.firstVisible(),h=a.firstVisible();break;case"next-page":u=o.nextPage(s.row,this._viewPortHeight);break;case"prev-page":u=o.prevPage(s.row,this._viewPortHeight);break;case"word-right":h=a.nextUntil(h,Or(t,s,!0));break;case"word-left":h=a.prevUntil(h,Or(t,s,!0));break;case"word-up":u=o.prevUntil(u,Or(t,s,!1));break;case"word-down":u=o.nextUntil(u,Or(t,s,!1))}t.select(new c(u,h))}navigateInSelection(e){var t,r,n,s=this._sheet,i=s.activeCell().topLeft,o=s.originalActiveCell(),a=s._grid._rows,u=s._grid._columns,h=o.row,l=o.col,f=!1,p=!1,d=i.col,g=i.row;function m(e){t=e.topLeft,r=e.bottomRight}m(s.currentNavigationRange());for(var v=!1,y=!1;!v&&!y;){var w=new c(h,l);switch(s.singleCellSelection()&&(f=t.eq(w)&&s._sheetRef.topLeft.eq(w),p=r.eq(w)&&s._sheetRef.bottomRight.eq(w),f||(f=u.firstVisible()===l&&a.firstVisible()===h),p||(p=u.lastVisible()===l&&a.lastVisible()===h)),e){case"next":p?y=!0:r.eq(w)?(m(s.nextNavigationRange()),h=t.row,l=t.col):((l=u.nextVisible(d))===d||l>r.col)&&(l=t.col,h=(n=a.nextVisible(h))===h||n>r.row?t.row:n);break;case"previous":f?(y=!0,this._sheet._workbook._view.element.querySelector(".k-spreadsheet-name-editor .k-input-inner").focus()):t.eq(w)?(m(s.previousNavigationRange()),h=r.row,l=r.col):((l=u.prevVisible(d))===d||l<t.col)&&(l=r.col,h=(n=a.prevVisible(h))===h||n<t.row?r.row:n);break;case"lower":r.eq(w)?(m(s.nextNavigationRange()),h=t.row,l=t.col):((h=a.nextVisible(g))===g||h>r.row)&&(h=t.row,l=(n=u.nextVisible(l))===l||n>r.col?t.col:n);break;case"upper":t.eq(w)?(m(s.previousNavigationRange()),h=r.row,l=r.col):((h=a.prevVisible(g))===g||h<t.row)&&(h=r.row,l=(n=u.prevVisible(l))===l||n<t.col?r.col:n);break;default:throw new Error("Unknown entry navigation: "+e)}v=!this.shouldSkip(h,l),d=l,g=h}v&&(s.singleCellSelection()?s.select(new c(h,l)):s.activeCell(new c(h,l)))}extendSelection(e,t){var r=this._sheet,n=r._grid;if("autofill"!==t){"range"===t?e=n.normalize(e):"row"===t?e=n.rowRef(e.row).bottomRight:"column"===t&&(e=n.colRef(e.col).bottomRight);var s=r.originalActiveCell().toRangeRef();this.updateCurrentSelectionRange(new f(s.topLeft,e))}else this.resizeAutoFill(e)}shouldSkip(e,t){if(this._sheet.isHiddenRow(e)||this._sheet.isHiddenColumn(t))return!0;var r=new c(e,t),n=!1;return this._sheet.forEachMergedCell((function(e){e.intersects(r)&&!e.collapse().eq(r)&&(n=!0)})),n}resizeAutoFill(e){var t,r,n=this._sheet,s=n.select(),i=n._autoFillOrigin,o=this.autoFillCalculator.autoFillDest(s,e),a=this.punch(s,o);if(!a){var u=n.range(o)._previewFillFrom(n.range(i));u&&(r=u.direction,t=u.hint)}n.updateAutoFill(o,a,t,r)}determineDirection(e){var t=this._sheet.currentSelectionRange(),r=this._sheet.activeCell(),n=r.topLeft.col===t.topLeft.col,s=r.bottomRight.col===t.bottomRight.col,i=r.topLeft.row===t.topLeft.row,o=r.bottomRight.row===t.bottomRight.row;switch(e){case"left":e=s?"expand-left":"shrink-left";break;case"right":e=n?"expand-right":"shrink-right";break;case"up":e=o?"expand-up":"shrink-up";break;case"down":e=i?"expand-down":"shrink-down";break;case"prev-page":e=o?"expand-page-up":"shrink-page-up";break;case"next-page":e=i?"expand-page-down":"shrink-page-down";break;case"word-left":e=s?"expand-word-left":"shrink-word-left";break;case"word-right":e=n?"expand-word-right":"shrink-word-right";break;case"word-up":e=o?"expand-word-up":"shrink-word-up";break;case"word-down":e=i?"expand-word-down":"shrink-word-down"}return e}updateCurrentSelectionRange(e){var t=this._sheet;t.select(t.originalSelect().replaceAt(t.selectionRangeIndex(),e),!1)}punch(e,t){var r;if(t.topLeft.eq(e.topLeft))if(t.bottomRight.row<e.bottomRight.row){var n=this.rowEdge.nextRight(t.bottomRight.row);r=new f(new c(n,e.topLeft.col),e.bottomRight)}else if(t.bottomRight.col<e.bottomRight.col){var s=this.colEdge.nextRight(t.bottomRight.col);r=new f(new c(e.topLeft.row,s),e.bottomRight)}return r}}function Or(e,t,r){var n=e.range(t).value();return function(s,i,o){if(o)return!0;var a=(r?e.range(t.row,s):e.range(s,t.col)).value();return null===n?null!==a&&s:i||null!==a?null===a:(n=null,!1)}}function jr(e){return null==e?null:te.runtime.serialToDate(e)}var Wr=function(e){return e};class qr{constructor(e){this.options=Object.assign({columns:[]},this.options,Object.keys(e).reduce(((t,r)=>(void 0!==e[r]&&(t[r]=e[r]),t)),{})),this.columns=this._normalizeColumns(this.options.columns),this._sheet(),this._dataSource(),this._header(),this._boundRowsCount=0,this.dataSource.fetch()}_sheet(){this.sheet=this.options.sheet,this._sheetChangeHandler=this._sheetChange.bind(this),this._sheetDeleteRowHandler=this._sheetDeleteRow.bind(this),this._sheetInsertRowHandler=this._sheetInsertRow.bind(this),this.sheet.bind("change",this._sheetChangeHandler).bind("afterDeleteRow",this._sheetDeleteRowHandler).bind("afterInsertRow",this._sheetInsertRowHandler)}_sheetInsertRow(e){void 0!==e.index&&this.dataSource.insert(Math.max(e.index-1,0),{})}_sheetDeleteRow(e){if(void 0!==e.index){var t=this.dataSource,r=t.view()[e.index-1];r&&t.remove(r)}}_header(){this.sheet.batch(function(){this.columns.forEach(function(e,t){this.sheet.range(0,t).value(e.title)}.bind(this))}.bind(this))}_sheetChange(e){if(!e.insertRow&&!e.deleteRow&&e.recalc&&e.ref&&e.isValue){var t,r,n,s,i,o=this.dataSource,a=o.view(),u=this.columns,h=[],l=this.sheet,c=function(e){for(var t,n=0,i=(e=e.toRangeRef()).topLeft.row;i<=e.bottomRight.row;i++){(t=a[i-1])||(t=o.insert(i-1,{}),a=o.view());for(var l=0,c=e.topLeft.col;c<=e.bottomRight.col&&c<u.length;c++){var f=h[s][n][l++];t.set(u[c].field,r[c](f))}n++}};for(o.reader.model&&(t=o.reader.model.fields),!u.length&&a.length&&(u=Object.keys(a[0].toJSON())),r=u.map((function(e){var r=e.field;return r&&t&&t[r]&&"date"===t[r].type?jr:Wr})),this._skipRebind=!0,(n=l._grid.normalize(e.ref))instanceof p||(n=new p([n])),(i=n.refs).forEach((function(e){h.push(l.range(e).values())})),s=0;s<i.length;s++)i[s].forEach(c);this._boundRowsCount=o.view().length,this._skipRebind=!1}}_normalizeColumns(e){return e.map((function(e){var t=e.field||e;return{field:t,title:e.title||t}}))}_dataSource(){var e=this.options.dataSource;e=Array.isArray(e)?{data:e}:e,this.dataSource&&this._changeHandler?this.dataSource.unbind("change",this._changeHandler).unbind("progress",this._progressHandler).unbind("error",this._errorHandler):(this._changeHandler=this._change.bind(this),this._progressHandler=this._requestStart.bind(this),this._errorHandler=this._error.bind(this)),this.dataSource=this.options.sheet.createSheetDataSource?.(e).bind("change",this._changeHandler).bind("progress",this._progressHandler).bind("error",this._errorHandler)}_error(){this._progress(!1)}_requestStart(){this._progress(!0)}_progress(e){this.sheet.trigger("progress",{toggle:e})}_change(){if(!this._skipRebind&&!this.sheet.trigger("dataBinding")){var e=this.dataSource.view(),t=this.columns;!t.length&&e.length&&(this.columns=t=this._normalizeColumns(Object.keys(e[0].toJSON())),this._header());var r=t.map((function(e){return z(e.field)}));this.sheet.batch(function(){for(var t=Math.max(e.length,this._boundRowsCount,this.sheet._grid.rowCount-1),n=0;n<t;n++)for(var s=0;s<r.length;s++){var i=e[n]?r[s](e[n]):null;this.sheet.range(n+1,s).value(i)}}.bind(this)),this._boundRowsCount=e.length,this._progress(!1),this.sheet.trigger("dataBound")}}destroy(){this.dataSource.unbind("change",this._changeHandler).unbind("progress",this._progressHandler).unbind("error",this._errorHandler),this.sheet.unbind("change",this._sheetChangeHandler).unbind("deleteRow",this._sheetDeleteRowHandler).unbind("insertRow",this._sheetInsertRowHandler)}}const Yr=function(){function e(){return r.g(new Date)}return{dayOfWeek:r.e,getDate:r.g,isToday:function(t){return r.g(t).getTime()===e().getTime()},addDays:r.d,today:e,firstDayOfMonth:r.f}}(),Jr={or:{concat:(e,t)=>r=>e(r)||t(r),identity:()=>!1},and:{concat:(e,t)=>r=>e(r)&&t(r),identity:()=>!0}},Xr={contains:(e,t)=>(e||"").indexOf(t)>=0,doesnotcontain:(e,t)=>-1===(e||"").indexOf(t),doesnotendwith:(e,t)=>(e||"").indexOf(t,(e||"").length-(t||"").length)<0,doesnotstartwith:(e,t)=>-1===(e||"").lastIndexOf(t,0),endswith:(e,t)=>(e||"").indexOf(t,(e||"").length-(t||"").length)>=0,eq:(e,t)=>e===t,gt:(e,t)=>e>t,gte:(e,t)=>e>=t,isempty:e=>""===e,isnotempty:e=>""!==e,isnotnull:e=>q(e),isnull:e=>!q(e),lt:(e,t)=>e<t,lte:(e,t)=>e<=t,neq:(e,t)=>e!=t,startswith:(e,t)=>0===(e||"").lastIndexOf(t,0)},Gr=/^\/Date\((.*?)\)\/$/,Kr=({field:e,ignoreCase:t,value:r,operator:n,accentFoldingFiltering:s})=>{e=q(e)?e:e=>e,t=!q(t)||t;const i=Qr(X(e)?e:z(e,!0),r,t,s);r=((e,t,r)=>{if(null!=e&&J(e)){const n=Gr.exec(e);if(n)return new Date(+n[1]).getTime();if(t)return r?e.toLocaleLowerCase(r):e.toLowerCase()}else if(null!=e&&Y(e))return e.getTime();return e})(r,t,s);const o=X(n)?n:Xr[n];return e=>o(i(e),r,t)},Qr=(e,t,r,n)=>{if(!q(t))return e;let s=e;if(J(t)){const i=Gr.exec(t);i?t=new Date(+i[1]):s=t=>{const s=e(t);return"string"==typeof s&&r?n?s.toLocaleLowerCase(n):s.toLowerCase():(e=>!isNaN(e-parseFloat(e)))(s)?s+"":s}}return Y(t)?e=>{const t=s(e);return Y(t)?t.getTime():t}:s},Zr=function(e){const t=e.accentFoldingFiltering,r=Jr[e.logic||"and"];return e.filters.filter(q).map((e=>{const r=q(t)?H({},e,{accentFoldingFiltering:t}):e;return q(e.filters)?Zr(r):Kr(r)})).reduce(r.concat,r.identity)};let en={};const tn=te.runtime.dateToSerial,rn=te.runtime.serialToDate;class nn{prepare(){}value(e){return e.value}matches(){throw new Error("The 'matches' method is not implemented.")}toJSON(){throw new Error("The 'toJSON' method is not implemented.")}}nn.create=function(e){var t=e.filter;if(!t)throw new Error("Filter type not specified.");var r=en[t.charAt(0).toUpperCase()+t.substring(1)+"Filter"];if(!r)throw new Error("Filter type not recognized.");return new r(e)};class sn extends nn{constructor(e){super(e),this._values=[],this._dates=[],this._blanks=!1,void 0!==e.values&&(this._values=e.values),void 0!==e.blanks&&(this._blanks=e.blanks),void 0!==e.dates&&(this._dates=e.dates)}value(e){var t=e.value;this._dates.length>0&&e.format&&"number"==typeof t&&("date"===Je.type(t,e.format)&&(t=rn(t)));return t}matches(e){return null==e?this._blanks:e instanceof Date?this._dates.some((function(t){return!(t.year!==e.getFullYear()||void 0!==t.month&&t.month!==e.getMonth()||void 0!==t.day&&t.day!==e.getDate()||void 0!==t.hours&&t.hours!==e.getHours()||void 0!==t.minutes&&t.minutes!==e.getMinutes()||void 0!==t.seconds&&t.seconds!==e.getSeconds())})):this._values.indexOf(e)>=0}toJSON(){return{filter:"value",blanks:this._blanks,values:this._values.slice(0)}}}class on extends nn{constructor(e){if(super(e),this._logic="and",void 0!==e.logic&&(this._logic=e.logic),void 0===e.criteria)throw new Error("Must specify criteria.");this._criteria=e.criteria,this._matches=Zr({logic:this._logic,filters:this._criteria,accentFoldingFiltering:ee().name})}matches(e){return null!==e&&this._matches(e)}value(e){var t=e.value,r=this._criteria[0].value,n=r instanceof Date?"date":typeof r,s=typeof t;return e.format&&(s=Je.type(t,e.format)),s!=n?"string"==n&&(e.format&&(t=Je.text(t,e.format)),t+=""):"date"==s&&(t=rn(t)),t}toJSON(){return{filter:"custom",logic:this._logic,criteria:this._criteria}}}class an extends nn{constructor(e){super(e),this._type=e.type,this._value=e.value,this._values=[]}prepare(e){var t=e.map(this.value).sort().filter((function(e,t,r){return 0===t||e!==r[t-1]}));"topNumber"===this._type||"topPercent"==this._type?t.sort((function(e,t){return t-e})):t.sort((function(e,t){return e-t}));var r=this._value;"topPercent"!==this._type&&"bottomPercent"!==this._type||(r=t.length*r/100|0),this._values=t.slice(0,r)}matches(e){return this._values.indexOf(e)>=0}toJSON(){return{filter:"top",type:this._type,value:this._value}}}class un extends nn{constructor(e){if(super(e),this._type=e.type,this._predicate=this[e.type],"function"!=typeof this._predicate)throw new Error("DynamicFilter type '"+e.type+"' not recognized.")}value(e){var t=e.value;e.format&&("date"===Je.type(t,e.format)&&(t=rn(t)));return t}prepare(e){for(var t=0,r=0,n=0;n<e.length;n++){var s=this.value(e[n]);"number"==typeof s&&(t+=s,r++)}this._average=r>0?t/r:0}matches(e){return this._predicate(e)}aboveAverage(e){return e instanceof Date&&(e=tn(e)),"number"==typeof e&&e>this._average}belowAverage(e){return e instanceof Date&&(e=tn(e)),"number"==typeof e&&e<this._average}tomorrow(e){if(e instanceof Date){var t=Yr.addDays(Yr.today(),1);return Yr.getDate(e).getTime()===t.getTime()}return!1}today(e){return e instanceof Date&&Yr.isToday(e)}yesterday(e){if(e instanceof Date){var t=Yr.addDays(Yr.today(),-1);return Yr.getDate(e).getTime()===t.getTime()}return!1}nextWeek(e){return pn(Yr.addDays(Yr.today(),7),e)}thisWeek(e){return pn(Yr.today(),e)}lastWeek(e){return pn(Yr.addDays(Yr.today(),-7),e)}nextMonth(e){return fn(e,1)}thisMonth(e){return fn(e,0)}lastMonth(e){return fn(e,-1)}nextQuarter(e){if(e instanceof Date){var t=Yr.today(),r=ln(e)-ln(t);return 1===r&&t.getFullYear()===e.getFullYear()||-3==r&&t.getFullYear()+1===e.getFullYear()}return!1}thisQuarter(e){if(e instanceof Date){var t=Yr.today();return 0===ln(e)-ln(t)&&t.getFullYear()===e.getFullYear()}return!1}lastQuarter(e){if(e instanceof Date){var t=Yr.today(),r=ln(t)-ln(e);return 1===r&&t.getFullYear()===e.getFullYear()||-3==r&&t.getFullYear()-1===e.getFullYear()}return!1}nextYear(e){return cn(e,1)}thisYear(e){return cn(e,0)}lastYear(e){return cn(e,-1)}yearToDate(e){if(e instanceof Date){var t=Yr.today();return e.getFullYear()===t.getFullYear()&&e<=t}return!1}toJSON(){return{filter:"dynamic",type:this._type}}}en={Filter:nn,ValueFilter:sn,CustomFilter:on,TopFilter:an},[1,2,3,4].forEach((function(e){un.prototype["quarter"+e]=function(t){return t instanceof Date&&ln(t)===e}}));const hn=()=>{ee().calendar.months.format.wide.forEach((function(e,t){un.prototype[e.toLowerCase()]=function(e){return e instanceof Date&&e.getMonth()===t}}))};function ln(e){var t=e.getMonth()+1;return t>=1&&t<=3?1:t>=4&&t<=6?2:t>=7&&t<=9?3:4}function cn(e,t){if(e instanceof Date){var r=Yr.today();return r.setFullYear(r.getFullYear()+t),r.getFullYear()===e.getFullYear()}return!1}function fn(e,t){if(e instanceof Date){var r=Yr.firstDayOfMonth(Yr.today());return r.setMonth(r.getMonth()+t,1),r.getTime()===Yr.firstDayOfMonth(e).getTime()}return!1}function pn(e,t){if(t instanceof Date){var r=Yr.dayOfWeek(Yr.getDate(e),1),n=Yr.dayOfWeek(Yr.getDate(t),1);return r.getTime()===n.getTime()}return!1}var dn;class gn{constructor(e){this._sheet=e,this.selection=d.toRangeRef(),this.originalSelection=d.toRangeRef(),this._activeCell=d.toRangeRef(),this.originalActiveCell=d}currentSelectionRange(){return this.selection.rangeAt(this.selectionRangeIndex).toRangeRef()}currentOriginalNavigationRange(){return this.originalSelection.rangeAt(this.selectionRangeIndex).toRangeRef()}currentNavigationRange(){return this.singleCellSelection()?this._sheet._sheetRef:this.selection.rangeAt(this.selectionRangeIndex).toRangeRef()}nextNavigationRange(){return this.singleCellSelection()||(this.selectionRangeIndex=this.selection.nextRangeIndex(this.selectionRangeIndex)),this.currentNavigationRange()}previousNavigationRange(){return this.singleCellSelection()||(this.selectionRangeIndex=this.selection.previousRangeIndex(this.selectionRangeIndex)),this.currentNavigationRange()}activeCell(e){return e&&(this.originalActiveCell=e.first(),this._activeCell=this._sheet.unionWithMerged(e.toRangeRef()),this._sheet.focus(e),this._sheet.triggerChange({activeCell:!0,selection:!0})),this._activeCell}select(e,t,r,n){if(e){if(e.eq(this.originalSelection))return;if(this._sheet.triggerSelect(new fr(e,this._sheet)),this.originalSelection=e,this.selection=t,!1!==r){if(e.isCell())this._sheet.forEachMergedCell(e,(function(t){e=t.topLeft})),this.activeCell(e);else{if(e=this.selection.lastRange(),n&&n._sheet===this._sheet&&n.panes[0]){var s,i,o,a,u,l,p=n.panes;for(s=0;s<p.length&&(!(i=p[s])._currentView||(o=i._currentView.rows.values,a=i._currentView.columns.values,u=new f(new c(o.start,a.start),new c(o.end,a.end)),(l=e.intersect(u))===h));s++);l&&l!==h&&(e=l)}this.activeCell(e.first())}this.selectionRangeIndex=this.selection.size()-1}else this._sheet.triggerChange({selection:!0})}return this.selection}singleCellSelection(){return this._activeCell.eq(this.selection)}}let mn={};class vn extends kr{constructor(){super(),this.events=["changing","commandRequest","afterInsertRow","afterDeleteRow","insertRow","insertColumn","deleteRow","deleteColumn","hideRow","hideColumn","unhideRow","unhideColumn","select","dataBinding","dataBound","progress"],this.createSheetDataSource=Array.from(arguments).pop(),this._reinit.apply(this,arguments)}activeCellCustomEditor(){let e=this.activeCell().first();if(this.range(e).enable()){let t,r=this.validation(e),n=this._properties.get("editor",this._grid.cellRefIndex(e));return null!=n?t=mn[n]:r&&r.showButton&&(n="_validation_"+r.dataType,t=mn[n]),"function"==typeof t&&(t=mn[n]=t()),t}}_reinit(e,t,r,n,s,i,o){o=o||{},this._defaultCellStyle={background:o.background,color:o.color,fontFamily:o.fontFamily,fontSize:o.fontSize,italic:o.italic,bold:o.bold,underline:o.underline,wrap:o.wrap,verticalAlign:o.verticalAlign,textAlign:o.textAlign},this._rows=new Dr(e,r),this._columns=new Dr(t,n),this._filteredRows=new Qt(0,e-1,!1),this._mergedCells=[],this._frozenRows=0,this._frozenColumns=0,this._suspendChanges=!1,this._filter=null,this._showGridLines=!0,this._gridLinesColor=null,this._grid=new $r(this._rows,this._columns,e,t,s,i),this._sheetRef=this._grid.normalize(g),this._properties=new sr(e,t,this._defaultCellStyle),this._sorter=new Ir(this._grid,this._properties.sortable()),this._viewSelection=new gn(this),this._editSelection=new gn(this),this._formulaSelections=[],this._drawings=[]}resize(e,t){e=Math.max(e,1),t=Math.max(t,1);var r=this._rows._count,n=this._columns._count;e<r&&this.range(e,0,r-e,n).clear(),t<n&&this.range(0,t,r,n-t).clear(),this._rows._resize(e),this._columns._resize(t),this._grid._resize(e,t),this._properties._resize(e,t),this._sheetRef=this._grid.normalize(g),e>r&&(this.range(r,0,e-r,t).clear(),this._filteredRows.value(r,e-1,!1)),t>n&&this.range(0,n,e,t-n).clear(),this.triggerChange({layout:!0})}_resizeAddRow(e){this.resize(this._rows._count+(e||1),this._columns._count)}_resizeAddColumn(e){this.resize(this._rows._count,this._columns._count+(e||1))}_resizeDeleteRow(e){this._resizeAddRow(-(e||1))}_resizeDeleteColumn(e){this._resizeAddColumn(-(e||1))}_resizeForJSON(e){for(var t=e.length,r=0,n=0;n<e.length;++n){var s=e[n];if(null!=s.index&&(t=Math.max(t,s.index+1)),s.cells){r=Math.max(r,s.cells.length);for(var i=0;i<s.cells.length;++i){var o=s.cells[i];null!=o.index&&(r=Math.max(r,o.index+1))}}}this.resize(Math.max(t,this._rows._count),Math.max(r,this._columns._count))}_selectionState(){return this._inEdit?this._editSelection:this._viewSelection}navigator(){return this._navigator||(this._navigator=new Pr(this)),this._navigator}axisManager(){return this._axisManager||(this._axisManager=new Tr(this)),this._axisManager}_name(e){return e?(this._sheetName=e,this):this._sheetName}name(){return this._name()}_state(e){return e?(this._sheetState=e,this):this._sheetState||"visible"}state(){return this._state()}_property(e,t,r){return void 0===t?e():(e(t),this.triggerChange(r))}_field(e,t,r){return void 0===t?this[e]:(this[e]=t,this.triggerChange(r))}suspendChanges(e){return void 0===e?this._suspendChanges:(this._suspendChanges=e,this)}triggerChange(e){return this._suspendChanges?e&&e.isValue&&(this._valueChanged=!0):this.trigger("change",e),this}triggerSelect(e){this.trigger("select",{range:e})}setDataSource(e,t){this.dataSourceBinder&&this.dataSourceBinder.destroy(),this.dataSourceBinder=new qr({dataSource:e,sheet:this,columns:t,createSheetDataSource:this.createSheetDataSource}),this.dataSource=this.dataSourceBinder.dataSource}hideColumn(e){if(!this.trigger("hideColumn",{index:e}))return this._property(this._columns.hide.bind(this._columns),e,{layout:!0})}unhideColumn(e){if(!this.trigger("unhideColumn",{index:e}))return this._property(this._columns.unhide.bind(this._columns),e,{layout:!0})}isHiddenColumn(e){return this._grid._columns.hidden(e)}_copyRange(e,t){var r=this._grid,n=r.rowCount,s=r.normalize(e.topLeft),i=r.normalize(e.bottomRight),o=s.col*n+s.row,a=i.col*n+i.row,u=t.col*n+t.row;this._properties.copy(o,a,u)}_saveModifiedFormulas(e,t){var r=dn;dn=e;var n=t();return dn=r,n}_restoreModifiedFormulas(e){var t=this._workbook;e.forEach((function(e){var r,n=t.sheetByName(e.sheet);e instanceof te.runtime.Formula&&(r=n._grid.cellRefIndex(e),n._properties.set("formula",r,r,e)),e instanceof hr.Validation&&(r=n._grid.cellRefIndex(e),n._properties.set("validation",r,r,e))}))}_adjustReferences(e,t,r,n){if(this._mergedCells=n.reduce((function(n,s){return(s=s.adjust(null,null,null,null,"row"===e,t,r))instanceof f&&n.push(s),n}),[]),this._workbook){var s=this._name();this._workbook._sheets.forEach((function(n){n._forFormulas((function(n){var i=n.adjust(s,e,t,r);i&&dn&&dn.push(i)})),n._forValidations((function(n){var i=n.adjust(s,e,t,r);i&&dn&&dn.push(i)}))})),this._workbook.adjustNames(s,"row"===e,t,r)}var i=this.select();(i=i.adjust(null,null,null,null,"row"===e,t,r))!==h&&this.select(i),("col"===e?this._columns:this._rows).adjust(t,r),"row"===e&&(r<0?this._filteredRows.copy(t-r,this._rows._count-1,t):(this._filteredRows.copy(t,this._rows._count,t+r),this._filteredRows.value(t,t+r-1,!1))),this._drawings.forEach((function(n){n.topLeftCell&&(n.topLeftCell=n.topLeftCell.adjust(null,null,null,null,"row"===e,t,r))}))}_forFormulas(e){var t=this._properties.get("formula").values(),r=t.length;t.forEach((function(t,n){e.call(this,t.value,n,r)}),this)}_forValidations(e){this._properties.get("validation").values().forEach((function(t){e.call(this,t.value)}),this)}insertRow(e,t){if(!this.trigger("insertRow",{index:e}))return this.batch((function(){this._resizeAddRow();var t=this._grid,r=t.columnCount,n=t.rowCount;if(e+1!==n){var s=this.frozenRows();e<s&&this.frozenRows(s+1);for(var i=this._mergedCells.slice(),o=0;o<r;o++){var a=new f(new c(e,o),new c(e,o)),u=t.normalize(a.topLeft),h=t.normalize(a.bottomRight),l=new f(new c(u.row,u.col),new c(n-2,h.col));this._copyRange(l,new c(u.row+1,u.col)),new fr(a,this).clear({clearAll:!0,keepBorders:!0})}this._adjustReferences("row",e,1,i)}}),{recalc:!0,layout:!0,insertRow:{index:e},ref:new f(new c(e,0),new c(1/0,1/0))}),t||this.trigger("afterInsertRow",{index:e}),this}isEnabledRow(e){var t=new f(new c(e,0),new c(e,this._grid.columnCount));return new fr(t,this).enable()}deleteRow(e,t){return this.isEnabledRow(e)?this.trigger("deleteRow",{index:e})?void 0:(this.batch((function(){var t=this._grid,r=t.columnCount,n=this.frozenRows();e<n&&this.frozenRows(n-1);for(var s=this._mergedCells.slice(),i=0;i<r;i++){var o=new f(new c(e,i),new c(e,i));new fr(o,this).clear({clearAll:!0,keepBorders:!0});var a=t.normalize(o.topLeft),u=t.normalize(o.bottomRight),h=new f(new c(a.row+1,a.col),new c(1/0,u.col));this._copyRange(h,a);var l=t.normalize(h.bottomRight);new fr(new f(l,l),this).clear()}this._adjustReferences("row",e,-1,s),this._resizeDeleteRow()}),{recalc:!0,layout:!0,deleteRow:{index:e},ref:new f(new c(e,0),new c(1/0,1/0))}),t||this.trigger("afterDeleteRow",{index:e}),this):this}insertColumn(e){if(!this.trigger("insertColumn",{index:e}))return this.batch((function(){this._resizeAddColumn();var t=this._grid,r=t.columnCount;if(e+1!==r){var n=this.frozenColumns();e<n&&this.frozenColumns(n+1);for(var s=this._mergedCells.slice(),i=r;i>=e;i--){var o=new f(new c(0,i),new c(1/0,i));if(new fr(o,this).clear({clearAll:!0,keepBorders:!0}),i===e)break;var a=t.normalize(o.topLeft),u=t.normalize(o.bottomRight),h=new f(new c(a.row,a.col-1),new c(u.row,u.col-1));this._copyRange(h,a)}this._adjustReferences("col",e,1,s)}}),{recalc:!0,layout:!0,insertColumn:{index:e},ref:new f(new c(0,e),new c(1/0,1/0))}),this}isEnabledColumn(e){var t=new f(new c(0,e),new c(1/0,e));return new fr(t,this).enable()}deleteColumn(e){return this.isEnabledColumn(e)?this.trigger("deleteColumn",{index:e})?void 0:(this.batch((function(){var t=this._grid,r=t.columnCount,n=this.frozenColumns();e<n&&this.frozenColumns(n-1);for(var s=this._mergedCells.slice(),i=e;i<r;i++){var o=new f(new c(0,i),new c(1/0,i));if(new fr(o,this).clear({clearAll:!0,keepBorders:!0}),i===r-1)break;var a=t.normalize(o.topLeft),u=t.normalize(o.bottomRight),h=new f(new c(a.row,a.col+1),new c(u.row,u.col+1));this._copyRange(h,a)}this._adjustReferences("col",e,-1,s),this._resizeDeleteColumn()}),{recalc:!0,layout:!0,deleteColumn:{index:e},ref:new f(new c(0,e),new c(1/0,1/0))}),this):this}_filterRow(e){this._rows.hide(e),this._filteredRows.value(e,e,!0),this.triggerChange({layout:!0})}hideRow(e){if(!this.trigger("hideRow",{index:e}))return this._property(this._rows.hide.bind(this._rows),e,{layout:!0})}unhideRow(e){if(!this.trigger("unhideRow",{index:e}))return this._property(this._rows.unhide.bind(this._rows),e,{layout:!0})}isHiddenRow(e){return this._grid._rows.hidden(e)}isFilteredRow(e){return this._filteredRows.value(e)}columnWidth(e,t){return this._property(this._columns.value.bind(this._columns,e,e),t,{layout:!0})}rowHeight(e,t){return this._property(this._rows.value.bind(this._rows,e,e),t,{layout:!0})}frozenRows(e){return this._field("_frozenRows",e,{layout:!0})}frozenColumns(e){return this._field("_frozenColumns",e,{layout:!0})}showGridLines(e){return this._field("_showGridLines",e,{layout:!0})}gridLinesColor(e){return this._field("_gridLinesColor",e,{layout:!0})}_ref(e,t,r,n){var s=null;return e instanceof u?e:e instanceof fr?e._ref.toRangeRef():("string"==typeof e?s=te.parseReference(e):(r||(r=1),n||(n=1),s=new f(new c(e,t),new c(e+r-1,t+n-1))),s)}range(e,t,r,n){return new fr(this._ref(e,t,r,n),this)}_getMergedCells(e){var t=this._grid,r={},n={},s=!1;return this.forEachMergedCell(e,(function(i){var o=i.topLeft;t.forEach(i,(function(t){o.eq(t)?(r[t.print()]=i,s=!0):e.contains(t)&&(n[t.print()]=o,s=!0)}))})),{primary:r,secondary:n,hasMerged:s}}forEachMergedCell(e,t){var r=!1;void 0===t&&(t=e,r=!0),this._mergedCells.forEach((function(n){(r||n.intersects(e))&&t(n)}))}forEachFilterHeader(e,t){var r=!1;if(void 0===t&&(t=e,r=!0),this._filter){var n=[];this._filter.ref.forEachColumn((function(t){(r||t.intersects(e))&&n.push(t.topLeft)})),this._mergedCells.forEach((function(e){n=n.map((function(t){return e.intersects(t)?e:t}))})),n.reduce((function(e,t){return e.indexOf(t)<0&&e.push(t),e}),[]).forEach(t)}}forEach(e,t){var r=this;function n(e){e instanceof f||(e=e.toRangeRef());var n,s,i=r._grid.normalize(e.topLeft),o=r._grid.normalize(e.bottomRight);function a(e){t(s++,n,e)}for(n=i.col;n<=o.col;n++){s=i.row;var u=r._grid.index(s,n),h=r._grid.index(o.row,n);r._properties.forEach(u,h,a)}}e instanceof f||(e=r._ref(e)),e instanceof p?e.forEach(n):n(e)}startResizing(e){this._initialPosition=e,this._resizeInProgress=!0}startAutoFill(){this._autoFillInProgress=!0;var e=this.select();this._autoFillOrigin=e,this._autoFillDest=e,this.triggerChange({selection:!0})}updateAutoFill(e,t,r,n){this._autoFillDest=e,this._autoFillPunch=t,this._autoFillHint=r,this._autoFillDirection=n,this.triggerChange({selection:!0})}autoFillRef(){return this._autoFillDest}autoFillPunch(){return this._autoFillPunch}autoFillInProgress(){return this._autoFillInProgress}resizingInProgress(){return this._resizeInProgress}draggingInProgress(){return this._draggingInProgress}completeResizing(){if(this._resizeInProgress){this._resizeInProgress=!1;var e=this.resizeHintPosition();if(this._initialPosition&&e){var t=this.resizeHandlePosition();t.col!==-1/0?this.trigger("commandRequest",{command:"ColumnWidthCommand",options:{target:t.col,value:this.columnWidth(t.col)-(this._initialPosition.x-e.x)}}):this.trigger("commandRequest",{command:"RowHeightCommand",options:{target:t.row,value:this.rowHeight(t.row)-(this._initialPosition.y-e.y)}})}else this.trigger("change",{resize:!0})}}_visualRange(e){for(var t=this._mergedCells,r=t.length;--r>=0;)if(t[r].intersects(e))return this.range(t[r]);return this.range(e)}_renderComment(e){var t=null;if(e){var r=this._visualRange(e);t=r.comment(),e=r._ref.toRangeRef().topLeft}t?this._commentRef&&e.eq(this._commentRef)||(this._commentRef=e,this.trigger("change",{comment:!0})):this._commentRef&&(this._commentRef=null,this.trigger("change",{comment:!0}))}resizeHandlePosition(){return this._resizeHandlePosition}resizeHintPosition(e){return void 0!==e&&(this._resizeHintPosition=e,this.trigger("change",{resize:!0})),this._resizeHintPosition}removeResizeHandle(){this._resizeHandlePosition&&(this._resizeHintPosition=void 0,this._resizeHandlePosition=void 0,this._initialPosition=void 0,this.trigger("change",{resize:!0}))}positionResizeHandle(e){this._resizeHandlePosition=e,this.trigger("change",{resize:!0})}startDragging(e){this._draggingInProgress=e}completeDragging(){var e=this._draggingInProgress;if(e){this._draggingInProgress=null;var t=e.drawing;if(t.eq(e.copy))return;if(t.topLeftCell){var r=this.drawingBoundingBox(t),n=this._rows.indexVisible(r.top),s=this._columns.indexVisible(r.left),i=new c(n,s),o=this.refBoundingBox(i);t.offsetX=r.left-o.left,t.offsetY=r.top-o.top,t.topLeftCell=i,this.triggerChange({dragging:!0})}this.trigger("commandRequest",{command:"DrawingUpdateCommand",options:{sheet:this,drawing:t,previous:e.copy}})}}startSelection(e){this.frozenRows()||this.frozenColumns()?this._currentView=null:e&&e._sheet===this&&(this._currentView=e),this._selectionInProgress=!0}completeSelection(){if(this._selectionInProgress&&(this._selectionInProgress=!1,this._resizeHintPosition=void 0,this.trigger("change",{selection:!0})),this._autoFillInProgress){this._autoFillInProgress=!1;var e=this._autoFillDest,t=this._autoFillOrigin;this._autoFillPunch?this.trigger("commandRequest",{command:"ClearContentCommand",options:{operatingRange:this.range(this._autoFillPunch)}}):e.eq(t)?this.triggerChange({selection:!0}):this.trigger("commandRequest",{command:"AutoFillCommand",options:{operatingRange:this.range(e),origin:this.range(t)}}),this._autoFillDest=null,this._autoFillPunch=null,this._autoFillOrigin=null,this.select(e)}}selectionInProgress(){return this._selectionInProgress}select(e,t){var r,n=this._selectionState();return e&&(e=this._ref(e),e=this._grid.normalize(e),r=this._grid.isAxis(e)?e:this.unionWithMerged(e)),n.select(e,r,t,this._currentView)}originalSelect(){return this._selectionState().originalSelection}currentSelectionRange(){return this._selectionState().currentSelectionRange()}currentOriginalSelectionRange(){return this._selectionState().currentOriginalNavigationRange()}currentNavigationRange(){return this._selectionState().currentNavigationRange()}nextNavigationRange(){return this._selectionState().nextNavigationRange()}previousNavigationRange(){return this._selectionState().previousNavigationRange()}selectionRangeIndex(){return this._selectionState().selectionRangeIndex}activeCell(e){return this._selectionState().activeCell(e)}originalActiveCell(){return this._selectionState().originalActiveCell}singleCellSelection(){return this._selectionState().singleCellSelection()}unionWithMerged(e){var t=this._mergedCells;return e.map((function(e){return e.toRangeRef().union(t)}))}trim(e){var t=[],r=this._grid;return this._properties.forEachProperty((function(n){t.push(r.trim(e,n.list))})),this.unionWithMerged(e.topLeft.toRangeRef().union(t))}focus(e){if(!e){var t=this._focus;return this._focus=null,t}this._focus=e.toRangeRef()}activeCellSelection(){return new fr(this._grid.normalize(this.activeCell()),this)}selection(){return new fr(this._grid.normalize(this._selectionState().selection),this)}selectedHeaders(){var e=this.select(),t={},r={},n=!1,s=!1,i=this._grid.rowCount-1,o=this._grid.columnCount-1;return e.forEach((function(e){var a,u="partial",h="partial",l=(e=e.toRangeRef()).bottomRight,c=e.topLeft,f=c.col<=0&&l.col>=o,p=c.row<=0&&l.row>=i;if(p&&(s=!0,h="full"),f&&(n=!0,u="full"),!p)for(a=c.row;a<=l.row;a++)"full"!==t[a]&&(t[a]=u);if(!f)for(a=c.col;a<=l.col;a++)"full"!==r[a]&&(r[a]=h)})),{rows:t,cols:r,allRows:s,allCols:n,all:s&&n}}isInEditMode(e){if(void 0===e)return this._inEdit;this._inEdit=e,e&&(this._editSelection.selection=this._viewSelection.selection.clone(),this._editSelection.originalSelection=this._viewSelection.originalSelection.clone(),this._editSelection._activeCell=this._viewSelection._activeCell.clone(),this._editSelection.originalActiveCell=this._viewSelection.originalActiveCell.clone())}_setFormulaSelections(e){this._formulaSelections=(e||[]).slice(),this.triggerChange({selection:!0})}_viewActiveCell(){return this._viewSelection._activeCell.toRangeRef()}toJSON(){var e={},r=this._rows.toJSON("height",e),n=this._columns.toJSON("width",{}),s=this._viewSelection,i=[],o=this._defaultCellStyle||{};this.forEach(g,(function(n,s,a){if(function(e){Object.keys(o).forEach((function(t){e[t]===o[t]&&delete e[t]}))}(a),0!==Object.keys(a).length){a.link&&i.push({ref:u.display(null,n,s),target:a.link});var h=e[n];void 0===h&&(h=r.length,r.push({index:n}),e[n]=h),n=r[h],a.index=s,void 0===n.cells&&(n.cells=[]),a.formula&&(a.formula.arrayFormulaRange?a.formula={src:a.formula.toString(),ref:a.formula.arrayFormulaRange.toString()}:a.formula=a.formula.toString()),a.validation&&(a.validation=a.validation.toJSON()),a.color&&(a.color=t.p(a.color).toCss()),a.background&&(a.background=t.p(a.background).toCss()),a.borderTop&&a.borderTop.color&&(a.borderTop.color=t.p(a.borderTop.color).toCss()),a.borderBottom&&a.borderBottom.color&&(a.borderBottom.color=t.p(a.borderBottom.color).toCss()),a.borderRight&&a.borderRight.color&&(a.borderRight.color=t.p(a.borderRight.color).toCss()),a.borderLeft&&a.borderLeft.color&&(a.borderLeft.color=t.p(a.borderLeft.color).toCss()),n.cells.push(a)}}));var a={name:this._name(),state:this._state(),rows:r,columns:n,selection:s.selection.toString(),activeCell:s.activeCell().toString(),frozenRows:this.frozenRows(),frozenColumns:this.frozenColumns(),showGridLines:this.showGridLines(),gridLinesColor:this.gridLinesColor(),mergedCells:this._mergedCells.map((function(e){return e.toString()})),hyperlinks:i,defaultCellStyle:o,drawings:this._drawings.map((function(e){return e.toJSON()}))};return this._sort&&(a.sort={ref:this._sort.ref.toString(),columns:this._sort.columns.map((function(e){return{index:e.index,ascending:e.ascending}}))}),this._filter&&(a.filter={ref:this._filter.ref.toString(),columns:this._filter.columns.map((function(e){var t=e.filter.toJSON();return t.index=e.index,t}))}),a}fromJSON(e){this.batch((function(){if(void 0!==e.name&&this._name(e.name),void 0!==e.frozenColumns&&this.frozenColumns(e.frozenColumns),void 0!==e.frozenRows&&this.frozenRows(e.frozenRows),void 0!==e.columns&&this._columns.fromJSON("width",e.columns),void 0!==e.rows){this._resizeForJSON(e.rows),this._rows.fromJSON("height",e.rows);for(var t=0;t<e.rows.length;t++){var r=e.rows[t],n=r.index;if(void 0===n&&(n=t),r.cells)for(var s=0;s<r.cells.length;s++){var i=r.cells[s],o=i.index;if(void 0===o&&(o=s),i.formula){var a="string"!=typeof i.formula,u=a?i.formula.src:i.formula,h=this._compileFormula(n,o,u);a&&h.setArrayFormulaRange(te.parseReference(i.formula.ref)),i.formula=h}i.validation&&(i.validation=this._compileValidation(n,o,i.validation)),this._properties.fromJSON(this._grid.index(n,o),i)}}}if(e.drawings&&(this._drawings=e.drawings.map(yn.fromJSON)),e.selection&&(this._viewSelection.selection=this._viewSelection.originalSelection=this._ref(e.selection)),e.activeCell){var l=this._ref(e.activeCell);this._viewSelection._activeCell=l.toRangeRef(),this._viewSelection.originalActiveCell=l.first()}if(e.mergedCells&&e.mergedCells.forEach((function(e){this.range(e).merge()}),this),e.filter){var c=e.filter.ref,f=void 0===e.filter.columns?[]:e.filter.columns;c&&(this._filter={ref:this._ref(c),columns:f.map((function(e){return{index:e.index,filter:nn.create(e)}}))},this._refreshFilter())}void 0!==e.showGridLines&&(this._showGridLines=e.showGridLines),this._gridLinesColor=e.gridLinesColor,e.sort&&this._sortBy(this._ref(e.sort.ref),e.sort.columns.slice(0))})),this._rows._refresh(),this._columns._refresh()}formula(e){return this._properties.get("formula",this._grid.cellRefIndex(e))}validation(e){return this._properties.get("validation",this._grid.cellRefIndex(e))}resetFormulas(){this._forFormulas((function(e){e.reset()}))}resetValidations(){this._forValidations((function(e){e.reset()}))}recalc(e,t){var r=this._properties.get("formula").values(),n=r.length,s=0,i=0;if(!n&&t)return t();function o(){s--,i!==n||s||t()}for(;i<n;)s++,r[i++].value.exec(e,t?o:null)}revalidate(e){var t=this;this._forValidations((function(r){var n=new c(r.row,r.col),s=new f(n,n);r.exec(e,t._get(s,"value"),t._get(s,"format"))}))}_value(e,t,r){var n=this._grid.index(e,t);if(void 0===r)return this._properties.get("value",n);this._properties.set("value",n,n,r)}_validation(e,t){var r=this._grid.index(e,t);return this._properties.get("validation",r)}_compileValidation(e,t,r){return r instanceof hr.Validation?r.clone(this._name(),e,t):(null!=r.from&&(r.from=(r.from+"").replace(/^=/,"")),null!=r.to&&(r.to=(r.to+"").replace(/^=/,"")),hr.compile(this._name(),e,t,r))}_compileFormula(e,t,r){return r=r.replace(/^=/,""),r=te.parseFormula(this._name(),e,t,r),te.compile(r)}_copyValuesInRange(e,t,r,n){var s,i,o;for(s=e.col;s<=t.col;s++){i=this._grid.index(e.row,s),o=this._grid.index(t.row,s);for(var a=i,u=e.row;a<=o;++a,++u)r=r.clone(this._name(),u,s),this._properties.set(n,a,a,r)}return r}_set(e,t,r){var n,s,i,o=this._grid.normalize(e.topLeft),a=this._grid.normalize(e.bottomRight);if("number"==typeof r&&(r=te.runtime.limitPrecision(r)),r&&"formula"===t)"string"==typeof r&&(r=this._compileFormula(o.row,o.col,r)),r=this._copyValuesInRange(o,a,r,"formula");else if(r&&"validation"===t)r=this._compileValidation(o.row,o.col,r),r=this._copyValuesInRange(o,a,r,"validation");else for(n=o.col;n<=a.col;n++)s=this._grid.index(o.row,n),i=this._grid.index(a.row,n),this._properties.set(t,s,i,r),"formula"===t&&this._properties.set("value",s,i,null)}_get(e,t){var r=this._grid.normalize(e.topLeft),n=this._grid.index(r.row,r.col);return this._properties.get(t,n)}batch(e,t){var r=this.suspendChanges();return this.suspendChanges(!0),this._valueChanged=!1,e.call(this),t||(t={recalc:!0}),this._valueChanged&&(t.isValue=!0),this.suspendChanges(r).triggerChange(t)}_sortBy(e,t){var r=null;t.forEach((function(t){r=this._sorter.sortBy(e,t.index,this._properties.get("value"),t.ascending,r)}),this),this._sort={ref:e,columns:t},this._refreshFilter(),this.forEach(e,function(e,t,r){var n=r.formula;if(n){var s=e-n.row;if(0!==s){var i=s>0?n.row:n.row+s;n.adjust(this.name(),"row",i,s)}}}.bind(this)),this.triggerChange({recalc:!0})}_refreshFilter(){this._filter&&this._filterBy(this._filter.ref,this._filter.columns)}_filterBy(e,t){this.batch((function(){for(var r=e.topLeft.row;r<=e.bottomRight.row;r++)this.isFilteredRow(r)&&(this._filteredRows.value(r,r,!1),this._rows.unhide(r));t.forEach((function(t){var r=e.resize({top:1}).toColumn(t.index),n=[];if(r!==h){this.forEach(r,(function(e,t,r){r.row=e,n.push(r)})),t.filter.prepare(n);for(var s=0;s<n.length;s++){var i=n[s],o=t.filter.value(i);!1===t.filter.matches(o)&&this._filterRow(i.row)}}}),this),this._filter={ref:e,columns:t}}),{recalc:!0,layout:!0,filter:!0})}filterColumn(e){var t=this.filter().ref;return e.toRangeRef().topLeft.col-t.topLeft.col}filter(){return this._filter}clearFilter(e){this._clearFilter(e instanceof Array?e:[e])}_clearFilter(e){this._filter&&this.batch((function(){this._filter.columns=this._filter.columns.filter((function(t){return e.indexOf(t.index)<0})),this._refreshFilter()}),{recalc:!0,layout:!0,filter:!0})}getAxisState(){return{rows:this._rows.getState(),columns:this._columns.getState()}}setAxisState(e){this._rows.setState(e.rows),this._columns.setState(e.columns),this.triggerChange({layout:!0})}getState(){return{rows:this._rows.getState(),columns:this._columns.getState(),mergedCells:this._mergedCells.map((function(e){return e.clone()})),properties:this._properties.getState()}}setState(e){this._rows.setState(e.rows),this._columns.setState(e.columns),this._mergedCells=e.mergedCells,this._properties.setState(e.properties),this.triggerChange(y)}_merge(e){var t,r=this._mergedCells,n=this;return this.batch((function(){t=e.map((function(e){if(e instanceof c)return e;var t=e.toRangeRef().union(r,(function(e){r.splice(r.indexOf(e),1)})),s=new fr(t,n),i=s._get("formula"),o=s.value(),a=s.format(),u=s.background();s.value(null),s.format(null),s.background(null);var h=new fr(t.collapse(),n);return i?h._set("formula",i):h.value(o),h.format(a),h.background(u),r.push(t),t}));var s=n._viewSelection;s.selection=n.unionWithMerged(s.originalSelection),s._activeCell=n.unionWithMerged(s.originalActiveCell)}),{activeCell:!0,selection:!0}),t}_useCultureDecimals(){return this._workbook&&this._workbook.options.useCultureDecimals}withCultureDecimals(e){var t=".";return this._useCultureDecimals()&&(t=ee().numbers.symbols.decimal),te.withDecimalSeparator(t,e)}drawingBoundingBox(e){var t=e.offsetX,r=e.offsetY;return e.topLeftCell&&(t+=this._columns.sum(0,e.topLeftCell.col-1),r+=this._rows.sum(0,e.topLeftCell.row-1)),new Vr(t,r,e.width,e.height)}refBoundingBox(e){return this._grid.rectangle(e.toRangeRef())}addDrawing(e,t){return e instanceof yn||(e=new yn(e)),this._drawings.push(e),t&&(this._activeDrawing=e),this.triggerChange({layout:!0}),e}removeDrawing(e){var t=this._drawings.indexOf(e);t>=0&&(this._drawings.splice(t,1),this.triggerChange({layout:!0}))}usesImage(e){for(var t=this._drawings.length;--t>=0;)if(this._drawings[t].image===e)return!0;return!1}isMerged(e){for(var t=this._mergedCells,r=t.length;--r>=0;)if(t[r].eq(e))return!0;return!1}}class yn{constructor(e){this.reset(e)}toJSON(){return{topLeftCell:this.topLeftCell.toString(),offsetX:this.offsetX,offsetY:this.offsetY,width:this.width,height:this.height,image:this.image,opacity:this.opacity}}clone(){return new yn(this)}reset(e){var t=e.topLeftCell;"string"==typeof t&&(t=te.parseReference(t)),this.topLeftCell=t,this.offsetX=e.offsetX||0,this.offsetY=e.offsetY||0,this.width=e.width,this.height=e.height,this.image=e.image,this.opacity=null!=e.opacity?e.opacity:1}eq(e){return(!this.topLeftCell&&!e.topLeftCell||this.topLeftCell&&e.topLeftCell&&this.topLeftCell.eq(e.topLeftCell))&&this.offsetX===e.offsetX&&this.offsetY===e.offsetY&&this.width===e.width&&this.height===e.height&&this.image===e.image&&this.opacity===e.opacity}}yn.fromJSON=function(e){return new yn(e)};let wn={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],executive:[521.86,756],folio:[612,936],legal:[612,1008],letter:[612,792],tabloid:[792,1224]};function bn(e){return e*(72/25.4)}function _n(e){return bn(10*e)}function An(e){return 72*e}function Cn(e,t){if("number"==typeof e)return e;if("string"==typeof e){let t;if(t=/^\s*([0-9.]+)\s*(mm|cm|in|pt)\s*$/.exec(e),t){let e=parseFloat(t[1]);if(!isNaN(e))return"pt"===t[2]?e:{mm:bn,cm:_n,in:An}[t[2]](e)}}if(null!=t)return t;throw new Error("Can't parse unit: "+e)}let xn,kn=.8;function Mn(e,t,r,n,s){let i=0,o=[],a=t,u=0;return t&&r&&(r*=t),e.forEach((function(e,h){null!=n&&h<n&&(u+=e),t&&i+e>a&&(a-i<r&&(i=t*Math.ceil(i/t)+u,u>0&&s.push(i-u)),a+=t*Math.ceil(e/t)),o.push(i),i+=e})),o.push(i),o}function En(e,t,r){let n=e._grid;t=n.normalize(t);let s=n.rectangle(t),i=[];e._drawings.forEach((function(t){let r=e.drawingBoundingBox(t);r.intersects(s)&&i.push({drawing:t,box:r.offset(-s.left,-s.top)})}));let o=[],a=[],u=[],h=e._getMergedCells(t),l=-1,f=-1;e.forEach(t,(function(n,s,p){let d=n-t.topLeft.row,g=s-t.topLeft.col,m=e.rowHeight(n),v=e.columnWidth(s);r.forScreen||(p.drawings=i.filter((function(t){let r=t.drawing.topLeftCell;if(r&&r.row==n&&r.col==s)return l=Math.max(l,e._rows.index(t.box.bottom)),f=Math.max(f,e._columns.index(t.box.right)),!0}))),g||a.push(m),d||u.push(v);let y=new c(n,s).print();if(h.secondary[y])return;p.row=d,p.col=g;let w=h.primary[y];if(w?(delete h.primary[y],p.merged=!0,p.rowspan=w.height(),p.colspan=w.width(),r.forScreen&&(p.width=e._columns.sum(w.topLeft.col,w.bottomRight.col),p.height=e._rows.sum(w.topLeft.row,w.bottomRight.row))):(p.rowspan=1,p.colspan=1),!e._grid._columns.sum(s,s+p.colspan-1)||!e._grid._rows.sum(n,n+p.rowspan-1))return;let b=r.forScreen||function(e){return null!=e.value||e.merged||null!=e.background||null!=e.borderRight||null!=e.borderBottom||null!=e.dBorders||null!=e.validation&&!e.validation.value||e.drawings&&e.drawings.length}(p);(r.emptyCells||b)&&(b?(l=Math.max(l,d+p.rowspan-1),f=Math.max(f,g+p.colspan-1)):p.empty=!0,o.push(p))})),r.forScreen||(a=a.slice(0,l+1),u=u.slice(0,f+1));let p=r.pageWidth,d=r.pageHeight,g=r.scale||1;if(r.fitWidth){let e=u.reduce(Rn,0);e>p&&(g=p/e)}p=Math.ceil(p/g),d=Math.ceil(d/g);let m=[],v=Mn(a,d||0,r.maxEmpty,r.headerRows,m),y=Mn(u,p||0,r.maxEmpty),w=0,b=0,_=[];return o=o.filter((function(e){return(!e.empty||!(e.row>l||e.col>f))&&(r.headerRows&&e.row<r.headerRows&&_.push(e),e.left=y[e.col],e.top=v[e.row],e.merged?r.forScreen?(e.right=e.left+e.width,e.bottom=e.top+e.height):(e.right=Sn(y,e.col+e.colspan),e.bottom=Sn(v,e.row+e.rowspan),e.width=e.right-e.left,e.height=e.bottom-e.top):(e.width=u[e.col],e.height=a[e.row],e.bottom=e.top+e.height,e.right=e.left+e.width),r.forScreen||e.drawings.forEach((function(t){let r=t.box;r.left=e.left+t.drawing.offsetX,r.top=e.top+t.drawing.offsetY,r.right=r.left+r.width,r.bottom=r.top+r.height})),w=Math.max(w,e.right),b=Math.max(b,e.bottom),!0)})),Object.keys(h.primary).forEach((function(r){let n=h.primary[r];e.forEach(n.topLeft.toRangeRef(),(function(r,s,i){let a=r-t.topLeft.row,u=s-t.topLeft.col;i.merged=!0,i.colspan=n.width(),i.rowspan=n.height(),i.top=a<0?-e._rows.sum(r,r-a-1):v[a],i.left=u<0?-e._columns.sum(s,s-u-1):y[u],i.height=e._rows.sum(n.topLeft.row,n.bottomRight.row),i.width=e._columns.sum(n.topLeft.col,n.bottomRight.col),i.height>0&&i.width>0&&(i.right=i.left+i.width,i.bottom=i.top+i.height,i.row=a,i.col=u,o.push(i))}))})),r.headerRows&&(m.forEach((function(e){_.forEach((function(t){(t=function(e,t){t||(t={});if(Object.assign)return Object.assign(t,e);return Object.keys(e).reduce((function(t,r){return t[r]=e[r],t}),t)}(t)).top+=e,t.bottom=t.top+t.height,o.push(t)})),v.push(e)})),v.sort(Ln)),{width:w,height:b,cells:o.sort(Nn),scale:g,xCoords:y,yCoords:v,drawings:i}}function Fn(e,t){return e.size===t.size&&e.color===t.color}function Rn(e,t){return e+t}function Sn(e,t){return t<e.length?e[t]:e[e.length-1]}function Nn(e,t){return e.top<t.top?-1:e.top==t.top?e.left<t.left?-1:e.left==t.left?0:1:1}function Ln(e,t){return e<t?-1:e>t?1:0}function Dn(e,r,n,s){let i=Math.ceil(r.width/s.pageWidth),o=Math.ceil(r.height/s.pageHeight),a=Math.ceil(s.pageWidth/r.scale),u=Math.ceil(s.pageHeight/r.scale);for(let e=0;e<o;++e)for(let t=0;t<i;++t)h(e,t);function h(i,o){let h=o*a,l=h+a,c=i*u,f=c+u,p=0,d=0;function g(e){return!(e.right<=h||e.left>=l||e.bottom<=c||e.top>=f)&&(p=Math.max(e.bottom,p),d=Math.max(e.right,d),!0)}let m=r.cells.filter(g),v=r.drawings.filter((function(e){return g(e.box)}));if(p=Math.min(p,f),d=Math.min(d,l),m.length||v.length){let i=new t.G;n.append(i);let o=new t.G;i.append(o),o.clip(t.b.fromRect(new t.R([h-1,c-1],[d+1,p+1])));let a=t.M.scale(r.scale,r.scale).multiplyCopy(t.M.translate(-h,-c));if((s.hCenter||s.vCenter)&&(a=a.multiplyCopy(t.M.translate(s.hCenter?(l-d)/2:0,s.vCenter?(f-p)/2:0))),o.transform(a),s.guidelines){let e=null;r.xCoords.forEach((function(r){(r=Math.min(r,d))!==e&&r>=h&&r<=l&&(e=r,o.append((new t.b).moveTo(r,c).lineTo(r,p).close().stroke(s.guideColor,kn)))})),e=null,r.yCoords.forEach((function(r){(r=Math.min(r,p))!==e&&r>=c&&r<=f&&(e=r,o.append((new t.b).moveTo(h,r).lineTo(d,r).close().stroke(s.guideColor,kn)))}))}let u=Bn();m.forEach((function(r){!function(e,r,n){let s=new t.G;r.append(s);let i=new t.R([e.left,e.top],[e.width,e.height]);if(e.background||e.merged){let r=i;n.guidelines&&(r=i.clone(),r.origin.x+=.5,r.origin.y+=.5,r.size.width-=1,r.size.height-=1),s.append(new t.x(r).fill(e.background||"#fff").stroke(null))}e.dBorders&&(2&e.dBorders.type&&s.append((new t.b).moveTo(e.left,e.bottom).lineTo(e.right,e.top).stroke(e.dBorders.color,e.dBorders.size)),1&e.dBorders.type&&s.append((new t.b).moveTo(e.left,e.top).lineTo(e.right,e.bottom).stroke(e.dBorders.color,e.dBorders.size)));let o=e.value;if(null!=o){let r="number"==typeof o?"number":null,n=new t.G;n.clip(t.b.fromRect(i)),s.append(n);let a,u=e.format;if(u||"number"!=r||o==Math.floor(o)||(u="0.##############"),u?(a=Je.textAndColor(o,u),o=a.text,a.type&&(r=a.type)):o+="",!e.textAlign)switch(r){case"number":case"date":case"percent":case"currency":e.textAlign="right";break;case"boolean":e.textAlign="center"}!function(e,r,n,s){xn||(xn=document.createElement("div"),xn.style.position="fixed",xn.style.left="0px",xn.style.top="0px",xn.style.visibility="hidden",xn.style.overflow="hidden",xn.style.boxSizing="border-box",xn.style.lineHeight="normal",document.body.appendChild(xn));xn.firstChild&&xn.removeChild(xn.firstChild);xn.style.padding="2px 4px",xn.style.color=r,xn.style.font=function(e){let t=[];e.italic&&t.push("italic");e.bold&&t.push("bold");return t.push((e.fontSize||12)+"px"),t.push(e.fontFamily||"Arial"),t.join(" ")}(n),xn.style.width=n.width+"px",xn.style.textAlign=n.textAlign||"left",xn.style.textDecoration=n.underline?"underline":"none",Un(n,xn.style),n.wrap?(xn.style.whiteSpace="pre-wrap",xn.style.overflowWrap=xn.style.wordWrap="break-word"):(xn.style.whiteSpace="pre",xn.style.overflowWrap=xn.style.wordWrap="normal");xn.appendChild(document.createTextNode(e));let i=0;switch(n.verticalAlign){case"center":i=n.height-xn.offsetHeight>>1;break;case void 0:case null:case"bottom":i=n.height-xn.offsetHeight}i<0&&(i=0);let o=t.y(xn);o.transform(t.M.translate(n.left,n.top+i)),s.append(o)}(o,a&&a.color||e.color||"#000",e,n)}}(r,o,s),u.add(r,e)}));let g=new t.G;u.vert.forEach((function(e){e.forEach((function(e){e.rendered||(e.rendered=!0,g.append((new t.b).moveTo(e.x,e.top).lineTo(e.x,e.bottom).close().stroke(e.color,e.size)))}))})),u.horiz.forEach((function(e){e.forEach((function(e){e.rendered||(e.rendered=!0,g.append((new t.b).moveTo(e.left,e.y).lineTo(e.right,e.y).close().stroke(e.color,e.size)))}))})),o.append(g),v.forEach((function(r){let n=r.drawing,s=n.image;if(null!=s){let i=r.box,a=e._workbook.imageUrl(s);o.append(new n.Image(a,new t.R([i.left,i.top],[i.width,i.height])).opacity(n.opacity))}}))}}}function Un(e,t){if(e.indent){let r=1.4*e.indent;switch(t.textAlign){case null:case"left":t.paddingLeft=r+"ch";break;case"right":t.paddingRight=r+"ch";break;case"center":t.paddingLeft=r/2+"ch",t.paddingRight=r/2+"ch"}}}function Vn(e,r,n,s){null==n&&null==s&&(s=r,n={},r=g),null==s&&(s=n,r instanceof Range||r instanceof u||"string"==typeof r?n={}:(n=r,r=g)),n=Object.assign({},{paperSize:"A4",landscape:!0,margin:"1cm",guidelines:!0,guideColor:"#aaa",emptyCells:!0,fitWidth:!1,center:!1,headerRows:null,maxEmpty:.2,scale:1},n);let i=new t.G,o=function(e){if("function"!=typeof e){let t=e;e=function(e,r){return e in t?t[e]:r}}let t=e("paperSize",wn.a4);if(!t)return{};if("string"==typeof t&&(t=wn[t.toLowerCase()],null==t))throw new Error("Unknown paper size");t[0]=Cn(t[0]),t[1]=Cn(t[1]),e("landscape",!1)&&(t=[Math.max(t[0],t[1]),Math.min(t[0],t[1])]);let r=e("margin");return r&&("string"==typeof r||"number"==typeof r?(r=Cn(r,0),r={left:r,top:r,right:r,bottom:r}):r={left:Cn(r.left,0),top:Cn(r.top,0),right:Cn(r.right,0),bottom:Cn(r.bottom,0)},e("addMargin")&&(t[0]+=r.left+r.right,t[1]+=r.top+r.bottom)),{paperSize:t,margin:r}}(n);i.options.set("pdf",{author:n.author,creator:n.creator,date:n.date,keywords:n.keywords,margin:o.margin,multiPage:!0,paperSize:o.paperSize,subject:n.subject,title:n.title,autoPrint:n.autoPrint});let a=o.paperSize[0],h=o.paperSize[1];o.margin&&(a-=o.margin.left+o.margin.right+1,h-=o.margin.top+o.margin.bottom+1),n.pageWidth=a,n.pageHeight=h;let l=En(e,e._ref(r),n);Dn(e,l,i,n),s(i)}function $n(){}function Bn(){let e=new $n,t=new $n;function r(e){return"__proto__"===e||"constructor"===e||"prototype"===e}function n(e,n,s,i,o,a){if(r(e)||r(n))return;let u=t[n]||(t[n]=new $n),h=e>0&&u[e-1];h&&Fn(h,s)?(u[e]=h,h.bottom=a):u[e]={size:s.size,color:s.color||"#000",x:i,top:o,bottom:a}}function s(t,n,s,i,o,a){if(r(t)||r(n))return;let u=e[t]||(e[t]=new $n),h=n>0&&u[n-1];h&&Fn(h,s)?(u[n]=h,h.right=a):u[n]={size:s.size,color:s.color||"#000",y:i,left:o,right:a}}return{add:function(e,t){if(t){let r=t._properties,n=t._grid;e.borderLeft=r.get("vBorders",n.index(e.row,e.col)),e.borderRight=r.get("vBorders",n.index(e.row,e.col+e.colspan)),e.borderTop=r.get("hBorders",n.index(e.row,e.col)),e.borderBottom=r.get("hBorders",n.index(e.row+e.rowspan,e.col))}e.borderLeft&&n(e.row,e.col,e.borderLeft,e.left,e.top,e.bottom),e.borderRight&&n(e.row,e.col+e.colspan,e.borderRight,e.right,e.top,e.bottom),e.borderTop&&s(e.row,e.col,e.borderTop,e.top,e.left,e.right),e.borderBottom&&s(e.row+e.rowspan,e.col,e.borderBottom,e.bottom,e.left,e.right)},horiz:e,vert:t}}vn.prototype.draw=function(e,t,r){let n=this;n._workbook?n.recalc(n._workbook._context,(function(){Vn(n,e,t,r)})):Vn(n,e,t,r)},$n.prototype={forEach:function(e){Object.keys(this).forEach((function(t){e(this[t],t,this)}),this)}};const In={Borders:Bn,doLayout:En,applyIndent:Un},Tn=".",zn={view:"k-spreadsheet-view",fixedContainer:"k-spreadsheet-fixed-container",editContainer:"k-spreadsheet-edit-container",scroller:"k-spreadsheet-scroller",viewSize:"k-spreadsheet-view-size",clipboard:"k-spreadsheet-clipboard",cellEditor:"k-spreadsheet-cell-editor",barEditor:"k-spreadsheet-editor",topCorner:"k-spreadsheet-top-corner",filterHeadersWrapper:"k-filter-wrapper",filterRange:"k-filter-range",filterButton:"k-spreadsheet-filter",filterButtonSelected:"k-selected",horizontalResize:"k-horizontal-resize",verticalResize:"k-vertical-resize",icon:"k-icon",iconFilterDefault:"k-i-caret-alt-down",sheetsBar:"k-spreadsheet-sheets-bar",sheetsBarActive:"k-spreadsheet-sheets-bar-active",sheetsBarInactive:"k-spreadsheet-sheets-bar-inactive",cellContextMenu:"k-spreadsheet-cell-context-menu",rowHeaderContextMenu:"k-spreadsheet-row-header-context-menu",colHeaderContextMenu:"k-spreadsheet-col-header-context-menu",drawingContextMenu:"k-spreadsheet-drawing-context-menu"},Hn={cell:"k-spreadsheet-cell",vaxis:"k-spreadsheet-vaxis",haxis:"k-spreadsheet-haxis",vborder:"k-spreadsheet-vborder",hborder:"k-spreadsheet-hborder",rowHeader:"k-spreadsheet-row-header",columnHeader:"k-spreadsheet-column-header",pane:"k-spreadsheet-pane",data:"k-spreadsheet-data",mergedCell:"k-spreadsheet-merged-cell",mergedCellsWrapper:"k-merged-cells-wrapper",activeCell:"k-spreadsheet-active-cell",selection:"k-spreadsheet-selection",selectionWrapper:"k-selection-wrapper",autoFillWrapper:"k-auto-fill-wrapper",single:"k-single",top:"k-top",right:"k-right",bottom:"k-bottom",left:"k-left",resizeHandle:"k-resize-handle",columnResizeHandle:"k-column-resize-handle",rowResizeHandle:"k-row-resize-handle",resizeHint:"k-resize-hint",resizeHintHandle:"k-resize-hint-handle",resizeHintMarker:"k-resize-hint-marker",resizeHintVertical:"k-resize-hint-vertical",selectionHighlight:"k-spreadsheet-selection-highlight",series:["k-series-a","k-series-b","k-series-c","k-series-d","k-series-e","k-series-f"]};function Pn(e){return(e.size||1)+"px solid "+(e.color||"#000")}function On(e){return/:\/\//.test(e)||(e="http://"+e),e}function jn(e,r,n,s){function i(e){let t=r.link;if(t||"object"==typeof r.value&&(t=r.value.link),t){let n={textDecoration:"none"};return r.color&&(n.color=r.color),r.underline&&(n.textDecoration="underline"),Be.element("a",{href:On(t),style:n,target:"_blank"},e?[e]:[])}return e}let o=null!=r.value||null!=r.validation&&!r.validation.value||r.background||r.merged||r.comment||r.dBorders;if(!n&&!o)return;let a={background:[]},u=r.background;if(u){let e=u;s&&(e=t.p(e).toHSV(),e.v*=.9,e=e.toCssRgba()),e=Pn({color:e}),a.outline=e}r.dBorders&&(2&r.dBorders.type&&a.background.push("linear-gradient(to top left, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) calc(50% - "+r.dBorders.size+"px), "+r.dBorders.color+" 50%, rgba(0, 0, 0, 0) calc(50% + "+r.dBorders.size+"px), rgba(0, 0, 0, 0) 100%)"),1&r.dBorders.type&&a.background.push("linear-gradient(to top right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) calc(50% - "+r.dBorders.size+"px), "+r.dBorders.color+" 50%, rgba(0, 0, 0, 0) calc(50% + "+r.dBorders.size+"px), rgba(0, 0, 0, 0) 100%)")),u&&a.background.push(u),r.color&&(a.color=r.color),r.fontFamily&&(a.fontFamily=r.fontFamily),r.underline&&(a.textDecoration="underline"),r.italic&&(a.fontStyle="italic"),r.textAlign&&(a.textAlign=r.textAlign),r.bold&&(a.fontWeight="bold"),r.fontSize&&(a.fontSize=r.fontSize+"px"),!0===r.wrap?(a.whiteSpace="pre-wrap",a.overflowWrap="break-word",a.wordWrap="break-word"):(a.whiteSpace="pre",a.overflowWrap="normal",a.wordWrap="normal"),a.left=r.left+1+"px",a.top=r.top+1+"px",a.width=r.width-1+"px",a.height=r.height-1+"px";let h=r.value,l=typeof h,c=r.format;if(c||"number"!==l||h===Math.floor(h)||(c="0.##############"),c&&null!=h?(h=Je.format(h,c),h.__dataType&&(l=h.__dataType)):null!=h&&(h=r.html?Be.html(h):Be.text(h)),!a.textAlign)switch(l){case"number":case"date":case"percent":case"currency":a.textAlign="right";break;case"boolean":a.textAlign="center"}In.applyIndent(r,a);let f=[Hn.cell];n&&f.push(n),!1===r.enable&&f.push("k-disabled"),r.merged&&(f.push("k-spreadsheet-merged-cell"),r.enable||e.push(Be.element("div",{className:"k-spreadsheet-disabled-mask",style:{left:r.left+1+"px",top:r.top+1+"px",width:r.width-1+"px",height:r.height-1+"px"}}))),r.comment&&f.push("k-spreadsheet-has-comment");let p=r.verticalAlign||"bottom";h=p&&h?Be.element("div",{className:"k-vertical-align-"+p},[i(h)]):i(h),a.background.length?a.background=a.background.join(","):delete a.background;let d=h?[h]:[],g={style:a},m=r.validation;m&&!m.value&&(d.push(Be.element("span",{className:"k-dirty"})),f.push("k-dirty-cell"),g.title=m.message),g.className=f.join(" ");let v=Be.element("div",g,d);return e.push(v),v}class Wn{constructor(e,t,r){this._sheet=e,this._grid=t,this.getIconHTMLString=r}refresh(e,t){this._grid.refresh(e,t)}isVisible(e,t,r){return this._grid.view(e,t).ref.intersects(r)}render(e){let t=e.scroller,r=t.scrollLeft,n=t.scrollTop;n<0&&(n=0),r<0&&(r=0);let s=Wn.classNames,i=this._sheet,o=this._grid,a=o.view(r,n);this._currentView=a,this._currentRect=this._rectangle(a.ref),this._selectedHeaders=i.selectedHeaders();let h=[];if(h.push(this.renderData(e)),i._activeDrawing||h.push(this.renderSelection(t)),h.push(this.renderAutoFill()),h.push(this.renderEditorSelection()),h.push(this.renderFilterHeaders()),o.hasRowHeader){let e=Be.element("div",{className:s.rowHeader,style:{width:o.headerWidth+"px",top:a.rowOffset+"px"}});h.push(e),i.forEach(a.ref.leftColumn(),function(t){if(!i.isHiddenRow(t)){let r=t+1,n=i.rowHeight(t);e.children.push(Be.element("div",{className:this.headerClassName(t,"row"),style:{width:o.headerWidth+"px",height:n+"px"}},[Be.element("div",{className:"k-vertical-align-center"},[Be.text(r+"")])]))}}.bind(this))}if(o.hasColumnHeader){let e=Be.element("div",{className:s.columnHeader,style:{top:"0px",left:a.columnOffset+"px",width:this._currentRect.width+"px",height:o.headerHeight+"px"}});h.push(e);let t=0;i.forEach(a.ref.topRow(),function(r,n){if(!i.isHiddenColumn(n)){let r=u.display(null,1/0,n),s=i.columnWidth(n);e.children.push(Be.element("div",{className:this.headerClassName(n,"col"),style:{position:"absolute",left:t+"px",width:s+"px",height:o.headerHeight+"px"}},[Be.element("div",{className:"k-vertical-align-center"},[Be.text(r+"")])])),t+=s}}.bind(this))}i.resizeHandlePosition()&&(o.hasColumnHeader||o.hasRowHeader)&&(i.resizeHintPosition()||this.renderResizeHandle(h));let l=[s.pane];return o.hasColumnHeader&&l.push(s.top),o.hasRowHeader&&l.push(s.left),Be.element("div",{style:o.style,className:l.join(" ")},h)}headerClassName(e,t){let r,n,s=this._selectedHeaders;"row"===t?(r=s.rows[e],n=s.allRows):(r=s.cols[e],n=s.allCols);let i=r||(s.all?"full":n?"partial":"none");return i&&(i="k-selection-"+i),i}renderData(e){let t,r=this._sheet,n=this._currentView,s=Be.element("div",{className:Wn.classNames.data,style:{position:"relative",left:n.columnOffset+"px",top:n.rowOffset+"px"}}),i=this._currentRect,o=In.doLayout(r,n.ref,{forScreen:!0}),a=this._grid,u=r._showGridLines;u&&(t=null,o.xCoords.forEach((function(e){e!==t&&(t=e,s.children.push(Be.element("div",{className:Hn.vaxis,style:{left:e+"px",height:i.height+"px",borderColor:r.gridLinesColor()}})))})),t=null,o.yCoords.forEach((function(e){e!==t&&(t=e,s.children.push(Be.element("div",{className:Hn.haxis,style:{top:e+"px",width:i.width+"px",borderColor:r.gridLinesColor()}})))})));let h=In.Borders(),l=r.activeCell().toRangeRef(),c=l.topLeft;return o.cells.forEach((function(t){let i=null,o=t.row+n.ref.topLeft.row,f=t.col+n.ref.topLeft.col;if(r._activeDrawing){let e=r._activeDrawing.topLeftCell;e&&e.row===o&&e.col===f&&(i="k-spreadsheet-drawing-anchor-cell")}else o===c.row&&f===c.col&&(i=[Wn.classNames.activeCell].concat(this._activeFormulaColor(),this._directionClasses(l)),r.singleCellSelection()&&i.push(Wn.classNames.single),i=i.join(" "));if(h.add(t),jn(s.children,t,i,u),t.comment&&r._commentRef&&o===r._commentRef.row&&f===r._commentRef.col){let r=4,s=t.right+a.left+n.columnOffset+r,i={top:t.top+a.top+n.rowOffset+"px"};s+200>e.contentWidth?i.right=e.contentWidth-a.left-t.left-n.columnOffset+r+"px":i.left=s+"px";let o=Be.element("div",{className:"k-tooltip k-spreadsheet-cell-comment",style:i},[Be.text(t.comment)]);e.toplevelElements.push(o)}}),this),h.vert.forEach((function(e){e.forEach((function(e){if(!e.rendered){e.rendered=!0;let t={left:e.x+"px",top:e.top+"px",height:e.bottom-e.top+1+"px",borderWidth:e.size+"px",borderColor:e.color};1!==e.size&&(t.transform="translateX(-"+(e.size-1)/2+"px)"),s.children.push(Be.element("div",{className:Hn.vborder,style:t}))}}))})),h.horiz.forEach((function(e){e.forEach((function(e){if(!e.rendered){e.rendered=!0;let t={top:e.y+"px",left:e.left+"px",width:e.right-e.left+"px",borderWidth:e.size+"px",borderColor:e.color};1!==e.size&&(t.transform="translateY(-"+(e.size-1)/2+"px)"),s.children.push(Be.element("div",{className:Hn.hborder,style:t}))}}))})),this.renderDrawings(o,s.children),s}renderDrawings(e,t){let r=this._sheet,n=r._workbook;e.drawings.forEach((function(e){let s=e.drawing,i=e.box.toDiv("k-spreadsheet-drawing");s.image&&i.children.push(Be.element("div",{className:"k-spreadsheet-drawing-image",style:{backgroundImage:"url('"+n.imageUrl(s.image)+"')",opacity:s.opacity}})),s===r._activeDrawing&&(i.attr.className+=" k-spreadsheet-active-drawing",function(e){["N","NE","E","SE","S","SW","W","NW"].forEach((function(t){e.push(Be.element("div",{className:"k-spreadsheet-drawing-handle "+t,"data-direction":t}))}))}(i.children)),t.push(i)}))}renderResizeHandle(e){let t,r=this._sheet.resizeHandlePosition(),n=this._rectangle(r),s=[Wn.classNames.resizeHandle];if(r.col!==-1/0){if(this._grid.rows._start>0)return;t={height:this._grid.headerHeight+"px",width:"7px",left:n.right-3.5+"px",top:"0px"},s.push(zn.horizontalResize)}else{if(this._grid.columns._start>0)return;t={height:"7px",width:this._grid.headerWidth+"px",top:n.bottom-3.5+"px",left:"0px"},s.push(zn.verticalResize)}e.push(Be.element("div",{className:s.join(" "),style:t}))}filterIconRect(e){return new Vr(e.right-16-3,e.top+3,16,16)}icon(e){return"function"==typeof this.getIconHTMLString?Be.element(this.getIconHTMLString(e)):Be.element("span",{className:zn.icon+" "+e})}renderFilterHeaders(){let e=this,t=this._sheet,r=[],n=zn,s=t.filter();return s&&this._addDiv(r,s.ref,n.filterRange),t.forEachFilterHeader(this._currentView.ref,function(t){let i=this._rectangle(t),o=this.filterIconRect(i),a=this._sheet.filterColumn(t),u=function(t,r,n){let i={left:r.left+"px",top:r.top+"px"},o=s&&s.columns.some((function(e){return e.index===n})),a=t.filterButton;return o&&(a+=" "+t.filterButtonSelected),Be.element("span",{className:a,style:i},[e.icon(t.iconFilterDefault)])}(n,o,a);r.push(u)}.bind(this)),Be.element("div",{className:n.filterHeadersWrapper},r)}renderEditorSelection(){let e=Wn.classNames,t=this._sheet,r=[];return t._formulaSelections.forEach(function(t){let n=t.ref;n!==h&&this._addDiv(r,n,e.selectionHighlight+" "+t.colorClass)}.bind(this)),Be.element("div",{className:e.selectionWrapper},r)}renderSelection(e){let t=Wn.classNames,r=[],n=[t.selection],s=this._sheet,i=s.activeCell().toRangeRef(),o=s.select();return n=n.concat(this._activeFormulaColor()),1===o.size()&&n.push("k-single-selection"),this._sheet.autoFillPunch()&&n.push("k-dim-auto-fill-handle"),o.forEach(function(e){e!==h&&this._addDiv(r,e,n.join(" "))}.bind(this)),this._renderCustomEditorButton(r,i,e),Be.element("div",{className:t.selectionWrapper},r)}renderAutoFill(){let e=[];if(this._sheet.autoFillInProgress()){let t=this._sheet.autoFillRef(),r=this._sheet.autoFillPunch(),n=this._sheet._autoFillDirection;if(this._addDiv(e,t,"k-auto-fill"),r)this._addDiv(e,r,"k-auto-fill-punch");else if(void 0!==n){let r,s;switch(n){case 0:case 1:r=t.bottomRight,s="k-auto-fill-br-hint";break;case 2:r=new c(t.topLeft.row,t.bottomRight.col),s="k-auto-fill-tr-hint";break;case 3:r=new c(t.bottomRight.row,t.topLeft.col),s="k-auto-fill-bl-hint"}let i=this._addDiv(e,r,s);if(i){let e=Be.element("span",{className:"k-tooltip"},[Be.text(this._sheet._autoFillHint)]);i.children.push(e)}}}return Be.element("div",{className:Wn.classNames.autoFillWrapper},e)}_addDiv(e,t,r){let n;return this._currentView.ref.intersects(t)&&(n=this._rectangle(t).resize(1,1).toDiv(r),e.push(n)),n}_renderCustomEditorButton(e,t,r){let n=this,s=n._sheet,i=n._currentView,o=n._grid.columns._axis._count,a=s.activeCellCustomEditor();if(a&&i.ref.intersects(t)){let i=n._rectangle(t);s.forEach(t.collapse(),(function(t,s,u){u.left=i.left,u.top=i.top,u.width=i.width,u.height=i.height;let h="k-button k-button-md k-rounded-md k-button-solid k-button-solid-base k-spreadsheet-editor-button",l=s===o-1||n._buttonOutOfVisiblePane(t,s,r);l&&(h+=" k-spreadsheet-last-column"),n._editorInLastColumn=l;let c=Be.element("div",{className:h,style:{left:u.left+(l?0:u.width)+"px",top:u.top+"px",height:u.height+"px"}});a.icon&&c.children.push(n.icon(a.icon)),e.push(c)}))}}_activeFormulaColor(){let e,t=[];return this._sheet.isInEditMode()&&(e=this._sheet._formulaSelections.filter((function(e){return e.active&&"ref"===e.type}))[0],e&&t.push(e.colorClass)),t}_directionClasses(e){let t=[],r=Wn.classNames,n=this._currentView.ref;return e.move(0,-1).intersects(n)||t.push(r.left),e.move(-1,0).intersects(n)||t.push(r.top),e.move(0,1).intersects(n)||t.push(r.right),e.move(1,0).intersects(n)||t.push(r.bottom),t}_rectangle(e){return this._grid.boundingRectangle(e.toRangeRef()).offset(-this._currentView.mergedCellLeft,-this._currentView.mergedCellTop)}_buttonOutOfVisiblePane(e,t,r){let n=this._grid,s=this._sheet,i=s.range(e,t)._ref,o=n.scrollBoundaries(i),a=n.columns.frozen?0:r.scrollLeft;if(o.right+20>a||t+1===s.frozenColumns())return!0}}Wn.classNames=Hn;let qn=["font-family","font-size","font-stretch","font-style","font-weight","letter-spacing","text-transform","line-height"],Yn={27:"esc",37:"left",39:"right",35:"end",36:"home",32:"spacebar"},Jn=/(^_|[^a-z0-9]$)/i;class Xn extends Mr{constructor(e,t){const r=Object.assign({},{name:"FormulaInput",autoScale:!1,filterOperator:"startswith",scalePadding:30,minLength:1,formulaBarWidth:null},t);super(e,r),this.events=["keyup","focus"],this.input=t.input,e&&(this.bind(this.events,this.options),e.classList.add(Xn.classNames.wrapper),r&&r.formulaBarWidth,this._highlightedRefs=[],this._formulaSource(),this._formulaList(),this._tooltip(),this._sync=this._sync.bind(this),this.scale=this.scale.bind(this),this._keydown=this._keydown.bind(this),this._keyup=this._keyup.bind(this),this._blur=this._blur.bind(this),this._input=this._input.bind(this),this._focus=this._focus.bind(this),this._paste=this._paste.bind(this),this.options.autoScale&&e.addEventListener("input",this.scale),e.addEventListener("keydown",this._keydown),e.addEventListener("keyup",this._keyup),e.addEventListener("blur",this._blur),e.addEventListener("input",this._input),e.addEventListener("click",this._input),e.addEventListener("focus",this._focus),e.addEventListener("paste",this._paste))}enable(e){if(void 0===e)return"true"===this.element.getAttribute("contenteditable");e?this.element.setAttribute("contenteditable",e):this.element.removeAttribute("contenteditable"),this.element.classList.toggle("k-disabled",!e)}getPos(){let e=this.element,t=window.getSelection(),r=s(t.focusNode,t.focusOffset),n=s(t.anchorNode,t.anchorOffset);if(null!=r&&null!=n){if(r>n){let e=r;r=n,n=e}return{begin:r,end:n,collapsed:r===n}}function s(t,r){try{!function e(n){if(n===t)throw r;if(1===n.nodeType)for(let t=n.firstChild;t;t=t.nextSibling)e(t);else 3===n.nodeType&&(r+=n.nodeValue.length)}(e)}catch(e){return e}}}setPos(e,t){let r=this.element;function n(e,t){try{!function e(r){if(3===r.nodeType){let e=r.nodeValue.length;if(e>=t)throw r;t-=e}else if(1===r.nodeType)for(let t=r.firstChild;t;t=t.nextSibling)e(t)}(e)}catch(e){return{node:e,pos:t}}}e=n(r,e),t=null!=t?n(r,t):e,e&&t&&this._setRange(e,t)}end(){this.setPos(this.length())}home(){this.setPos(0)}select(){this.setPos(0,this.length())}length(){return this.value().length}_setRange(e,t){let r=document.createRange();r.setStart(e.node,e.pos),r.setEnd(t.node,t.pos);let n=window.getSelection(),s=n.getRangeAt(0);var i,o;o=s,((i=r).startOffset!==o.startOffset||i.endOffset!==o.endOffset||i.startContainer!==o.endContainer||i.endContainer!==o.endContainer)&&(n.removeAllRanges(),n.addRange(r))}_formulaSource(){let e,t=[];for(let r in te.runtime.FUNCS)Jn.test(r)||(e=r.toUpperCase(),t.push({value:e,text:e}));this.formulaSource=t}get list(){return this.input.current.list}get popup(){return this.input.current.popup}_formulaList(){this.list.data(this.formulaSource),this.list.itemClick((e=>{this._formulaListChange(e)}))}_formulaListChange(e){let t=this._tokenContext();if(!t||this._mute)return;let r=t.token,n=e,s={replace:!0,token:r,end:r.end};t.nextToken&&"("===t.nextToken.value||(n+="("),this._replaceAt(s,n),this.popup.close()}_blur(){this.popup.close(),clearTimeout(this._focusId),this.trigger("blur")}_isFormula(){return/^=/.test(this.value())}_keydown(e){let t=e.keyCode,r=this;Yn[t]?(r.popup.close(),r._navigated=!0):r._move(t)&&(r._navigated=!0,e.preventDefault()),r._keyDownTimeout=setTimeout(r._syntaxHighlight.bind(r))}_keyup(){let e,t=this.popup;if(this._isFormula()&&!this._navigated){e=((this._tokenContext()||{}).token||{}).value;const r=this.filter(e);e&&r.length?(t[t.visible()?"position":"open"](),setTimeout((()=>{this.list.focusFirst()}),0)):t.close()}this._navigated=!1,this._syntaxHighlight(),this.trigger("keyup")}_input(){this._syntaxHighlight()}_focus(){setTimeout(this._sync.bind(this)),this._focusTimeout=setTimeout(this._syntaxHighlight.bind(this)),this.trigger("focus")}_paste(e){e.preventDefault();let t,r=this.getPos();t=e.clipboardData.getData("text/plain");let n=this.value();n=n.substr(0,r.begin)+t+n.substr(r.end),this.value(n),this.setPos(r.begin+t.length),this.scale()}_move(e){let t=this.list,r=this.popup;if(r.visible()){if(e===C)return t.focusNext(),!0;if(e===A)return t.focusPrev(),!0;if(e===_||e===b){let e="function"==typeof t.focusIndex?t.focusIndex():t.focus();return t.data()[e]&&this._formulaListChange(t.data()[e].value),r.close(),!0}if(e===x)return t.focusFirst(),!0;if(e===k)return t.focusLast(),!0}return!1}_tokenContext(){let e=this.getPos(),t=this.value();if(!t||!e||!e.collapsed)return null;let r,n=te.tokenize(t,this.row(),this.col());for(let t=0;t<n.length;++t)if(r=n[t],Kn(r,e)&&/^(?:str|sym|func)$/.test(r.type))return{token:r,nextToken:n[t+1]};return null}_sync(){this._editorToSync&&this.isActive()&&this._editorToSync.value(this.value())}_textContainer(){let e=function(e,t){let r,n={};return document.defaultView&&document.defaultView.getComputedStyle?(r=document.defaultView.getComputedStyle(e,""),t&&t.forEach((function(e){n[e]=r.getPropertyValue(e)}))):(r=e.currentStyle,t&&t.forEach((function(e){var t;n[e]=r[(t=e,t.replace(/\-(\w)/g,(function(e,t){return t.toUpperCase()})))]}))),function(e){let t,r=0;for(t in e)e.hasOwnProperty(t)&&"toJSON"!==t&&r++;return r}(n)||(n=r),n}(this.element,qn);e.position="absolute",e.visibility="hidden",e.whiteSpace="pre",e.top=-3333,e.left=-3333,this._span=document.createElement("span"),this._span.style.whiteSpace="pre";for(const t in e)Object.hasOwnProperty.call(e,t)&&(this._span.style[t]=e[t]);W(this._span,this.element)}_tooltip(){this._cellTooltip=document.createElement("div"),this._cellTooltip.className="k-widget k-tooltip",this._cellTooltip.style.position="absolute",this._cellTooltip.style.display="none",this._cellTooltip.appendChild(document.createTextNode("A1")),W(this._cellTooltip,this.element)}tooltip(e){for(;this._cellTooltip.firstChild;)this._cellTooltip.removeChild(this._cellTooltip.firstChild);this._cellTooltip.appendChild(document.createTextNode(e))}toggleTooltip(e){this._cellTooltip.style.display=e?"":"none"}isActive(){return this.element===function(){try{return document.activeElement}catch(e){return document.documentElement.activeElement}}()}filter(e){if(!e||e.length<this.options.minLength)return;const t=this.formulaSource.filter((t=>String(t.value).toLowerCase().startsWith(e.toLowerCase())));return this.list.data(t),t}hide(){this.enable(!1),this.element.style.display="none",this._cellTooltip.style.display="none"}show(){this.enable(!0),this.element.style.display="block"}row(){if(this.activeCell)return this.activeCell.row}col(){if(this.activeCell)return this.activeCell.col}position(e){e&&(this.show(),this.element.style.top=e.top+1+"px",this.element.style.left=e.left+1+"px",this._cellTooltip.style.top=e.top-this._cellTooltip.offsetHeight-10+"px",this._cellTooltip.style.left=e.left+"px")}resize(e){e&&(this.element.style.width=e.width-1+"px",this.element.style.height=e.height-1+"px")}canInsertRef(e){return this._canInsertRef(e)}_canInsertRef(e){if(this.popup.visible())return null;let t,r,n,s=e,i=this.getPos();if(i&&this._isFormula()){if(0===i.begin)return null;for(t=te.tokenize(this.value(),this.row(),this.col()),n=0;n<t.length;++n){if(r=t[n],Kn(r,i))return a(r);if(o(r))return u(t[n-1],r)}return u(r,null)}return null;function o(e){return e.begin>i.begin}function a(e){if(e){if(/^(?:num|str|bool|sym|ref)$/.test(e.type))return{replace:!0,token:e,end:e.end};if(/^(?:op|punc|startexp)$/.test(e.type))return e.end===i.end?u(e,t[n+1]):u(t[n-1],e)}}function u(e,t){if(null==e)return null;if(null==t)return/^(?:op|startexp)$/.test(e.type)||Gn(e.value)?{token:e,end:i.end}:null;if(s){if("op"===e.type&&/^(?:punc|op)$/.test(t.type))return{token:e,end:i.end}}else{if("startexp"===e.type)return{token:e,end:i.end};if(/^(?:op|punc)$/.test(e.type)&&/^[,;({]$/.test(e.value))return{token:e,end:i.end};if(/^(?:ref|sym)/.test(e.type))return{token:e,replace:!0,end:e.end};if(/^(?:ref|sym)/.test(t.type))return{token:t,replace:!0,end:t.end}}return!1}}refAtPoint(e){let t=this._canInsertRef();if(t){let r=e.selection()._ref.simplify().clone().relative(0,0,3);e.isMerged(r)&&(r=r.topLeft),e!==this.activeSheet&&(r=r.setSheet(e.name(),!0)),this._replaceAt(t,r.print(0,0))}}_replaceAt(e,t){let r=this.value(),n=e.token,s=r.substr(e.end);r=r.substr(0,e.replace?n.begin:e.end)+t;let i=r.length;r+=s,this._value(r),this.setPos(i),this.scale(),this._syntaxHighlight()}syncWith(e){this._editorToSync=e,this.element&&(this.element.removeEventListener("input",this._sync),this.element.addEventListener("input",this._sync))}scale(){let e,t,r=this.element;this._span||this._textContainer(),this._span.innerHTML=r.innerHTML,e=this._span.offsetWidth+this.options.scalePadding,t=this._span.offsetHeight,e>r.offsetWidth&&(r.style.width=e+"px");t-1>r.offsetHeight&&(r.style.height=t-1+"px"),this._sync()}_value(e){if((this.element.innerText||this.element.textContent).replace(/\n$/,"")!==e){for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);this.element.appendChild(document.createTextNode(e))}}value(e){let t=(this.element.innerText||this.element.textContent).replace(/\n$/,"");if(void 0===e)return t;t!==e&&(this._value(e),this._syntaxHighlight())}highlightedRefs(){return this._highlightedRefs.slice()}_syntaxHighlight(){let e=this.getPos(),t=this.value(),r=Wn.classNames.series,n=[],s=0,i=[],o=[];e&&!e.collapsed||(/^=/.test(t)?(o=te.tokenize(t,this.row(),this.col()),o.forEach((function(t){if(t.active=!1,t.cls=["k-syntax-"+t.type],"ref"===t.type&&(t.colorClass=r[s++%r.length],t.cls.push(t.colorClass),n.push(t)),e&&"punc"===t.type)if(Gn(t.value))i.unshift(t);else if(")"===(o=t.value)||"]"===o||"}"===o){let r=i.shift();r?!function(e,t){return"("===t?")"===e:"["===t?"]"===e:"{"===t&&"}"===e}(t.value,r.value)?(t.cls.push("k-syntax-error"),r.cls.push("k-syntax-error")):(Kn(t,e)||Kn(r,e))&&(t.cls.push("k-syntax-paren-match"),r.cls.push("k-syntax-paren-match")):t.cls.push("k-syntax-error")}var o,a;e&&Kn(t,e)&&(t.cls.push("k-syntax-at-point"),t.active=!0),"func"!==t.type||(a=t.value,te.runtime.FUNCS[a.toLowerCase()])||e&&Kn(t,e)||t.cls.push("k-syntax-error")})),o.reverse().forEach((function(e){let r=e.begin,n=e.end,s=function(e){return String(e).replace(Fr,"&amp;").replace(Rr,"&lt;").replace(Lr,"&gt;").replace(Sr,"&quot;").replace(Nr,"&#39;")}(t.substring(r,n));t=t.substr(0,r)+"<span class='"+e.cls.join(" ")+"'>"+s+"</span>"+t.substr(n)})),this.element.innerHTML=t,e&&this.setPos(e.begin,e.end),this._highlightedRefs=n):this._highlightedRefs.length&&(this._highlightedRefs=[],this._value(t)))}destroy(){this._editorToSync=null,this.element.removeEventListener("input",this.scale),this.element.removeEventListener("keydown",this._keydown),this.element.removeEventListener("keyup",this._keyup),this.element.removeEventListener("blur",this._blur),this.element.removeEventListener("input",this._input),this.element.removeEventListener("click",this._input),this.element.removeEventListener("focus",this._focus),this.element.removeEventListener("paste",this._paste),clearTimeout(this._focusTimeout),clearTimeout(this._keyDownTimeout),this._cellTooltip=null,this._span=null,super.destroy()}insertNewline(){let e=this.value(),t=this.getPos(),r=t.end===e.length;e=e.substr(0,t.begin)+(r?"\n\n":"\n"+e.substr(t.end)),this.value(e),this.setPos(t.begin+1)}}function Gn(e){return"("===e||"["===e||"{"===e}function Kn(e,t){return e.begin<=t.begin&&e.end>=t.end}Xn.classNames={wrapper:"k-spreadsheet-formula-input",listWrapper:"k-spreadsheet-formula-list"};class Qn extends Mr{constructor(e,t){super(e,t);const r=e&&e.querySelector(".k-spreadsheet-formula-input:not(.k-spreadsheet-cell-editor)");this.formulaInput=new Xn(r,this.options)}destroy(){this.formulaInput&&this.formulaInput.destroy(),this.formulaInput=null}}class Zn extends Mr{readData(){const e=[];return this._workbook.forEachName((function(t){!t.hidden&&t.value instanceof u&&e.push({name:t.name})})),e}value(e){if(this.options.combobox.current)return this.options.combobox.current.value(e)}}class es extends Mr{constructor(e,t){super(e,Object.assign({},{name:"SheetsBar"},t)),this.events=["select","reorder","rename"]}onSheetReorderEnd(e){this.trigger("reorder",{oldIndex:e.oldIndex,newIndex:e.newIndex})}onSheetRemove(e){this.trigger("remove",{name:e,confirmation:!0})}onSheetSelect(e){this.trigger("select",{name:e,isAddButton:!1})}onSheetRename(e,t){this.trigger("rename",{name:e,sheetIndex:t})}onAddSelect(){this.trigger("select",{isAddButton:!0})}destroy(){super.destroy()}}class ts{constructor(){this.cols=[],this.trs=[],this._height=0,this._width=0}addColumn(e){this._width+=e;let t=Be.element("col",{style:{width:e+"px"}});t.visible=e>0,this.cols.push(t)}addRow(e){let t=null;t={style:{height:e+"px"}},this._height+=e;let r=Be.element("tr",t);r.visible=e>0,this.trs.push(r)}addCell(e,t,r,n,s){null==t&&(t=""),t instanceof Be.Node||(t=Be.text(t));let i=[t];s&&!s.value&&(i.push(Be.element("span",{className:"k-dirty"})),n=(n||"")+(n?" ":"")+"k-dirty-cell",r.title=s.message),n&&(r.className=n);let o=Be.element("td",r,i);return this.trs[e].children.push(o),o}toDomTree(e,t,r){this.trs=this.trs.filter((function(e){return e.visible}));let n=0;return this.cols=this.cols.filter((function(e,t){return e.visible||(this.trs.forEach((function(e){e.children.splice(t-n,1)})),n++),e.visible}),this),Be.element("table",{style:{left:e+"px",top:t+"px",height:this._height+"px",width:this._width+"px"},className:r,role:"presentation"},[Be.element("colgroup",null,this.cols),Be.element("tbody",null,this.trs)])}}function rs(e,t,r){return e>=t&&e<=r}class ns extends kr{constructor(e,t){super();let r=ns.classNames;if(this.element=e,this.options=H({},{messages:m.view},this.options,t),this.events=["update","message"],this._chrome(),this._dialogs=[],this._formulaInput(),this.wrapper=e.querySelector(Tn+r.view),this.container=e.querySelector(Tn+r.fixedContainer),this.scroller=e.querySelector(Tn+r.scroller),this.clipboard=e.querySelector(Tn+r.clipboard),this.viewSize=this.scroller?this.scroller.querySelector(".k-spreadsheet-view-size")||this.scroller.firstElementChild:null,!this.viewSize)throw new Error("The scroller element does not contain a view size element.");this.tree=new Be.Tree(this.container),this.clipboardContents=new Be.Tree(this.clipboard),this.editor=new Er(this),this._sheetsbar(),this.options.createContextMenus?.()}enableClipboard(e){this.isClipboardDeactivated=!e,e?this.clipboard.setAttribute("contenteditable",e):this.clipboard.removeAttribute("contenteditable")}_resize(){}_chrome(){let e=this.element.querySelector(".k-spreadsheet-name-editor");this.nameEditor=new Zn(e,{combobox:this.options.nameBoxRef});let t=this.element.querySelector(".k-spreadsheet-formula-bar");this.formulaBar=new Qn(t,{input:this.options.formulaBarInputRef}),this._tabstrip()}_formulaInput(){let e=this.element.querySelector(Tn+ns.classNames.cellEditor);this.formulaInput=new Xn(e,{autoScale:!0,input:this.options.formulaCellInputRef})}_sheetsbar(){this.options.sheetsbar&&(this.sheetsbar=new es(this.element.querySelector(Tn+ns.classNames.sheetsBar),this.options.sheetsbar),this.options.createSheetBar?.(this.options.openDialogCallback))}_tabstrip(){this.tabstrip=this.options.createTabStrip?.()}_executeCommand(e){this._sheet.trigger("commandRequest",e)}workbook(e){this._workbook=e,e._view=this,this.nameEditor._workbook=e}sheet(e){this._sheet=e}activeCellRectangle(){return this.cellRectangle(this._sheet._viewActiveCell())}_rectangle(e,t){return e._grid.boundingRectangle(t.toRangeRef())}isColumnResizer(e,t,r){return e-=this._sheet._grid._headerWidth,t._grid.columns.frozen||(e+=this.scroller.scrollLeft),null===(r=this._sheet._grid._columns.locate(0,r,(function(t){return Math.abs(e-t)<=3.5})))||this._sheet.isHiddenColumn(r)?null:r}isRowResizer(e,t,r){return e-=this._sheet._grid._headerHeight,t._grid.rows.frozen||(e+=this.scroller.scrollTop),null===(r=this._sheet._grid._rows.locate(0,r,(function(t){return Math.abs(e-t)<=3.5})))||this._sheet.isHiddenRow(r)?null:r}isFilterIcon(e,t,r,n){let s=this,i=r._grid,o=i.rows.frozen?0:s.scroller.scrollTop,a=i.columns.frozen?0:s.scroller.scrollLeft;return e-=s._sheet._grid._headerWidth-a,t-=s._sheet._grid._headerHeight-o,B((function(i){s._sheet.forEachFilterHeader(n,(function(n){let o=s._rectangle(r,n);r.filterIconRect(o).intersects(e,t)&&i(!0)}))}))}isAutoFill(e,t,r){let n=this._sheet.select();if(n.size>1)return!1;e-=this._sheet._grid._headerWidth,t-=this._sheet._grid._headerHeight,r._grid.columns.frozen||(e+=this.scroller.scrollLeft),r._grid.rows.frozen||(t+=this.scroller.scrollTop);let s=this._rectangle(r,n);return Math.abs(s.right-e)<8&&Math.abs(s.bottom-t)<8}isEditButton(e,t,r){if(this._sheet.activeCellCustomEditor()){let n=this.activeCellRectangle();if(t>=n.top&&t<=n.bottom)return r._editorInLastColumn?e<n.left&&e>=n.left-20:e>n.right&&e<=n.right+20}}drawingAt(e,t,r){e-=this._sheet._grid._headerWidth,t-=this._sheet._grid._headerHeight,r._grid.columns.frozen||(e+=this.scroller.scrollLeft),r._grid.rows.frozen||(t+=this.scroller.scrollTop);let n=this._sheet,s=this._sheet._drawings;for(let r=s.length;--r>=0;){let i=s[r],o=n.drawingBoundingBox(i);if(o.intersects(e,t))return{drawing:i,drx:o.left-e,dry:o.top-t}}}objectAt(e,t,r){let n,s,i=this._sheet._grid;if(e<0||t<0||e>this.scroller.clientWidth||t>this.scroller.clientHeight)n={type:"outside"};else if(e<i._headerWidth&&t<i._headerHeight)n={type:"topcorner"};else if(s=this.paneAt(e,t),s){if(!r){let r=this.drawingAt(e,t,s);if(r)return{type:"drawing",drawing:r.drawing,drx:r.drx,dry:r.dry,pane:s,startX:e,startY:t}}let o=s._grid.rows.indexVisible(t,this.scroller.scrollTop),a=s._grid.columns.indexVisible(e,this.scroller.scrollLeft),u="cell",h=new c(o,a),l=this._sheet.selectionInProgress();this.isAutoFill(e,t,s)?u="autofill":this.isFilterIcon(e,t,s,h)?u="filtericon":!l&&e<i._headerWidth?(u="rowheader",null!==(o=this.isRowResizer(t,s,o))&&(h=new c(o,-1/0),u="rowresizehandle")):!l&&t<i._headerHeight?(u="columnheader",null!==(a=this.isColumnResizer(e,s,a))&&(h=new c(-1/0,a),u="columnresizehandle")):this.isEditButton(e,t,s)&&(u="editor"),n={type:u,ref:h}}else n={type:"outside"};return n.pane=s,n.x=e,n.y=t,n}paneAt(e,t){return this.panes.filter((function(r){let n=r._grid;return rs(t,n.top,n.bottom)&&rs(e,n.left,n.right)}))[0]}containingPane(e){return this.panes.filter((function(t){return!!t._grid.contains(e)}))[0]}cellRectangle(e){let t=this.containingPane(e)._grid;return this._sheet._grid.rectangle(e).offset(t.headerWidth-(t.columns.frozen?0:this.scroller.scrollLeft),t.headerHeight-(t.rows.frozen?0:this.scroller.scrollTop))}refresh(e){let t=this._sheet;if(this.trigger("update",{reason:e,range:t.range(t.activeCell()),sheet:t}),this._resize(),this.viewSize.style.height=t._grid.totalHeight()+"px",this.viewSize.style.width=t._grid.totalWidth()+"px",e.layout){let e=t.frozenColumns(),r=t.frozenRows();this.panes=[this._pane(r,e)],e>0&&this.panes.push(this._pane(r,0,null,e)),r>0&&this.panes.push(this._pane(0,e,r,null)),r>0&&e>0&&this.panes.push(this._pane(0,0,r,e))}e.filter&&this._destroyFilterMenu(),e.activeCell&&(this._focus=t.activeCell().toRangeRef())}createFilterMenu(e){this._destroyFilterMenu();let t=this._sheet,r=t.filter().ref,n={column:e,range:new fr(r,t)};return this._filterMenu=this.options.createFilterMenu(n),this._filterMenu}selectClipboardContents(){this.isClipboardDeactivated||(this.clipboard.focus({preventScroll:!0}),function(e){let t=window.getSelection();t.removeAllRanges();let r=document.createRange();r.selectNodeContents(e),t.addRange(r)}(this.clipboard))}scrollIntoView(e){let t=!1,r=this.containingPane(e)._grid,n=r.scrollBoundaries(e),s=this.scroller,i=r.rows.frozen?0:s.scrollTop,o=r.columns.frozen?0:s.scrollLeft;return n.top<i&&(t=!0,s.scrollTop=n.scrollTop),n.bottom>i&&(t=!0,s.scrollTop=n.scrollBottom),n.left<o&&(t=!0,s.scrollLeft=n.scrollLeft),n.right>o&&(t=!0,s.scrollLeft=n.scrollRight),t}_destroyDialog(){this._dialogs.pop()}openCustomEditor(){let e=this,t=e._sheet.activeCell().first(),r=e._sheet.activeCellCustomEditor(),n=e._sheet.range(t);r.edit({range:n,rect:e.activeCellRectangle(),view:this,validation:this._sheet.validation(t),callback:function(t,r){e._executeCommand({command:"EditCommand",options:{operatingRange:n,editRange:n,property:r?"input":"value",value:t}})}})}openDialog(e,t){let r=this._sheet;return r.withCultureDecimals(function(){let n=r.activeCell(),s=new fr(n,r),i={...t,name:e,ref:n,range:s};return this.trigger("message",i),i.dialog}.bind(this))}showError(e,t){let r=this._dialogs,n=this.options.messages.errors;if(r.length>0)return;let s=function(){r.pop(),this.selectClipboardContents(),t&&t()}.bind(this);const i={title:e.title||"Error",text:e.body?e.body:n[e.type],close:s};r.push(i),this.openDialog(e.type||"message",i)}destroy(){this.unbind(),[this.tree,this.clipboardContents].forEach((e=>{for(;e&&e.root&&e.root.lastChild;)e.root.removeChild(e.root.lastChild)})),this.tree=this.clipboardContents=null,this.tabstrip&&(this.tabstrip.destroy(),this.tabstrip=null),this._destroyFilterMenu()}_destroyFilterMenu(){this._filterMenu&&(this._filterMenu.destroy(),this._filterMenu=void 0)}render(e){let t=this._sheet,r=t.focus(),n=j(),s=this.wrapper.clientWidth-n,i=this.wrapper.clientHeight-n;if(r&&this.scrollIntoView(r))return;let o=t.resizingInProgress()?t.resizeHandlePosition().col===-1/0?"column":"row":"none";this.wrapper.classList.toggle(zn.editContainer,this.editor.isActive()),this.wrapper.classList.toggle(zn.horizontalResize,"row"===o),this.wrapper.classList.toggle(zn.verticalResize,"column"===o);let a=t._grid,u=[],h={scroller:this.scroller,toplevelElements:u,contentWidth:s,contentHeight:i};this.panes.forEach((function(e){u.push(e.render(h))}));let l=Be.element("div",{style:{width:a._headerWidth+"px",height:a._headerHeight+"px"},className:ns.classNames.topCorner});u.push(l),t.resizeHandlePosition()&&t.resizeHintPosition()&&u.push(this.renderResizeHint()),this.tree.render(u),this.container.style.width=s+"px",this.container.style.height=i+"px",this.editor.isActive()?this.editor.toggleTooltip(this.activeCellRectangle()):e.resize||e.comment||t.selectionInProgress()||t.resizingInProgress()||t.draggingInProgress()||t.isInEditMode()||this.renderClipboardContents()}renderResizeHint(){let e,t=this._sheet,r=t.resizeHandlePosition().col!==-1/0;e=r?{height:this.scroller.clientHeight+"px",width:"7px",left:t.resizeHintPosition().x+"px",top:"0px"}:{height:"7px",width:this.scroller.clientWidth+"px",top:t.resizeHintPosition().y+"px",left:"0px"};let n=Wn.classNames;return Be.element("div",{className:n.resizeHint+(r?"":" "+n.resizeHintVertical),style:e},[Be.element("div",{className:n.resizeHintHandle}),Be.element("div",{className:n.resizeHintMarker})])}renderClipboardContents(){let e=this._sheet,t=e._grid,r=t.normalize(e.select().toRangeRef()),n=this._workbook.clipboard().canCopy();if(!1===n.canCopy&&n.multiSelection)return this.clipboardContents.render([]),void this.selectClipboardContents();r=e.trim(r);let s=new ts,i=t.rangeDimensions(r);i.rows.forEach((function(e){s.addRow(e)})),i.columns.forEach((function(e){s.addColumn(e)}));let o=e._getMergedCells(r),a=o.primary,u=o.secondary;e.forEach(r,(function(e,t,n){let i=new c(e,t).print();if(!u[i]){let t=function(e,t,r){let n={};r.background&&(n.backgroundColor=r.background),r.color&&(n.color=r.color),r.fontFamily&&(n.fontFamily=r.fontFamily),r.underline&&(n.textDecoration="underline"),r.italic&&(n.fontStyle="italic"),r.textAlign&&(n.textAlign=r.textAlign),r.verticalAlign&&(n.verticalAlign="center"===r.verticalAlign?"middle":r.verticalAlign),r.bold&&(n.fontWeight="bold"),r.fontSize&&(n.fontSize=r.fontSize+"px"),!0===r.wrap&&(n.whiteSpace="pre-wrap"),r.borderRight?n.borderRight=Pn(r.borderRight):r.background&&(n.borderRightColor=r.background),r.borderBottom?n.borderBottom=Pn(r.borderBottom):r.background&&(n.borderBottomColor=r.background);let s=r.value,i=typeof s,o=r.format;o||"number"!==i||s===Math.floor(s)||(o="0.##############"),o&&null!=s&&(s=Je.format(s,o),s.__dataType&&(i=s.__dataType));let a={style:n};if(!n.textAlign)switch(i){case"number":case"date":case"percent":case"currency":n.textAlign="right";break;case"boolean":n.textAlign="center"}/^(?:string|undefined)$/.test(i)||(a.sdval=r.value,a["data-sheets-value"]=JSON.stringify({1:3,3:r.value}),o&&(a.sdnum=o,a["data-sheets-numberformat"]=JSON.stringify({1:2,2:o,3:1}))),r.formula&&(a["data-sheets-formula"]="="+r.formula.print());let u=null;!1===r.enable&&(u="k-disabled");let h,l,c=e.addCell(t,s,a,u,r.validation);return r.borderLeft?(l=function(e,t){let r=e.trs[t].children;return r[r.length-2]}(e,t),h=Pn(r.borderLeft),l&&h&&(l.attr.style.borderRight=h)):r.background&&(n.borderLeftColor=r.background),r.borderTop?(l=function(e,t){let r=e.trs[t-1],n=e.trs[t].children.length-1;if(r&&n>=0)return r.children[n]}(e,t),h=Pn(r.borderTop),l&&h&&(l.attr.style.borderBottom=h)):r.background&&(n.borderTopColor=r.background),c}(s,e-r.topLeft.row,n),o=a[i];o&&(t.attr.colspan=o.width(),t.attr.rowspan=o.height())}})),this.clipboardContents.render([s.toDomTree(0,0,"kendo-clipboard-"+this._workbook.clipboard()._uid)]),this.selectClipboardContents()}_pane(e,t,r,n){let s=new Wn(this._sheet,this._sheet._grid.pane({row:e,column:t,rowCount:r,columnCount:n}),this.options.getIconHTMLString);return s.refresh(this.scroller.clientWidth,this.scroller.clientHeight),s}}ns.classNames=zn;const ss=/<table[^>]+>/gim,is=e=>(e||"").match(ss)||[];class os{constructor(e){this._content={},this._externalContent={},this._internalContent={},this.workbook=e,this.origin=h,this.iframe=document.createElement("iframe"),this.iframe.className="k-spreadsheet-clipboard-paste",this.iframe.setAttribute("title","Spreadsheet clipboard iframe"),this.menuInvoked=!1,this._uid=function(){let e,t,r="";for(r+="abcdef"[Math.floor(Math.random()*Math.floor(6))],e=1;e<32;e++)t=16*Math.random()|0,8!==e&&12!==e&&16!==e&&20!==e||(r+="-"),r+=(12===e?4:16===e?3&t|8:t).toString(16);return r}(),document.body.appendChild(this.iframe)}destroy(){this.iframe&&this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe)}canCopy(){let e={canCopy:!0},t=this.workbook.activeSheet().select();return t===h&&(e.canCopy=!1),t instanceof p&&(e.canCopy=!1,e.multiSelection=!0),this.menuInvoked&&(e.canCopy=!1,e.menuInvoked=!0),e}canPaste(){let e=this.workbook.activeSheet(),t=this.pasteRef(),r={canPaste:!0,pasteOnMerged:!1,pasteOnDisabled:!1};return e.range(t).enable()||(r.canPaste=!1,r.pasteOnDisabled=!0),t.eq(e.unionWithMerged(t))||(r.canPaste=!1,r.pasteOnMerged=!0),this.menuInvoked&&(r.canPaste=!1,r.menuInvoked=!0),r}intersectsMerged(){let e=this.workbook.activeSheet();this.parse(),this.origin=this._content.origRef;let t=this.pasteRef();return!t.eq(e.unionWithMerged(t))}copy(){let e=this.workbook.activeSheet();this.origin=e.select(),this._internalContent=e.selection().getState(),delete this._externalContent.html,delete this._externalContent.plain}cut(){let e=this.workbook.activeSheet();this.copy(),e.range(e.select()).clear()}pasteRef(){let e=this.workbook.activeSheet();if(this.origin===h)return e.select();let t=e.activeCell().first(),r=this.origin.first(),n=r.row-t.row,s=r.col-t.col;return this.origin.relative(n,s,3)}paste(){let e=this.workbook.activeSheet(),t=this.pasteRef();(t.bottomRight.row>=e._rows._count||t.bottomRight.col>=e._columns._count)&&e.resize(Math.max(t.bottomRight.row+1,e._rows._count),Math.max(t.bottomRight.col+1,e._columns._count)),e.range(t).setState(this._content,this),e.triggerChange({recalc:!0,ref:t})}external(e){if(!e||!e.html&&!e.plain)return this._externalContent;this._externalContent=e}isExternal(){return!this._isInternal()}parse(){let e;if(this._isInternal())e=this._internalContent;else{let t=this._externalContent;if(e=t.plain?function(e){let t=as();if(-1===e.indexOf("\t")&&-1===e.indexOf("\n"))us(t,0,0,{value:e});else{let r=e.split("\n");for(let e=0;e<r.length;e++){let n=r[e].split("\t");for(let r=0;r<n.length;r++)us(t,e,r,{value:n[r]})}}return t}(t.plain):as(),t.html){let r=this.iframe.contentWindow.document;r.open(),r.write(t.html),r.close();let n=r.querySelector("table"),s=r.head.querySelector("meta[name=ProgId]")?.getAttribute("content");if(n){let t=function(e,t){let r=as(),n=[],s=0,i=0;for(let t=0;t<e.rows.length;++t)n.push([]);let o=new te.runtime.Matrix,a=new te.runtime.Matrix;for(let u=0;u<e.rows.length;++u,++s){let h=e.rows[u];i=0;for(let e=0;e<h.cells.length;++e){let u=h.cells[e],l=u.rowSpan,p=u.colSpan;for(;n[s][i];)i++;let d=u.getAttribute("style"),g=/mso-ignore:colspan/.test(d);us(r,s,i,ls(s,i,u,o,a,t)),(l>1||p>1&&!g)&&r.mergedCells.push(new f(new c(s,i),new c(s+l-1,i+p-1)).toString());for(let e=s+l;--e>=s;)for(let t=i+p;--t>=i;)e<n.length&&(n[e][t]=!0,e===s&&t===i||us(r,e,t,{}))}}return r}(n,s);t.data.forEach((function(t,r){t.forEach((function(t,n){/^\s*#+\s*$/.test(t.value)&&(t.value=e.data[r][n].value)}))})),e=t}}this.origin=e.origRef}this._content=e}_isInternal(){if(void 0===this._externalContent.html)return!0;const e="kendo-clipboard-"+this._uid,t=t=>t.some((t=>t.includes(e)));return t(is(this._externalContent.html))||t(is(this._externalContent.plain))}}function as(){let e=new c(0,0,0);return{ref:e,mergedCells:[],data:[],foreign:!0,origRef:e.toRangeRef()}}function us(e,t,r,n){let s=e.data||(e.data=[]);s[t]||(s[t]=[]),s[t][r]=n;let i=e.origRef.bottomRight;i.row=Math.max(i.row,t),i.col=Math.max(i.col,r)}function hs(e){return e.replace(/^-(?:ms|moz|webkit)-/,"")}function ls(e,t,r,n,s,i){let o,a,u,h=window.getComputedStyle(r),l="string"==typeof i&&i.indexOf("Excel")>-1;!l&&(o=r.getAttribute("data-sheets-value"))&&(o=JSON.parse(o),o=o[o[1]]),!l&&(a=r.getAttribute("data-sheets-numberformat"))&&(a=JSON.parse(a),a=a[a[1]]),u=r.getAttribute("data-sheets-formula"),l||null!=o||null!=a||null!=u||(o=r.getAttribute("sdval"),a=r.getAttribute("sdnum"),a&&(a=a.replace(/^1033;(?:0;)?/,""))),null==o&&(o=(r.innerText||r.textContent).replace(/\t$/,""));let c=function(e,t){e.className||(t=e.style);let r={};return["borderBottom","borderRight","borderLeft","borderTop"].forEach((function(e){let n=t[e+"Width"];n&&(n=parseInt(n,10)),n&&(r[e]={size:n,color:t[e+"Color"]||"#000"})})),r}(r,h),f={value:""===o?null:o,formula:u,borderTop:c.borderTop||n.get(e,t)||null,borderBottom:c.borderBottom||n.get(e+1,t)||null,borderLeft:c.borderLeft||s.get(e,t)||null,borderRight:c.borderRight||s.get(e,t+1)||null,fontSize:parseInt(h.fontSize,10)};null!=a&&(f.format=a),n.set(e,t,f.borderTop),n.set(e+1,t,f.borderBottom),s.set(e,t,f.borderLeft),s.set(e,t+1,f.borderRight),"rgb(0, 0, 0)"!==h.backgroundColor&&"rgba(0, 0, 0, 0)"!==h.backgroundColor&&(f.background=h.backgroundColor),"right"!==hs(h.textAlign)&&(f.textAlign=hs(h.textAlign)),"middle"!==h.verticalAlign&&(f.verticalAlign=h.verticalAlign),"normal"!==h.wordWrap&&(f.wrap=!0);const p=r.querySelector("font");return p&&(h=window.getComputedStyle(p)),"rgb(0, 0, 0)"!==h.color&&"rgba(0, 0, 0, 0)"!==h.color&&(f.color=h.color),/^underline/.test(h.textDecoration)&&(f.underline=!0),"italic"==h.fontStyle&&(f.italic=!0),/^(?:bold|[67]00)$/i.test(h.fontWeight)&&(f.bold=!0),f}let cs="autoFill",fs="clear",ps="cut",ds="edit",gs="paste",ms="validation";const vs=()=>{};class ys{constructor(e){this.options=e,this._workbook=e.workbook,this._property=e&&e.property,this._state={}}range(e){return void 0!==e&&this._setRange(e),this._range}_setRange(e){this._range=e}redo(){this.range().select(),this.exec()}undo(){this.setState(this._state)}getState(){this._state=this.range().getState(this._property)}setState(e){this.range().setState(e)}rejectState(e){return this.undo(),{title:e.title,body:e.message,reason:"error",type:"validationError"}}_forEachCell(e){let t=this.range();t._ref.forEach(function(r){t.sheet().forEach(r.toRangeRef(),e.bind(this))}.bind(this))}usesImage(){return!1}}class ws extends ys{constructor(e){super(e),this._sheet=e.sheet,this._drawing=e.drawing,this._orig=this._drawing.clone(),this._previous=e.previous}exec(){}undo(){this._drawing.reset(this._previous),this._sheet._activeDrawing=this._drawing,this._sheet.triggerChange({layout:!0})}redo(){this._drawing.reset(this._orig),this._sheet._activeDrawing=this._drawing,this._sheet.triggerChange({layout:!0})}usesImage(e){return this._drawing.image===e||this._orig.image===e||this._previous.image===e}}class bs extends ys{constructor(e){super(e),this._drawing=e.drawing}usesImage(e){return this._drawing.image===e}}class _s extends bs{constructor(e){super(e),this._blob=e.blob,this._width=e.width,this._height=e.height}exec(){let e=this.range(),t=e.sheet(),r=this._width,n=this._height,s=r/n;r>n?(r=Math.min(r,300),n=r/s):(n=Math.min(n,300),r=n*s),this._drawing=t.addDrawing({topLeftCell:e.topLeft(),offsetX:5,offsetY:5,width:r,height:n,opacity:1,image:this._workbook.addImage(this._blob)},!0),this._blob=null}undo(){let e=this.range().sheet();e._activeDrawing=null,e.removeDrawing(this._drawing)}redo(){let e=this.range().sheet();e._activeDrawing=this._drawing,e.addDrawing(this._drawing)}}class As extends bs{exec(){let e=this.range().sheet();e._activeDrawing=null,e.removeDrawing(this._drawing)}undo(){let e=this.range().sheet();e._activeDrawing=this._drawing,e.addDrawing(this._drawing)}redo(){this.exec()}}class Cs extends bs{exec(){let e=this.range().sheet();this._origIndex=e._drawings.indexOf(this._drawing),e._drawings.splice(this._origIndex,1),this._newIndex=this._reorder(),e._drawings.splice(this._newIndex,0,this._drawing),e.triggerChange({drawings:!0})}undo(){let e=this.range().sheet();e._drawings.splice(this._newIndex,1),e._drawings.splice(this._origIndex,0,this._drawing),e.triggerChange({drawings:!0})}}class xs extends Cs{_reorder(){return this.range().sheet()._drawings.length}}class ks extends Cs{_reorder(){return 0}}class Ms extends ys{constructor(e){super(e),this._target=e.target,this._value=e.value}exec(){this.getState(),this.setState(this._value)}}class Es extends Ms{getState(){this._state=this.range().sheet().columnWidth(this._target)}setState(e){this.range().sheet().columnWidth(this._target,e)}}class Fs extends Ms{getState(){this._state=this.range().sheet().rowHeight(this._target)}setState(e){this.range().sheet().rowHeight(this._target,e)}}class Rs extends ys{constructor(e){super(e),this._link=e.link}exec(){let e=this.range();this._prevLink=e.link(),this._prevUnderline=e.underline(),e.link(this._link),e.underline(!0),null==e.value()&&(this._hasSetValue=!0,e.value(this._link))}undo(){let e=this.range();e.link(this._prevLink),e.underline(this._prevUnderline),this._hasSetValue&&e.value(null)}}class Ss extends Ms{getState(){this._state=this._range.sheet().showGridLines()}setState(e){this._range.sheet().showGridLines(e)}}class Ns extends ys{_setRange(e){ys.prototype._setRange.call(this,e.skipHiddenCells())}constructor(e){super(e),this._value=e.value}exec(){let e=this.range();e.enable()&&(this.getState(),"format"===this.options.property&&this._workbook.trigger("changeFormat",{range:e}),e[this._property](this._value))}}class Ls extends Ns{exec(){let e=this.range();e.enable()&&(this.getState(),e.clearFormat())}}class Ds extends ys{exec(){let e,t,r,n,s,i=[];return this.range().enable()?this.range().canEditArrayFormula()?(this.getState(),e=this.range().skipHiddenCells(),e._ref.refs&&e._ref.refs.length>1?e._ref.refs.forEach((function(t){s=e.sheet().range(t),i=i.concat(s.values())})):i=e.values(),r=[],i.forEach((function(e){t=[],e.forEach((function(){t.push(null)})),r.push(t)})),e.sheet().trigger("changing",{data:r,range:e,changeType:fs})?void 0:(e.clearContent(),n=e._getValidationState(),n?this.rejectState(n):void 0)):{reason:"error",type:"intersectsArray"}:{reason:"error",type:"cannotModifyDisabled"}}undo(){let e,t=this.range().skipHiddenCells(),r=t.sheet(),n=this._state.data,s=[];n.forEach((function(t){e=[],t.forEach((function(t){e.push(t.value)})),s.push(e)})),r.trigger("changing",{data:s,range:t,changeType:fs})||this.setState(this._state)}}class Us extends Ns{constructor(e){e.property=e.property||"input",super(e)}_setRange(e){Ns.prototype._setRange.apply(this,arguments),this._editRange=this.options.arrayFormula?e:e.sheet().activeCellSelection()}getState(){this._state=this.range().getState()}exec(){return this.range().sheet().withCultureDecimals(this._exec.bind(this))}undo(){let e=this._editRange,t=this._state;e.sheet().trigger("changing",{data:t.data[0][0].value,range:e,changeType:ds})||this.setState(this._state)}_exec(){let e=this.options.arrayFormula,t=this._editRange;if(!t.enable())return{reason:"error",type:"rangeDisabled"};if(!t.canEditArrayFormula())return{reason:"error",type:"intersectsArray"};let r=this._value;if(this.getState(),!this.range().sheet().trigger("changing",{data:r,range:this._editRange,changeType:ds}))if("value"!==this._property)try{t.link(null),""===r?t.value(null):(t.input(r,{arrayFormula:e}),/\n/.test(t.value())&&t.wrap(!0)),t._adjustRowHeight();let n=t._getValidationState();if(n)return this.rejectState(n)}catch(e){if(e instanceof te.runtime.ParseError)return{title:"Error in formula",body:e+"",reason:"error"};throw e}else t.value(r)}}class Vs extends Ns{constructor(e){e.property="comment",super(e)}}class $s extends Ns{constructor(e){e.property="wrap",super(e),this._value=e.value}getState(){let e={};this.range().forEachRow((function(t){let r=t.topLeft().row;e[r]=t.sheet().rowHeight(r)})),this._state=this.range().getState(this._property),this._rowHeight=e}undo(){let e=this.range().sheet(),t=this._rowHeight;this.range().setState(this._state);for(let r in t)e.rowHeight(r,t[r])}}class Bs extends ys{constructor(e){e.property="format",super(e),this._delta=e.value}exec(){let e=this.range().sheet(),t=this._delta;this.getState(),e.batch(function(){this.range().forEachCell((function(r,n,s){let i=s.format;if(!i){let e=s.value;"number"==typeof e&&/\./.test(e)&&(i="0."+String(e).split(".")[1].replace(/\d/g,"0"))}(i||t>0)&&(i=Je.adjustDecimals(i||"0",t),e.range(r,n).format(i))}))}.bind(this))}}class Is extends ys{constructor(e){e.property="border",super(e),this._type=e.border,this._style=e.style}_batch(e){return this.range().sheet().batch(e,{})}exec(){let e=this;e._type&&(e.getState(),e._batch((function(){e[e._type](e._style)})))}noBorders(){this.range().insideBorders(null),this.outsideBorders(null)}allBorders(e){this.range().insideBorders(e),this.outsideBorders(e)}leftBorder(e){this.range().leftColumn().borderLeft(e)}rightBorder(e){this.range().rightColumn().borderRight(e)}topBorder(e){this.range().topRow().borderTop(e)}bottomBorder(e){this.range().bottomRow().borderBottom(e)}outsideBorders(e){let t=this.range();t.leftColumn().borderLeft(e),t.topRow().borderTop(e),t.rightColumn().borderRight(e),t.bottomRow().borderBottom(e)}insideBorders(e){this.range().insideBorders(e),this.outsideBorders(null)}insideHorizontalBorders(e){this.range().insideHorizontalBorders(e)}insideVerticalBorders(e){this.range().insideVerticalBorders(e)}}class Ts extends ys{constructor(e){super(e),this._type=e.value}exec(){this.getState(),this[this._type](),this.range().sheet().triggerChange({recalc:!0})}activate(e){this.range().sheet().activeCell(e)}getState(){this._state=this.range().getState()}undo(){"unmerge"!==this._type&&(this.range().unmerge(),this.activate(this.range().topLeft())),this.range().setState(this._state)}cells(){let e=this.range(),t=e._ref;e.merge(),this.activate(t)}horizontally(){let e=this.range().topRow()._ref;this.range().forEachRow((function(e){e.merge()})),this.activate(e)}vertically(){let e=this.range().leftColumn()._ref;this.range().forEachColumn((function(e){e.merge()})),this.activate(e)}unmerge(){let e=this.range(),t=e._ref.topLeft;e.unmerge(),this.activate(t)}}class zs extends ys{constructor(e){super(e),this._type=e.value}exec(){this.getState(),this._topLeft=this.range().topLeft(),this[this._type]()}getState(){this._state=this.range().sheet().getState()}undo(){this.range().sheet().setState(this._state)}panes(){let e=this._topLeft;this.range().sheet().frozenColumns(e.col).frozenRows(e.row)}rows(){let e=this._topLeft;this.range().sheet().frozenRows(e.row)}columns(){let e=this._topLeft;this.range().sheet().frozenColumns(e.col)}unfreeze(){this.range().sheet().frozenRows(0).frozenColumns(0)}}class Hs extends ys{constructor(e){super(e),this._clipboard=e.workbook.clipboard(),this._clipboard.parse(),this._event=e.event,this._clipboardContent=this._clipboard._content,this._sheet=this._workbook.activeSheet(),this._range=this._sheet.selection?this._sheet.selection():this._sheet.range(this._clipboard.pasteRef()),this._state=this._range.getState(),this._targetRangeRefs=(this._range._ref instanceof p?this._range._ref.refs:[this._range._ref]).map((function(e){return e.toRangeRef()}))}exec(){return this.range().sheet().withCultureDecimals(this._exec.bind(this))}undo(){let e=this._sheet,t=this._range;e.trigger("changing",{data:this._state.data,range:t,changeType:gs})||this.setState(this._state)}_exec(){let e=this._clipboard.canPaste();if(!e.canPaste)return e.menuInvoked?{reason:"error",type:"useKeyboard"}:e.pasteOnMerged?{reason:"error",type:"modifyMerged"}:e.pasteOnDisabled?(this._event.preventDefault(),{reason:"error",type:"cannotModifyDisabled"}):{reason:"error"};let t=this._sheet,r=this._range;this._workbook.trigger("paste",{range:r,clipboardContent:this._clipboardContent})||t.trigger("changing",{data:this._clipboardContent.data,range:r,changeType:gs})?this._event.preventDefault():this._processPaste()}_adjustPasteTarget(e,t,r){let n,s,i,o,a,u,h,l=this,c=l._targetRangeRefs,d=l._sheet,g=[],m=function(e,t){let r=0,n=e.topLeft,s=t.topLeft;return n.row>s.row?r=1:n.row<s.row?r=-1:n.col>s.col?r=1:n.col<s.col&&(r=-1),r};for(u=0;u<c.length;u+=1)i=c[u],a=e[u],o=i.topLeft,h={row:a.rows*t+o.row-1,col:a.cols*r+o.col-1},n=new f(o,h),g.push(n);1===g.length?s=d.range(n):(g.sort(m),s=d.range(new p(g))),s.select(),l._range=s,l._state=l._range.getState()}_processPaste(){let e,t=this,r=t._sheet,n=t._clipboardContent,s=t._range,i=n.data,o=i.length,a=i[0].length,u=t._targetRangeRefs,h=t._targetRanges(o,a),l=this._clipboard.pasteRef();(l.bottomRight.row>=r._rows._count||l.bottomRight.col>=r._columns._count)&&r.resize(Math.max(l.bottomRight.row+1,r._rows._count),Math.max(l.bottomRight.col+1,r._columns._count)),t._adjustPasteTarget(h,o,a),r.batch((function(){for(e=0;e<u.length;e++)t._populateTargetRange(u[e],o,a,h[e])}),{recalc:!0,ref:t._range._ref}),s._adjustRowHeight()}_populateTargetRange(e,t,r,n){let s,i,o,a=e.topLeft;for(i=0;i<n.rows;i++)for(o=0;o<n.cols;o++)s=this._sheet.range(a.row+t*i,a.col+r*o),s.setState(this._clipboardContent,this._clipboard)}_targetRangeDimensions(e,t,r){let n=e.topLeft,s=e.bottomRight,i=s.row-n.row+1,o=s.col-n.col+1,a=1,u=1;return i%t==0&&o%r==0&&(a=i/t,u=o/r),{rows:a,cols:u}}_targetRanges(e,t){let r,n=this._targetRangeRefs,s=[];for(r=0;r<n.length;r++)s.push(this._targetRangeDimensions(n[r],e,t));return s}}class Ps extends ys{exec(){let e=this.options,t=this._workbook.activeSheet();(e.range||t.range(e.rowIndex))._adjustRowHeight()}}class Os extends ys{exec(){if(!qs().paste)return{reason:"error",type:"useKeyboard"};this._workbook._view.clipboard.focus({preventScroll:!0}),document.execCommand("paste")}}class js extends ys{constructor(e){super(e),this._eventType="cut",this._clipboard=e.workbook.clipboard(),this._event=e.event}exec(){let e,t,r=this._clipboard.canCopy(),n=[];if(!r.canCopy)return r.menuInvoked?{reason:"error",type:"useKeyboard"}:r.multiSelection?{reason:"error",type:"unsupportedSelection"}:void 0;let s=this._workbook.activeSheet().selection();if("cut"===this._eventType){if(!s.enable())return this._event.preventDefault(),{reason:"error",type:"cannotModifyDisabled"};this.getState()}if(this._workbook.trigger(this._eventType,{range:s}))this._event.preventDefault();else if("cut"===this._eventType){if(e=s.values(),e.forEach((function(e){t=[],e.forEach((function(){t.push({})})),n.push(t)})),s.sheet().trigger("changing",{data:n,range:s,changeType:ps}))return;this._clipboard.cut()}else this._clipboard.copy()}undo(){let e=this.range();e.sheet().trigger("changing",{data:this._state.data,range:e,changeType:ps})||this.setState(this._state)}}class Ws extends js{constructor(e){super(e),this._eventType="copy",this.undo=vs}}function qs(){return{copy:!!document.queryCommandSupported&&document.queryCommandSupported("copy"),cut:!!document.queryCommandSupported&&document.queryCommandSupported("cut"),paste:!!document.queryCommandSupported&&document.queryCommandSupported("paste")}}class Ys extends ys{constructor(e){super(e),this._clipboard=e.workbook.clipboard(),this.cannotUndo=!0}exec(){if(!qs().copy)return{reason:"error",type:"useKeyboard"};document.execCommand("copy")}}class Js extends ys{constructor(e){super(e)}origin(e){this._origin=e}exec(){let e,t=this.range();if(!t.enable())return{reason:"error",type:"rangeDisabled"};if(t.intersectingArrayFormula())return{reason:"error",type:"intersectsArray"};this.getState();try{if(e=t._previewFillFrom(this._origin),t.sheet().trigger("changing",{data:e.props,range:e.dest,changeType:cs}))return;e.dest._properties(e.props,!0)}catch(e){if(e instanceof fr.FillError)return{reason:"error",type:e.code};throw e}}undo(){let e=this.range(),t=this._state;e.sheet().trigger("changing",{data:t.data,range:e,changeType:cs})||this.setState(this._state)}}class Xs extends ys{constructor(e){super(e),this._clipboard=e.workbook.clipboard(),this.cannotUndo=!0}exec(){if(!qs().copy)return{reason:"error",type:"useKeyboard"};document.execCommand("cut")}}class Gs extends ys{undo(){this.range().filter(this._state)}exec(){let e=this.range();this._state=e.hasFilter(),e.filter(!this._state)}}class Ks extends ys{undo(){this.range().sheet().setState(this._state)}exec(){let e=this.range(),t=e.sheet(),r=t.activeCell(),n=this.options.sheet?r.topLeft.col:this.options.column||0,s="asc"===this.options.value;this._state=t.getState(),this.options.sheet&&(e=this.expandRange());let i=e.cantSort();if(i)return{reason:"error",type:i.code};e.sort({column:n,ascending:s})}expandRange(){let e=this.range().sheet();return new fr(e._sheetRef,e)}}class Qs extends ys{column(){return this.options.column||0}undo(){this.range().sheet().clearFilter(this.column()),this._state.length&&this.range().filter(this._state)}getState(){let e=this.range().sheet().filter();e&&(this._state=e.columns.filter(function(e){return e.index===this.column()}.bind(this)))}exec(){let e,t,r=this.range(),n=this.column(),s=r.sheet().filter(),i=!1;this.options.valueFilter?t={column:n,filter:new sn(this.options.valueFilter)}:this.options.customFilter&&(t={column:n,filter:new on(this.options.customFilter)}),this.getState(),s&&s.ref.eq(r._ref)&&s.columns.length?(s.columns.forEach((function(e){e.index===n&&(i=!0)})),e=s.columns.map((function(e){return e.index===n?t:{column:e.index,filter:e.filter}})),i||e.push(t)):e=t,r.filter(e)}}class Zs extends Qs{exec(){let e=this.range(),t=this.column();this.getState(),e.clearFilter(t)}}class ei extends ys{constructor(e){super(e),this.axis=e.axis}undo(){this.range().sheet().setAxisState(this._state)}exec(){let e=this.range().sheet();this._state=e.getAxisState(),"row"===this.axis?e.axisManager().hideSelectedRows():e.axisManager().hideSelectedColumns()}}class ti extends ei{exec(){let e=this.range().sheet();this._state=e.getAxisState(),"row"===this.axis?e.axisManager().unhideSelectedRows():e.axisManager().unhideSelectedColumns()}}class ri extends ys{exec(){this._expandedRange=this._expand(this.range()),this._state=this._expandedRange.getState(),this._indexes=this._exec(this._expandedRange.sheet())}undo(){let e=this,t=e._expandedRange,r=t.sheet();r.batch((function(){e._indexes.forEach((function(t){e._undoOne(r,t),r._restoreModifiedFormulas(t.formulas)})),t.setState(e._state)}),{layout:!0,recalc:!0,ref:t._ref,isValue:!0})}}class ni extends ri{_expand(e){return e.resize({left:-1/0,right:1/0})}_exec(e){return e.axisManager().deleteSelectedRows()}_undoOne(e,t){e.insertRow(t.index),e.rowHeight(t.index,t.height)}}class si extends ri{_expand(e){return e.resize({top:-1/0,bottom:1/0})}_exec(e){return e.axisManager().deleteSelectedColumns()}_undoOne(e,t){e.insertColumn(t.index),e.columnWidth(t.index,t.width)}}class ii extends ys{constructor(e){super(e),this._value=e.value}undo(){let e=this,t=e.range().sheet();t.batch((function(){for(let r=e._pos.count;--r>=0;)e._undoOne(t,e._pos.base)}),{layout:!0,recalc:!0})}}class oi extends ii{exec(){let e=this._value,t=this.range().sheet();this._pos="left"===e?t.axisManager().addColumnLeft():t.axisManager().addColumnRight()}_undoOne(e,t){e.deleteColumn(t)}}class ai extends ii{exec(){let e=this._value,t=this.range().sheet();this._pos="above"===e?t.axisManager().addRowAbove():t.axisManager().addRowBelow()}_undoOne(e,t){e.deleteRow(t)}}class ui extends ys{constructor(e){super(e),this._value=e.value}exec(){let e=this,t=e.range().sheet();if(this.getState(),!t.trigger("changing",{data:e._value,range:e.range(),changeType:ms}))try{t.withCultureDecimals((function(){e.range().validation(e._value)}))}catch(e){if(e instanceof te.runtime.ParseError)return{title:"Error in formula",body:e+"",reason:"error"};throw e}}undo(){let e=this.range(),t=this._state;e.sheet().trigger("changing",{data:t.data[0][0].validation,range:e,changeType:ms})||this.setState(this._state)}}class hi extends ys{constructor(e){super(e),this.cannotUndo=!0}exec(){if(null===this.options.file.name.match(/.xlsx$/i))return{reason:"error",type:"openUnsupported"};let e=this.options.workbook;e.fromFile(this.options.file);let t=e.excelImportErrors;t&&t.length&&e._view.openDialog("importError",{errors:t})}}class li extends ys{constructor(e){super(e),this.cannotUndo=!0}exec(){let e=this.options.name+this.options.extension;if(".xlsx"===this.options.extension)return this.options.workbook.saveAsExcel({fileName:e});".pdf"===this.options.extension&&this.options.workbook.saveAsPDF(H(this.options.pdf,{workbook:this.options.workbook,fileName:e}))}}class ci extends ys{constructor(e){super(e),this._name=e.name,this._value=e.value}getState(){this._state=this._workbook.nameDefinition(this._name)}setState(){this._workbook.nameDefinition(this._name,this._state),this._workbook.trigger("change",{recalc:!0})}}class fi extends ci{exec(){this.getState();try{this._workbook.defineName(this._name,this._value),this._workbook.trigger("change",{recalc:!0})}catch(e){return{title:"Error",body:e+"",reason:"error"}}}}class pi extends ci{exec(){this.getState(),this._workbook.undefineName(this._name),this._workbook.trigger("change",{recalc:!0})}}var di=Object.freeze({__proto__:null,AddColumnCommand:oi,AddCommand:ii,AddRowCommand:ai,AdjustDecimalsCommand:Bs,AdjustRowHeightCommand:Ps,ApplyFilterCommand:Qs,AutoFillCommand:Js,BorderChangeCommand:Is,BringToFrontCommand:xs,ClearContentCommand:Ds,ClearFilterCommand:Zs,ColumnWidthCommand:Es,Command:ys,CopyCommand:Ws,CutCommand:js,DefineNameCommand:fi,DeleteColumnCommand:si,DeleteCommand:ri,DeleteDrawingCommand:As,DeleteNameCommand:pi,DeleteRowCommand:ni,DrawingCommand:bs,DrawingUpdateCommand:ws,EditCommand:Us,EditValidationCommand:ui,FilterCommand:Gs,FreezePanesCommand:zs,GridLinesChangeCommand:Ss,HideLineCommand:ei,HyperlinkCommand:Rs,InsertCommentCommand:Vs,InsertImageCommand:_s,MergeCellCommand:Ts,NameCommand:ci,OpenCommand:hi,PasteCommand:Hs,PropertyChangeCommand:Ns,PropertyCleanCommand:Ls,ReorderDrawingsCommand:Cs,RowHeightCommand:Fs,SaveAsCommand:li,SendToBackCommand:ks,SortCommand:Ks,TargetValueCommand:Ms,TextWrapCommand:$s,ToolbarCopyCommand:Ys,ToolbarCutCommand:Xs,ToolbarPasteCommand:Os,UnHideLineCommand:ti});class gi extends kr{constructor(e){super(),this.options=e,this.events=["undo","redo"],this.clear()}push(e){this.stack=this.stack.slice(0,this.currentCommandIndex+1),this.currentCommandIndex=this.stack.push(e)-1}undo(){if(this.canUndo()){let e=this.stack[this.currentCommandIndex--];e.undo(),this.trigger("undo",{command:e})}}redo(){if(this.canRedo()){let e=this.stack[++this.currentCommandIndex];e.redo(),this.trigger("redo",{command:e})}}clear(){this.stack=[],this.currentCommandIndex=-1}canUndo(){return this.currentCommandIndex>=0}canRedo(){return this.currentCommandIndex!==this.stack.length-1}}let mi=String.fromCharCode,vi={amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:160};function yi(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}function wi(e,t){t>65535?(t-=65536,e.push(t>>>10&1023|55296,56320|1023&t)):e.push(t)}let bi=yi("<![CDATA["),_i=yi("]]>"),Ai=yi("--\x3e"),Ci=yi("!--"),xi=yi("/>"),ki=yi("</"),Mi=yi("?>"),Ei=yi("?"),Fi=yi("<"),Ri=yi(">"),Si=yi(";"),Ni=yi("="),Li=yi("&"),Di=yi('"'),Ui=yi("'"),Vi=yi("#"),$i=yi("x"),Bi=yi("X"),Ii={};function Ti(e,t){let r=0,n=[],s={is:function(e){let t=n.length,r=e.length;for(;--t>=0&&--r>=0;)if(n[t].$tag!==e[r]&&"*"!==e[r])return!1;return r<0?n[n.length-1]:null},exit:function(){throw Ii},stack:n};function i(t){let n=e[r++];240&n^240?224&n^224?192&n^192?t.push(n):wi(t,(31&n)<<6|63&e[r++]):wi(t,(15&n)<<12|(63&e[r++])<<6|63&e[r++]):wi(t,(3&n)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])}function o(e){throw new Error(e+", at "+r)}function a(t){let n=[];for(;r<e.length&&t(e[r]);)n.push(e[r++]);return n}function u(e){return mi.apply(0,a(e))}function h(){a(f)}function l(t){let n=r;for(let s=0;s<t.length;++s)if(e[r++]!==t[s])return r=n,!1;return t}function c(e){l(e)||o("Expecting "+e.join(", "))}function f(e){return 9===e||10===e||13===e||32===e}function p(e){return e>=48&&e<=57}function d(e){return e>=48&&e<=57||(e|=32)>=97&&e<=102}function g(e){return 58===e||95===e||(e|=32)>=97&&e<=122}function m(e){return 45===e||p(e)||g(e)}function v(){let t,s;l(Ei)?(A("decl",y(),_()),c(Mi)):l(Ci)?function(){let t=[];for(;r<e.length;){if(l(Ai))return A("comment",mi.apply(0,t));i(t)}}():(t=y(),s=_(t),n.push(s),l(xi)?A("enter",t,s,!0):(c(Ri),A("enter",t,s),function(t){let n=[];for(;r<e.length;){if(l(ki))return n.length&&A("text",mi.apply(0,n));if(l(bi))for(;r<e.length&&!l(_i);)i(n);else l(Fi)?(n.length&&A("text",mi.apply(0,n)),v(),n=[]):l(Li)?b(n):i(n)}o("Unclosed tag "+t)}(t),t!==y()&&o("Bad closing tag"),A("leave",t,s),h(),c(Ri)),n.pop())}function y(){return g(e[r])||o("Expecting XML name"),u(m)}function w(){let t=l(Di)||l(Ui);t||o("Expecting string");let n=[];for(;r<e.length;){if(l(t))return mi.apply(0,n);l(Li)?b(n):i(n)}o("Unfinished string")}function b(e){let t;if(l(Vi))t=l($i)||l(Bi)?parseInt(u(d),16):parseInt(u(p),10),isNaN(t)&&o("Bad numeric entity");else{let e=y();t=vi[e],void 0===t&&o("Unknown entity "+e)}wi(e,t),c(Si)}function _(t){let n={$tag:t};for(;r<e.length;){h();let t=e[r];if(63===t||62===t||47===t)break;n[y()]=(c(Ni),w())}return n}function A(e,r,n,i){let o=t&&t[e];o&&o.call(s,r,n,i)}let C=[];for(i(C),65279!==C[0]&&(r=0);r<e.length;)h(),c(Fi),v(),h()}const zi=function(){try{return Ti.apply(this,arguments)}catch(e){if(e!==Ii)throw e}};class Hi{constructor(){this._progressHandlers=[],this._resolved=!1,this._rejected=!1,this.promise=new window.Promise(((e,t)=>{this._resolve=t=>{this._resolved||this._rejected||(this._resolved=!0,e(t))},this._reject=e=>{this._resolved||this._rejected||(this._rejected=!0,t(e))}}))}resolve(e){return this._resolve(e),this}reject(e){return this._reject(e),this}notify(e){this._resolved||this._rejected||this._progressHandlers.forEach((t=>t(e)))}progress(e){return this._progressHandlers.push(e),this}then(e,t,r){return r&&this.progress(r),this.promise.then(e,t)}promise(){return this.promise}}let Pi={greaterThanOrEqual:"greaterThanOrEqualTo",lessThanOrEqual:"lessThanOrEqualTo"},Oi=null;function ji(e,r,n){let i=new FileReader;i.onload=async function(e){s.J.loadAsync(e.target.result).then((async e=>await async function(e,r,n){Oi=r.excelImportErrors=[];let s=await async function(e){let t=[],r=null;return await So(e,"xl/sharedStrings.xml",{leave:function(){this.is(ro)&&(t.push(r),r=null)},text:function(e){this.is(to)&&(null==r&&(r=""),r+=e)}}),t}(e),i=await No(e,"_rels/workbook.xml"),o=await async function(e,t){let r=[],n={colorScheme:r},s=wo(t);e.file(s)&&(await So(e,s,{enter:function(e,t){this.is(zo)?r.push(Oo("window"===t.val?"FFFFFFFF":"FF000000")):this.is(To)&&r.push(Oo("FF"+t.val))}}),r.length>3&&(i(r,0,1),i(r,2,3)));function i(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}return n}(e,i.byType.theme[0]),a=await async function(e,r){let n={fonts:[],numFmts:{},fills:[],borders:[],namedStyles:[],inlineStyles:[]},s=null,i=null,o=null,a=null;function u(e){let t={borderId:Ho(e.borderId),fillId:Ho(e.fillId),fontId:Ho(e.fontId),numFmtId:Ho(e.numFmtId),pivotButton:Po(e.pivotButton),quotePrefix:Po(e.quotePrefix),xfId:Ho(e.xfId)};function r(r){if(null!=e[r])return t[r]=Po(e[r])}return r("applyAlignment"),r("applyBorder"),r("applyFill"),r("applyFont"),r("applyNumberFormat"),r("applyProtection")&&(t.protection={locked:!0}),t}function h(e,n){if(e.rgb)return Oo(e.rgb);if(e.indexed)return Io[Ho(e.indexed)];if(e.theme){let s=r.colorScheme[Ho(e.theme)];if(!s)return n;let i=t.p(s);if(e.tint){i=i.toHSL();let t=parseFloat(e.tint);i.l=t<0?i.l*(1+t):i.l*(1-t)+(100-100*(1-t))}return i.toCssRgba()}}return await So(e,"xl/styles.xml",{enter:function(e,t,r){if(this.is(Bo))n.numFmts[t.numFmtId]=t;else if(this.is(Uo))n.fonts.push(s={}),r&&(s=null);else if(s)"sz"===e?s.size=parseFloat(t.val):"name"===e?s.name=t.val:"b"===e?s.bold=Po(t.val,!0):"i"===e?s.italic=Po(t.val,!0):"u"===e?s.underline=null==t.val||"single"===t.val:"color"===e&&(s.color=h(t,null));else if(this.is(Do))n.fills.push(i={}),r&&(i=null);else if(i)"patternFill"===e?i.type=t.patternType:("fgColor"===e&&"solid"===i.type||"bgColor"===e&&"solid"!==i.type)&&(i.color=h(t,Io[0]));else if(this.is(Lo))n.borders.push(o={diagonalUp:+Po(t.diagonalUp,0),diagonalDown:+Po(t.diagonalDown,0)}),r&&(o=null);else if(o){if(/^(?:left|top|right|bottom|diagonal)$/.test(e)&&(o[e]={style:t.style||"none"},"diagonal"===e&&(o.diagonal.up=o.diagonalUp,o.diagonal.down=o.diagonalDown)),"color"===e){let e=this.stack[this.stack.length-2].$tag;o[e].color=h(t,Io[0])}}else this.is($o)?(a=u(t),n.namedStyles.push(a),r&&(a=null)):this.is(Vo)?(a=u(t),n.inlineStyles.push(a),r&&(a=null)):a&&("alignment"===e?(/^(?:left|center|right|justify)$/.test(t.horizontal)&&(a.textAlign=t.horizontal),/^(?:top|center|bottom)$/.test(t.vertical)&&(a.verticalAlign=t.vertical),null!=t.wrapText&&(a.wrapText=Po(t.wrapText)),null!=t.indent&&(a.indent=Ho(t.indent))):"protection"==e&&(a.protection={locked:Po(t.locked)}))},leave:function(e){this.is(Uo)?s=null:this.is(Do)?i=null:this.is(Lo)?o=null:"xf"===e&&(a=null)}}),n}(e,o),u=[],h=0;await So(e,"xl/workbook.xml",{enter:function(t,n){if(this.is(Zi)){let t=n["r:id"],o=i.byId[t],h=n.name,l=n.state,c=function(e){let t,r={rows:0,cols:0};return zi(e,{enter:function(e,n){"dimension"===e?(t=te.parseReference(n.ref),t.bottomRight&&(r.cols=t.bottomRight.col+1,r.rows=t.bottomRight.row+1)):"sheetFormatPr"===e?(n.defaultColWidth&&(r.columnWidth=_o(parseFloat(n.defaultColWidth))),n.defaultRowHeight&&(r.rowHeight=Ao(parseFloat(n.defaultRowHeight)))):this.is(Ki)&&n.r?r.rows=Math.max(r.rows,+n.r):this.is(Wi)&&n.r&&(t=te.parseReference(n.r),r.rows=Math.max(r.rows,t.row+1),r.cols=Math.max(r.cols,t.col+1))}}),r}(i.bytes[o]);r.options.columnWidth=c.columnWidth||r.options.columnWidth,r.options.rowHeight=c.rowHeight||r.options.rowHeight,u.push({workbook:r,zip:e,strings:s,styles:a,file:o,options:{state:l,name:h,rows:Math.max(r.options.rows||0,c.rows),columns:Math.max(r.options.columns||0,c.cols),columnWidth:c.columnWidth,rowHeight:c.rowHeight}})}else this.is(so)&&n.activeTab&&(h=Ho(n.activeTab))},text:function(e){let t=this.is(Yi);if(t&&!Po(t.function)&&!Po(t.vbProcedure)){let n=t.localSheetId,s=null;null!=n&&(s=u[n].options.name);let i=t.name;"_xlnm._FilterDatabase"!==i&&(s&&(i="'"+s.replace(/\'/g,"\\'")+"'!"+i),Eo(s,null,(function(){r.defineName(i,e,Po(t.hidden))}),"reading user-defined name: "+i))}}});let l=new Hi;l.progress((function(e){n&&n.notify(e)})).then((function(){let e=r.sheets();!function(e){for(let t=0;t<e.length;t++)e[t].suspendChanges(!1).triggerChange({recalc:!0})}(e),r.activeSheet(e[h]),n&&n.resolve()})),function(e,t,r){let n=window.Promise.resolve();for(let s=0;s<e.length;s++)!function(s,i){n=n.then((function(){let n=t.insertSheet(s.options);n.suspendChanges(!0);let o=bo(n,s),a={sheet:n,progress:1===i?1:i/(e.length-1)};return o.then((function(){r.notify(a)})),o}))}(e[s],s);n.then((function(){r.resolve()}))}(u,r,l)}(e,r,n)))},i.readAsArrayBuffer(e)}let Wi=["sheetData","row","c"],qi=["cols","col"],Yi=["definedNames","definedName"],Ji=["sheetData","row","c","f"],Xi=["mergeCells","mergeCell"],Gi=["sheetViews","sheetView","pane"],Ki=["sheetData","row"],Qi=["sheetViews","sheetView","selection"],Zi=["sheets","sheet"],eo=["sheetData","row","c","is"],to=["t"],ro=["si"],no=["sheetData","row","c","v"],so=["bookViews","workbookView"],io=["sheetViews","sheetView"],oo=["hyperlinks","hyperlink"],ao=["sheetProtection"],uo=["dataValidations","dataValidation"],ho=["dataValidations","dataValidation","formula1"],lo=["dataValidations","dataValidation","formula2"],co=["x14:dataValidations","x14:dataValidation"],fo=["x14:dataValidations","x14:dataValidation","xm:sqref"],po=["x14:dataValidations","x14:dataValidation","x14:formula1","xm:f"],go=["x14:dataValidations","x14:dataValidation","x14:formula2","xm:f"],mo=["commentList","comment"],vo=["authors","author"],yo=["t"];function wo(e){return/^\//.test(e)?e=e.substr(1):/^xl\//.test(e)||(e="xl/"+e),e}function bo(e,t){let r=new Hi;return setTimeout((async function(){await async function(e,t,r,s,i){let o,a,u,h,l,p,d,m,v,y,w,b,_,A,C={},x=r._columns._count,k=null,M=t.replace(/worksheets\//,"worksheets/_rels/"),E=await No(e,M),F=[],R=[];if(Oi=r._workbook.excelImportErrors,t=wo(t),await So(e,t,{enter:function(e,t,n){let s;if(this.is(Ji))n&&"shared"===t.t&&null!=t.si&&(h=r.range(C[t.si])._get("formula"));else if(this.is(Wi)){u=null,h=null,o=t.r,l=null,null==o&&(o=te.parseReference(k),o.col++,o=o.toString()),k=o,a=t.t;let e=t.s;null!=e&&R.push({ref:o,sty:+e})}else if(this.is(Xi))r.range(t.ref).merge();else if(this.is(qi)){let e,n=Ho(t.min)-1,s=Math.min(x,Ho(t.max))-1;if(t.width&&(e=_o(parseFloat(t.width)),0!==e&&r._columns.values.value(n,s,e)),"1"===t.hidden||0===e)for(let e=n;e<=s;e++)r.hideColumn(e);null!=t.style&&R.unshift({ref:new f(new c(-1/0,n),new c(1/0,s)),sty:+t.style})}else if(this.is(Ki)){let e,n=Ho(t.r)-1;t.ht&&(e=Ao(parseFloat(t.ht)),0!==e&&r._rows.values.value(n,n,e)),"1"!==t.hidden&&0!==e||r.hideRow(n)}else if(this.is(Qi)){if(t.activeCell){let e=te.parseReference(t.activeCell);r.select(e,!0)}}else if(this.is(Gi))t.state&&t.state.indexOf("frozen")>-1&&(t.xSplit&&r.frozenColumns(Ho(t.xSplit)),t.ySplit&&r.frozenRows(Ho(t.ySplit)));else if(this.is(io))r.showGridLines(Po(t.showGridLines,!0));else if(this.is(oo)){let e=t["r:id"],n=E.byId[e];n&&r.range(t.ref).link(n)}else this.is(ao)?t.sheet&&r.range(g).enable(!1):this.is(["autoFilter"])?(v=t.ref,n&&S()):v&&(this.is(["filterColumn"])?y=parseInt(t.colId,10):this.is(["customFilters"])?(w=Po(t.and)?"and":"or",b=[]):this.is(["customFilter"])?(s=function(e,t){let r={equal:"eq",notEqual:"ne",greaterThan:"gt",greaterThanOrEqual:"gte",lessThan:"lt",lessThanOrEqual:"lte"}[e];if(t=Mo(t),r&&"number"==typeof t)return{operator:r,value:t};if(("notEqual"===e||!e)&&"string"==typeof t)return{operator:e?"doesnotmatch":"matches",value:t}}(t.operator,t.val),s&&b.push({operator:s.operator,value:s.value})):this.is(["dynamicFilter"])?F.push({column:y,filter:new un({type:ko(t.type)})}):this.is(["top10"])?F.push({column:y,filter:new an({value:Mo(t.val),type:(i=Po(t.percent),p=Po(t.top),i&&p?"topPercent":p?"topNumber":i?"bottomPercent":"bottomNumber")})}):this.is(["filters"])?(_=Po(t.blank),A=[]):this.is(["filter"])&&A.push(Mo(t.val)));var i,p},leave:function(e,t){if(this.is(Ji))h||"shared"!==t.t||null==t.si||(h=r.range(C[t.si])._get("formula"));else if(this.is(Wi)){if(null!=h){Eo(r,l||o,(function(){r.range(l||o).formula(h,p)}),"parsing formula")&&r.range(l||o).value(h).background("#ffaaaa")}else if(null!=u){let e=r.range(o);e._get("formula")||(a&&"n"!==a?"s"===a?u=s[Ho(u)]:"b"===a?u="1"===u:"d"===a&&(u=Z().parseDate(u)):u=parseFloat(u),null!=u&&e.value(u))}}else this.is(uo)||this.is(co)?function(){let e=te.parseSqref(t.sqref),n=t.type.toLowerCase(),s=t.operator;/^(?:whole|decimal)$/.test(n)?n="number":"list"===n&&(s="list"),!s&&/^(?:number|date)$/.test(n)&&(s="between"),e.forEach((function(e){Eo(r,e,(function(){r.range(e).validation({type:Po(t.showErrorMessage,!0)?"reject":"warning",from:d,to:m,dataType:n,comparerType:Pi[s]||s,allowNulls:Po(t.allowBlank),showButton:Po(t.showDropDown)||"date"===n||"list"===n,messageTemplate:t.error,titleTemplate:t.errorTitle})}),"parsing validation")}))}():"cols"===e?r._columns._refresh():"sheetData"===e?r._rows._refresh():"autoFilter"===e?S():v&&("customFilters"===e?F.push({column:y,filter:new on({logic:w,criteria:b})}):"filters"===e&&F.push({column:y,filter:new sn({values:A,blanks:_})}))},text:function(e){let t;this.is(no)||this.is(eo)?u=e:(t=this.is(Ji))?(h=e,p="array"===t.t,p?l=t.ref:"shared"===t.t&&(C[t.si]=o)):this.is(ho)||this.is(po)?d=e:this.is(lo)||this.is(go)?m=e:this.is(fo)&&(this.stack[this.stack.length-2].sqref=e)}}),R.forEach((({ref:e,sty:t})=>function(e,t,r,n){let s,i,o=e.range(t),a=r.inlineStyles[n];a.xfId&&(s=r.namedStyles[a.xfId]);f("applyBorder","borderId")&&c(r.borders[i]);f("applyFont","fontId")&&l(r.fonts[i]);f("applyAlignment","textAlign")&&o.textAlign(i);f("applyAlignment","verticalAlign")&&o.verticalAlign(i);f("applyAlignment","indent")&&o.indent(i);f("applyAlignment","wrapText")&&o._property("wrap",i);f("applyFill","fillId")&&h(r.fills[i]);f("applyNumberFormat","numFmtId")&&u(r.numFmts[i]||Ro[i]);f("applyProtection","protection")&&o.enable(!a.protection.locked);function u(e){let t="string"==typeof e?e:e.formatCode;null==t||/^general$/i.test(t)||(t=t.replace(/^\[\$-[0-9]+\]/,""),o.format(t))}function h(e){"solid"===e.type&&o.background(e.color)}function l(e){o.fontFamily(e.name),e.size&&o._property("fontSize",4*e.size/3),e.bold&&o.bold(!0),e.italic&&o.italic(!0),e.underline&&o.underline(!0),e.color&&o.color(e.color)}function c(e){function t(t,r){let n=e[t];if(!n)return;let s=Fo[n.style];if(!s)return;let i=n.color;null==i&&(i="#000");let a={size:s,color:i};"diagonal"===t&&(a.type=n.up<<1|n.down),o._property(r,a)}t("left","borderLeft"),t("top","borderTop"),t("right","borderRight"),t("bottom","borderBottom"),t("diagonal","dBorders")}function f(e,t){let r=a[e];if(null!=r&&!r)return!1;if(i=a[t],s&&null==i){if(r=s[e],null!=r&&!r)return!1;i=s[t]}return null!=i}}(r,e,i,t))),E.byType.comments){let n=jo(t,E.byType.comments[0]);await async function(e,t,r){let n,s,i=[];await So(e,t,{enter:function(e,t){this.is(mo)?s={author:i[t.authorId],ref:t.ref,text:""}:this.is(vo)&&(n="")},leave:function(){this.is(mo)?r.range(s.ref).comment(s.text):this.is(vo)&&i.push(n)},text:function(e){this.is(yo)?s.text+=e:this.is(vo)&&(n+=e)}})}(e,n,r)}if(E.byType.drawing){let s=jo(t,E.byType.drawing[0]);await async function(e,t,r){let s,i,o,a,u=["xdr:twoCellAnchor"],h=["xdr:ext"],l=["xdr:oneCellAnchor"],f=["xdr:from"],p=["xdr:to"],d=["xdr:row"],g=["xdr:col"],m=["xdr:rowOff"],v=["xdr:colOff"],y=["xdr:blipFill","a:blip"],w=t.replace(/drawings\//,"drawings/_rels/"),b=await No(e,w);if(b.byType.image){let s=Object.keys(b.byId);for(let i=0;i<s.length;++i){let o=s[i],a=jo(t,b.byId[o]),u=Co(a);if(u){let t=await e.file(a).async("arraybuffer"),s=xo(a),i=s&&!n.b.edge?new window.File([t],s,{type:u}):new window.Blob([t],{type:u});b.byId[o]=r._workbook.addImage(i)}}}await So(e,t,{enter:function(e,t){if(this.is(u)||this.is(l))s={};else if(this.is(f)||this.is(p))i={};else if(this.is(y)){let e=t["r:embed"];s.image=b.byId[e]}else this.is(h)&&(o=Wo(parseFloat(t.cx)),a=Wo(parseFloat(t.cy)))},leave:function(){if(this.is(f))s.topLeftCell=new c(i.row,i.col),s.offsetX=Wo(i.colOffset),s.offsetY=Wo(i.rowOffset);else if(this.is(p))s.brCell=new c(i.row,i.col),s.brX=Wo(i.colOffset),s.brY=Wo(i.rowOffset);else if(this.is(u)&&s.image){let e=r._columns.sum(0,s.topLeftCell.col-1)+s.offsetX,t=r._rows.sum(0,s.topLeftCell.row-1)+s.offsetY,n=r._columns.sum(0,s.brCell.col-1)+s.brX,i=r._rows.sum(0,s.brCell.row-1)+s.brY;r.addDrawing({topLeftCell:s.topLeftCell,offsetX:s.offsetX,offsetY:s.offsetY,width:null!=o?o:n-e,height:null!=a?a:i-t,image:s.image,opacity:1})}else this.is(l)&&s.image&&r.addDrawing({topLeftCell:s.topLeftCell,offsetX:s.offsetX,offsetY:s.offsetY,width:o,height:a,image:s.image,opacity:1})},text:function(e){this.is(d)?i.row=parseFloat(e):this.is(g)?i.col=parseFloat(e):this.is(m)?i.rowOffset=parseFloat(e):this.is(v)&&(i.colOffset=parseFloat(e))}})}(e,s,r)}function S(){r.range(v).filter(F),v=null}}(t.zip,t.file,e,t.strings,t.styles),r.resolve()}),0),r}function _o(e){return 7*((256*e+Math.floor(128/7))/256)}function Ao(e){return e*(4/3)}function Co(e){let t=/\.([^.]+)$/.exec(e);if(t&&t[1])return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",wmf:"image/wmf"}[t[1].toLowerCase()]}function xo(e){let t=/[^/]+$/.exec(e);return t&&t[0]}function ko(e){return{Q1:"quarter1",Q2:"quarter2",Q3:"quarter3",Q4:"quarter4",M1:"january",M2:"february",M3:"march",M4:"april",M5:"may",M6:"june",M7:"july",M8:"august",M9:"september",M10:"october",M11:"november",M12:"december"}[e.toUpperCase()]||e}function Mo(e){let t=parseFloat(e);return isNaN(t)||t!==e?e:t}function Eo(e,t,r,n){try{return r(),!1}catch(r){let s={context:n,error:String(r)};return e&&e.name?s.sheet=e.name():e&&(s.sheet=e),t&&(s.location=String(t)),Oi.push(s),!0}}let Fo={none:0,thin:1,medium:2,dashed:1,dotted:1,thick:3,double:3,hair:1,mediumDashed:2,dashDot:1,mediumDashDot:2,dashDotDot:1,mediumDashDotDot:2,slantDashDot:1},Ro={0:"General",1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",12:"# ?/?",13:"# ??/??",14:"mm-dd-yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",37:"#,##0 ;(#,##0)",38:"#,##0 ;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mmss.0",48:"##0.0E+0",49:"@"};function So(e,t,r){return new window.Promise((n=>{let s=e.file(t);s?s.async("uint8array").then((e=>{zi(e,r),n()})):n()}))}async function No(e,t){let r={byId:{},byType:{theme:[]},bytes:{}};await So(e,wo(t)+".rels",{enter:function(e,t){if("Relationship"===e){r.byId[t.Id]=t.Target;let e=t.Type.match(/\w+$/)[0],n=r.byType[e]||[];n.push(t.Target),r.byType[e]=n}}});let n=[],s=[];Object.keys(r.byId).forEach((t=>{let i=r.byId[t],o=e.file(wo(i));o&&(n.push(i),s.push(o.async("uint8array")))}));let i=await window.Promise.all(s);return n.forEach(((e,t)=>r.bytes[e]=i[t])),r}let Lo=["borders","border"],Do=["fills","fill"],Uo=["fonts","font"],Vo=["cellXfs","xf"],$o=["cellStyleXfs","xf"],Bo=["numFmts","numFmt"],Io=[Oo("FF000000"),Oo("FFFFFFFF"),Oo("FFFF0000"),Oo("FF00FF00"),Oo("FF0000FF"),Oo("FFFFFF00"),Oo("FFFF00FF"),Oo("FF00FFFF"),Oo("FF000000"),Oo("FFFFFFFF"),Oo("FFFF0000"),Oo("FF00FF00"),Oo("FF0000FF"),Oo("FFFFFF00"),Oo("FFFF00FF"),Oo("FF00FFFF"),Oo("FF800000"),Oo("FF008000"),Oo("FF000080"),Oo("FF808000"),Oo("FF800080"),Oo("FF008080"),Oo("FFC0C0C0"),Oo("FF808080"),Oo("FF9999FF"),Oo("FF993366"),Oo("FFFFFFCC"),Oo("FFCCFFFF"),Oo("FF660066"),Oo("FFFF8080"),Oo("FF0066CC"),Oo("FFCCCCFF"),Oo("FF000080"),Oo("FFFF00FF"),Oo("FFFFFF00"),Oo("FF00FFFF"),Oo("FF800080"),Oo("FF800000"),Oo("FF008080"),Oo("FF0000FF"),Oo("FF00CCFF"),Oo("FFCCFFFF"),Oo("FFCCFFCC"),Oo("FFFFFF99"),Oo("FF99CCFF"),Oo("FFFF99CC"),Oo("FFCC99FF"),Oo("FFFFCC99"),Oo("FF3366FF"),Oo("FF33CCCC"),Oo("FF99CC00"),Oo("FFFFCC00"),Oo("FFFF9900"),Oo("FFFF6600"),Oo("FF666699"),Oo("FF969696"),Oo("FF003366"),Oo("FF339966"),Oo("FF003300"),Oo("FF333300"),Oo("FF993300"),Oo("FF993366"),Oo("FF333399"),Oo("FF333333"),Oo("FF000000"),Oo("FFFFFFFF")];let To=["a:clrScheme","*","a:srgbClr"],zo=["a:clrScheme","*","a:sysClr"];function Ho(e){return null==e?null:parseInt(e,10)}function Po(e,t){return null==e?t:"true"===e||!0===e||1===e||"1"===e}function Oo(e){let t=/^([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);return"rgba("+parseInt(t[2],16)+", "+parseInt(t[3],16)+", "+parseInt(t[4],16)+", "+parseInt(t[1],16)/255+")"}function jo(e,t){for(e=e.split(/\/+/),t=t.split(/\/+/),e.pop();t.length;){let r=t.shift();if(""===r)e=[];else{if("."===r)continue;".."===r?e.pop():e.push(r)}}return e.join("/")}function Wo(e){return e/9525}const qo=["cut","copy","paste","changing","change","contextmenu","excelImport","excelExport","insertSheet","removeSheet","selectSheet","renameSheet","insertRow","insertColumn","deleteRow","deleteColumn","hideRow","hideColumn","unhideRow","unhideColumn","select","changeFormat","dataBinding","dataBound","progress"];function Yo(e,t){let r=new XMLHttpRequest;r.onload=function(){t(r.response,r.getResponseHeader("Content-Type"))},r.onerror=function(){t(null)},r.open("GET",e),r.responseType="arraybuffer",r.send()}class Jo extends kr{constructor(e,t){super(),this.events=qo,this.options=e,this._view=t,this._sheets=[],this._images={},this._imgID=0,this._sheetsSearchCache={},this._sheet=this.insertSheet({rows:this.options.rows,columns:this.options.columns,rowHeight:this.options.rowHeight,columnWidth:this.options.columnWidth,headerHeight:this.options.headerHeight,headerWidth:this.options.headerWidth,dataSource:this.options.dataSource}),this.undoRedoStack=new gi,this.undoRedoStack.bind(["undo","redo"],this._onUndoRedo.bind(this)),this._context=new Ct(this),this._validationContext=new xt(this),this._names=Object.create(null),this.fromJSON(this.options)}clipboard(){return this._clipboard||(this._clipboard=new os(this)),this._clipboard}destroy(){this.unbind(),this._clipboard&&this._clipboard.destroy()}_sheetChanging(e){this.trigger("changing",e)&&e.preventDefault()}_sheetChange(e){this.trigger("change",e)}_sheetInsertRow(e){this.trigger("insertRow",{sheet:e.sender,index:e.index})&&e.preventDefault()}_sheetInsertColumn(e){this.trigger("insertColumn",{sheet:e.sender,index:e.index})&&e.preventDefault()}_sheetDeleteRow(e){this.trigger("deleteRow",{sheet:e.sender,index:e.index})&&e.preventDefault()}_sheetDeleteColumn(e){this.trigger("deleteColumn",{sheet:e.sender,index:e.index})&&e.preventDefault()}_sheetHideRow(e){this.trigger("hideRow",{sheet:e.sender,index:e.index})&&e.preventDefault()}_sheetHideColumn(e){this.trigger("hideColumn",{sheet:e.sender,index:e.index})&&e.preventDefault()}_sheetUnhideRow(e){this.trigger("unhideRow",{sheet:e.sender,index:e.index})&&e.preventDefault()}_sheetUnhideColumn(e){this.trigger("unhideColumn",{sheet:e.sender,index:e.index})&&e.preventDefault()}_sheetSelect(e){this.trigger("select",e)}_sheetDataBinding(e){this.trigger("dataBinding",{sheet:e.sender})&&e.preventDefault()}_sheetDataBound(e){this.trigger("dataBound",{sheet:e.sender})}_sheetProgress(e){let t=this;setTimeout((function(){t.trigger("progress",{toggle:e.toggle})}))}_sheetCommandRequest(e){this.trigger("commandRequest",e)}_inputForRef(e){let t=this;return t._sheet.withCultureDecimals((function(){return new fr(e,t._sheet).input()}))}_onUndoRedo(e){e.command.range().select()}execute(e){let t,r=Object.assign({},{workbook:this},e.options);this.options.getWorkbookCommand&&(t=this.options.getWorkbookCommand(e.command,r)),t=t||new di[e.command](r);let n=this.activeSheet();r.origin&&t.origin(r.origin),r.operatingRange?t.range(r.operatingRange):t.range(n.selection()),r.editRange&&(t._editRange=r.editRange);let s=t.exec();return s&&"error"===s.reason||t.cannotUndo||this.undoRedoStack.push(t),this.cleanupImages(),s}resetFormulas(){this._sheets.forEach((function(e){e.resetFormulas()}))}resetValidations(){this._sheets.forEach((function(e){e.resetValidations()}))}refresh(e){e.recalc&&(this.resetFormulas(),this.resetValidations(),this._sheet.recalc(this._context),this._sheet.revalidate(this._validationContext))}activeSheet(e){if(void 0===e)return this._sheet;this.sheetByName(e.name())&&(this._sheet=e,e.triggerChange(y))}moveSheetToIndex(e,t){let r=this.sheetIndex(e),n=this._sheets;-1!==r&&(this._sheetsSearchCache={},n.splice(t,0,n.splice(r,1)[0]),this.trigger("change",{sheetSelection:!0}))}insertSheet(e){let t,r=this,n="number"==typeof(e=e||{}).index?e.index:r._sheets.length,s=r._sheets;const i=this.options.messages;let o=function(e){e=e||1;let t=i.workbook.defaultSheetName+e;return r.sheetByName(t)?o(e+1):t};if(e.name&&r.sheetByName(e.name))return;this._sheetsSearchCache={},t=e.name||o();let a=new vn(e.rows||this.options.rows,e.columns||this.options.columns,e.rowHeight||this.options.rowHeight,e.columnWidth||this.options.columnWidth,e.headerHeight||this.options.headerHeight,e.headerWidth||this.options.headerWidth,e.defaultCellStyle||this.options.defaultCellStyle,e.createSheetDataSource||this.options.createSheetDataSource);return a._workbook=this,a._name(t),a._state(e.state),this._bindSheetEvents(a),s.splice(n,0,a),e.data&&a.fromJSON(e.data),e.dataSource&&a.setDataSource(e.dataSource),this.trigger("change",{sheetSelection:!0}),a}_bindSheetEvents(e){e.bind("changing",this._sheetChanging.bind(this)),e.bind("change",this._sheetChange.bind(this)),e.bind("insertRow",this._sheetInsertRow.bind(this)),e.bind("insertColumn",this._sheetInsertColumn.bind(this)),e.bind("deleteRow",this._sheetDeleteRow.bind(this)),e.bind("deleteColumn",this._sheetDeleteColumn.bind(this)),e.bind("hideRow",this._sheetHideRow.bind(this)),e.bind("hideColumn",this._sheetHideColumn.bind(this)),e.bind("unhideRow",this._sheetUnhideRow.bind(this)),e.bind("unhideColumn",this._sheetUnhideColumn.bind(this)),e.bind("select",this._sheetSelect.bind(this)),e.bind("commandRequest",this._sheetCommandRequest.bind(this)),e.bind("dataBinding",this._sheetDataBinding.bind(this)),e.bind("dataBound",this._sheetDataBound.bind(this)),e.bind("progress",this._sheetProgress.bind(this))}sheets(){return this._sheets.slice()}sheetByName(e){return this._sheets[this.sheetIndex(e)]}sheetByIndex(e){return this._sheets[e]}sheetIndex(e){let t=this._sheets,r=("string"==typeof e?e:e.name()).toLowerCase(),n=this._sheetsSearchCache[r];if(n>=0)return n;for(n=0;n<t.length;n++){let e=t[n].name().toLowerCase();if(this._sheetsSearchCache[e]=n,e===r)return n}return-1}renameSheet(e,t){let r=e.name().toLowerCase();if(t&&r!==t.toLowerCase()&&!this.sheetByName(t)&&(e=this.sheetByName(r))&&(this._sheetsSearchCache={},!this.trigger("renameSheet",{sheet:e,newSheetName:t})))return this._sheets.forEach((function(e){e._forFormulas((function(e){e.renameSheet(r,t)}))})),this.forEachName(function(e,n){e.nameref.renameSheet(r,t)&&(this.undefineName(n),e.name=e.nameref.print(),this.nameDefinition(e.name,e)),(e.value instanceof u||e.value instanceof te.runtime.Formula)&&e.value.renameSheet(r,t)}.bind(this)),e._name(t),this.trigger("change",{sheetSelection:!0}),e}removeSheet(e){let t=this,r=t._sheets,n=e.name(),s=t.sheetIndex(e);if(1!==r.length&&!this.trigger("removeSheet",{sheet:e})&&(this._sheetsSearchCache={},s>-1))if(e.unbind(),r.splice(s,1),t.activeSheet().name()===n){let e=r[s===r.length?s-1:s];t.activeSheet(e)}else this.trigger("change",{recalc:!0,sheetSelection:!0})}_clearSheets(){for(let e=0;e<this._sheets.length;e++)this._sheets[e]._activeDrawing=[],this._sheets[e]._drawings=[],this._sheets[e].unbind();this._sheets=[],this._sheetsSearchCache={},this._names={},this._images={},this._imgID=0}_loadImages(){let e=this,t=Object.keys(e._images),r=t.length;function n(){--r<=0&&e.activeSheet().triggerChange({layout:!0})}r?t.forEach((function(t){let r=e._images[t];r.blob||Yo(r.url,(function(e,t){null!=e&&(r.blob=new Blob([e],{type:t}),delete r.url),n()}))})):n()}fromJSON(e){if(e.sheets){this._clearSheets(),e.images&&(this._imgID=0,this._images={},Object.keys(e.images).forEach((function(t){if(!isNaN(t)){let e=parseFloat(t);isFinite(e)&&(this._imgID=Math.max(this._imgID,e))}this._images[t]={url:e.images[t]}}),this),this._loadImages());for(let t=0;t<e.sheets.length;t++){let r=e.sheets[t],n=Xo(r,this.options),s=this.insertSheet({rows:n.rowCount,columns:n.columnCount,rowHeight:n.rowHeight,columnWidth:n.columnWidth,headerHeight:n.headerHeight,headerWidth:n.headerWidth,data:r});r.dataSource&&s.setDataSource(r.dataSource)}}e.activeSheet?this.activeSheet(this.sheetByName(e.activeSheet)):this.activeSheet(this._sheets[0]),e.names&&e.names.forEach((function(e){this.defineName(e.name,e.value,e.hidden)}),this)}toJSON(){this.resetFormulas(),this.resetValidations();let e=Object.keys(this._names).map((function(e){let t=this._names[e],r=t.value;return r=r instanceof u||r instanceof te.runtime.Formula?r.print(0,0,!0):r instanceof K?String(r):JSON.stringify(r),{value:r,hidden:t.hidden,name:t.name,sheet:t.nameref.sheet,localName:t.nameref.name}}),this);return{activeSheet:this.activeSheet().name(),sheets:this._sheets.map((function(e){return e.recalc(this._context),e.revalidate(this._validationContext),e.toJSON()}),this),names:e,images:{},columnWidth:this.options.columnWidth,rowHeight:this.options.rowHeight}}saveJSON(){let e=this,t=e.toJSON(),r=Object.keys(e._images).filter((function(t){return 1===e.usesImage(t)})),n=r.length;const s=[];return n&&r.forEach((function(r){let n=e._images[r];if(n.blob){const e=new Promise((e=>{let s=new FileReader;s.onload=function(){t.images[r]=s.result,e()},s.readAsDataURL(n.blob)}));s.push(e)}else t.images[r]=n.url})),Promise.all(s).then((()=>t))}fromFile(e){const t=new Hi;return e&&!this.trigger("excelImport",{file:e,deferred:t})&&(this._clearSheets(),this._readExcel(e,this,t)),t.promise}_readExcel(e,t,r){ji(e,t,r)}saveAsExcel(e){let t=this;e=H({},t.options.excel,e);let r=t.toJSON();if(t.trigger("excelExport",{workbook:r}))return;let n=Object.keys(t._images).filter((function(e){return 1===t.usesImage(e)})),s=n.length,i=s?{}:null;const o=[];return s?(n.forEach((function(e){let r=t._images[e];if(r.blob){const t=new Promise((t=>{let n=new FileReader;n.onload=function(){i[e]={type:r.blob.type,name:r.blob.name,data:n.result},s--,t()},n.readAsArrayBuffer(r.blob)}));o.push(t)}else{const t=new Promise((t=>{Yo(r.url,(function(r,n){i[e]={type:n,data:r},s--,t()}))}));o.push(t)}})),Promise.all(o).then((()=>a()))):a();function a(){if(--s<=0){r.images=i;let t=new e.Workbook(r);const n=e.forceProxy?t.toDataURL():t.toBlob();return e.saveAs?n.then((t=>{e.saveAs(t,r.fileName||e.fileName,{proxyURL:e.proxyURL,forceProxy:e.forceProxy})})):n}return Promise.resolve()}}draw(e,t){"function"!=typeof e||t||(t=e,e={});let r=[],n=this._sheets;!function s(i){if(i<n.length)n[i].draw(g,e,(function(e){r.push(e),s(i+1)}));else{let e=r[0];for(i=1;i<r.length;++i)e.children=e.children.concat(r[i].children);t(e)}}(0)}nameForRef(e,t){void 0===t&&(t=e.sheet),t=t.toLowerCase();let r=String(e);for(let e in this._names){let n=this._names[e],s=n.value;if(s instanceof u&&(!s.sheet||s.sheet&&t===s.sheet.toLowerCase())&&String(s)===r)return n}return{name:r}}defineName(e,t,r){let n=te.parseNameDefinition(e,t);e=n.name.print(),this._names[e.toLowerCase()]={value:n.value,hidden:r,name:e,nameref:n.name}}undefineName(e){delete this._names[e.toLowerCase()]}nameValue(e){return(e=e.toLowerCase())in this._names?this._names[e].value:null}nameDefinition(e,t){return e=e.toLowerCase(),arguments.length>1&&(void 0===t?delete this._names[e]:this._names[e]=t),this._names[e]}forEachName(e){Object.keys(this._names).forEach((function(t){e(this._names[t],t)}),this)}adjustNames(e,t,r,n){e=e.toLowerCase(),Object.keys(this._names).forEach((function(s){let i=this._names[s],o=i.value;o instanceof u&&o.sheet.toLowerCase()===e?i.value=o.adjust(null,null,null,null,t,r,n):o instanceof te.runtime.Formula&&o.adjust(e,t?"row":"col",r,n)}),this)}addImage(e){let t=String(++this._imgID);return this._images[t]="string"==typeof e?{url:e}:{blob:e},t}imageUrl(e){let t=this._images[e],r=t.url;return r||(r=t.url=window.URL.createObjectURL(t.blob)),r}cleanupImages(){Object.keys(this._images).forEach((function(e){if(!this.usesImage(e)){let t=this._images[e].url;t&&window.URL.revokeObjectURL(t),delete this._images[e]}}),this)}usesImage(e){let t,r=this._sheets;for(t=r.length;--t>=0;)if(r[t].usesImage(e))return 1;let n=this.undoRedoStack.stack;for(t=n.length;--t>=0;)if(n[t].usesImage(e))return 2;return!1}}function Xo(e,t){function r(e,t,r){return void 0!==e?e:void 0!==t?t:r}let n=r(e.rowCount,t.rows,200),s=r(e.columnCount,t.columns,50),i=r(e.rowHeight,t.rowHeight,20),o=r(e.columnWidth,t.columnWidth,64),a=r(e.headerHeight,t.headerHeight,20),u=r(e.headerWidth,t.headerWidth,32);if(void 0!==e.rows)for(let t=0;t<e.rows.length;++t){let i=e.rows[t],o=r(i.index,t);if(o>=n&&(n=o+1),i.cells)for(let e=0;e<i.cells.length;++e){let t=r(i.cells[e].index,e);t>=s&&(s=t+1)}}return{rowCount:n,columnCount:s,rowHeight:i,columnWidth:o,headerHeight:a,headerWidth:u}}const Go=["cut","copy","paste","pdfExport","excelExport","excelImport","changing","change","render","removeSheet","selectSheet","renameSheet","insertRow","insertColumn","deleteRow","insertSheet","deleteColumn","hideRow","hideColumn","unhideRow","unhideColumn","select","changeFormat","dataBinding","dataBound","update","message","contextmenu"];const{FUNCS:Ko,defineBuiltinFunction:Qo,limitPrecision:Zo,packDate:ea,unpackDate:ta,daysInMonth:ra,daysInYear:na,isLeapYear:sa}=te.runtime;function ia(e,t){return e="string"==typeof e?e.toLowerCase():e,t="string"==typeof t?t.toLowerCase():t,!1===e&&null==t||(!1===t&&null==e||(0===e&&null==t||(0===t&&null==e||(""===e&&null==t||(""===t&&null==e||e===t)))))}function oa(e,t,r){return"string"==typeof e&&"string"!=typeof t&&(t=null==t?"":t+""),"string"!=typeof e&&"string"==typeof t&&(e=null==e?"":e+""),"number"==typeof e&&null==t&&(t=0),"number"==typeof t&&null==e&&(e=0),"string"==typeof e&&"string"==typeof t&&(e=e.toLowerCase(),t=t.toLowerCase()),typeof t==typeof e?r(e=le(e,15),t=le(t,15)):new K("VALUE")}function aa(e){return(Math.exp(e)+Math.exp(-e))/2}function ua(e){return(Math.exp(e)-Math.exp(-e))/2}function ha(e){return ua(e)/aa(e)}function la(e,t){for(;t;){var r=e%t;e=t,t=r}return e}function ca(e,t){return Math.abs(e*t)/la(e,t)}function fa(e,t){for(var r=[],n=0,s=e[0];n<e.length;)r.push({matrix:e[n++],pred:La(e[n++])});for(var i=0;i<s.height;++i)e:for(var o=0;o<s.width;++o){for(n=0;n<r.length;++n){var a=r[n].matrix.get(i,o);if(!r[n].pred(null==a||""===a?0:a))continue e}t(i,o)}}function pa(e){return function(t,r,n,s){var i=this;if(s instanceof u){var o=s.clone().toRangeRef();if(o.width()!=r.width||o.height()!=r.height)return isFinite(o.topLeft.row)||(o.topLeft.row=0),isFinite(o.topLeft.col)||(o.topLeft.col=0),o.bottomRight.row=o.topLeft.row+r.height-1,o.bottomRight.col=o.topLeft.col+r.width-1,i.resolveCells([o],(function(){t(e(r,n,i.asMatrix(o)))}))}t(e(r,n,i.asMatrix(s)))}}function da(e,t,r){var n=[],s=e.each((function(e){if(e instanceof K)return e;"number"==typeof e&&n.push(e)}));return s||(t>n.length?new K("NUM"):n.sort(r)[t-1])}function ga(e){return e.reduce((function(e,t){return e+t}),0)/e.length}function ma(e,t,r){return null==r&&(r=ga(e)),e.reduce((function(e,t){return e+Math.pow(t-r,2)}),0)/t}function va(e,t){return Math.sqrt(ma(e,t))}function ya(e,t,r){var n=0,s=0,i=null,o=null,a=!1;return e.forEach((function(e){e<t?(n++,i=null==i?e:Math.max(i,e)):e>t?(s++,o=null==o?e:Math.min(o,e)):a=!0})),n||s?a?r?(n+1)/(e.length+1):n/(n+s):((o-t)*ya(e,i,r)+(t-i)*ya(e,o,r))/(o-i):new K("N/A")}function wa(e,t,r){for(var n=0,s=ga(e),i=ga(t),o=e.length,a=0;a<o;++a)n+=(e[a]-s)*(t[a]-i);return n/r}Qo("binary+",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))||null==i&&(i=0,1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=0,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e+t})),Qo("binary-",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))||null==i&&(i=0,1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=0,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e-t})),Qo("binary*",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))||null==i&&(i=0,1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=0,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e*t})),Qo("binary/",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))||null==i&&(i=0,1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||0==o&&(s="DIV/0",1)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e/t})),Qo("binary^",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))||null==i&&(i=0,1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=0,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return Math.pow(e,t)})),Qo("binary&",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))||("string"==typeof i||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1))||"boolean"==typeof i||null==i))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||("string"==typeof o||"boolean"==typeof o||"number"==typeof o?(o+="",1):void 0===o&&(o="",1))||"boolean"==typeof o||null==o?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return null==e&&(e=""),null==t&&(t=""),""+e+t})),Qo("binary=",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(s=this.force(s),!(r<=e.length))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:(i=this.force(i),r<=e.length?(t.push(i),r<e.length?new K("N/A"):t):i instanceof K?i:new K(n))},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return ia(e,t)})),Qo("binary<>",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(s=this.force(s),!(r<=e.length))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:(i=this.force(i),r<=e.length?(t.push(i),r<e.length?new K("N/A"):t):i instanceof K?i:new K(n))},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return!ia(e,t)})),Qo("binary<",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(s=this.force(s),!(r<=e.length))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:(i=this.force(i),r<=e.length?(t.push(i),r<e.length?new K("N/A"):t):i instanceof K?i:new K(n))},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return oa(e,t,((e,t)=>e<t))})),Qo("binary<=",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(s=this.force(s),!(r<=e.length))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:(i=this.force(i),r<=e.length?(t.push(i),r<e.length?new K("N/A"):t):i instanceof K?i:new K(n))},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return oa(e,t,((e,t)=>e<=t))})),Qo("binary>",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(s=this.force(s),!(r<=e.length))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:(i=this.force(i),r<=e.length?(t.push(i),r<e.length?new K("N/A"):t):i instanceof K?i:new K(n))},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return oa(e,t,((e,t)=>e>t))})),Qo("binary>=",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(s=this.force(s),!(r<=e.length))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:(i=this.force(i),r<=e.length?(t.push(i),r<e.length?new K("N/A"):t):i instanceof K?i:new K(n))},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return oa(e,t,((e,t)=>e>=t))})),Qo("unary+",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))||null==s&&(s=0,1)?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e})),Qo("unary-",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))||null==s&&(s=0,1)?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return-e})),Qo("unary%",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))||null==s&&(s=0,1)?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e/100})),Qo("binary:",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(!(s instanceof c))return new K(n);t.push(s);var i=e[r++];return i instanceof K?i:i instanceof c?(t.push(i),2<e.length?new K("N/A"):t):new K(n)}},(function(e,t){return new f(e,t).setSheet(e.sheet||this.formula.sheet,e.hasSheet())})),Qo("binary,",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(!(s instanceof u))return new K(n);t.push(s);var i=e[r++];return i instanceof K?i:i instanceof u?(t.push(i),2<e.length?new K("N/A"):t):new K(n)}},(function(e,t){return new p([e,t])})),Qo("binary ",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(!(s instanceof u))return new K(n);t.push(s);var i=e[r++];return i instanceof K?i:i instanceof u?(t.push(i),2<e.length?new K("N/A"):t):new K(n)}},(function(e,t){return e.intersect(t)})),Qo("not",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:null!=(n=this.force(n))&&1<=e.length||null==n&&(n=0,1)?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return!this.bool(e)})),Qo("isblank",!1,{check:function(e){var t=[],r=0,n=e[r++];return 1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e instanceof c&&null==(e=this.getRefData(e))})),Qo("iserror",!1,{check:function(e){var t=[],r=0,n=e[r++];return n=this.force(n),1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e instanceof K})),Qo("iserr",!1,{check:function(e){var t=[],r=0,n=e[r++];return n=this.force(n),1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e instanceof K&&"N/A"!=e.code})),Qo("isna",!1,{check:function(e){var t=[],r=0,n=e[r++];return n=this.force(n),1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e instanceof K&&"N/A"==e.code})),Qo("islogical",!1,{check:function(e){var t=[],r=0,n=e[r++];return n=this.force(n),1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return"boolean"==typeof e})),Qo("isnontext",!1,{check:function(e){var t=[],r=0,n=e[r++];return n=this.force(n),1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return"string"!=typeof e})),Qo("istext",!1,{check:function(e){var t=[],r=0,n=e[r++];return n=this.force(n),1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return"string"==typeof e})),Qo("isnumber",!1,{check:function(e){var t=[],r=0,n=e[r++];return n=this.force(n),1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return"number"==typeof e})),Qo("isref",!1,{check:function(e){var t=[],r=0,n=e[r++];return 1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e instanceof c||e instanceof f})),Qo("_matrix",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:(t=this.asMatrix(s))&&(s=t)||("string"==typeof s||"boolean"==typeof s||"number"==typeof s?(s+="",1):void 0===s&&(s="",1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return"string"==typeof e&&(e=this.asMatrix([e.split(/\s*,\s*/)])),e})),Ko[",getname"]=function(e,t){this.fetchName(t[0],e)},Qo("abs",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.abs),Qo("cos",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.cos),Qo("sin",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.sin),Qo("acos",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.acos),Qo("asin",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.asin),Qo("tan",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.tan),Qo("atan",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.atan),Qo("exp",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.exp),Qo("sqrt",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.sqrt),Qo("ln",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.log),Qo("log",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o>0||(s="NUM",0))||null==o&&(o=10,1)?(r.push(o),1==o&&(s="DIV/0",1)?new K(s):2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return Math.log(e)/Math.log(t)})),Qo("log10",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&(i>0||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return Math.log(e)/Math.log(10)})),Qo("pi",!1,{check:function(e){return 0<e.length?new K("N/A"):[]}},(function(){return Math.PI})),Qo("sqrtpi",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&(i>=0||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return Math.sqrt(e*Math.PI)})),Qo("degrees",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return 180*e/Math.PI%360})),Qo("radians",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return Math.PI*e/180})),Qo("cosh",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},aa),Qo("acosh",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:"number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))?(r.push(i),i>=1||(s="N/A",0)?1<e.length?new K("N/A"):r:new K(s)):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return Math.log(e+Math.sqrt(e-1)*Math.sqrt(e+1))})),Qo("sinh",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},ua),Qo("asinh",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return Math.log(e+Math.sqrt(e*e+1))})),Qo("sec",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return 1/Math.cos(e)})),Qo("sech",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return 1/aa(e)})),Qo("csc",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return 1/Math.sin(e)})),Qo("csch",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return 1/ua(e)})),Qo("atan2",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||0==i&&(s="DIV/0",1))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return Math.atan(t/e)})),Qo("tanh",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},ha),Qo("atanh",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&(i>-1&&i<1||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return Math.log(Math.sqrt(1-e*e)/(1-e))})),Qo("cot",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||0==i&&(s="DIV/0",1)?i instanceof K?i:new K(s):(r.push(i),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return 1/Math.tan(e)})),Qo("coth",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||0==i&&(s="DIV/0",1)?i instanceof K?i:new K(s):(r.push(i),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return 1/ha(e)})),Qo("acot",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return Math.PI/2-Math.atan(e)})),Qo("acoth",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:"number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))?(r.push(i),i<-1||(s="N/A",0)||i>1||(s="N/A",0)?1<e.length?new K("N/A"):r:new K(s)):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return Math.log((e+1)/(e-1))/2})),Qo("power",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return Math.pow(e,t)})),Qo("mod",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||0==o&&(s="DIV/0",1)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e%t})),Qo("quotient",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||0==o&&(s="DIV/0",1)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return Math.floor(e/t)})),Qo("ceiling",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))?(r.push(o),o>=0||i<0||(s="N/A",0)?2<e.length?new K("N/A"):r:new K(s)):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return t?t*Math.ceil(e/t):0})),Qo("ceiling.precise",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=1,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return(t=Math.abs(t))?t*Math.ceil(e/t):0})),te.runtime.defineAlias("iso.ceiling","ceiling.precise"),Qo("ceiling.math",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=i<0?-1:1,1)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)||null==a&&(a=0,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){return t&&e?(e<0&&(!r&&t<0||r&&t>0)&&(t=-t),t?t*Math.ceil(e/t):0):0})),Qo("floor",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))?(r.push(o),o>=0||i<0||(s="N/A",0)?2<e.length?new K("N/A"):r:new K(s)):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return t?t*Math.floor(e/t):0})),Qo("floor.precise",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=1,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return(t=Math.abs(t))?t*Math.floor(e/t):0})),Qo("floor.math",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=i<0?-1:1,1)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)||null==a&&(a=0,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){return t&&e?(e<0&&(!r&&t<0||r&&t>0)&&(t=-t),t?t*Math.floor(e/t):0):0})),Qo("int",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Math.floor),Qo("mround",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return t?t*Math.round(e/t):0})),Qo("round",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){var r=e<0?-1:1;return r<0&&(e=-e),t=Math.pow(10,t),e=Zo(e*t),r*(e=Math.round(e))/t})),Qo("roundup",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return t=Math.pow(10,t),(e=(e=Zo(e*t))<0?Math.floor(e):Math.ceil(e))/t})),Qo("rounddown",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return t=Math.pow(10,t),(e=(e=Zo(e*t))<0?Math.ceil(e):Math.floor(e))/t})),Qo("even",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){var t=e<0?Math.floor(e):Math.ceil(e);return t%2?t+(t<0?-1:1):t})),Qo("odd",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){var t=e<0?Math.floor(e):Math.ceil(e);return t%2?t:t+(t<0?-1:1)})),Qo("sign",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e<0?-1:e>0?1:0})),Qo("gcd",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){for(var t=e[0],r=1;r<e.length;++r)t=la(t,e[r]);return t})),Qo("lcm",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){for(var t=e[0],r=1;r<e.length;++r)t=ca(t,e[r]);return t})),Qo("sum",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.reduce((function(e,t){return e+t}),0)})),Qo("product",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.reduce((function(e,t){return e*t}),1)})),Qo("sumproduct",!1,{check:function(e){var t,r,n=[],s=[],i=0,o="VALUE",a=e[i++];if(a instanceof K)return a;if(!(r=this.asMatrix(a))||!(a=r))return a instanceof K?a:new K(o);if(s.push(a),i>=e.length)return new K("N/A");s.push(t=[]),n.push(s),s=t;do{var u=e[i++];if(u instanceof K)return u;if(!(r=this.asMatrix(u))||!(u=r)||u.width!=a.width&&(o="N/A",1)||u.height!=a.height&&(o="N/A",1))return u instanceof K?u:new K(o);s.push(u)}while(i<e.length);return s=n.pop(),i<e.length?new K("N/A"):s},resolve:function(e,t){var r=[],n=0;for(r.push(e[n++]);n<e.length;)r.push(e[n++]);this.resolveCells(r,t)}},(function(e,t){var r=0;return e.each((function(e,n,s){if("number"==typeof e){for(var i=0;i<t.length;++i){var o=t[i].get(n,s);if("number"!=typeof o)return;e*=o}r+=e}})),r})),Qo("sumsq",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.reduce((function(e,t){return e+t*t}),0)})),Qo("sumx2my2",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!(t=this.asMatrix(o))||!(o=t)||o.width!=i.width&&(s="N/A",1)||o.height!=i.height&&(s="N/A",1)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){var r=0;return e.each((function(e,n,s){var i=t.get(n,s);"number"==typeof e&&"number"==typeof i&&(r+=e*e-i*i)})),r})),Qo("sumx2py2",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!(t=this.asMatrix(o))||!(o=t)||o.width!=i.width&&(s="N/A",1)||o.height!=i.height&&(s="N/A",1)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){var r=0;return e.each((function(e,n,s){var i=t.get(n,s);"number"==typeof e&&"number"==typeof i&&(r+=e*e+i*i)})),r})),Qo("sumxmy2",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!(t=this.asMatrix(o))||!(o=t)||o.width!=i.width&&(s="N/A",1)||o.height!=i.height&&(s="N/A",1)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){var r=0;return e.each((function(e,n,s){var i=t.get(n,s);"number"==typeof e&&"number"==typeof i&&(r+=(e-i)*(e-i))})),r})),Qo("seriessum",!1,{check:function(e){var t,r,n=[],s=0,i="VALUE",o=e[s++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(i);n.push(o);var a=e[s++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1))))return a instanceof K?a:new K(i);n.push(a);var u=e[s++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))))return u instanceof K?u:new K(i);n.push(u);var h=e[s++];return h instanceof K?h:(r=this.asMatrix(h))&&(h=r)?(n.push(h),4<e.length?new K("N/A"):n):h instanceof K?h:new K(i)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){var s=0;return n.each((function(n){if("number"!=typeof n)throw new K("VALUE");s+=n*Math.pow(e,t),t+=r})),s})),Qo("min",!1,{check:function(e){var t=[],r=0;try{var n=this.cellValues(e.slice(r)).reduce(function(e,t){if(t instanceof K)throw t;return"number"==typeof t&&(t=Zo(t),1)&&e.push(t),e}.bind(this),[]);r=e.length,t.push(n)}catch(e){if(e instanceof K)return e;throw e}return r<e.length?new K("N/A"):t},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.length?Math.min.apply(Math,e):0})),Qo("max",!1,{check:function(e){var t=[],r=0;try{var n=this.cellValues(e.slice(r)).reduce(function(e,t){if(t instanceof K)throw t;return"number"==typeof t&&(t=Zo(t),1)&&e.push(t),e}.bind(this),[]);r=e.length,t.push(n)}catch(e){if(e instanceof K)return e;throw e}return r<e.length?new K("N/A"):t},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.length?Math.max.apply(Math,e):0})),Qo("counta",!1,{check:function(e){var t=[],r=0;try{var n=this.cellValues(e.slice(r)).reduce(function(t,n){return null!=n&&r<=e.length&&t.push(n),t}.bind(this),[]);r=e.length,t.push(n)}catch(e){if(e instanceof K)return e;throw e}return r<e.length?new K("N/A"):t},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.length})),Qo("count",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.length})),Qo("countunique",!1,{check:function(e){var t=[],r=0;try{var n=this.cellValues(e.slice(r)).reduce(function(t,n){return null!=n&&r<=e.length&&t.push(n),t}.bind(this),[]);r=e.length,t.push(n)}catch(e){if(e instanceof K)return e;throw e}return r<e.length?new K("N/A"):t},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){var t=0,r=[];return e.forEach((function(e){r.indexOf(e)<0&&(t++,r.push(e))})),t})),Qo("countblank",!1,{check:function(e){var t,r,n=[],s=[],i=0;if(i>=e.length)return new K("N/A");s.push(t=[]),n.push(s),s=t;do{var o=e[i++];if(o instanceof K)return o;if(!((r=this.asMatrix(o))&&(o=r)||null!=o&&i<=e.length))return o instanceof K?o:new K("VALUE");s.push(o)}while(i<e.length);return s=n.pop(),i<e.length?new K("N/A"):s},resolve:function(e,t){for(var r=[],n=0;n<e.length;)r.push(e[n++]);this.resolveCells(r,t)}},(function(e){var t=0;function r(e){null!=e&&""!==e||t++}return function(e){for(var t=0;t<e.length;++t){var n=e[t];n instanceof ie?n.each(r,!0):r(n)}}(e),t})),Qo("iseven",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e%2==0})),Qo("isodd",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e%2!=0})),Qo("n",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:null!=(n=this.force(n))&&1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return"boolean"==typeof e?e?1:0:"number"==typeof e?e:0})),Qo("na",!1,{check:function(e){return 0<e.length?new K("N/A"):[]}},(function(){return new K("N/A")})),Qo("countifs",!1,{check:function(e){var t,r,n=[],s=[],i=0,o="VALUE",a=e[i++];if(a instanceof K)return a;if(!(r=this.asMatrix(a))||!(a=r))return a instanceof K?a:new K(o);s.push(a);var u=e[i++];if(u instanceof K)return u;if(!(null!=(u=this.force(u))&&i<=e.length))return u instanceof K?u:new K(o);for(s.push(u),s.push(t=[]),n.push(s),s=t;i<e.length;){var h=e[i++];if(h instanceof K)return h;if(!(r=this.asMatrix(h))||!(h=r))return h instanceof K?h:new K(o);s.push(h);var l=e[i++];if(l instanceof K)return l;if(!(null!=(l=this.force(l))&&i<=e.length))return l instanceof K?l:new K(o);s.push(l)}return s=n.pop(),i<e.length?new K("N/A"):s},resolve:function(e,t){var r=[],n=0;for(r.push(e[n++]),r.push(e[n++]);n<e.length;)r.push(e[n++]),r.push(e[n++]);this.resolveCells(r,t)}},(function(e,t,r){var n=0;return r.unshift(e,t),fa(r,(function(){n++})),n})),Qo("sumifs",!1,{check:function(e){var t,r,n=[],s=[],i=0,o="VALUE",a=e[i++];if(a instanceof K)return a;if(!(r=this.asMatrix(a))||!(a=r))return a instanceof K?a:new K(o);s.push(a);var u=e[i++];if(u instanceof K)return u;if(!(r=this.asMatrix(u))||!(u=r))return u instanceof K?u:new K(o);s.push(u);var h=e[i++];if(h instanceof K)return h;if(!(null!=(h=this.force(h))&&i<=e.length))return h instanceof K?h:new K(o);for(s.push(h),s.push(t=[]),n.push(s),s=t;i<e.length;){var l=e[i++];if(l instanceof K)return l;if(!(r=this.asMatrix(l))||!(l=r))return l instanceof K?l:new K(o);s.push(l);var c=e[i++];if(c instanceof K)return c;if(!(null!=(c=this.force(c))&&i<=e.length))return c instanceof K?c:new K(o);s.push(c)}return s=n.pop(),i<e.length?new K("N/A"):s},resolve:function(e,t){var r=[],n=0;for(r.push(e[n++]),r.push(e[n++]),r.push(e[n++]);n<e.length;)r.push(e[n++]),r.push(e[n++]);this.resolveCells(r,t)}},(function(e,t,r,n){n.unshift(e,Da,t,r);var s=0;return fa(n,(function(t,r){var n=e.get(t,r);n&&(s+=n)})),s})),Qo("averageifs",!1,{check:function(e){var t,r,n=[],s=[],i=0,o="VALUE",a=e[i++];if(a instanceof K)return a;if(!(r=this.asMatrix(a))||!(a=r))return a instanceof K?a:new K(o);s.push(a);var u=e[i++];if(u instanceof K)return u;if(!(r=this.asMatrix(u))||!(u=r))return u instanceof K?u:new K(o);s.push(u);var h=e[i++];if(h instanceof K)return h;if(!(null!=(h=this.force(h))&&i<=e.length))return h instanceof K?h:new K(o);for(s.push(h),s.push(t=[]),n.push(s),s=t;i<e.length;){var l=e[i++];if(l instanceof K)return l;if(!(r=this.asMatrix(l))||!(l=r))return l instanceof K?l:new K(o);s.push(l);var c=e[i++];if(c instanceof K)return c;if(!(null!=(c=this.force(c))&&i<=e.length))return c instanceof K?c:new K(o);s.push(c)}return s=n.pop(),i<e.length?new K("N/A"):s},resolve:function(e,t){var r=[],n=0;for(r.push(e[n++]),r.push(e[n++]),r.push(e[n++]);n<e.length;)r.push(e[n++]),r.push(e[n++]);this.resolveCells(r,t)}},(function(e,t,r,n){n.unshift(e,Da,t,r);var s=0,i=0;return fa(n,(function(t,r){var n=e.get(t,r);null!=n&&""!==n||(n=0),s+=n,i++})),i?s/i:new K("DIV/0")})),Qo("countif",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:null!=(o=this.force(o))&&2<=e.length?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0;t.push(e[i++]),s.push(!1);var o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){t=La(t);var r=0;return e.each((function(e){t(e)&&r++})),r})),Qo("sumif",!0,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!(null!=(o=this.force(o))&&n<=e.length))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:a instanceof c||a instanceof f||(t=this.asMatrix(a))&&(a=t)||null==(a=this.force(a))&&(a=i,1)?(r.push(a),n<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0;t.push(e[i++]),s.push(!1);var o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,t.push(e[i++]),s.push(!1),{args:t,width:r,height:n,arrays:s}}},pa((function(e,t,r){var n=0;return t=La(t),e.each((function(e,s,i){if(t(e)){var o=r.get(s,i);Da(o)&&(n+=o||0)}})),n}))),Qo("averageif",!0,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!(null!=(o=this.force(o))&&n<=e.length))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:a instanceof c||a instanceof f||(t=this.asMatrix(a))&&(a=t)||null==(a=this.force(a))&&(a=i,1)?(r.push(a),n<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0;t.push(e[i++]),s.push(!1);var o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,t.push(e[i++]),s.push(!1),{args:t,width:r,height:n,arrays:s}}},pa((function(e,t,r){var n=0,s=0;return t=La(t),e.each((function(e,i,o){if(t(e)){var a=r.get(i,o);Da(a)&&(n+=a||0,s++)}})),s?n/s:new K("DIV/0")}))),Qo("large",!1,{check:function(e){var t,r,n=[],s=0,i="VALUE",o=e[s++];if(o instanceof K)return o;if(!(r=this.asMatrix(o))||!(o=r))return o instanceof K?o:new K(i);n.push(o);var a=e[s++];return a instanceof K?a:("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&(a>0||(i="NUM",0))?(n.push(a),2<e.length?new K("N/A"):n):a instanceof K?a:new K(i)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0;t.push(e[i++]),s.push(!1);var o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return da(e,t,Va)})),Qo("small",!1,{check:function(e){var t,r,n=[],s=0,i="VALUE",o=e[s++];if(o instanceof K)return o;if(!(r=this.asMatrix(o))||!(o=r))return o instanceof K?o:new K(i);n.push(o);var a=e[s++];return a instanceof K?a:("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&(a>0||(i="NUM",0))?(n.push(a),2<e.length?new K("N/A"):n):a instanceof K?a:new K(i)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0;t.push(e[i++]),s.push(!1);var o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return da(e,t,Ua)})),Qo("stdev.s",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length>=2||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return va(e,e.length-1)})),Qo("stdev.p",!1,{check:function(e){var t=[],r=0,n="VALUE";try{var s=this.cellValues(e.slice(r)).reduce(function(e,t){if(t instanceof K)throw t;return"number"==typeof t&&(t=Zo(t),1)&&e.push(t),e}.bind(this),[]);r=e.length,t.push(s)}catch(e){if(e instanceof K)return e;throw e}return s.length>=1||(n="NUM",0)?r<e.length?new K("N/A"):t:new K(n)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return va(e,e.length)})),Qo("var.s",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length>=2||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return ma(e,e.length-1)})),Qo("var.p",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length>=2||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return ma(e,e.length)})),Qo("median",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length>0||(s="N/A",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){var t=e.length;return e.sort(Ua),t%2?e[t>>1]:(e[t>>=1]+e[t-1])/2})),Qo("mode.sngl",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){e.sort(Ua);for(var t=null,r=0,n=1,s=null,i=0;i<e.length;++i){var o=e[i];o!=t?(r=1,t=o):r++,r>n&&(n=r,s=o)}return null==s?new K("N/A"):s})),Qo("mode.mult",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){var t=Object.create(null),r=2,n=[];e.forEach((function(e){var s=t[e]||0;t[e]=++s,s==r?n.push(e):s>r&&(r=s,n=[e])}));var s=new ie(this);return n.forEach((function(e,t){s.set(t,0,e)})),s})),Qo("geomean",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length>0||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){var t=e.length,r=e.reduce((function(e,t){if(t<0)throw new K("NUM");return e*t}),1);return Math.pow(r,1/t)})),Qo("harmean",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length>0||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.length/e.reduce((function(e,t){if(!t)throw new K("DIV/0");return e+1/t}),0)})),Qo("trimmean",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o>=0&&o<1||(s="NUM",0))?(r.push(o),i.length>0||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){var r=e.length;e.sort(Ua);var n=Math.floor(r*t);n%2&&--n;for(var s=0,i=n/=2;i<r-n;++i)s+=e[i];return s/(r-2*n)})),Qo("frequency",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(s)}catch(e){if(e instanceof K)return e;throw e}try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){e.sort(Ua),t.sort(Ua);var r=-1/0,n=0;function s(t){for(var s=0;n<e.length&&e[n]>r&&e[n]<=t;)++s,++n;return s}var i=new ie(this);return t.forEach((function(e,t){var n=s(e);r=e,i.set(t,0,n)})),i.set(i.height,0,e.length-n),i})),Qo("rank.eq",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)||null==a&&(a=!1,1)?(r.push(a),n<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){t.sort(r?Ua:Va);var n=t.indexOf(e);return n<0?new K("N/A"):n+1})),te.runtime.defineAlias("rank","rank.eq"),Qo("rank.avg",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);try{var o=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(o)}catch(e){if(e instanceof K)return e;throw e}var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)||null==a&&(a=!1,1)?(r.push(a),n<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){t.sort(r?Ua:Va);var n=t.indexOf(e);if(n<0)return new K("N/A");for(var s=n;t[s]==e;++s);return(n+s+1)/2})),Qo("kurt",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length>=4||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){var t=e.length,r=ga(e),n=ma(e,t-1,r),s=Math.sqrt(n);return t*(t+1)/((t-1)*(t-2)*(t-3))*e.reduce((function(e,t){return e+Math.pow((t-r)/s,4)}),0)-3*Math.pow(t-1,2)/((t-2)*(t-3))})),Qo("percentrank.inc",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:null==(a=this.force(a))&&(a=3,1)||("number"==typeof a||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>0||(s="NUM",0))?(r.push(a),i.length>0||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){var n=ya(e,t,0);return n=n.toFixed(r+1),parseFloat(n.substr(0,n.length-1))})),Qo("percentrank.exc",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:null==(a=this.force(a))&&(a=3,1)||("number"==typeof a||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>0||(s="NUM",0))?(r.push(a),i.length>0||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){var n=ya(e,t,1);return n=n.toFixed(r+1),parseFloat(n.substr(0,n.length-1))})),te.runtime.defineAlias("percentrank","percentrank.inc"),Qo("covariance.p",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}return i.length!=o.length&&(s="N/A",1)?new K(s):i.length>0||(s="DIV/0",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){return wa(e,t,e.length)})),Qo("covariance.s",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}return i.length!=o.length&&(s="N/A",1)?new K(s):i.length>1||(s="DIV/0",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){return wa(e,t,e.length-1)})),te.runtime.defineAlias("covar","covariance.p");var ba=$((function(e){for(var t=2,r=1;t<=e;++t)r*=t;return r}));Qo("fact",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&((i|=0)>=0||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},ba),Qo("factdouble",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&((i|=0)>=0||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){for(var t=2+(1&e),r=1;t<=e;t+=2)r*=t;return r})),Qo("multinomial",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(s)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){var t=1,r=0;return e.forEach((function(e){if(e<0)throw new K("NUM");r+=e,t*=ba(e)})),ba(r)/t}));var _a=$((function(e,t){for(var r=t+1,n=1,s=1,i=1;n<=e-t;++r,++n)s*=r,i*=n;return s/i}));function Aa(e,t){e.sort(Ua);var r=e.length,n=0|t,s=t-n;return 0===n?e[0]:n>=r?e[r-1]:e[--n]+s*(e[n+1]-e[n])}function Ca(e,t){return Aa(e,t*(e.length-1)+1)}function xa(e,t){return Aa(e,t*(e.length+1))}Qo("combin",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!((i|=0)>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o|=0,1)&&(o>=0&&o<=i||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},_a),Qo("combina",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!((i|=0)>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o|=0,1)&&(o>=1&&o<=i||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return _a(e+t-1,e-1)})),Qo("average",!1,{check:function(e){var t=[],r=0,n="VALUE";try{var s=this.cellValues(e.slice(r)).reduce(function(e,t){if(t instanceof K)throw t;return"number"==typeof t&&(t=Zo(t),1)&&e.push(t),e}.bind(this),[]);r=e.length,t.push(s)}catch(e){if(e instanceof K)return e;throw e}return s.length>0||(n="DIV/0",0)?r<e.length?new K("N/A"):t:new K(n)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){return e.reduce((function(e,t){return e+t}),0)/e.length})),Qo("averagea",!1,{check:function(e){var t=[],r=0;try{var n=this.cellValues(e.slice(r)).reduce(function(t,n){if(n instanceof K)throw n;return null!=n&&r<=e.length&&t.push(n),t}.bind(this),[]);r=e.length,t.push(n)}catch(e){if(e instanceof K)return e;throw e}return r<e.length?new K("N/A"):t},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){var t=0,r=0;return e.forEach((function(e){"string"!=typeof e&&(t+=e),++r})),r?t/r:new K("DIV/0")})),Qo("percentile.inc",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o>=0&&o<=1||(s="NUM",0))?(r.push(o),n<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},Ca),Qo("percentile.exc",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o>0&&o<1||(s="NUM",0))?(r.push(o),n<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},xa),Qo("quartile.inc",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(s)}catch(e){if(e instanceof K)return e;throw e}var i=e[n++];return i instanceof K?i:0!==(i=this.force(i))&&1!==i&&2!==i&&3!==i&&4!==i?i instanceof K?i:new K("VALUE"):(r.push(i),n<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return Ca(e,t/4)})),Qo("quartile.exc",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(s)}catch(e){if(e instanceof K)return e;throw e}var i=e[n++];return i instanceof K?i:0!==(i=this.force(i))&&1!==i&&2!==i&&3!==i&&4!==i?i instanceof K?i:new K("VALUE"):(r.push(i),n<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return xa(e,t/4)})),te.runtime.defineAlias("quartile","quartile.inc"),te.runtime.defineAlias("percentile","percentile.inc");var ka=["AVERAGE","COUNT","COUNTA","MAX","MIN","PRODUCT","STDEV.S","STDEV.P","SUM","VAR.S","VAR.P","MEDIAN","MODE.SNGL","LARGE","SMALL","PERCENTILE.INC","QUARTILE.INC","PERCENTILE.EXC","QUARTILE.EXC"];function Ma(e,t,r){var n=[];return function t(s){if(s instanceof u)e.getRefCells(s,!0).forEach((function(e){var t=e.value;if(!(1&r&&e.hidden)){if(e.formula){var s=e.formula.print(e.row,e.col);if(/^\s*(?:aggregate|subtotal)\s*\(/i.test(s)&&!(4&r))return}2&r&&t instanceof K||("number"==typeof t||t instanceof K)&&n.push(t)}}));else if(Array.isArray(s))for(var i=0;i<s.length;++i)t(s[i]);else s instanceof ie?s.each(t):("number"==typeof s||s instanceof K&&!(2&r))&&n.push(s)}(t),n}function Ea(e,t,r,n){if(n){for(var s=0,i=0;i<=e;++i)s+=_a(t,i)*Math.pow(r,i)*Math.pow(1-r,t-i);return s}return _a(t,e)*Math.pow(r,e)*Math.pow(1-r,t-e)}function Fa(e){var t=ta(ea(e,0,1));return 4==t.day||3==t.day&&te.runtime.isLeapYear(e)?53:52}function Ra(e,t,r){var n=ta(e),s=ta(t);return r?(31==n.date&&(n.date=30),31==s.date&&(s.date=30)):(1==n.month&&1==s.month&&n.date==ra(n.year,1)&&s.date==ra(s.year,1)&&(s.date=30),n.date==ra(n.year,n.month)?(n.date=30,31==s.date&&(s.date=30)):30==n.date&&31==s.date&&(s.date=30)),360*(s.year-n.year)+30*(s.month-n.month)+(s.date-n.date)}Qo("aggregate",!0,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(1!==(s=this.force(s))&&2!==s&&3!==s&&4!==s&&5!==s&&6!==s&&7!==s&&8!==s&&9!==s&&10!==s&&11!==s&&12!==s&&13!==s&&14!==s&&15!==s&&16!==s&&17!==s&&18!==s&&19!==s)return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:null==(i=this.force(i))&&(i=0,1)||0===i||1===i||2===i||3===i||4===i||5===i||6===i||7===i?(t.push(i),t.push(e.slice(r)),(r=e.length)<e.length?new K("N/A"):t):i instanceof K?i:new K(n)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){var s=this;s.resolveCells(n,(function(){var i;if(t>12){i=Ma(s,n[0],r);var o=n[1];if(o instanceof c&&(o=s.getRefData(o)),"number"!=typeof o)return e(new K("VALUE"))}else i=Ma(s,n,r);s.func(ka[t-1],e,i)}))})),Qo("subtotal",!0,{check:function(e){var t,r,n=[],s=[],i=0,o="VALUE",a=e[i++];if(a instanceof K)return a;if(1!==(a=this.force(a))&&2!==a&&3!==a&&4!==a&&5!==a&&6!==a&&7!==a&&8!==a&&9!==a&&10!==a&&11!==a&&101!==a&&102!==a&&103!==a&&104!==a&&105!==a&&106!==a&&107!==a&&108!==a&&109!==a&&110!==a&&111!==a)return a instanceof K?a:new K(o);if(s.push(a),i>=e.length)return new K("N/A");s.push(t=[]),n.push(s),s=t;do{var h=e[i++];if(h instanceof K)return h;if(!(h instanceof u||(r=this.asMatrix(h))&&(h=r)))return new K(o);s.push(h)}while(i<e.length);return s=n.pop(),i<e.length?new K("N/A"):s},resolve:function(e,t){var r=[],n=0;for(r.push(e[n++]);n<e.length;)n++;this.resolveCells(r,t)}},(function(e,t){var r=this,n=t>100;n&&(t-=100);for(var s=[],i=2;i<arguments.length;++i)s.push(arguments[i]);r.resolveCells(s,(function(){var i=Ma(r,s,n?1:0);r.func(ka[t-1],e,i)}))})),Qo("avedev",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length>=2||(s="NUM",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e){var t=e.reduce((function(e,t){return e+t}),0)/e.length;return e.reduce((function(e,r){return e+Math.abs(r-t)}),0)/e.length})),Qo("binom.dist",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!((i|=0)>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!(("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o|=0,1)&&(o>=i||(s="N/A",0))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>=0&&a<=1||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},Ea),te.runtime.defineAlias("binomdist","binom.dist"),Qo("binom.inv",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!((i|=0)>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>=0&&o<=1||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&(a>=0&&a<=1||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){for(var n=0;n<=e;++n)if(Ea(n,e,t,!0)>=r)return n;return new K("N/A")})),te.runtime.defineAlias("critbinom","binom.inv"),Qo("binom.dist.range",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!((i|=0)>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>=0&&o<=1||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!(("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&(a|=0,1)&&(a>=0&&a<=i||(s="NUM",0))))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:("number"==typeof(u=this.force(u))||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u|=0,1)&&(u>=a&&u<=i||(s="NUM",0))||null==u&&(u=a,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){for(var s=0,i=r;i<=n;++i)s+=_a(e,i)*Math.pow(t,i)*Math.pow(1-t,e-i);return s})),Qo("negbinom.dist",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!((i|=0)>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>=0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>=0&&a<=1||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){if(n){for(var s=0;e>=0;)s+=_a(e+t-1,e)*Math.pow(r,t)*Math.pow(1-r,e),e--;return s}return _a(e+t-1,e)*Math.pow(r,t)*Math.pow(1-r,e)})),te.runtime.defineAlias("negbinomdist","negbinom.dist"),Qo("address",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!((i|=0)>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!(null==(a=this.force(a))&&(a=1,1)||1===a||2===a||3===a||4===a))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!(null==(u=this.force(u))&&(u=!0,1)||"boolean"==typeof u||"number"==typeof u&&(u=!!u,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:null==(h=this.force(h))||("string"==typeof h||"boolean"==typeof h||"number"==typeof h?(h+="",1):void 0===h&&(h="",1))?(r.push(h),5<e.length?new K("N/A"):r):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=new c(e-1,t-1,r-1);return s&&i.setSheet(s,!0),n?i.print(0,0):i.print()})),Qo("areas",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:n instanceof u?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")}},(function(e){var t=0;return function e(r){r instanceof c||r instanceof f?t++:r instanceof p&&r.refs.forEach(e)}(e),t})),Qo("choose",!1,{check:function(e){var t,r=[],n=[],s=0,i="VALUE",o=e[s++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(i);if(n.push(o),s>=e.length)return new K("N/A");n.push(t=[]),r.push(n),n=t;do{var a=e[s++];if(a instanceof K)return a;if(!(s<=e.length))return new K(i);n.push(a)}while(s<e.length);return n=r.pop(),s<e.length?new K("N/A"):n},resolve:function(e,t){var r=[],n=0;for(r.push(e[n++]);n<e.length;)n++;this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);for(o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;i<e.length;)t.push(e[i++]),s.push(!1);return{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e>t.length?new K("N/A"):t[e-1]})),Qo("column",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:n instanceof c||n instanceof f||null==(n=this.force(n))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return e?e instanceof c?e.col+1:this.asMatrix(e).mapCol((function(t){return t+e.topLeft.col+1})):this.formula.col+1})),Qo("columns",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:s instanceof c||s instanceof f||(t=this.asMatrix(s))&&(s=t)?(r.push(s),1<e.length?new K("N/A"):r):new K("VALUE")}},(function(e){return e instanceof u?e.width():e.width})),Qo("formulatext",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:n instanceof u?(t.push(n),1<e.length?new K("N/A"):t):new K("VALUE")}},(function(e){var t=this.getRefCells(e)[0];return t.formula?t.formula.print(t.row,t.col):new K("N/A")})),Qo("hlookup",!1,{check:function(e){var t,r,n=[],s=0,i="VALUE",o=e[s++];if(o instanceof K)return o;if(!(null!=(o=this.force(o))&&s<=e.length))return o instanceof K?o:new K(i);n.push(o);var a=e[s++];if(a instanceof K)return a;if(!(r=this.asMatrix(a))||!(a=r))return a instanceof K?a:new K(i);n.push(a);var u=e[s++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!((u|=0)>0||(i="NUM",0)))return u instanceof K?u:new K(i);n.push(u);var h=e[s++];return h instanceof K?h:"boolean"==typeof(h=this.force(h))||"number"==typeof h&&(h=!!h,1)||null==h&&(h=!0,1)?(n.push(h),s<e.length?new K("N/A"):n):h instanceof K?h:new K(i)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){var s=null;return t.eachCol((function(r){var i=t.get(0,r);if(n){if(i>e)return!0;s=r}else if(i===e)return s=r,!0})),null==s?new K("N/A"):t.get(r-1,s)})),Qo("index",!0,{check:function(e){var t,r,n=[],s=0,i="VALUE",o=e[s++];if(o instanceof K)return o;if(!(o instanceof u||(r=this.asMatrix(o))&&(o=r)))return o instanceof K?o:new K(i);n.push(o);var a=e[s++];if(a instanceof K)return a;if(!(("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>=0||(i="NUM",0))||null==a))return a instanceof K?a:new K(i);n.push(a);var h=e[s++];if(h instanceof K)return h;if(!(("number"==typeof(h=this.force(h))||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))&&((h|=0)>=0||(i="NUM",0))||null==h))return h instanceof K?h:new K(i);n.push(h);var l=e[s++];return l instanceof K?l:("number"==typeof(l=this.force(l))||"boolean"==typeof l&&(l=+l,1)||"string"==typeof l&&!/^(?:=|true|false)/i.test(l)&&(t=te.parse(0,0,0,l),/^date|number|percent$/.test(t.type)&&(l=+t.value,1)))&&((l|=0)>0||(i="NUM",0))||null==l&&(l=1,1)?(n.push(l),4<e.length?new K("N/A"):n):l instanceof K?l:new K(i)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=this;if(t instanceof p&&(t=t.refs[s-1]),!r&&!n||!t)return e(new K("N/A"));if(t instanceof c&&(t=t.toRangeRef()),t instanceof f){if(r&&n){if(n>t.width()||r>t.height())return e(new K("REF"));var o=t.toCell(r-1,n-1);return void i.resolveCells([o],(function(){e(i.getRefData(o))}))}if(!r){var a=t.toColumn(n-1);return void i.resolveCells([a],(function(){e(i.asMatrix(a))}))}if(!n){var u=t.toRow(r-1);return void i.resolveCells([u],(function(){e(i.asMatrix(u))}))}}else if(t instanceof ie){if(t.width>1&&t.height>1){if(r&&n)return e(t.get(r-1,n-1));if(!r)return e(t.mapRow((function(e){return t.get(e,n-1)})));if(!n)return e(t.mapCol((function(e){return t.get(r-1,e)})))}if(1==t.width)return e(t.get((r||1)-1,0));if(1==t.height)return e(t.get(0,(n||1)-1))}else e(new K("REF"))})),Qo("indirect",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){try{var t=this.formula,r=te.parseFormula(t.sheet,t.row,t.col,e).ast;if(r instanceof l&&(r=this.ss.nameValue(r,t.sheet,t.row,t.col)),!(r instanceof u))throw 1;return r.absolute(t.row,t.col)}catch(e){return new K("REF")}})),Qo("match",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(null!=(i=this.force(i))&&n<=e.length))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!(t=this.asMatrix(o))||!(o=t))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:-1===(a=this.force(a))||0===a||1===a||null==a&&(a=1,1)?(r.push(a),n<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){var n,s=1;return 0===r?n=La(e):-1===r?n=La("<="+e):1===r&&(n=La(">="+e)),t.each((function(t){if(null!=t&&n(t))return 0!==r&&e!=t&&--s,!0;s++}),!0)&&s>0?s:new K("N/A")})),Qo("offset",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(i instanceof c||i instanceof f))return new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!(("number"==typeof(u=this.force(u))||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&((u|=0)>0||(s="NUM",0))||null==u&&(u=i.height(),1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:("number"==typeof(h=this.force(h))||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))&&((h|=0)>0||(s="NUM",0))||null==h&&(h=i.width(),1)?(r.push(h),5<e.length?new K("N/A"):r):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;n++,r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0;t.push(e[i++]),s.push(!1);var o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var h=this._arrayArg(e[i]);return h?(t.push(h),r=Math.max(r,h.width),n=Math.max(n,h.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r,n,s){var i=(e instanceof c?e:e.topLeft).clone();return i.row+=t,i.col+=r,i.row<0||i.col<0?new K("VALUE"):n>1||s>1?new f(i,new c(i.row+n-1,i.col+s-1)).setSheet(e.sheet,e.hasSheet()):i})),Qo("row",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:n instanceof c||n instanceof f||null==(n=this.force(n))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return e?e instanceof c?e.row+1:this.asMatrix(e).mapRow((function(t){return t+e.topLeft.row+1})):this.formula.row+1})),Qo("rows",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:s instanceof c||s instanceof f||(t=this.asMatrix(s))&&(s=t)?(r.push(s),1<e.length?new K("N/A"):r):new K("VALUE")}},(function(e){return e instanceof u?e.height():e.height})),Qo("vlookup",!1,{check:function(e){var t,r,n=[],s=0,i="VALUE",o=e[s++];if(o instanceof K)return o;if(!(null!=(o=this.force(o))&&s<=e.length))return o instanceof K?o:new K(i);n.push(o);var a=e[s++];if(a instanceof K)return a;if(!(r=this.asMatrix(a))||!(a=r))return a instanceof K?a:new K(i);n.push(a);var u=e[s++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!((u|=0)>0||(i="NUM",0)))return u instanceof K?u:new K(i);n.push(u);var h=e[s++];return h instanceof K?h:"boolean"==typeof(h=this.force(h))||"number"==typeof h&&(h=!!h,1)||null==h&&(h=!0,1)?(n.push(h),s<e.length?new K("N/A"):n):h instanceof K?h:new K(i)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){var s=null;return"number"!=typeof e&&(n=!1),"string"==typeof e&&(e=e.toLowerCase()),t.eachRow((function(r){var i=t.get(r,0);if(n){if(i>e)return!0;s=r}else if("string"==typeof i&&(i=i.toLowerCase()),i===e)return s=r,!0})),null==s?new K("N/A"):t.get(s,r-1)})),Qo("date",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)?a instanceof K?a:new K(s):(r.push(a),3<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){return ea(e,t-1,r)})),Qo("day",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:!("number"==typeof(s=this.force(s))||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1)))||(s|=0,0)?s instanceof K?s:new K("VALUE"):(r.push(s),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return ta(e).date})),Qo("month",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:!("number"==typeof(s=this.force(s))||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1)))||(s|=0,0)?s instanceof K?s:new K("VALUE"):(r.push(s),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return ta(e).month+1})),Qo("year",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:!("number"==typeof(s=this.force(s))||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1)))||(s|=0,0)?s instanceof K?s:new K("VALUE"):(r.push(s),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return ta(e).year})),Qo("weekday",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:!("number"==typeof(s=this.force(s))||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1)))||(s|=0,0)?s instanceof K?s:new K("VALUE"):(r.push(s),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return ta(e).day+1})),Qo("weeknum",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:null==(o=this.force(o))&&(o=1,1)||1===o||2===o||11===o||12===o||13===o||14===o||15===o||16===o||17===o||21===o?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){var r,n=ea(ta(e).year,0,1),s=ta(n);return 21==t?((r=3-(s.day+6)%7)<0&&(r+=7),n+=r,s.date+=r,s.day=4,t=1):t=1==t?0:2==t?1:(t-10)%7,(r=s.day-t)<0&&(r+=7),n-=r,Math.ceil((e+1-n)/7)})),Qo("isoweeknum",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:!("number"==typeof(s=this.force(s))||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1)))||(s|=0,0)?s instanceof K?s:new K("VALUE"):(r.push(s),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){var t=ta(e),r=t.day||7,n=Math.floor((t.ord-r+10)/7);return n<1?Fa(t.year-1):53==n&&n>Fa(t.year)?1:n})),Qo("now",!1,{check:function(e){return 0<e.length?new K("N/A"):[]}},(function(){return te.runtime.dateToSerial(new Date)})),Qo("today",!1,{check:function(e){return 0<e.length?new K("N/A"):[]}},(function(){return 0|te.runtime.dateToSerial(new Date)})),Qo("time",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)?a instanceof K?a:new K(s):(r.push(a),3<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){return te.runtime.packTime(e,t,r,0)})),Qo("hour",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return te.runtime.unpackTime(e).hours})),Qo("minute",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return te.runtime.unpackTime(e).minutes})),Qo("second",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return te.runtime.unpackTime(e).seconds})),Qo("edate",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){var r=ta(e),n=r.month+t,s=r.year+Math.floor(n/12);return(n%=12)<0&&(n+=12),r=Math.min(r.date,ra(s,n)),ea(s,n,r)})),Qo("eomonth",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){var r=ta(e),n=r.month+t,s=r.year+Math.floor(n/12);return(n%=12)<0&&(n+=12),r=ra(s,n),ea(s,n,r)})),Qo("workday",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);try{var a=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&(r|=0,1)&&e.push(r),e}.bind(this),[]);n=e.length,r.push(a)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e.slice(2)),this.resolveCells(r,t)}},(function(e,t,r){var n=t>0?1:-1;t=Math.abs(t);for(var s=ta(e).day;t>0;)e+=n,(s=(s+n)%7)>0&&s<6&&r.indexOf(e)<0&&--t;return e})),Qo("networkdays",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);try{var a=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&(r|=0,1)&&e.push(r),e}.bind(this),[]);n=e.length,r.push(a)}catch(e){if(e instanceof K)return e;throw e}return n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e.slice(2)),this.resolveCells(r,t)}},(function(e,t,r){if(e>t){var n=e;e=t,t=n}for(var s=0,i=ta(e).day;e<=t;)i>0&&i<6&&r.indexOf(e)<0&&s++,e++,i=(i+1)%7;return s})),Qo("days",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e-t})),te.runtime._days_360=Ra,Qo("days360",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)||null==a&&(a=!1,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},Ra),Qo("yearfrac",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:null==(a=this.force(a))&&(a=0,1)||0===a||1===a||2===a||3===a||4===a?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){switch(r){case 0:return Ra(e,t,!1)/360;case 1:return(t-e)/na(ta(e).year);case 2:return(t-e)/360;case 3:return(t-e)/365;case 4:return Ra(e,t,!0)/360}})),Qo("datevalue",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){var t=te.runtime.parseDate(e);return t?te.runtime.dateToSerial(t):new K("VALUE")})),Qo("timevalue",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){var t=e.toLowerCase().match(/(\d+):(\d+)(:(\d+)(\.(\d+))?)?\s*(am?|pm?)?/);if(t){var r=parseFloat(t[1]),n=parseFloat(t[2]),s=t[3]?parseFloat(t[4]):0,i=t[7];return i&&(r>12||r<1)?new K("VALUE"):(/^p/.test(i)&&(r+=12),te.runtime.packTime(r,n,s,0))}return new K("VALUE")})),Qo("mdeterm",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:!(t=this.asMatrix(i))||!(i=t)||i.width!=i.height&&(s="N/A",1)?i instanceof K?i:new K(s):(r.push(i),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return e.each((function(e){if("number"!=typeof e)return new K("VALUE")}),!0)||e.determinant()})),Qo("transpose",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:(t=this.asMatrix(s))&&(s=t)?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return e.transpose()})),Qo("mmult",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:!(t=this.asMatrix(o))||!(o=t)||o.height!=i.width&&(s="N/A",1)?o instanceof K?o:new K(s):(r.push(o),2<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return e.multiply(t)})),Qo("munit",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&((i|=0)>=0||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return new ie(this).unit(e)})),Qo("minverse",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:!(t=this.asMatrix(i))||!(i=t)||i.width!=i.height&&(s="N/A",1)?i instanceof K?i:new K(s):(r.push(i),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return e.each((function(e){if("number"!=typeof e)return new K("VALUE")}),!0)||e.inverse()||new K("VALUE")})),Qo("rand",!1,{check:function(e){return 0<e.length?new K("N/A"):[]}},(function(){return Math.random()})),Qo("randbetween",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o|=0,1)&&(o>=i||(s="N/A",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return e+Math.floor((t-e+1)*Math.random())})),Qo("true",!1,{check:function(e){return 0<e.length?new K("N/A"):[]}},(function(){return!0})),Qo("false",!1,{check:function(e){return 0<e.length?new K("N/A"):[]}},(function(){return!0})),Qo("roman",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:!("number"==typeof(s=this.force(s))||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1)))||(s|=0,0)?s instanceof K?s:new K("VALUE"):(r.push(s),1<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return function(e){let t={1:"i",10:"x",100:"c",2:"ii",20:"xx",200:"cc",3:"iii",30:"xxx",300:"ccc",4:"iv",40:"xl",400:"cd",5:"v",50:"l",500:"d",6:"vi",60:"lx",600:"dc",7:"vii",70:"lxx",700:"dcc",8:"viii",80:"lxxx",800:"dccc",9:"ix",90:"xc",900:"cm",1e3:"m"},r=[1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],n="";for(;e>0;)e<r[0]?r.shift():(n+=t[r[0]],e-=r[0]);return n}(e).toUpperCase()})),Qo("arabic",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){var t=function(e){e=e.toLowerCase();let t={i:1,v:5,x:10,l:50,c:100,d:500,m:1e3},r=0,n=0;for(let s=0;s<e.length;++s){let i=t[e.charAt(s)];if(!i)return null;r+=i,i>n&&(r-=2*n),n=i}return r}(e);return null==t?new K("VALUE"):t})),Qo("base",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!(("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o|=0,1)&&(o>=2&&o<=36||(s="NUM",0))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>=0||(s="NUM",0))||null==a&&(a=0,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){for(var n=e.toString(t).toUpperCase();n.length<r;)n="0"+n;return n})),Qo("decimal",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o|=0,1)&&(o>=2&&o<=36||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){e=e.toUpperCase();for(var r=0,n=0;n<e.length;++n){var s=e.charCodeAt(n);if(s>=48&&s<=57)s-=48;else{if(!(s>=65&&s<55+t))return new K("VALUE");s-=55}r=r*t+s}return r})),Qo("char",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&((i|=0)>=0||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return String.fromCharCode(e)}));var Sa=/[\0-\x1F\x7F-\x9F\xAD\u0378\u0379\u037F-\u0383\u038B\u038D\u03A2\u0528-\u0530\u0557\u0558\u0560\u0588\u058B-\u058E\u0590\u05C8-\u05CF\u05EB-\u05EF\u05F5-\u0605\u061C\u061D\u06DD\u070E\u070F\u074B\u074C\u07B2-\u07BF\u07FB-\u07FF\u082E\u082F\u083F\u085C\u085D\u085F-\u089F\u08A1\u08AD-\u08E3\u08FF\u0978\u0980\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09FC-\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF2-\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B55\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B78-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BFB-\u0C00\u0C04\u0C0D\u0C11\u0C29\u0C34\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5A-\u0C5F\u0C64\u0C65\u0C70-\u0C77\u0C80\u0C81\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0D01\u0D04\u0D0D\u0D11\u0D3B\u0D3C\u0D45\u0D49\u0D4F-\u0D56\u0D58-\u0D5F\u0D64\u0D65\u0D76-\u0D78\u0D80\u0D81\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DF1\u0DF5-\u0E00\u0E3B-\u0E3E\u0E5C-\u0E80\u0E83\u0E85\u0E86\u0E89\u0E8B\u0E8C\u0E8E-\u0E93\u0E98\u0EA0\u0EA4\u0EA6\u0EA8\u0EA9\u0EAC\u0EBA\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F48\u0F6D-\u0F70\u0F98\u0FBD\u0FCD\u0FDB-\u0FFF\u10C6\u10C8-\u10CC\u10CE\u10CF\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u137D-\u137F\u139A-\u139F\u13F5-\u13FF\u169D-\u169F\u16F1-\u16FF\u170D\u1715-\u171F\u1737-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17DE\u17DF\u17EA-\u17EF\u17FA-\u17FF\u180F\u181A-\u181F\u1878-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191D-\u191F\u192C-\u192F\u193C-\u193F\u1941-\u1943\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19DD\u1A1C\u1A1D\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1A9F\u1AAE-\u1AFF\u1B4C-\u1B4F\u1B7D-\u1B7F\u1BF4-\u1BFB\u1C38-\u1C3A\u1C4A-\u1C4C\u1C80-\u1CBF\u1CC8-\u1CCF\u1CF7-\u1CFF\u1DE7-\u1DFB\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FC5\u1FD4\u1FD5\u1FDC\u1FF0\u1FF1\u1FF5\u1FFF\u200B-\u200F\u202A-\u202E\u2060-\u206F\u2072\u2073\u208F\u209D-\u209F\u20BB-\u20CF\u20F1-\u20FF\u218A-\u218F\u23F4-\u23FF\u2427-\u243F\u244B-\u245F\u2700\u2B4D-\u2B4F\u2B5A-\u2BFF\u2C2F\u2C5F\u2CF4-\u2CF8\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D71-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E3C-\u2E7F\u2E9A\u2EF4-\u2EFF\u2FD6-\u2FEF\u2FFC-\u2FFF\u3040\u3097\u3098\u3100-\u3104\u312E-\u3130\u318F\u31BB-\u31BF\u31E4-\u31EF\u321F\u32FF\u4DB6-\u4DBF\u9FCD-\u9FFF\uA48D-\uA48F\uA4C7-\uA4CF\uA62C-\uA63F\uA698-\uA69E\uA6F8-\uA6FF\uA78F\uA794-\uA79F\uA7AB-\uA7F7\uA82C-\uA82F\uA83A-\uA83F\uA878-\uA87F\uA8C5-\uA8CD\uA8DA-\uA8DF\uA8FC-\uA8FF\uA954-\uA95E\uA97D-\uA97F\uA9CE\uA9DA-\uA9DD\uA9E0-\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A\uAA5B\uAA7C-\uAA7F\uAAC3-\uAADA\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F-\uABBF\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBC2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFE\uFDFF\uFE1A-\uFE1F\uFE27-\uFE2F\uFE53\uFE67\uFE6C-\uFE6F\uFE75\uFEFD-\uFF00\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFDF\uFFE7\uFFEF-\uFFFB\uFFFE\uFFFF]/g;function Na(e,t){this.link=e,this.text=t}Qo("clean",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.replace(Sa,"")})),Qo("code",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.charAt(0)})),te.runtime.defineAlias("unichar","char"),te.runtime.defineAlias("unicode","code"),Qo("concatenate",!1,{check:function(e){var t,r=[],n=[],s=0;if(s>=e.length)return new K("N/A");n.push(t=[]),r.push(n),n=t;do{var i=e[s++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K("VALUE");n.push(i)}while(s<e.length);return n=r.pop(),s<e.length?new K("N/A"):n},resolve:function(e,t){for(var r=[],n=0;n<e.length;)r.push(e[n++]);this.resolveCells(r,t)},arrayArgs:function(e){for(var t=[],r=0,n=0,s=[],i=0;i<e.length;){var o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++}return{args:t,width:r,height:n,arrays:s}}},(function(e){for(var t="",r=0;r<e.length;++r)t+=e[r];return t})),Qo("dollar",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o|=0,1)||null==o&&(o=2,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){for(var r="$#,##0DECIMALS;($#,##0DECIMALS)",n="",s=1;t-- >0;)n+="0";for(;++t<0;)s*=10;return""!==n?n="."+n:1!==s&&(e=Math.round(e/s)*s),r=r.replace(/DECIMALS/g,n),Je.text(e,r)})),Qo("exact",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(!("string"==typeof(s=this.force(s))||"boolean"==typeof s||"number"==typeof s?(s+="",1):void 0===s&&(s="",1)))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1))?(t.push(i),2<e.length?new K("N/A"):t):i instanceof K?i:new K(n)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e===t})),Qo("find",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("string"==typeof(o=this.force(o))||"boolean"==typeof o||"number"==typeof o?(o+="",1):void 0===o&&(o="",1)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>0||(s="NUM",0))||null==a&&(a=1,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){var n=t.indexOf(e,r-1);return n<0?new K("VALUE"):n+1})),Qo("fixed",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!(("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&(o|=0,1)||null==o&&(o=2,1)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||null==a&&(a=!1,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){var n=Math.pow(10,t);e=Math.round(e*n)/n;var s=r?"0":"#,##0";if(t>0)for(s+=".";t-- >0;)s+="0";return Je.text(e,s)})),Qo("left",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>=0||(s="NUM",0))||null==o&&(o=1,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e.substr(0,t)})),Qo("right",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>=0||(s="NUM",0))||null==o&&(o=1,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e.substr(-t)})),Qo("len",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.length})),Qo("lower",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.toLowerCase()})),Qo("upper",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.toUpperCase()})),Qo("ltrim",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.replace(/^\s+/,"")})),Qo("rtrim",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.replace(/\s+$/,"")})),Qo("trim",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.replace(/^\s+|\s+$/,"")})),Qo("mid",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>=0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){return e.substr(t-1,r)})),Qo("proper",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:("string"==typeof(n=this.force(n))||"boolean"==typeof n||"number"==typeof n?(n+="",1):void 0===n&&(n="",1))?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return e.toLowerCase().replace(/\b./g,(function(e){return e.toUpperCase()}))})),Qo("replace",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!((a|=0)>=0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:("string"==typeof(u=this.force(u))||"boolean"==typeof u||"number"==typeof u?(u+="",1):void 0===u&&(u="",1))?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var h=this._arrayArg(e[i]);return h?(t.push(h),r=Math.max(r,h.width),n=Math.max(n,h.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r,n){return e.substr(0,--t)+n+e.substr(t+r)})),Qo("rept",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>=0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){for(var r="";t-- >0;)r+=e;return r})),Qo("search",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("string"==typeof(o=this.force(o))||"boolean"==typeof o||"number"==typeof o?(o+="",1):void 0===o&&(o="",1)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>0||(s="NUM",0))||null==a&&(a=1,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);return u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r){var n=t.toLowerCase().indexOf(e.toLowerCase(),r-1);return n<0?new K("VALUE"):n+1})),Qo("substitute",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("string"==typeof(o=this.force(o))||"boolean"==typeof o||"number"==typeof o?(o+="",1):void 0===o&&(o="",1)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("string"==typeof(a=this.force(a))||"boolean"==typeof a||"number"==typeof a?(a+="",1):void 0===a&&(a="",1)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:("number"==typeof(u=this.force(u))||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&((u|=0)>0||(s="NUM",0))||null==u?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var u=this._arrayArg(e[i]);u?(t.push(u),r=Math.max(r,u.width),n=Math.max(n,u.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var h=this._arrayArg(e[i]);return h?(t.push(h),r=Math.max(r,h.width),n=Math.max(n,h.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t,r,n){if(t===r)return e;var s=e.split(t);if(null==n)return s.join(r);e="",n--;for(var i=0;i<s.length;++i)e+=s[i],i<s.length-1&&(e+=i===n?r:t);return e})),Qo("t",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:null!=(n=this.force(n))&&1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return"string"==typeof e?e:""})),Qo("text",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(!(null!=(s=this.force(s))&&r<=e.length))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1))?(t.push(i),r<e.length?new K("N/A"):t):i instanceof K?i:new K(n)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return Je.text(e,t)})),Qo("value",!1,{check:function(e){var t=[],r=0,n=e[r++];return n instanceof K?n:null!=(n=this.force(n))&&1<=e.length?(t.push(n),1<e.length?new K("N/A"):t):n instanceof K?n:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);return o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e){return"number"==typeof e?e:"boolean"==typeof e?+e:(e=(e+"").replace(/[$€,]/g,""),e=parseFloat(e),isNaN(e)?new K("VALUE"):e)})),Na.prototype.toString=function(){return this.text},Qo("hyperlink",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s instanceof K)return s;if(!("string"==typeof(s=this.force(s))||"boolean"==typeof s||"number"==typeof s?(s+="",1):void 0===s&&(s="",1)))return s instanceof K?s:new K(n);t.push(s);var i=e[r++];return i instanceof K?i:("string"==typeof(i=this.force(i))||"boolean"==typeof i||"number"==typeof i?(i+="",1):void 0===i&&(i="",1))||null==i&&(i=s,1)?(t.push(i),2<e.length?new K("N/A"):t):i instanceof K?i:new K(n)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return new Na(e,t)})),Qo("iferror",!1,{check:function(e){var t=[],r=0,n="VALUE",s=e[r++];if(s=this.force(s),!(r<=e.length))return new K(n);t.push(s);var i=e[r++];return null!=(i=this.force(i))&&r<=e.length?(t.push(i),r<e.length?new K("N/A"):t):new K(n)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)},arrayArgs:function(e){var t=[],r=0,n=0,s=[],i=0,o=this._arrayArg(e[i]);o?(t.push(o),r=Math.max(r,o.width),n=Math.max(n,o.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++;var a=this._arrayArg(e[i]);return a?(t.push(a),r=Math.max(r,a.width),n=Math.max(n,a.height),s.push(!0)):(t.push(e[i]),s.push(!1)),i++,{args:t,width:r,height:n,arrays:s}}},(function(e,t){return e instanceof K?t:e}));var La=function(){var e=Object.create(null);function t(e,t){if("string"==typeof t){var r=parseFloat(t);isNaN(r)||r!=t||(t=r)}return function(r){var n=t;return"string"==typeof r&&"string"==typeof n&&(r=r.toLowerCase(),n=n.toLowerCase()),e(r,n)}}function r(e){var t,r;return"string"==typeof e&&(e=e.toLowerCase()),/^[0-9.]+%$/.test(e)?(r=e.substr(0,e.length-1),t=parseFloat(r),isNaN(t)||t!=r||(e=t/100)):/^[0-9.]+$/.test(e)&&(t=parseFloat(e),isNaN(t)||t!=e||(e=t)),e}function n(e,t){return r(e)<r(t)}function s(e,t){return r(e)<=r(t)}function i(e,t){return r(e)>r(t)}function o(e,t){return r(e)>=r(t)}function a(e,t){return!u(e,t)}function u(e,t){return t instanceof RegExp?t.test(e):("string"!=typeof e&&"string"!=typeof t||(e=String(e),t=String(t)),r(e)==r(t))}return function(r){if("function"==typeof r)return r;var h;if(h=/^=(.*)$/.exec(r))return t(u,h[1]);if(h=/^<>(.*)$/.exec(r))return t(a,h[1]);if(h=/^<=(.*)$/.exec(r))return t(s,h[1]);if(h=/^<(.*)$/.exec(r))return t(n,h[1]);if(h=/^>=(.*)$/.exec(r))return t(o,h[1]);if(h=/^>(.*)$/.exec(r))return t(i,h[1]);if(/[?*]/.exec(r)){var l=e[r];return l||(l=r.replace(/(~\?|~\*|[\]({\+\.\|\^\$\\})\[]|[?*])/g,(function(e){switch(e){case"~?":return"\\?";case"~*":return"\\*";case"?":return".";case"*":return".*";default:return"\\"+e}})),l=e[r]=new RegExp("^"+l+"$","i")),t(u,l)}return t(u,r)}}();function Da(e){return"number"==typeof e||"boolean"==typeof e||null==e||""===e}function Ua(e,t){return e===t?0:e<t?-1:1}function Va(e,t){return e===t?0:e<t?1:-1}Qo("ERF",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return null==t?za(e):za(t)-za(e)})),Qo("ERFC",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},Ha),Qo("GAMMALN",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&(i>0||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},Pa),Qo("GAMMA",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},Oa),Qo("GAMMA.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},Ya),Qo("GAMMA.INV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&(a>0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},Ja),Qo("NORM.S.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:"boolean"==typeof(o=this.force(o))||"number"==typeof o&&(o=!!o,1)?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},Xa),Qo("NORM.S.INV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&(i>=0&&i<=1||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},Ga),Qo("NORM.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){if(!n)return Math.exp(-(e-t)*(e-t)/(2*r*r))/(r*Math.sqrt(2*Math.PI));return Xa((e-t)/r,!0)})),Qo("NORM.INV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&(a>0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},Ka),Qo("BETADIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))||null==u&&(u=0,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:"number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1))||null==h&&(h=1,1)?(r.push(h),(i>=u||(s="NUM",0))&&(i<=h||(s="NUM",0))&&(u<h||(s="NUM",0))?5<e.length?new K("N/A"):r:new K(s)):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){return Qa((e-n)/(s-n),t,r)})),Qo("BETA.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!("number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1))||null==h&&(h=0,1)))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];return l instanceof K?l:"number"==typeof(l=this.force(l))&&(l=Zo(l),1)||"boolean"==typeof l&&(l=+l,1)||"string"==typeof l&&!/^(?:=|true|false)/i.test(l)&&(t=te.parse(0,0,0,l),/^date|number|percent$/.test(t.type)&&(l=+t.value,1))||null==l&&(l=1,1)?(r.push(l),(i>=h||(s="NUM",0))&&(i<=l||(s="NUM",0))&&(h<l||(s="NUM",0))?6<e.length?new K("N/A"):r:new K(s)):l instanceof K?l:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s,i){if(n)return Qa((e-s)/(i-s),t,r);return function(e,t,r){return Math.exp((t-1)*Math.log(e)+(r-1)*Math.log(1-e)-ja(t,r))}((e-s)/(i-s),t,r)/(i-s)})),Qo("BETA.INV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))||null==u&&(u=0,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:"number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1))||null==h&&(h=1,1)?(r.push(h),5<e.length?new K("N/A"):r):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},tu),Qo("CHISQ.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},ru),Qo("CHISQ.DIST.RT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},nu),Qo("CHISQ.INV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},su),Qo("CHISQ.INV.RT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return su(1-e,t)})),Qo("CHISQ.TEST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:(t=this.asMatrix(o))&&(o=t)?(r.push(o),i.width!=o.width&&(s="N/A",1)||i.height!=o.height&&(s="N/A",1)?new K(s):2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return function(e,t){var r,n,s=e.length,i=e[0].length,o=0;for(r=0;r<s;r++)for(n=0;n<i;n++){var a=t[r][n],u=e[r][n]-a;o+=(u*=u)/a}return nu(o,(s-1)*(i-1))}(e.data,t.data)})),Qo("EXPON.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){if(r)return 1-Math.exp(-t*e);return t*Math.exp(-t*e)})),Qo("POISSON.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!((i|=0)>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>=0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){if(r)return 1-ru(2*t,2*(e+1),!0);for(var n=0,s=2;s<=e;s++)n+=Math.log(s);return Math.exp(e*Math.log(t)-t-n)})),Qo("F.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!((a|=0)>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},iu),Qo("F.DIST.RT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return 1-iu(e,t,r,!0)})),Qo("F.INV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return r/t*(1/tu(1-e,r/2,t/2,0,1)-1)})),Qo("F.INV.RT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return r/t*(1/tu(e,r/2,t/2,0,1)-1)})),Qo("F.TEST",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}return(i.length>=2||(s="DIV/0",0))&&(o.length>=2||(s="DIV/0",0))?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){var r=e.length-1,n=t.length-1,s=au(e,ou(e)),i=au(t,ou(t));if(!s||!i)throw new K("DIV/0");return 2*iu(s/i,r,n,!0)})),Qo("FISHER",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];return i instanceof K?i:("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))&&(i>-1&&i<1||(s="NUM",0))?(r.push(i),1<e.length?new K("N/A"):r):i instanceof K?i:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return.5*Math.log((1+e)/(1-e))})),Qo("FISHERINV",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){var t=Math.exp(2*e);return(t-1)/(t+1)})),Qo("T.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!((o|=0)>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:"boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},uu),Qo("T.DIST.RT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},hu),Qo("T.DIST.2T",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},lu),Qo("T.INV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},cu),Qo("T.INV.2T",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0&&i<=1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return cu(1-e/2,t)})),Qo("T.TEST",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)||1!==a&&2!==a)return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:!("number"==typeof(u=this.force(u))||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||(u|=0,0)||1!==u&&2!==u&&3!==u?u instanceof K?u:new K(s):(r.push(u),1==u&&i.length!=o.length&&(s="N/A",1)?new K(s):(i.length>=2||(s="DIV/0",0))&&(o.length>=2||(s="DIV/0",0))?n<e.length?new K("N/A"):r:new K(s))},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e.slice(n)),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){var s,i,o=e.length,a=t.length;if(1==n){for(var u=0,h=0,l=0;l<o;l++){var c=e[l]-t[l];u+=c,h+=c*c}var f=u/o;return s=f/Math.sqrt((h-u*f)/(o*(o-1))),1==r?hu(s,o-1):lu(s,o-1)}var p=ou(e),d=ou(t),g=au(e,p),m=au(t,d);if(3==n){var v=g/o,y=m/a,w=v+y,b=v/w,_=y/w;return i=1/(b*b/(o-1)+_*_/(a-1)),s=Ta(p-d)/Math.sqrt(w),1==r?hu(s,i):lu(s,i)}return i=o+a-2,s=Ta(p-d)*Math.sqrt(i*o*a/((o+a)*((o-1)*g+(a-1)*m))),1==r?hu(s,i):lu(s,i)})),Qo("CONFIDENCE.T",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0&&i<1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!((a|=0)>0||(s="NUM",0))||1==a&&(s="DIV/0",1)?a instanceof K?a:new K(s):(r.push(a),3<e.length?new K("N/A"):r)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return-cu(e/2,r-1)*t/Math.sqrt(r)})),Qo("CONFIDENCE.NORM",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0&&i<1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&((a|=0)>0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return-Ga(e/2)*t/Math.sqrt(r)})),Qo("GAUSS",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return Xa(e,!0)-.5})),Qo("PHI",!1,{check:function(e){var t,r=[],n=0,s=e[n++];return s instanceof K?s:"number"==typeof(s=this.force(s))&&(s=Zo(s),1)||"boolean"==typeof s&&(s=+s,1)||"string"==typeof s&&!/^(?:=|true|false)/i.test(s)&&(t=te.parse(0,0,0,s),/^date|number|percent$/.test(t.type)&&(s=+t.value,1))?(r.push(s),1<e.length?new K("N/A"):r):s instanceof K?s:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),this.resolveCells(r,t)}},(function(e){return Xa(e)})),Qo("LOGNORM.DIST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){if(n)return.5+.5*za((Math.log(e)-t)/(r*Math.sqrt(2)));var s=Math.log(e)-t;return Math.exp(-s*s/(2*r*r))/(e*r*Math.sqrt(2*Math.PI))})),Qo("LOGNORM.INV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0&&i<1||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&(a>0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return Math.exp(Ka(e,t,r))})),Qo("PROB",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1))))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))||null==u&&(u=a,1)?(r.push(u),o.length!=i.length&&(s="N/A",1)?new K(s):n<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e.slice(n)),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){var s,i=e.length,o=0;for(s=0;s<i;s++){if(t[s]<=0||t[s]>1)throw new K("NUM");o+=t[s]}if(1!=o)throw new K("NUM");var a=0;for(s=0;s<i;s++){var u=e[s];u>=r&&u<=n&&(a+=t[s])}return a})),Qo("SLOPE",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}return o.length!=i.length&&(s="N/A",1)?new K(s):o.length>0&&i.length>0||(s="N/A",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){for(var r=ou(t),n=ou(e),s=0,i=0,o=0,a=e.length;o<a;o++){var u=t[o]-r;s+=u*(e[o]-n),i+=u*u}return s/i})),Qo("INTERCEPT",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}return o.length!=i.length&&(s="N/A",1)?new K(s):o.length>0&&i.length>0||(s="N/A",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){for(var r=ou(t),n=ou(e),s=0,i=0,o=0,a=e.length;o<a;o++){var u=t[o]-r;s+=u*(e[o]-n),i+=u*u}return n-s*r/i})),Qo("PEARSON",!1,{check:function(e){var t=[],r=0,n="VALUE";try{var s=this.cellValues(e.slice(r,r+1),!0).reduce(function(t,n){if(n instanceof K)throw n;return r<=e.length&&t.push(n),t}.bind(this),[]);r+=1,t.push(s)}catch(e){if(e instanceof K)return e;throw e}try{var i=this.cellValues(e.slice(r,r+1),!0).reduce(function(t,n){if(n instanceof K)throw n;return r<=e.length&&t.push(n),t}.bind(this),[]);r+=1,t.push(i)}catch(e){if(e instanceof K)return e;throw e}return i.length!=s.length&&(n="N/A",1)?new K(n):i.length>0&&s.length>0||(n="N/A",0)?r<e.length?new K("N/A"):t:new K(n)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},fu),Qo("RSQ",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}return o.length!=i.length&&(s="N/A",1)?new K(s):(o.length>0&&i.length>0||(s="N/A",0))&&(1!=o.length&&1!=i.length||(s="N/A",0))?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){var r=fu(e,t);return r*r})),Qo("STEYX",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}return o.length!=i.length&&(s="N/A",1)?new K(s):o.length>=3&&i.length>=3||(s="DIV/0",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){for(var r=t.length,n=ou(t),s=ou(e),i=0,o=0,a=0,u=0;u<r;u++){var h=t[u]-n,l=e[u]-s;i+=l*l,o+=h*l,a+=h*h}return Math.sqrt((i-o*o/a)/(r-2))})),Qo("FORECAST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}try{var a=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(a)}catch(e){if(e instanceof K)return e;throw e}return a.length!=o.length&&(s="N/A",1)?new K(s):a.length>0&&o.length>0||(s="N/A",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t,r){for(var n=ou(r),s=ou(t),i=0,o=0,a=0,u=r.length;a<u;a++){var h=r[a]-n;i+=h*(t[a]-s),o+=h*h}if(0===o)throw new K("N/A");var l=i/o;return s-l*n+l*e})),Qo("LINEST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!((t=this.asMatrix(o))&&(o=t)||null==o))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)||null==a&&(a=!0,1)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)||null==u&&(u=!1,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},gu),Qo("LOGEST",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!((t=this.asMatrix(o))&&(o=t)||null==o))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("boolean"==typeof(a=this.force(a))||"number"==typeof a&&(a=!!a,1)||null==a&&(a=!0,1)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)||null==u&&(u=!1,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){return gu.call(this,e.map(Math.log),t,r,n).map(Math.exp)})),Qo("TREND",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!((t=this.asMatrix(o))&&(o=t)||null==o))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!((t=this.asMatrix(a))&&(a=t)||null==a))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)||null==u&&(u=!0,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},mu),Qo("GROWTH",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!(t=this.asMatrix(i))||!(i=t))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!((t=this.asMatrix(o))&&(o=t)||null==o))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!((t=this.asMatrix(a))&&(a=t)||null==a))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"boolean"==typeof(u=this.force(u))||"number"==typeof u&&(u=!!u,1)||null==u&&(u=!0,1)?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){return mu.call(this,e.map(Math.log),t,r,n).map(Math.exp)})),Qo("FV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1))||null==a&&(a=0,1)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))||null==u&&(u=0,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:0===(h=this.force(h))||1===h||null==h&&(h=0,1)?(r.push(h),a||u||(s="N/A",0)?5<e.length?new K("N/A"):r:new K(s)):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},yu),Qo("PV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1))||null==a&&(a=0,1)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))||null==u&&(u=0,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:0===(h=this.force(h))||1===h||null==h&&(h=0,1)?(r.push(h),5<e.length?new K("N/A"):r):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){if(!e)return-n-r*t;var i=Math.pow(1+e,t);return-(n+r*(i-1)/e*(1+e*s))/i})),Qo("PMT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1))))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))||null==u&&(u=0,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:0===(h=this.force(h))||1===h||null==h&&(h=0,1)?(r.push(h),5<e.length?new K("N/A"):r):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},wu),Qo("NPER",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1))))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))||null==u&&(u=0,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:0===(h=this.force(h))||1===h||null==h&&(h=0,1)?(r.push(h),5<e.length?new K("N/A"):r):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){if(!e)return-(n+r)/t;var i=t*(1+e*s);return Math.log((i-n*e)/(i+r*e))/Math.log(1+e)})),Qo("RATE",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))||null==o&&(o=0,1)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1))))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))||null==u&&(u=0,1)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!(0===(h=this.force(h))||1===h||null==h&&(h=0,1)))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];return l instanceof K?l:("number"==typeof(l=this.force(l))&&(l=Zo(l),1)||"boolean"==typeof l&&(l=+l,1)||"string"==typeof l&&!/^(?:=|true|false)/i.test(l)&&(t=te.parse(0,0,0,l),/^date|number|percent$/.test(t.type)&&(l=+t.value,1)))&&(l>0||(s="NUM",0))||null==l&&(l=.01,1)?(r.push(l),o||u||(s="N/A",0)?6<e.length?new K("N/A"):r:new K(s)):l instanceof K?l:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s,i){return vu((function(i){var o=Math.pow(1+i,e-1),a=o*(1+i);return[r*a+t*(1/i+s)*(a-1)+n,e*r*o+t*(-(a-1)/(i*i)+(1/i+s)*e*o)]}),i)})),Qo("IPMT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!("number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1))||null==h&&(h=0,1)))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];return l instanceof K?l:0===(l=this.force(l))||1===l||null==l&&(l=0,1)?(r.push(l),o>=1&&o<=a||(s="N/A",0)?6<e.length?new K("N/A"):r:new K(s)):l instanceof K?l:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},bu),Qo("PPMT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!("number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1))||null==h&&(h=0,1)))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];return l instanceof K?l:0===(l=this.force(l))||1===l||null==l&&(l=0,1)?(r.push(l),o>=1&&o<=a||(s="N/A",0)?6<e.length?new K("N/A"):r:new K(s)):l instanceof K?l:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s,i){return wu(e,r,n,s,i)-bu(e,t,r,n,s,i)})),Qo("CUMPRINC",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!("number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))||!(h>0||(s="NUM",0)))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];return l instanceof K?l:0===(l=this.force(l))||1===l||null==l&&(l=0,1)?(r.push(l),h>=u||(s="NUM",0)?6<e.length?new K("N/A"):r:new K(s)):l instanceof K?l:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s,i){1==i&&(n--,s--);var o=Math.pow(1+e,t),a=Math.pow(1+e,n-1),u=Math.pow(1+e,s),h=e*r*o/(o-1);return u*r-(u-1)/e*h-(a*r-(a-1)/e*h)})),Qo("CUMIPMT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!("number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))||!(h>0||(s="NUM",0)))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];return l instanceof K?l:0===(l=this.force(l))||1===l||null==l&&(l=0,1)?(r.push(l),h>=u||(s="NUM",0)?6<e.length?new K("N/A"):r:new K(s)):l instanceof K?l:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s,i){for(var o=0,a=n;a<=s;a++)o+=bu(e,a,t,r,0,i);return o})),Qo("NPV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);try{var o=this.cellValues(e.slice(n)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n=e.length,r.push(o)}catch(e){if(e instanceof K)return e;throw e}return o.length>0||(s="N/A",0)?n<e.length?new K("N/A"):r:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t){for(var r=0,n=0,s=t.length;n<s;n++)r+=t[n]*Math.pow(1+e,-n-1);return r})),Qo("IRR",!1,{check:function(e){var t,r=[],n=0;try{var s=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(s)}catch(e){if(e instanceof K)return e;throw e}var i=e[n++];return i instanceof K?i:"number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))||null==i&&(i=.1,1)?(r.push(i),n<e.length?new K("N/A"):r):i instanceof K?i:new K("VALUE")},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return vu((function(t){for(var r=0,n=0,s=0,i=e.length;s<i;s++)r+=e[s]*Math.pow(1+t,-s-1),n+=-s*e[s]*Math.pow(1+t,-s-2);return[r,n]}),t)})),Qo("EFFECT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return Math.pow(1+e/t,t)-1})),Qo("NOMINAL",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];return o instanceof K?o:("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))&&((o|=0)>0||(s="NUM",0))?(r.push(o),2<e.length?new K("N/A"):r):o instanceof K?o:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t){return t*(Math.pow(e+1,1/t)-1)})),Qo("XNPV",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}try{var a=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&(r|=0,1)&&e.push(r),e}.bind(this),[]);n+=1,r.push(a)}catch(e){if(e instanceof K)return e;throw e}return o.length!=a.length&&(s="NUM",1)?new K(s):n<e.length?new K("N/A"):r},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(1)),r.push(e.slice(1)),this.resolveCells(r,t)}},(function(e,t,r){for(var n=0,s=0,i=t.length;s<i;s++)n+=t[s]*Math.pow(1+e,(r[0]-r[s])/365);return n})),Qo("XIRR",!1,{check:function(e){var t,r=[],n=0,s="VALUE";try{var i=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r&&(r=Zo(r),1)||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&e.push(r),e}.bind(this),[]);n+=1,r.push(i)}catch(e){if(e instanceof K)return e;throw e}try{var o=this.cellValues(e.slice(n,n+1)).reduce(function(e,r){if(r instanceof K)throw r;return("number"==typeof r||"boolean"==typeof r&&(r=+r,1)||"string"==typeof r&&!/^(?:=|true|false)/i.test(r)&&(t=te.parse(0,0,0,r),/^date|number|percent$/.test(t.type)&&(r=+t.value,1)))&&(r|=0,1)&&e.push(r),e}.bind(this),[]);n+=1,r.push(o)}catch(e){if(e instanceof K)return e;throw e}var a=e[n++];return a instanceof K?a:"number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1))||null==a&&(a=.1,1)?(r.push(a),i.length!=o.length&&(s="NUM",1)?new K(s):n<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e.slice(n)),r.push(e.slice(n)),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return vu((function(r){for(var n=e[0],s=0,i=1,o=e.length;i<o;i++){var a=(t[0]-t[i])/365;n+=e[i]*Math.pow(1+r,a),s+=a*e[i]*Math.pow(1+r,a-1)}return[n,s]}),r)})),Qo("ISPMT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:"number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1))?(r.push(u),o>=1&&o<=a||(s="N/A",0)?4<e.length?new K("N/A"):r:new K(s)):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){return-n*e*(1-t/r)})),Qo("DB",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:"number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1))||null==h&&(h=12,1)?(r.push(h),5<e.length?new K("N/A"):r):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=1-Math.pow(t/e,1/r);i=Math.floor(1e3*i+.5)/1e3;var o=e*i*s/12;if(1==n)return o;for(var a=1;a<r;a++){if(a==n-1)return(e-o)*i;o+=(e-o)*i}return(e-o)*i*(12-s)/12})),Qo("DDB",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:"number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1))||null==h&&(h=2,1)?(r.push(h),5<e.length?new K("N/A"):r):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=s/r,o=-e*(Math.pow(1-i,n-1)-1),a=(e-o)*i;return a=Math.min(a,Math.max(0,e-o-t))})),Qo("SLN",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];return a instanceof K?a:("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))&&(a>0||(s="NUM",0))?(r.push(a),3<e.length?new K("N/A"):r):a instanceof K?a:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return(e-t)/r})),Qo("SYD",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1))))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1))))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u>0||(s="NUM",0))?(r.push(u),4<e.length?new K("N/A"):r):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){return(e-t)*(r-n+1)*2/(r*(r+1))})),Qo("VDB",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))&&(i=Zo(i),1)||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||!(i>=0||(s="NUM",0)))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))&&(o=Zo(o),1)||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||!(o>=0||(s="NUM",0)))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>=0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!("number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))||!(h>=0||(s="NUM",0)))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];if(l instanceof K)return l;if(!(("number"==typeof(l=this.force(l))&&(l=Zo(l),1)||"boolean"==typeof l&&(l=+l,1)||"string"==typeof l&&!/^(?:=|true|false)/i.test(l)&&(t=te.parse(0,0,0,l),/^date|number|percent$/.test(t.type)&&(l=+t.value,1)))&&(l>=0||(s="NUM",0))||null==l&&(l=2,1)))return l instanceof K?l:new K(s);r.push(l);var c=e[n++];return c instanceof K?c:"boolean"==typeof(c=this.force(c))||"number"==typeof c&&(c=!!c,1)||null==c&&(c=!1,1)?(r.push(c),h>=u||(s="NUM",0)?7<e.length?new K("N/A"):r:new K(s)):c instanceof K?c:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s,i,o){var a=i>=r?1:i/r;function u(e,r){var n,s,i;return s=1==a?1==r?e:0:e*Math.pow(1-a,r-1),(n=(i=e*Math.pow(1-a,r))<t?s-t:s-i)<0?0:n}function h(e,r,n){for(var s,i=e-t,o=Math.ceil(n),a=0,h=0,l=!1,c=1;c<=o;c++){if(l)s=a;else{var f=u(e,c);(a=i/(r-c+1))>f?(s=a,l=!0):(s=f,i-=f)}c==o&&(s*=n+1-o),h+=s}return h}var l=Math.floor(n),c=Math.ceil(s),f=0;if(o)for(var p=l+1;p<=c;p++){var d=u(e,p);p==l+1?d*=Math.min(s,l+1)-n:p==c&&(d*=s+1-c),f+=d}else{var g=r;if(n!=Math.floor(n)&&i>1&&n>=r/2){var m=n-r/2;n=r/2,s-=m,g+=1}e-=h(e,g,n),f=h(e,r-n,s-n)}return f})),Qo("COUPDAYBS",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)||1!==a&&2!==a&&4!==a)return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:null==(u=this.force(u))&&(u=0,1)||("number"==typeof u||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u|=0,1)&&(0===u||1===u||2===u||3===u||4===u)?(r.push(u),i<o||(s="NUM",0)?4<e.length?new K("N/A"):r:new K(s)):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){return Au(Cu(e,t,r)[0],e,n)})),Qo("COUPDAYS",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)||1!==a&&2!==a&&4!==a)return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:null==(u=this.force(u))&&(u=0,1)||("number"==typeof u||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u|=0,1)&&(0===u||1===u||2===u||3===u||4===u)?(r.push(u),i<o||(s="NUM",0)?4<e.length?new K("N/A"):r:new K(s)):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){if(1==n){var s=Cu(e,t,r);return Au(s[0],s[1],1)}if(3==n)return 365/r;return 360/r})),Qo("COUPDAYSNC",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)||1!==a&&2!==a&&4!==a)return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:null==(u=this.force(u))&&(u=0,1)||("number"==typeof u||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u|=0,1)&&(0===u||1===u||2===u||3===u||4===u)?(r.push(u),i<o||(s="NUM",0)?4<e.length?new K("N/A"):r:new K(s)):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n){var s=Cu(e,t,r)[1];return Au(e,s,n)})),Qo("COUPPCD",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)||1!==a&&2!==a&&4!==a)return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:null==(u=this.force(u))&&(u=0,1)||("number"==typeof u||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u|=0,1)&&(0===u||1===u||2===u||3===u||4===u)?(r.push(u),i<o||(s="NUM",0)?4<e.length?new K("N/A"):r:new K(s)):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return Cu(e,t,r)[0]})),Qo("COUPNCD",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)||1!==a&&2!==a&&4!==a)return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:null==(u=this.force(u))&&(u=0,1)||("number"==typeof u||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u|=0,1)&&(0===u||1===u||2===u||3===u||4===u)?(r.push(u),i<o||(s="NUM",0)?4<e.length?new K("N/A"):r:new K(s)):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){return Cu(e,t,r)[1]})),Qo("COUPNUM",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0)||1!==a&&2!==a&&4!==a)return a instanceof K?a:new K(s);r.push(a);var u=e[n++];return u instanceof K?u:null==(u=this.force(u))&&(u=0,1)||("number"==typeof u||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u|=0,1)&&(0===u||1===u||2===u||3===u||4===u)?(r.push(u),i<o||(s="NUM",0)?4<e.length?new K("N/A"):r:new K(s)):u instanceof K?u:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r){var n=ta(e),s=ta(t);return 1+((12*(s.year-n.year)+s.month-n.month)*r/12|0)})),Qo("ACCRINTM",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!(null==(u=this.force(u))&&(u=1e3,1)||("number"==typeof u&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))&&(u>0||(s="NUM",0))))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:null==(h=this.force(h))&&(h=0,1)||("number"==typeof h||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))&&(h|=0,1)&&(0===h||1===h||2===h||3===h||4===h)?(r.push(h),i<o||(s="NUM",0)?5<e.length?new K("N/A"):r:new K(s)):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=xu(ta(t).year,s);return r*n*Au(e,t,s)/i})),Qo("ACCRINT",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||(a|=0,0))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!(null==(h=this.force(h))&&(h=1e3,1)||("number"==typeof h&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))&&(h>0||(s="NUM",0))))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];if(l instanceof K)return l;if(!("number"==typeof(l=this.force(l))||"boolean"==typeof l&&(l=+l,1)||"string"==typeof l&&!/^(?:=|true|false)/i.test(l)&&(t=te.parse(0,0,0,l),/^date|number|percent$/.test(t.type)&&(l=+t.value,1)))||(l|=0,0)||1!==l&&2!==l&&4!==l)return l instanceof K?l:new K(s);r.push(l);var c=e[n++];if(c instanceof K)return c;if(!(null==(c=this.force(c))&&(c=0,1)||("number"==typeof c||"boolean"==typeof c&&(c=+c,1)||"string"==typeof c&&!/^(?:=|true|false)/i.test(c)&&(t=te.parse(0,0,0,c),/^date|number|percent$/.test(t.type)&&(c=+t.value,1)))&&(c|=0,1)&&(0===c||1===c||2===c||3===c||4===c)))return c instanceof K?c:new K(s);r.push(c);var f=e[n++];return f instanceof K?f:"boolean"==typeof(f=this.force(f))||"number"==typeof f&&(f=!!f,1)||null==f&&(f=!0,1)?(r.push(f),i<a||(s="NUM",0)?8<e.length?new K("N/A"):r:new K(s)):f instanceof K?f:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s,i,o,a){var u,h,l,c,f,p,d=0,g=s*n/i,m=o%2==0?360:365;function v(e,t){return(t-e)*i/m|0}return r<=t?(h=(u=Cu(r,t,i))[0],l=u[1],h<=e?g*Au(e,r,o)/Au(h,l,o):(c=(u=Cu(e,h,i))[0],g*((p=v(f=u[1],r))+Au(e,f,o)/Au(c,f,o)+(r<l?Au(h,r,o)/Au(h,l,o):0)))):(u=function(e,t,r){var n=ta(t),s=ta(e),i=n.year-s.year;i>0&&(i=(i-1)*r);var o,a=e,u=12/r;for(;t>a;)o=a,a=_u(e,++i*u);return[o,a]}(t,r,i),h=u[0],l=u[1],p=v(t,r),d=l==r?g*p:g*(p+Au(h,r,o)/Au(h,l,o)),a?(h=(u=Cu(e,t,i))[0],l=u[1],d+=g*((p=v(e,t))+Au(e,l,o)/Au(h,l,o))):d)})),Qo("DISC",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:null==(h=this.force(h))&&(h=0,1)||("number"==typeof h||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))&&(h|=0,1)&&(0===h||1===h||2===h||3===h||4===h)?(r.push(h),i<o||(s="NUM",0)?5<e.length?new K("N/A"):r:new K(s)):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=s%2==0?360:sa(ta(e).year)?366:365;return(n-r)/n*i/Au(e,t,s)})),Qo("INTRATE",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:null==(h=this.force(h))&&(h=0,1)||("number"==typeof h||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))&&(h|=0,1)&&(0===h||1===h||2===h||3===h||4===h)?(r.push(h),i<o||(s="NUM",0)?5<e.length?new K("N/A"):r:new K(s)):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=s%2==0?360:sa(ta(e).year)?366:365;return(n-r)/r*i/Au(e,t,s)})),Qo("RECEIVED",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:null==(h=this.force(h))&&(h=0,1)||("number"==typeof h||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))&&(h|=0,1)&&(0===h||1===h||2===h||3===h||4===h)?(r.push(h),i<o||(s="NUM",0)?5<e.length?new K("N/A"):r:new K(s)):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=s%2==0?360:sa(ta(e).year)?366:365;return r/(1-n*Au(e,t,s)/i)})),Qo("PRICE",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];if(h instanceof K)return h;if(!("number"==typeof(h=this.force(h))&&(h=Zo(h),1)||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))||!(h>0||(s="NUM",0)))return h instanceof K?h:new K(s);r.push(h);var l=e[n++];if(l instanceof K)return l;if(!("number"==typeof(l=this.force(l))||"boolean"==typeof l&&(l=+l,1)||"string"==typeof l&&!/^(?:=|true|false)/i.test(l)&&(t=te.parse(0,0,0,l),/^date|number|percent$/.test(t.type)&&(l=+t.value,1)))||(l|=0,0)||1!==l&&2!==l&&4!==l)return l instanceof K?l:new K(s);r.push(l);var c=e[n++];return c instanceof K?c:null==(c=this.force(c))&&(c=0,1)||("number"==typeof c||"boolean"==typeof c&&(c=+c,1)||"string"==typeof c&&!/^(?:=|true|false)/i.test(c)&&(t=te.parse(0,0,0,c),/^date|number|percent$/.test(t.type)&&(c=+t.value,1)))&&(c|=0,1)&&(0===c||1===c||2===c||3===c||4===c)?(r.push(c),i<o||(s="NUM",0)?7<e.length?new K("N/A"):r:new K(s)):c instanceof K?c:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s,i,o){var a=1+((t-e)*i/(o%2==0?360:365)|0),u=Cu(e,t,i),h=u[0],l=u[1],c=Au(h,e,o),f=Au(e,l,o),p=Au(h,l,o),d=100*r/i,g=n/i,m=f/p;if(1==a)return(s+d)/(1+m*g)-c/p*d;return s/Math.pow(1+g,a-1+m)+d*Math.pow(1+g,1-a-m)*(Math.pow(1+g,a)-1)/g-c/p*d})),Qo("PRICEDISC",!1,{check:function(e){var t,r=[],n=0,s="VALUE",i=e[n++];if(i instanceof K)return i;if(!("number"==typeof(i=this.force(i))||"boolean"==typeof i&&(i=+i,1)||"string"==typeof i&&!/^(?:=|true|false)/i.test(i)&&(t=te.parse(0,0,0,i),/^date|number|percent$/.test(t.type)&&(i=+t.value,1)))||(i|=0,0))return i instanceof K?i:new K(s);r.push(i);var o=e[n++];if(o instanceof K)return o;if(!("number"==typeof(o=this.force(o))||"boolean"==typeof o&&(o=+o,1)||"string"==typeof o&&!/^(?:=|true|false)/i.test(o)&&(t=te.parse(0,0,0,o),/^date|number|percent$/.test(t.type)&&(o=+t.value,1)))||(o|=0,0))return o instanceof K?o:new K(s);r.push(o);var a=e[n++];if(a instanceof K)return a;if(!("number"==typeof(a=this.force(a))&&(a=Zo(a),1)||"boolean"==typeof a&&(a=+a,1)||"string"==typeof a&&!/^(?:=|true|false)/i.test(a)&&(t=te.parse(0,0,0,a),/^date|number|percent$/.test(t.type)&&(a=+t.value,1)))||!(a>0||(s="NUM",0)))return a instanceof K?a:new K(s);r.push(a);var u=e[n++];if(u instanceof K)return u;if(!("number"==typeof(u=this.force(u))&&(u=Zo(u),1)||"boolean"==typeof u&&(u=+u,1)||"string"==typeof u&&!/^(?:=|true|false)/i.test(u)&&(t=te.parse(0,0,0,u),/^date|number|percent$/.test(t.type)&&(u=+t.value,1)))||!(u>0||(s="NUM",0)))return u instanceof K?u:new K(s);r.push(u);var h=e[n++];return h instanceof K?h:null==(h=this.force(h))&&(h=0,1)||("number"==typeof h||"boolean"==typeof h&&(h=+h,1)||"string"==typeof h&&!/^(?:=|true|false)/i.test(h)&&(t=te.parse(0,0,0,h),/^date|number|percent$/.test(t.type)&&(h=+t.value,1)))&&(h|=0,1)&&(0===h||1===h||2===h||3===h||4===h)?(r.push(h),i<o||(s="NUM",0)?5<e.length?new K("N/A"):r:new K(s)):h instanceof K?h:new K(s)},resolve:function(e,t){var r=[],n=0;r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),r.push(e[n++]),this.resolveCells(r,t)}},(function(e,t,r,n,s){var i=Au(e,t,s),o=xu(ta(t).year,s);return n-r*n*i/o}));var $a=300,Ba=22204e-20,Ia=1e-30,Ta=Math.abs;function za(e){if(Ta(e)>=3.3)return 1-Ha(e);var t=e>0?1:-1;-1==t&&(e=-e);for(var r=0,n=1,s=1;s<100;s++)r+=n,n*=2*e*e/(2*s+1);return 2*t/Math.sqrt(Math.PI)*e*Math.exp(-e*e)*r}function Ha(e){if(Ta(e)<3.3)return 1-za(e);var t=1;e<0&&(t=-1,e=-e);for(var r=e,n=8;n>=1;n-=.5)r=e+n/r;return r=1/(e+r),1==t?Math.exp(-e*e)/Math.sqrt(Math.PI)*r:2-Math.exp(-e*e)/Math.sqrt(Math.PI)*r}function Pa(e){var t=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],r=e,n=e+5.5,s=t[0];n-=(e+.5)*Math.log(n);for(var i=1;i<=6;i++)s+=t[i]/(r+=1);return-n+Math.log(Math.sqrt(2*Math.PI)*s/e)}function Oa(e){if(e>0)return Math.exp(Pa(e));var t=Math.PI,r=-e;return-t/(r*Oa(r)*Math.sin(t*r))}function ja(e,t){return Pa(e)+Pa(t)-Pa(e+t)}function Wa(e,t){return Math.exp(ja(e,t))}function qa(e,t){return t<e+1?function(e,t){var r,n=1/e,s=n,i=e,o=Pa(e);for(r=1;r<=$a&&(n+=s*=t/++i,!(Ta(s)<Ta(n)*Ba));r++);return n*Math.exp(-t+e*Math.log(t)-o)}(e,t):1-function(e,t){for(var r=Ia,n=r,s=0,i=1,o=t+1-e,a=Pa(e),u=1;u<=$a;u++){Ta(s=o+i*s)<Ia&&(s=Ia),Ta(n=o+i/n)<Ia&&(n=Ia);var h=n*(s=1/s);if(r*=h,Ta(h-1)<Ba)break;o+=2,i=-u*(u-e)}return r*Math.exp(-t-a+e*Math.log(t))}(e,t)}function Ya(e,t,r,n){return n?qa(t,e/r):Math.pow(e/r,t-1)*Math.exp(-e/r)/(r*Oa(t))}function Ja(e,t,r){if(0===e)return 0;if(1==e)return 1/0;var n=0,s=10,i=0,o=t*r;o>1&&(s*=o);for(var a=0;a<$a;a++){var u=Ya(i=.5*(n+s),t,r,!0);if(Ta(e-u)<1e-16)break;u>e?s=i:n=i}return i}function Xa(e,t){return t?.5+.5*za(e/Math.sqrt(2)):Math.exp(-e*e/2)/Math.sqrt(2*Math.PI)}function Ga(e){var t,r,n=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],s=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],i=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],o=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],a=.02425;return e<a?(t=Math.sqrt(-2*Math.log(e)),(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+i[5])/((((o[0]*t+o[1])*t+o[2])*t+o[3])*t+1)):.97575<e?(t=Math.sqrt(-2*Math.log(1-e)),-(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+i[5])/((((o[0]*t+o[1])*t+o[2])*t+o[3])*t+1)):(((((n[0]*(r=(t=e-.5)*t)+n[1])*r+n[2])*r+n[3])*r+n[4])*r+n[5])*t/(((((s[0]*r+s[1])*r+s[2])*r+s[3])*r+s[4])*r+1)}function Ka(e,t,r){return t+r*Ga(e)}function Qa(e,t,r){var n=Math.exp(t*Math.log(e)+r*Math.log(1-e)-ja(t,r));return e<(t+1)/(t+r+2)?n*Za(t,r,e)/t:1-n*Za(r,t,1-e)/r}function Za(e,t,r){var n,s,i,o,a,u,h,l,c,f;for(c=e-1,o=1,Ta(a=1-(l=e+t)*r/(f=e+1))<Ia&&(a=Ia),h=a=1/a,n=1;n<=$a&&(Ta(a=1+(i=n*(t-n)*r/((c+(s=2*n))*(e+s)))*a)<Ia&&(a=Ia),Ta(o=1+i/o)<Ia&&(o=Ia),h*=(a=1/a)*o,Ta(a=1+(i=-(e+n)*(l+n)*r/((e+s)*(f+s)))*a)<Ia&&(a=Ia),Ta(o=1+i/o)<Ia&&(o=Ia),h*=u=(a=1/a)*o,!(Ta(u-1)<Ba));n++);return h}function eu(e,t,r){for(var n=0,s=1,i=0,o=0;o<$a;o++){var a=Qa(i=.5*(n+s),t,r);if(Ta(e-a)<Ba)break;a>e?s=i:n=i}return i}function tu(e,t,r,n,s){return n+(s-n)*eu(e,t,r)}function ru(e,t,r){return Ya(e,t/2,2,r)}function nu(e,t){return 1-ru(e,t,!0)}function su(e,t){return Ja(e,t/2,2)}function iu(e,t,r,n){if(n)return Qa(t*e/(r+t*e),t/2,r/2);var s=t/r;return s/Wa(t/=2,r/=2)*Math.pow(s*e,t-1)/Math.pow(1+s*e,t+r)}function ou(e){for(var t=0,r=e.length,n=0;n<r;n++)t+=e[n];return t/r}function au(e,t){for(var r=0,n=e.length,s=0;s<n;s++){var i=e[s]-t;r+=i*i}return r/(n-1)}function uu(e,t,r){return r?1-.5*Qa(t/(e*e+t),t/2,.5):1/(Math.sqrt(t)*Wa(.5,t/2))*Math.pow(1+e*e/t,-(t+1)/2)}function hu(e,t){return 1-uu(e,t,!0)}function lu(e,t){return e<0&&(e=-e),2*hu(e,t)}function cu(e,t){var r=eu(2*Math.min(e,1-e),t/2,.5);return r=Math.sqrt(t*(1-r)/r),e>.5?r:-r}function fu(e,t){!function(e,t){for(var r=e.length;--r>=0;)"number"==typeof e[r]&&"number"==typeof t[r]||(e.splice(r,1),t.splice(r,1))}(e,t);for(var r=ou(e),n=ou(t),s=0,i=0,o=0,a=0,u=e.length;a<u;a++){var h=e[a]-r,l=t[a]-n;s+=h*l,i+=h*h,o+=l*l}return s/Math.sqrt(i*o)}function pu(e){for(var t=e.height,r=0,n=0;n<t;n++)r+=e.data[n][0];return r/t}function du(e,t){for(var r=e.height,n=0,s=0;s<r;s++){var i=e.data[s][0]-t;n+=i*i}return n}function gu(e,t,r,n){var s=0;t||(t=e.map((function(){return++s}))),r&&((t=t.clone()).eachRow((function(e){t.data[e].unshift(1)})),++t.width);var i=t.transpose(),o=i.multiply(t).inverse().multiply(i).multiply(e),a=[];for(s=o.height-1;s>=0;s--)a.push(o.data[s][0]);if(r||a.push(0),!n)return this.asMatrix([a]);var u=t.multiply(o),h=e.adds(u,!0),l=du(u,r?pu(u):0),c=du(h,r?pu(h):0),f=[];f.push(l,c);var p=l/(l+c),d=e.height-t.width,g=Math.sqrt(c/d),m=[];m.push(p,g);var v=r?l/(t.width-1)/(c/d):p/t.width/((1-p)/d),y=[];y.push(v,d);var w=i.multiply(t).inverse(),b=[];for(s=w.height-1;s>=0;s--)b.push(Math.sqrt(w.data[s][s]*c/d));return this.asMatrix([a,b,m,y,f])}function mu(e,t,r,n){var s=0;t||(t=e.map((function(){return++s}))),n&&((t=t.clone()).eachRow((function(e){t.data[e].unshift(1)})),++t.width);var i=t.transpose(),o=i.multiply(t).inverse().multiply(i).multiply(e);return r?n&&((r=r.clone()).eachRow((function(e){r.data[e].unshift(1)})),++r.width):r=t,r.multiply(o)}function vu(e,t,r,n){for(var s=r||20,i=n||1e-7,o=t,a=1;a<=s;a++){var u=e(o),h=u[0]/u[1];if(o-=h,Math.abs(h)<i)return o}return new K("NUM")}function yu(e,t,r,n,s){var i=Math.pow(1+e,t);return-(n*i+r*(e?(i-1)/e:t)*(1+e*s))}function wu(e,t,r,n,s){if(!e)return-(n+r)/t;var i=Math.pow(1+e,t);return-e*(n+r*i)/((1+e*s)*(i-1))}function bu(e,t,r,n,s,i){if(1==i&&1==t)return 0;var o=yu(e,t-1,wu(e,r,n,s,i),n,i)*e;return i?o/(1+e):o}function _u(e,t){var r=ta(e),n=r.month+t,s=r.year+Math.floor(n/12);return(n%=12)<0&&(n+=12),r=Math.min(r.date,ra(s,n)),ea(s,n,r)}function Au(e,t,r){return 1==r||2==r||3==r?t-e:Ra(e,t,r)}function Cu(e,t,r){var n=ta(e),s=ta(t).year-n.year;s>0&&(s=(s-1)*r);var i,o=12/r;do{i=_u(t,-++s*o)}while(e<i);return[i,_u(t,- --s*o)]}function xu(e,t){return 3==t?365:1==t?sa(e)?366:365:360}const{packDate:ku,unpackDate:Mu,packTime:Eu,unpackTime:Fu,serialToDate:Ru,dateToSerial:Su,defineAlias:Nu}=te.runtime;var Lu=Object.freeze({__proto__:null,ALL_PROPERTIES:ar,ALL_REASONS:y,AddColumnCommand:oi,AddCommand:ii,AddRowCommand:ai,AdjustDecimalsCommand:Bs,AdjustRowHeightCommand:Ps,ApplyFilterCommand:Qs,AutoFillCalculator:zr,AutoFillCommand:Js,Axis:Dr,AxisManager:Tr,BorderChangeCommand:Is,BringToFrontCommand:xs,CalcError:K,CellRef:c,ClearContentCommand:Ds,ClearFilterCommand:Zs,Clipboard:os,ColumnWidthCommand:Es,Command:ys,Context:ne,Controller:Tt,CopyCommand:Ws,CustomFilter:on,CutCommand:js,Deferred:Hi,DefineNameCommand:fi,DeleteColumnCommand:si,DeleteCommand:ri,DeleteDrawingCommand:As,DeleteNameCommand:pi,DeleteRowCommand:ni,Drawing:yn,DrawingCommand:bs,DrawingUpdateCommand:ws,DynamicFilter:un,EditCommand:Us,EditValidationCommand:ui,EventListener:Mt,FIRSTREF:d,Filter:nn,FilterCommand:Gs,FormulaBar:Qn,FormulaContext:Ct,FormulaInput:Xn,FreezePanesCommand:zs,Grid:$r,GridLinesChangeCommand:Ss,HideLineCommand:ei,HyperlinkCommand:Rs,InsertCommentCommand:Vs,InsertImageCommand:_s,Matrix:ie,MergeCellCommand:Ts,NULLREF:h,NameCommand:ci,NameEditor:Zn,NameRef:l,OpenCommand:hi,Pane:Wn,PaneAxis:Ur,PaneGrid:Br,PasteCommand:Hs,PropertyBag:sr,PropertyChangeCommand:Ns,PropertyCleanCommand:Ls,Range:fr,RangeList:Qt,RangeRef:f,RangeTree:Yt,Ref:u,ReorderDrawingsCommand:Cs,RowHeightCommand:Fs,SHEETREF:g,SaveAsCommand:li,SendToBackCommand:ks,Sheet:vn,SheetDataSourceBinder:qr,SheetEditor:Er,SheetNavigator:Pr,SortCommand:Ks,Sorter:Ir,SpreadsheetWidget:class extends Mr{constructor(e,t){super(e,H({},v,t)),this.events=Go,this.bind(this.events,this.options),Z({locale:this.options.locale,...this.options.intl}),hn(),this._view=new ns(this.element,{messages:this.options.messages.view,toolbar:this.options.toolbar,sheetsbar:this.options.sheetsbar,formulaBarInputRef:this.options.formulaBarInputRef,formulaCellInputRef:this.options.formulaCellInputRef,nameBoxRef:this.options.nameBoxRef,createTabStrip:this.options.createTabStrip,createFilterMenu:this.options.createFilterMenu,createContextMenus:this.options.createContextMenus,createSheetBar:this.options.createSheetBar,getIconHTMLString:this.options.getIconHTMLString,openDialogCallback:this.openDialog.bind(this)}),this._workbook=new Jo(this.options,this._view),this._controller=new Tt(this._view,this._workbook),this._autoRefresh=!0,this._bindWorkbookEvents(),this._bindViewEvents(),this._view.workbook(this._workbook),this._view.enableClipboard(!1),this.refresh(),this._view.enableClipboard(!0),this._resizeHandler=this.resize.bind(this),window.addEventListener("resize",this._resizeHandler),this._keyDownHandler=this._keyDown.bind(this),this.element.addEventListener("keydown",this._keyDownHandler)}get view(){return this._view}get workbook(){return this._workbook}_keyDown(e){let t=e.keyCode,r=e.ctrlKey||e.metaKey;if(this.trigger("keydown",e),t===E&&e.shiftKey)return this._view.sheetsbar.onAddSelect(),void e.preventDefault();if(e.altKey&&t===k){let e=this.sheetIndex(this.activeSheet()),t=this.sheetByIndex(e+1)?.name();t&&this._view.sheetsbar.onSheetSelect(t)}else if(e.altKey&&t===x){let e=this.sheetIndex(this.activeSheet()),t=this.sheetByIndex(e-1)?.name();t&&this._view.sheetsbar.onSheetSelect(t)}else{if(e.altKey&&t===w)return this._view.sheetsbar.onSheetRemove(this.activeSheet()._name()),void e.preventDefault();if(e.altKey&&t===U)return this.options.createSheetEditor?.(),void e.preventDefault();if(r&&t===F)this._handleTypographicalEmphasis("bold");else if(r&&t===R)this._handleTypographicalEmphasis("italic");else if(r&&t===S)this._handleTypographicalEmphasis("underline");else{if(e.altKey&&t===L)return this._view.tabstrip?.select("home"),void e.preventDefault();if(e.altKey&&t===N)return this._view.tabstrip?.select("insert"),void e.preventDefault();if(e.altKey&&t===D)return this._view.tabstrip?.select("data"),void e.preventDefault();t===M&&(e.preventDefault(),this._view.tabstrip?.focus())}}}_handleTypographicalEmphasis(e){const t=this.activeSheet();t&&this.executeCommand({command:"PropertyChangeCommand",options:{property:e,value:!t.range(t.activeCell())[e]()}})}_resize(){this.refresh({layout:!0})}_workbookChanging(e){this.trigger("changing",e)&&e.preventDefault()}_workbookChange(e){if(this._autoRefresh&&this.refresh(e),e.recalc&&e.ref){let t=e.range||new fr(e.ref,this.activeSheet());this.trigger("change",{range:t})}}_workbookCut(e){this.trigger("cut",e)}_workbookCopy(e){this.trigger("copy",e)}_workbookPaste(e){this.trigger("paste",e)}activeSheet(e){return this._workbook.activeSheet(e)}moveSheetToIndex(e,t){return this._workbook.moveSheetToIndex(e,t)}insertSheet(e){return this._workbook.insertSheet(e)}sheets(){return this._workbook.sheets()}removeSheet(e){return this._workbook.removeSheet(e)}sheetByName(e){return this._workbook.sheetByName(e)}sheetIndex(e){return this._workbook.sheetIndex(e)}sheetByIndex(e){return this._workbook.sheetByIndex(e)}renameSheet(e,t){return this._workbook.renameSheet(e,t)}executeCommand(e){return this._controller.executeCommand(e)}refresh(e){return e||(e=y),e.editorClose||(this._view.sheet(this._workbook.activeSheet()),this._controller.sheet(this._workbook.activeSheet()),this._workbook.refresh(e)),e.editorChange||(this._view.refresh(e),this._controller.refresh(),this._view.render(e),this.trigger("render")),this}openDialog(e,t){return this._view.openDialog(e,t)}autoRefresh(e){return void 0!==e?(this._autoRefresh=e,!0===e&&this.refresh(),this):this._autoRefresh}toJSON(){return this._workbook.toJSON()}fromJSON(e){e.sheets?(this._workbook.destroy(),this._workbook=new Jo(H({},this.options,e)),this._bindWorkbookEvents(),this._view.workbook(this._workbook),this._controller.workbook(this._workbook),this.activeSheet(this.activeSheet())):this.refresh()}saveJSON(){return this._workbook.saveJSON()}fromFile(e){return this._workbook.fromFile(e)}saveAsPDF(e){this._workbook.saveAsPDF(H({},this.options.pdf,e,{workbook:this._workbook}))}saveAsExcel(e){return this._workbook.saveAsExcel(e)}draw(e,t){this._workbook.draw(e,t)}_workbookExcelExport(e){this.trigger("excelExport",e)&&e.preventDefault()}_workbookExcelImport(e){this.trigger("excelImport",e)&&e.preventDefault()}_workbookPdfExport(e){this.trigger("pdfExport",e)&&e.preventDefault()}_workbookInsertSheet(e){this.trigger("insertSheet",e)&&e.preventDefault()}_workbookRemoveSheet(e){this.trigger("removeSheet",e)&&e.preventDefault()}_workbookSelectSheet(e){this.trigger("selectSheet",e)&&e.preventDefault()}_workbookRenameSheet(e){this.trigger("renameSheet",e)&&e.preventDefault()}_workbookInsertRow(e){this.trigger("insertRow",e)&&e.preventDefault()}_workbookInsertColumn(e){this.trigger("insertColumn",e)&&e.preventDefault()}_workbookDeleteRow(e){this.trigger("deleteRow",e)&&e.preventDefault()}_workbookDeleteColumn(e){this.trigger("deleteColumn",e)&&e.preventDefault()}_workbookHideRow(e){this.trigger("hideRow",e)&&e.preventDefault()}_workbookHideColumn(e){this.trigger("hideColumn",e)&&e.preventDefault()}_workbookUnhideRow(e){this.trigger("unhideRow",e)&&e.preventDefault()}_workbookUnhideColumn(e){this.trigger("unhideColumn",e)&&e.preventDefault()}_workbookSelect(e){this.trigger("select",e)}_workbookChangeFormat(e){this.trigger("changeFormat",e)}_workbookDataBinding(e){this.trigger("dataBinding",e)&&e.preventDefault()}_workbookDataBound(e){this.trigger("dataBound",e)}_workbookProgress(){}_viewUpdate(e){this.trigger("update",e)}_viewMessage(e){this.trigger("message",e)}_onContextMenu(e){this.trigger("contextmenu",e)}_bindWorkbookEvents(){this._workbook.bind("cut",this._workbookCut.bind(this)),this._workbook.bind("copy",this._workbookCopy.bind(this)),this._workbook.bind("paste",this._workbookPaste.bind(this)),this._workbook.bind("changing",this._workbookChanging.bind(this)),this._workbook.bind("change",this._workbookChange.bind(this)),this._workbook.bind("excelExport",this._workbookExcelExport.bind(this)),this._workbook.bind("excelImport",this._workbookExcelImport.bind(this)),this._workbook.bind("pdfExport",this._workbookPdfExport.bind(this)),this._workbook.bind("insertSheet",this._workbookInsertSheet.bind(this)),this._workbook.bind("removeSheet",this._workbookRemoveSheet.bind(this)),this._workbook.bind("selectSheet",this._workbookSelectSheet.bind(this)),this._workbook.bind("renameSheet",this._workbookRenameSheet.bind(this)),this._workbook.bind("insertRow",this._workbookInsertRow.bind(this)),this._workbook.bind("insertColumn",this._workbookInsertColumn.bind(this)),this._workbook.bind("deleteRow",this._workbookDeleteRow.bind(this)),this._workbook.bind("deleteColumn",this._workbookDeleteColumn.bind(this)),this._workbook.bind("hideRow",this._workbookHideRow.bind(this)),this._workbook.bind("hideColumn",this._workbookHideColumn.bind(this)),this._workbook.bind("unhideRow",this._workbookUnhideRow.bind(this)),this._workbook.bind("unhideColumn",this._workbookUnhideColumn.bind(this)),this._workbook.bind("select",this._workbookSelect.bind(this)),this._workbook.bind("changeFormat",this._workbookChangeFormat.bind(this)),this._workbook.bind("dataBinding",this._workbookDataBinding.bind(this)),this._workbook.bind("dataBound",this._workbookDataBound.bind(this)),this._workbook.bind("progress",this._workbookProgress.bind(this)),this._workbook.bind("contextmenu",this._onContextMenu.bind(this))}_bindViewEvents(){this._view.bind("update",this._viewUpdate.bind(this)),this._view.bind("message",this._viewMessage.bind(this))}destroy(){window.removeEventListener("resize",this._resizeHandler),this.element.removeEventListener("keydown",this._keyDownHandler),this.unbind(),this._workbook.destroy(),this._controller.destroy(),this._view.destroy()}defineName(e,t,r){return this._workbook.defineName(e,t,r)}undefineName(e){return this._workbook.undefineName(e)}nameValue(e){return this._workbook.nameValue(e)}forEachName(e){return this._workbook.forEachName(e)}cellContextMenu(){return this._view.cellContextMenu}rowHeaderContextMenu(){return this._view.rowHeaderContextMenu}colHeaderContextMenu(){return this._view.colHeaderContextMenu}addImage(e){return this._workbook.addImage(e)}cleanupImages(){return this._workbook.cleanupImages()}},TargetValueCommand:Ms,TextWrapCommand:$s,ToolbarCopyCommand:Ys,ToolbarCutCommand:Xs,ToolbarPasteCommand:Os,TopFilter:an,UnHideLineCommand:ti,UnionRef:p,ValidationFormulaContext:xt,ValueFilter:sn,View:ns,Workbook:Jo,calc:te,dateToNumber:function(e){return null==e?null:te.runtime.dateToSerial(e)},dateToSerial:Su,defineAlias:Nu,defineFunction:function(e,t){return e=e.toLowerCase(),re[e]=t,{args:function(r,n){var s=ue(0,r);return n&&(s.arrayArgs&&window.console.log(s.arrayArgs.toString()),s.resolve&&window.console.log(s.resolve.toString()),s.check&&window.console.log(s.check.toString())),(re[e]=fe(t,s.resolve,s.check,s.arrayArgs)).kendoSpreadsheetArgs=r,this},argsAsync:function(r,n){var s=ue(0,r);return n&&(s.arrayArgs&&window.console.log(s.arrayArgs.toString()),s.resolve&&window.console.log(s.resolve.toString()),s.check&&window.console.log(s.check.toString())),(re[e]=pe(t,s.resolve,s.check,s.arrayArgs)).kendoSpreadsheetArgs=r,this}}},draw:In,drawCell:jn,formatting:Je,initDynamicFilter:hn,intl:Z,numberToDate:jr,packDate:ku,packTime:Eu,registerEditor:function(e,t){mn[e]=t},serialToDate:Ru,unpackDate:Mu,unpackTime:Fu,validation:hr});e.__meta__={id:"spreadsheet-common.cmn.chunk",name:"SpreadsheetCommonCmnChunk",category:"web",description:"A reusable outputed chunk of code",depends:["drawing.cmn.chunk","date-math.cmn.chunk","common.cmn.chunk","jszip-esm.cmn.chunk"],hidden:!0,chunk:!0},e.c=Lu}));
//# sourceMappingURL=kendo.spreadsheet-common.cmn.chunk.min.js.map