@odoo/o-spreadsheet 16.4.0-alpha.6 → 16.4.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -270,7 +270,7 @@
270
270
  cursor: pointer;
271
271
  color: #000;
272
272
  }
273
- `;class Rr extends t.Component{static components={Menu:Ir};static template="o-spreadsheet-LinkDisplay";get cell(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;const{col:e,row:t}=this.props.cellPosition;throw new Error(`LinkDisplay Component can only be used with link cells. ${Tt(e,t)} is not a link.`)}getUrlRepresentation(e){return Yi(e,this.env.model.getters)}openLink(){Xi(this.link,this.env)}edit(){const{col:e,row:t}=this.props.cellPosition;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:e,row:t,popoverType:"LinkEditor"})}unlink(){const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.props.cellPosition,i=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:o}),s=i?.textColor===I?void 0:i?.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:o,sheetId:e,content:this.link.label,style:{...i,textColor:s,underline:void 0}})}}const Tr={onHover:(e,t)=>{const o=t.getEvaluatedCell(e);return!t.isDashboard()&&o.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:Rr,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}};Rr.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Ar=/(.*?)\((.*?)\)(.*)/,Or=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function Nr(e,t=""){return function(e,t){let o,i=e.match(Ar),s=i[1].trim(),r=[],n=!1,a=!1,l=!1;for(let e of i[2].split(",")){const t=e.trim().toUpperCase();let i=Or.find((e=>t===e));i?r.push(i):"RANGE<ANY>"===t?r.push("RANGE"):"OPTIONAL"===t?n=!0:"REPEATING"===t?a=!0:"LAZY"===t?l=!0:t.startsWith("DEFAULT=")&&(o=e.trim().slice(8))}const c={name:s,description:t,type:r};n&&(c.optional=!0);a&&(c.repeating=!0);l&&(c.lazy=!0);void 0!==o&&(c.default=!0,c.defaultValue=o);return c}(e,t)}function Mr(e){let t=0,o=0,i=0;for(let s of e.args)t++,s.optional||s.repeating||s.default||o++,s.repeating&&i++;const s=e;return s.minArgRequired=o,s.maxArgPossible=i?1/0:t,s.nbrArgRepeating=i,s.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,i),s.hidden=e.hidden||!1,s}function _r(e,t){gs((()=>1===t.length||1===t[0].length),e)}function Fr(e,...t){if(t.every(cs)){const o=t[0].length,i=t[0][0].length;for(const s of t)gs((()=>s.length===o&&s[0].length===i),e)}else if(t.some((e=>Array.isArray(e)&&(1!==e.length||1!==e[0].length))))throw new Error(e)}function Dr(e,t){gs((()=>t>0),e)}function Lr(e,t){gs((()=>t.length===t[0].length),e)}function Pr(e){return e.every((e=>e.every((e=>"number"==typeof e))))}function kr(e){const t=Array(e);for(let o=0;o<e;o++)t[o]=Array(e).fill(0),t[o][o]=1;return t}function Ur(e){if(e.length!==e[0].length)throw new Error("Function [[FUNCTION_NAME]] invert matrix error, only square matrices are invertible");let t=1;const o=e.length,i=kr(o),s=e.map((e=>e.slice()));for(let e=0;e<o;e++){let r=s[e][e];if(0==r){for(let r=e+1;r<o;r++)if(0!=s[e][r]){Vr(s,e,r),Vr(i,e,r),t*=-1;break}if(r=s[e][e],0===r)return{determinant:0}}for(let t=0;t<o;t++)s[t][e]=s[t][e]/r,i[t][e]=i[t][e]/r;t*=r;for(let t=0;t<o;t++){if(t==e)continue;const r=s[e][t];for(let n=0;n<o;n++)s[n][t]-=r*s[n][e],i[n][t]-=r*i[n][e]}}return{inverted:i,determinant:t}}function Vr(e,t,o){for(let i=0;i<e.length;i++){const s=e[i][t];e[i][t]=e[i][o],e[i][o]=s}}const zr={description:r("Returns a result array constrained to a specific width and height."),args:[Nr("input_range (any, range<any>)",r("The range to constrain.")),Nr("rows (number)",r("The number of rows in the constrained array.")),Nr("columns (number)",r("The number of columns in the constrained array."))],returns:["RANGE<ANY>"],compute:function(e,t,o){const i=$s(e),s=bs(t,this.locale),n=bs(o,this.locale);Dr(r("The rows argument (%s) must be strictly positive.",s.toString()),s),Dr(r("The columns argument (%s) must be strictly positive.",s.toString()),n);const a=Math.min(s,i[0].length),l=Math.min(n,i.length),c=Array(l);for(let e=0;e<l;e++){c[e]=Array(a);for(let t=0;t<a;t++)c[e][t]=Hs(i[e][t])}return c},isExported:!1},Br={description:r("Creates a new array from the selected columns in the existing range."),args:[Nr("array (any, range<any>)",r("The array that contains the columns to be returned.")),Nr("col_num (number, range<number>)",r("The first column index of the columns to be returned.")),Nr("col_num2 (number, range<number>, repeating)",r("The columns indexes of the columns to be returned."))],returns:["RANGE<ANY>"],compute:function(e,...t){const o=$s(e),i=Ws(t,(e=>bs(e,this.locale)));gs((()=>i.every((e=>e>0&&e<=o.length))),r("The columns arguments must be between 1 and %s (got %s).",o.length.toString(),(i.find((e=>e<=0||e>o.length))||0).toString()));const s=Array(i.length);for(let e=0;e<i.length;e++){const t=i[e]-1;s[e]=o[t]}return Bs(s)},isExported:!0},Hr={description:r("Creates a new array from the selected rows in the existing range."),args:[Nr("array (any, range<any>)",r("The array that contains the rows to be returned.")),Nr("row_num (number, range<number>)",r("The first row index of the rows to be returned.")),Nr("row_num2 (number, range<number>, repeating)",r("The rows indexes of the rows to be returned."))],returns:["RANGE<ANY>"],compute:function(e,...t){const o=$s(e),i=Ws(t,(e=>bs(e,this.locale)));gs((()=>i.every((e=>e>0&&e<=o[0].length))),r("The rows arguments must be between 1 and %s (got %s).",o[0].length.toString(),(i.find((e=>e<=0||e>o[0].length))||0).toString()));const s=Array(o.length);for(let e=0;e<o.length;e++){s[e]=Array(i.length);for(let t=0;t<i.length;t++){const r=i[t]-1;s[e][t]=Hs(o[e][r])}}return s},isExported:!0},$r={description:r("Expands or pads an array to specified row and column dimensions."),args:[Nr("array (any, range<any>)",r("The array to expand.")),Nr("rows (number)",r("The number of rows in the expanded array. If missing, rows will not be expanded.")),Nr("columns (number, optional)",r("The number of columns in the expanded array. If missing, columns will not be expanded.")),Nr("pad_with (any, default=0)",r("The value with which to pad."))],returns:["RANGE<ANY>"],compute:function(e,t,o,i=0){const s=$s(e),n=bs(t,this.locale),a=void 0!==o?bs(o,this.locale):s.length,l=null!=i?i:0;gs((()=>n>=s[0].length),r("The rows arguments (%s) must be greater or equal than the number of rows of the array.",n.toString())),gs((()=>a>=s.length),r("The columns arguments (%s) must be greater or equal than the number of columns of the array.",a.toString()));const c=[];for(let e=0;e<a;e++){c[e]=[];for(let t=0;t<n;t++)e>=s.length||t>=s[e].length?c[e][t]=l:c[e][t]=s[e][t]??0}return c},isExported:!0},Wr={description:r("Flattens all the values from one or more ranges into a single column."),args:[Nr("range (any, range<any>)",r("The first range to flatten.")),Nr("range2 (any, range<any>, repeating)",r("Additional ranges to flatten."))],returns:["RANGE<ANY>"],compute:function(...e){return[Ws(e,Hs)]},isExported:!1},Gr={description:r("Calculates the frequency distribution of a range."),args:[Nr("data (range<number>)",r("The array of ranges containing the values to be counted.")),Nr("classes (number, range<number>)",r("The range containing the set of classes."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=Ws([e],(e=>e)).filter((e=>"number"==typeof e)),i=Ws([t],(e=>e)).filter((e=>"number"==typeof e)).map(((e,t)=>({initialIndex:t,value:e,count:0}))).sort(((e,t)=>e.value-t.value));i.push({initialIndex:i.length,value:1/0,count:0});const s=o.sort(((e,t)=>e-t));let r=0;for(const e of s){for(;e>i[r].value&&r<i.length-1;)r++;i[r].count++}return[i.sort(((e,t)=>e.initialIndex-t.initialIndex)).map((e=>e.count))]},isExported:!0},qr={description:r("Appends ranges horizontally and in sequence to return a larger array."),args:[Nr("range1 (any, range<any>)",r("The first range to be appended.")),Nr("range2 (any, range<any>, repeating)",r("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],compute:function(...e){const t=e.map((e=>$s(e))),o=Math.max(...t.map((e=>e[0].length))),i=[];for(const e of t)for(const t of e){const e=Array(o).fill(0);for(let o=0;o<t.length;o++)e[o]=Hs(t[o]);i.push(e)}return i},isExported:!0},Zr={description:r("Returns the matrix determinant of a square matrix."),args:[Nr("square_matrix (number, range<number>)",r("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],returns:["NUMBER"],compute:function(e){const t=$s(e);if(Lr(r("The argument square_matrix must have the same number of columns and rows."),t),!Pr(t))throw new Error(r("The argument square_matrix must be a matrix of numbers."));const{determinant:o}=Ur(t);return o},isExported:!0},jr={description:r("Returns the multiplicative inverse of a square matrix."),args:[Nr("square_matrix (number, range<number>)",r("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=$s(e);if(Lr(r("The argument square_matrix must have the same number of columns and rows."),t),!Pr(t))throw new Error(r("The argument square_matrix must be a matrix of numbers."));const{inverted:o}=Ur(t);if(!o)throw new Error(r("The matrix is not invertible."));return o},isExported:!0},Yr={description:r("Calculates the matrix product of two matrices."),args:[Nr("matrix1 (number, range<number>)",r("The first matrix in the matrix multiplication operation.")),Nr("matrix2 (number, range<number>)",r("The second matrix in the matrix multiplication operation."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=$s(e),i=$s(t);if(gs((()=>o.length===i[0].length),r("In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).",o.length.toString(),i[0].length.toString())),!Pr(o)||!Pr(i))throw new Error(r("The arguments matrix1 and matrix2 must be matrices of numbers."));return function(e,t){if(e.length!==t[0].length)throw new Error(r("Cannot multiply matrices : incompatible matrices size."));const o=e[0].length,i=t.length,s=e.length,n=Array(i);for(let r=0;r<i;r++){n[r]=Array(o);for(let i=0;i<o;i++){let o=0;for(let n=0;n<s;n++)o+=e[n][i]*t[r][n];n[r][i]=o}}return n}(o,i)},isExported:!0},Xr={description:r("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[Nr("range1 (number, range<number>)",r("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),Nr("range2 (number, range<number>, repeating)",r("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],returns:["NUMBER"],compute:function(...e){Fr(r("All the ranges must have the same dimensions."),...e);const t=e.map($s);let o=0;for(let e=0;e<t[0].length;e++)for(let i=0;i<t[0][e].length;i++){if(!t.every((t=>"number"==typeof t[e][i])))continue;let s=1;for(const o of t)s*=ms(o[e][i],this.locale);o+=s}return o},isExported:!0};function Kr(e,t,o){Fr("The arguments array_x and array_y must have the same dimensions.",e,t);const i=$s(e),s=$s(t);let r=!1,n=0;for(const e in i)for(const t in i[e]){const a=i[e][t],l=s[e][t];"number"==typeof a&&"number"==typeof l&&(r=!0,n+=o(a,l))}if(!r)throw new Error("The arguments array_x and array_y must contain at least one pair of numbers.");return n}const Qr={description:r("Calculates the sum of the difference of the squares of the values in two array."),args:[Nr("array_x (number, range<number>)",r("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),Nr("array_y (number, range<number>)",r("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return Kr(e,t,((e,t)=>e**2-t**2))},isExported:!0},Jr={description:r("Calculates the sum of the sum of the squares of the values in two array."),args:[Nr("array_x (number, range<number>)",r("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),Nr("array_y (number, range<number>)",r("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return Kr(e,t,((e,t)=>e**2+t**2))},isExported:!0},en={description:r("Calculates the sum of squares of the differences of values in two array."),args:[Nr("array_x (number, range<number>)",r("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),Nr("array_y (number, range<number>)",r("The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together."))],returns:["NUMBER"],compute:function(e,t){return Kr(e,t,((e,t)=>(e-t)**2))},isExported:!0},tn=[Nr("array (any, range<any>)",r("The array which will be transformed.")),Nr("ignore (number, default=0)",r("The control to ignore blanks and errors. 0 (default) is to keep all values, 1 is to ignore blanks, 2 is to ignore errors, and 3 is to ignore blanks and errors.")),Nr("scan_by_column (number, default=false)",r("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))],on={description:r("Transforms a range of cells into a single column."),args:tn,returns:["RANGE<ANY>"],compute:function(e,t=0,o=false){const i=$s(e),s=bs(t,this.locale),n=ys(o);gs((()=>s>=0&&s<=3),r("Argument ignore must be between 0 and 3"));const a=Os([i],((e,t)=>1!==s&&3!==s||null!=t?(e.push(Hs(t)),e):e),[],n?"colFirst":"rowFirst");if(0===a.length)throw new g(r("No results for the given arguments of TOCOL."));return[a]},isExported:!0},sn={description:r("Transforms a range of cells into a single row."),args:tn,returns:["RANGE<ANY>"],compute:function(e,t=0,o=false){const i=$s(e),s=bs(t,this.locale),n=ys(o);gs((()=>s>=0&&s<=3),r("Argument ignore must be between 0 and 3"));const a=Os([i],((e,t)=>1!==s&&3!==s||null!=t?(e.push([Hs(t)]),e):e),[],n?"colFirst":"rowFirst");if(0===a.length||0===a[0].length)throw new g(r("No results for the given arguments of TOROW."));return a},isExported:!0},rn={description:r("Transposes the rows and columns of a range."),args:[Nr("range (any, range<any>)",r("The range to be transposed."))],returns:["RANGE<ANY>"],computeFormat:e=>{if(e.format)return cs(e.format)?Qe(e.format):e.format},compute:function(e){return Qe($s(e),Hs)},isExported:!0},nn={description:r("Appends ranges vertically and in sequence to return a larger array."),args:[Nr("range1 (any, range<any>)",r("The first range to be appended.")),Nr("range2 (any, range<any>, repeating)",r("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],compute:function(...e){const t=e.map((e=>$s(e))),o=Math.max(...t.map((e=>e.length))),i=t.reduce(((e,t)=>e+t[0].length),0),s=Array(o).fill([]).map((()=>Array(i).fill(0)));let r=0;for(const e of t){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++)s[t][r+o]=Hs(e[t][o]);r+=e[0].length}return s},isExported:!0},an={description:r("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[Nr("range (any, range<any>)",r("The range to wrap.")),Nr("wrap_count (number)",r("The maximum number of cells for each column, rounded down to the nearest whole number.")),Nr("pad_with (any, default=0)",r("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],compute:function(e,t,o=0){const i=$s(e),s=bs(t,this.locale),n=null===o?0:o;_r(r("Argument range must be a single row or column."),i);const a=i.flat(),l=Math.ceil(a.length/s),c=Array(l);for(let e=0;e<l;e++){c[e]=Array(s).fill(n);for(let t=0;t<s;t++){const o=e*s+t;o<a.length&&(c[e][t]=Hs(a[o]))}}return c},isExported:!0},ln={description:r("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[Nr("range (any, range<any>)",r("The range to wrap.")),Nr("wrap_count (number)",r("The maximum number of cells for each row, rounded down to the nearest whole number.")),Nr("pad_with (any, default=0)",r("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],compute:function(e,t,o=0){const i=$s(e),s=bs(t,this.locale),n=null===o?0:o;_r(r("Argument range must be a single row or column."),i);const a=i.flat(),l=Math.ceil(a.length/s),c=Array(s).fill([]).map((()=>Array(l).fill(n)));for(let e=0;e<l;e++)for(let t=0;t<s;t++){const o=e*s+t;o<a.length&&(c[t][e]=Hs(a[o]))}return c},isExported:!0};var cn=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:zr,CHOOSECOLS:Br,CHOOSEROWS:Hr,EXPAND:$r,FLATTEN:Wr,FREQUENCY:Gr,HSTACK:qr,MDETERM:Zr,MINVERSE:jr,MMULT:Yr,SUMPRODUCT:Xr,SUMX2MY2:Qr,SUMX2PY2:Jr,SUMXMY2:en,TOCOL:on,TOROW:sn,TRANSPOSE:rn,VSTACK:nn,WRAPCOLS:an,WRAPROWS:ln});const hn={description:r("Apply a large number format"),args:[Nr("value (number)",r("The number.")),Nr("unit (string, optional)",r("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:function(e,t){const o=Math.abs(ms(e.value,this.locale)),i=e.format;if(void 0!==t){const e=t?.value;switch(e){case"k":return Do(i,1e3,"k",this.locale);case"m":return Do(i,1e6,"m",this.locale);case"b":return Do(i,1e9,"b",this.locale);default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return o<1e5?Do(i,0,"",this.locale):o<1e8?Do(i,1e3,"k",this.locale):o<1e11?Do(i,1e6,"m",this.locale):Do(i,1e9,"b",this.locale)},compute:function(e){return ms(e,this.locale)}};var dn=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:hn});const un=/^-?[a-z0-9]+$/i,gn={description:r("Absolute value of a number."),args:[Nr("value (number)",r("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(ms(e,this.locale))},isExported:!0},pn={description:r("Inverse cosine of a value, in radians."),args:[Nr("value (number)",r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},mn={description:r("Inverse hyperbolic cosine of a number."),args:[Nr("value (number)",r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},fn={description:r("Inverse cotangent of a value."),args:[Nr("value (number)",r("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},bn={description:r("Inverse hyperbolic cotangent of a value."),args:[Nr("value (number)",r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>Math.abs(t)>1),r("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},vn={description:r("Inverse sine of a value, in radians."),args:[Nr("value (number)",r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Sn={description:r("Inverse hyperbolic sine of a number."),args:[Nr("value (number)",r("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(ms(e,this.locale))},isExported:!0},Cn={description:r("Inverse tangent of a value, in radians."),args:[Nr("value (number)",r("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(ms(e,this.locale))},isExported:!0},En={description:r("Angle from the X axis to a point (x,y), in radians."),args:[Nr("x (number)",r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),Nr("y (number)",r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=ms(t,this.locale);return gs((()=>0!==o||0!==i),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(i,o)},isExported:!0},wn={description:r("Inverse hyperbolic tangent of a number."),args:[Nr("value (number)",r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},yn={description:r("Rounds number up to nearest multiple of factor."),args:[Nr("value (number)",r("The value to round up to the nearest integer multiple of factor.")),Nr("factor (number, default=1)",r("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){const o=ms(e,this.locale),i=ms(t,this.locale);return gs((()=>i>=0||o<=0),r("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),o.toString())),i?Math.ceil(o/i)*i:0},isExported:!0},xn={description:r("Rounds number up to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round up to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),Nr("mode (number, default=0)",r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1,o=0){let i=ms(t,this.locale);if(0===i)return 0;const s=ms(e,this.locale);if(i=Math.abs(i),s>=0)return Math.ceil(s/i)*i;return 0===ms(o,this.locale)?-Math.floor(Math.abs(s)/i)*i:-Math.ceil(Math.abs(s)/i)*i},isExported:!0},In={description:r("Rounds number up to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round up to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){return xn.compute.bind(this)(e,t,0)},isExported:!0},Rn={description:r("Cosine of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(ms(e,this.locale))},isExported:!0},Tn={description:r("Hyperbolic cosine of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(ms(e,this.locale))},isExported:!0},An={description:r("Cotangent of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},On={description:r("Hyperbolic cotangent of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Nn={description:r("Number of empty values."),args:[Nr("value1 (any, range)",r("The first value or range in which to count the number of blanks.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Os(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Mn={description:r("A conditional count across a range."),args:[Nr("range (range)",r("The range that is tested against criterion.")),Nr("criterion (string)",r("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return Ls(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},_n={description:r("Count values depending on multiple criteria."),args:[Nr("criteria_range1 (range)",r("The range to check against criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Nr("criterion2 (string, repeating)",r("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return Ls(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0};function Fn(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Dn={description:r("Counts number of unique values in a range."),args:[Nr("value1 (any, range)",r("The first value or range to consider for uniqueness.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Os(e,((e,t)=>Fn(t)?e.add(t):e),new Set).size}},Ln={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:[Nr("range (range)",r("The range of cells from which the number of unique values will be counted.")),Nr("criteria_range1 (range)",r("The range of cells over which to evaluate criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Nr("criterion2 (string, repeating)",r("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=new Set;return Ls(t,((t,i)=>{const s=e[t][i];Fn(s)&&o.add(s)}),this.locale),o.size}},Pn={description:r("Cosecant of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},kn={description:r("Hyperbolic cosecant of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Un={description:r("Converts from another base to decimal."),args:[Nr("value (string)",r("The number to convert.")),Nr(",base (number)",r("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let o=ms(t,this.locale);o=Math.floor(o),gs((()=>2<=o&&o<=36),r("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const i=Cs(e);if(""===i)return 0;gs((()=>!!un.test(i)),r("The value (%s) must be a valid base %s representation.",i,o.toString()));const s=parseInt(i,o);return gs((()=>!isNaN(s)),r("The value (%s) must be a valid base %s representation.",i,o.toString())),s},isExported:!0},Vn={description:r("Converts an angle value in radians to degrees."),args:[Nr("angle (number)",r("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*ms(e,this.locale)/Math.PI},isExported:!0},zn={description:r("Euler's number, e (~2.718) raised to a power."),args:[Nr("value (number)",r("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(ms(e,this.locale))},isExported:!0},Bn={description:r("Rounds number down to nearest multiple of factor."),args:[Nr("value (number)",r("The value to round down to the nearest integer multiple of factor.")),Nr("factor (number, default=1)",r("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){const o=ms(e,this.locale),i=ms(t,this.locale);return gs((()=>i>=0||o<=0),r("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),o.toString())),i?Math.floor(o/i)*i:0},isExported:!0},Hn={description:r("Rounds number down to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round down to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),Nr("mode (number, default=0)",r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1,o=0){let i=ms(t,this.locale);if(0===i)return 0;const s=ms(e,this.locale);if(i=Math.abs(i),s>=0)return Math.floor(s/i)*i;return 0===ms(o,this.locale)?-Math.ceil(Math.abs(s)/i)*i:-Math.floor(Math.abs(s)/i)*i},isExported:!0},$n={description:r("Rounds number down to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round down to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){return Hn.compute.bind(this)(e,t,0)},isExported:!0},Wn={description:r("Whether the provided value is even."),args:[Nr("value (number)",r("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=fs(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Gn={description:r("Rounds number up to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round up to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){return xn.compute.bind(this)(e,t,0)},isExported:!0},qn={description:r("Whether the provided value is even."),args:[Nr("value (number)",r("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=fs(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Zn={description:r("The logarithm of a number, base e (euler's number)."),args:[Nr("value (number)",r("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},jn={description:r("Modulo (remainder) operator."),args:[Nr("dividend (number)",r("The number to be divided to find the remainder.")),Nr("divisor (number)",r("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){const o=ms(t,this.locale);gs((()=>0!==o),r("The divisor must be different from 0."));const i=ms(e,this.locale)%o;return i>0&&o<0||i<0&&o>0?i+o:i},isExported:!0},Yn={description:r("Returns a n x n unit matrix, where n is the input dimension."),args:[Nr("dimension (number)",r("An integer specifying the dimension size of the unit matrix. It must be positive."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=bs(e,this.locale);return Dr(r("The argument dimension must be positive"),t),kr(t)},isExported:!0},Xn={description:r("Rounds a number up to the nearest odd integer."),args:[Nr("value (number)",r("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e){const t=ms(e,this.locale);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,t<0?-o:o},isExported:!0},Kn={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Qn={description:r("A number raised to a power."),args:[Nr("base (number)",r("The number to raise to the exponent power.")),Nr("exponent (number)",r("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){const o=ms(e,this.locale),i=ms(t,this.locale);return gs((()=>o>=0||Number.isInteger(i)),r("The exponent (%s) must be an integer when the base is negative.",i.toString())),Math.pow(o,i)},isExported:!0},Jn={description:r("Result of multiplying a series of numbers together."),args:[Nr("factor1 (number, range<number>)",r("The first number or range to calculate for the product.")),Nr("factor2 (number, range<number>, repeating)",r("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t=0,o=1;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(o*=i,t+=1);else null!=i&&(o*=fs(i,this.locale),t+=1);return 0===t?0:o},isExported:!0},ea={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},ta={description:r("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[Nr("rows (number, default=1)",r("The number of rows to be returned.")),Nr("columns (number, default=1)",r("The number of columns to be returned.")),Nr("min (number, default=0)",r("The minimum number you would like returned.")),Nr("max (number, default=1)",r("The maximum number you would like returned.")),Nr("whole_number (number, default=FALSE)",r("Return a whole number or a decimal value."))],returns:["RANGE<NUMBER>"],compute:function(e=1,t=1,o=0,i=1,s=!1){const n=bs(t,this.locale),a=bs(e,this.locale),l=ms(o,this.locale),c=ms(i,this.locale),h=ys(s);Dr(r("The number columns (%s) must be positive.",n.toString()),n),Dr(r("The number rows (%s) must be positive.",a.toString()),a),gs((()=>l<=c),r("The maximum (%s) must be greater than or equal to the minimum (%s).",c.toString(),l.toString())),h&&gs((()=>Number.isInteger(l)&&Number.isInteger(c)),r("The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.",c.toString(),l.toString()));const d=Array(n);for(let e=0;e<n;e++){d[e]=Array(a);for(let t=0;t<a;t++)d[e][t]=h?Math.floor(Math.random()*(c-l+1)+l):l+Math.random()*(c-l)}return d},isExported:!0},oa={description:r("Random integer between two values, inclusive."),args:[Nr("low (number)",r("The low end of the random range.")),Nr("high (number)",r("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){let o=ms(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let i=ms(t,this.locale);return Number.isInteger(i)||(i=Math.floor(i)),gs((()=>o<=i),r("The high (%s) must be greater than or equal to the low (%s).",i.toString(),o.toString())),o+Math.ceil((i-o+1)*Math.random())-1},isExported:!0},ia={description:r("Rounds a number according to standard rules."),args:[Nr("value (number)",r("The value to round to places number of places.")),Nr("places (number, default=0)",r("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=ms(e,this.locale);let i=ms(t,this.locale);const s=Math.abs(o);let r;return 0===i?r=Math.round(s):(Number.isInteger(i)||(i=Math.trunc(i)),r=Math.round(s*Math.pow(10,i))/Math.pow(10,i)),o>=0?r:-r},isExported:!0},sa={description:r("Rounds down a number."),args:[Nr("value (number)",r("The value to round to places number of places, always rounding down.")),Nr("places (number, default=0)",r("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=ms(e,this.locale);let i=ms(t,this.locale);const s=Math.abs(o);let r;return 0===i?r=Math.floor(s):(Number.isInteger(i)||(i=Math.trunc(i)),r=Math.floor(s*Math.pow(10,i))/Math.pow(10,i)),o>=0?r:-r},isExported:!0},ra={description:r("Rounds up a number."),args:[Nr("value (number)",r("The value to round to places number of places, always rounding up.")),Nr("places (number, default=0)",r("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=ms(e,this.locale);let i=ms(t,this.locale);const s=Math.abs(o);let r;return 0===i?r=Math.ceil(s):(Number.isInteger(i)||(i=Math.trunc(i)),r=Math.ceil(s*Math.pow(10,i))/Math.pow(10,i)),o>=0?r:-r},isExported:!0},na={description:r("Secant of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(ms(e,this.locale))},isExported:!0},aa={description:r("Hyperbolic secant of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(ms(e,this.locale))},isExported:!0},la={description:r("Sine of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(ms(e,this.locale))},isExported:!0},ca={description:r("Hyperbolic sine of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(ms(e,this.locale))},isExported:!0},ha={description:r("Positive square root of a positive number."),args:[Nr("value (number)",r("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e){const t=ms(e,this.locale);return gs((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},da={description:r("Sum of a series of numbers and/or cells."),args:[Nr("value1 (number, range<number>)",r("The first number or range to add together.")),Nr("value2 (number, range<number>, repeating)",r("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){return Ns(e,((e,t)=>e+t),0,this.locale)},isExported:!0},ua={description:r("A conditional sum across a range."),args:[Nr("criteria_range (range)",r("The range which is tested against criterion.")),Nr("criterion (string)",r("The pattern or test to apply to range.")),Nr("sum_range (range, default=criteria_range)",r("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let i=0;return Ls([e,t],((e,t)=>{const s=o[e][t];"number"==typeof s&&(i+=s)}),this.locale),i},isExported:!0},ga={description:r("Sums a range depending on multiple criteria."),args:[Nr("sum_range (range)",r("The range to sum.")),Nr("criteria_range1 (range)",r("The range to check against criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges to check.")),Nr("criterion2 (string, repeating)",r("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let o=0;return Ls(t,((t,i)=>{const s=e[t][i];"number"==typeof s&&(o+=s)}),this.locale),o},isExported:!0},pa={description:r("Tangent of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(ms(e,this.locale))},isExported:!0},ma={description:r("Hyperbolic tangent of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(ms(e,this.locale))},isExported:!0},fa={description:r("Truncates a number."),args:[Nr("value (number)",r("The value to be truncated.")),Nr("places (number, default=0)",r("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=ms(e,this.locale);let i=ms(t,this.locale);return 0===i?Math.trunc(o):(Number.isInteger(i)||(i=Math.trunc(i)),Math.trunc(o*Math.pow(10,i))/Math.pow(10,i))},isExported:!0};var ba=Object.freeze({__proto__:null,ABS:gn,ACOS:pn,ACOSH:mn,ACOT:fn,ACOTH:bn,ASIN:vn,ASINH:Sn,ATAN:Cn,ATAN2:En,ATANH:wn,CEILING:yn,CEILING_MATH:xn,CEILING_PRECISE:In,COS:Rn,COSH:Tn,COT:An,COTH:On,COUNTBLANK:Nn,COUNTIF:Mn,COUNTIFS:_n,COUNTUNIQUE:Dn,COUNTUNIQUEIFS:Ln,CSC:Pn,CSCH:kn,DECIMAL:Un,DEGREES:Vn,EXP:zn,FLOOR:Bn,FLOOR_MATH:Hn,FLOOR_PRECISE:$n,ISEVEN:Wn,ISO_CEILING:Gn,ISODD:qn,LN:Zn,MOD:jn,MUNIT:Yn,ODD:Xn,PI:Kn,POWER:Qn,PRODUCT:Jn,RAND:ea,RANDARRAY:ta,RANDBETWEEN:oa,ROUND:ia,ROUNDDOWN:sa,ROUNDUP:ra,SEC:na,SECH:aa,SIN:la,SINH:ca,SQRT:ha,SUM:da,SUMIF:ua,SUMIFS:ga,TAN:pa,TANH:ma,TRUNC:fa});function va(e,t,o){let i=[],s=[],n=0,a=0;Rs([e],(e=>{i.push(e),n+=1})),Rs([t],(e=>{s.push(e),a+=1})),gs((()=>n===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",n.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<n;e++){const t=i[e],o=s[e];"number"==typeof t&&"number"==typeof o&&(l+=1,c+=t,h+=o)}gs((()=>0!==l&&(!o||1!==l)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<n;e++){const t=i[e],o=s[e];"number"==typeof t&&"number"==typeof o&&(g+=(t-d)*(o-u))}return g/(l-(o?1:0))}function Sa(e,t,o,i){let s=0,n=0;const a=o?Ms:Ns;n=a(e,((e,t)=>(s+=1,e+t)),0,i),gs((()=>0!==s&&(!t||1!==s)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const l=n/s;return a(e,((e,t)=>e+Math.pow(t-l,2)),0,i)/(s-(t?1:0))}function Ca(e,t,o,i){const s=ms(t,i);gs((()=>o?0<=s&&s<=1:0<s&&s<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,a=[],l=0;return Rs(e,(e=>{"number"==typeof e&&(n=Us(a,e,"nextSmaller","asc",a.length,((e,t)=>e[t])),a.splice(n+1,0,e),l++)})),gs((()=>0!==l),r("[[FUNCTION_NAME]] has no valid input data.")),o||gs((()=>1/(l+1)<=s&&s<=l/(l+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),lo(a,s,o)}const Ea={description:r("Average magnitude of deviations from mean."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=Ns(e,((e,o)=>(t+=1,e+o)),0,this.locale);gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const i=o/t;return Ns(e,((e,t)=>e+Math.abs(i-t)),0,this.locale)/t},isExported:!0},wa={description:r("Numerical average value in a dataset, ignoring text."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the average value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t=0;const o=Ns(e,((e,o)=>(t+=1,e+o)),0,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},ya=r("[[FUNCTION_NAME]] has mismatched range sizes."),xa=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Ia={description:r("Weighted average."),args:[Nr("values (number, range<number>)",r("Values to average.")),Nr("weights (number, range<number>)",r("Weights for each corresponding value.")),Nr("additional_values (number, range<number>, repeating)",r("Additional values to average.")),Nr("additional_weights (number, range<number>, repeating)",r("Additional weights."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t,o,i=0,s=0;gs((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let n=0;n<e.length-1;n+=2)if(t=e[n],o=e[n+1],Array.isArray(t)){gs((()=>Array.isArray(o)),ya);let e=t.length,n=t[0].length;gs((()=>e===o.length&&n===o[0].length),ya);for(let a=0;a<e;a++)for(let e=0;e<n;e++){let n=t[a][e],l=o[a][e],c="number"==typeof n,h="number"==typeof l;gs((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(gs((()=>l>=0),xa),i+=n*l,s+=l)}}else o=ms(o,this.locale),t=ms(t,this.locale),gs((()=>o>=0),xa),i+=t*o,s+=o;return gs((()=>0!==s),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/s}},Ra={description:r("Numerical average value in a dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the average value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t=0;const o=Ms(e,((e,o)=>(t+=1,e+o)),0,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},Ta={description:r("Average of values depending on criteria."),args:[Nr("criteria_range (range)",r("The range to check against criterion.")),Nr("criterion (string)",r("The pattern or test to apply to criteria_range.")),Nr("average_range (range, default=criteria_range)",r("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,o){null==o&&(o=e);let i=0,s=0;return Ls([e,t],((t,r)=>{const n=(o||e)[t][r];"number"==typeof n&&(i+=1,s+=n)}),this.locale),gs((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),s/i},isExported:!0},Aa={description:r("Average of values depending on multiple criteria."),args:[Nr("average_range (range)",r("The range to average.")),Nr("criteria_range1 (range)",r("The range to check against criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1.")),Nr("criteria_range2 (any, range, repeating)",r("Additional criteria_range and criterion to check.")),Nr("criterion2 (string, repeating)",r("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=0,i=0;return Ls(t,((t,s)=>{const r=e[t][s];"number"==typeof r&&(o+=1,i+=r)}),this.locale),gs((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/o},isExported:!0},Oa={description:r("The number of numeric values in dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when counting.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(t+=1);else("string"!=typeof o||ro(o,this.locale)||zt(o,this.locale))&&(t+=1);return t},isExported:!0},Na={description:r("The number of values in a dataset."),args:[Nr("value1 (any, range)",r("The first value or range to consider when counting.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Os(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Ma={description:r("The covariance of a dataset."),args:[Nr("data_y (any, range)",r("The range representing the array or matrix of dependent data.")),Nr("data_x (any, range)",r("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return va(e,t,!1)},isExported:!0},_a={description:r("The covariance of a dataset."),args:[Nr("data_y (any, range)",r("The range representing the array or matrix of dependent data.")),Nr("data_x (any, range)",r("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return va(e,t,!1)},isExported:!0},Fa={description:r("The sample covariance of a dataset."),args:[Nr("data_y (any, range)",r("The range representing the array or matrix of dependent data.")),Nr("data_x (any, range)",r("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return va(e,t,!0)},isExported:!0},Da={description:r("Nth largest element from a data set."),args:[Nr("data (any, range)",r("Array or range containing the dataset to consider.")),Nr("n (number)",r("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){const o=Math.trunc(ms(t,this.locale));let i,s=[],n=0;Rs([e],(e=>{"number"==typeof e&&(i=Us(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(i+1,0,e),n++,n>o&&(s.shift(),n--))}));const a=s.shift();return gs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),gs((()=>n>=o),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},La={description:r("Maximum value in a numeric dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the maximum value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){const t=Ns(e,((e,t)=>e<t?t:e),-1/0,this.locale);return t===-1/0?0:t},isExported:!0},Pa={description:r("Maximum numeric value in a dataset."),args:[Nr("value1 (any, range)",r("The first value or range to consider when calculating the maximum value.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){const t=Ms(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return t===-1/0?0:t},isExported:!0},ka={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[Nr("range (range)",r("The range of cells from which the maximum will be determined.")),Nr("criteria_range1 (range)",r("The range of cells over which to evaluate criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Nr("criterion2 (string, repeating)",r("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=-1/0;return Ls(t,((t,i)=>{const s=e[t][i];"number"==typeof s&&(o=o<s?s:o)}),this.locale),o===-1/0?0:o},isExported:!0},Ua={description:r("Median value in a numeric dataset."),args:[Nr("value1 (any, range)",r("The first value or range to consider when calculating the median value.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t=[];return Ts(e,(e=>{t.push(e)}),this.locale),Ca(t,.5,!0,this.locale)},isExported:!0},Va={description:r("Minimum value in a numeric dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the minimum value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){const t=Ns(e,((e,t)=>t<e?t:e),1/0,this.locale);return t===1/0?0:t},isExported:!0},za={description:r("Minimum numeric value in a dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the minimum value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){const t=Ms(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return t===1/0?0:t},isExported:!0},Ba={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[Nr("range (range)",r("The range of cells from which the minimum will be determined.")),Nr("criteria_range1 (range)",r("The range of cells over which to evaluate criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Nr("criterion2 (string, repeating)",r("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=1/0;return Ls(t,((t,i)=>{const s=e[t][i];"number"==typeof s&&(o=o>s?s:o)}),this.locale),o===1/0?0:o},isExported:!0},Ha={description:r("Value at a given percentile of a dataset."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("percentile (number)",r("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Wa.compute.bind(this)(e,t)},isExported:!0},$a={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("percentile (number)",r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Ca([e],t,!1,this.locale)},isExported:!0},Wa={description:r("Value at a given percentile of a dataset."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("percentile (number)",r("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Ca([e],t,!0,this.locale)},isExported:!0},Ga={description:r("Value nearest to a specific quartile of a dataset."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("quartile_number (number)",r("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Za.compute.bind(this)(e,t)},isExported:!0},qa={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("quartile_number (number)",r("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Ca([e],.25*Math.trunc(ms(t,this.locale)),!1,this.locale)},isExported:!0},Za={description:r("Value nearest to a specific quartile of a dataset."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("quartile_number (number)",r("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Ca([e],.25*Math.trunc(ms(t,this.locale)),!0,this.locale)},isExported:!0},ja={description:r("Nth smallest element in a data set."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("n (number)",r("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){const o=Math.trunc(ms(t,this.locale));let i,s=[],n=0;Rs([e],(e=>{"number"==typeof e&&(i=Us(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(i+1,0,e),n++,n>o&&(s.pop(),n--))}));const a=s.pop();return gs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),gs((()=>n>=o),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},Ya={description:r("Standard deviation."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(tl.compute.bind(this)(...e))},isExported:!0},Xa={description:r("Standard deviation of entire population."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ol.compute.bind(this)(...e))},isExported:!0},Ka={description:r("Standard deviation."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(il.compute.bind(this)(...e))},isExported:!0},Qa={description:r("Standard deviation of sample (text as 0)."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(sl.compute.bind(this)(...e))},isExported:!0},Ja={description:r("Standard deviation of entire population."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(rl.compute.bind(this)(...e))},isExported:!0},el={description:r("Standard deviation of entire population (text as 0)."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(nl.compute.bind(this)(...e))},isExported:!0},tl={description:r("Variance."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!0,!1,this.locale)},isExported:!0},ol={description:r("Variance of entire population."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!1,!1,this.locale)},isExported:!0},il={description:r("Variance."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!0,!1,this.locale)},isExported:!0},sl={description:r("Variance of sample (text as 0)."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!0,!0,this.locale)},isExported:!0},rl={description:r("Variance of entire population."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!1,!1,this.locale)},isExported:!0},nl={description:r("Variance of entire population (text as 0)."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!1,!0,this.locale)},isExported:!0};var al=Object.freeze({__proto__:null,AVEDEV:Ea,AVERAGE:wa,AVERAGE_WEIGHTED:Ia,AVERAGEA:Ra,AVERAGEIF:Ta,AVERAGEIFS:Aa,COUNT:Oa,COUNTA:Na,COVAR:Ma,COVARIANCE_P:_a,COVARIANCE_S:Fa,LARGE:Da,MAX:La,MAXA:Pa,MAXIFS:ka,MEDIAN:Ua,MIN:Va,MINA:za,MINIFS:Ba,PERCENTILE:Ha,PERCENTILE_EXC:$a,PERCENTILE_INC:Wa,QUARTILE:Ga,QUARTILE_EXC:qa,QUARTILE_INC:Za,SMALL:ja,STDEV:Ya,STDEV_P:Xa,STDEV_S:Ka,STDEVA:Qa,STDEVP:Ja,STDEVPA:el,VAR:tl,VAR_P:ol,VAR_S:il,VARA:sl,VARP:rl,VARPA:nl});function ll(e,t,o,i){const s=new Map,n=e.length;for(let t=n-1;t>=0;t--)s.set(Cs(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(r("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||n-1<a)throw new Error(r("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),n.toString()))}else{const e=Cs(t).toUpperCase();if(a=s.get(e)??-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Cs(t),[...s.keys()].toString()))}const l=o[0].length;if(l<2)throw new Error(r("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let r=[],n=!0;for(let i=0;i<o.length;i++){const a=Cs(o[i][0]).toUpperCase(),l=s.get(a),c=o[i][t];if(void 0!==c){if(void 0===l){n=!1;break}r.push([e[l].slice(1,h)]),r.push(c)}}if(n){if(!(r.length>0)){c=new Set(Array(h-1).keys());break}Ls(r,((e,t)=>{c.add(t)}),i,!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const cl=[Nr("database (range)",r("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")),Nr("field (any)",r("Indicates which column in database contains the values to be extracted and operated on.")),Nr("criteria (range)",r("An array or range containing zero or more criteria to filter the database values by before operating."))],hl={description:r("Average of a set of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return wa.compute.bind(this)([i])},isExported:!0},dl={description:r("Counts values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Oa.compute.bind(this)([i])},isExported:!0},ul={description:r("Counts values and text from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Na.compute.bind(this)([i])},isExported:!0},gl={description:r("Single value from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return gs((()=>1===i.length),r("More than one match found in DGET evaluation.")),i[0]},isExported:!0},pl={description:r("Maximum of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return La.compute.bind(this)([i])},isExported:!0},ml={description:r("Minimum of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Va.compute.bind(this)([i])},isExported:!0},fl={description:r("Product of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Jn.compute.bind(this)([i])},isExported:!0},bl={description:r("Standard deviation of population sample from table."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Ya.compute.bind(this)([i])},isExported:!0},vl={description:r("Standard deviation of entire population from table."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Ja.compute.bind(this)([i])},isExported:!0},Sl={description:r("Sum of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return da.compute.bind(this)([i])},isExported:!0},Cl={description:r("Variance of population sample from table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return tl.compute.bind(this)([i])},isExported:!0},El={description:r("Variance of a population from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return rl.compute.bind(this)([i])},isExported:!0};var wl=Object.freeze({__proto__:null,DAVERAGE:hl,DCOUNT:dl,DCOUNTA:ul,DGET:gl,DMAX:pl,DMIN:ml,DPRODUCT:fl,DSTDEV:bl,DSTDEVP:vl,DSUM:Sl,DVAR:Cl,DVARP:El});var yl;!function(e){e.WHOLE_YEARS="Y",e.WHOLE_MONTHS="M",e.WHOLE_DAYS="D",e.DAYS_WITHOUT_WHOLE_MONTHS="MD",e.MONTH_WITHOUT_WHOLE_YEARS="YM",e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR="YD"}(yl||(yl={}));const xl={description:r("Converts year/month/day into a date."),args:[Nr("year (number)",r("The year component of the date.")),Nr("month (number)",r("The month component of the date.")),Nr("day (number)",r("The day component of the date."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o){let i=Math.trunc(ms(e,this.locale));const s=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale));gs((()=>0<=i&&i<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",i.toString())),i<1900&&(i+=1900);const a=Ht(new Date(i,s-1,n));return gs((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Il={description:r("Calculates the number of days, months, or years between two dates."),args:[Nr("start_date (date)",r("The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),Nr("end_date (date)",r("The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),Nr("unit (string)",r('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).'))],returns:["NUMBER"],compute:function(e,t,o){const i=Cs(o).toUpperCase();gs((()=>Object.values(yl).includes(i)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return r("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(yl),Cs(o)));const s=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=Bt(s),l=Bt(n);switch(gs((()=>n>=s),r("start_date (%s) should be on or before end_date (%s).",a.toLocaleDateString(),l.toLocaleDateString())),i){case yl.WHOLE_YEARS:return Xt(a,l);case yl.WHOLE_MONTHS:return jt(a,l);case yl.WHOLE_DAYS:return Yt(a,l);case yl.MONTH_WITHOUT_WHOLE_YEARS:return jt(a,l)-12*Xt(a,l);case yl.DAYS_WITHOUT_WHOLE_MONTHS:let e=l.getDate()-a.getDate();if(e<0){e=$t(new Date(l.getFullYear(),l.getMonth()-1,1))-Math.abs(e)}return e;case yl.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return Zt(e,t,1)<1}(s,n))return Yt(a,l);const e=new Date(a.getFullYear(),l.getMonth(),l.getDate());let t=Yt(a,e);return t<0&&(e.setFullYear(a.getFullYear()+1),t=Yt(a,e)),t}}},isExported:!0},Rl={description:r("Converts a date string to a date value."),args:[Nr("date_string (string)",r("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=Cs(e),o=zt(t,this.locale);return gs((()=>null!==o),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},Tl={description:r("Day of the month that a specific date falls on."),args:[Nr("date (string)",r("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getDate()},isExported:!0},Al={description:r("Number of days between two dates."),args:[Nr("end_date (date)",r("The end of the date range.")),Nr("start_date (date)",r("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const o=xs(e,this.locale),i=xs(t,this.locale),s=o.getTime()-i.getTime();return Math.round(s/Ot)},isExported:!0},Ol={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:[Nr("start_date (date)",r("The start date to consider in the calculation.")),Nr("end_date (date)",r("The end date to consider in the calculation.")),Nr("method (number, default=0)",r("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,o=0){const i=ms(e,this.locale),s=ms(t,this.locale),r=ys(o)?4:0,n=Yl.compute.bind(this)(e,t,r);return Math.sign(s-i)*Math.round(360*n)},isExported:!0},Nl={description:r("Date a number of months before/after another date."),args:[Nr("start_date (date)",r("The date from which to calculate the result.")),Nr("months (number)",r("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t){return Ht(Gt(xs(e,this.locale),Math.trunc(ms(t,this.locale)),!1))},isExported:!0},Ml={description:r("Last day of a month before or after a date."),args:[Nr("start_date (date)",r("The date from which to calculate the result.")),Nr("months (number)",r("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t){const o=xs(e,this.locale),i=Math.trunc(ms(t,this.locale)),s=o.getFullYear(),r=o.getMonth();return Ht(new Date(s,r+i+1,0))},isExported:!0},_l={description:r("Hour component of a specific time."),args:[Nr("time (date)",r("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getHours()},isExported:!0},Fl={description:r("ISO week number of the year."),args:[Nr("date (date)",r("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],returns:["NUMBER"],compute:function(e){const t=xs(e,this.locale),o=t.getFullYear();let i=1;for(;4!==new Date(o,0,i).getDay();)i+=1;const s=new Date(o,0,i-3);let r=31;for(;4!==new Date(o,11,r).getDay();)r-=1;const n=new Date(o,11,r+3);let a,l;switch(a=s.getTime()<=t.getTime()?t.getTime()<=n.getTime()?0:1:-1,a){case 0:l=s;break;case 1:l=new Date(o,11,r+3+1);break;case-1:let e=1;for(;4!==new Date(o-1,0,e).getDay();)e+=1;l=new Date(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/Ot;return Math.floor(c/7)+1},isExported:!0},Dl={description:r("Minute component of a specific time."),args:[Nr("time (date)",r("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getMinutes()},isExported:!0},Ll={description:r("Month of the year a specific date falls in"),args:[Nr("date (date)",r("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getMonth()+1},isExported:!0},Pl={description:r("Net working days between two provided days."),args:[Nr("start_date (date)",r("The start date of the period from which to calculate the number of net working days.")),Nr("end_date (date)",r("The end date of the period from which to calculate the number of net working days.")),Nr("holidays (date, range<date>, optional)",r("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,o){return Ul.compute.bind(this)(e,t,1,o)},isExported:!0};function kl(e){if("string"==typeof e){gs((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),r('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let o=0;o<7;o++)"1"===e[o]&&t.push((o+1)%7);return t}if("number"==typeof e)return gs((()=>1<=e&&e<=7||11<=e&&e<=17),r("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(r("The weekend must be a number or a string."))}const Ul={description:r("Net working days between two dates (specifying weekends)."),args:[Nr("start_date (date)",r("The start date of the period from which to calculate the number of net working days.")),Nr("end_date (date)",r("The end date of the period from which to calculate the number of net working days.")),Nr("weekend (any, default=1)",r("A number or string representing which days of the week are considered weekends.")),Nr("holidays (date, range<date>, optional)",r("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,o=1,i){const s=xs(e,this.locale),r=xs(t,this.locale),n=kl(o);let a=new Set;void 0!==i&&Rs([i],(e=>{const t=xs(e,this.locale);a.add(t.getTime())}));const l=s.getTime()>r.getTime(),c=new Date((l?s:r).getTime());let h=new Date((l?r:s).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)n.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Vl={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat+" "+this.locale.timeFormat},compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-At.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/Ot)+o},isExported:!0},zl={description:r("Minute component of a specific time."),args:[Nr("time (date)",r("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getSeconds()},isExported:!0},Bl={description:r("Converts hour/minute/second into a time."),args:[Nr("hour (number)",r("The hour component of the time.")),Nr("minute (number)",r("The minute component of the time.")),Nr("second (number)",r("The second component of the time."))],returns:["DATE"],computeFormat:function(){return this.locale.timeFormat},compute:function(e,t,o){let i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale));return s+=Math.floor(n/60),n=n%60+(n<0?60:0),i+=Math.floor(s/60),s=s%60+(s<0?60:0),i%=24,gs((()=>i>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),i/24+s/1440+n/86400},isExported:!0},Hl={description:r("Converts a time string into its serial number representation."),args:[Nr("time_string (string)",r("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=Cs(e),o=zt(t,this.locale);gs((()=>null!==o),r("The time_string (%s) cannot be parsed to date/time.",t));const i=o.value-Math.trunc(o.value);return i<0?1+i:i},isExported:!0},$l={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(){const e=new Date;return Ht(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Wl={description:r("Day of the week of the date provided (as number)."),args:[Nr("date (date)",r("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Nr("type (number, default=1)",r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const o=xs(e,this.locale),i=Math.round(ms(t,this.locale)),s=o.getDay();return gs((()=>[1,2,3].includes(i)),r("The type (%s) must be 1, 2 or 3.",i.toString())),1===i?s+1:2===i?0===s?7:s:0===s?6:s-1},isExported:!0},Gl={description:r("Week number of the year."),args:[Nr("date (date)",r("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Nr("type (number, default=1)",r("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const o=xs(e,this.locale),i=Math.round(ms(t,this.locale));if(gs((()=>1===i||2===i||11<=i&&i<=17||21===i),r("The type (%s) is out of range.",i.toString())),21===i)return Fl.compute.bind(this)(e);let s;s=1===i||2===i?i-1:i-10==7?0:i-10;const n=o.getFullYear();let a=1,l=new Date(n,0,a);for(;l.getDay()!==s;)a+=1,l=new Date(n,0,a);const c=(o.getTime()-l.getTime())/Ot;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},ql={description:r("Date after a number of workdays."),args:[Nr("start_date (date)",r("The date from which to begin counting.")),Nr("num_days (number)",r("The number of working days to advance from start_date. If negative, counts backwards.")),Nr("holidays (date, range<date>, optional)",r("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o){return Zl.compute.bind(this)(e,t,1,o)},isExported:!0},Zl={description:r("Date after a number of workdays (specifying weekends)."),args:[Nr("start_date (date)",r("The date from which to begin counting.")),Nr("num_days (number)",r("The number of working days to advance from start_date. If negative, counts backwards.")),Nr("weekend (any, default=1)",r("A number or string representing which days of the week are considered weekends.")),Nr("holidays (date, range<date>, optional)",r("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o=1,i){let s=xs(e,this.locale),n=Math.trunc(ms(t,this.locale));"string"==typeof o&&gs((()=>"1111111"!==o),r("The weekend (%s) must be different from '1111111'.",o));const a=kl(o);let l=new Set;void 0!==i&&Rs([i],(e=>{const t=xs(e,this.locale);l.add(t.getTime())}));let c=new Date(s.getTime()),h=c.getTime();const d=Math.sign(n);let u=Math.abs(n);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-At.getTime();return Math.round(g/Ot)},isExported:!0},jl={description:r("Year specified by a given date."),args:[Nr("date (date)",r("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getFullYear()},isExported:!0},Yl={description:r("Exact number of years between two dates."),args:[Nr("start_date (date)",r("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Nr("end_date (date)",r("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Nr("day_count_convention (number, default=0)",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o=0){let i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale));const n=Math.trunc(ms(o,this.locale));return gs((()=>i>=0),r("The start_date (%s) must be positive or null.",i.toString())),gs((()=>s>=0),r("The end_date (%s) must be positive or null.",s.toString())),gs((()=>0<=n&&n<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),Zt(i,s,n)}},Xl={description:r("First day of the month preceding a date."),args:[Nr("date (date)",r("The date from which to calculate the result."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=xs(e,this.locale),o=t.getFullYear(),i=t.getMonth();return Ht(new Date(o,i,1))}},Kl={description:r("Last day of the month following a date."),args:[Nr("date (date)",r("The date from which to calculate the result."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){return Ml.compute.bind(this)(e,0)}},Ql={description:r("Quarter of the year a specific date falls in"),args:[Nr("date (date)",r("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((xs(e,this.locale).getMonth()+1)/3)}},Jl={description:r("First day of the quarter of the year a specific date falls in."),args:[Nr("date (date)",r("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Ql.compute.bind(this)(e),o=jl.compute.bind(this)(e);return Ht(new Date(o,3*(t-1),1))}},ec={description:r("Last day of the quarter of the year a specific date falls in."),args:[Nr("date (date)",r("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Ql.compute.bind(this)(e),o=jl.compute.bind(this)(e);return Ht(new Date(o,3*t,0))}},tc={description:r("First day of the year a specific date falls in."),args:[Nr("date (date)",r("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=jl.compute.bind(this)(e);return Ht(new Date(t,0,1))}},oc={description:r("Last day of the year a specific date falls in."),args:[Nr("date (date)",r("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=jl.compute.bind(this)(e);return Ht(new Date(t+1,0,0))}};var ic=Object.freeze({__proto__:null,DATE:xl,DATEDIF:Il,DATEVALUE:Rl,DAY:Tl,DAYS:Al,DAYS360:Ol,EDATE:Nl,EOMONTH:Ml,HOUR:_l,ISOWEEKNUM:Fl,MINUTE:Dl,MONTH:Ll,NETWORKDAYS:Pl,NETWORKDAYS_INTL:Ul,NOW:Vl,SECOND:zl,TIME:Bl,TIMEVALUE:Hl,TODAY:$l,WEEKDAY:Wl,WEEKNUM:Gl,WORKDAY:ql,WORKDAY_INTL:Zl,YEAR:jl,YEARFRAC:Yl,MONTH_START:Xl,MONTH_END:Kl,QUARTER:Ql,QUARTER_START:Jl,QUARTER_END:ec,YEAR_START:tc,YEAR_END:oc});const sc={description:r("Compare two numeric values, returning 1 if they're equal."),args:[Nr(" (number)",r("The first number to compare.")),Nr(" (number, default=0)",r("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return ms(e,this.locale)===ms(t,this.locale)?1:0},isExported:!0};var rc=Object.freeze({__proto__:null,DELTA:sc});const nc={description:r("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[Nr("range (any, range<any>)",r("The data to be filtered.")),Nr("condition1 (boolean, range<boolean>)",r("A column or row containing true or false values corresponding to the first column or row of range.")),Nr("condition2 (boolean, range<boolean>, repeating)",r("Additional column or row containing true or false values."))],returns:["RANGE<ANY>"],compute:function(e,...t){let o=$s(e);const i=t.map((e=>$s(e)));i.map((e=>_r(r("The arguments condition must be a single column or row."),e))),Fr(r("The arguments conditions must have the same dimensions."),...i);const s=i.map((e=>e.flat())),n=1===i[0].length?"row":"col";o="row"===n?Qe(o):o,gs((()=>s.every((e=>e.length===o.length))),r("FILTER has mismatched sizes on the range and conditions."));const a=[];for(let e=0;e<o.length;e++){const t=o[e];s.every((t=>t[e]))&&a.push(t)}if(!a.length)throw new g(r("No match found in FILTER evaluation"));return Bs("row"===n?Qe(a):a)},isExported:!0},ac={description:r("Unique rows in the provided source range."),args:[Nr("range (any, range<any>)",r("The data to filter by unique entries.")),Nr("by_column (boolean, default=FALSE)",r("Whether to filter the data by columns or by rows.")),Nr("exactly_once (boolean, default=FALSE)",r("Whether to return only entries with no duplicates."))],returns:["RANGE<NUMBER>"],compute:function(e,t,o){if(!cs(e))return Hs(e);const i=ys(t)||!1,s=ys(o)||!1;i||(e=Qe(e));const n=new Map;for(const t of e){const e=JSON.stringify(t),o=n.get(e);o?o.count++:n.set(e,{val:t,count:1})}const a=s?[...n.values()].filter((e=>1===e.count)).map((e=>e.val)):[...n.values()].map((e=>e.val));if(!a.length)throw new Error(r("No unique values found"));return Bs(i?a:Qe(a))},isExported:!0};var lc=Object.freeze({__proto__:null,FILTER:nc,UNIQUE:ac});function cc(e,t){gs((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function hc(e,t){gs((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function dc(e){gs((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function uc(e){gs((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function gc(e){gs((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function pc(e){gs((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function mc(e){gs((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function fc(e){gs((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function bc(e){gs((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function vc(e){gs((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function Sc(e){gs((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function Cc(e){gs((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function Ec(e){gs((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function wc(e,t){gs((()=>e<=t),r("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function yc(e){gs((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function xc(e){gs((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function Ic(e){gs((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function Rc(e){gs((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Tc(e,t,o){const i=xs(e,o),s=xs(t,o),n=new Date(i);n.setFullYear(i.getFullYear()+1),gs((()=>s.getTime()<=n.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Ac(e,t,o){mc(o),gs((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),gs((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),gs((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),gs((()=>t<=o),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Oc(e){gs((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Nc(e,t){gs((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Mc(e){gs((()=>e.every((t=>t>=e[0]))),r("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const _c=[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))];function Fc(e,t,o,i,s=1e-10,n){let a,l,c,h,d=o,u=!1,g=0;do{c=e(d),isNaN(c)?(gs((()=>g<i&&void 0!==n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=n(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<s||Math.abs(c)<s,gs((()=>g<i),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Dc={description:r("Accrued interest of security paying at maturity."),args:[Nr("issue (date)",r("The date the security was initially issued.")),Nr("maturity (date)",r("The maturity date of the security.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(i,this.locale),l=ms(o,this.locale),c=Math.trunc(ms(s,this.locale));hc(n,r),uc(c),gc(a),fc(l);return a*l*Yl.compute.bind(this)(r,n,s)},isExported:!0},Lc={description:r("Depreciation for an accounting period."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("purchase_date (date)",r("The date the asset was purchased.")),Nr("first_period_end (date)",r("The date the first period ended.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("period (number)",r("The single period within life for which to calculate depreciation.")),Nr("rate (number)",r("The deprecation rate.")),Nr(" (number, optional)",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n,a=0){a=a||0;const l=ms(e,this.locale),c=Math.trunc(ms(t,this.locale)),h=Math.trunc(ms(o,this.locale)),d=ms(i,this.locale),u=ms(s,this.locale),g=ms(n,this.locale),p=Math.trunc(ms(a,this.locale));!function(e){gs((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),Cc(d),function(e,t){gs((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){gs((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),fc(g),uc(p),gs((()=>c<=h),r("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,b=Yl.compute.bind(this)(c,h,p),v=c===h?f:f*b,S=l-v-f*m;return S>=d?0===m?v:f:d-S<f?f-(d-S):0},isExported:!0},Pc={description:r("Days in coupon period containing settlement date."),args:_c,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));if(cc(s,r),dc(n),uc(a),1===a){const s=Bc.compute.bind(this)(e,t,o,i);return Vc.compute.bind(this)(e,t,o,i)-s}return(3===a?365:360)/n},isExported:!0},kc={description:r("Days from settlement until next coupon."),args:_c,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);const l=Bc.compute.bind(this)(s,r,o,i);if([1,2,3].includes(a))return s-l;if(4===a){const e=Zt(l,s,a);return Math.round(360*e)}const c=xs(s,this.locale),h=xs(l,this.locale),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Wt(h)&&Wt(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Wt(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Uc={description:r("Days from settlement until next coupon."),args:_c,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);const l=Vc.compute.bind(this)(s,r,o,i);if([1,2,3].includes(a))return l-s;if(4===a){const e=Zt(s,l,a);return Math.round(360*e)}const c=kc.compute.bind(this)(e,t,o,a);return Pc.compute.bind(this)(e,t,o,a)-c},isExported:!0},Vc={description:r("Next coupon date after the settlement date."),args:_c,returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);const l=12/n,c=zc.compute.bind(this)(e,t,o,i);return Ht(Gt(xs(r,this.locale),-(c-1)*l,!0))},isExported:!0},zc={description:r("Number of coupons between settlement and maturity."),args:_c,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);let l=1,c=r;const h=12/n;for(;c>s;)c=Ht(Gt(xs(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},Bc={description:r("Last coupon date prior to or on the settlement date."),args:_c,returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);const l=12/n,c=zc.compute.bind(this)(e,t,o,i);return Ht(Gt(xs(r,this.locale),-c*l,!0))},isExported:!0},Hc={description:r("Cumulative interest paid over a set of periods."),args:[Nr("rate (number)",r("The interest rate.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("first_period (number)",r("The number of the payment period to begin the cumulative calculation.")),Nr("last_period (number)",r("The number of the payment period to end the cumulative calculation.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,i,s,r=0){const n=ms(i,this.locale),a=ms(s,this.locale),l=ms(e,this.locale),c=ms(o,this.locale),h=ms(t,this.locale);Ac(n,a,h),fc(l),Ec(c);let d=0;for(let t=n;t<=a;t++){d+=eh.compute.bind(this)(e,t,h,o,0,r)}return d},isExported:!0},$c={description:r("Cumulative principal paid over a set of periods."),args:[Nr("rate (number)",r("The interest rate.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("first_period (number)",r("The number of the payment period to begin the cumulative calculation.")),Nr("last_period (number)",r("The number of the payment period to end the cumulative calculation.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,i,s,r=0){const n=ms(i,this.locale),a=ms(s,this.locale),l=ms(e,this.locale),c=ms(o,this.locale),h=ms(t,this.locale);Ac(n,a,h),fc(l),Ec(c);let d=0;for(let t=n;t<=a;t++){d+=hh.compute.bind(this)(e,t,h,o,0,r)}return d},isExported:!0},Wc={description:r("Depreciation via declining balance method."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated.")),Nr("period (number)",r("The single period within life for which to calculate depreciation.")),Nr("month (number, optional)",r("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,...s){const n=ms(e,this.locale),a=ms(t,this.locale),l=ms(o,this.locale),c=Math.trunc(ms(i,this.locale)),h=s.length?Math.trunc(ms(s[0],this.locale)):12,d=l+(12===h?0:1);vc(n),Cc(a),Sc(c),bc(l),gs((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),gs((()=>c<=d),r("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/n,1/l);g=Math.round(1e3*g)/1e3;let p=n,m=n*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},Gc={description:r("Depreciation via double-declining balance method."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated.")),Nr("period (number)",r("The single period within life for which to calculate depreciation.")),Nr("factor (number, default=2)",r("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,s=2){s=s||0;const r=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale),c=ms(s,this.locale);if(vc(r),Cc(n),Sc(l),bc(a),wc(l,a),Rc(c),0===r||n>=r)return 0;const h=c/a;if(h>1)return 1===i?r-n:0;if(l<=1)return r*h;const d=r*Math.pow(1-h,l-1),u=r*Math.pow(1-h,l),g=u<n?d-n:d-u;return Math.max(g,0)},isExported:!0},qc={description:r("Discount rate of a security based on price."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("price (number)",r("The price at which the security is bought per 100 face value.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(o,this.locale),l=ms(i,this.locale),c=Math.trunc(ms(s,this.locale));cc(r,n),uc(c),pc(a),gc(l);return(l-a)/l/Yl.compute.bind(this)(r,n,c)},isExported:!0},Zc={description:r("Convert a decimal fraction to decimal value."),args:[Nr("fractional_price (number)",r("The price quotation given using fractional decimal conventions.")),Nr("unit (number)",r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=Math.trunc(ms(t,this.locale));gs((()=>i>0),r("The unit (%s) must be strictly positive.",i.toString()));const s=Math.trunc(o);return s+(o-s)*(10**Math.ceil(Math.log10(i))/i)},isExported:!0},jc={description:r("Convert a decimal value to decimal fraction."),args:[Nr("decimal_price (number)",r("The price quotation given as a decimal value.")),Nr("unit (number)",r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=Math.trunc(ms(t,this.locale));gs((()=>i>0),r("The unit (%s) must be strictly positive.",i.toString()));const s=Math.trunc(o);return s+(o-s)*(i/10**Math.ceil(Math.log10(i)))},isExported:!0},Yc={description:r("Number of periods for an investment to reach a value."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("yield (number)",r("The expected annual yield of the security.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n=0){n=n||0;const a=Math.trunc(ms(e,this.locale)),l=Math.trunc(ms(t,this.locale)),c=ms(o,this.locale),h=ms(i,this.locale),d=Math.trunc(ms(s,this.locale)),u=Math.trunc(ms(n,this.locale));cc(a,l),dc(d),uc(u),gs((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),gs((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=Yl.compute.bind(this)(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,b=h/d;let v=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+b)**e;S+=(p+(e-1)/d)*t,v+=t}return 0===v?0:S/v},isExported:!0},Xc={description:r("Annual effective interest rate."),args:[Nr("nominal_rate (number)",r("The nominal interest rate per year.")),Nr("periods_per_year (number)",r("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=Math.trunc(ms(t,this.locale));return gs((()=>o>0),r("The nominal rate (%s) must be strictly greater than 0.",o.toString())),gs((()=>i>0),r("The number of periods by year (%s) must strictly greater than 0.",i.toString())),Math.pow(1+o/i,i)-1},isExported:!0},Kc={description:r("Future value of an annuity investment."),args:[Nr("rate (number)",r("The interest rate.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("payment_amount (number)",r("The amount per period to be paid.")),Nr("present_value (number, default=0)",r("The current value of the annuity.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i=0,s=0){i=i||0,s=s||0;const r=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale),c=ys(s)?1:0;return r?-l*(1+r)**n-a*(1+r*c)*((1+r)**n-1)/r:-(l+a*n)},isExported:!0},Qc={description:r("Future value of principal from series of rates."),args:[Nr("principal (number)",r("The amount of initial capital or value to compound against.")),Nr("rate_schedule (number, range<number>)",r("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Os([t],((e,t)=>e*(1+ms(t,this.locale))),ms(e,this.locale))},isExported:!0},Jc={description:r("Calculates effective interest rate."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("investment (number)",r("The amount invested in the security.")),Nr("redemption (number)",r("The amount to be received at maturity.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(i,this.locale),l=ms(o,this.locale);cc(r,n),yc(l),gc(a);return(a-l)/l/Yl.compute.bind(this)(r,n,s)},isExported:!0},eh={description:r("Payment on the principal of an investment."),args:[Nr("rate (number)",r("The annualized rate of interest.")),Nr("period (number)",r("The amortization period, in terms of number of periods.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,s=0,r=0){return ch.compute.bind(this)(e,o,i,s,r)-hh.compute.bind(this)(e,t,o,i,s,r)},isExported:!0},th={description:r("Internal rate of return given periodic cashflows."),args:[Nr("cashflow_amounts (number, range<number>)",r("An array or range containing the income or payments associated with the investment.")),Nr("rate_guess (number, default=0.1)",r("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const o=ms(t,this.locale);Oc(o);let i=!1,s=!1,n=[];Ts([e],(e=>{e>0&&(i=!0),e<0&&(s=!0),n.push(e)}),this.locale),gs((()=>i&&s),r("The cashflow_amounts must include negative and positive values."));const a=n.shift();return Fc((function(e){return function(e,t,o){const i=o.length;let s=0;return o.reduce(((t,o)=>(s++,t+o*e**(i-s))),t*e**i)}(e,a,n)}),(function(e){return function(e,t,o){const i=o.length;let s=0;return o.reduce(((t,o)=>(s++,t+o*(i-s)*e**(i-s-1))),t*i*e**(i-1))}(e,a,n)}),o+1,20,1e-5)-1},isExported:!0},oh={description:r("Returns the interest paid at a particular period of an investment."),args:[Nr("rate (number)",r("The interest rate.")),Nr("period (number)",r("The period for which you want to view the interest payment.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,o,i){const s=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale);gs((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(n/a))*s},isExported:!0},ih={description:r("Modified Macaulay duration."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("yield (number)",r("The expected annual yield of the security.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,r=0){return Yc.compute.bind(this)(e,t,o,i,s,r)/(1+ms(i,this.locale)/Math.trunc(ms(s,this.locale)))},isExported:!0},sh={description:r("Modified internal rate of return."),args:[Nr("cashflow_amounts (range<number>)",r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),Nr("financing_rate (number)",r("The interest rate paid on funds invested.")),Nr("reinvestment_return_rate (number)",r("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,o){const i=ms(t,this.locale),s=ms(o,this.locale),n=Qe(e).flat().filter(He).map((e=>ms(e,this.locale))),a=n.length;let l=0,c=0;for(const e of Oe(0,a)){const t=n[e];t>=0?l+=t*(s+1)**(a-e-1):c+=t/(i+1)**e}gs((()=>0!==c&&0!==l),r("There must be both positive and negative values in cashflow_amounts."));return(-l/c)**(1/(a-1))-1},isExported:!0},rh={description:r("Annual nominal interest rate."),args:[Nr("effective_rate (number)",r("The effective interest rate per year.")),Nr("periods_per_year (number)",r("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=Math.trunc(ms(t,this.locale));return gs((()=>o>0),r("The effective rate (%s) must must strictly greater than 0.",o.toString())),gs((()=>i>0),r("The number of periods by year (%s) must strictly greater than 0.",i.toString())),(Math.pow(o+1,1/i)-1)*i},isExported:!0},nh={description:r("Number of payment periods for an investment."),args:[Nr("rate (number)",r("The interest rate.")),Nr("payment_amount (number)",r("The amount of each payment made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,i=0,s=0){i=i||0,s=s||0;const r=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale),c=ys(s)?1:0;if(0===r)return-(l+a)/n;const h=n*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const ah={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[Nr("discount (number)",r("The discount rate of the investment over one period.")),Nr("cashflow1 (number, range<number>)",r("The first future cash flow.")),Nr("cashflow2 (number, range<number>, repeating)",r("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const o=ms(e,this.locale);return gs((()=>-1!==o),r("The discount (%s) must be different from -1.",o.toString())),function(e,t,o,i){let s=0;return Ns(o,((t,o)=>(s++,t+o/(1+e)**s)),t,i)}(o,0,t,this.locale)},isExported:!0},lh={description:r("Computes the number of periods needed for an investment to reach a value."),args:[Nr("rate (number)",r("The rate at which the investment grows each period.")),Nr("present_value (number)",r("The investment's current value.")),Nr("future_value (number)",r("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,o){const i=ms(e,this.locale),s=ms(t,this.locale),n=ms(o,this.locale);return fc(i),gs((()=>s>0),r("The present_value (%s) must be strictly positive.",s.toString())),gs((()=>n>0),r("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(s))/Math.log(1+i)},isExported:!0},ch={description:r("Periodic payment for an annuity investment."),args:[Nr("rate (number)",r("The annualized rate of interest.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i=0,s=0){i=i||0,s=s||0;const r=ms(t,this.locale),n=ms(e,this.locale),a=ys(s)?1:0;let l=ms(i,this.locale),c=ms(o,this.locale);if(mc(r),0===n)return-(l+c)/r;let h=-(c*(1+n)**r+l);return h=h*n/((1+n*a)*((1+n)**r-1)),h},isExported:!0},hh={description:r("Payment on the principal of an investment."),args:[Nr("rate (number)",r("The annualized rate of interest.")),Nr("period (number)",r("The amortization period, in terms of number of periods.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,s=0,n=0){s=s||0,n=n||0;const a=ms(o,this.locale),l=ms(e,this.locale),c=ms(t,this.locale),h=ys(n)?1:0,d=ms(s,this.locale),u=ms(i,this.locale);mc(a),gs((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=ch.compute.bind(this)(l,a,u,d,n);if(1===h&&1===c)return g;const p=0===h?c-1:c-2,m=u+g*h;return g+-Kc.compute.bind(this)(l,p,g,m,0)*l},isExported:!0},dh={description:r("Present value of an annuity investment."),args:[Nr("rate (number)",r("The interest rate.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("payment_amount (number)",r("The amount per period to be paid.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i=0,s=0){i=i||0,s=s||0;const r=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale),c=ys(s)?1:0;return r?-(a*(1+r*c)*((1+r)**n-1)/r+l)/(1+r)**n:-(l+a*n)},isExported:!0},uh={description:r("Price of a security paying periodic interest."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("yield (number)",r("The expected annual yield of the security.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n,a=0){a=a||0;const l=Math.trunc(ms(e,this.locale)),c=Math.trunc(ms(t,this.locale)),h=ms(o,this.locale),d=ms(i,this.locale),u=ms(s,this.locale),g=Math.trunc(ms(n,this.locale)),p=Math.trunc(ms(a,this.locale));cc(l,c),dc(g),uc(p),gs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),gs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),gc(u);const m=Yl.compute.bind(this)(l,c,p)*g,f=Math.ceil(m),b=m-Math.floor(m)||1,v=1+d/g,S=100*h/g;if(1===f)return(S+u)/(b*d/g+1)-S*(1-b);let C=0;for(let e=1;e<=f;e++)C+=S/v**(e-1+b);return u/v**(f-1+b)+C-S*(1-b)},isExported:!0},gh={description:r("Price of a discount security."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("discount (number)",r("The discount rate of the security at time of purchase.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(o,this.locale),l=ms(i,this.locale),c=Math.trunc(ms(s,this.locale));cc(r,n),uc(c),xc(a),gc(l);return l-a*l*Yl.compute.bind(this)(r,n,c)},isExported:!0},ph={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("issue (date)",r("The date the security was initially issued.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("yield (number)",r("The expected annual yield of the security.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n=0){n=n||0;const a=Math.trunc(ms(e,this.locale)),l=Math.trunc(ms(t,this.locale)),c=Math.trunc(ms(o,this.locale)),h=ms(i,this.locale),d=ms(s,this.locale),u=Math.trunc(ms(n,this.locale));hc(a,c),cc(a,l),uc(u),gs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),gs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=Yl.compute.bind(this)(a,l,u),p=Yl.compute.bind(this)(a,c,u);return(100+Yl.compute.bind(this)(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},mh=.1,fh={description:r("Interest rate of an annuity investment."),args:[Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("payment_per_period (number)",r("The amount per period to be paid.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period.")),Nr("rate_guess (number, default=0.1)",r("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,o,i=0,s=0,n=.1){i=i||0,s=s||0,n=n||mh;const a=ms(e,this.locale),l=ms(t,this.locale),c=ys(s)?1:0,h=ms(n,this.locale);let d=ms(i,this.locale),u=ms(o,this.locale);mc(a),gs((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),r("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),Oc(h),d-=l*c,u+=l*c;return Fc((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),o=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(o-1)/e/e)}),h,40,1e-5)},isExported:!0},bh={description:r("Amount received at maturity for a security."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("investment (number)",r("The amount invested (irrespective of face value of each security).")),Nr("discount (number)",r("The discount rate of the security invested in.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(o,this.locale),l=ms(i,this.locale),c=Math.trunc(ms(s,this.locale));cc(r,n),uc(c),yc(a),xc(l);return a/(1-l*Yl.compute.bind(this)(r,n,c))},isExported:!0},vh={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[Nr("number_of_periods (number)",r("The number of periods.")),Nr("present_value (number)",r("The present value of the investment.")),Nr("future_value (number)",r("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,o){const i=ms(e,this.locale),s=ms(t,this.locale),r=ms(o,this.locale);return mc(i),(r/s)**(1/i)-1},isExported:!0},Sh={description:r("Depreciation of an asset using the straight-line method."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o){return(ms(e,this.locale)-ms(t,this.locale))/ms(o,this.locale)},isExported:!0},Ch={description:r("Depreciation via sum of years digit method."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated.")),Nr("period (number)",r("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i){const s=ms(e,this.locale),r=ms(t,this.locale),n=ms(o,this.locale),a=ms(i,this.locale);Sc(a),bc(n),wc(a,n);return(n-a+1)/(n*(n+1)/2)*(s-r)},isExported:!0},Eh={description:r("Price of a US Treasury bill."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("discount (number)",r("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale)),r=ms(o,this.locale);cc(i,s),Tc(i,s,this.locale),xc(r),Ic(r);return 100*(1-r*Yl.compute.bind(this)(i,s,2))},isExported:!0},wh={description:r("Equivalent rate of return for a US Treasury bill."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("discount (number)",r("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale)),r=ms(o,this.locale);cc(i,s),Tc(i,s,this.locale),xc(r),Ic(r);const n=Al.compute.bind(this)(s,i);if(n<=182)return 365*r/(360-r*n);const a=Eh.compute.bind(this)(i,s,r)/100,l=n/(366===n?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},yh={description:r("The yield of a US Treasury bill based on price."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("price (number)",r("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale)),r=ms(o,this.locale);cc(i,s),Tc(i,s,this.locale),pc(r);return(100-r)/r*(1/Yl.compute.bind(this)(i,s,2))},isExported:!0},xh={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated.")),Nr("start (number)",r("Starting period to calculate depreciation.")),Nr("end (number)",r("Ending period to calculate depreciation.")),Nr("factor (number, default=2)",r("The number of months in the first year of depreciation.")),Nr("no_switch (number, default=false)",r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n=2,a=false){n=n||0;const l=ms(e,this.locale),c=ms(t,this.locale),h=ms(o,this.locale),d=Math.trunc(ms(i,this.locale)),u=Math.trunc(ms(s,this.locale)),g=ms(n,this.locale),p=ys(a);if(vc(l),Cc(c),function(e,t,o){bc(o),gs((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),gs((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),gs((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),gs((()=>t<=o),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(d,u,h),Rc(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,b=0,v=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,o=(f-c)/(h-e);!p&&o>t?(S=!0,b=o):b=t}const t=Math.max(f-b,c);e>=d&&(v+=f-t),f=t}return v},isExported:!0},Ih={description:r("Internal rate of return given non-periodic cash flows."),args:[Nr("cashflow_amounts (range<number>)",r("An range containing the income or payments associated with the investment.")),Nr("cashflow_dates (range<number>)",r("An range with dates corresponding to the cash flows in cashflow_amounts.")),Nr("rate_guess (number, default=0.1)",r("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,o=.1){const i=ms(o=o||0,this.locale),s=e.flat().map((e=>ms(e,this.locale))),n=t.flat().map((e=>ms(e,this.locale)));var a;Nc(e,t),a=s,gs((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),Mc(n),Oc(i);const l=new Map;for(const e of Oe(0,n.length)){const t=n[e];l.has(t)?l.set(t,l.get(t)+s[e]):l.set(t,s[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return Fc((e=>{let t=h[0];for(const o of Oe(1,h.length)){const i=(c[0]-c[o])/365;t+=h[o]*(1+e)**i}return t}),(e=>{let t=0;for(const o of Oe(1,h.length)){const i=(c[0]-c[o])/365;t+=i*h[o]*(1+e)**(i-1)}return t}),i,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Rh={description:r("Net present value given to non-periodic cash flows.."),args:[Nr("discount (number)",r("The discount rate of the investment over one period.")),Nr("cashflow_amounts (number, range<number>)",r("An range containing the income or payments associated with the investment.")),Nr("cashflow_dates (number, range<number>)",r("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,o){const i=ms(e,this.locale),s=Array.isArray(t)?t.flat().map((e=>fs(e,this.locale))):[fs(t,this.locale)],n=Array.isArray(o)?o.flat().map((e=>fs(e,this.locale))):[fs(o,this.locale)];if(Array.isArray(o)&&Array.isArray(t)?Nc(t,o):gs((()=>s.length===n.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Mc(n),fc(i),1===s.length)return s[0];const a=new Map;for(const e of Oe(0,n.length)){const t=n[e];a.has(t)?a.set(t,a.get(t)+s[e]):a.set(t,s[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of Oe(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+i)**t}return h},isExported:!0},Th={description:r("Annual yield of a security paying periodic interest."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("price (number)",r("The price at which the security is bought per 100 face value.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n,a=0){a=a||0;const l=Math.trunc(ms(e,this.locale)),c=Math.trunc(ms(t,this.locale)),h=ms(o,this.locale),d=ms(i,this.locale),u=ms(s,this.locale),g=Math.trunc(ms(n,this.locale)),p=Math.trunc(ms(a,this.locale));cc(l,c),dc(g),uc(p),gs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),pc(d),gc(u);const m=Yl.compute.bind(this)(l,c,p)*g,f=Math.ceil(m),b=m-Math.floor(m)||1,v=100*h/g;if(1===f){const e=d+v*(1-b);return(u+v-e)*g*(1/b)/e}const S=Fc((function(e){return function(e,t,o,i,s,r){let n=r-(e+s*(1-t))*i**(o-1+t);for(let e=1;e<=o;e++)n+=s*i**(e-1);return n}(d,b,f,e,v,u)}),(function(e){return function(e,t,o,i,s){let r=-(e+s*(1-t))*(o-1+t)*i**(o-2+t);for(let e=1;e<=o;e++)r+=s*(e-1)*i**(e-2);return r}(d,b,f,e,v)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Ah={description:r("Annual yield of a discount security."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("price (number)",r("The price at which the security is bought per 100 face value.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(o,this.locale),l=ms(i,this.locale),c=Math.trunc(ms(s,this.locale));cc(r,n),uc(c),pc(a),gc(l);return(l/a-1)/Yl.compute.bind(this)(e,t,s)},isExported:!0},Oh={description:r("Annual yield of a security paying interest at maturity."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("issue (date)",r("The date the security was initially issued.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("price (number)",r("The price at which the security is bought.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n=0){n=n||0;const a=Math.trunc(ms(e,this.locale)),l=Math.trunc(ms(t,this.locale)),c=Math.trunc(ms(o,this.locale)),h=ms(i,this.locale),d=ms(s,this.locale),u=Math.trunc(ms(n,this.locale));cc(a,l),uc(u),gs((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),gs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),pc(d);const g=Yl.compute.bind(this)(c,l,u),p=Yl.compute.bind(this)(c,a,u),m=Yl.compute.bind(this)(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Nh=Object.freeze({__proto__:null,ACCRINTM:Dc,AMORLINC:Lc,COUPDAYS:Pc,COUPDAYBS:kc,COUPDAYSNC:Uc,COUPNCD:Vc,COUPNUM:zc,COUPPCD:Bc,CUMIPMT:Hc,CUMPRINC:$c,DB:Wc,DDB:Gc,DISC:qc,DOLLARDE:Zc,DOLLARFR:jc,DURATION:Yc,EFFECT:Xc,FV:Kc,FVSCHEDULE:Qc,INTRATE:Jc,IPMT:eh,IRR:th,ISPMT:oh,MDURATION:ih,MIRR:sh,NOMINAL:rh,NPER:nh,NPV:ah,PDURATION:lh,PMT:ch,PPMT:hh,PV:dh,PRICE:uh,PRICEDISC:gh,PRICEMAT:ph,RATE:fh,RECEIVED:bh,RRI:vh,SLN:Sh,SYD:Ch,TBILLPRICE:Eh,TBILLEQ:wh,TBILLYIELD:yh,VDB:xh,XIRR:Ih,XNPV:Rh,YIELD:Th,YIELDDISC:Ah,YIELDMAT:Oh});const Mh={description:r("Whether a value is an error other than #N/A."),args:[Nr("value (any, lazy)",r("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return e?.errorType!=a.NotAvailable}},isExported:!0},_h={description:r("Whether a value is an error."),args:[Nr("value (any, lazy)",r("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},Fh={description:r("Whether a value is `true` or `false`."),args:[Nr("value (any, lazy)",r("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},Dh={description:r("Whether a value is the error #N/A."),args:[Nr("value (any, lazy)",r("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return e?.errorType==a.NotAvailable}},isExported:!0},Lh={description:r("Whether a value is non-textual."),args:[Nr("value (any, lazy)",r("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},Ph={description:r("Whether a value is a number."),args:[Nr("value (any, lazy)",r("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},kh={description:r("Whether a value is text."),args:[Nr("value (any, lazy)",r("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Uh={description:r("Whether the referenced cell is empty"),args:[Nr("value (any, lazy)",r("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Vh={description:r("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var zh=Object.freeze({__proto__:null,ISERR:Mh,ISERROR:_h,ISLOGICAL:Fh,ISNA:Dh,ISNONTEXT:Lh,ISNUMBER:Ph,ISTEXT:kh,ISBLANK:Uh,NA:Vh});const Bh={description:r("Logical `and` operator."),args:[Nr("logical_expression1 (boolean, range<boolean>)",r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Nr("logical_expression2 (boolean, range<boolean>, repeating)",r("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!0;return _s(e,(e=>(t=!0,o=o&&e,o))),gs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Hh={description:r("Returns value depending on logical expression."),args:[Nr("logical_expression (boolean)",r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),Nr("value_if_true (any, lazy)",r("The value the function returns if logical_expression is TRUE.")),Nr("value_if_false (any, lazy, default=FALSE)",r("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,o=(()=>!1)){const i=ys(e)?t():o();return null==i?"":i},isExported:!0},$h={description:r("Value if it is not an error, otherwise 2nd argument."),args:[Nr("value (any, lazy)",r("The value to return if value itself is not an error.")),Nr('value_if_error (any, lazy, default="empty")',r("The value the function returns if value is an error."))],returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{try{return e().format}catch(e){return t()?.format}},compute:function(e,t=(()=>"")){let o;try{o=e()}catch(e){o=t()}return null==o?"":o},isExported:!0},Wh={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:[Nr("value (any, lazy)",r("The value to return if value itself is not #N/A an error.")),Nr('value_if_error (any, lazy, default="empty")',r("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t=(()=>"")){let o;try{o=e()}catch(i){o=i.errorType===a.NotAvailable?t():e()}return null==o?"":o},isExported:!0},Gh={description:r("Returns a value depending on multiple logical expressions."),args:[Nr("condition1 (boolean, lazy)",r("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),Nr("value1 (any, lazy)",r("The returned value if condition1 is TRUE.")),Nr("condition2 (boolean, lazy, repeating)",r("Additional conditions to be evaluated if the previous ones are FALSE.")),Nr("value2 (any, lazy, repeating)",r("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){gs((()=>e.length%2==0),r("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(ys(e[t]())){const o=e[t+1]();return null!==o?o:""}throw new Error(r("No match."))},isExported:!0},qh={description:r("Returns opposite of provided logical value."),args:[Nr("logical_expression (boolean)",r("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!ys(e)},isExported:!0},Zh={description:r("Logical `or` operator."),args:[Nr("logical_expression1 (boolean, range<boolean>)",r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Nr("logical_expression2 (boolean, range<boolean>, repeating)",r("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return _s(e,(e=>(t=!0,o=o||e,!o))),gs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},jh={description:r("Logical `xor` operator."),args:[Nr("logical_expression1 (boolean, range<boolean>)",r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Nr("logical_expression2 (boolean, range<boolean>, repeating)",r("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return _s(e,(e=>(t=!0,o=o?!e:e,!0))),gs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Yh=Object.freeze({__proto__:null,AND:Bh,IF:Hh,IFERROR:$h,IFNA:Wh,IFS:Gh,NOT:qh,OR:Zh,XOR:jh});function Xh(e,t){if(void 0===e)throw new g(r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Cs(t)))}const Kh={description:r("Returns a cell reference as a string. "),args:[Nr("row (number)",r("The row number of the cell reference. ")),Nr("column (number)",r("The column number (not name) of the cell reference. A is column number 1. ")),Nr("absolute_relative_mode (number, default=1)",r("An indicator of whether the reference is row/column absolute. 1 is row and column absolute (e.g. $A$1), 2 is row absolute and column relative (e.g. A$1), 3 is row relative and column absolute (e.g. $A1), and 4 is row and column relative (e.g. A1).")),Nr("use_a1_notation (boolean, default=TRUE)",r("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),Nr("sheet (string, optional)",r("A string indicating the name of the sheet into which the address points."))],returns:["STRING"],compute:function(e,t,o=1,i=!0,s){const n=vs(e,this.locale),a=vs(t,this.locale);Ss(n),Ss(a);const l=vs(o,this.locale);var c,h;gs((()=>[1,2,3,4].includes(l)),(c=4,h=l,r("The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.",1..toString(),c.toString(),h.toString())));let d;if(ys(i)){d=Tt(a-1,n-1,{rowFixed:!![1,2].includes(l),colFixed:!![1,3].includes(l)})}else{d=([1,2].includes(l)?`R${n}`:`R[${n}]`)+([1,3].includes(l)?`C${a}`:`C[${a}]`)}return void 0!==s?`${Ee(Cs(s))}!${d}`:d},isExported:!0},Qh={description:r("Column number of a specified cell."),args:[Nr("cell_reference (meta, default='this cell')",r("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){const t=e||this.__originCellXC?.();gs((()=>!!t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Jo(t).left+1},isExported:!0},Jh={description:r("Number of columns in a specified array or range."),args:[Nr("range (meta)",r("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Jo(e);return t.right-t.left+1},isExported:!0},ed={description:r("Horizontal lookup"),args:[Nr("search_key (any)",r("The value to search for. For example, 42, 'Cats', or I24.")),Nr("range (range)",r("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),Nr("index (number)",r("The row index of the value to be returned, where the first row in range is numbered 1.")),Nr("is_sorted (boolean, default=true)",r("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,o,i=true){const s=Math.trunc(ms(o,this.locale)),n=Es(e);gs((()=>1<=s&&s<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=ys(i)?Us(t,n,"nextSmaller","asc",t.length,ks):Vs(t,n,"strict",t.length,ks);const l=t[a];return Xh(l,e),l[s-1]},isExported:!0},td={description:r("Look up a value."),args:[Nr("search_key (any)",r("The value to search for. For example, 42, 'Cats', or I24.")),Nr("search_array (range)",r("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),Nr("result_range (range, optional)",r("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],returns:["ANY"],compute:function(e,t,o){let i=t.length,s=t[0].length;const n=Es(e),a=s>=i,l=Us(t,n,"nextSmaller","asc",a?s:i,a?Ps:ks);return-1===l&&Xh(void 0,e),Xh(a?t[0][l]:t[l][s-1],e),void 0===o?a?t[i-1][l]:t[l][s-1]:(i=o.length,s=o[0].length,gs((()=>1===i||1===s),r("The result_range must be a single row or a single column.")),i>1?(gs((()=>l<=i-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),o[l][0]):(gs((()=>l<=s-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),o[0][l]))},isExported:!0},od={description:r("Position of item in range that matches value."),args:[Nr("search_key (any)",r("The value to search for. For example, 42, 'Cats', or I24.")),Nr("range (any, range)",r("The one-dimensional array to be searched.")),Nr("search_type (number, default=1)",r("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,o=1){let i=ms(o,this.locale);const s=Es(e),n=t.length,a=t[0].length;gs((()=>1===n||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===n?Ps:ks,h=1===n?t[0].length:t.length;switch(i=Math.sign(i),i){case 1:l=Us(t,s,"nextSmaller","asc",h,c);break;case 0:l=Vs(t,s,"strict",h,c);break;case-1:l=Us(t,s,"nextGreater","desc",h,c)}return Xh(1===n?t[0][l]:t[l],e),l+1},isExported:!0},id={description:r("Row number of a specified cell."),args:[Nr("cell_reference (meta, default='this cell')",r("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){e=e||this.__originCellXC?.(),gs((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Jo(e).top+1},isExported:!0},sd={description:r("Number of rows in a specified array or range."),args:[Nr("range (meta)",r("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Jo(e);return t.bottom-t.top+1},isExported:!0},rd={description:r("Vertical lookup."),args:[Nr("search_key (any)",r("The value to search for. For example, 42, 'Cats', or I24.")),Nr("range (any, range)",r("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),Nr("index (number)",r("The column index of the value to be returned, where the first column in range is numbered 1.")),Nr("is_sorted (boolean, default=true)",r("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,o,i=true){const s=Math.trunc(ms(o,this.locale)),n=Es(e);gs((()=>1<=s&&s<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=ys(i)?Us(t,n,"nextSmaller","asc",t[0].length,Ps):Vs(t,n,"strict",t[0].length,Ps);const l=t[s-1][a];return Xh(l,e),l},isExported:!0},nd={description:r("Search a range for a match and return the corresponding item from a second range."),args:[Nr("search_key (any)",r("The value to search for.")),Nr("lookup_range (any, range)",r("The range to consider for the search. Should be a single column or a single row.")),Nr("return_range (any, range)",r("The range containing the return value. Should have the same dimensions as lookup_range.")),Nr("if_not_found (any, lazy, optional)",r("If a valid match is not found, return this value.")),Nr("match_mode (any, default=0)",r("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),Nr("search_mode (any, default=1)",r("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,o,i,s=0,n=1){const a=Math.trunc(ms(s,this.locale)),l=Math.trunc(ms(n,this.locale)),c=Es(e);gs((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),gs((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),gs((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?"col":"row";gs((()=>"col"===h?o[0].length===t[0].length:o.length===t.length),r("return_range should have the same dimensions as lookup_range."));const d="col"===h?Ps:ks,u="col"===h?t[0].length:t.length,g=0===a?"strict":1===a?"nextGreater":"nextSmaller",p=-1===l;let m;if(2===l||-2===l){m=Us(t,c,g,2===l?"asc":"desc",u,d)}else m=Vs(t,c,g,u,d,p);if(-1!==m)return Bs("col"===h?o.map((e=>[e[m]])):[o[m]]);const f=i?.();return Xh(f,e),f},isExported:!0};var ad=Object.freeze({__proto__:null,ADDRESS:Kh,COLUMN:Qh,COLUMNS:Jh,HLOOKUP:ed,LOOKUP:td,MATCH:od,ROW:id,ROWS:sd,VLOOKUP:rd,XLOOKUP:nd});const ld={description:r("Sum of two numbers."),args:[Nr("value1 (number)",r("The first addend.")),Nr("value2 (number)",r("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return ms(e,this.locale)+ms(t,this.locale)}},cd={description:r("Concatenation of two values."),args:[Nr("value1 (string)",r("The value to which value2 will be appended.")),Nr("value2 (string)",r("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return Cs(e)+Cs(t)},isExported:!0},hd={description:r("One number divided by another."),args:[Nr("dividend (number)",r("The number to be divided.")),Nr("divisor (number)",r("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){const o=ms(t,this.locale);return gs((()=>0!==o),r("The divisor must be different from zero.")),ms(e,this.locale)/o}};function dd(e){return null==e}const ud={number:0,string:"",boolean:!1},gd={description:r("Equal."),args:[Nr("value1 (any)",r("The first value.")),Nr("value2 (any)",r("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=dd(e)?ud[typeof t]:e,t=dd(t)?ud[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function pd(e,t,o){e=dd(e)?ud[typeof t]:e,t=dd(t)?ud[typeof e]:t,"number"!=typeof e&&(e=Cs(e).toUpperCase()),"number"!=typeof t&&(t=Cs(t).toUpperCase());const i=typeof e,s=typeof t;return"string"===i&&"number"===s||("string"!==s||"number"!==i)&&o(e,t)}const md={description:r("Strictly greater than."),args:[Nr("value1 (any)",r("The value to test as being greater than value2.")),Nr("value2 (any)",r("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return pd(e,t,((e,t)=>e>t))}},fd={description:r("Greater than or equal to."),args:[Nr("value1 (any)",r("The value to test as being greater than or equal to value2.")),Nr("value2 (any)",r("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return pd(e,t,((e,t)=>e>=t))}},bd={description:r("Less than."),args:[Nr("value1 (any)",r("The value to test as being less than value2.")),Nr("value2 (any)",r("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!fd.compute.bind(this)(e,t)}},vd={description:r("Less than or equal to."),args:[Nr("value1 (any)",r("The value to test as being less than or equal to value2.")),Nr("value2 (any)",r("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!md.compute.bind(this)(e,t)}},Sd={description:r("Difference of two numbers."),args:[Nr("value1 (number)",r("The minuend, or number to be subtracted from.")),Nr("value2 (number)",r("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return ms(e,this.locale)-ms(t,this.locale)}},Cd={description:r("Product of two numbers"),args:[Nr("factor1 (number)",r("The first multiplicand.")),Nr("factor2 (number)",r("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return ms(e,this.locale)*ms(t,this.locale)}},Ed={description:r("Not equal."),args:[Nr("value1 (any)",r("The first value.")),Nr("value2 (any)",r("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!gd.compute.bind(this)(e,t)}},wd={description:r("A number raised to a power."),args:[Nr("base (number)",r("The number to raise to the exponent power.")),Nr("exponent (number)",r("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return Qn.compute.bind(this)(e,t)}},yd={description:r("A number with the sign reversed."),args:[Nr("value (number)",r("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>e?.format,returns:["NUMBER"],compute:function(e){return-ms(e,this.locale)}},xd={description:r("Value interpreted as a percentage."),args:[Nr("percentage (number)",r("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return ms(e,this.locale)/100}},Id={description:r("A specified number, unchanged."),args:[Nr("value (any)",r("The number to return."))],returns:["ANY"],computeFormat:e=>e?.format,compute:function(e){return null===e?"":e}};var Rd=Object.freeze({__proto__:null,ADD:ld,CONCAT:cd,DIVIDE:hd,EQ:gd,GT:md,GTE:fd,LT:bd,LTE:vd,MINUS:Sd,MULTIPLY:Cd,NE:Ed,POW:wd,UMINUS:yd,UNARY_PERCENT:xd,UPLUS:Id});const Td=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Ad={description:r("Gets character associated with number."),args:[Nr("table_number (number)",r("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(ms(e,this.locale));return gs((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Od={description:r("Remove non-printable characters from a piece of text."),args:[Nr("text (string)",r("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=Cs(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},Nd={description:r("Appends strings to one another."),args:[Nr("string1 (string, range<string>)",r("The initial string.")),Nr("string2 (string, range<string>, repeating)",r("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Os(e,((e,t)=>e+Cs(t)),"")},isExported:!0},Md={description:r("Tests whether two strings are identical."),args:[Nr("string1 (string)",r("The first string to compare.")),Nr("string2 (string)",r("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return Cs(e)===Cs(t)},isExported:!0},_d={description:r("First position of string found in text, case-sensitive."),args:[Nr("search_for (string)",r("The string to look for within text_to_search.")),Nr("text_to_search (string)",r("The text to search for the first occurrence of search_for.")),Nr("starting_at (number, default=1)",r("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const i=Cs(e),s=Cs(t),n=ms(o,this.locale);gs((()=>""!==s),r("The text_to_search must be non-empty.")),gs((()=>n>=1),r("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const a=s.indexOf(i,n-1);return gs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i.toString(),s)),a+1},isExported:!0},Fd={description:r("Concatenates elements of arrays with delimiter."),args:[Nr("delimiter (string)",r("The character or string to place between each concatenated value.")),Nr("value_or_array1 (string, range<string>)",r("The value or values to be appended using delimiter.")),Nr("value_or_array2 (string, range<string>, repeating)",r("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const o=Cs(e);return Os(t,((e,t)=>(e?e+o:"")+Cs(t)),"")}},Dd={description:r("Substring from beginning of specified string."),args:[Nr("text (string)",r("The string from which the left portion will be returned.")),Nr("number_of_characters (number, optional)",r("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?ms(t[0],this.locale):1;return gs((()=>o>=0),r("The number_of_characters (%s) must be positive or null.",o.toString())),Cs(e).substring(0,o)},isExported:!0},Ld={description:r("Length of a string."),args:[Nr("text (string)",r("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return Cs(e).length},isExported:!0},Pd={description:r("Converts a specified string to lowercase."),args:[Nr("text (string)",r("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return Cs(e).toLowerCase()},isExported:!0},kd={description:r("A segment of a string."),args:[Nr("text (string)",r("The string to extract a segment from.")),Nr(" (number)",r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),Nr(" (number)",r("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,o){const i=Cs(e),s=ms(t,this.locale),n=ms(o,this.locale);return gs((()=>s>=1),r("The starting_at argument (%s) must be positive greater than one.",s.toString())),gs((()=>n>=0),r("The extract_length argument (%s) must be positive or null.",n.toString())),i.slice(s-1,s+n-1)},isExported:!0},Ud={description:r("Capitalizes each word in a specified string."),args:[Nr("text_to_capitalize (string)",r("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return Cs(e).replace(Td,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Vd={description:r("Replaces part of a text string with different text."),args:[Nr("text (string)",r("The text, a part of which will be replaced.")),Nr("position (number)",r("The position where the replacement will begin (starting from 1).")),Nr("length (number)",r("The number of characters in the text to be replaced.")),Nr("new_text (string)",r("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,o,i){const s=ms(t,this.locale);gs((()=>s>=1),r("The position (%s) must be greater than or equal to 1.",s.toString()));const n=Cs(e),a=ms(o,this.locale),l=Cs(i);return n.substring(0,s-1)+l+n.substring(s-1+a)},isExported:!0},zd={description:r("A substring from the end of a specified string."),args:[Nr("text (string)",r("The string from which the right portion will be returned.")),Nr("number_of_characters (number, optional)",r("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?ms(t[0],this.locale):1;gs((()=>o>=0),r("The number_of_characters (%s) must be positive or null.",o.toString()));const i=Cs(e),s=i.length;return i.substring(s-o,s)},isExported:!0},Bd={description:r("First position of string found in text, ignoring case."),args:[Nr("search_for (string)",r("The string to look for within text_to_search.")),Nr("text_to_search (string)",r("The text to search for the first occurrence of search_for.")),Nr("starting_at (number, default=1)",r("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const i=Cs(e).toLowerCase(),s=Cs(t).toLowerCase(),n=ms(o,this.locale);gs((()=>""!==s),r("The text_to_search must be non-empty.")),gs((()=>n>=1),r("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const a=s.indexOf(i,n-1);return gs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i,s)),a+1},isExported:!0},Hd={description:r("Split text by specific character delimiter(s)."),args:[Nr("text (string)",r("The text to divide.")),Nr("delimiter (string)",r("The character or characters to use to split text.")),Nr("split_by_each (boolean, default=true})",r("Whether or not to divide text around each character contained in delimiter.")),Nr("remove_empty_text (boolean, default=true)",r("Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters."))],returns:["RANGE<STRING>"],compute:function(e,t,o=true,i=true){const s=Cs(e),n=ve(Cs(t)),a=ys(o),l=ys(i);gs((()=>n.length>0),r("The _delimiter (%s) must be not be empty.",n));const c=a?new RegExp(`[${n}]`,"g"):new RegExp(n,"g");let h=s.split(c);return l&&(h=h.filter((e=>""!==e))),Qe([h])},isExported:!0},$d={description:r("Replaces existing text with new text in a string."),args:[Nr("text_to_search (string)",r("The text within which to search and replace.")),Nr("search_for (string)",r("The string to search for within text_to_search.")),Nr("replace_with (string)",r("The string that will replace search_for.")),Nr("occurrence_number (number, optional)",r("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],returns:["NUMBER"],compute:function(e,t,o,i){const s=ms(i,this.locale);gs((()=>s>=0),r("The occurrenceNumber (%s) must be positive or null.",s.toString()));const n=Cs(e),a=Cs(t);if(""===a)return n;const l=Cs(o),c=new RegExp(ve(a),"g");if(0===s)return n.replace(c,l);let h=0;return n.replace(c,(e=>++h===s?l:e))},isExported:!0},Wd={description:r("Combines text from multiple strings and/or arrays."),args:[Nr("delimiter (string)",r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),Nr("ignore_empty (boolean)",r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),Nr("text1 (string, range<string>)",r("Any text item. This could be a string, or an array of strings in a range.")),Nr("text2 (string, range<string>, repeating)",r("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...o){const i=Cs(e),s=ys(t);let r=0;return Os(o,((e,t)=>s&&""===Cs(t)?e:(r++?e+i:"")+Cs(t)),"")},isExported:!0},Gd={description:r("Removes space characters."),args:[Nr("text (string)",r("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Cs(e).trim()},isExported:!0},qd={description:r("Converts a specified string to uppercase."),args:[Nr("text (string)",r("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return Cs(e).toUpperCase()},isExported:!0},Zd={description:r("Converts a number to text according to a specified format."),args:[Nr("number (number)",r("The number, date or time to format.")),Nr("format (string)",r("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return vo(ms(e,this.locale),{format:Cs(t),locale:this.locale})},isExported:!0};var jd=Object.freeze({__proto__:null,CHAR:Ad,CLEAN:Od,CONCATENATE:Nd,EXACT:Md,FIND:_d,JOIN:Fd,LEFT:Dd,LEN:Ld,LOWER:Pd,MID:kd,PROPER:Ud,REPLACE:Vd,RIGHT:zd,SEARCH:Bd,SPLIT:Hd,SUBSTITUTE:$d,TEXTJOIN:Wd,TRIM:Gd,UPPER:qd,TEXT:Zd});const Yd={description:r("Creates a hyperlink in a cell."),args:[Nr("url (string)",r("The full URL of the link enclosed in quotation marks.")),Nr("link_label (string, optional)",r("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const o=Cs(e).trim(),i=Cs(t)||o;return""===o?i:Pe(i,o)},isExported:!0};var Xd=Object.freeze({__proto__:null,HYPERLINK:Yd});const Kd=[{name:r("Array"),functions:cn},{name:r("Database"),functions:wl},{name:r("Date"),functions:ic},{name:r("Filter"),functions:lc},{name:r("Financial"),functions:Nh},{name:r("Info"),functions:zh},{name:r("Lookup"),functions:ad},{name:r("Logical"),functions:Yh},{name:r("Math"),functions:ba},{name:r("Misc"),functions:dn},{name:r("Operator"),functions:Rd},{name:r("Statistical"),functions:al},{name:r("Text"),functions:jd},{name:r("Engineering"),functions:rc},{name:r("Web"),functions:Xd}],Qd=/^[A-Z0-9\_\.]+$/;const Jd=new class extends $i{mapping={};add(e,t){if(e=e.toUpperCase(),!Qd.test(e))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=Mr(t);return function(e){let t=!1,o=!1,i=!1;for(let s of e){if(s.type.includes("META")&&s.type.length>1)throw new Error(r("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!s.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||i,n=!(s.optional||s.repeating||s.default);if(e&&n)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=s.repeating,o=s.optional,i=s.default}}(o.args),this.mapping[e]=function(...e){const t=o.compute.bind(this),i=o.computeFormat?o.computeFormat.bind(this):()=>{},s=t(...function(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>e()?.value:e.value}))}(e)),r=i(...e);if(cs(s))return{value:s,format:r};if(!cs(r))return{value:s,format:r};throw new Error("A format matrix should never be associated with a scalar value")},super.add(e,o),this}};for(let e of Kd){const t=e.functions;for(let o in t){const i=t[o];i.category=i.category||e.name,o=o.replace(/_/g,"."),Jd.add(o,{isExported:!1,...i})}}class eu{scope;code="";constructor(e=new ou){this.scope=e}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new tu(this.scope,this.code,e)}toString(){return iu(this.code)}}class tu{scope;returnExpression;code;constructor(e,t,o){this.scope=e,this.returnExpression=o,this.code=iu(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new eu(this.scope);return t.append(`const ${e} = () => {`),t.append(this.code),t.append(`return ${this.returnExpression};`),t.append("}"),t.return(e)}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new eu(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class ou{nextId=1;declaredVariables=new Set;nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function iu(e){let t="",o=0;const i=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of i)e.startsWith("}")&&o--,t+="\t".repeat(o)+e+"\n",e.endsWith("{")&&o++;return t.trim()}const su=Jd.content,ru=["%"],nu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(ru);function au(e,t=oo){e=ot(e);const o=new Su(e),i=[];for(;!o.isOver();){let e=bu(o)||du(o,t)||hu(o)||uu(o)||pu(o)||lu(o)||vu(o)||gu(o,t)||fu(o);e||(e={type:"UNKNOWN",value:o.shift()}),i.push(e)}return i}function lu(e){return"?"===e.current()?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const cu={"(":"LEFT_PAREN",")":"RIGHT_PAREN"};function hu(e){if(e.current()in cu){const t=e.shift();return{type:cu[t],value:t}}return null}function du(e,t){if(e.current()===t.formulaArgSeparator){return{type:"ARG_SEPARATOR",value:e.shift()}}return null}function uu(e){for(let t of nu)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:"OPERATOR",value:t};return null}function gu(e,t){const o=e.remaining().match(io(t.decimalSeparator));return o?(e.advanceBy(o[0].length),{type:"NUMBER",value:o[0]}):null}function pu(e){if('"'===e.current()){const t=e.shift();let o=t;for(;e.current()&&(e.current()!==t||"\\"===o[o.length-1]);)o+=e.shift();return'"'===e.current()&&(o+=e.shift()),{type:"STRING",value:o}}return null}const mu=/\w|\.|!|\$/;function fu(e){let t="";if("'"===e.current()){let o=e.shift();for(t+=o;e.current();)if(o=e.shift(),t+=o,"'"===o){if(!e.current()||"'"!==e.current())break;o=e.shift(),t+=o}if("'"!==o)return{type:"UNKNOWN",value:t}}for(;e.current()&&mu.test(e.current());)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in su)return{type:"FUNCTION",value:e};return qo.test(e)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function bu(e){let t=0;for(;e.current()===pe;)t++,e.shift();if(t)return{type:"SPACE",value:pe.repeat(t)};for(;" "===e.current();)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function vu(e){return e.currentStartsWith(Q)?(e.advanceBy(Q.length),{type:"INVALID_REFERENCE",value:Q}):null}class Su{text;currentIndex=0;constructor(e){this.text=e}current(){return this.text[this.currentIndex]}shift(){return this.text[this.currentIndex++]}advanceBy(e){this.currentIndex+=e}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){for(let t=0;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}}const Cu=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Eu=["-","+"],wu=["%"],yu=["*","+","&"],xu={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Iu(e){const t=e.shift();if(!t)throw new h(he);switch(t.type){case"DEBUGGER":const o=Au(e,1e3);return o.debug=!0,o;case"NUMBER":return{type:"NUMBER",value:ao(t.value,oo)};case"STRING":return{type:"STRING",value:be(t.value)};case"FUNCTION":const i=function(e){Tu(e,"LEFT_PAREN",r("Missing opening parenthesis"));const t=e[0];if("RIGHT_PAREN"===t?.type)return Tu(e,"RIGHT_PAREN"),[];const o=[];o.push(Ru(e));for(;"RIGHT_PAREN"!==e[0]?.type;)Tu(e,"ARG_SEPARATOR",r("Wrong function call")),o.push(Ru(e));return Tu(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:t.value,args:i};case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===e[0]?.value&&"REFERENCE"===e[1]?.type){e.shift();const o=e.shift();return{type:"REFERENCE",value:`${t.value}:${o?.value}`}}return{type:"REFERENCE",value:t.value};case"SYMBOL":if(["TRUE","FALSE"].includes(t.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===t.value.toUpperCase()};if(t.value&&Cu.test(t.value)&&"LEFT_PAREN"===e[0]?.type)throw new p(t.value);throw new h(r("Invalid formula"));case"LEFT_PAREN":const s=Au(e);return Tu(e,"RIGHT_PAREN",r("Missing closing parenthesis")),s;case"OPERATOR":const n=t.value;if(Eu.includes(n))return{type:"UNARY_OPERATION",value:n,operand:Au(e,xu[n])};throw new h(r("Unexpected token: %s",t.value));default:throw new h(r("Unexpected token: %s",t.value))}}function Ru(e){const t=e[0];return"ARG_SEPARATOR"===t?.type||"RIGHT_PAREN"===t?.type?{type:"EMPTY",value:""}:Au(e)}function Tu(e,t,o=he){const i=e.shift();if(!i||i.type!==t)throw new h(o)}function Au(e,t=0){if(0===e.length)throw new h(he);let o=Iu(e);for(;"OPERATOR"===e[0]?.type&&xu[e[0].value]>t;){const t=e.shift().value;if(wu.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:Au(e,xu[t])}}}return o}function Ou(e){return Nu(au(e))}function Nu(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=Au(e);if(e.length)throw new h(he);return t}function Mu(e,t,o){switch(t===e.type&&(e=o(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>Mu(e,t,o)))};case"UNARY_OPERATION":return{...e,operand:Mu(e.operand,t,o)};case"BIN_OPERATION":return{...e,right:Mu(e.right,t,o),left:Mu(e.left,t,o)};default:return e}}function _u(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>_u(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?Fu(e)+e.value:e.value+Du(e);case"BIN_OPERATION":return Fu(e)+e.value+Du(e)}}function Fu(e){const t=e.value,o="left"in e?e.left:e.operand,i=o.value;return"BIN_OPERATION"===o.type&&xu[i]<xu[t]?`(${_u(o)})`:_u(o)}function Du(e){const t=e.value,o="right"in e?e.right:e.operand,i=xu[o.value],s=xu[t];let r=!1;return"BIN_OPERATION"!==o.type?r=!1:i<s?r=!0:i!==s||yu.includes(t)||(r=!0),r?`(${_u(o)})`:_u(o)}var Lu;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(Lu||(Lu={}));const Pu=(e,t=(()=>!0))=>[{goTo:e,guard:t}],ku=(e,t=(()=>!0))=>({goTo:e,guard:t}),Uu={[Lu.LeftRef]:{REFERENCE:Pu(Lu.Separator),NUMBER:Pu(Lu.FullRowSeparator),SYMBOL:[ku(Lu.FullColumnSeparator,(e=>Zo(e.value))),ku(Lu.FullRowSeparator,(e=>jo(e.value)))]},[Lu.FullColumnSeparator]:{SPACE:Pu(Lu.FullColumnSeparator),OPERATOR:Pu(Lu.RightColumnRef,(e=>":"===e.value))},[Lu.FullRowSeparator]:{SPACE:Pu(Lu.FullRowSeparator),OPERATOR:Pu(Lu.RightRowRef,(e=>":"===e.value))},[Lu.Separator]:{SPACE:Pu(Lu.Separator),OPERATOR:Pu(Lu.RightRef,(e=>":"===e.value))},[Lu.RightRef]:{SPACE:Pu(Lu.RightRef),NUMBER:Pu(Lu.Found),REFERENCE:Pu(Lu.Found,(e=>Xo(e.value))),SYMBOL:Pu(Lu.Found,(e=>Yo(e.value)))},[Lu.RightColumnRef]:{SPACE:Pu(Lu.RightColumnRef),SYMBOL:Pu(Lu.Found,(e=>Yo(e.value))),REFERENCE:Pu(Lu.Found,(e=>Xo(e.value)))},[Lu.RightRowRef]:{SPACE:Pu(Lu.RightRowRef),NUMBER:Pu(Lu.Found),REFERENCE:Pu(Lu.Found,(e=>Xo(e.value)))},[Lu.Found]:{}};function Vu(e){let t=0,o=Uu[Lu.LeftRef];const i=[];for(;void 0!==o;){const s=e[t++];if(!s)return null;const r=o[s.type]?.find((e=>e.guard(s))),n=r?r.goTo:void 0;switch(n){case void 0:return null;case Lu.Found:return i.push(s),e.splice(0,t),{type:"REFERENCE",value:Ge(i.map((e=>e.value)))};default:o=Uu[n],i.push(s)}}return null}function zu(e,t=oo){const o=au(e,t),i=[];for(;o.length;)i.push(Vu(o)||o.shift());return i}const Bu=Jd.content,Hu={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},$u={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},Wu={};function Gu(e){const t=zu(e),{dependencies:o,constantValues:i}=function(e){const t={numbers:[],strings:[]},o=[];for(const i of e)switch(i.type){case"INVALID_REFERENCE":case"REFERENCE":o.push(i.value);break;case"STRING":const e=be(i.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=ao(i.value,oo);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:o,constantValues:t}}(t),s=function(e,t,o){return Ge(e.map((e=>{switch(e.type){case"STRING":const i=be(e.value);return`|S${o.strings.indexOf(i)}|`;case"NUMBER":return`|N${o.numbers.indexOf(ao(e.value,oo))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,o,i);if(!Wu[s]){const n=Nu([...t]),a=new ou;if("BIN_OPERATION"===n.type&&":"===n.value)throw new h(r("Invalid formula"));if("EMPTY"===n.type)throw new h(r("Invalid formula"));const l=g(n),c=new eu;c.append(`// ${s}`),c.append(l),c.append(`return ${l.returnExpression};`);let d=new Function("deps","ref","range","ctx",c.toString());function u(e){const{args:t}=e,o=e.value.toUpperCase(),i=Bu[o];!function(e){const t=e.args.length,o=e.value.toUpperCase(),i=Bu[o];if(t<i.minArgRequired)throw new h(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",o,i.minArgRequired.toString(),t.toString()));if(t>i.maxArgPossible)throw new h(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",o,i.maxArgPossible.toString(),t.toString()));const s=i.nbrArgRepeating;if(s>1){const e=i.args.length-s;if((t-e)%s!=0)throw new h(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",o,e.toString(),s.toString()))}}(e);const s=[];for(let e=0;e<t.length;e++){const n=i.getArgToFocus(e+1)-1,a=i.args[n],l=t[e],c=a.type||[],d=c.includes("META"),u=a.lazy,p=c.some((e=>qu(e))),m=c.every((e=>qu(e)));if(m&&!Zu(l))throw new h(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",o,(e+1).toString(),l.type.toLowerCase()));const f=g(l,d,p,{functionName:o,paramIndex:e+1});s.push(u?f.wrapInClosure():f)}return s}function g(e,t=!1,s=!1,n={}){const l=new eu(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new h(r("Argument must be a reference to a cell or range."));switch(e.debug&&l.append("debugger;"),e.type){case"BOOLEAN":return l.return(`{ value: ${e.value} }`);case"NUMBER":return l.return(`{ value: this.constantValues.numbers[${i.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${i.strings.indexOf(e.value)}] }`);case"REFERENCE":const r=o.indexOf(e.value);return s?l.return(`range(deps[${r}])`):l.return(`ref(deps[${r}], ${t?"true":"false"}, "${n.functionName||Hu["="]}", ${n.paramIndex})`);case"FUNCALL":const a=u(e).map((e=>e.assignResultToVariable()));l.append(...a);const c=e.value.toUpperCase();return l.append(`ctx.__lastFnCalled = '${c}';`),l.return(`ctx['${c}'](${a.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=$u[e.value],o=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${o.returnExpression})`)}case"BIN_OPERATION":{const t=Hu[e.value],o=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),i=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(o),l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${o.returnExpression}, ${i.returnExpression})`)}case"EMPTY":return l.return("undefined")}}Wu[s]={execute:d}}return{execute:Wu[s].execute,dependencies:o,constantValues:i,tokens:t}}function qu(e){return e.startsWith("RANGE")}function Zu(e){if("REFERENCE"===e.type)return!0;if("FUNCALL"===e.type){const t=Bu[e.value.toUpperCase()];return t&&qu(t.returns[0])}return!1}function ju(e,t){return function(e){let t=[],o="";return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"FUNCTION":o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0}),o="";break;case"RIGHT_PAREN":t.pop();break;case"ARG_SEPARATOR":t.length&&t[t.length-1].argPosition++}if(t.length){const o=t[t.length-1];o.parent&&(e.functionContext=Object.assign({},o))}return e}))}(function(e){let t=1;const o=[];return e.map((e=>("LEFT_PAREN"===e.type?(o.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=o.pop()),e)))}(function(e){let t=0;return e.map((e=>{const o=e.value.toString().length,i=Object.assign({},e,{start:t,end:t+o,length:o});return t=i.end,i}))}(zu(e,t))))}function Yu(e){if(!e||"object"!=typeof e||"string"!=typeof e.name||"string"!=typeof e.code||"string"!=typeof e.thousandsSeparator||"string"!=typeof e.decimalSeparator||"string"!=typeof e.dateFormat||"string"!=typeof e.timeFormat||"string"!=typeof e.formulaArgSeparator)return!1;if(!Object.values(e).every((e=>e)))return!1;if(e.formulaArgSeparator===e.decimalSeparator)return!1;try{vo(1,{locale:e,format:"#,##0.00"}),vo(1,{locale:e,format:e.dateFormat}),vo(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function Xu(e,t){return e.startsWith("=")?function(e,t){return Ju(e,t,oo)}(e,t):eg(e,t)}function Ku(e,t){return e.startsWith("=")?Qu(e,t):function(e,t){if("."===t.decimalSeparator||!ro(e,oo))return e;const o=No(oo),i=e.replace(o,(e=>e.replace(".",t.decimalSeparator)));return i}(e,t)}function Qu(e,t){return Ju(e,oo,t)}function Ju(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const i=au(e,t);let s="";for(const e of i)"NUMBER"===e.type?s+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?s+=o.formulaArgSeparator:s+=e.value;return s}function eg(e,t){return"."!==t.decimalSeparator&&ro(e,t)?e.replace(t.decimalSeparator,"."):e}function tg(e,t){return ig(e,(e=>Xu(e,t)))}function og(e,t){return ig(e,(e=>Ku(e,t)))}function ig(e,t){switch((e=Se(e)).type){case"CellIsRule":switch(e.operator){case"Between":case"NotBetween":case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return e.values=e.values.map((e=>t(e))),e;case"BeginsWith":case"ContainsText":case"EndsWith":case"NotContains":case"IsEmpty":case"IsNotEmpty":return e}break;case"ColorScaleRule":return e.minimum=sg(e.minimum,t),e.maximum=sg(e.maximum,t),e.midpoint&&(e.midpoint=sg(e.midpoint,t)),e;case"IconSetRule":return e.lowerInflectionPoint.value=t(e.lowerInflectionPoint.value),e.upperInflectionPoint.value=t(e.upperInflectionPoint.value),e}}function sg(e,t){if(!e?.value)return e;const o=t("formula"===e.type?"="+e.value:e.value),i="formula"===e.type?o.slice(1):o;return{...e,value:i}}const rg={name:r("Link sheet"),children:[e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map((e=>({id:e.id,name:e.name,execute:()=>Pe(e.name,ze(e.id))})))]},ng={name:r("Delete"),isVisible:e=>e.model.getters.getSheetIds().length>1,execute:e=>e.askConfirmation(r("Are you sure you want to delete this sheet?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))},ag={name:r("Duplicate"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}},lg=e=>({name:r("Rename"),execute:e.renameSheetCallback}),cg={name:r("Move right"),isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getVisibleSheetIds();return o.indexOf(t)!==o.length-1},execute:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:1})},hg={name:r("Move left"),isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},execute:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:-1})},dg={name:r("Hide sheet"),isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,execute:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})};function ug(e){return e.map(pg).sort(((e,t)=>e.sequence-t.sequence))}const gg=new Ni;function pg(e){const t=e.name,o=e.children;return{id:e.id||gg.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,isActive:e.isActive,execute:e.execute,children:o?e=>o.map((t=>"function"==typeof t?t(e):t)).flat().map(pg):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon||"",description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class mg extends $i{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,o){"function"!=typeof o&&void 0===o.id&&(o.id=e);const i=t.splice(0,1)[0];let s=this.content[i];if(!s)throw new Error(`Path ${i+":"+t.join(":")} not found`);for(let e of t){const o=s.children;if(!o||"function"==typeof o)throw new Error(`${e} is either not a node or it's dynamically computed`);if(s=o.find((t=>t.id===e)),!s)throw new Error(`Path ${i+":"+t.join(":")} not found`)}return s.children||(s.children=[]),s.children.push(o),this}getMenuItems(){return ug(this.getAll())}}const fg=new mg;fg.add("sheet",{...rg,sequence:10});Di`
273
+ `;class Rr extends t.Component{static components={Menu:Ir};static template="o-spreadsheet-LinkDisplay";get cell(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;const{col:e,row:t}=this.props.cellPosition;throw new Error(`LinkDisplay Component can only be used with link cells. ${Tt(e,t)} is not a link.`)}getUrlRepresentation(e){return Yi(e,this.env.model.getters)}openLink(){Xi(this.link,this.env)}edit(){const{col:e,row:t}=this.props.cellPosition;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:e,row:t,popoverType:"LinkEditor"})}unlink(){const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.props.cellPosition,i=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:o}),s=i?.textColor===I?void 0:i?.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:o,sheetId:e,content:this.link.label,style:{...i,textColor:s,underline:void 0}})}}const Tr={onHover:(e,t)=>{const o=t.getEvaluatedCell(e);return!t.isDashboard()&&o.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:Rr,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}};Rr.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Ar=/(.*?)\((.*?)\)(.*)/,Or=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function Nr(e,t=""){return function(e,t){let o,i=e.match(Ar),s=i[1].trim(),r=[],n=!1,a=!1,l=!1;for(let e of i[2].split(",")){const t=e.trim().toUpperCase();let i=Or.find((e=>t===e));i?r.push(i):"RANGE<ANY>"===t?r.push("RANGE"):"OPTIONAL"===t?n=!0:"REPEATING"===t?a=!0:"LAZY"===t?l=!0:t.startsWith("DEFAULT=")&&(o=e.trim().slice(8))}const c={name:s,description:t,type:r};n&&(c.optional=!0);a&&(c.repeating=!0);l&&(c.lazy=!0);void 0!==o&&(c.default=!0,c.defaultValue=o);return c}(e,t)}function Mr(e){let t=0,o=0,i=0;for(let s of e.args)t++,s.optional||s.repeating||s.default||o++,s.repeating&&i++;const s=e;return s.minArgRequired=o,s.maxArgPossible=i?1/0:t,s.nbrArgRepeating=i,s.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,i),s.hidden=e.hidden||!1,s}function _r(e,t){gs((()=>1===t.length||1===t[0].length),e)}function Fr(e,...t){if(t.every(cs)){const o=t[0].length,i=t[0][0].length;for(const s of t)gs((()=>s.length===o&&s[0].length===i),e)}else if(t.some((e=>Array.isArray(e)&&(1!==e.length||1!==e[0].length))))throw new Error(e)}function Dr(e,t){gs((()=>t>0),e)}function Lr(e,t){gs((()=>t.length===t[0].length),e)}function Pr(e){return e.every((e=>e.every((e=>"number"==typeof e))))}function kr(e){const t=Array(e);for(let o=0;o<e;o++)t[o]=Array(e).fill(0),t[o][o]=1;return t}function Ur(e){if(e.length!==e[0].length)throw new Error("Function [[FUNCTION_NAME]] invert matrix error, only square matrices are invertible");let t=1;const o=e.length,i=kr(o),s=e.map((e=>e.slice()));for(let e=0;e<o;e++){let r=s[e][e];if(0==r){for(let r=e+1;r<o;r++)if(0!=s[e][r]){Vr(s,e,r),Vr(i,e,r),t*=-1;break}if(r=s[e][e],0===r)return{determinant:0}}for(let t=0;t<o;t++)s[t][e]=s[t][e]/r,i[t][e]=i[t][e]/r;t*=r;for(let t=0;t<o;t++){if(t==e)continue;const r=s[e][t];for(let n=0;n<o;n++)s[n][t]-=r*s[n][e],i[n][t]-=r*i[n][e]}}return{inverted:i,determinant:t}}function Vr(e,t,o){for(let i=0;i<e.length;i++){const s=e[i][t];e[i][t]=e[i][o],e[i][o]=s}}const zr={description:r("Returns a result array constrained to a specific width and height."),args:[Nr("input_range (any, range<any>)",r("The range to constrain.")),Nr("rows (number)",r("The number of rows in the constrained array.")),Nr("columns (number)",r("The number of columns in the constrained array."))],returns:["RANGE<ANY>"],compute:function(e,t,o){const i=$s(e),s=bs(t,this.locale),n=bs(o,this.locale);Dr(r("The rows argument (%s) must be strictly positive.",s.toString()),s),Dr(r("The columns argument (%s) must be strictly positive.",s.toString()),n);const a=Math.min(s,i[0].length),l=Math.min(n,i.length),c=Array(l);for(let e=0;e<l;e++){c[e]=Array(a);for(let t=0;t<a;t++)c[e][t]=Hs(i[e][t])}return c},isExported:!1},Br={description:r("Creates a new array from the selected columns in the existing range."),args:[Nr("array (any, range<any>)",r("The array that contains the columns to be returned.")),Nr("col_num (number, range<number>)",r("The first column index of the columns to be returned.")),Nr("col_num2 (number, range<number>, repeating)",r("The columns indexes of the columns to be returned."))],returns:["RANGE<ANY>"],compute:function(e,...t){const o=$s(e),i=Ws(t,(e=>bs(e,this.locale)));gs((()=>i.every((e=>e>0&&e<=o.length))),r("The columns arguments must be between 1 and %s (got %s).",o.length.toString(),(i.find((e=>e<=0||e>o.length))||0).toString()));const s=Array(i.length);for(let e=0;e<i.length;e++){const t=i[e]-1;s[e]=o[t]}return Bs(s)},isExported:!0},Hr={description:r("Creates a new array from the selected rows in the existing range."),args:[Nr("array (any, range<any>)",r("The array that contains the rows to be returned.")),Nr("row_num (number, range<number>)",r("The first row index of the rows to be returned.")),Nr("row_num2 (number, range<number>, repeating)",r("The rows indexes of the rows to be returned."))],returns:["RANGE<ANY>"],compute:function(e,...t){const o=$s(e),i=Ws(t,(e=>bs(e,this.locale)));gs((()=>i.every((e=>e>0&&e<=o[0].length))),r("The rows arguments must be between 1 and %s (got %s).",o[0].length.toString(),(i.find((e=>e<=0||e>o[0].length))||0).toString()));const s=Array(o.length);for(let e=0;e<o.length;e++){s[e]=Array(i.length);for(let t=0;t<i.length;t++){const r=i[t]-1;s[e][t]=Hs(o[e][r])}}return s},isExported:!0},$r={description:r("Expands or pads an array to specified row and column dimensions."),args:[Nr("array (any, range<any>)",r("The array to expand.")),Nr("rows (number)",r("The number of rows in the expanded array. If missing, rows will not be expanded.")),Nr("columns (number, optional)",r("The number of columns in the expanded array. If missing, columns will not be expanded.")),Nr("pad_with (any, default=0)",r("The value with which to pad."))],returns:["RANGE<ANY>"],compute:function(e,t,o,i=0){const s=$s(e),n=bs(t,this.locale),a=void 0!==o?bs(o,this.locale):s.length,l=null!=i?i:0;gs((()=>n>=s[0].length),r("The rows arguments (%s) must be greater or equal than the number of rows of the array.",n.toString())),gs((()=>a>=s.length),r("The columns arguments (%s) must be greater or equal than the number of columns of the array.",a.toString()));const c=[];for(let e=0;e<a;e++){c[e]=[];for(let t=0;t<n;t++)e>=s.length||t>=s[e].length?c[e][t]=l:c[e][t]=s[e][t]??0}return c},isExported:!0},Wr={description:r("Flattens all the values from one or more ranges into a single column."),args:[Nr("range (any, range<any>)",r("The first range to flatten.")),Nr("range2 (any, range<any>, repeating)",r("Additional ranges to flatten."))],returns:["RANGE<ANY>"],compute:function(...e){return[Ws(e,Hs)]},isExported:!1},Gr={description:r("Calculates the frequency distribution of a range."),args:[Nr("data (range<number>)",r("The array of ranges containing the values to be counted.")),Nr("classes (number, range<number>)",r("The range containing the set of classes."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=Ws([e],(e=>e)).filter((e=>"number"==typeof e)),i=Ws([t],(e=>e)).filter((e=>"number"==typeof e)).map(((e,t)=>({initialIndex:t,value:e,count:0}))).sort(((e,t)=>e.value-t.value));i.push({initialIndex:i.length,value:1/0,count:0});const s=o.sort(((e,t)=>e-t));let r=0;for(const e of s){for(;e>i[r].value&&r<i.length-1;)r++;i[r].count++}return[i.sort(((e,t)=>e.initialIndex-t.initialIndex)).map((e=>e.count))]},isExported:!0},qr={description:r("Appends ranges horizontally and in sequence to return a larger array."),args:[Nr("range1 (any, range<any>)",r("The first range to be appended.")),Nr("range2 (any, range<any>, repeating)",r("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],compute:function(...e){const t=e.map((e=>$s(e))),o=Math.max(...t.map((e=>e[0].length))),i=[];for(const e of t)for(const t of e){const e=Array(o).fill(0);for(let o=0;o<t.length;o++)e[o]=Hs(t[o]);i.push(e)}return i},isExported:!0},Zr={description:r("Returns the matrix determinant of a square matrix."),args:[Nr("square_matrix (number, range<number>)",r("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],returns:["NUMBER"],compute:function(e){const t=$s(e);if(Lr(r("The argument square_matrix must have the same number of columns and rows."),t),!Pr(t))throw new Error(r("The argument square_matrix must be a matrix of numbers."));const{determinant:o}=Ur(t);return o},isExported:!0},jr={description:r("Returns the multiplicative inverse of a square matrix."),args:[Nr("square_matrix (number, range<number>)",r("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=$s(e);if(Lr(r("The argument square_matrix must have the same number of columns and rows."),t),!Pr(t))throw new Error(r("The argument square_matrix must be a matrix of numbers."));const{inverted:o}=Ur(t);if(!o)throw new Error(r("The matrix is not invertible."));return o},isExported:!0},Yr={description:r("Calculates the matrix product of two matrices."),args:[Nr("matrix1 (number, range<number>)",r("The first matrix in the matrix multiplication operation.")),Nr("matrix2 (number, range<number>)",r("The second matrix in the matrix multiplication operation."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=$s(e),i=$s(t);if(gs((()=>o.length===i[0].length),r("In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).",o.length.toString(),i[0].length.toString())),!Pr(o)||!Pr(i))throw new Error(r("The arguments matrix1 and matrix2 must be matrices of numbers."));return function(e,t){if(e.length!==t[0].length)throw new Error(r("Cannot multiply matrices : incompatible matrices size."));const o=e[0].length,i=t.length,s=e.length,n=Array(i);for(let r=0;r<i;r++){n[r]=Array(o);for(let i=0;i<o;i++){let o=0;for(let n=0;n<s;n++)o+=e[n][i]*t[r][n];n[r][i]=o}}return n}(o,i)},isExported:!0},Xr={description:r("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[Nr("range1 (number, range<number>)",r("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),Nr("range2 (number, range<number>, repeating)",r("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],returns:["NUMBER"],compute:function(...e){Fr(r("All the ranges must have the same dimensions."),...e);const t=e.map($s);let o=0;for(let e=0;e<t[0].length;e++)for(let i=0;i<t[0][e].length;i++){if(!t.every((t=>"number"==typeof t[e][i])))continue;let s=1;for(const o of t)s*=ms(o[e][i],this.locale);o+=s}return o},isExported:!0};function Kr(e,t,o){Fr("The arguments array_x and array_y must have the same dimensions.",e,t);const i=$s(e),s=$s(t);let r=!1,n=0;for(const e in i)for(const t in i[e]){const a=i[e][t],l=s[e][t];"number"==typeof a&&"number"==typeof l&&(r=!0,n+=o(a,l))}if(!r)throw new Error("The arguments array_x and array_y must contain at least one pair of numbers.");return n}const Qr={description:r("Calculates the sum of the difference of the squares of the values in two array."),args:[Nr("array_x (number, range<number>)",r("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),Nr("array_y (number, range<number>)",r("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return Kr(e,t,((e,t)=>e**2-t**2))},isExported:!0},Jr={description:r("Calculates the sum of the sum of the squares of the values in two array."),args:[Nr("array_x (number, range<number>)",r("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),Nr("array_y (number, range<number>)",r("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return Kr(e,t,((e,t)=>e**2+t**2))},isExported:!0},en={description:r("Calculates the sum of squares of the differences of values in two array."),args:[Nr("array_x (number, range<number>)",r("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),Nr("array_y (number, range<number>)",r("The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together."))],returns:["NUMBER"],compute:function(e,t){return Kr(e,t,((e,t)=>(e-t)**2))},isExported:!0},tn=[Nr("array (any, range<any>)",r("The array which will be transformed.")),Nr("ignore (number, default=0)",r("The control to ignore blanks and errors. 0 (default) is to keep all values, 1 is to ignore blanks, 2 is to ignore errors, and 3 is to ignore blanks and errors.")),Nr("scan_by_column (number, default=false)",r("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))],on={description:r("Transforms a range of cells into a single column."),args:tn,returns:["RANGE<ANY>"],compute:function(e,t=0,o=false){const i=$s(e),s=bs(t,this.locale),n=ys(o);gs((()=>s>=0&&s<=3),r("Argument ignore must be between 0 and 3"));const a=Os([i],((e,t)=>1!==s&&3!==s||null!=t?(e.push(Hs(t)),e):e),[],n?"colFirst":"rowFirst");if(0===a.length)throw new g(r("No results for the given arguments of TOCOL."));return[a]},isExported:!0},sn={description:r("Transforms a range of cells into a single row."),args:tn,returns:["RANGE<ANY>"],compute:function(e,t=0,o=false){const i=$s(e),s=bs(t,this.locale),n=ys(o);gs((()=>s>=0&&s<=3),r("Argument ignore must be between 0 and 3"));const a=Os([i],((e,t)=>1!==s&&3!==s||null!=t?(e.push([Hs(t)]),e):e),[],n?"colFirst":"rowFirst");if(0===a.length||0===a[0].length)throw new g(r("No results for the given arguments of TOROW."));return a},isExported:!0},rn={description:r("Transposes the rows and columns of a range."),args:[Nr("range (any, range<any>)",r("The range to be transposed."))],returns:["RANGE<ANY>"],computeFormat:e=>{if(e.format)return cs(e.format)?Qe(e.format):e.format},compute:function(e){return Qe($s(e),Hs)},isExported:!0},nn={description:r("Appends ranges vertically and in sequence to return a larger array."),args:[Nr("range1 (any, range<any>)",r("The first range to be appended.")),Nr("range2 (any, range<any>, repeating)",r("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],compute:function(...e){const t=e.map((e=>$s(e))),o=Math.max(...t.map((e=>e.length))),i=t.reduce(((e,t)=>e+t[0].length),0),s=Array(o).fill([]).map((()=>Array(i).fill(0)));let r=0;for(const e of t){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++)s[t][r+o]=Hs(e[t][o]);r+=e[0].length}return s},isExported:!0},an={description:r("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[Nr("range (any, range<any>)",r("The range to wrap.")),Nr("wrap_count (number)",r("The maximum number of cells for each column, rounded down to the nearest whole number.")),Nr("pad_with (any, default=0)",r("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],compute:function(e,t,o=0){const i=$s(e),s=bs(t,this.locale),n=null===o?0:o;_r(r("Argument range must be a single row or column."),i);const a=i.flat(),l=Math.ceil(a.length/s),c=Array(l);for(let e=0;e<l;e++){c[e]=Array(s).fill(n);for(let t=0;t<s;t++){const o=e*s+t;o<a.length&&(c[e][t]=Hs(a[o]))}}return c},isExported:!0},ln={description:r("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[Nr("range (any, range<any>)",r("The range to wrap.")),Nr("wrap_count (number)",r("The maximum number of cells for each row, rounded down to the nearest whole number.")),Nr("pad_with (any, default=0)",r("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],compute:function(e,t,o=0){const i=$s(e),s=bs(t,this.locale),n=null===o?0:o;_r(r("Argument range must be a single row or column."),i);const a=i.flat(),l=Math.ceil(a.length/s),c=Array(s).fill([]).map((()=>Array(l).fill(n)));for(let e=0;e<l;e++)for(let t=0;t<s;t++){const o=e*s+t;o<a.length&&(c[t][e]=Hs(a[o]))}return c},isExported:!0};var cn=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:zr,CHOOSECOLS:Br,CHOOSEROWS:Hr,EXPAND:$r,FLATTEN:Wr,FREQUENCY:Gr,HSTACK:qr,MDETERM:Zr,MINVERSE:jr,MMULT:Yr,SUMPRODUCT:Xr,SUMX2MY2:Qr,SUMX2PY2:Jr,SUMXMY2:en,TOCOL:on,TOROW:sn,TRANSPOSE:rn,VSTACK:nn,WRAPCOLS:an,WRAPROWS:ln});const hn={description:r("Apply a large number format"),args:[Nr("value (number)",r("The number.")),Nr("unit (string, optional)",r("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:function(e,t){const o=Math.abs(ms(e.value,this.locale)),i=e.format;if(void 0!==t){const e=t?.value;switch(e){case"k":return Do(i,1e3,"k",this.locale);case"m":return Do(i,1e6,"m",this.locale);case"b":return Do(i,1e9,"b",this.locale);default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return o<1e5?Do(i,0,"",this.locale):o<1e8?Do(i,1e3,"k",this.locale):o<1e11?Do(i,1e6,"m",this.locale):Do(i,1e9,"b",this.locale)},compute:function(e){return ms(e,this.locale)}};var dn=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:hn});const un=/^-?[a-z0-9]+$/i,gn={description:r("Absolute value of a number."),args:[Nr("value (number)",r("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(ms(e,this.locale))},isExported:!0},pn={description:r("Inverse cosine of a value, in radians."),args:[Nr("value (number)",r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},mn={description:r("Inverse hyperbolic cosine of a number."),args:[Nr("value (number)",r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},fn={description:r("Inverse cotangent of a value."),args:[Nr("value (number)",r("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},bn={description:r("Inverse hyperbolic cotangent of a value."),args:[Nr("value (number)",r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>Math.abs(t)>1),r("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},vn={description:r("Inverse sine of a value, in radians."),args:[Nr("value (number)",r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Sn={description:r("Inverse hyperbolic sine of a number."),args:[Nr("value (number)",r("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(ms(e,this.locale))},isExported:!0},Cn={description:r("Inverse tangent of a value, in radians."),args:[Nr("value (number)",r("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(ms(e,this.locale))},isExported:!0},En={description:r("Angle from the X axis to a point (x,y), in radians."),args:[Nr("x (number)",r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),Nr("y (number)",r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=ms(t,this.locale);return gs((()=>0!==o||0!==i),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(i,o)},isExported:!0},wn={description:r("Inverse hyperbolic tangent of a number."),args:[Nr("value (number)",r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},yn={description:r("Rounds number up to nearest multiple of factor."),args:[Nr("value (number)",r("The value to round up to the nearest integer multiple of factor.")),Nr("factor (number, default=1)",r("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){const o=ms(e,this.locale),i=ms(t,this.locale);return gs((()=>i>=0||o<=0),r("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),o.toString())),i?Math.ceil(o/i)*i:0},isExported:!0},xn={description:r("Rounds number up to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round up to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),Nr("mode (number, default=0)",r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1,o=0){let i=ms(t,this.locale);if(0===i)return 0;const s=ms(e,this.locale);if(i=Math.abs(i),s>=0)return Math.ceil(s/i)*i;return 0===ms(o,this.locale)?-Math.floor(Math.abs(s)/i)*i:-Math.ceil(Math.abs(s)/i)*i},isExported:!0},In={description:r("Rounds number up to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round up to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){return xn.compute.bind(this)(e,t,0)},isExported:!0},Rn={description:r("Cosine of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(ms(e,this.locale))},isExported:!0},Tn={description:r("Hyperbolic cosine of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(ms(e,this.locale))},isExported:!0},An={description:r("Cotangent of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},On={description:r("Hyperbolic cotangent of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Nn={description:r("Number of empty values."),args:[Nr("value1 (any, range)",r("The first value or range in which to count the number of blanks.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Os(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Mn={description:r("A conditional count across a range."),args:[Nr("range (range)",r("The range that is tested against criterion.")),Nr("criterion (string)",r("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return Ls(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},_n={description:r("Count values depending on multiple criteria."),args:[Nr("criteria_range1 (range)",r("The range to check against criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Nr("criterion2 (string, repeating)",r("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return Ls(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0};function Fn(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Dn={description:r("Counts number of unique values in a range."),args:[Nr("value1 (any, range)",r("The first value or range to consider for uniqueness.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Os(e,((e,t)=>Fn(t)?e.add(t):e),new Set).size}},Ln={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:[Nr("range (range)",r("The range of cells from which the number of unique values will be counted.")),Nr("criteria_range1 (range)",r("The range of cells over which to evaluate criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Nr("criterion2 (string, repeating)",r("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=new Set;return Ls(t,((t,i)=>{const s=e[t][i];Fn(s)&&o.add(s)}),this.locale),o.size}},Pn={description:r("Cosecant of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},kn={description:r("Hyperbolic cosecant of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Un={description:r("Converts from another base to decimal."),args:[Nr("value (string)",r("The number to convert.")),Nr(",base (number)",r("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let o=ms(t,this.locale);o=Math.floor(o),gs((()=>2<=o&&o<=36),r("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const i=Cs(e);if(""===i)return 0;gs((()=>!!un.test(i)),r("The value (%s) must be a valid base %s representation.",i,o.toString()));const s=parseInt(i,o);return gs((()=>!isNaN(s)),r("The value (%s) must be a valid base %s representation.",i,o.toString())),s},isExported:!0},Vn={description:r("Converts an angle value in radians to degrees."),args:[Nr("angle (number)",r("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*ms(e,this.locale)/Math.PI},isExported:!0},zn={description:r("Euler's number, e (~2.718) raised to a power."),args:[Nr("value (number)",r("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(ms(e,this.locale))},isExported:!0},Bn={description:r("Rounds number down to nearest multiple of factor."),args:[Nr("value (number)",r("The value to round down to the nearest integer multiple of factor.")),Nr("factor (number, default=1)",r("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){const o=ms(e,this.locale),i=ms(t,this.locale);return gs((()=>i>=0||o<=0),r("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),o.toString())),i?Math.floor(o/i)*i:0},isExported:!0},Hn={description:r("Rounds number down to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round down to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),Nr("mode (number, default=0)",r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1,o=0){let i=ms(t,this.locale);if(0===i)return 0;const s=ms(e,this.locale);if(i=Math.abs(i),s>=0)return Math.floor(s/i)*i;return 0===ms(o,this.locale)?-Math.ceil(Math.abs(s)/i)*i:-Math.floor(Math.abs(s)/i)*i},isExported:!0},$n={description:r("Rounds number down to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round down to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){return Hn.compute.bind(this)(e,t,0)},isExported:!0},Wn={description:r("Whether the provided value is even."),args:[Nr("value (number)",r("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=fs(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Gn={description:r("Rounds number up to nearest multiple of factor."),args:[Nr("number (number)",r("The value to round up to the nearest integer multiple of significance.")),Nr("significance (number, default=1)",r("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){return xn.compute.bind(this)(e,t,0)},isExported:!0},qn={description:r("Whether the provided value is even."),args:[Nr("value (number)",r("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=fs(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Zn={description:r("The logarithm of a number, base e (euler's number)."),args:[Nr("value (number)",r("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=ms(e,this.locale);return gs((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},jn={description:r("Modulo (remainder) operator."),args:[Nr("dividend (number)",r("The number to be divided to find the remainder.")),Nr("divisor (number)",r("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){const o=ms(t,this.locale);gs((()=>0!==o),r("The divisor must be different from 0."));const i=ms(e,this.locale)%o;return i>0&&o<0||i<0&&o>0?i+o:i},isExported:!0},Yn={description:r("Returns a n x n unit matrix, where n is the input dimension."),args:[Nr("dimension (number)",r("An integer specifying the dimension size of the unit matrix. It must be positive."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=bs(e,this.locale);return Dr(r("The argument dimension must be positive"),t),kr(t)},isExported:!0},Xn={description:r("Rounds a number up to the nearest odd integer."),args:[Nr("value (number)",r("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e){const t=ms(e,this.locale);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,t<0?-o:o},isExported:!0},Kn={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Qn={description:r("A number raised to a power."),args:[Nr("base (number)",r("The number to raise to the exponent power.")),Nr("exponent (number)",r("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){const o=ms(e,this.locale),i=ms(t,this.locale);return gs((()=>o>=0||Number.isInteger(i)),r("The exponent (%s) must be an integer when the base is negative.",i.toString())),Math.pow(o,i)},isExported:!0},Jn={description:r("Result of multiplying a series of numbers together."),args:[Nr("factor1 (number, range<number>)",r("The first number or range to calculate for the product.")),Nr("factor2 (number, range<number>, repeating)",r("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t=0,o=1;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(o*=i,t+=1);else null!=i&&(o*=fs(i,this.locale),t+=1);return 0===t?0:o},isExported:!0},ea={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},ta={description:r("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[Nr("rows (number, default=1)",r("The number of rows to be returned.")),Nr("columns (number, default=1)",r("The number of columns to be returned.")),Nr("min (number, default=0)",r("The minimum number you would like returned.")),Nr("max (number, default=1)",r("The maximum number you would like returned.")),Nr("whole_number (number, default=FALSE)",r("Return a whole number or a decimal value."))],returns:["RANGE<NUMBER>"],compute:function(e=1,t=1,o=0,i=1,s=!1){const n=bs(t,this.locale),a=bs(e,this.locale),l=ms(o,this.locale),c=ms(i,this.locale),h=ys(s);Dr(r("The number columns (%s) must be positive.",n.toString()),n),Dr(r("The number rows (%s) must be positive.",a.toString()),a),gs((()=>l<=c),r("The maximum (%s) must be greater than or equal to the minimum (%s).",c.toString(),l.toString())),h&&gs((()=>Number.isInteger(l)&&Number.isInteger(c)),r("The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.",c.toString(),l.toString()));const d=Array(n);for(let e=0;e<n;e++){d[e]=Array(a);for(let t=0;t<a;t++)d[e][t]=h?Math.floor(Math.random()*(c-l+1)+l):l+Math.random()*(c-l)}return d},isExported:!0},oa={description:r("Random integer between two values, inclusive."),args:[Nr("low (number)",r("The low end of the random range.")),Nr("high (number)",r("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){let o=ms(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let i=ms(t,this.locale);return Number.isInteger(i)||(i=Math.floor(i)),gs((()=>o<=i),r("The high (%s) must be greater than or equal to the low (%s).",i.toString(),o.toString())),o+Math.ceil((i-o+1)*Math.random())-1},isExported:!0},ia={description:r("Rounds a number according to standard rules."),args:[Nr("value (number)",r("The value to round to places number of places.")),Nr("places (number, default=0)",r("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=ms(e,this.locale);let i=ms(t,this.locale);const s=Math.abs(o);let r;return 0===i?r=Math.round(s):(Number.isInteger(i)||(i=Math.trunc(i)),r=Math.round(s*Math.pow(10,i))/Math.pow(10,i)),o>=0?r:-r},isExported:!0},sa={description:r("Rounds down a number."),args:[Nr("value (number)",r("The value to round to places number of places, always rounding down.")),Nr("places (number, default=0)",r("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=ms(e,this.locale);let i=ms(t,this.locale);const s=Math.abs(o);let r;return 0===i?r=Math.floor(s):(Number.isInteger(i)||(i=Math.trunc(i)),r=Math.floor(s*Math.pow(10,i))/Math.pow(10,i)),o>=0?r:-r},isExported:!0},ra={description:r("Rounds up a number."),args:[Nr("value (number)",r("The value to round to places number of places, always rounding up.")),Nr("places (number, default=0)",r("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=ms(e,this.locale);let i=ms(t,this.locale);const s=Math.abs(o);let r;return 0===i?r=Math.ceil(s):(Number.isInteger(i)||(i=Math.trunc(i)),r=Math.ceil(s*Math.pow(10,i))/Math.pow(10,i)),o>=0?r:-r},isExported:!0},na={description:r("Secant of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(ms(e,this.locale))},isExported:!0},aa={description:r("Hyperbolic secant of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(ms(e,this.locale))},isExported:!0},la={description:r("Sine of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(ms(e,this.locale))},isExported:!0},ca={description:r("Hyperbolic sine of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(ms(e,this.locale))},isExported:!0},ha={description:r("Positive square root of a positive number."),args:[Nr("value (number)",r("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e){const t=ms(e,this.locale);return gs((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},da={description:r("Sum of a series of numbers and/or cells."),args:[Nr("value1 (number, range<number>)",r("The first number or range to add together.")),Nr("value2 (number, range<number>, repeating)",r("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){return Ns(e,((e,t)=>e+t),0,this.locale)},isExported:!0},ua={description:r("A conditional sum across a range."),args:[Nr("criteria_range (range)",r("The range which is tested against criterion.")),Nr("criterion (string)",r("The pattern or test to apply to range.")),Nr("sum_range (range, default=criteria_range)",r("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let i=0;return Ls([e,t],((e,t)=>{const s=o[e][t];"number"==typeof s&&(i+=s)}),this.locale),i},isExported:!0},ga={description:r("Sums a range depending on multiple criteria."),args:[Nr("sum_range (range)",r("The range to sum.")),Nr("criteria_range1 (range)",r("The range to check against criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges to check.")),Nr("criterion2 (string, repeating)",r("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let o=0;return Ls(t,((t,i)=>{const s=e[t][i];"number"==typeof s&&(o+=s)}),this.locale),o},isExported:!0},pa={description:r("Tangent of an angle provided in radians."),args:[Nr("angle (number)",r("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(ms(e,this.locale))},isExported:!0},ma={description:r("Hyperbolic tangent of any real number."),args:[Nr("value (number)",r("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(ms(e,this.locale))},isExported:!0},fa={description:r("Truncates a number."),args:[Nr("value (number)",r("The value to be truncated.")),Nr("places (number, default=0)",r("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=ms(e,this.locale);let i=ms(t,this.locale);return 0===i?Math.trunc(o):(Number.isInteger(i)||(i=Math.trunc(i)),Math.trunc(o*Math.pow(10,i))/Math.pow(10,i))},isExported:!0};var ba=Object.freeze({__proto__:null,ABS:gn,ACOS:pn,ACOSH:mn,ACOT:fn,ACOTH:bn,ASIN:vn,ASINH:Sn,ATAN:Cn,ATAN2:En,ATANH:wn,CEILING:yn,CEILING_MATH:xn,CEILING_PRECISE:In,COS:Rn,COSH:Tn,COT:An,COTH:On,COUNTBLANK:Nn,COUNTIF:Mn,COUNTIFS:_n,COUNTUNIQUE:Dn,COUNTUNIQUEIFS:Ln,CSC:Pn,CSCH:kn,DECIMAL:Un,DEGREES:Vn,EXP:zn,FLOOR:Bn,FLOOR_MATH:Hn,FLOOR_PRECISE:$n,ISEVEN:Wn,ISO_CEILING:Gn,ISODD:qn,LN:Zn,MOD:jn,MUNIT:Yn,ODD:Xn,PI:Kn,POWER:Qn,PRODUCT:Jn,RAND:ea,RANDARRAY:ta,RANDBETWEEN:oa,ROUND:ia,ROUNDDOWN:sa,ROUNDUP:ra,SEC:na,SECH:aa,SIN:la,SINH:ca,SQRT:ha,SUM:da,SUMIF:ua,SUMIFS:ga,TAN:pa,TANH:ma,TRUNC:fa});function va(e,t,o){let i=[],s=[],n=0,a=0;Rs([e],(e=>{i.push(e),n+=1})),Rs([t],(e=>{s.push(e),a+=1})),gs((()=>n===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",n.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<n;e++){const t=i[e],o=s[e];"number"==typeof t&&"number"==typeof o&&(l+=1,c+=t,h+=o)}gs((()=>0!==l&&(!o||1!==l)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<n;e++){const t=i[e],o=s[e];"number"==typeof t&&"number"==typeof o&&(g+=(t-d)*(o-u))}return g/(l-(o?1:0))}function Sa(e,t,o,i){let s=0,n=0;const a=o?Ms:Ns;n=a(e,((e,t)=>(s+=1,e+t)),0,i),gs((()=>0!==s&&(!t||1!==s)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const l=n/s;return a(e,((e,t)=>e+Math.pow(t-l,2)),0,i)/(s-(t?1:0))}function Ca(e,t,o,i){const s=ms(t,i);gs((()=>o?0<=s&&s<=1:0<s&&s<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,a=[],l=0;return Rs(e,(e=>{"number"==typeof e&&(n=Us(a,e,"nextSmaller","asc",a.length,((e,t)=>e[t])),a.splice(n+1,0,e),l++)})),gs((()=>0!==l),r("[[FUNCTION_NAME]] has no valid input data.")),o||gs((()=>1/(l+1)<=s&&s<=l/(l+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),lo(a,s,o)}const Ea={description:r("Average magnitude of deviations from mean."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=Ns(e,((e,o)=>(t+=1,e+o)),0,this.locale);gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const i=o/t;return Ns(e,((e,t)=>e+Math.abs(i-t)),0,this.locale)/t},isExported:!0},wa={description:r("Numerical average value in a dataset, ignoring text."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the average value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t=0;const o=Ns(e,((e,o)=>(t+=1,e+o)),0,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},ya=r("[[FUNCTION_NAME]] has mismatched range sizes."),xa=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Ia={description:r("Weighted average."),args:[Nr("values (number, range<number>)",r("Values to average.")),Nr("weights (number, range<number>)",r("Weights for each corresponding value.")),Nr("additional_values (number, range<number>, repeating)",r("Additional values to average.")),Nr("additional_weights (number, range<number>, repeating)",r("Additional weights."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t,o,i=0,s=0;gs((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let n=0;n<e.length-1;n+=2)if(t=e[n],o=e[n+1],Array.isArray(t)){gs((()=>Array.isArray(o)),ya);let e=t.length,n=t[0].length;gs((()=>e===o.length&&n===o[0].length),ya);for(let a=0;a<e;a++)for(let e=0;e<n;e++){let n=t[a][e],l=o[a][e],c="number"==typeof n,h="number"==typeof l;gs((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(gs((()=>l>=0),xa),i+=n*l,s+=l)}}else o=ms(o,this.locale),t=ms(t,this.locale),gs((()=>o>=0),xa),i+=t*o,s+=o;return gs((()=>0!==s),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/s}},Ra={description:r("Numerical average value in a dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the average value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t=0;const o=Ms(e,((e,o)=>(t+=1,e+o)),0,this.locale);return gs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},Ta={description:r("Average of values depending on criteria."),args:[Nr("criteria_range (range)",r("The range to check against criterion.")),Nr("criterion (string)",r("The pattern or test to apply to criteria_range.")),Nr("average_range (range, default=criteria_range)",r("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,o){null==o&&(o=e);let i=0,s=0;return Ls([e,t],((t,r)=>{const n=(o||e)[t][r];"number"==typeof n&&(i+=1,s+=n)}),this.locale),gs((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),s/i},isExported:!0},Aa={description:r("Average of values depending on multiple criteria."),args:[Nr("average_range (range)",r("The range to average.")),Nr("criteria_range1 (range)",r("The range to check against criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1.")),Nr("criteria_range2 (any, range, repeating)",r("Additional criteria_range and criterion to check.")),Nr("criterion2 (string, repeating)",r("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=0,i=0;return Ls(t,((t,s)=>{const r=e[t][s];"number"==typeof r&&(o+=1,i+=r)}),this.locale),gs((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/o},isExported:!0},Oa={description:r("The number of numeric values in dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when counting.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(t+=1);else("string"!=typeof o||ro(o,this.locale)||zt(o,this.locale))&&(t+=1);return t},isExported:!0},Na={description:r("The number of values in a dataset."),args:[Nr("value1 (any, range)",r("The first value or range to consider when counting.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Os(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Ma={description:r("The covariance of a dataset."),args:[Nr("data_y (any, range)",r("The range representing the array or matrix of dependent data.")),Nr("data_x (any, range)",r("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return va(e,t,!1)},isExported:!0},_a={description:r("The covariance of a dataset."),args:[Nr("data_y (any, range)",r("The range representing the array or matrix of dependent data.")),Nr("data_x (any, range)",r("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return va(e,t,!1)},isExported:!0},Fa={description:r("The sample covariance of a dataset."),args:[Nr("data_y (any, range)",r("The range representing the array or matrix of dependent data.")),Nr("data_x (any, range)",r("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return va(e,t,!0)},isExported:!0},Da={description:r("Nth largest element from a data set."),args:[Nr("data (any, range)",r("Array or range containing the dataset to consider.")),Nr("n (number)",r("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){const o=Math.trunc(ms(t,this.locale));let i,s=[],n=0;Rs([e],(e=>{"number"==typeof e&&(i=Us(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(i+1,0,e),n++,n>o&&(s.shift(),n--))}));const a=s.shift();return gs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),gs((()=>n>=o),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},La={description:r("Maximum value in a numeric dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the maximum value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){const t=Ns(e,((e,t)=>e<t?t:e),-1/0,this.locale);return t===-1/0?0:t},isExported:!0},Pa={description:r("Maximum numeric value in a dataset."),args:[Nr("value1 (any, range)",r("The first value or range to consider when calculating the maximum value.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){const t=Ms(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return t===-1/0?0:t},isExported:!0},ka={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[Nr("range (range)",r("The range of cells from which the maximum will be determined.")),Nr("criteria_range1 (range)",r("The range of cells over which to evaluate criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Nr("criterion2 (string, repeating)",r("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=-1/0;return Ls(t,((t,i)=>{const s=e[t][i];"number"==typeof s&&(o=o<s?s:o)}),this.locale),o===-1/0?0:o},isExported:!0},Ua={description:r("Median value in a numeric dataset."),args:[Nr("value1 (any, range)",r("The first value or range to consider when calculating the median value.")),Nr("value2 (any, range, repeating)",r("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){let t=[];return Ts(e,(e=>{t.push(e)}),this.locale),Ca(t,.5,!0,this.locale)},isExported:!0},Va={description:r("Minimum value in a numeric dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the minimum value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){const t=Ns(e,((e,t)=>t<e?t:e),1/0,this.locale);return t===1/0?0:t},isExported:!0},za={description:r("Minimum numeric value in a dataset."),args:[Nr("value1 (number, range<number>)",r("The first value or range to consider when calculating the minimum value.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(...e){const t=Ms(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return t===1/0?0:t},isExported:!0},Ba={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[Nr("range (range)",r("The range of cells from which the minimum will be determined.")),Nr("criteria_range1 (range)",r("The range of cells over which to evaluate criterion1.")),Nr("criterion1 (string)",r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Nr("criteria_range2 (any, range, repeating)",r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Nr("criterion2 (string, repeating)",r("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=1/0;return Ls(t,((t,i)=>{const s=e[t][i];"number"==typeof s&&(o=o>s?s:o)}),this.locale),o===1/0?0:o},isExported:!0},Ha={description:r("Value at a given percentile of a dataset."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("percentile (number)",r("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Wa.compute.bind(this)(e,t)},isExported:!0},$a={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("percentile (number)",r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Ca([e],t,!1,this.locale)},isExported:!0},Wa={description:r("Value at a given percentile of a dataset."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("percentile (number)",r("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Ca([e],t,!0,this.locale)},isExported:!0},Ga={description:r("Value nearest to a specific quartile of a dataset."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("quartile_number (number)",r("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Za.compute.bind(this)(e,t)},isExported:!0},qa={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("quartile_number (number)",r("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Ca([e],.25*Math.trunc(ms(t,this.locale)),!1,this.locale)},isExported:!0},Za={description:r("Value nearest to a specific quartile of a dataset."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("quartile_number (number)",r("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){return Ca([e],.25*Math.trunc(ms(t,this.locale)),!0,this.locale)},isExported:!0},ja={description:r("Nth smallest element in a data set."),args:[Nr("data (any, range)",r("The array or range containing the dataset to consider.")),Nr("n (number)",r("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],computeFormat:e=>Array.isArray(e?.format)?e.format[0][0]:e?.format,compute:function(e,t){const o=Math.trunc(ms(t,this.locale));let i,s=[],n=0;Rs([e],(e=>{"number"==typeof e&&(i=Us(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(i+1,0,e),n++,n>o&&(s.pop(),n--))}));const a=s.pop();return gs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),gs((()=>n>=o),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},Ya={description:r("Standard deviation."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(tl.compute.bind(this)(...e))},isExported:!0},Xa={description:r("Standard deviation of entire population."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ol.compute.bind(this)(...e))},isExported:!0},Ka={description:r("Standard deviation."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(il.compute.bind(this)(...e))},isExported:!0},Qa={description:r("Standard deviation of sample (text as 0)."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(sl.compute.bind(this)(...e))},isExported:!0},Ja={description:r("Standard deviation of entire population."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(rl.compute.bind(this)(...e))},isExported:!0},el={description:r("Standard deviation of entire population (text as 0)."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(nl.compute.bind(this)(...e))},isExported:!0},tl={description:r("Variance."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!0,!1,this.locale)},isExported:!0},ol={description:r("Variance of entire population."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!1,!1,this.locale)},isExported:!0},il={description:r("Variance."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!0,!1,this.locale)},isExported:!0},sl={description:r("Variance of sample (text as 0)."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the sample.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!0,!0,this.locale)},isExported:!0},rl={description:r("Variance of entire population."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!1,!1,this.locale)},isExported:!0},nl={description:r("Variance of entire population (text as 0)."),args:[Nr("value1 (number, range<number>)",r("The first value or range of the population.")),Nr("value2 (number, range<number>, repeating)",r("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sa(e,!1,!0,this.locale)},isExported:!0};var al=Object.freeze({__proto__:null,AVEDEV:Ea,AVERAGE:wa,AVERAGE_WEIGHTED:Ia,AVERAGEA:Ra,AVERAGEIF:Ta,AVERAGEIFS:Aa,COUNT:Oa,COUNTA:Na,COVAR:Ma,COVARIANCE_P:_a,COVARIANCE_S:Fa,LARGE:Da,MAX:La,MAXA:Pa,MAXIFS:ka,MEDIAN:Ua,MIN:Va,MINA:za,MINIFS:Ba,PERCENTILE:Ha,PERCENTILE_EXC:$a,PERCENTILE_INC:Wa,QUARTILE:Ga,QUARTILE_EXC:qa,QUARTILE_INC:Za,SMALL:ja,STDEV:Ya,STDEV_P:Xa,STDEV_S:Ka,STDEVA:Qa,STDEVP:Ja,STDEVPA:el,VAR:tl,VAR_P:ol,VAR_S:il,VARA:sl,VARP:rl,VARPA:nl});function ll(e,t,o,i){const s=new Map,n=e.length;for(let t=n-1;t>=0;t--)s.set(Cs(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(r("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||n-1<a)throw new Error(r("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),n.toString()))}else{const e=Cs(t).toUpperCase();if(a=s.get(e)??-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Cs(t),[...s.keys()].toString()))}const l=o[0].length;if(l<2)throw new Error(r("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let r=[],n=!0;for(let i=0;i<o.length;i++){const a=Cs(o[i][0]).toUpperCase(),l=s.get(a),c=o[i][t];if(void 0!==c){if(void 0===l){n=!1;break}r.push([e[l].slice(1,h)]),r.push(c)}}if(n){if(!(r.length>0)){c=new Set(Array(h-1).keys());break}Ls(r,((e,t)=>{c.add(t)}),i,!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const cl=[Nr("database (range)",r("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")),Nr("field (any)",r("Indicates which column in database contains the values to be extracted and operated on.")),Nr("criteria (range)",r("An array or range containing zero or more criteria to filter the database values by before operating."))],hl={description:r("Average of a set of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return wa.compute.bind(this)([i])},isExported:!0},dl={description:r("Counts values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Oa.compute.bind(this)([i])},isExported:!0},ul={description:r("Counts values and text from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Na.compute.bind(this)([i])},isExported:!0},gl={description:r("Single value from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return gs((()=>1===i.length),r("More than one match found in DGET evaluation.")),i[0]},isExported:!0},pl={description:r("Maximum of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return La.compute.bind(this)([i])},isExported:!0},ml={description:r("Minimum of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Va.compute.bind(this)([i])},isExported:!0},fl={description:r("Product of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Jn.compute.bind(this)([i])},isExported:!0},bl={description:r("Standard deviation of population sample from table."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Ya.compute.bind(this)([i])},isExported:!0},vl={description:r("Standard deviation of entire population from table."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return Ja.compute.bind(this)([i])},isExported:!0},Sl={description:r("Sum of values from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return da.compute.bind(this)([i])},isExported:!0},Cl={description:r("Variance of population sample from table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return tl.compute.bind(this)([i])},isExported:!0},El={description:r("Variance of a population from a table-like range."),args:cl,returns:["NUMBER"],compute:function(e,t,o){const i=ll(e,t,o,this.locale);return rl.compute.bind(this)([i])},isExported:!0};var wl=Object.freeze({__proto__:null,DAVERAGE:hl,DCOUNT:dl,DCOUNTA:ul,DGET:gl,DMAX:pl,DMIN:ml,DPRODUCT:fl,DSTDEV:bl,DSTDEVP:vl,DSUM:Sl,DVAR:Cl,DVARP:El});var yl;!function(e){e.WHOLE_YEARS="Y",e.WHOLE_MONTHS="M",e.WHOLE_DAYS="D",e.DAYS_WITHOUT_WHOLE_MONTHS="MD",e.MONTH_WITHOUT_WHOLE_YEARS="YM",e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR="YD"}(yl||(yl={}));const xl={description:r("Converts year/month/day into a date."),args:[Nr("year (number)",r("The year component of the date.")),Nr("month (number)",r("The month component of the date.")),Nr("day (number)",r("The day component of the date."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o){let i=Math.trunc(ms(e,this.locale));const s=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale));gs((()=>0<=i&&i<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",i.toString())),i<1900&&(i+=1900);const a=Ht(new Date(i,s-1,n));return gs((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Il={description:r("Calculates the number of days, months, or years between two dates."),args:[Nr("start_date (date)",r("The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),Nr("end_date (date)",r("The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),Nr("unit (string)",r('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).'))],returns:["NUMBER"],compute:function(e,t,o){const i=Cs(o).toUpperCase();gs((()=>Object.values(yl).includes(i)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return r("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(yl),Cs(o)));const s=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=Bt(s),l=Bt(n);switch(gs((()=>n>=s),r("start_date (%s) should be on or before end_date (%s).",a.toLocaleDateString(),l.toLocaleDateString())),i){case yl.WHOLE_YEARS:return Xt(a,l);case yl.WHOLE_MONTHS:return jt(a,l);case yl.WHOLE_DAYS:return Yt(a,l);case yl.MONTH_WITHOUT_WHOLE_YEARS:return jt(a,l)-12*Xt(a,l);case yl.DAYS_WITHOUT_WHOLE_MONTHS:let e=l.getDate()-a.getDate();if(e<0){e=$t(new Date(l.getFullYear(),l.getMonth()-1,1))-Math.abs(e)}return e;case yl.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return Zt(e,t,1)<1}(s,n))return Yt(a,l);const e=new Date(a.getFullYear(),l.getMonth(),l.getDate());let t=Yt(a,e);return t<0&&(e.setFullYear(a.getFullYear()+1),t=Yt(a,e)),t}}},isExported:!0},Rl={description:r("Converts a date string to a date value."),args:[Nr("date_string (string)",r("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=Cs(e),o=zt(t,this.locale);return gs((()=>null!==o),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},Tl={description:r("Day of the month that a specific date falls on."),args:[Nr("date (string)",r("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getDate()},isExported:!0},Al={description:r("Number of days between two dates."),args:[Nr("end_date (date)",r("The end of the date range.")),Nr("start_date (date)",r("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const o=xs(e,this.locale),i=xs(t,this.locale),s=o.getTime()-i.getTime();return Math.round(s/Ot)},isExported:!0},Ol={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:[Nr("start_date (date)",r("The start date to consider in the calculation.")),Nr("end_date (date)",r("The end date to consider in the calculation.")),Nr("method (number, default=0)",r("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,o=0){const i=ms(e,this.locale),s=ms(t,this.locale),r=ys(o)?4:0,n=Yl.compute.bind(this)(e,t,r);return Math.sign(s-i)*Math.round(360*n)},isExported:!0},Nl={description:r("Date a number of months before/after another date."),args:[Nr("start_date (date)",r("The date from which to calculate the result.")),Nr("months (number)",r("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t){return Ht(Gt(xs(e,this.locale),Math.trunc(ms(t,this.locale)),!1))},isExported:!0},Ml={description:r("Last day of a month before or after a date."),args:[Nr("start_date (date)",r("The date from which to calculate the result.")),Nr("months (number)",r("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t){const o=xs(e,this.locale),i=Math.trunc(ms(t,this.locale)),s=o.getFullYear(),r=o.getMonth();return Ht(new Date(s,r+i+1,0))},isExported:!0},_l={description:r("Hour component of a specific time."),args:[Nr("time (date)",r("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getHours()},isExported:!0},Fl={description:r("ISO week number of the year."),args:[Nr("date (date)",r("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],returns:["NUMBER"],compute:function(e){const t=xs(e,this.locale),o=t.getFullYear();let i=1;for(;4!==new Date(o,0,i).getDay();)i+=1;const s=new Date(o,0,i-3);let r=31;for(;4!==new Date(o,11,r).getDay();)r-=1;const n=new Date(o,11,r+3);let a,l;switch(a=s.getTime()<=t.getTime()?t.getTime()<=n.getTime()?0:1:-1,a){case 0:l=s;break;case 1:l=new Date(o,11,r+3+1);break;case-1:let e=1;for(;4!==new Date(o-1,0,e).getDay();)e+=1;l=new Date(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/Ot;return Math.floor(c/7)+1},isExported:!0},Dl={description:r("Minute component of a specific time."),args:[Nr("time (date)",r("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getMinutes()},isExported:!0},Ll={description:r("Month of the year a specific date falls in"),args:[Nr("date (date)",r("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getMonth()+1},isExported:!0},Pl={description:r("Net working days between two provided days."),args:[Nr("start_date (date)",r("The start date of the period from which to calculate the number of net working days.")),Nr("end_date (date)",r("The end date of the period from which to calculate the number of net working days.")),Nr("holidays (date, range<date>, optional)",r("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,o){return Ul.compute.bind(this)(e,t,1,o)},isExported:!0};function kl(e){if("string"==typeof e){gs((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),r('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let o=0;o<7;o++)"1"===e[o]&&t.push((o+1)%7);return t}if("number"==typeof e)return gs((()=>1<=e&&e<=7||11<=e&&e<=17),r("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(r("The weekend must be a number or a string."))}const Ul={description:r("Net working days between two dates (specifying weekends)."),args:[Nr("start_date (date)",r("The start date of the period from which to calculate the number of net working days.")),Nr("end_date (date)",r("The end date of the period from which to calculate the number of net working days.")),Nr("weekend (any, default=1)",r("A number or string representing which days of the week are considered weekends.")),Nr("holidays (date, range<date>, optional)",r("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,o=1,i){const s=xs(e,this.locale),r=xs(t,this.locale),n=kl(o);let a=new Set;void 0!==i&&Rs([i],(e=>{const t=xs(e,this.locale);a.add(t.getTime())}));const l=s.getTime()>r.getTime(),c=new Date((l?s:r).getTime());let h=new Date((l?r:s).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)n.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Vl={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat+" "+this.locale.timeFormat},compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-At.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/Ot)+o},isExported:!0},zl={description:r("Minute component of a specific time."),args:[Nr("time (date)",r("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getSeconds()},isExported:!0},Bl={description:r("Converts hour/minute/second into a time."),args:[Nr("hour (number)",r("The hour component of the time.")),Nr("minute (number)",r("The minute component of the time.")),Nr("second (number)",r("The second component of the time."))],returns:["DATE"],computeFormat:function(){return this.locale.timeFormat},compute:function(e,t,o){let i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale));return s+=Math.floor(n/60),n=n%60+(n<0?60:0),i+=Math.floor(s/60),s=s%60+(s<0?60:0),i%=24,gs((()=>i>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),i/24+s/1440+n/86400},isExported:!0},Hl={description:r("Converts a time string into its serial number representation."),args:[Nr("time_string (string)",r("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=Cs(e),o=zt(t,this.locale);gs((()=>null!==o),r("The time_string (%s) cannot be parsed to date/time.",t));const i=o.value-Math.trunc(o.value);return i<0?1+i:i},isExported:!0},$l={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(){const e=new Date;return Ht(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Wl={description:r("Day of the week of the date provided (as number)."),args:[Nr("date (date)",r("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Nr("type (number, default=1)",r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const o=xs(e,this.locale),i=Math.round(ms(t,this.locale)),s=o.getDay();return gs((()=>[1,2,3].includes(i)),r("The type (%s) must be 1, 2 or 3.",i.toString())),1===i?s+1:2===i?0===s?7:s:0===s?6:s-1},isExported:!0},Gl={description:r("Week number of the year."),args:[Nr("date (date)",r("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Nr("type (number, default=1)",r("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const o=xs(e,this.locale),i=Math.round(ms(t,this.locale));if(gs((()=>1===i||2===i||11<=i&&i<=17||21===i),r("The type (%s) is out of range.",i.toString())),21===i)return Fl.compute.bind(this)(e);let s;s=1===i||2===i?i-1:i-10==7?0:i-10;const n=o.getFullYear();let a=1,l=new Date(n,0,a);for(;l.getDay()!==s;)a+=1,l=new Date(n,0,a);const c=(o.getTime()-l.getTime())/Ot;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},ql={description:r("Date after a number of workdays."),args:[Nr("start_date (date)",r("The date from which to begin counting.")),Nr("num_days (number)",r("The number of working days to advance from start_date. If negative, counts backwards.")),Nr("holidays (date, range<date>, optional)",r("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o){return Zl.compute.bind(this)(e,t,1,o)},isExported:!0},Zl={description:r("Date after a number of workdays (specifying weekends)."),args:[Nr("start_date (date)",r("The date from which to begin counting.")),Nr("num_days (number)",r("The number of working days to advance from start_date. If negative, counts backwards.")),Nr("weekend (any, default=1)",r("A number or string representing which days of the week are considered weekends.")),Nr("holidays (date, range<date>, optional)",r("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o=1,i){let s=xs(e,this.locale),n=Math.trunc(ms(t,this.locale));"string"==typeof o&&gs((()=>"1111111"!==o),r("The weekend (%s) must be different from '1111111'.",o));const a=kl(o);let l=new Set;void 0!==i&&Rs([i],(e=>{const t=xs(e,this.locale);l.add(t.getTime())}));let c=new Date(s.getTime()),h=c.getTime();const d=Math.sign(n);let u=Math.abs(n);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-At.getTime();return Math.round(g/Ot)},isExported:!0},jl={description:r("Year specified by a given date."),args:[Nr("date (date)",r("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return xs(e,this.locale).getFullYear()},isExported:!0},Yl={description:r("Exact number of years between two dates."),args:[Nr("start_date (date)",r("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Nr("end_date (date)",r("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Nr("day_count_convention (number, default=0)",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o=0){let i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale));const n=Math.trunc(ms(o,this.locale));return gs((()=>i>=0),r("The start_date (%s) must be positive or null.",i.toString())),gs((()=>s>=0),r("The end_date (%s) must be positive or null.",s.toString())),gs((()=>0<=n&&n<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),Zt(i,s,n)}},Xl={description:r("First day of the month preceding a date."),args:[Nr("date (date)",r("The date from which to calculate the result."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=xs(e,this.locale),o=t.getFullYear(),i=t.getMonth();return Ht(new Date(o,i,1))}},Kl={description:r("Last day of the month following a date."),args:[Nr("date (date)",r("The date from which to calculate the result."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){return Ml.compute.bind(this)(e,0)}},Ql={description:r("Quarter of the year a specific date falls in"),args:[Nr("date (date)",r("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((xs(e,this.locale).getMonth()+1)/3)}},Jl={description:r("First day of the quarter of the year a specific date falls in."),args:[Nr("date (date)",r("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Ql.compute.bind(this)(e),o=jl.compute.bind(this)(e);return Ht(new Date(o,3*(t-1),1))}},ec={description:r("Last day of the quarter of the year a specific date falls in."),args:[Nr("date (date)",r("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Ql.compute.bind(this)(e),o=jl.compute.bind(this)(e);return Ht(new Date(o,3*t,0))}},tc={description:r("First day of the year a specific date falls in."),args:[Nr("date (date)",r("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=jl.compute.bind(this)(e);return Ht(new Date(t,0,1))}},oc={description:r("Last day of the year a specific date falls in."),args:[Nr("date (date)",r("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=jl.compute.bind(this)(e);return Ht(new Date(t+1,0,0))}};var ic=Object.freeze({__proto__:null,DATE:xl,DATEDIF:Il,DATEVALUE:Rl,DAY:Tl,DAYS:Al,DAYS360:Ol,EDATE:Nl,EOMONTH:Ml,HOUR:_l,ISOWEEKNUM:Fl,MINUTE:Dl,MONTH:Ll,NETWORKDAYS:Pl,NETWORKDAYS_INTL:Ul,NOW:Vl,SECOND:zl,TIME:Bl,TIMEVALUE:Hl,TODAY:$l,WEEKDAY:Wl,WEEKNUM:Gl,WORKDAY:ql,WORKDAY_INTL:Zl,YEAR:jl,YEARFRAC:Yl,MONTH_START:Xl,MONTH_END:Kl,QUARTER:Ql,QUARTER_START:Jl,QUARTER_END:ec,YEAR_START:tc,YEAR_END:oc});const sc={description:r("Compare two numeric values, returning 1 if they're equal."),args:[Nr(" (number)",r("The first number to compare.")),Nr(" (number, default=0)",r("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return ms(e,this.locale)===ms(t,this.locale)?1:0},isExported:!0};var rc=Object.freeze({__proto__:null,DELTA:sc});const nc={description:r("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[Nr("range (any, range<any>)",r("The data to be filtered.")),Nr("condition1 (boolean, range<boolean>)",r("A column or row containing true or false values corresponding to the first column or row of range.")),Nr("condition2 (boolean, range<boolean>, repeating)",r("Additional column or row containing true or false values."))],returns:["RANGE<ANY>"],compute:function(e,...t){let o=$s(e);const i=t.map((e=>$s(e)));i.map((e=>_r(r("The arguments condition must be a single column or row."),e))),Fr(r("The arguments conditions must have the same dimensions."),...i);const s=i.map((e=>e.flat())),n=1===i[0].length?"row":"col";o="row"===n?Qe(o):o,gs((()=>s.every((e=>e.length===o.length))),r("FILTER has mismatched sizes on the range and conditions."));const a=[];for(let e=0;e<o.length;e++){const t=o[e];s.every((t=>t[e]))&&a.push(t)}if(!a.length)throw new g(r("No match found in FILTER evaluation"));return Bs("row"===n?Qe(a):a)},isExported:!0},ac={description:r("Unique rows in the provided source range."),args:[Nr("range (any, range<any>)",r("The data to filter by unique entries.")),Nr("by_column (boolean, default=FALSE)",r("Whether to filter the data by columns or by rows.")),Nr("exactly_once (boolean, default=FALSE)",r("Whether to return only entries with no duplicates."))],returns:["RANGE<NUMBER>"],compute:function(e,t,o){if(!cs(e))return Hs(e);const i=ys(t)||!1,s=ys(o)||!1;i||(e=Qe(e));const n=new Map;for(const t of e){const e=JSON.stringify(t),o=n.get(e);o?o.count++:n.set(e,{val:t,count:1})}const a=s?[...n.values()].filter((e=>1===e.count)).map((e=>e.val)):[...n.values()].map((e=>e.val));if(!a.length)throw new Error(r("No unique values found"));return Bs(i?a:Qe(a))},isExported:!0};var lc=Object.freeze({__proto__:null,FILTER:nc,UNIQUE:ac});function cc(e,t){gs((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function hc(e,t){gs((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function dc(e){gs((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function uc(e){gs((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function gc(e){gs((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function pc(e){gs((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function mc(e){gs((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function fc(e){gs((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function bc(e){gs((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function vc(e){gs((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function Sc(e){gs((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function Cc(e){gs((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function Ec(e){gs((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function wc(e,t){gs((()=>e<=t),r("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function yc(e){gs((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function xc(e){gs((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function Ic(e){gs((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function Rc(e){gs((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Tc(e,t,o){const i=xs(e,o),s=xs(t,o),n=new Date(i);n.setFullYear(i.getFullYear()+1),gs((()=>s.getTime()<=n.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Ac(e,t,o){mc(o),gs((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),gs((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),gs((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),gs((()=>t<=o),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Oc(e){gs((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Nc(e,t){gs((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Mc(e){gs((()=>e.every((t=>t>=e[0]))),r("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const _c=[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))];function Fc(e,t,o,i,s=1e-10,n){let a,l,c,h,d=o,u=!1,g=0;do{c=e(d),isNaN(c)?(gs((()=>g<i&&void 0!==n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=n(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<s||Math.abs(c)<s,gs((()=>g<i),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Dc={description:r("Accrued interest of security paying at maturity."),args:[Nr("issue (date)",r("The date the security was initially issued.")),Nr("maturity (date)",r("The maturity date of the security.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(i,this.locale),l=ms(o,this.locale),c=Math.trunc(ms(s,this.locale));hc(n,r),uc(c),gc(a),fc(l);return a*l*Yl.compute.bind(this)(r,n,s)},isExported:!0},Lc={description:r("Depreciation for an accounting period."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("purchase_date (date)",r("The date the asset was purchased.")),Nr("first_period_end (date)",r("The date the first period ended.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("period (number)",r("The single period within life for which to calculate depreciation.")),Nr("rate (number)",r("The deprecation rate.")),Nr(" (number, optional)",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n,a=0){a=a||0;const l=ms(e,this.locale),c=Math.trunc(ms(t,this.locale)),h=Math.trunc(ms(o,this.locale)),d=ms(i,this.locale),u=ms(s,this.locale),g=ms(n,this.locale),p=Math.trunc(ms(a,this.locale));!function(e){gs((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),Cc(d),function(e,t){gs((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){gs((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),fc(g),uc(p),gs((()=>c<=h),r("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,b=Yl.compute.bind(this)(c,h,p),v=c===h?f:f*b,S=l-v-f*m;return S>=d?0===m?v:f:d-S<f?f-(d-S):0},isExported:!0},Pc={description:r("Days in coupon period containing settlement date."),args:_c,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));if(cc(s,r),dc(n),uc(a),1===a){const s=Bc.compute.bind(this)(e,t,o,i);return Vc.compute.bind(this)(e,t,o,i)-s}return(3===a?365:360)/n},isExported:!0},kc={description:r("Days from settlement until next coupon."),args:_c,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);const l=Bc.compute.bind(this)(s,r,o,i);if([1,2,3].includes(a))return s-l;if(4===a){const e=Zt(l,s,a);return Math.round(360*e)}const c=xs(s,this.locale),h=xs(l,this.locale),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Wt(h)&&Wt(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Wt(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Uc={description:r("Days from settlement until next coupon."),args:_c,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);const l=Vc.compute.bind(this)(s,r,o,i);if([1,2,3].includes(a))return l-s;if(4===a){const e=Zt(s,l,a);return Math.round(360*e)}const c=kc.compute.bind(this)(e,t,o,a);return Pc.compute.bind(this)(e,t,o,a)-c},isExported:!0},Vc={description:r("Next coupon date after the settlement date."),args:_c,returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);const l=12/n,c=zc.compute.bind(this)(e,t,o,i);return Ht(Gt(xs(r,this.locale),-(c-1)*l,!0))},isExported:!0},zc={description:r("Number of coupons between settlement and maturity."),args:_c,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);let l=1,c=r;const h=12/n;for(;c>s;)c=Ht(Gt(xs(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},Bc={description:r("Last coupon date prior to or on the settlement date."),args:_c,returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o,i=0){i=i||0;const s=Math.trunc(ms(e,this.locale)),r=Math.trunc(ms(t,this.locale)),n=Math.trunc(ms(o,this.locale)),a=Math.trunc(ms(i,this.locale));cc(s,r),dc(n),uc(a);const l=12/n,c=zc.compute.bind(this)(e,t,o,i);return Ht(Gt(xs(r,this.locale),-c*l,!0))},isExported:!0},Hc={description:r("Cumulative interest paid over a set of periods."),args:[Nr("rate (number)",r("The interest rate.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("first_period (number)",r("The number of the payment period to begin the cumulative calculation.")),Nr("last_period (number)",r("The number of the payment period to end the cumulative calculation.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,i,s,r=0){const n=ms(i,this.locale),a=ms(s,this.locale),l=ms(e,this.locale),c=ms(o,this.locale),h=ms(t,this.locale);Ac(n,a,h),fc(l),Ec(c);let d=0;for(let t=n;t<=a;t++){d+=eh.compute.bind(this)(e,t,h,o,0,r)}return d},isExported:!0},$c={description:r("Cumulative principal paid over a set of periods."),args:[Nr("rate (number)",r("The interest rate.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("first_period (number)",r("The number of the payment period to begin the cumulative calculation.")),Nr("last_period (number)",r("The number of the payment period to end the cumulative calculation.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,i,s,r=0){const n=ms(i,this.locale),a=ms(s,this.locale),l=ms(e,this.locale),c=ms(o,this.locale),h=ms(t,this.locale);Ac(n,a,h),fc(l),Ec(c);let d=0;for(let t=n;t<=a;t++){d+=hh.compute.bind(this)(e,t,h,o,0,r)}return d},isExported:!0},Wc={description:r("Depreciation via declining balance method."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated.")),Nr("period (number)",r("The single period within life for which to calculate depreciation.")),Nr("month (number, optional)",r("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,...s){const n=ms(e,this.locale),a=ms(t,this.locale),l=ms(o,this.locale),c=Math.trunc(ms(i,this.locale)),h=s.length?Math.trunc(ms(s[0],this.locale)):12,d=l+(12===h?0:1);vc(n),Cc(a),Sc(c),bc(l),gs((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),gs((()=>c<=d),r("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/n,1/l);g=Math.round(1e3*g)/1e3;let p=n,m=n*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},Gc={description:r("Depreciation via double-declining balance method."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated.")),Nr("period (number)",r("The single period within life for which to calculate depreciation.")),Nr("factor (number, default=2)",r("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,s=2){s=s||0;const r=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale),c=ms(s,this.locale);if(vc(r),Cc(n),Sc(l),bc(a),wc(l,a),Rc(c),0===r||n>=r)return 0;const h=c/a;if(h>1)return 1===i?r-n:0;if(l<=1)return r*h;const d=r*Math.pow(1-h,l-1),u=r*Math.pow(1-h,l),g=u<n?d-n:d-u;return Math.max(g,0)},isExported:!0},qc={description:r("Discount rate of a security based on price."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("price (number)",r("The price at which the security is bought per 100 face value.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(o,this.locale),l=ms(i,this.locale),c=Math.trunc(ms(s,this.locale));cc(r,n),uc(c),pc(a),gc(l);return(l-a)/l/Yl.compute.bind(this)(r,n,c)},isExported:!0},Zc={description:r("Convert a decimal fraction to decimal value."),args:[Nr("fractional_price (number)",r("The price quotation given using fractional decimal conventions.")),Nr("unit (number)",r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=Math.trunc(ms(t,this.locale));gs((()=>i>0),r("The unit (%s) must be strictly positive.",i.toString()));const s=Math.trunc(o);return s+(o-s)*(10**Math.ceil(Math.log10(i))/i)},isExported:!0},jc={description:r("Convert a decimal value to decimal fraction."),args:[Nr("decimal_price (number)",r("The price quotation given as a decimal value.")),Nr("unit (number)",r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=Math.trunc(ms(t,this.locale));gs((()=>i>0),r("The unit (%s) must be strictly positive.",i.toString()));const s=Math.trunc(o);return s+(o-s)*(i/10**Math.ceil(Math.log10(i)))},isExported:!0},Yc={description:r("Number of periods for an investment to reach a value."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("yield (number)",r("The expected annual yield of the security.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n=0){n=n||0;const a=Math.trunc(ms(e,this.locale)),l=Math.trunc(ms(t,this.locale)),c=ms(o,this.locale),h=ms(i,this.locale),d=Math.trunc(ms(s,this.locale)),u=Math.trunc(ms(n,this.locale));cc(a,l),dc(d),uc(u),gs((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),gs((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=Yl.compute.bind(this)(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,b=h/d;let v=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+b)**e;S+=(p+(e-1)/d)*t,v+=t}return 0===v?0:S/v},isExported:!0},Xc={description:r("Annual effective interest rate."),args:[Nr("nominal_rate (number)",r("The nominal interest rate per year.")),Nr("periods_per_year (number)",r("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=Math.trunc(ms(t,this.locale));return gs((()=>o>0),r("The nominal rate (%s) must be strictly greater than 0.",o.toString())),gs((()=>i>0),r("The number of periods by year (%s) must strictly greater than 0.",i.toString())),Math.pow(1+o/i,i)-1},isExported:!0},Kc={description:r("Future value of an annuity investment."),args:[Nr("rate (number)",r("The interest rate.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("payment_amount (number)",r("The amount per period to be paid.")),Nr("present_value (number, default=0)",r("The current value of the annuity.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i=0,s=0){i=i||0,s=s||0;const r=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale),c=ys(s)?1:0;return r?-l*(1+r)**n-a*(1+r*c)*((1+r)**n-1)/r:-(l+a*n)},isExported:!0},Qc={description:r("Future value of principal from series of rates."),args:[Nr("principal (number)",r("The amount of initial capital or value to compound against.")),Nr("rate_schedule (number, range<number>)",r("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Os([t],((e,t)=>e*(1+ms(t,this.locale))),ms(e,this.locale))},isExported:!0},Jc={description:r("Calculates effective interest rate."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("investment (number)",r("The amount invested in the security.")),Nr("redemption (number)",r("The amount to be received at maturity.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(i,this.locale),l=ms(o,this.locale);cc(r,n),yc(l),gc(a);return(a-l)/l/Yl.compute.bind(this)(r,n,s)},isExported:!0},eh={description:r("Payment on the principal of an investment."),args:[Nr("rate (number)",r("The annualized rate of interest.")),Nr("period (number)",r("The amortization period, in terms of number of periods.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,s=0,r=0){return ch.compute.bind(this)(e,o,i,s,r)-hh.compute.bind(this)(e,t,o,i,s,r)},isExported:!0},th={description:r("Internal rate of return given periodic cashflows."),args:[Nr("cashflow_amounts (number, range<number>)",r("An array or range containing the income or payments associated with the investment.")),Nr("rate_guess (number, default=0.1)",r("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const o=ms(t,this.locale);Oc(o);let i=!1,s=!1,n=[];Ts([e],(e=>{e>0&&(i=!0),e<0&&(s=!0),n.push(e)}),this.locale),gs((()=>i&&s),r("The cashflow_amounts must include negative and positive values."));const a=n.shift();return Fc((function(e){return function(e,t,o){const i=o.length;let s=0;return o.reduce(((t,o)=>(s++,t+o*e**(i-s))),t*e**i)}(e,a,n)}),(function(e){return function(e,t,o){const i=o.length;let s=0;return o.reduce(((t,o)=>(s++,t+o*(i-s)*e**(i-s-1))),t*i*e**(i-1))}(e,a,n)}),o+1,20,1e-5)-1},isExported:!0},oh={description:r("Returns the interest paid at a particular period of an investment."),args:[Nr("rate (number)",r("The interest rate.")),Nr("period (number)",r("The period for which you want to view the interest payment.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,o,i){const s=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale);gs((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(n/a))*s},isExported:!0},ih={description:r("Modified Macaulay duration."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("yield (number)",r("The expected annual yield of the security.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,r=0){return Yc.compute.bind(this)(e,t,o,i,s,r)/(1+ms(i,this.locale)/Math.trunc(ms(s,this.locale)))},isExported:!0},sh={description:r("Modified internal rate of return."),args:[Nr("cashflow_amounts (range<number>)",r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),Nr("financing_rate (number)",r("The interest rate paid on funds invested.")),Nr("reinvestment_return_rate (number)",r("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,o){const i=ms(t,this.locale),s=ms(o,this.locale),n=Qe(e).flat().filter(He).map((e=>ms(e,this.locale))),a=n.length;let l=0,c=0;for(const e of Oe(0,a)){const t=n[e];t>=0?l+=t*(s+1)**(a-e-1):c+=t/(i+1)**e}gs((()=>0!==c&&0!==l),r("There must be both positive and negative values in cashflow_amounts."));return(-l/c)**(1/(a-1))-1},isExported:!0},rh={description:r("Annual nominal interest rate."),args:[Nr("effective_rate (number)",r("The effective interest rate per year.")),Nr("periods_per_year (number)",r("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=ms(e,this.locale),i=Math.trunc(ms(t,this.locale));return gs((()=>o>0),r("The effective rate (%s) must must strictly greater than 0.",o.toString())),gs((()=>i>0),r("The number of periods by year (%s) must strictly greater than 0.",i.toString())),(Math.pow(o+1,1/i)-1)*i},isExported:!0},nh={description:r("Number of payment periods for an investment."),args:[Nr("rate (number)",r("The interest rate.")),Nr("payment_amount (number)",r("The amount of each payment made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,i=0,s=0){i=i||0,s=s||0;const r=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale),c=ys(s)?1:0;if(0===r)return-(l+a)/n;const h=n*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const ah={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[Nr("discount (number)",r("The discount rate of the investment over one period.")),Nr("cashflow1 (number, range<number>)",r("The first future cash flow.")),Nr("cashflow2 (number, range<number>, repeating)",r("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const o=ms(e,this.locale);return gs((()=>-1!==o),r("The discount (%s) must be different from -1.",o.toString())),function(e,t,o,i){let s=0;return Ns(o,((t,o)=>(s++,t+o/(1+e)**s)),t,i)}(o,0,t,this.locale)},isExported:!0},lh={description:r("Computes the number of periods needed for an investment to reach a value."),args:[Nr("rate (number)",r("The rate at which the investment grows each period.")),Nr("present_value (number)",r("The investment's current value.")),Nr("future_value (number)",r("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,o){const i=ms(e,this.locale),s=ms(t,this.locale),n=ms(o,this.locale);return fc(i),gs((()=>s>0),r("The present_value (%s) must be strictly positive.",s.toString())),gs((()=>n>0),r("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(s))/Math.log(1+i)},isExported:!0},ch={description:r("Periodic payment for an annuity investment."),args:[Nr("rate (number)",r("The annualized rate of interest.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i=0,s=0){i=i||0,s=s||0;const r=ms(t,this.locale),n=ms(e,this.locale),a=ys(s)?1:0;let l=ms(i,this.locale),c=ms(o,this.locale);if(mc(r),0===n)return-(l+c)/r;let h=-(c*(1+n)**r+l);return h=h*n/((1+n*a)*((1+n)**r-1)),h},isExported:!0},hh={description:r("Payment on the principal of an investment."),args:[Nr("rate (number)",r("The annualized rate of interest.")),Nr("period (number)",r("The amortization period, in terms of number of periods.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,s=0,n=0){s=s||0,n=n||0;const a=ms(o,this.locale),l=ms(e,this.locale),c=ms(t,this.locale),h=ys(n)?1:0,d=ms(s,this.locale),u=ms(i,this.locale);mc(a),gs((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=ch.compute.bind(this)(l,a,u,d,n);if(1===h&&1===c)return g;const p=0===h?c-1:c-2,m=u+g*h;return g+-Kc.compute.bind(this)(l,p,g,m,0)*l},isExported:!0},dh={description:r("Present value of an annuity investment."),args:[Nr("rate (number)",r("The interest rate.")),Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("payment_amount (number)",r("The amount per period to be paid.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i=0,s=0){i=i||0,s=s||0;const r=ms(e,this.locale),n=ms(t,this.locale),a=ms(o,this.locale),l=ms(i,this.locale),c=ys(s)?1:0;return r?-(a*(1+r*c)*((1+r)**n-1)/r+l)/(1+r)**n:-(l+a*n)},isExported:!0},uh={description:r("Price of a security paying periodic interest."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("yield (number)",r("The expected annual yield of the security.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n,a=0){a=a||0;const l=Math.trunc(ms(e,this.locale)),c=Math.trunc(ms(t,this.locale)),h=ms(o,this.locale),d=ms(i,this.locale),u=ms(s,this.locale),g=Math.trunc(ms(n,this.locale)),p=Math.trunc(ms(a,this.locale));cc(l,c),dc(g),uc(p),gs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),gs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),gc(u);const m=Yl.compute.bind(this)(l,c,p)*g,f=Math.ceil(m),b=m-Math.floor(m)||1,v=1+d/g,S=100*h/g;if(1===f)return(S+u)/(b*d/g+1)-S*(1-b);let C=0;for(let e=1;e<=f;e++)C+=S/v**(e-1+b);return u/v**(f-1+b)+C-S*(1-b)},isExported:!0},gh={description:r("Price of a discount security."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("discount (number)",r("The discount rate of the security at time of purchase.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(o,this.locale),l=ms(i,this.locale),c=Math.trunc(ms(s,this.locale));cc(r,n),uc(c),xc(a),gc(l);return l-a*l*Yl.compute.bind(this)(r,n,c)},isExported:!0},ph={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("issue (date)",r("The date the security was initially issued.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("yield (number)",r("The expected annual yield of the security.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n=0){n=n||0;const a=Math.trunc(ms(e,this.locale)),l=Math.trunc(ms(t,this.locale)),c=Math.trunc(ms(o,this.locale)),h=ms(i,this.locale),d=ms(s,this.locale),u=Math.trunc(ms(n,this.locale));hc(a,c),cc(a,l),uc(u),gs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),gs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=Yl.compute.bind(this)(a,l,u),p=Yl.compute.bind(this)(a,c,u);return(100+Yl.compute.bind(this)(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},mh=.1,fh={description:r("Interest rate of an annuity investment."),args:[Nr("number_of_periods (number)",r("The number of payments to be made.")),Nr("payment_per_period (number)",r("The amount per period to be paid.")),Nr("present_value (number)",r("The current value of the annuity.")),Nr("future_value (number, default=0)",r("The future value remaining after the final payment has been made.")),Nr("end_or_beginning (number, default=0)",r("Whether payments are due at the end (0) or beginning (1) of each period.")),Nr("rate_guess (number, default=0.1)",r("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,o,i=0,s=0,n=.1){i=i||0,s=s||0,n=n||mh;const a=ms(e,this.locale),l=ms(t,this.locale),c=ys(s)?1:0,h=ms(n,this.locale);let d=ms(i,this.locale),u=ms(o,this.locale);mc(a),gs((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),r("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),Oc(h),d-=l*c,u+=l*c;return Fc((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),o=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(o-1)/e/e)}),h,40,1e-5)},isExported:!0},bh={description:r("Amount received at maturity for a security."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("investment (number)",r("The amount invested (irrespective of face value of each security).")),Nr("discount (number)",r("The discount rate of the security invested in.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(o,this.locale),l=ms(i,this.locale),c=Math.trunc(ms(s,this.locale));cc(r,n),uc(c),yc(a),xc(l);return a/(1-l*Yl.compute.bind(this)(r,n,c))},isExported:!0},vh={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[Nr("number_of_periods (number)",r("The number of periods.")),Nr("present_value (number)",r("The present value of the investment.")),Nr("future_value (number)",r("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,o){const i=ms(e,this.locale),s=ms(t,this.locale),r=ms(o,this.locale);return mc(i),(r/s)**(1/i)-1},isExported:!0},Sh={description:r("Depreciation of an asset using the straight-line method."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o){return(ms(e,this.locale)-ms(t,this.locale))/ms(o,this.locale)},isExported:!0},Ch={description:r("Depreciation via sum of years digit method."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated.")),Nr("period (number)",r("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i){const s=ms(e,this.locale),r=ms(t,this.locale),n=ms(o,this.locale),a=ms(i,this.locale);Sc(a),bc(n),wc(a,n);return(n-a+1)/(n*(n+1)/2)*(s-r)},isExported:!0},Eh={description:r("Price of a US Treasury bill."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("discount (number)",r("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale)),r=ms(o,this.locale);cc(i,s),Tc(i,s,this.locale),xc(r),Ic(r);return 100*(1-r*Yl.compute.bind(this)(i,s,2))},isExported:!0},wh={description:r("Equivalent rate of return for a US Treasury bill."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("discount (number)",r("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale)),r=ms(o,this.locale);cc(i,s),Tc(i,s,this.locale),xc(r),Ic(r);const n=Al.compute.bind(this)(s,i);if(n<=182)return 365*r/(360-r*n);const a=Eh.compute.bind(this)(i,s,r)/100,l=n/(366===n?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},yh={description:r("The yield of a US Treasury bill based on price."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("price (number)",r("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(ms(e,this.locale)),s=Math.trunc(ms(t,this.locale)),r=ms(o,this.locale);cc(i,s),Tc(i,s,this.locale),pc(r);return(100-r)/r*(1/Yl.compute.bind(this)(i,s,2))},isExported:!0},xh={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:[Nr("cost (number)",r("The initial cost of the asset.")),Nr("salvage (number)",r("The value of the asset at the end of depreciation.")),Nr("life (number)",r("The number of periods over which the asset is depreciated.")),Nr("start (number)",r("Starting period to calculate depreciation.")),Nr("end (number)",r("Ending period to calculate depreciation.")),Nr("factor (number, default=2)",r("The number of months in the first year of depreciation.")),Nr("no_switch (number, default=false)",r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n=2,a=false){n=n||0;const l=ms(e,this.locale),c=ms(t,this.locale),h=ms(o,this.locale),d=Math.trunc(ms(i,this.locale)),u=Math.trunc(ms(s,this.locale)),g=ms(n,this.locale),p=ys(a);if(vc(l),Cc(c),function(e,t,o){bc(o),gs((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),gs((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),gs((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),gs((()=>t<=o),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(d,u,h),Rc(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,b=0,v=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,o=(f-c)/(h-e);!p&&o>t?(S=!0,b=o):b=t}const t=Math.max(f-b,c);e>=d&&(v+=f-t),f=t}return v},isExported:!0},Ih={description:r("Internal rate of return given non-periodic cash flows."),args:[Nr("cashflow_amounts (range<number>)",r("An range containing the income or payments associated with the investment.")),Nr("cashflow_dates (range<number>)",r("An range with dates corresponding to the cash flows in cashflow_amounts.")),Nr("rate_guess (number, default=0.1)",r("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,o=.1){const i=ms(o=o||0,this.locale),s=e.flat().map((e=>ms(e,this.locale))),n=t.flat().map((e=>ms(e,this.locale)));var a;Nc(e,t),a=s,gs((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),Mc(n),Oc(i);const l=new Map;for(const e of Oe(0,n.length)){const t=n[e];l.has(t)?l.set(t,l.get(t)+s[e]):l.set(t,s[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return Fc((e=>{let t=h[0];for(const o of Oe(1,h.length)){const i=(c[0]-c[o])/365;t+=h[o]*(1+e)**i}return t}),(e=>{let t=0;for(const o of Oe(1,h.length)){const i=(c[0]-c[o])/365;t+=i*h[o]*(1+e)**(i-1)}return t}),i,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Rh={description:r("Net present value given to non-periodic cash flows.."),args:[Nr("discount (number)",r("The discount rate of the investment over one period.")),Nr("cashflow_amounts (number, range<number>)",r("An range containing the income or payments associated with the investment.")),Nr("cashflow_dates (number, range<number>)",r("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,o){const i=ms(e,this.locale),s=Array.isArray(t)?t.flat().map((e=>fs(e,this.locale))):[fs(t,this.locale)],n=Array.isArray(o)?o.flat().map((e=>fs(e,this.locale))):[fs(o,this.locale)];if(Array.isArray(o)&&Array.isArray(t)?Nc(t,o):gs((()=>s.length===n.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Mc(n),fc(i),1===s.length)return s[0];const a=new Map;for(const e of Oe(0,n.length)){const t=n[e];a.has(t)?a.set(t,a.get(t)+s[e]):a.set(t,s[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of Oe(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+i)**t}return h},isExported:!0},Th={description:r("Annual yield of a security paying periodic interest."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("price (number)",r("The price at which the security is bought per 100 face value.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("frequency (number)",r("The number of interest or coupon payments per year (1, 2, or 4).")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n,a=0){a=a||0;const l=Math.trunc(ms(e,this.locale)),c=Math.trunc(ms(t,this.locale)),h=ms(o,this.locale),d=ms(i,this.locale),u=ms(s,this.locale),g=Math.trunc(ms(n,this.locale)),p=Math.trunc(ms(a,this.locale));cc(l,c),dc(g),uc(p),gs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),pc(d),gc(u);const m=Yl.compute.bind(this)(l,c,p)*g,f=Math.ceil(m),b=m-Math.floor(m)||1,v=100*h/g;if(1===f){const e=d+v*(1-b);return(u+v-e)*g*(1/b)/e}const S=Fc((function(e){return function(e,t,o,i,s,r){let n=r-(e+s*(1-t))*i**(o-1+t);for(let e=1;e<=o;e++)n+=s*i**(e-1);return n}(d,b,f,e,v,u)}),(function(e){return function(e,t,o,i,s){let r=-(e+s*(1-t))*(o-1+t)*i**(o-2+t);for(let e=1;e<=o;e++)r+=s*(e-1)*i**(e-2);return r}(d,b,f,e,v)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Ah={description:r("Annual yield of a discount security."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("price (number)",r("The price at which the security is bought per 100 face value.")),Nr("redemption (number)",r("The redemption amount per 100 face value, or par.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s=0){s=s||0;const r=Math.trunc(ms(e,this.locale)),n=Math.trunc(ms(t,this.locale)),a=ms(o,this.locale),l=ms(i,this.locale),c=Math.trunc(ms(s,this.locale));cc(r,n),uc(c),pc(a),gc(l);return(l/a-1)/Yl.compute.bind(this)(e,t,s)},isExported:!0},Oh={description:r("Annual yield of a security paying interest at maturity."),args:[Nr("settlement (date)",r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Nr("maturity (date)",r("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Nr("issue (date)",r("The date the security was initially issued.")),Nr("rate (number)",r("The annualized rate of interest.")),Nr("price (number)",r("The price at which the security is bought.")),Nr("day_count_convention (number, default=0 )",r("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,s,n=0){n=n||0;const a=Math.trunc(ms(e,this.locale)),l=Math.trunc(ms(t,this.locale)),c=Math.trunc(ms(o,this.locale)),h=ms(i,this.locale),d=ms(s,this.locale),u=Math.trunc(ms(n,this.locale));cc(a,l),uc(u),gs((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),gs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),pc(d);const g=Yl.compute.bind(this)(c,l,u),p=Yl.compute.bind(this)(c,a,u),m=Yl.compute.bind(this)(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Nh=Object.freeze({__proto__:null,ACCRINTM:Dc,AMORLINC:Lc,COUPDAYS:Pc,COUPDAYBS:kc,COUPDAYSNC:Uc,COUPNCD:Vc,COUPNUM:zc,COUPPCD:Bc,CUMIPMT:Hc,CUMPRINC:$c,DB:Wc,DDB:Gc,DISC:qc,DOLLARDE:Zc,DOLLARFR:jc,DURATION:Yc,EFFECT:Xc,FV:Kc,FVSCHEDULE:Qc,INTRATE:Jc,IPMT:eh,IRR:th,ISPMT:oh,MDURATION:ih,MIRR:sh,NOMINAL:rh,NPER:nh,NPV:ah,PDURATION:lh,PMT:ch,PPMT:hh,PV:dh,PRICE:uh,PRICEDISC:gh,PRICEMAT:ph,RATE:fh,RECEIVED:bh,RRI:vh,SLN:Sh,SYD:Ch,TBILLPRICE:Eh,TBILLEQ:wh,TBILLYIELD:yh,VDB:xh,XIRR:Ih,XNPV:Rh,YIELD:Th,YIELDDISC:Ah,YIELDMAT:Oh});const Mh={description:r("Whether a value is an error other than #N/A."),args:[Nr("value (any, lazy)",r("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return e?.errorType!=a.NotAvailable}},isExported:!0},_h={description:r("Whether a value is an error."),args:[Nr("value (any, lazy)",r("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},Fh={description:r("Whether a value is `true` or `false`."),args:[Nr("value (any, lazy)",r("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},Dh={description:r("Whether a value is the error #N/A."),args:[Nr("value (any, lazy)",r("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return e?.errorType==a.NotAvailable}},isExported:!0},Lh={description:r("Whether a value is non-textual."),args:[Nr("value (any, lazy)",r("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},Ph={description:r("Whether a value is a number."),args:[Nr("value (any, lazy)",r("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},kh={description:r("Whether a value is text."),args:[Nr("value (any, lazy)",r("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Uh={description:r("Whether the referenced cell is empty"),args:[Nr("value (any, lazy)",r("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Vh={description:r("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var zh=Object.freeze({__proto__:null,ISERR:Mh,ISERROR:_h,ISLOGICAL:Fh,ISNA:Dh,ISNONTEXT:Lh,ISNUMBER:Ph,ISTEXT:kh,ISBLANK:Uh,NA:Vh});const Bh={description:r("Logical `and` operator."),args:[Nr("logical_expression1 (boolean, range<boolean>)",r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Nr("logical_expression2 (boolean, range<boolean>, repeating)",r("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!0;return _s(e,(e=>(t=!0,o=o&&e,o))),gs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Hh={description:r("Logical value `false`."),args:[],returns:["BOOLEAN"],compute:function(){return!1},isExported:!0},$h={description:r("Returns value depending on logical expression."),args:[Nr("logical_expression (boolean)",r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),Nr("value_if_true (any, lazy)",r("The value the function returns if logical_expression is TRUE.")),Nr("value_if_false (any, lazy, default=FALSE)",r("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,o=(()=>!1)){const i=ys(e)?t():o();return null==i?"":i},isExported:!0},Wh={description:r("Value if it is not an error, otherwise 2nd argument."),args:[Nr("value (any, lazy)",r("The value to return if value itself is not an error.")),Nr('value_if_error (any, lazy, default="empty")',r("The value the function returns if value is an error."))],returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{try{return e().format}catch(e){return t()?.format}},compute:function(e,t=(()=>"")){let o;try{o=e()}catch(e){o=t()}return null==o?"":o},isExported:!0},Gh={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:[Nr("value (any, lazy)",r("The value to return if value itself is not #N/A an error.")),Nr('value_if_error (any, lazy, default="empty")',r("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t=(()=>"")){let o;try{o=e()}catch(i){o=i.errorType===a.NotAvailable?t():e()}return null==o?"":o},isExported:!0},qh={description:r("Returns a value depending on multiple logical expressions."),args:[Nr("condition1 (boolean, lazy)",r("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),Nr("value1 (any, lazy)",r("The returned value if condition1 is TRUE.")),Nr("condition2 (boolean, lazy, repeating)",r("Additional conditions to be evaluated if the previous ones are FALSE.")),Nr("value2 (any, lazy, repeating)",r("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){gs((()=>e.length%2==0),r("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(ys(e[t]())){const o=e[t+1]();return null!==o?o:""}throw new Error(r("No match."))},isExported:!0},Zh={description:r("Returns opposite of provided logical value."),args:[Nr("logical_expression (boolean)",r("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!ys(e)},isExported:!0},jh={description:r("Logical `or` operator."),args:[Nr("logical_expression1 (boolean, range<boolean>)",r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Nr("logical_expression2 (boolean, range<boolean>, repeating)",r("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return _s(e,(e=>(t=!0,o=o||e,!o))),gs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Yh={description:r("Logical value `true`."),args:[],returns:["BOOLEAN"],compute:function(){return!0},isExported:!0},Xh={description:r("Logical `xor` operator."),args:[Nr("logical_expression1 (boolean, range<boolean>)",r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Nr("logical_expression2 (boolean, range<boolean>, repeating)",r("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return _s(e,(e=>(t=!0,o=o?!e:e,!0))),gs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Kh=Object.freeze({__proto__:null,AND:Bh,FALSE:Hh,IF:$h,IFERROR:Wh,IFNA:Gh,IFS:qh,NOT:Zh,OR:jh,TRUE:Yh,XOR:Xh});function Qh(e,t){if(void 0===e)throw new g(r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Cs(t)))}const Jh={description:r("Returns a cell reference as a string. "),args:[Nr("row (number)",r("The row number of the cell reference. ")),Nr("column (number)",r("The column number (not name) of the cell reference. A is column number 1. ")),Nr("absolute_relative_mode (number, default=1)",r("An indicator of whether the reference is row/column absolute. 1 is row and column absolute (e.g. $A$1), 2 is row absolute and column relative (e.g. A$1), 3 is row relative and column absolute (e.g. $A1), and 4 is row and column relative (e.g. A1).")),Nr("use_a1_notation (boolean, default=TRUE)",r("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),Nr("sheet (string, optional)",r("A string indicating the name of the sheet into which the address points."))],returns:["STRING"],compute:function(e,t,o=1,i=!0,s){const n=vs(e,this.locale),a=vs(t,this.locale);Ss(n),Ss(a);const l=vs(o,this.locale);var c,h;gs((()=>[1,2,3,4].includes(l)),(c=4,h=l,r("The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.",1..toString(),c.toString(),h.toString())));let d;if(ys(i)){d=Tt(a-1,n-1,{rowFixed:!![1,2].includes(l),colFixed:!![1,3].includes(l)})}else{d=([1,2].includes(l)?`R${n}`:`R[${n}]`)+([1,3].includes(l)?`C${a}`:`C[${a}]`)}return void 0!==s?`${Ee(Cs(s))}!${d}`:d},isExported:!0},ed={description:r("Column number of a specified cell."),args:[Nr("cell_reference (meta, default='this cell')",r("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){const t=e||this.__originCellXC?.();gs((()=>!!t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Jo(t).left+1},isExported:!0},td={description:r("Number of columns in a specified array or range."),args:[Nr("range (meta)",r("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Jo(e);return t.right-t.left+1},isExported:!0},od={description:r("Horizontal lookup"),args:[Nr("search_key (any)",r("The value to search for. For example, 42, 'Cats', or I24.")),Nr("range (range)",r("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),Nr("index (number)",r("The row index of the value to be returned, where the first row in range is numbered 1.")),Nr("is_sorted (boolean, default=true)",r("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,o,i=true){const s=Math.trunc(ms(o,this.locale)),n=Es(e);gs((()=>1<=s&&s<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=ys(i)?Us(t,n,"nextSmaller","asc",t.length,ks):Vs(t,n,"strict",t.length,ks);const l=t[a];return Qh(l,e),l[s-1]},isExported:!0},id={description:r("Look up a value."),args:[Nr("search_key (any)",r("The value to search for. For example, 42, 'Cats', or I24.")),Nr("search_array (range)",r("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),Nr("result_range (range, optional)",r("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],returns:["ANY"],compute:function(e,t,o){let i=t.length,s=t[0].length;const n=Es(e),a=s>=i,l=Us(t,n,"nextSmaller","asc",a?s:i,a?Ps:ks);return-1===l&&Qh(void 0,e),Qh(a?t[0][l]:t[l][s-1],e),void 0===o?a?t[i-1][l]:t[l][s-1]:(i=o.length,s=o[0].length,gs((()=>1===i||1===s),r("The result_range must be a single row or a single column.")),i>1?(gs((()=>l<=i-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),o[l][0]):(gs((()=>l<=s-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),o[0][l]))},isExported:!0},sd={description:r("Position of item in range that matches value."),args:[Nr("search_key (any)",r("The value to search for. For example, 42, 'Cats', or I24.")),Nr("range (any, range)",r("The one-dimensional array to be searched.")),Nr("search_type (number, default=1)",r("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,o=1){let i=ms(o,this.locale);const s=Es(e),n=t.length,a=t[0].length;gs((()=>1===n||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===n?Ps:ks,h=1===n?t[0].length:t.length;switch(i=Math.sign(i),i){case 1:l=Us(t,s,"nextSmaller","asc",h,c);break;case 0:l=Vs(t,s,"strict",h,c);break;case-1:l=Us(t,s,"nextGreater","desc",h,c)}return Qh(1===n?t[0][l]:t[l],e),l+1},isExported:!0},rd={description:r("Row number of a specified cell."),args:[Nr("cell_reference (meta, default='this cell')",r("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){e=e||this.__originCellXC?.(),gs((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Jo(e).top+1},isExported:!0},nd={description:r("Number of rows in a specified array or range."),args:[Nr("range (meta)",r("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Jo(e);return t.bottom-t.top+1},isExported:!0},ad={description:r("Vertical lookup."),args:[Nr("search_key (any)",r("The value to search for. For example, 42, 'Cats', or I24.")),Nr("range (any, range)",r("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),Nr("index (number)",r("The column index of the value to be returned, where the first column in range is numbered 1.")),Nr("is_sorted (boolean, default=true)",r("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,o,i=true){const s=Math.trunc(ms(o,this.locale)),n=Es(e);gs((()=>1<=s&&s<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=ys(i)?Us(t,n,"nextSmaller","asc",t[0].length,Ps):Vs(t,n,"strict",t[0].length,Ps);const l=t[s-1][a];return Qh(l,e),l},isExported:!0},ld={description:r("Search a range for a match and return the corresponding item from a second range."),args:[Nr("search_key (any)",r("The value to search for.")),Nr("lookup_range (any, range)",r("The range to consider for the search. Should be a single column or a single row.")),Nr("return_range (any, range)",r("The range containing the return value. Should have the same dimensions as lookup_range.")),Nr("if_not_found (any, lazy, optional)",r("If a valid match is not found, return this value.")),Nr("match_mode (any, default=0)",r("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),Nr("search_mode (any, default=1)",r("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,o,i,s=0,n=1){const a=Math.trunc(ms(s,this.locale)),l=Math.trunc(ms(n,this.locale)),c=Es(e);gs((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),gs((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),gs((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?"col":"row";gs((()=>"col"===h?o[0].length===t[0].length:o.length===t.length),r("return_range should have the same dimensions as lookup_range."));const d="col"===h?Ps:ks,u="col"===h?t[0].length:t.length,g=0===a?"strict":1===a?"nextGreater":"nextSmaller",p=-1===l;let m;if(2===l||-2===l){m=Us(t,c,g,2===l?"asc":"desc",u,d)}else m=Vs(t,c,g,u,d,p);if(-1!==m)return Bs("col"===h?o.map((e=>[e[m]])):[o[m]]);const f=i?.();return Qh(f,e),f},isExported:!0};var cd=Object.freeze({__proto__:null,ADDRESS:Jh,COLUMN:ed,COLUMNS:td,HLOOKUP:od,LOOKUP:id,MATCH:sd,ROW:rd,ROWS:nd,VLOOKUP:ad,XLOOKUP:ld});const hd={description:r("Sum of two numbers."),args:[Nr("value1 (number)",r("The first addend.")),Nr("value2 (number)",r("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return ms(e,this.locale)+ms(t,this.locale)}},dd={description:r("Concatenation of two values."),args:[Nr("value1 (string)",r("The value to which value2 will be appended.")),Nr("value2 (string)",r("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return Cs(e)+Cs(t)},isExported:!0},ud={description:r("One number divided by another."),args:[Nr("dividend (number)",r("The number to be divided.")),Nr("divisor (number)",r("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){const o=ms(t,this.locale);return gs((()=>0!==o),r("The divisor must be different from zero.")),ms(e,this.locale)/o}};function gd(e){return null==e}const pd={number:0,string:"",boolean:!1},md={description:r("Equal."),args:[Nr("value1 (any)",r("The first value.")),Nr("value2 (any)",r("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=gd(e)?pd[typeof t]:e,t=gd(t)?pd[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function fd(e,t,o){e=gd(e)?pd[typeof t]:e,t=gd(t)?pd[typeof e]:t,"number"!=typeof e&&(e=Cs(e).toUpperCase()),"number"!=typeof t&&(t=Cs(t).toUpperCase());const i=typeof e,s=typeof t;return"string"===i&&"number"===s||("string"!==s||"number"!==i)&&o(e,t)}const bd={description:r("Strictly greater than."),args:[Nr("value1 (any)",r("The value to test as being greater than value2.")),Nr("value2 (any)",r("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return fd(e,t,((e,t)=>e>t))}},vd={description:r("Greater than or equal to."),args:[Nr("value1 (any)",r("The value to test as being greater than or equal to value2.")),Nr("value2 (any)",r("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return fd(e,t,((e,t)=>e>=t))}},Sd={description:r("Less than."),args:[Nr("value1 (any)",r("The value to test as being less than value2.")),Nr("value2 (any)",r("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!vd.compute.bind(this)(e,t)}},Cd={description:r("Less than or equal to."),args:[Nr("value1 (any)",r("The value to test as being less than or equal to value2.")),Nr("value2 (any)",r("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!bd.compute.bind(this)(e,t)}},Ed={description:r("Difference of two numbers."),args:[Nr("value1 (number)",r("The minuend, or number to be subtracted from.")),Nr("value2 (number)",r("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return ms(e,this.locale)-ms(t,this.locale)}},wd={description:r("Product of two numbers"),args:[Nr("factor1 (number)",r("The first multiplicand.")),Nr("factor2 (number)",r("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return ms(e,this.locale)*ms(t,this.locale)}},yd={description:r("Not equal."),args:[Nr("value1 (any)",r("The first value.")),Nr("value2 (any)",r("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!md.compute.bind(this)(e,t)}},xd={description:r("A number raised to a power."),args:[Nr("base (number)",r("The number to raise to the exponent power.")),Nr("exponent (number)",r("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return Qn.compute.bind(this)(e,t)}},Id={description:r("A number with the sign reversed."),args:[Nr("value (number)",r("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>e?.format,returns:["NUMBER"],compute:function(e){return-ms(e,this.locale)}},Rd={description:r("Value interpreted as a percentage."),args:[Nr("percentage (number)",r("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return ms(e,this.locale)/100}},Td={description:r("A specified number, unchanged."),args:[Nr("value (any)",r("The number to return."))],returns:["ANY"],computeFormat:e=>e?.format,compute:function(e){return null===e?"":e}};var Ad=Object.freeze({__proto__:null,ADD:hd,CONCAT:dd,DIVIDE:ud,EQ:md,GT:bd,GTE:vd,LT:Sd,LTE:Cd,MINUS:Ed,MULTIPLY:wd,NE:yd,POW:xd,UMINUS:Id,UNARY_PERCENT:Rd,UPLUS:Td});const Od=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Nd={description:r("Gets character associated with number."),args:[Nr("table_number (number)",r("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(ms(e,this.locale));return gs((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Md={description:r("Remove non-printable characters from a piece of text."),args:[Nr("text (string)",r("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=Cs(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},_d={description:r("Appends strings to one another."),args:[Nr("string1 (string, range<string>)",r("The initial string.")),Nr("string2 (string, range<string>, repeating)",r("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Os(e,((e,t)=>e+Cs(t)),"")},isExported:!0},Fd={description:r("Tests whether two strings are identical."),args:[Nr("string1 (string)",r("The first string to compare.")),Nr("string2 (string)",r("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return Cs(e)===Cs(t)},isExported:!0},Dd={description:r("First position of string found in text, case-sensitive."),args:[Nr("search_for (string)",r("The string to look for within text_to_search.")),Nr("text_to_search (string)",r("The text to search for the first occurrence of search_for.")),Nr("starting_at (number, default=1)",r("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const i=Cs(e),s=Cs(t),n=ms(o,this.locale);gs((()=>""!==s),r("The text_to_search must be non-empty.")),gs((()=>n>=1),r("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const a=s.indexOf(i,n-1);return gs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i.toString(),s)),a+1},isExported:!0},Ld={description:r("Concatenates elements of arrays with delimiter."),args:[Nr("delimiter (string)",r("The character or string to place between each concatenated value.")),Nr("value_or_array1 (string, range<string>)",r("The value or values to be appended using delimiter.")),Nr("value_or_array2 (string, range<string>, repeating)",r("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const o=Cs(e);return Os(t,((e,t)=>(e?e+o:"")+Cs(t)),"")}},Pd={description:r("Substring from beginning of specified string."),args:[Nr("text (string)",r("The string from which the left portion will be returned.")),Nr("number_of_characters (number, optional)",r("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?ms(t[0],this.locale):1;return gs((()=>o>=0),r("The number_of_characters (%s) must be positive or null.",o.toString())),Cs(e).substring(0,o)},isExported:!0},kd={description:r("Length of a string."),args:[Nr("text (string)",r("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return Cs(e).length},isExported:!0},Ud={description:r("Converts a specified string to lowercase."),args:[Nr("text (string)",r("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return Cs(e).toLowerCase()},isExported:!0},Vd={description:r("A segment of a string."),args:[Nr("text (string)",r("The string to extract a segment from.")),Nr(" (number)",r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),Nr(" (number)",r("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,o){const i=Cs(e),s=ms(t,this.locale),n=ms(o,this.locale);return gs((()=>s>=1),r("The starting_at argument (%s) must be positive greater than one.",s.toString())),gs((()=>n>=0),r("The extract_length argument (%s) must be positive or null.",n.toString())),i.slice(s-1,s+n-1)},isExported:!0},zd={description:r("Capitalizes each word in a specified string."),args:[Nr("text_to_capitalize (string)",r("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return Cs(e).replace(Od,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Bd={description:r("Replaces part of a text string with different text."),args:[Nr("text (string)",r("The text, a part of which will be replaced.")),Nr("position (number)",r("The position where the replacement will begin (starting from 1).")),Nr("length (number)",r("The number of characters in the text to be replaced.")),Nr("new_text (string)",r("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,o,i){const s=ms(t,this.locale);gs((()=>s>=1),r("The position (%s) must be greater than or equal to 1.",s.toString()));const n=Cs(e),a=ms(o,this.locale),l=Cs(i);return n.substring(0,s-1)+l+n.substring(s-1+a)},isExported:!0},Hd={description:r("A substring from the end of a specified string."),args:[Nr("text (string)",r("The string from which the right portion will be returned.")),Nr("number_of_characters (number, optional)",r("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?ms(t[0],this.locale):1;gs((()=>o>=0),r("The number_of_characters (%s) must be positive or null.",o.toString()));const i=Cs(e),s=i.length;return i.substring(s-o,s)},isExported:!0},$d={description:r("First position of string found in text, ignoring case."),args:[Nr("search_for (string)",r("The string to look for within text_to_search.")),Nr("text_to_search (string)",r("The text to search for the first occurrence of search_for.")),Nr("starting_at (number, default=1)",r("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const i=Cs(e).toLowerCase(),s=Cs(t).toLowerCase(),n=ms(o,this.locale);gs((()=>""!==s),r("The text_to_search must be non-empty.")),gs((()=>n>=1),r("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const a=s.indexOf(i,n-1);return gs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i,s)),a+1},isExported:!0},Wd={description:r("Split text by specific character delimiter(s)."),args:[Nr("text (string)",r("The text to divide.")),Nr("delimiter (string)",r("The character or characters to use to split text.")),Nr("split_by_each (boolean, default=true})",r("Whether or not to divide text around each character contained in delimiter.")),Nr("remove_empty_text (boolean, default=true)",r("Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters."))],returns:["RANGE<STRING>"],compute:function(e,t,o=true,i=true){const s=Cs(e),n=ve(Cs(t)),a=ys(o),l=ys(i);gs((()=>n.length>0),r("The _delimiter (%s) must be not be empty.",n));const c=a?new RegExp(`[${n}]`,"g"):new RegExp(n,"g");let h=s.split(c);return l&&(h=h.filter((e=>""!==e))),Qe([h])},isExported:!0},Gd={description:r("Replaces existing text with new text in a string."),args:[Nr("text_to_search (string)",r("The text within which to search and replace.")),Nr("search_for (string)",r("The string to search for within text_to_search.")),Nr("replace_with (string)",r("The string that will replace search_for.")),Nr("occurrence_number (number, optional)",r("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],returns:["NUMBER"],compute:function(e,t,o,i){const s=ms(i,this.locale);gs((()=>s>=0),r("The occurrenceNumber (%s) must be positive or null.",s.toString()));const n=Cs(e),a=Cs(t);if(""===a)return n;const l=Cs(o),c=new RegExp(ve(a),"g");if(0===s)return n.replace(c,l);let h=0;return n.replace(c,(e=>++h===s?l:e))},isExported:!0},qd={description:r("Combines text from multiple strings and/or arrays."),args:[Nr("delimiter (string)",r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),Nr("ignore_empty (boolean)",r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),Nr("text1 (string, range<string>)",r("Any text item. This could be a string, or an array of strings in a range.")),Nr("text2 (string, range<string>, repeating)",r("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...o){const i=Cs(e),s=ys(t);let r=0;return Os(o,((e,t)=>s&&""===Cs(t)?e:(r++?e+i:"")+Cs(t)),"")},isExported:!0},Zd={description:r("Removes space characters."),args:[Nr("text (string)",r("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Cs(e).trim()},isExported:!0},jd={description:r("Converts a specified string to uppercase."),args:[Nr("text (string)",r("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return Cs(e).toUpperCase()},isExported:!0},Yd={description:r("Converts a number to text according to a specified format."),args:[Nr("number (number)",r("The number, date or time to format.")),Nr("format (string)",r("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return vo(ms(e,this.locale),{format:Cs(t),locale:this.locale})},isExported:!0};var Xd=Object.freeze({__proto__:null,CHAR:Nd,CLEAN:Md,CONCATENATE:_d,EXACT:Fd,FIND:Dd,JOIN:Ld,LEFT:Pd,LEN:kd,LOWER:Ud,MID:Vd,PROPER:zd,REPLACE:Bd,RIGHT:Hd,SEARCH:$d,SPLIT:Wd,SUBSTITUTE:Gd,TEXTJOIN:qd,TRIM:Zd,UPPER:jd,TEXT:Yd});const Kd={description:r("Creates a hyperlink in a cell."),args:[Nr("url (string)",r("The full URL of the link enclosed in quotation marks.")),Nr("link_label (string, optional)",r("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const o=Cs(e).trim(),i=Cs(t)||o;return""===o?i:Pe(i,o)},isExported:!0};var Qd=Object.freeze({__proto__:null,HYPERLINK:Kd});const Jd=[{name:r("Array"),functions:cn},{name:r("Database"),functions:wl},{name:r("Date"),functions:ic},{name:r("Filter"),functions:lc},{name:r("Financial"),functions:Nh},{name:r("Info"),functions:zh},{name:r("Lookup"),functions:cd},{name:r("Logical"),functions:Kh},{name:r("Math"),functions:ba},{name:r("Misc"),functions:dn},{name:r("Operator"),functions:Ad},{name:r("Statistical"),functions:al},{name:r("Text"),functions:Xd},{name:r("Engineering"),functions:rc},{name:r("Web"),functions:Qd}],eu=/^[A-Z0-9\_\.]+$/;const tu=new class extends $i{mapping={};add(e,t){if(e=e.toUpperCase(),!eu.test(e))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=Mr(t);return function(e){let t=!1,o=!1,i=!1;for(let s of e){if(s.type.includes("META")&&s.type.length>1)throw new Error(r("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!s.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||i,n=!(s.optional||s.repeating||s.default);if(e&&n)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=s.repeating,o=s.optional,i=s.default}}(o.args),this.mapping[e]=function(...e){const t=o.compute.bind(this),i=o.computeFormat?o.computeFormat.bind(this):()=>{},s=t(...function(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>e()?.value:e.value}))}(e)),r=i(...e);if(cs(s))return{value:s,format:r};if(!cs(r))return{value:s,format:r};throw new Error("A format matrix should never be associated with a scalar value")},super.add(e,o),this}};for(let e of Jd){const t=e.functions;for(let o in t){const i=t[o];i.category=i.category||e.name,o=o.replace(/_/g,"."),tu.add(o,{isExported:!1,...i})}}class ou{scope;code="";constructor(e=new su){this.scope=e}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new iu(this.scope,this.code,e)}toString(){return ru(this.code)}}class iu{scope;returnExpression;code;constructor(e,t,o){this.scope=e,this.returnExpression=o,this.code=ru(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new ou(this.scope);return t.append(`const ${e} = () => {`),t.append(this.code),t.append(`return ${this.returnExpression};`),t.append("}"),t.return(e)}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new ou(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class su{nextId=1;declaredVariables=new Set;nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function ru(e){let t="",o=0;const i=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of i)e.startsWith("}")&&o--,t+="\t".repeat(o)+e+"\n",e.endsWith("{")&&o++;return t.trim()}const nu=["%"],au="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(nu);function lu(e,t=oo){e=ot(e);const o=new Cu(e),i=[];for(;!o.isOver();){let e=vu(o)||uu(o,t)||du(o)||gu(o)||mu(o)||cu(o)||Su(o)||pu(o,t)||bu(o);e||(e={type:"UNKNOWN",value:o.shift()}),i.push(e)}return i}function cu(e){return"?"===e.current()?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const hu={"(":"LEFT_PAREN",")":"RIGHT_PAREN"};function du(e){if(e.current()in hu){const t=e.shift();return{type:hu[t],value:t}}return null}function uu(e,t){if(e.current()===t.formulaArgSeparator){return{type:"ARG_SEPARATOR",value:e.shift()}}return null}function gu(e){for(let t of au)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:"OPERATOR",value:t};return null}function pu(e,t){const o=e.remaining().match(io(t.decimalSeparator));return o?(e.advanceBy(o[0].length),{type:"NUMBER",value:o[0]}):null}function mu(e){if('"'===e.current()){const t=e.shift();let o=t;for(;e.current()&&(e.current()!==t||"\\"===o[o.length-1]);)o+=e.shift();return'"'===e.current()&&(o+=e.shift()),{type:"STRING",value:o}}return null}const fu=/\w|\.|!|\$/;function bu(e){let t="";if("'"===e.current()){let o=e.shift();for(t+=o;e.current();)if(o=e.shift(),t+=o,"'"===o){if(!e.current()||"'"!==e.current())break;o=e.shift(),t+=o}if("'"!==o)return{type:"UNKNOWN",value:t}}for(;e.current()&&fu.test(e.current());)t+=e.shift();if(t.length){const e=t;return qo.test(e)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function vu(e){let t=0;for(;e.current()===pe;)t++,e.shift();if(t)return{type:"SPACE",value:pe.repeat(t)};for(;" "===e.current();)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function Su(e){return e.currentStartsWith(Q)?(e.advanceBy(Q.length),{type:"INVALID_REFERENCE",value:Q}):null}class Cu{text;currentIndex=0;constructor(e){this.text=e}current(){return this.text[this.currentIndex]}shift(){return this.text[this.currentIndex++]}advanceBy(e){this.currentIndex+=e}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){for(let t=0;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}}const Eu=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,wu=["-","+"],yu=["%"],xu=["*","+","&"],Iu={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Ru(e){const t=e.shift();if(!t)throw new h(he);switch(t.type){case"DEBUGGER":const o=Ou(e,1e3);return o.debug=!0,o;case"NUMBER":return{type:"NUMBER",value:ao(t.value,oo)};case"STRING":return{type:"STRING",value:be(t.value)};case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===e[0]?.value&&"REFERENCE"===e[1]?.type){e.shift();const o=e.shift();return{type:"REFERENCE",value:`${t.value}:${o?.value}`}}return{type:"REFERENCE",value:t.value};case"SYMBOL":const i=t.value;if("LEFT_PAREN"===e[0]?.type&&Eu.test(t.value)){const t=function(e){Au(e,"LEFT_PAREN",r("Missing opening parenthesis"));const t=e[0];if("RIGHT_PAREN"===t?.type)return Au(e,"RIGHT_PAREN"),[];const o=[];o.push(Tu(e));for(;"RIGHT_PAREN"!==e[0]?.type;)Au(e,"ARG_SEPARATOR",r("Wrong function call")),o.push(Tu(e));return Au(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:i,args:t}}const s=i.toUpperCase();if("TRUE"===s||"FALSE"===s)return{type:"BOOLEAN",value:"TRUE"===s};throw new h(r("Invalid formula"));case"LEFT_PAREN":const n=Ou(e);return Au(e,"RIGHT_PAREN",r("Missing closing parenthesis")),n;case"OPERATOR":const a=t.value;if(wu.includes(a))return{type:"UNARY_OPERATION",value:a,operand:Ou(e,Iu[a])};throw new h(r("Unexpected token: %s",t.value));default:throw new h(r("Unexpected token: %s",t.value))}}function Tu(e){const t=e[0];return"ARG_SEPARATOR"===t?.type||"RIGHT_PAREN"===t?.type?{type:"EMPTY",value:""}:Ou(e)}function Au(e,t,o=he){const i=e.shift();if(!i||i.type!==t)throw new h(o)}function Ou(e,t=0){if(0===e.length)throw new h(he);let o=Ru(e);for(;"OPERATOR"===e[0]?.type&&Iu[e[0].value]>t;){const t=e.shift().value;if(yu.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:Ou(e,Iu[t])}}}return o}function Nu(e){return Mu(lu(e))}function Mu(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=Ou(e);if(e.length)throw new h(he);return t}function _u(e,t,o){return Lu(e,(e=>e.type===t?o(e):e))}function Fu(e){return Array.from(Du(e))}function*Du(e){switch(yield e,e.type){case"FUNCALL":for(const t of e.args)yield*Du(t);break;case"UNARY_OPERATION":yield*Du(e.operand);break;case"BIN_OPERATION":yield*Du(e.left),yield*Du(e.right)}}function Lu(e,t){switch((e=t(e)).type){case"FUNCALL":return{...e,args:e.args.map((e=>Lu(e,t)))};case"UNARY_OPERATION":return{...e,operand:Lu(e.operand,t)};case"BIN_OPERATION":return{...e,right:Lu(e.right,t),left:Lu(e.left,t)};default:return e}}function Pu(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>Pu(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?ku(e)+e.value:e.value+Uu(e);case"BIN_OPERATION":return ku(e)+e.value+Uu(e)}}function ku(e){const t=e.value,o="left"in e?e.left:e.operand,i=o.value;return"BIN_OPERATION"===o.type&&Iu[i]<Iu[t]?`(${Pu(o)})`:Pu(o)}function Uu(e){const t=e.value,o="right"in e?e.right:e.operand,i=Iu[o.value],s=Iu[t];let r=!1;return"BIN_OPERATION"!==o.type?r=!1:i<s?r=!0:i!==s||xu.includes(t)||(r=!0),r?`(${Pu(o)})`:Pu(o)}var Vu;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(Vu||(Vu={}));const zu=(e,t=(()=>!0))=>[{goTo:e,guard:t}],Bu=(e,t=(()=>!0))=>({goTo:e,guard:t}),Hu={[Vu.LeftRef]:{REFERENCE:zu(Vu.Separator),NUMBER:zu(Vu.FullRowSeparator),SYMBOL:[Bu(Vu.FullColumnSeparator,(e=>Zo(e.value))),Bu(Vu.FullRowSeparator,(e=>jo(e.value)))]},[Vu.FullColumnSeparator]:{SPACE:zu(Vu.FullColumnSeparator),OPERATOR:zu(Vu.RightColumnRef,(e=>":"===e.value))},[Vu.FullRowSeparator]:{SPACE:zu(Vu.FullRowSeparator),OPERATOR:zu(Vu.RightRowRef,(e=>":"===e.value))},[Vu.Separator]:{SPACE:zu(Vu.Separator),OPERATOR:zu(Vu.RightRef,(e=>":"===e.value))},[Vu.RightRef]:{SPACE:zu(Vu.RightRef),NUMBER:zu(Vu.Found),REFERENCE:zu(Vu.Found,(e=>Xo(e.value))),SYMBOL:zu(Vu.Found,(e=>Yo(e.value)))},[Vu.RightColumnRef]:{SPACE:zu(Vu.RightColumnRef),SYMBOL:zu(Vu.Found,(e=>Yo(e.value))),REFERENCE:zu(Vu.Found,(e=>Xo(e.value)))},[Vu.RightRowRef]:{SPACE:zu(Vu.RightRowRef),NUMBER:zu(Vu.Found),REFERENCE:zu(Vu.Found,(e=>Xo(e.value)))},[Vu.Found]:{}};function $u(e){let t=0,o=Hu[Vu.LeftRef];const i=[];for(;void 0!==o;){const s=e[t++];if(!s)return null;const r=o[s.type]?.find((e=>e.guard(s))),n=r?r.goTo:void 0;switch(n){case void 0:return null;case Vu.Found:return i.push(s),e.splice(0,t),{type:"REFERENCE",value:Ge(i.map((e=>e.value)))};default:o=Hu[n],i.push(s)}}return null}function Wu(e,t=oo){const o=lu(e,t),i=[];for(;o.length;)i.push($u(o)||o.shift());return i}const Gu=tu.content,qu={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Zu={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},ju={};function Yu(e){const t=Wu(e),{dependencies:o,constantValues:i}=function(e){const t={numbers:[],strings:[]},o=[];for(const i of e)switch(i.type){case"INVALID_REFERENCE":case"REFERENCE":o.push(i.value);break;case"STRING":const e=be(i.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=ao(i.value,oo);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:o,constantValues:t}}(t),s=function(e,t,o){return Ge(e.map((e=>{switch(e.type){case"STRING":const i=be(e.value);return`|S${o.strings.indexOf(i)}|`;case"NUMBER":return`|N${o.numbers.indexOf(ao(e.value,oo))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,o,i);if(!ju[s]){const n=Mu([...t]),a=new su;if("BIN_OPERATION"===n.type&&":"===n.value)throw new h(r("Invalid formula"));if("EMPTY"===n.type)throw new h(r("Invalid formula"));const l=g(n),c=new ou;c.append(`// ${s}`),c.append(l),c.append(`return ${l.returnExpression};`);let d=new Function("deps","ref","range","ctx",c.toString());function u(e){const{args:t}=e,o=e.value.toUpperCase(),i=Gu[o];if(!i)throw new p(e.value);!function(e){const t=e.args.length,o=e.value.toUpperCase(),i=Gu[o];if(t<i.minArgRequired)throw new h(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",o,i.minArgRequired.toString(),t.toString()));if(t>i.maxArgPossible)throw new h(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",o,i.maxArgPossible.toString(),t.toString()));const s=i.nbrArgRepeating;if(s>1){const e=i.args.length-s;if((t-e)%s!=0)throw new h(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",o,e.toString(),s.toString()))}}(e);const s=[];for(let e=0;e<t.length;e++){const n=i.getArgToFocus(e+1)-1,a=i.args[n],l=t[e],c=a.type||[],d=c.includes("META"),u=a.lazy,p=c.some((e=>Xu(e))),m=c.every((e=>Xu(e)));if(m&&!Ku(l))throw new h(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",o,(e+1).toString(),l.type.toLowerCase()));const f=g(l,d,p,{functionName:o,paramIndex:e+1});s.push(u?f.wrapInClosure():f)}return s}function g(e,t=!1,s=!1,n={}){const l=new ou(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new h(r("Argument must be a reference to a cell or range."));switch(e.debug&&l.append("debugger;"),e.type){case"BOOLEAN":return l.return(`{ value: ${e.value} }`);case"NUMBER":return l.return(`{ value: this.constantValues.numbers[${i.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${i.strings.indexOf(e.value)}] }`);case"REFERENCE":const r=o.indexOf(e.value);return s?l.return(`range(deps[${r}])`):l.return(`ref(deps[${r}], ${t?"true":"false"}, "${n.functionName||qu["="]}", ${n.paramIndex})`);case"FUNCALL":const a=u(e).map((e=>e.assignResultToVariable()));l.append(...a);const c=e.value.toUpperCase();return l.append(`ctx.__lastFnCalled = '${c}';`),l.return(`ctx['${c}'](${a.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=Zu[e.value],o=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${o.returnExpression})`)}case"BIN_OPERATION":{const t=qu[e.value],o=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),i=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(o),l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${o.returnExpression}, ${i.returnExpression})`)}case"EMPTY":return l.return("undefined")}}ju[s]={execute:d}}return{execute:ju[s].execute,dependencies:o,constantValues:i,tokens:t}}function Xu(e){return e.startsWith("RANGE")}function Ku(e){if("REFERENCE"===e.type)return!0;if("FUNCALL"===e.type){const t=Gu[e.value.toUpperCase()];return t&&Xu(t.returns[0])}return!1}function Qu(e,t){return function(e){let t=[],o="";return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"SYMBOL":o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0}),o="";break;case"RIGHT_PAREN":t.pop();break;case"ARG_SEPARATOR":t.length&&t[t.length-1].argPosition++}if(t.length){const o=t[t.length-1];o.parent&&(e.functionContext=Object.assign({},o))}return e}))}(function(e){let t=1;const o=[];return e.map((e=>("LEFT_PAREN"===e.type?(o.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=o.pop()),e)))}(function(e){let t=0;return e.map((e=>{const o=e.value.toString().length,i=Object.assign({},e,{start:t,end:t+o,length:o});return t=i.end,i}))}(Wu(e,t))))}const Ju=tu.content;function eg(e){try{return 0===Fu(Mu(e)).filter((e=>"FUNCALL"===e.type&&!Ju[e.value.toUpperCase()]?.isExported)).length}catch(e){return!1}}function tg(e){if(!e||"object"!=typeof e||"string"!=typeof e.name||"string"!=typeof e.code||"string"!=typeof e.thousandsSeparator||"string"!=typeof e.decimalSeparator||"string"!=typeof e.dateFormat||"string"!=typeof e.timeFormat||"string"!=typeof e.formulaArgSeparator)return!1;if(!Object.values(e).every((e=>e)))return!1;if(e.formulaArgSeparator===e.decimalSeparator)return!1;try{vo(1,{locale:e,format:"#,##0.00"}),vo(1,{locale:e,format:e.dateFormat}),vo(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function og(e,t){return e.startsWith("=")?function(e,t){return rg(e,t,oo)}(e,t):ng(e,t)}function ig(e,t){return e.startsWith("=")?sg(e,t):function(e,t){if("."===t.decimalSeparator||!ro(e,oo))return e;const o=No(oo),i=e.replace(o,(e=>e.replace(".",t.decimalSeparator)));return i}(e,t)}function sg(e,t){return rg(e,oo,t)}function rg(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const i=lu(e,t);let s="";for(const e of i)"NUMBER"===e.type?s+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?s+=o.formulaArgSeparator:s+=e.value;return s}function ng(e,t){return"."!==t.decimalSeparator&&ro(e,t)?e.replace(t.decimalSeparator,"."):e}function ag(e,t){return cg(e,(e=>og(e,t)))}function lg(e,t){return cg(e,(e=>ig(e,t)))}function cg(e,t){switch((e=Se(e)).type){case"CellIsRule":switch(e.operator){case"Between":case"NotBetween":case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return e.values=e.values.map((e=>t(e))),e;case"BeginsWith":case"ContainsText":case"EndsWith":case"NotContains":case"IsEmpty":case"IsNotEmpty":return e}break;case"ColorScaleRule":return e.minimum=hg(e.minimum,t),e.maximum=hg(e.maximum,t),e.midpoint&&(e.midpoint=hg(e.midpoint,t)),e;case"IconSetRule":return e.lowerInflectionPoint.value=t(e.lowerInflectionPoint.value),e.upperInflectionPoint.value=t(e.upperInflectionPoint.value),e}}function hg(e,t){if(!e?.value)return e;const o=t("formula"===e.type?"="+e.value:e.value),i="formula"===e.type?o.slice(1):o;return{...e,value:i}}const dg={name:r("Link sheet"),children:[e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map((e=>({id:e.id,name:e.name,execute:()=>Pe(e.name,ze(e.id))})))]},ug={name:r("Delete"),isVisible:e=>e.model.getters.getSheetIds().length>1,execute:e=>e.askConfirmation(r("Are you sure you want to delete this sheet?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))},gg={name:r("Duplicate"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}},pg=e=>({name:r("Rename"),execute:e.renameSheetCallback}),mg={name:r("Move right"),isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getVisibleSheetIds();return o.indexOf(t)!==o.length-1},execute:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:1})},fg={name:r("Move left"),isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},execute:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:-1})},bg={name:r("Hide sheet"),isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,execute:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})};function vg(e){return e.map(Cg).sort(((e,t)=>e.sequence-t.sequence))}const Sg=new Ni;function Cg(e){const t=e.name,o=e.children;return{id:e.id||Sg.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,isActive:e.isActive,execute:e.execute,children:o?e=>o.map((t=>"function"==typeof t?t(e):t)).flat().map(Cg):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon||"",description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class Eg extends $i{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,o){"function"!=typeof o&&void 0===o.id&&(o.id=e);const i=t.splice(0,1)[0];let s=this.content[i];if(!s)throw new Error(`Path ${i+":"+t.join(":")} not found`);for(let e of t){const o=s.children;if(!o||"function"==typeof o)throw new Error(`${e} is either not a node or it's dynamically computed`);if(s=o.find((t=>t.id===e)),!s)throw new Error(`Path ${i+":"+t.join(":")} not found`)}return s.children||(s.children=[]),s.children.push(o),this}getMenuItems(){return vg(this.getAll())}}const wg=new Eg;wg.add("sheet",{...dg,sequence:10});Di`
274
274
  .o-link-editor {
275
275
  font-size: 13px;
276
276
  background-color: white;
@@ -343,13 +343,13 @@
343
343
  }
344
344
  }
345
345
  }
346
- `;class bg extends t.Component{static template="o-spreadsheet-LinkEditor";static components={Menu:Ir};menuItems=fg.getMenuItems();link=t.useState(this.defaultState);menu=t.useState({isOpen:!1});linkEditorRef=t.useRef("linkEditor");position=br(this.linkEditorRef);urlInput=t.useRef("urlInput");setup(){t.onMounted((()=>this.urlInput.el?.focus()))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t});return i.link?{url:i.link.url,label:i.formattedValue,isUrlEditable:i.link.isUrlEditable}:{label:i.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,o=Ki(t);o&&(this.link.url=o.url,this.link.label=o.label,this.link.isUrlEditable=o.isUrlEditable)}getUrlRepresentation(e){return Yi(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getLocale(),i=this.link.label?Xu(this.link.label,o):this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:e,row:t,sheetId:this.env.model.getters.getActiveSheetId(),content:Pe(i,this.link.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}const vg={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:bg,cellCorner:"BottomLeft"})};bg.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Sg=new $i;function Cg(e){return 8===(e=ht(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}Sg.add("ErrorToolTip",ar).add("LinkCell",Tr).add("LinkEditor",vg).add("FilterMenu",dr);class Eg{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function wg(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?ri(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?oi(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function yg(e,t,o,i){let s=!1;const r=[];for(let i in o){let n=o[i];if(n.labelCell){const e=Rg(n.labelCell,t);n.labelCell!==e&&(s=!0,n={...n,labelCell:e})}const a=Rg(n.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Q?(s=!0,n=void 0):a!==n.dataRange&&(s=!0,n={...n,dataRange:a}),r[i]=n}let n=i;const a=Rg(n,t);a!==n&&(s=!0,n=a);return{isStale:s,dataSets:r.filter(He),labelRange:n}}function xg(e,t,o){return o.map((o=>({dataRange:Ri(e,t,o.dataRange),labelCell:o.labelCell?Ri(e,t,o.labelCell):void 0})))}function Ig(e,t,o){return o?Ri(e,t,o):void 0}function Rg(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Tg(e,t,o,i){const s=[];for(const r of t){const t=e.getRangeFromSheetXC(o,r),{unboundedZone:n,sheetId:a,invalidSheetName:l,invalidXc:c}=t;if(!l&&!c)if(n.left!==n.right&&n.top!==n.bottom){if(void 0===n.right)continue;for(let t=n.left;t<=n.right;t++){const o={...n,left:t,right:t};s.push(Ag(e,a,o,i?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else n.left===n.right&&n.top===n.bottom?i||s.push(Ag(e,a,n,void 0)):s.push(Ag(e,a,n,i?{top:n.top,bottom:n.top,left:n.left,right:n.left}:void 0))}return s}function Ag(e,t,o,i){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${ti(o)}`);if(i){const s=ti(o),r=ti(i);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,s)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,ti(o))}}function Og(e,t){const o=t.labelCell?.zone;let i=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=pi(i);1===e?i={...i,left:i.left+1}:1===t&&(i={...i,top:i.top+1})}const s=t.dataRange.clone({zone:i});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function Ng(e,t,o){if(!t)return;let i={...t.zone};o&&t.zone.bottom>t.zone.top&&(i.top=i.top+1);const s=t.clone({zone:i});return e.getRangeString(s,"forceSheetReference")}function Mg(e,t){let o;if(e.labelRange){const i=wg(Qo(e.labelRange),t);o=i?ti(i):void 0}const i=e.dataSets.map(Qo).map((e=>wg(e,t))).filter(He).map(ti);return{...e,labelRange:o,dataSets:i}}const _g=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Fg{graphColorIndex=0;next(){return _g[this.graphColorIndex++%_g.length]}}function Dg(e){return e&&pt(e)<.3?"#FFFFFF":"#000000"}function Lg(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!qo.test(e)));if(t)return 33;if(e.dataSets.map(Qo).some((e=>e.top!==e.bottom&&wi(e))))return 33}return 0}function Pg(e){if(e.labelRange){if(!qo.test(e.labelRange||""))return 34}return 0}function kg(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const i=yi(t.dataRange.zone);return!(yi(e.zone)<i)}function Ug(e,t,o,i){if(e){if("text"===o||t?.type!==Qi.number||e.type!==Qi.number)return e.formattedValue;{let s=t.value-e.value;if("percentage"===o&&0!==s&&(s=s/e.value*100),"percentage"!==o&&e.format)return vo(s,{format:e.format,locale:i});const r=Math.abs(parseFloat(s.toFixed(2))).toLocaleString();return"percentage"===o?r+"%":r}}return""}function Vg(e,t,o,i,s){if("text"===t||e?.type!==Qi.number||o?.type!==Qi.number)return;const r=o.value-e.value;return r>0?i:r<0?s:void 0}function zg(e,t,o){if("text"===o||e?.type!==Qi.number||t?.type!==Qi.number)return"neutral";const i=t.value-e.value;return i>0?"up":i<0?"down":"neutral"}const Bg={Errors:{26:r("The range is invalid"),52:r("The argument is missing. Please provide a value"),53:r("The second argument is missing. Please provide a value"),54:r("The minpoint must be a number"),55:r("The midpoint must be a number"),56:r("The maxpoint must be a number"),57:r("The first value must be a number"),58:r("The second value must be a number"),48:r("Minimum must be smaller then Maximum"),51:r("Minimum must be smaller then Midpoint"),50:r("Midpoint must be smaller then Maximum"),49:r("Lower inflection point must be smaller than upper inflection point"),59:r("Invalid Minpoint formula"),61:r("Invalid Maxpoint formula"),60:r("Invalid Midpoint formula"),62:r("Invalid upper inflection point formula"),63:r("Invalid lower inflection point formula"),25:r("A range needs to be defined"),Unexpected:r("The rule is invalid for an unknown reason")},ColorScale:r("Color scale"),IconSet:r("Icon set")},Hg={IsEmpty:r("Is empty"),IsNotEmpty:r("Is not empty"),ContainsText:r("Contains"),NotContains:r("Does not contain"),BeginsWith:r("Starts with"),EndsWith:r("Ends with"),Equal:r("Is equal to"),NotEqual:r("Is not equal to"),GreaterThan:r("Is greater than"),GreaterThanOrEqual:r("Is greater than or equal to"),LessThan:r("Is less than"),LessThanOrEqual:r("Is less than or equal to"),Between:r("Is between"),NotBetween:r("Is not between")},$g={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),33:r("The dataset is invalid"),34:r("Labels are invalid"),35:r("The key value is invalid"),36:r("The baseline value is invalid"),37:r("The data range is invalid"),38:r("A minimum range limit value is needed"),39:r("The minimum range limit value must be a number"),40:r("A maximum range limit value is needed"),41:r("The maximum range limit value must be a number"),42:r("Minimum range limit must be smaller than maximum range limit"),43:r("The lower inflection point value must be a number"),44:r("The upper inflection point value must be a number")}},Wg={Custom:r("Custom")},Gg=r("Merged cells are preventing this operation. Unmerge those cells and try again."),qg={Errors:{Unexpected:r("Cannot split the selection for an unknown reason"),92:r("There is no match for the selected separator in the selection"),89:r("Only a selection from a single column can be split"),91:r("Splitting will overwrite existing content")}};function Zg(e,t){if(t.dataRange){const o=t.labelCell?[ti(t.labelCell.zone)]:[],i=ui([ti(t.dataRange.zone)],o)[0];if(void 0===i)return[];const s=e.getRangeFromSheetXC(t.dataRange.sheetId,i);return e.getRangeValues(s).map((e=>""===e?void 0:e))}return[]}function jg(e,t){const o=Oe(0,Math.max(e.length,...t.map((e=>e.data?.length||0)))).filter((o=>{const i=e[o],s=t.map((e=>e.data?.[o]));return i||s.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function Yg(e,t){const o=new Set(e),i={};o.forEach((e=>{i[e]=new Array(t.length).fill(0)}));for(const o of Oe(0,e.length)){const r=e[o];for(const e of Oe(0,t.length))i[r][e]+="number"==typeof(s=t[e].data[o])?s:0}var s;return{labels:Object.keys(i),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(i).map((e=>e[t]))})))}}function Xg(e){return e?e.length>te?e.substring(0,te)+"…":e:""}function Kg(e,t,o,{format:i,locale:r}){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:s(e.title),fontColor:o},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){let o=t.datasets?.[e.datasetIndex||0]?.label;const s=""!==e.yLabel?e.yLabel:t.datasets?.[e.datasetIndex||0]?.data?.[e.index||0],n=i&&"number"==typeof s?vo(s,{format:i,locale:r}):s?.toLocaleString()||"";return o?`${o}: ${n}`:n}}}},data:{labels:t.map(Xg),datasets:[]}}}function Qg(e,t,o){let i={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(i={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e)))});else if(1===t.length)for(let o=0;o<Zg(e,t[0]).length;o++)i.formattedValues.push(""),i.values.push("");else if(t[0]){i={formattedValues:Oe(0,Zg(e,t[0]).length).map((e=>e.toString())),values:i.formattedValues}}return i}function Jg(e,t){for(const o of t){const t=e.getRangeFormats(o.dataRange).find((e=>void 0!==e&&!Io(e)));if(t)return t}}function ep(e,t){const o=[];for(const[i,s]of Object.entries(t)){let t;if(s.labelCell){const o=s.labelCell,r=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=r&&o?Xg(r.formattedValue):t=`${$g.Series} ${parseInt(i)+1}`}else t=t=`${$g.Series} ${parseInt(i)+1}`;let r=s.dataRange?Zg(e,s):[];o.push({data:r,label:t})}return o}function tp(e){return 0===e?"origin":e-1}class op extends Eg{dataSets;labelRange;background;verticalAxisPosition;legendPosition;stacked;aggregated;type="bar";dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Tg(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return Mg(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Lg,Pg)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=xg(this.sheetId,e,this.dataSets),o=Ig(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new op(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new op(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Og(this.getters,e))).filter((e=>""!==e.range)),t=Ng(this.getters,this.labelRange,kg(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:Cg(this.background||w),fontColor:Cg(Dg(this.background)),dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=yg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new op(s,this.sheetId,this.getters)}}function ip(e){return e.dataRange&&!qo.test(e.dataRange)?37:0}function sp(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function rp(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?42:0}function np(e,t){if(""===e)switch(t){case"rangeMin":return 38;case"rangeMax":return 40}return 0}function ap(e,t){if(isNaN(e))switch(t){case"rangeMin":return 39;case"rangeMax":return 41;case"lowerInflectionPointValue":return 43;case"upperInflectionPointValue":return 44}return 0}class lp extends Eg{dataRange;sectionRule;background;type="gauge";constructor(e,t,o){super(e,t,o),this.dataRange=Ti(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,ip,e.chainValidations(sp(np,e.batchValidations),sp(ap,e.batchValidations),rp),e.chainValidations((o=ap,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=wg(Qo(e.dataRange),t)),{...e,dataRange:o?ti(o):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=Ig(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new lp(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new lp(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=Rg(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new lp(o,this.sheetId,this.getters)}}const cp={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},hp={inSeconds:function(e){return Math.floor(e/cp.second)},inMinutes:function(e){return Math.floor(e/cp.minute)},inHours:function(e){return Math.floor(e/cp.hour)},inDays:function(e){return Math.floor(e/cp.day)},inMonths:function(e){return Math.floor(e/cp.month)},inYears:function(e){return Math.floor(e/cp.year)}},dp=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function up(e,t,o){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),s=function(e,t,o){const i=e.map((e=>zt(e,o)?.jsDate));if(i.some((e=>void 0===e))||e.length<2)return;const s=i.map((e=>e.getTime())),r=Math.max(...s)-Math.min(...s),n=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(cp.second>=cp[n]&&hp.inSeconds(r)<180)return"second";if(cp.minute>=cp[n]&&hp.inMinutes(r)<180)return"minute";if(cp.hour>=cp[n]&&hp.inHours(r)<96)return"hour";if(cp.day>=cp[n]&&hp.inDays(r)<90)return"day";if(cp.month>=cp[n]&&hp.inMonths(r)<36)return"month";return"year"}(e,i,o),r={};return s&&(r[s]=i),{parser:i,displayFormats:r,unit:s}}class gp extends Eg{dataSets;labelRange;background;verticalAxisPosition;legendPosition;labelsAsText;stacked;aggregated;type="line";dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Tg(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static validateChartDefinition(e,t){return e.checkValidations(t,Lg,Pg)}static transformDefinition(e,t){return Mg(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=yg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new gp(s,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Og(this.getters,e))).filter((e=>""!==e.range)),t=Ng(this.getters,this.labelRange,kg(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:Cg(this.background||w),fontColor:Cg(Dg(this.background)),dataSets:e,labelRange:t}}copyForSheetId(e){const t=xg(this.sheetId,e,this.dataSets),o=Ig(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new gp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new gp(t,e,this.getters)}}function pp(e,t){return fp(e,t)||bp(e,t)}function mp(e,t){return function(e,t){return!e.labelsAsText&&fp(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&bp(e.labelRange,t)}(e,t)?"linear":"category"}function fp(e,t){if(!e||!bp(e,t))return!1;const o=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(o&&dp.test(o))}function bp(e,t){if(!e)return!1;const o=t.getRangeValues(e);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}class vp extends Eg{dataSets;labelRange;background;legendPosition;type="pie";aggregated;dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Tg(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return Mg(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Lg,Pg)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=xg(this.sheetId,e,this.dataSets),o=Ig(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new vp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new vp(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Og(this.getters,e))).filter((e=>""!==e.range)),t=Ng(this.getters,this.labelRange,kg(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:Cg(this.background||w),fontColor:Cg(Dg(this.background)),verticalAxisPosition:"left",dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=yg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new vp(s,this.sheetId,this.getters)}}function Sp(e,t){const o=[],i=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=i;t++)o.push(e.next());return o}function Cp(e){return e.keyValue&&!qo.test(e.keyValue)?35:0}function Ep(e){return e.baseline&&!qo.test(e.baseline)?36:0}class wp extends Eg{keyValue;baseline;baselineMode;baselineDescr;background;baselineColorUp;baselineColorDown;fontColor;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=Ti(o,t,e.keyValue),this.baseline=Ti(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Cp,Ep)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:ie,baselineColorUp:se,baselineColorDown:re,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,i;return e.baseline&&(o=wg(Qo(e.baseline),t)),e.keyValue&&(i=wg(Qo(e.keyValue),t)),{...e,baseline:o?ti(o):void 0,keyValue:i?ti(i):void 0}}copyForSheetId(e){const t=Ig(this.sheetId,e,this.baseline),o=Ig(this.sheetId,e,this.keyValue),i=this.getDefinitionWithSpecificRanges(t,o,e);return new wp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new wp(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=Rg(this.baseline,e),o=Rg(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const i=this.getDefinitionWithSpecificRanges(t,o);return new wp(i,this.sheetId,this.getters)}}const yp=new $i;yp.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new op(e,t,o),getChartRuntime:function(e,t){let o=Qg(t,e.dataSets,e.labelRange).formattedValues,i=ep(t,e.dataSets);e.dataSetsHaveTitle&&i[0]&&o.length>i[0].data.length&&o.shift(),({labels:o,dataSetsValues:i}=jg(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=Yg(o,i));const s=function(e,t,o){const i=Dg(e.background),s=Kg(e,t,i,o),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0,callback:e=>o.format?vo(e,o):e?.toLocaleString()||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,o,{format:Jg(t,e.dataSets),locale:t.getLocale()}),r=new Fg;for(let{label:e,data:t}of i){const o=r.next(),i={label:e,data:t,borderColor:o,backgroundColor:o};s.data.datasets.push(i)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>op.validateChartDefinition(e,t),transformDefinition:(e,t)=>op.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>op.getDefinitionFromContextCreation(e),name:r("Bar"),sequence:10}),yp.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new gp(e,t,o),getChartRuntime:function(e,t){const o=mp(e,t),i=Qg(t,e.dataSets,e.labelRange);let s="linear"===o?i.values:i.formattedValues,r=ep(t,e.dataSets);e.dataSetsHaveTitle&&r[0]&&s.length>r[0].data.length&&s.shift(),({labels:s,dataSetsValues:r}=jg(s,r)),"time"===o&&({labels:s,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],i=Se(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=Ze(o,e);for(let t of i)t.data[e]=void 0}return{labels:o,dataSetsValues:i}}(s,r)),e.aggregated&&({labels:s,dataSetsValues:r}=Yg(s,r));const n=t.getLocale(),a={format:Jg(t,e.dataSets),locale:n},l=function(e,t,o){const i=Dg(e.background),s=Kg(e,t,i,o),r={labels:{fontColor:i,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,i]of o.entries())i.fillStyle=t.datasets[e].borderColor;return o}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0,callback:e=>o.format?vo(e,o):e?.toLocaleString()||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,s,a),c=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===o?(l.options.scales.xAxes[0].type="time",l.options.scales.xAxes[0].time=up(s,c,n),l.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(l.options.scales.xAxes[0].type="linear",l.options.scales.xAxes[0].ticks.callback=e=>vo(e,a),l.options.tooltips.callbacks.title=e=>vo(e[0]?.xLabel||"",a));const h=new Fg;for(let[t,{label:i,data:n}]of r.entries()){["linear","time"].includes(o)&&(n=n.map(((e,t)=>({x:s[t]||void 0,y:e}))));const r=h.next();let a=ft(r);e.stacked&&(a.a=ne);const c={label:i,data:n,lineTension:0,borderColor:r,backgroundColor:mt(a),pointBackgroundColor:r,fill:!!e.stacked&&tp(t)};l.data.datasets.push(c)}return{chartJsConfig:l,background:e.background||w}},validateChartDefinition:(e,t)=>gp.validateChartDefinition(e,t),transformDefinition:(e,t)=>gp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>gp.getDefinitionFromContextCreation(e),name:r("Line"),sequence:20}),yp.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new vp(e,t,o),getChartRuntime:function(e,t){let o=Qg(t,e.dataSets,e.labelRange).formattedValues,i=ep(t,e.dataSets);e.dataSetsHaveTitle&&i[0]&&o.length>i[0].data.length&&o.shift(),({labels:o,dataSetsValues:i}=jg(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=Yg(o,i));const s=function(e,t,o){const i=Dg(e.background),s=Kg(e,t,i,o),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,o,{format:Jg(t,e.dataSets),locale:t.getLocale()}),r=new Fg;for(let{label:e,data:t}of i){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Sp(r,i)};s.data.datasets.push(o)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>vp.validateChartDefinition(e,t),transformDefinition:(e,t)=>vp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>vp.getDefinitionFromContextCreation(e),name:r("Pie"),sequence:30}),yp.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new wp(e,t,o),getChartRuntime:function(e,t){let o,i,r="",n="";if(e.keyValue){const i={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(i),r=String(o.value),n=o.formattedValue}const a=e.baseline;if(a){const o={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};i=t.getEvaluatedCell(o)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue),c=t.getLocale();return{title:s(e.title),keyValue:n||r,baselineDisplay:Ug(i,o,e.baselineMode,c),baselineArrow:zg(i,o,e.baselineMode),baselineColor:Vg(i,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?s(e.baselineDescr):"",fontColor:Dg(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>wp.validateChartDefinition(e,t),transformDefinition:(e,t)=>wp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>wp.getDefinitionFromContextCreation(e),name:r("Scorecard"),sequence:40}),yp.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new lp(e,t,o),getChartRuntime:function(e,t){const o=function(e,t){const o=Kg(e,[],Dg(e.background),{locale:t});return o.options.hover=void 0,o.options.events=[],o.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},o.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},o.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},o}(e,t.getLocale()),i=e.sectionRule.colors,s=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,n=Number(s.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==s.value){const e="number"===s.type?n:l+h*n/100;d.push({value:we(e,l,c),color:i.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:we(e,l,c),color:i.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(i.upperColor);const p=e.dataRange,m=h/30;let f=l-m,b=null,v=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===Qi.number&&(f=we(e.value,l-m,c+m),b=()=>t.getRangeFormattedValues(p)[0],v=!0)}return o.options.valueLabel.display=v,o.options.valueLabel.formatter=b,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:o,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>lp.validateChartDefinition(e,t),transformDefinition:(e,t)=>lp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>lp.getDefinitionFromContextCreation(e),name:r("Gauge"),sequence:50});const xp=new $i;xp.add("line",Mi),xp.add("bar",Mi),xp.add("pie",Mi),xp.add("gauge",Mi),xp.add("scorecard",zi);const Ip=new $i;Di`
346
+ `;class yg extends t.Component{static template="o-spreadsheet-LinkEditor";static components={Menu:Ir};menuItems=wg.getMenuItems();link=t.useState(this.defaultState);menu=t.useState({isOpen:!1});linkEditorRef=t.useRef("linkEditor");position=br(this.linkEditorRef);urlInput=t.useRef("urlInput");setup(){t.onMounted((()=>this.urlInput.el?.focus()))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t});return i.link?{url:i.link.url,label:i.formattedValue,isUrlEditable:i.link.isUrlEditable}:{label:i.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,o=Ki(t);o&&(this.link.url=o.url,this.link.label=o.label,this.link.isUrlEditable=o.isUrlEditable)}getUrlRepresentation(e){return Yi(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getLocale(),i=this.link.label?og(this.link.label,o):this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:e,row:t,sheetId:this.env.model.getters.getActiveSheetId(),content:Pe(i,this.link.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}const xg={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:yg,cellCorner:"BottomLeft"})};yg.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Ig=new $i;function Rg(e){return 8===(e=ht(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}Ig.add("ErrorToolTip",ar).add("LinkCell",Tr).add("LinkEditor",xg).add("FilterMenu",dr);class Tg{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function Ag(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?ri(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?oi(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Og(e,t,o,i){let s=!1;const r=[];for(let i in o){let n=o[i];if(n.labelCell){const e=_g(n.labelCell,t);n.labelCell!==e&&(s=!0,n={...n,labelCell:e})}const a=_g(n.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Q?(s=!0,n=void 0):a!==n.dataRange&&(s=!0,n={...n,dataRange:a}),r[i]=n}let n=i;const a=_g(n,t);a!==n&&(s=!0,n=a);return{isStale:s,dataSets:r.filter(He),labelRange:n}}function Ng(e,t,o){return o.map((o=>({dataRange:Ri(e,t,o.dataRange),labelCell:o.labelCell?Ri(e,t,o.labelCell):void 0})))}function Mg(e,t,o){return o?Ri(e,t,o):void 0}function _g(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Fg(e,t,o,i){const s=[];for(const r of t){const t=e.getRangeFromSheetXC(o,r),{unboundedZone:n,sheetId:a,invalidSheetName:l,invalidXc:c}=t;if(!l&&!c)if(n.left!==n.right&&n.top!==n.bottom){if(void 0===n.right)continue;for(let t=n.left;t<=n.right;t++){const o={...n,left:t,right:t};s.push(Dg(e,a,o,i?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else n.left===n.right&&n.top===n.bottom?i||s.push(Dg(e,a,n,void 0)):s.push(Dg(e,a,n,i?{top:n.top,bottom:n.top,left:n.left,right:n.left}:void 0))}return s}function Dg(e,t,o,i){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${ti(o)}`);if(i){const s=ti(o),r=ti(i);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,s)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,ti(o))}}function Lg(e,t){const o=t.labelCell?.zone;let i=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=pi(i);1===e?i={...i,left:i.left+1}:1===t&&(i={...i,top:i.top+1})}const s=t.dataRange.clone({zone:i});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function Pg(e,t,o){if(!t)return;let i={...t.zone};o&&t.zone.bottom>t.zone.top&&(i.top=i.top+1);const s=t.clone({zone:i});return e.getRangeString(s,"forceSheetReference")}function kg(e,t){let o;if(e.labelRange){const i=Ag(Qo(e.labelRange),t);o=i?ti(i):void 0}const i=e.dataSets.map(Qo).map((e=>Ag(e,t))).filter(He).map(ti);return{...e,labelRange:o,dataSets:i}}const Ug=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Vg{graphColorIndex=0;next(){return Ug[this.graphColorIndex++%Ug.length]}}function zg(e){return e&&pt(e)<.3?"#FFFFFF":"#000000"}function Bg(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!qo.test(e)));if(t)return 33;if(e.dataSets.map(Qo).some((e=>e.top!==e.bottom&&wi(e))))return 33}return 0}function Hg(e){if(e.labelRange){if(!qo.test(e.labelRange||""))return 34}return 0}function $g(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const i=yi(t.dataRange.zone);return!(yi(e.zone)<i)}function Wg(e,t,o,i){if(e){if("text"===o||t?.type!==Qi.number||e.type!==Qi.number)return e.formattedValue;{let s=t.value-e.value;if("percentage"===o&&0!==s&&(s=s/e.value*100),"percentage"!==o&&e.format)return vo(s,{format:e.format,locale:i});const r=Math.abs(parseFloat(s.toFixed(2))).toLocaleString();return"percentage"===o?r+"%":r}}return""}function Gg(e,t,o,i,s){if("text"===t||e?.type!==Qi.number||o?.type!==Qi.number)return;const r=o.value-e.value;return r>0?i:r<0?s:void 0}function qg(e,t,o){if("text"===o||e?.type!==Qi.number||t?.type!==Qi.number)return"neutral";const i=t.value-e.value;return i>0?"up":i<0?"down":"neutral"}const Zg={Errors:{26:r("The range is invalid"),52:r("The argument is missing. Please provide a value"),53:r("The second argument is missing. Please provide a value"),54:r("The minpoint must be a number"),55:r("The midpoint must be a number"),56:r("The maxpoint must be a number"),57:r("The first value must be a number"),58:r("The second value must be a number"),48:r("Minimum must be smaller then Maximum"),51:r("Minimum must be smaller then Midpoint"),50:r("Midpoint must be smaller then Maximum"),49:r("Lower inflection point must be smaller than upper inflection point"),59:r("Invalid Minpoint formula"),61:r("Invalid Maxpoint formula"),60:r("Invalid Midpoint formula"),62:r("Invalid upper inflection point formula"),63:r("Invalid lower inflection point formula"),25:r("A range needs to be defined"),Unexpected:r("The rule is invalid for an unknown reason")},ColorScale:r("Color scale"),IconSet:r("Icon set")},jg={IsEmpty:r("Is empty"),IsNotEmpty:r("Is not empty"),ContainsText:r("Contains"),NotContains:r("Does not contain"),BeginsWith:r("Starts with"),EndsWith:r("Ends with"),Equal:r("Is equal to"),NotEqual:r("Is not equal to"),GreaterThan:r("Is greater than"),GreaterThanOrEqual:r("Is greater than or equal to"),LessThan:r("Is less than"),LessThanOrEqual:r("Is less than or equal to"),Between:r("Is between"),NotBetween:r("Is not between")},Yg={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),33:r("The dataset is invalid"),34:r("Labels are invalid"),35:r("The key value is invalid"),36:r("The baseline value is invalid"),37:r("The data range is invalid"),38:r("A minimum range limit value is needed"),39:r("The minimum range limit value must be a number"),40:r("A maximum range limit value is needed"),41:r("The maximum range limit value must be a number"),42:r("Minimum range limit must be smaller than maximum range limit"),43:r("The lower inflection point value must be a number"),44:r("The upper inflection point value must be a number")}},Xg={Custom:r("Custom")},Kg=r("Merged cells are preventing this operation. Unmerge those cells and try again."),Qg={Errors:{Unexpected:r("Cannot split the selection for an unknown reason"),92:r("There is no match for the selected separator in the selection"),89:r("Only a selection from a single column can be split"),91:r("Splitting will overwrite existing content")}};function Jg(e,t){if(t.dataRange){const o=t.labelCell?[ti(t.labelCell.zone)]:[],i=ui([ti(t.dataRange.zone)],o)[0];if(void 0===i)return[];const s=e.getRangeFromSheetXC(t.dataRange.sheetId,i);return e.getRangeValues(s).map((e=>""===e?void 0:e))}return[]}function ep(e,t){const o=Oe(0,Math.max(e.length,...t.map((e=>e.data?.length||0)))).filter((o=>{const i=e[o],s=t.map((e=>e.data?.[o]));return i||s.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function tp(e,t){const o=new Set(e),i={};o.forEach((e=>{i[e]=new Array(t.length).fill(0)}));for(const o of Oe(0,e.length)){const r=e[o];for(const e of Oe(0,t.length))i[r][e]+="number"==typeof(s=t[e].data[o])?s:0}var s;return{labels:Object.keys(i),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(i).map((e=>e[t]))})))}}function op(e){return e?e.length>te?e.substring(0,te)+"…":e:""}function ip(e,t,o,{format:i,locale:r}){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:s(e.title),fontColor:o},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){let o=t.datasets?.[e.datasetIndex||0]?.label;const s=""!==e.yLabel?e.yLabel:t.datasets?.[e.datasetIndex||0]?.data?.[e.index||0],n=i&&"number"==typeof s?vo(s,{format:i,locale:r}):s?.toLocaleString()||"";return o?`${o}: ${n}`:n}}}},data:{labels:t.map(op),datasets:[]}}}function sp(e,t,o){let i={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(i={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e)))});else if(1===t.length)for(let o=0;o<Jg(e,t[0]).length;o++)i.formattedValues.push(""),i.values.push("");else if(t[0]){i={formattedValues:Oe(0,Jg(e,t[0]).length).map((e=>e.toString())),values:i.formattedValues}}return i}function rp(e,t){for(const o of t){const t=e.getRangeFormats(o.dataRange).find((e=>void 0!==e&&!Io(e)));if(t)return t}}function np(e,t){const o=[];for(const[i,s]of Object.entries(t)){let t;if(s.labelCell){const o=s.labelCell,r=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=r&&o?op(r.formattedValue):t=`${Yg.Series} ${parseInt(i)+1}`}else t=t=`${Yg.Series} ${parseInt(i)+1}`;let r=s.dataRange?Jg(e,s):[];o.push({data:r,label:t})}return o}function ap(e){return 0===e?"origin":e-1}class lp extends Tg{dataSets;labelRange;background;verticalAxisPosition;legendPosition;stacked;aggregated;type="bar";dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Fg(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return kg(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Bg,Hg)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=Ng(this.sheetId,e,this.dataSets),o=Mg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new lp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new lp(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lg(this.getters,e))).filter((e=>""!==e.range)),t=Pg(this.getters,this.labelRange,$g(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:Rg(this.background||w),fontColor:Rg(zg(this.background)),dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=Og(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new lp(s,this.sheetId,this.getters)}}function cp(e){return e.dataRange&&!qo.test(e.dataRange)?37:0}function hp(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function dp(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?42:0}function up(e,t){if(""===e)switch(t){case"rangeMin":return 38;case"rangeMax":return 40}return 0}function gp(e,t){if(isNaN(e))switch(t){case"rangeMin":return 39;case"rangeMax":return 41;case"lowerInflectionPointValue":return 43;case"upperInflectionPointValue":return 44}return 0}class pp extends Tg{dataRange;sectionRule;background;type="gauge";constructor(e,t,o){super(e,t,o),this.dataRange=Ti(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,cp,e.chainValidations(hp(up,e.batchValidations),hp(gp,e.batchValidations),dp),e.chainValidations((o=gp,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=Ag(Qo(e.dataRange),t)),{...e,dataRange:o?ti(o):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=Mg(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new pp(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new pp(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=_g(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new pp(o,this.sheetId,this.getters)}}const mp={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},fp={inSeconds:function(e){return Math.floor(e/mp.second)},inMinutes:function(e){return Math.floor(e/mp.minute)},inHours:function(e){return Math.floor(e/mp.hour)},inDays:function(e){return Math.floor(e/mp.day)},inMonths:function(e){return Math.floor(e/mp.month)},inYears:function(e){return Math.floor(e/mp.year)}},bp=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function vp(e,t,o){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),s=function(e,t,o){const i=e.map((e=>zt(e,o)?.jsDate));if(i.some((e=>void 0===e))||e.length<2)return;const s=i.map((e=>e.getTime())),r=Math.max(...s)-Math.min(...s),n=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(mp.second>=mp[n]&&fp.inSeconds(r)<180)return"second";if(mp.minute>=mp[n]&&fp.inMinutes(r)<180)return"minute";if(mp.hour>=mp[n]&&fp.inHours(r)<96)return"hour";if(mp.day>=mp[n]&&fp.inDays(r)<90)return"day";if(mp.month>=mp[n]&&fp.inMonths(r)<36)return"month";return"year"}(e,i,o),r={};return s&&(r[s]=i),{parser:i,displayFormats:r,unit:s}}class Sp extends Tg{dataSets;labelRange;background;verticalAxisPosition;legendPosition;labelsAsText;stacked;aggregated;type="line";dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Fg(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static validateChartDefinition(e,t){return e.checkValidations(t,Bg,Hg)}static transformDefinition(e,t){return kg(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=Og(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new Sp(s,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lg(this.getters,e))).filter((e=>""!==e.range)),t=Pg(this.getters,this.labelRange,$g(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:Rg(this.background||w),fontColor:Rg(zg(this.background)),dataSets:e,labelRange:t}}copyForSheetId(e){const t=Ng(this.sheetId,e,this.dataSets),o=Mg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Sp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Sp(t,e,this.getters)}}function Cp(e,t){return wp(e,t)||yp(e,t)}function Ep(e,t){return function(e,t){return!e.labelsAsText&&wp(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&yp(e.labelRange,t)}(e,t)?"linear":"category"}function wp(e,t){if(!e||!yp(e,t))return!1;const o=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(o&&bp.test(o))}function yp(e,t){if(!e)return!1;const o=t.getRangeValues(e);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}class xp extends Tg{dataSets;labelRange;background;legendPosition;type="pie";aggregated;dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Fg(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return kg(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Bg,Hg)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=Ng(this.sheetId,e,this.dataSets),o=Mg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new xp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new xp(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lg(this.getters,e))).filter((e=>""!==e.range)),t=Pg(this.getters,this.labelRange,$g(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:Rg(this.background||w),fontColor:Rg(zg(this.background)),verticalAxisPosition:"left",dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=Og(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new xp(s,this.sheetId,this.getters)}}function Ip(e,t){const o=[],i=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=i;t++)o.push(e.next());return o}function Rp(e){return e.keyValue&&!qo.test(e.keyValue)?35:0}function Tp(e){return e.baseline&&!qo.test(e.baseline)?36:0}class Ap extends Tg{keyValue;baseline;baselineMode;baselineDescr;background;baselineColorUp;baselineColorDown;fontColor;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=Ti(o,t,e.keyValue),this.baseline=Ti(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Rp,Tp)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:ie,baselineColorUp:se,baselineColorDown:re,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,i;return e.baseline&&(o=Ag(Qo(e.baseline),t)),e.keyValue&&(i=Ag(Qo(e.keyValue),t)),{...e,baseline:o?ti(o):void 0,keyValue:i?ti(i):void 0}}copyForSheetId(e){const t=Mg(this.sheetId,e,this.baseline),o=Mg(this.sheetId,e,this.keyValue),i=this.getDefinitionWithSpecificRanges(t,o,e);return new Ap(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new Ap(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=_g(this.baseline,e),o=_g(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const i=this.getDefinitionWithSpecificRanges(t,o);return new Ap(i,this.sheetId,this.getters)}}const Op=new $i;Op.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new lp(e,t,o),getChartRuntime:function(e,t){let o=sp(t,e.dataSets,e.labelRange).formattedValues,i=np(t,e.dataSets);e.dataSetsHaveTitle&&i[0]&&o.length>i[0].data.length&&o.shift(),({labels:o,dataSetsValues:i}=ep(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=tp(o,i));const s=function(e,t,o){const i=zg(e.background),s=ip(e,t,i,o),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0,callback:e=>o.format?vo(e,o):e?.toLocaleString()||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,o,{format:rp(t,e.dataSets),locale:t.getLocale()}),r=new Vg;for(let{label:e,data:t}of i){const o=r.next(),i={label:e,data:t,borderColor:o,backgroundColor:o};s.data.datasets.push(i)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>lp.validateChartDefinition(e,t),transformDefinition:(e,t)=>lp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>lp.getDefinitionFromContextCreation(e),name:r("Bar"),sequence:10}),Op.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new Sp(e,t,o),getChartRuntime:function(e,t){const o=Ep(e,t),i=sp(t,e.dataSets,e.labelRange);let s="linear"===o?i.values:i.formattedValues,r=np(t,e.dataSets);e.dataSetsHaveTitle&&r[0]&&s.length>r[0].data.length&&s.shift(),({labels:s,dataSetsValues:r}=ep(s,r)),"time"===o&&({labels:s,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],i=Se(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=Ze(o,e);for(let t of i)t.data[e]=void 0}return{labels:o,dataSetsValues:i}}(s,r)),e.aggregated&&({labels:s,dataSetsValues:r}=tp(s,r));const n=t.getLocale(),a={format:rp(t,e.dataSets),locale:n},l=function(e,t,o){const i=zg(e.background),s=ip(e,t,i,o),r={labels:{fontColor:i,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,i]of o.entries())i.fillStyle=t.datasets[e].borderColor;return o}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0,callback:e=>o.format?vo(e,o):e?.toLocaleString()||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,s,a),c=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===o?(l.options.scales.xAxes[0].type="time",l.options.scales.xAxes[0].time=vp(s,c,n),l.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(l.options.scales.xAxes[0].type="linear",l.options.scales.xAxes[0].ticks.callback=e=>vo(e,a),l.options.tooltips.callbacks.title=e=>vo(e[0]?.xLabel||"",a));const h=new Vg;for(let[t,{label:i,data:n}]of r.entries()){["linear","time"].includes(o)&&(n=n.map(((e,t)=>({x:s[t]||void 0,y:e}))));const r=h.next();let a=ft(r);e.stacked&&(a.a=ne);const c={label:i,data:n,lineTension:0,borderColor:r,backgroundColor:mt(a),pointBackgroundColor:r,fill:!!e.stacked&&ap(t)};l.data.datasets.push(c)}return{chartJsConfig:l,background:e.background||w}},validateChartDefinition:(e,t)=>Sp.validateChartDefinition(e,t),transformDefinition:(e,t)=>Sp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Sp.getDefinitionFromContextCreation(e),name:r("Line"),sequence:20}),Op.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new xp(e,t,o),getChartRuntime:function(e,t){let o=sp(t,e.dataSets,e.labelRange).formattedValues,i=np(t,e.dataSets);e.dataSetsHaveTitle&&i[0]&&o.length>i[0].data.length&&o.shift(),({labels:o,dataSetsValues:i}=ep(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=tp(o,i));const s=function(e,t,o){const i=zg(e.background),s=ip(e,t,i,o),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,o,{format:rp(t,e.dataSets),locale:t.getLocale()}),r=new Vg;for(let{label:e,data:t}of i){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Ip(r,i)};s.data.datasets.push(o)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>xp.validateChartDefinition(e,t),transformDefinition:(e,t)=>xp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>xp.getDefinitionFromContextCreation(e),name:r("Pie"),sequence:30}),Op.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new Ap(e,t,o),getChartRuntime:function(e,t){let o,i,r="",n="";if(e.keyValue){const i={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(i),r=String(o.value),n=o.formattedValue}const a=e.baseline;if(a){const o={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};i=t.getEvaluatedCell(o)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue),c=t.getLocale();return{title:s(e.title),keyValue:n||r,baselineDisplay:Wg(i,o,e.baselineMode,c),baselineArrow:qg(i,o,e.baselineMode),baselineColor:Gg(i,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?s(e.baselineDescr):"",fontColor:zg(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>Ap.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ap.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ap.getDefinitionFromContextCreation(e),name:r("Scorecard"),sequence:40}),Op.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new pp(e,t,o),getChartRuntime:function(e,t){const o=function(e,t){const o=ip(e,[],zg(e.background),{locale:t});return o.options.hover=void 0,o.options.events=[],o.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},o.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},o.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},o}(e,t.getLocale()),i=e.sectionRule.colors,s=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,n=Number(s.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==s.value){const e="number"===s.type?n:l+h*n/100;d.push({value:we(e,l,c),color:i.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:we(e,l,c),color:i.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(i.upperColor);const p=e.dataRange,m=h/30;let f=l-m,b=null,v=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===Qi.number&&(f=we(e.value,l-m,c+m),b=()=>t.getRangeFormattedValues(p)[0],v=!0)}return o.options.valueLabel.display=v,o.options.valueLabel.formatter=b,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:o,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>pp.validateChartDefinition(e,t),transformDefinition:(e,t)=>pp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>pp.getDefinitionFromContextCreation(e),name:r("Gauge"),sequence:50});const Np=new $i;Np.add("line",Mi),Np.add("bar",Mi),Np.add("pie",Mi),Np.add("gauge",Mi),Np.add("scorecard",zi);const Mp=new $i;Di`
347
347
  .o-chart-container {
348
348
  width: 100%;
349
349
  height: 100%;
350
350
  position: relative;
351
351
  }
352
- `;class Rp extends t.Component{static template="o-spreadsheet-ChartFigure";static components={};onDoubleClick(){this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=xp.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}Rp.props={figure:Object,onFigureDeleted:Function};class Tp extends t.Component{static template="o-spreadsheet-ImageFigure";static components={};get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function Ap(e,t){const o=Se(t),i=e.getSheetViewDimension(),s=i.width,r=i.height;if(o.width>s){const e=s/o.width;o.width=s,o.height=o.height*e}if(o.height>r){const e=r/o.height;o.height=r,o.width=o.width*e}return o}Tp.props={figure:Object,onFigureDeleted:Function};const Op=new $i;function Np(e,t){return{id:"copy",name:r("Copy"),sequence:2,description:"Ctrl+C",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function Mp(e,t){return{id:"cut",name:r("Cut"),sequence:3,description:"Ctrl+X",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function _p(e,t,o){return{id:"delete",name:r("Delete"),sequence:10,execute:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e}),t()}}}Op.add("chart",{Component:Rp,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,o){return ug([{id:"edit",name:r("Edit"),sequence:1,execute:()=>{o.model.dispatch("SELECT_FIGURE",{id:e}),o.openSidePanel("ChartPanel")}},Np(e,o),Mp(e,o),_p(e,t,o)])}}),Op.add("image",{Component:Tp,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,o){return ug([Np(e,o),Mp(e,o),{id:"reset_size",name:r("Reset size"),sequence:4,execute:()=>{const t=o.model.getters.getImageSize(e),{height:i,width:s}=Ap(o.model.getters,t);o.model.dispatch("UPDATE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e,height:i,width:s})}},_p(e,t,o)])}});const Fp=(new $i).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let i=0;i<e.quantity;i++)t.push(i+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let i of Ne(o)){const o=0===i[0]?0:i[0]-1,s=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:o,sheetId:e.sheetId,position:s})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of ss.values())Fp.contains(e)||Fp.add(e,Dp);function Dp(e){return[e]}function Lp(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(20)&&e.raiseError(r("This operation is not allowed with multiple selections."))}const Pp={MergeIsDestructive:r("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:r("You can't merge cells inside of an existing filter.")};const kp={wrongPasteSelection:r("This operation is not allowed with multiple selections."),willRemoveExistingMerge:r("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:r("Cannot do a special paste of a figure."),frozenPaneOverlap:r("Cannot paste merged cells over a frozen pane.")};function Up(e,t){t.isSuccessful||(t.reasons.includes(21)?e.raiseError(kp.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(kp.willRemoveExistingMerge):t.reasons.includes(23)?e.raiseError(kp.wrongFigurePasteOption):t.reasons.includes(76)&&e.raiseError(kp.frozenPaneOverlap))}function Vp(e,t,o){const i=e.model.dispatch("PASTE",{target:t,pasteOption:o});Up(e,i)}function zp(e,t,o,i){const s=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o,pasteOption:i});Up(e,s)}function Bp(e,t){const o=yp.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function Hp(e,t){let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const i=[ti(o)],r=t.getActiveSheetId(),n=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===yi(e)&&n?.content)return{type:"scorecard",title:"",background:n.style?.fillColor||void 0,keyValue:ti(e),baselineMode:ie,baselineColorUp:se,baselineColorDown:re};let a="";const l=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),c=!!l.find((e=>e.type!==Qi.empty&&e.type!==Qi.number));if(c){const e=l.filter((e=>e.type!==Qi.error&&e.type!==Qi.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];a=e.join(", "),t&&(a+=(a?" "+s("and")+" ":"")+t)}let h;e.left!==e.right&&(h=ti({...e,right:e.left}));const d=o.right===o.left?"none":"top";return pp(h?t.getRangeFromSheetXC(r,h):void 0,t)?{title:a,dataSets:i,labelsAsText:!1,stacked:!1,aggregated:!1,labelRange:h,type:"line",dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}:{title:a,dataSets:i,labelRange:h,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}}function $p(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Wp(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const Gp=async e=>qp(e,"onlyValue");async function qp(e,t){const o=e.model.getters.getClipboardTextContent(),i=await e.clipboard.readText();switch(i.status){case"ok":const s=e.model.getters.getSelectedZones();i&&i.content!==o?zp(e,s,i.content,t):Vp(e,s,t),e.model.getters.isCutOperation()&&"onlyValue"!==t&&await e.clipboard.write({[Ji.PlainText]:""});break;case"notImplemented":e.raiseError(r("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(r("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const Zp=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("ROW");return e.model.getters.canRemoveHeaders(t,"ROW",o)},jp=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("COL");return e.model.getters.canRemoveHeaders(t,"COL",o)},Yp=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:i,dimension:"ROW"})},Xp=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:i})},Kp=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:i})};const Qp=async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4(),i=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(r("An unexpected error occurred during the image transfer"))}}(e);if(!i)throw new Error("No image provider was given to the environment");const s=Ap(e.model.getters,i.size),n=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:s,scrollY:r}=e.getActiveSheetScrollInfo(),n=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,n.width-o),c=Math.min(a.height,n.height-i);return{x:o+s+Math.max(0,(l-t.width)/2),y:i+r+Math.max(0,(c-t.height)/2)}}(e.model.getters,s);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:n,size:s,definition:i})}},Jp=e=>$p(e,"0.00%"),em=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},tm=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},om=e=>1===e.model.getters.getSelectedZones().length,im={name:r("Undo"),description:"Ctrl+Z",execute:e=>e.model.dispatch("REQUEST_UNDO"),isEnabled:e=>e.model.getters.canUndo(),icon:"o-spreadsheet-Icon.UNDO"},sm={name:r("Redo"),description:"Ctrl+Y",execute:e=>e.model.dispatch("REQUEST_REDO"),isEnabled:e=>e.model.getters.canRedo(),icon:"o-spreadsheet-Icon.REDO"},rm={name:r("Copy"),description:"Ctrl+C",isReadonlyAllowed:!0,execute:async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"},nm={name:r("Cut"),description:"Ctrl+X",execute:async e=>{Lp(e),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"},am={name:r("Paste"),description:"Ctrl+V",execute:async e=>qp(e),icon:"o-spreadsheet-Icon.PASTE"},lm={name:r("Paste special"),isVisible:e=>!e.model.getters.isCutOperation(),icon:"o-spreadsheet-Icon.PASTE"},cm={name:r("Paste value only"),description:"Ctrl+Shift+V",execute:Gp},hm={name:r("Paste format only"),execute:e=>qp(e,"onlyFormat")},dm={name:r("Find and replace"),description:"Ctrl+H",isReadonlyAllowed:!0,execute:e=>{e.openSidePanel("FindAndReplace",{})},icon:"o-spreadsheet-Icon.FIND_AND_REPLACE"},um={name:r("Delete values"),execute:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},gm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:Zp},pm={...gm,isVisible:om},mm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},fm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Delete column %s",Et(t)):r("Delete columns %s - %s",Et(t),Et(o))},execute:e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:jp},bm={...fm,isVisible:om},vm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Clear column %s",Et(t)):r("Clear columns %s - %s",Et(t),Et(o))},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},Sm={name:r("Delete cells"),isVisible:om},Cm={name:r("Delete cell and shift up"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Up(e,o)}},Em={name:r("Delete cell and shift left"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Up(e,o)}},wm={name:r("Merge cells"),isEnabled:e=>!ym(e),isActive:e=>xm(e),execute:e=>function(e){if(ym(e))return;const t=e.model.getters.getSelectedZones(),o=[t[t.length-1]],i=e.model.getters.getActiveSheetId();xm(e)?e.model.dispatch("REMOVE_MERGE",{sheetId:i,target:o}):function(e,t,o){const i=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});i.isCancelledBecause(81)?e.raiseError(Pp.MergeInFilter):i.isCancelledBecause(3)&&e.askConfirmation(Pp.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(e,i,o)}(e),icon:"o-spreadsheet-Icon.MERGE_CELL"};function ym(e){const t=e.model.getters.getSelectedZones(),{top:o,left:i,right:s,bottom:r}=e.model.getters.getSelectedZone(),{sheetId:n}=e.model.getters.getActivePosition(),{xSplit:a,ySplit:l}=e.model.getters.getPaneDivisions(n);return t.length>1||o===r&&i===s||i<a&&a<=s||o<l&&l<=r}function xm(e){if(!ym(e)){const t=e.model.getters.getSelectedZones(),{col:o,row:i,sheetId:s}=e.model.getters.getActivePosition(),r=e.model.getters.expandZone(s,Ei({col:o,row:i}));return li(t[0],r)}return!1}var Im=Object.freeze({__proto__:null,undo:im,redo:sm,copy:rm,cut:nm,paste:am,pasteSpecial:lm,pasteSpecialValue:cm,pasteSpecialFormat:hm,findAndReplace:dm,deleteValues:um,deleteRows:gm,deleteRow:pm,clearRows:mm,deleteCols:fm,deleteCol:bm,clearCols:vm,deleteCells:Sm,deleteCellShiftUp:Cm,deleteCellShiftLeft:Em,mergeCells:wm});const Rm={name:e=>{const t=Jm(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},isVisible:e=>it(e.model.getters.getActiveRows())&&om(e)&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_ROW"},Tm={name:e=>{const t=Jm(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},execute:Yp,isVisible:e=>it(e.model.getters.getActiveRows())&&om(e)&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Am={...Tm,name:e=>{const t=Jm(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())}},Om={...Tm,name:e=>{const t=Jm(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},isVisible:om,icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Nm={execute:e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:i,dimension:"ROW"})},name:e=>{const t=Jm(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},isVisible:e=>it(e.model.getters.getActiveRows())&&om(e)&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_ROW_AFTER"},Mm={...Nm,name:e=>{const t=Jm(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())}},_m={name:e=>{const t=ef(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},isVisible:e=>it(e.model.getters.getActiveCols())&&om(e)&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_COL"},Fm={name:e=>{const t=ef(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},execute:Xp,isVisible:e=>it(e.model.getters.getActiveCols())&&om(e)&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},Dm={...Fm,name:e=>{const t=ef(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())}},Lm={...Fm,name:e=>{const t=ef(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},isVisible:om,icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},Pm={name:e=>{const t=ef(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},execute:Kp,isVisible:e=>it(e.model.getters.getActiveCols())&&om(e)&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_COL_AFTER"},km={...Pm,name:e=>{const t=ef(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},execute:Kp},Um={name:r("Insert cells"),isVisible:e=>om(e)&&0===e.model.getters.getActiveCols().size&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_CELL"},Vm={name:r("Insert cells and shift down"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Up(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_DOWN"},zm={name:r("Insert cells and shift right"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Up(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_RIGHT"},Bm={name:r("Chart"),execute:e=>{const t=e.model.getters,o=e.model.uuidGenerator.uuidv4(),i=t.getActiveSheetId();1===yi(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const s={width:536,height:335},r=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:s,scrollY:r}=e.getActiveSheetScrollInfo(),{width:n,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+s+Math.max(0,(n-t.width)/2),y:i+r+Math.max(0,(a-t.height)/2)}}(t,s);e.model.dispatch("CREATE_CHART",{sheetId:i,id:o,position:r,size:s,definition:Hp(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))},icon:"o-spreadsheet-Icon.INSERT_CHART"},Hm={name:r("Image"),description:"Ctrl+O",execute:Qp,isVisible:e=>void 0!==e.imageProvider,icon:"o-spreadsheet-Icon.INSERT_IMAGE"},$m={name:r("Function"),icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},Wm={name:r("SUM"),execute:e=>e.startCellEdition("=SUM(")},Gm={name:r("AVERAGE"),execute:e=>e.startCellEdition("=AVERAGE(")},qm={name:r("COUNT"),execute:e=>e.startCellEdition("=COUNT(")},Zm={name:r("MAX"),execute:e=>e.startCellEdition("=MAX(")},jm={name:r("MIN"),execute:e=>e.startCellEdition("=MIN(")},Ym={name:r("All"),children:Qm(Jd.getKeys())};const Xm={name:r("Link"),execute:em,icon:"o-spreadsheet-Icon.INSERT_LINK"},Km={name:r("Insert sheet"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,i=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:i,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},icon:"o-spreadsheet-Icon.INSERT_SHEET"};function Qm(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,execute:t=>t.startCellEdition(`=${e}(`)})))}function Jm(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function ef(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}const tf=new mg;tf.add("cut",{...nm,sequence:10}).add("copy",{...rm,sequence:20}).add("paste",{...am,sequence:30}).add("paste_special",{...lm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...cm,sequence:10}).addChild("paste_format_only",["paste_special"],{...hm,sequence:20}).add("add_row_before",{...Om,sequence:70}).add("add_column_before",{...Lm,sequence:90}).add("insert_cell",{...Um,sequence:100,separator:!0}).addChild("insert_cell_down",["insert_cell"],{...Vm,name:r("Shift down"),sequence:10}).addChild("insert_cell_right",["insert_cell"],{...zm,name:r("Shift right"),sequence:20}).add("delete_row",{...pm,sequence:110,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_column",{...bm,sequence:120,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_cell",{...Sm,sequence:130,separator:!0,icon:"o-spreadsheet-Icon.DELETE"}).addChild("delete_cell_up",["delete_cell"],{...Cm,name:r("Shift up"),sequence:10,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_UP"}).addChild("delete_cell_left",["delete_cell"],{...Em,name:r("Shift left"),sequence:20,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_LEFT"}).add("insert_link",{...Xm,name:r("Insert link"),sequence:150,separator:!0});const of=[Qi.number,Qi.error,Qi.text,Qi.boolean];function sf(e,t,o,i,s){let n=ns.Success,a=i.right>i.left;if(e.model.getters.doesIntersectMerge(t,i)){let o;a=!1;for(let s=i.top;s<=i.bottom;s++){o=[];for(let r=i.left;r<=i.right;r++){let i=e.model.getters.getMerge({sheetId:t,col:r,row:s});i&&!o.includes(i.id.toString())&&o.push(i.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s});else{const o=e.model.getters.getContiguousZone(t,i);li(o,i)?n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s}):e.askConfirmation(r("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{i=o,n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s})}),(()=>{n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s})}))}if(n.isCancelledBecause(64)){const{col:t,row:s}=o;e.model.selection.selectZone({cell:{col:t,row:s},zone:i}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const rf={filterOverlap:r("You cannot create overlapping filters."),nonContinuousTargets:r("A filter can only be created on a continuous selection."),mergeInFilter:r("You can't create a filter over a range that contains a merge.")};function nf(e,t,o){const i=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});i.isCancelledBecause(79)?e.raiseError(rf.filterOverlap):i.isCancelledBecause(81)?e.raiseError(rf.mergeInFilter):i.isCancelledBecause(82)&&e.raiseError(rf.nonContinuousTargets)}const af={name:r("Sort range"),isVisible:om,icon:"o-spreadsheet-Icon.SORT_RANGE"},lf={name:r("Ascending (A ⟶ Z)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();sf(e,i,t.cell,o[0],"ascending")},icon:"o-spreadsheet-Icon.SORT_ASCENDING"},cf={name:r("Descending (Z ⟶ A)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();sf(e,i,t.cell,o[0],"descending")},icon:"o-spreadsheet-Icon.SORT_DESCENDING"},hf={name:r("Create filter"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelection().zones;nf(e,t,o)},isVisible:e=>!tm(e),isEnabled:e=>xi(...e.model.getters.getSelectedZones()),icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},df={name:r("Remove filter"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:tm,icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},uf={name:r("Split text to columns"),sequence:1,execute:e=>e.openSidePanel("SplitToColumns",{}),isEnabled:e=>e.model.getters.isSingleColSelected(),icon:"o-spreadsheet-Icon.SPLIT_TEXT"},gf={name:r("Automatic"),execute:e=>$p(e,""),isActive:e=>function(e){const t=e.model.getters.getCell(e.model.getters.getActivePosition());return!t||!t.format}(e)},pf={name:r("Number"),description:"1,000.12",execute:e=>$p(e,"#,##0.00"),isActive:e=>Yf(e,"#,##0.00")},mf={name:r("Format as percent"),execute:Jp,icon:"o-spreadsheet-Icon.PERCENT"},ff={name:r("Percent"),description:"10.12%",execute:Jp,isActive:e=>Yf(e,"0.00%")},bf={name:r("Currency"),description:"$1,000.12",execute:e=>$p(e,"[$$]#,##0.00"),isActive:e=>Yf(e,"[$$]#,##0.00")},vf={name:r("Currency rounded"),description:"$1,000",execute:e=>$p(e,"[$$]#,##0"),isActive:e=>Yf(e,"[$$]#,##0")},Sf={name:r("Custom currency"),isVisible:e=>void 0!==e.loadCurrencies,execute:e=>e.openSidePanel("CustomCurrency",{})},Cf={name:r("Date"),description:"9/26/2008",execute:e=>$p(e,e.model.getters.getLocale().dateFormat),isActive:e=>Yf(e,e.model.getters.getLocale().dateFormat)},Ef={name:r("Time"),description:"10:43:00 PM",execute:e=>$p(e,e.model.getters.getLocale().timeFormat),isActive:e=>Yf(e,e.model.getters.getLocale().timeFormat)},wf={name:r("Date time"),description:"9/26/2008 22:43:00",execute:e=>{const t=e.model.getters.getLocale();$p(e,t.dateFormat+" "+t.timeFormat)},isActive:e=>{const t=e.model.getters.getLocale();return Yf(e,t.dateFormat+" "+t.timeFormat)}},yf={name:r("Duration"),description:"27:51:38",execute:e=>$p(e,"hhhh:mm:ss"),isActive:e=>Yf(e,"hhhh:mm:ss")},xf={name:r("Increase decimal places"),icon:"o-spreadsheet-Icon.INCREASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:1})},If={name:r("Decrease decimal places"),icon:"o-spreadsheet-Icon.DECRASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:-1})},Rf={name:r("Bold"),description:"Ctrl+B",execute:e=>Wp(e,{bold:!e.model.getters.getCurrentStyle().bold}),icon:"o-spreadsheet-Icon.BOLD",isActive:e=>!!e.model.getters.getCurrentStyle().bold},Tf={name:r("Italic"),description:"Ctrl+I",execute:e=>Wp(e,{italic:!e.model.getters.getCurrentStyle().italic}),icon:"o-spreadsheet-Icon.ITALIC",isActive:e=>!!e.model.getters.getCurrentStyle().italic},Af={name:r("Underline"),description:"Ctrl+U",execute:e=>Wp(e,{underline:!e.model.getters.getCurrentStyle().underline}),icon:"o-spreadsheet-Icon.UNDERLINE",isActive:e=>!!e.model.getters.getCurrentStyle().underline},Of={name:r("Strikethrough"),execute:e=>Wp(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),icon:"o-spreadsheet-Icon.STRIKE",isActive:e=>!!e.model.getters.getCurrentStyle().strikethrough},Nf={name:r("Font size"),children:me.map((e=>({name:e.toString(),sequence:e,id:`font_size_${e}`,execute:t=>Wp(t,{fontSize:e}),isActive:t=>function(e,t){const o=e.model.getters.getCurrentStyle().fontSize||q;return o===t}(t,e)}))),icon:"o-spreadsheet-Icon.FONT_SIZE"},Mf={name:r("Alignment"),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},_f={name:r("Horizontal align"),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},Ff={name:r("Left"),description:"Ctrl+Shift+L",execute:e=>Wp(e,{align:"left"}),isActive:e=>"left"===Xf(e),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},Df={name:r("Center"),description:"Ctrl+Shift+E",execute:e=>Wp(e,{align:"center"}),isActive:e=>"center"===Xf(e),icon:"o-spreadsheet-Icon.ALIGN_CENTER"},Lf={name:r("Right"),description:"Ctrl+Shift+R",execute:e=>Wp(e,{align:"right"}),isActive:e=>"right"===Xf(e),icon:"o-spreadsheet-Icon.ALIGN_RIGHT"},Pf={name:r("Vertical align"),icon:"o-spreadsheet-Icon.ALIGN_MIDDLE"},kf={name:r("Top"),execute:e=>Wp(e,{verticalAlign:"top"}),isActive:e=>"top"===(e.model.getters.getCurrentStyle().verticalAlign||j),icon:"o-spreadsheet-Icon.ALIGN_TOP"},Uf={name:r("Middle"),execute:e=>Wp(e,{verticalAlign:"middle"}),isActive:e=>"middle"===(e.model.getters.getCurrentStyle().verticalAlign||j),icon:"o-spreadsheet-Icon.ALIGN_MIDDLE"},Vf={name:r("Bottom"),execute:e=>Wp(e,{verticalAlign:"bottom"}),isActive:e=>"bottom"===(e.model.getters.getCurrentStyle().verticalAlign||j),icon:"o-spreadsheet-Icon.ALIGN_BOTTOM"},zf={name:r("Wrapping"),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Bf={name:r("Overflow"),execute:e=>Wp(e,{wrapping:"overflow"}),isActive:e=>"overflow"===(e.model.getters.getCurrentStyle().wrapping||"overflow"),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Hf={name:r("Wrap"),execute:e=>Wp(e,{wrapping:"wrap"}),isActive:e=>"wrap"===e.model.getters.getCurrentStyle().wrapping,icon:"o-spreadsheet-Icon.WRAPPING_WRAP"},$f={name:r("Clip"),execute:e=>Wp(e,{wrapping:"clip"}),isActive:e=>"clip"===e.model.getters.getCurrentStyle().wrapping,icon:"o-spreadsheet-Icon.WRAPPING_CLIP"},Wf={name:r("Text Color"),icon:"o-spreadsheet-Icon.TEXT_COLOR"},Gf={name:r("Fill Color"),icon:"o-spreadsheet-Icon.FILL_COLOR"},qf={name:r("Conditional formatting"),execute:e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},icon:"o-spreadsheet-Icon.CONDITIONAL_FORMAT"},Zf={name:r("Paint Format"),execute:e=>e.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:e.model.getters.getSelectedZones()}),icon:"o-spreadsheet-Icon.PAINT_FORMAT",isActive:e=>e.model.getters.isPaintingFormat()},jf={name:r("Clear formatting"),description:"Ctrl+<",execute:e=>e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()}),icon:"o-spreadsheet-Icon.CLEAR_FORMAT"};function Yf(e,t){return e.model.getters.getCell(e.model.getters.getActivePosition())?.format===t}function Xf(e){const t=e.model.getters.getCurrentStyle();if(t.align)return t.align;return e.model.getters.getActiveCell().defaultAlign}var Kf=Object.freeze({__proto__:null,formatNumberAutomatic:gf,formatNumberNumber:pf,formatPercent:mf,formatNumberPercent:ff,formatNumberCurrency:bf,formatNumberCurrencyRounded:vf,formatCustomCurrency:Sf,formatNumberDate:Cf,formatNumberTime:Ef,formatNumberDateTime:wf,formatNumberDuration:yf,incraseDecimalPlaces:xf,decraseDecimalPlaces:If,formatBold:Rf,formatItalic:Tf,formatUnderline:Af,formatStrikethrough:Of,formatFontSize:Nf,formatAlignment:Mf,formatAlignmentHorizontal:_f,formatAlignmentLeft:Ff,formatAlignmentCenter:Df,formatAlignmentRight:Lf,formatAlignmentVertical:Pf,formatAlignmentTop:kf,formatAlignmentMiddle:Uf,formatAlignmentBottom:Vf,formatWrapping:zf,formatWrappingOverflow:Bf,formatWrappingWrap:Hf,formatWrappingClip:$f,textColor:Wf,fillColor:Gf,formatCF:qf,paintFormat:Zf,clearFormat:jf});function Qf(e,t,o){const i=e.model.getters.getActiveSheetId(),s="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(s,{sheetId:i,quantity:o}).isCancelledBecause(66)&&e.raiseError(Gg)}const Jf={name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide column %s",Et(o).toString()):i-o+1===t.length?r("Hide columns %s - %s",Et(o).toString(),Et(i).toString()):r("Hide columns")},execute:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:jp,icon:"o-spreadsheet-Icon.HIDE_COL"},eb={name:r("Unhide columns"),execute:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))}},tb={name:r("Unhide all columns"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0},ob={name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide row %s",(o+1).toString()):i-o+1===t.length?r("Hide rows %s - %s",(o+1).toString(),(i+1).toString()):r("Hide rows")},execute:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:Zp,icon:"o-spreadsheet-Icon.HIDE_ROW"},ib={name:r("Unhide rows"),execute:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))}},sb={name:r("Unhide all rows"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0},rb={name:r("Unfreeze"),isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},execute:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),icon:"o-spreadsheet-Icon.UNFREEZE"},nb={name:r("Freeze"),icon:"o-spreadsheet-Icon.FREEZE"},ab={name:r("No rows"),execute:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit},lb={name:r("1 row"),execute:e=>Qf(e,"ROW",1),isReadonlyAllowed:!0},cb={name:r("2 rows"),execute:e=>Qf(e,"ROW",2),isReadonlyAllowed:!0},hb={name:r("Up to current row"),execute:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Qf(e,"ROW",t+1)},isReadonlyAllowed:!0},db={name:r("No columns"),execute:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit},ub={name:r("1 column"),execute:e=>Qf(e,"COL",1),isReadonlyAllowed:!0},gb={name:r("2 columns"),execute:e=>Qf(e,"COL",2),isReadonlyAllowed:!0},pb={name:r("Up to current column"),execute:e=>{const{right:t}=e.model.getters.getSelectedZone();Qf(e,"COL",t+1)},isReadonlyAllowed:!0},mb={name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},icon:"o-spreadsheet-Icon.SHOW_HIDE_GRID"},fb={name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),execute:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},bb={name:e=>vb(e)?r("Remove selected filters"):r("Create filter"),isActive:e=>vb(e),isEnabled:e=>!Sb(e),execute:e=>function(e){if(vb(e))return void e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()});if(Sb(e))return;e.model.selection.selectTableAroundSelection();const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();nf(e,t,o)}(e),icon:"o-spreadsheet-Icon.FILTER_ICON_INACTIVE"};function vb(e){const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)}function Sb(e){return!xi(...e.model.getters.getSelectedZones())}var Cb=Object.freeze({__proto__:null,hideCols:Jf,unhideCols:eb,unhideAllCols:tb,hideRows:ob,unhideRows:ib,unhideAllRows:sb,unFreezePane:rb,freezePane:nb,unFreezeRows:ab,freezeFirstRow:lb,freezeSecondRow:cb,freezeCurrentRow:hb,unFreezeCols:db,freezeFirstCol:ub,freezeSecondCol:gb,freezeCurrentCol:pb,viewGridlines:mb,viewFormulas:fb,createRemoveFilter:bb});const Eb=new mg;Eb.add("cut",{...nm,sequence:10}).add("copy",{...rm,sequence:20}).add("paste",{...am,sequence:30}).add("paste_special",{...lm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...cm,sequence:10}).addChild("paste_format_only",["paste_special"],{...hm,sequence:20}).add("sort_columns",{...af,name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,separator:!0}).addChild("sort_ascending",["sort_columns"],{...lf,sequence:10}).addChild("sort_descending",["sort_columns"],{...cf,sequence:20}).add("add_column_before",{...Fm,sequence:70}).add("add_column_after",{...Pm,sequence:80}).add("delete_column",{...fm,sequence:90,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_column",{...vm,sequence:100,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_columns",{...Jf,sequence:105,separator:!0}).add("unhide_columns",{...eb,sequence:106,separator:!0}).add("conditional_formatting",{...qf,sequence:110});const wb=new mg;wb.add("format_number_automatic",{...gf,sequence:10,separator:!0}).add("format_number_number",{...pf,sequence:20}).add("format_number_percent",{...ff,sequence:30,separator:!0}).add("format_number_currency",{...bf,sequence:40}).add("format_number_currency_rounded",{...vf,sequence:50}).add("format_custom_currency",{...Sf,sequence:60,separator:!0}).add("format_number_date",{...Cf,sequence:70}).add("format_number_time",{...Ef,sequence:80}).add("format_number_date_time",{...wf,sequence:90}).add("format_number_duration",{...yf,sequence:100,separator:!0});const yb={name:r("More formats"),icon:"o-spreadsheet-Icon.NUMBER_FORMATS",children:[()=>wb.getAll()]},xb=new mg;xb.add("cut",{...nm,sequence:10}).add("copy",{...rm,sequence:20}).add("paste",{...am,sequence:30}).add("paste_special",{...lm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...cm,sequence:10}).addChild("paste_format_only",["paste_special"],{...hm,sequence:20}).add("add_row_before",{...Tm,sequence:50}).add("add_row_after",{...Nm,sequence:60}).add("delete_row",{...gm,sequence:70,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_row",{...mm,sequence:80,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_rows",{...ob,sequence:85,separator:!0}).add("unhide_rows",{...ib,sequence:86,separator:!0}).add("conditional_formatting",{...qf,sequence:90});const Ib=new mg;Ib.add("file",{name:r("File"),sequence:10}).addChild("settings",["file"],{name:r("Settings"),sequence:100,execute:e=>e.openSidePanel("Settings"),icon:"o-spreadsheet-Icon.COG"}).add("edit",{name:r("Edit"),sequence:20}).addChild("undo",["edit"],{...im,sequence:10}).addChild("redo",["edit"],{...sm,sequence:20,separator:!0}).addChild("copy",["edit"],{...rm,sequence:30}).addChild("cut",["edit"],{...nm,sequence:40}).addChild("paste",["edit"],{...am,sequence:50}).addChild("paste_special",["edit"],{...lm,sequence:60,separator:!0}).addChild("paste_special_value",["edit","paste_special"],{...cm,sequence:10}).addChild("paste_special_format",["edit","paste_special"],{...hm,sequence:20}).addChild("find_and_replace",["edit"],{...dm,sequence:65,separator:!0}).addChild("delete",["edit"],{name:r("Delete"),icon:"o-spreadsheet-Icon.DELETE",sequence:70}).addChild("edit_delete_cell_values",["edit","delete"],{...um,sequence:10}).addChild("edit_delete_row",["edit","delete"],{...gm,sequence:20}).addChild("edit_delete_column",["edit","delete"],{...fm,sequence:30}).addChild("edit_delete_cell_shift_up",["edit","delete"],{...Cm,sequence:40}).addChild("edit_delete_cell_shift_left",["edit","delete"],{...Em,sequence:50}).addChild("edit_unhide_columns",["edit"],{...tb,sequence:80}).addChild("edit_unhide_rows",["edit"],{...sb,sequence:80}).add("view",{name:r("View"),sequence:30}).addChild("unfreeze_panes",["view"],{...rb,sequence:4}).addChild("freeze_panes",["view"],{...nb,sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{...ab,sequence:5}).addChild("freeze_first_row",["view","freeze_panes"],{...lb,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{...cb,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{...hb,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{...db,sequence:25}).addChild("freeze_first_col",["view","freeze_panes"],{...ub,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{...gb,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{...pb,sequence:40}).addChild("view_gridlines",["view"],{...mb,sequence:10}).addChild("view_formulas",["view"],{...fb,sequence:15}).add("insert",{name:r("Insert"),sequence:40}).addChild("insert_row",["insert"],{...Rm,sequence:10}).addChild("insert_row_before",["insert","insert_row"],{...Am,sequence:10}).addChild("insert_row_after",["insert","insert_row"],{...Mm,sequence:20}).addChild("insert_column",["insert"],{..._m,sequence:20}).addChild("insert_column_before",["insert","insert_column"],{...Dm,sequence:10}).addChild("insert_column_after",["insert","insert_column"],{...km,sequence:20}).addChild("insert_cell",["insert"],{...Um,sequence:43}).addChild("insert_cell_down",["insert","insert_cell"],{...Vm,name:r("Shift down"),sequence:10}).addChild("insert_cell_right",["insert","insert_cell"],{...zm,name:r("Shift right"),sequence:20}).addChild("insert_sheet",["insert"],{...Km,sequence:80,separator:!0}).addChild("insert_chart",["insert"],{...Bm,sequence:50}).addChild("insert_image",["insert"],{...Hm,sequence:55}).addChild("insert_function",["insert"],{...$m,sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{...Wm,sequence:0}).addChild("insert_function_average",["insert","insert_function"],{...Gm,sequence:10}).addChild("insert_function_count",["insert","insert_function"],{...qm,sequence:20}).addChild("insert_function_max",["insert","insert_function"],{...Zm,sequence:30}).addChild("insert_function_min",["insert","insert_function"],{...jm,sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{...Ym,sequence:50}).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=Jd.content;return[...new Set(Jd.getAll().map((e=>e.category)))].filter(He).sort().map(((t,o)=>{const i=Object.keys(e).filter((o=>e[o].category===t));return{name:t,children:Qm(i)}}))})).addChild("insert_link",["insert"],{...Xm,separator:!0,sequence:70}).add("format",{name:r("Format"),sequence:50}).addChild("format_number",["format"],{...yb,name:r("Number"),sequence:10,separator:!0}).addChild("format_bold",["format"],{...Rf,sequence:20}).addChild("format_italic",["format"],{...Tf,sequence:30}).addChild("format_underline",["format"],{...Af,sequence:40}).addChild("format_strikethrough",["format"],{...Of,sequence:50,separator:!0}).addChild("format_font_size",["format"],{...Nf,sequence:60,separator:!0}).addChild("format_alignment",["format"],{...Mf,sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{...Ff,sequence:10}).addChild("format_alignment_center",["format","format_alignment"],{...Df,sequence:20}).addChild("format_alignment_right",["format","format_alignment"],{...Lf,sequence:30,separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{...kf,sequence:40}).addChild("format_alignment_middle",["format","format_alignment"],{...Uf,sequence:50}).addChild("format_alignment_bottom",["format","format_alignment"],{...Vf,sequence:60,separator:!0}).addChild("format_wrapping",["format"],{...zf,sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{...Bf,sequence:10}).addChild("format_wrapping_wrap",["format","format_wrapping"],{...Hf,sequence:20}).addChild("format_wrapping_clip",["format","format_wrapping"],{...$f,sequence:30}).addChild("format_cf",["format"],{...qf,sequence:90,separator:!0}).addChild("format_clearFormat",["format"],{...jf,sequence:100,separator:!0}).add("data",{name:r("Data"),sequence:60}).addChild("sort_range",["data"],{...af,sequence:10,separator:!0}).addChild("sort_ascending",["data","sort_range"],{...lf,sequence:10}).addChild("sort_descending",["data","sort_range"],{...cf,sequence:20}).addChild("split_to_columns",["data"],{...uf,sequence:20,separator:!0}).addChild("add_data_filter",["data"],{...hf,sequence:30}).addChild("remove_data_filter",["data"],{...df,sequence:30});const Rb=new class extends $i{addTransformation(e,t,o){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},Tb={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function Ab(e,t){const o=Tb[e.key];e.shiftKey?t.resizeAnchorZone(o,e.ctrlKey?"end":1):t.moveAnchorCell(o,e.ctrlKey?"end":1)}const Ob=new Ni;Di`
352
+ `;class _p extends t.Component{static template="o-spreadsheet-ChartFigure";static components={};onDoubleClick(){this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=Np.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}_p.props={figure:Object,onFigureDeleted:Function};class Fp extends t.Component{static template="o-spreadsheet-ImageFigure";static components={};get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function Dp(e,t){const o=Se(t),i=e.getSheetViewDimension(),s=i.width,r=i.height;if(o.width>s){const e=s/o.width;o.width=s,o.height=o.height*e}if(o.height>r){const e=r/o.height;o.height=r,o.width=o.width*e}return o}Fp.props={figure:Object,onFigureDeleted:Function};const Lp=new $i;function Pp(e,t){return{id:"copy",name:r("Copy"),sequence:2,description:"Ctrl+C",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function kp(e,t){return{id:"cut",name:r("Cut"),sequence:3,description:"Ctrl+X",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function Up(e,t,o){return{id:"delete",name:r("Delete"),sequence:10,execute:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e}),t()}}}Lp.add("chart",{Component:_p,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,o){return vg([{id:"edit",name:r("Edit"),sequence:1,execute:()=>{o.model.dispatch("SELECT_FIGURE",{id:e}),o.openSidePanel("ChartPanel")}},Pp(e,o),kp(e,o),Up(e,t,o)])}}),Lp.add("image",{Component:Fp,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,o){return vg([Pp(e,o),kp(e,o),{id:"reset_size",name:r("Reset size"),sequence:4,execute:async()=>{const t=o.model.getters.getImagePath(e),i=o.model.getters.getImageSize(e)??await(o.imageProvider?.getImageOriginalSize(t));if(!o.model.getters.getImageSize(e)){o.model.getters.getImage(e).size=i}const{height:s,width:r}=Dp(o.model.getters,i);o.model.dispatch("UPDATE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e,height:s,width:r})}},Up(e,t,o)])}});const Vp=(new $i).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let i=0;i<e.quantity;i++)t.push(i+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let i of Ne(o)){const o=0===i[0]?0:i[0]-1,s=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:o,sheetId:e.sheetId,position:s})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of ss.values())Vp.contains(e)||Vp.add(e,zp);function zp(e){return[e]}function Bp(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(20)&&e.raiseError(r("This operation is not allowed with multiple selections."))}const Hp={MergeIsDestructive:r("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:r("You can't merge cells inside of an existing filter.")};const $p={wrongPasteSelection:r("This operation is not allowed with multiple selections."),willRemoveExistingMerge:r("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:r("Cannot do a special paste of a figure."),frozenPaneOverlap:r("Cannot paste merged cells over a frozen pane.")};function Wp(e,t){t.isSuccessful||(t.reasons.includes(21)?e.raiseError($p.wrongPasteSelection):t.reasons.includes(2)?e.raiseError($p.willRemoveExistingMerge):t.reasons.includes(23)?e.raiseError($p.wrongFigurePasteOption):t.reasons.includes(76)&&e.raiseError($p.frozenPaneOverlap))}function Gp(e,t,o){const i=e.model.dispatch("PASTE",{target:t,pasteOption:o});Wp(e,i)}function qp(e,t,o,i){const s=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o,pasteOption:i});Wp(e,s)}function Zp(e,t){const o=Op.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function jp(e,t){let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const i=[ti(o)],r=t.getActiveSheetId(),n=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===yi(e)&&n?.content)return{type:"scorecard",title:"",background:n.style?.fillColor||void 0,keyValue:ti(e),baselineMode:ie,baselineColorUp:se,baselineColorDown:re};let a="";const l=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),c=!!l.find((e=>e.type!==Qi.empty&&e.type!==Qi.number));if(c){const e=l.filter((e=>e.type!==Qi.error&&e.type!==Qi.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];a=e.join(", "),t&&(a+=(a?" "+s("and")+" ":"")+t)}let h;e.left!==e.right&&(h=ti({...e,right:e.left}));const d=o.right===o.left?"none":"top";return Cp(h?t.getRangeFromSheetXC(r,h):void 0,t)?{title:a,dataSets:i,labelsAsText:!1,stacked:!1,aggregated:!1,labelRange:h,type:"line",dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}:{title:a,dataSets:i,labelRange:h,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}}function Yp(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Xp(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const Kp=async e=>Qp(e,"onlyValue");async function Qp(e,t){const o=e.model.getters.getClipboardTextContent(),i=await e.clipboard.readText();switch(i.status){case"ok":const s=e.model.getters.getSelectedZones();i&&i.content!==o?qp(e,s,i.content,t):Gp(e,s,t),e.model.getters.isCutOperation()&&"onlyValue"!==t&&await e.clipboard.write({[Ji.PlainText]:""});break;case"notImplemented":e.raiseError(r("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(r("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const Jp=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("ROW");return e.model.getters.canRemoveHeaders(t,"ROW",o)},em=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("COL");return e.model.getters.canRemoveHeaders(t,"COL",o)},tm=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:i,dimension:"ROW"})},om=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:i})},im=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:i})};const sm=async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4(),i=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(r("An unexpected error occurred during the image transfer"))}}(e);if(!i)throw new Error("No image provider was given to the environment");const s=Dp(e.model.getters,i.size),n=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:s,scrollY:r}=e.getActiveSheetScrollInfo(),n=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,n.width-o),c=Math.min(a.height,n.height-i);return{x:o+s+Math.max(0,(l-t.width)/2),y:i+r+Math.max(0,(c-t.height)/2)}}(e.model.getters,s);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:n,size:s,definition:i})}},rm=e=>Yp(e,"0.00%"),nm=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},am=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},lm=e=>1===e.model.getters.getSelectedZones().length,cm={name:r("Undo"),description:"Ctrl+Z",execute:e=>e.model.dispatch("REQUEST_UNDO"),isEnabled:e=>e.model.getters.canUndo(),icon:"o-spreadsheet-Icon.UNDO"},hm={name:r("Redo"),description:"Ctrl+Y",execute:e=>e.model.dispatch("REQUEST_REDO"),isEnabled:e=>e.model.getters.canRedo(),icon:"o-spreadsheet-Icon.REDO"},dm={name:r("Copy"),description:"Ctrl+C",isReadonlyAllowed:!0,execute:async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"},um={name:r("Cut"),description:"Ctrl+X",execute:async e=>{Bp(e),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"},gm={name:r("Paste"),description:"Ctrl+V",execute:async e=>Qp(e),icon:"o-spreadsheet-Icon.PASTE"},pm={name:r("Paste special"),isVisible:e=>!e.model.getters.isCutOperation(),icon:"o-spreadsheet-Icon.PASTE"},mm={name:r("Paste value only"),description:"Ctrl+Shift+V",execute:Kp},fm={name:r("Paste format only"),execute:e=>Qp(e,"onlyFormat")},bm={name:r("Find and replace"),description:"Ctrl+H",isReadonlyAllowed:!0,execute:e=>{e.openSidePanel("FindAndReplace",{})},icon:"o-spreadsheet-Icon.FIND_AND_REPLACE"},vm={name:r("Delete values"),execute:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},Sm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:Jp},Cm={...Sm,isVisible:lm},Em={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},wm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Delete column %s",Et(t)):r("Delete columns %s - %s",Et(t),Et(o))},execute:e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:em},ym={...wm,isVisible:lm},xm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Clear column %s",Et(t)):r("Clear columns %s - %s",Et(t),Et(o))},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},Im={name:r("Delete cells"),isVisible:lm},Rm={name:r("Delete cell and shift up"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Wp(e,o)}},Tm={name:r("Delete cell and shift left"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Wp(e,o)}},Am={name:r("Merge cells"),isEnabled:e=>!Om(e),isActive:e=>Nm(e),execute:e=>function(e){if(Om(e))return;const t=e.model.getters.getSelectedZones(),o=[t[t.length-1]],i=e.model.getters.getActiveSheetId();Nm(e)?e.model.dispatch("REMOVE_MERGE",{sheetId:i,target:o}):function(e,t,o){const i=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});i.isCancelledBecause(81)?e.raiseError(Hp.MergeInFilter):i.isCancelledBecause(3)&&e.askConfirmation(Hp.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(e,i,o)}(e),icon:"o-spreadsheet-Icon.MERGE_CELL"};function Om(e){const t=e.model.getters.getSelectedZones(),{top:o,left:i,right:s,bottom:r}=e.model.getters.getSelectedZone(),{sheetId:n}=e.model.getters.getActivePosition(),{xSplit:a,ySplit:l}=e.model.getters.getPaneDivisions(n);return t.length>1||o===r&&i===s||i<a&&a<=s||o<l&&l<=r}function Nm(e){if(!Om(e)){const t=e.model.getters.getSelectedZones(),{col:o,row:i,sheetId:s}=e.model.getters.getActivePosition(),r=e.model.getters.expandZone(s,Ei({col:o,row:i}));return li(t[0],r)}return!1}var Mm=Object.freeze({__proto__:null,undo:cm,redo:hm,copy:dm,cut:um,paste:gm,pasteSpecial:pm,pasteSpecialValue:mm,pasteSpecialFormat:fm,findAndReplace:bm,deleteValues:vm,deleteRows:Sm,deleteRow:Cm,clearRows:Em,deleteCols:wm,deleteCol:ym,clearCols:xm,deleteCells:Im,deleteCellShiftUp:Rm,deleteCellShiftLeft:Tm,mergeCells:Am});const _m={name:e=>{const t=nf(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},isVisible:e=>it(e.model.getters.getActiveRows())&&lm(e)&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_ROW"},Fm={name:e=>{const t=nf(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},execute:tm,isVisible:e=>it(e.model.getters.getActiveRows())&&lm(e)&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Dm={...Fm,name:e=>{const t=nf(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())}},Lm={...Fm,name:e=>{const t=nf(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},isVisible:lm,icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Pm={execute:e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:i,dimension:"ROW"})},name:e=>{const t=nf(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},isVisible:e=>it(e.model.getters.getActiveRows())&&lm(e)&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_ROW_AFTER"},km={...Pm,name:e=>{const t=nf(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())}},Um={name:e=>{const t=af(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},isVisible:e=>it(e.model.getters.getActiveCols())&&lm(e)&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_COL"},Vm={name:e=>{const t=af(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},execute:om,isVisible:e=>it(e.model.getters.getActiveCols())&&lm(e)&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},zm={...Vm,name:e=>{const t=af(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())}},Bm={...Vm,name:e=>{const t=af(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},isVisible:lm,icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},Hm={name:e=>{const t=af(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},execute:im,isVisible:e=>it(e.model.getters.getActiveCols())&&lm(e)&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_COL_AFTER"},$m={...Hm,name:e=>{const t=af(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},execute:im},Wm={name:r("Insert cells"),isVisible:e=>lm(e)&&0===e.model.getters.getActiveCols().size&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_CELL"},Gm={name:r("Insert cells and shift down"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Wp(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_DOWN"},qm={name:r("Insert cells and shift right"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Wp(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_RIGHT"},Zm={name:r("Chart"),execute:e=>{const t=e.model.getters,o=e.model.uuidGenerator.uuidv4(),i=t.getActiveSheetId();1===yi(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const s={width:536,height:335},r=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:s,scrollY:r}=e.getActiveSheetScrollInfo(),{width:n,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+s+Math.max(0,(n-t.width)/2),y:i+r+Math.max(0,(a-t.height)/2)}}(t,s);e.model.dispatch("CREATE_CHART",{sheetId:i,id:o,position:r,size:s,definition:jp(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))},icon:"o-spreadsheet-Icon.INSERT_CHART"},jm={name:r("Image"),description:"Ctrl+O",execute:sm,isVisible:e=>void 0!==e.imageProvider,icon:"o-spreadsheet-Icon.INSERT_IMAGE"},Ym={name:r("Function"),icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},Xm={name:r("SUM"),execute:e=>e.startCellEdition("=SUM(")},Km={name:r("AVERAGE"),execute:e=>e.startCellEdition("=AVERAGE(")},Qm={name:r("COUNT"),execute:e=>e.startCellEdition("=COUNT(")},Jm={name:r("MAX"),execute:e=>e.startCellEdition("=MAX(")},ef={name:r("MIN"),execute:e=>e.startCellEdition("=MIN(")},tf={name:r("All"),children:rf(tu.getKeys())};const of={name:r("Link"),execute:nm,icon:"o-spreadsheet-Icon.INSERT_LINK"},sf={name:r("Insert sheet"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,i=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:i,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},icon:"o-spreadsheet-Icon.INSERT_SHEET"};function rf(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,execute:t=>t.startCellEdition(`=${e}(`)})))}function nf(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function af(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}const lf=new Eg;lf.add("cut",{...um,sequence:10}).add("copy",{...dm,sequence:20}).add("paste",{...gm,sequence:30}).add("paste_special",{...pm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...mm,sequence:10}).addChild("paste_format_only",["paste_special"],{...fm,sequence:20}).add("add_row_before",{...Lm,sequence:70}).add("add_column_before",{...Bm,sequence:90}).add("insert_cell",{...Wm,sequence:100,separator:!0}).addChild("insert_cell_down",["insert_cell"],{...Gm,name:r("Shift down"),sequence:10}).addChild("insert_cell_right",["insert_cell"],{...qm,name:r("Shift right"),sequence:20}).add("delete_row",{...Cm,sequence:110,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_column",{...ym,sequence:120,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_cell",{...Im,sequence:130,separator:!0,icon:"o-spreadsheet-Icon.DELETE"}).addChild("delete_cell_up",["delete_cell"],{...Rm,name:r("Shift up"),sequence:10,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_UP"}).addChild("delete_cell_left",["delete_cell"],{...Tm,name:r("Shift left"),sequence:20,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_LEFT"}).add("insert_link",{...of,name:r("Insert link"),sequence:150,separator:!0});const cf=[Qi.number,Qi.error,Qi.text,Qi.boolean];function hf(e,t,o,i,s){let n=ns.Success,a=i.right>i.left;if(e.model.getters.doesIntersectMerge(t,i)){let o;a=!1;for(let s=i.top;s<=i.bottom;s++){o=[];for(let r=i.left;r<=i.right;r++){let i=e.model.getters.getMerge({sheetId:t,col:r,row:s});i&&!o.includes(i.id.toString())&&o.push(i.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s});else{const o=e.model.getters.getContiguousZone(t,i);li(o,i)?n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s}):e.askConfirmation(r("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{i=o,n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s})}),(()=>{n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s})}))}if(n.isCancelledBecause(64)){const{col:t,row:s}=o;e.model.selection.selectZone({cell:{col:t,row:s},zone:i}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const df={filterOverlap:r("You cannot create overlapping filters."),nonContinuousTargets:r("A filter can only be created on a continuous selection."),mergeInFilter:r("You can't create a filter over a range that contains a merge.")};function uf(e,t,o){const i=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});i.isCancelledBecause(79)?e.raiseError(df.filterOverlap):i.isCancelledBecause(81)?e.raiseError(df.mergeInFilter):i.isCancelledBecause(82)&&e.raiseError(df.nonContinuousTargets)}const gf={name:r("Sort range"),isVisible:lm,icon:"o-spreadsheet-Icon.SORT_RANGE"},pf={name:r("Ascending (A ⟶ Z)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();hf(e,i,t.cell,o[0],"ascending")},icon:"o-spreadsheet-Icon.SORT_ASCENDING"},mf={name:r("Descending (Z ⟶ A)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();hf(e,i,t.cell,o[0],"descending")},icon:"o-spreadsheet-Icon.SORT_DESCENDING"},ff={name:r("Create filter"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelection().zones;uf(e,t,o)},isVisible:e=>!am(e),isEnabled:e=>xi(...e.model.getters.getSelectedZones()),icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},bf={name:r("Remove filter"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:am,icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},vf={name:r("Split text to columns"),sequence:1,execute:e=>e.openSidePanel("SplitToColumns",{}),isEnabled:e=>e.model.getters.isSingleColSelected(),icon:"o-spreadsheet-Icon.SPLIT_TEXT"},Sf={name:r("Automatic"),execute:e=>Yp(e,""),isActive:e=>function(e){const t=e.model.getters.getCell(e.model.getters.getActivePosition());return!t||!t.format}(e)},Cf={name:r("Number"),description:"1,000.12",execute:e=>Yp(e,"#,##0.00"),isActive:e=>tb(e,"#,##0.00")},Ef={name:r("Format as percent"),execute:rm,icon:"o-spreadsheet-Icon.PERCENT"},wf={name:r("Percent"),description:"10.12%",execute:rm,isActive:e=>tb(e,"0.00%")},yf={name:r("Currency"),description:"$1,000.12",execute:e=>Yp(e,"[$$]#,##0.00"),isActive:e=>tb(e,"[$$]#,##0.00")},xf={name:r("Currency rounded"),description:"$1,000",execute:e=>Yp(e,"[$$]#,##0"),isActive:e=>tb(e,"[$$]#,##0")},If={name:r("Custom currency"),isVisible:e=>void 0!==e.loadCurrencies,execute:e=>e.openSidePanel("CustomCurrency",{})},Rf={name:r("Date"),description:"9/26/2008",execute:e=>Yp(e,e.model.getters.getLocale().dateFormat),isActive:e=>tb(e,e.model.getters.getLocale().dateFormat)},Tf={name:r("Time"),description:"10:43:00 PM",execute:e=>Yp(e,e.model.getters.getLocale().timeFormat),isActive:e=>tb(e,e.model.getters.getLocale().timeFormat)},Af={name:r("Date time"),description:"9/26/2008 22:43:00",execute:e=>{const t=e.model.getters.getLocale();Yp(e,t.dateFormat+" "+t.timeFormat)},isActive:e=>{const t=e.model.getters.getLocale();return tb(e,t.dateFormat+" "+t.timeFormat)}},Of={name:r("Duration"),description:"27:51:38",execute:e=>Yp(e,"hhhh:mm:ss"),isActive:e=>tb(e,"hhhh:mm:ss")},Nf={name:r("Increase decimal places"),icon:"o-spreadsheet-Icon.INCREASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:1})},Mf={name:r("Decrease decimal places"),icon:"o-spreadsheet-Icon.DECRASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:-1})},_f={name:r("Bold"),description:"Ctrl+B",execute:e=>Xp(e,{bold:!e.model.getters.getCurrentStyle().bold}),icon:"o-spreadsheet-Icon.BOLD",isActive:e=>!!e.model.getters.getCurrentStyle().bold},Ff={name:r("Italic"),description:"Ctrl+I",execute:e=>Xp(e,{italic:!e.model.getters.getCurrentStyle().italic}),icon:"o-spreadsheet-Icon.ITALIC",isActive:e=>!!e.model.getters.getCurrentStyle().italic},Df={name:r("Underline"),description:"Ctrl+U",execute:e=>Xp(e,{underline:!e.model.getters.getCurrentStyle().underline}),icon:"o-spreadsheet-Icon.UNDERLINE",isActive:e=>!!e.model.getters.getCurrentStyle().underline},Lf={name:r("Strikethrough"),execute:e=>Xp(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),icon:"o-spreadsheet-Icon.STRIKE",isActive:e=>!!e.model.getters.getCurrentStyle().strikethrough},Pf={name:r("Font size"),children:me.map((e=>({name:e.toString(),sequence:e,id:`font_size_${e}`,execute:t=>Xp(t,{fontSize:e}),isActive:t=>function(e,t){const o=e.model.getters.getCurrentStyle().fontSize||q;return o===t}(t,e)}))),icon:"o-spreadsheet-Icon.FONT_SIZE"},kf={name:r("Alignment"),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},Uf={name:r("Horizontal align"),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},Vf={name:r("Left"),description:"Ctrl+Shift+L",execute:e=>Xp(e,{align:"left"}),isActive:e=>"left"===ob(e),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},zf={name:r("Center"),description:"Ctrl+Shift+E",execute:e=>Xp(e,{align:"center"}),isActive:e=>"center"===ob(e),icon:"o-spreadsheet-Icon.ALIGN_CENTER"},Bf={name:r("Right"),description:"Ctrl+Shift+R",execute:e=>Xp(e,{align:"right"}),isActive:e=>"right"===ob(e),icon:"o-spreadsheet-Icon.ALIGN_RIGHT"},Hf={name:r("Vertical align"),icon:"o-spreadsheet-Icon.ALIGN_MIDDLE"},$f={name:r("Top"),execute:e=>Xp(e,{verticalAlign:"top"}),isActive:e=>"top"===(e.model.getters.getCurrentStyle().verticalAlign||j),icon:"o-spreadsheet-Icon.ALIGN_TOP"},Wf={name:r("Middle"),execute:e=>Xp(e,{verticalAlign:"middle"}),isActive:e=>"middle"===(e.model.getters.getCurrentStyle().verticalAlign||j),icon:"o-spreadsheet-Icon.ALIGN_MIDDLE"},Gf={name:r("Bottom"),execute:e=>Xp(e,{verticalAlign:"bottom"}),isActive:e=>"bottom"===(e.model.getters.getCurrentStyle().verticalAlign||j),icon:"o-spreadsheet-Icon.ALIGN_BOTTOM"},qf={name:r("Wrapping"),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Zf={name:r("Overflow"),execute:e=>Xp(e,{wrapping:"overflow"}),isActive:e=>"overflow"===(e.model.getters.getCurrentStyle().wrapping||"overflow"),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},jf={name:r("Wrap"),execute:e=>Xp(e,{wrapping:"wrap"}),isActive:e=>"wrap"===e.model.getters.getCurrentStyle().wrapping,icon:"o-spreadsheet-Icon.WRAPPING_WRAP"},Yf={name:r("Clip"),execute:e=>Xp(e,{wrapping:"clip"}),isActive:e=>"clip"===e.model.getters.getCurrentStyle().wrapping,icon:"o-spreadsheet-Icon.WRAPPING_CLIP"},Xf={name:r("Text Color"),icon:"o-spreadsheet-Icon.TEXT_COLOR"},Kf={name:r("Fill Color"),icon:"o-spreadsheet-Icon.FILL_COLOR"},Qf={name:r("Conditional formatting"),execute:e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},icon:"o-spreadsheet-Icon.CONDITIONAL_FORMAT"},Jf={name:r("Paint Format"),execute:e=>e.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:e.model.getters.getSelectedZones()}),icon:"o-spreadsheet-Icon.PAINT_FORMAT",isActive:e=>e.model.getters.isPaintingFormat()},eb={name:r("Clear formatting"),description:"Ctrl+<",execute:e=>e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()}),icon:"o-spreadsheet-Icon.CLEAR_FORMAT"};function tb(e,t){return e.model.getters.getCell(e.model.getters.getActivePosition())?.format===t}function ob(e){const t=e.model.getters.getCurrentStyle();if(t.align)return t.align;return e.model.getters.getActiveCell().defaultAlign}var ib=Object.freeze({__proto__:null,formatNumberAutomatic:Sf,formatNumberNumber:Cf,formatPercent:Ef,formatNumberPercent:wf,formatNumberCurrency:yf,formatNumberCurrencyRounded:xf,formatCustomCurrency:If,formatNumberDate:Rf,formatNumberTime:Tf,formatNumberDateTime:Af,formatNumberDuration:Of,incraseDecimalPlaces:Nf,decraseDecimalPlaces:Mf,formatBold:_f,formatItalic:Ff,formatUnderline:Df,formatStrikethrough:Lf,formatFontSize:Pf,formatAlignment:kf,formatAlignmentHorizontal:Uf,formatAlignmentLeft:Vf,formatAlignmentCenter:zf,formatAlignmentRight:Bf,formatAlignmentVertical:Hf,formatAlignmentTop:$f,formatAlignmentMiddle:Wf,formatAlignmentBottom:Gf,formatWrapping:qf,formatWrappingOverflow:Zf,formatWrappingWrap:jf,formatWrappingClip:Yf,textColor:Xf,fillColor:Kf,formatCF:Qf,paintFormat:Jf,clearFormat:eb});function sb(e,t,o){const i=e.model.getters.getActiveSheetId(),s="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(s,{sheetId:i,quantity:o}).isCancelledBecause(66)&&e.raiseError(Kg)}const rb={name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide column %s",Et(o).toString()):i-o+1===t.length?r("Hide columns %s - %s",Et(o).toString(),Et(i).toString()):r("Hide columns")},execute:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:em,icon:"o-spreadsheet-Icon.HIDE_COL"},nb={name:r("Unhide columns"),execute:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))}},ab={name:r("Unhide all columns"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0},lb={name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide row %s",(o+1).toString()):i-o+1===t.length?r("Hide rows %s - %s",(o+1).toString(),(i+1).toString()):r("Hide rows")},execute:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:Jp,icon:"o-spreadsheet-Icon.HIDE_ROW"},cb={name:r("Unhide rows"),execute:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))}},hb={name:r("Unhide all rows"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0},db={name:r("Unfreeze"),isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},execute:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),icon:"o-spreadsheet-Icon.UNFREEZE"},ub={name:r("Freeze"),icon:"o-spreadsheet-Icon.FREEZE"},gb={name:r("No rows"),execute:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit},pb={name:r("1 row"),execute:e=>sb(e,"ROW",1),isReadonlyAllowed:!0},mb={name:r("2 rows"),execute:e=>sb(e,"ROW",2),isReadonlyAllowed:!0},fb={name:r("Up to current row"),execute:e=>{const{bottom:t}=e.model.getters.getSelectedZone();sb(e,"ROW",t+1)},isReadonlyAllowed:!0},bb={name:r("No columns"),execute:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit},vb={name:r("1 column"),execute:e=>sb(e,"COL",1),isReadonlyAllowed:!0},Sb={name:r("2 columns"),execute:e=>sb(e,"COL",2),isReadonlyAllowed:!0},Cb={name:r("Up to current column"),execute:e=>{const{right:t}=e.model.getters.getSelectedZone();sb(e,"COL",t+1)},isReadonlyAllowed:!0},Eb={name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},icon:"o-spreadsheet-Icon.SHOW_HIDE_GRID"},wb={name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),execute:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},yb={name:e=>xb(e)?r("Remove selected filters"):r("Create filter"),isActive:e=>xb(e),isEnabled:e=>!Ib(e),execute:e=>function(e){if(xb(e))return void e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()});if(Ib(e))return;e.model.selection.selectTableAroundSelection();const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();uf(e,t,o)}(e),icon:"o-spreadsheet-Icon.FILTER_ICON_INACTIVE"};function xb(e){const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)}function Ib(e){return!xi(...e.model.getters.getSelectedZones())}var Rb=Object.freeze({__proto__:null,hideCols:rb,unhideCols:nb,unhideAllCols:ab,hideRows:lb,unhideRows:cb,unhideAllRows:hb,unFreezePane:db,freezePane:ub,unFreezeRows:gb,freezeFirstRow:pb,freezeSecondRow:mb,freezeCurrentRow:fb,unFreezeCols:bb,freezeFirstCol:vb,freezeSecondCol:Sb,freezeCurrentCol:Cb,viewGridlines:Eb,viewFormulas:wb,createRemoveFilter:yb});const Tb=new Eg;Tb.add("cut",{...um,sequence:10}).add("copy",{...dm,sequence:20}).add("paste",{...gm,sequence:30}).add("paste_special",{...pm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...mm,sequence:10}).addChild("paste_format_only",["paste_special"],{...fm,sequence:20}).add("sort_columns",{...gf,name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,separator:!0}).addChild("sort_ascending",["sort_columns"],{...pf,sequence:10}).addChild("sort_descending",["sort_columns"],{...mf,sequence:20}).add("add_column_before",{...Vm,sequence:70}).add("add_column_after",{...Hm,sequence:80}).add("delete_column",{...wm,sequence:90,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_column",{...xm,sequence:100,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_columns",{...rb,sequence:105,separator:!0}).add("unhide_columns",{...nb,sequence:106,separator:!0}).add("conditional_formatting",{...Qf,sequence:110});const Ab=new Eg;Ab.add("format_number_automatic",{...Sf,sequence:10,separator:!0}).add("format_number_number",{...Cf,sequence:20}).add("format_number_percent",{...wf,sequence:30,separator:!0}).add("format_number_currency",{...yf,sequence:40}).add("format_number_currency_rounded",{...xf,sequence:50}).add("format_custom_currency",{...If,sequence:60,separator:!0}).add("format_number_date",{...Rf,sequence:70}).add("format_number_time",{...Tf,sequence:80}).add("format_number_date_time",{...Af,sequence:90}).add("format_number_duration",{...Of,sequence:100,separator:!0});const Ob={name:r("More formats"),icon:"o-spreadsheet-Icon.NUMBER_FORMATS",children:[()=>Ab.getAll()]},Nb=new Eg;Nb.add("cut",{...um,sequence:10}).add("copy",{...dm,sequence:20}).add("paste",{...gm,sequence:30}).add("paste_special",{...pm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...mm,sequence:10}).addChild("paste_format_only",["paste_special"],{...fm,sequence:20}).add("add_row_before",{...Fm,sequence:50}).add("add_row_after",{...Pm,sequence:60}).add("delete_row",{...Sm,sequence:70,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_row",{...Em,sequence:80,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_rows",{...lb,sequence:85,separator:!0}).add("unhide_rows",{...cb,sequence:86,separator:!0}).add("conditional_formatting",{...Qf,sequence:90});const Mb=new Eg;Mb.add("file",{name:r("File"),sequence:10}).addChild("settings",["file"],{name:r("Settings"),sequence:100,execute:e=>e.openSidePanel("Settings"),icon:"o-spreadsheet-Icon.COG"}).add("edit",{name:r("Edit"),sequence:20}).addChild("undo",["edit"],{...cm,sequence:10}).addChild("redo",["edit"],{...hm,sequence:20,separator:!0}).addChild("copy",["edit"],{...dm,sequence:30}).addChild("cut",["edit"],{...um,sequence:40}).addChild("paste",["edit"],{...gm,sequence:50}).addChild("paste_special",["edit"],{...pm,sequence:60,separator:!0}).addChild("paste_special_value",["edit","paste_special"],{...mm,sequence:10}).addChild("paste_special_format",["edit","paste_special"],{...fm,sequence:20}).addChild("find_and_replace",["edit"],{...bm,sequence:65,separator:!0}).addChild("delete",["edit"],{name:r("Delete"),icon:"o-spreadsheet-Icon.DELETE",sequence:70}).addChild("edit_delete_cell_values",["edit","delete"],{...vm,sequence:10}).addChild("edit_delete_row",["edit","delete"],{...Sm,sequence:20}).addChild("edit_delete_column",["edit","delete"],{...wm,sequence:30}).addChild("edit_delete_cell_shift_up",["edit","delete"],{...Rm,sequence:40}).addChild("edit_delete_cell_shift_left",["edit","delete"],{...Tm,sequence:50}).addChild("edit_unhide_columns",["edit"],{...ab,sequence:80}).addChild("edit_unhide_rows",["edit"],{...hb,sequence:80}).add("view",{name:r("View"),sequence:30}).addChild("unfreeze_panes",["view"],{...db,sequence:4}).addChild("freeze_panes",["view"],{...ub,sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{...gb,sequence:5}).addChild("freeze_first_row",["view","freeze_panes"],{...pb,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{...mb,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{...fb,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{...bb,sequence:25}).addChild("freeze_first_col",["view","freeze_panes"],{...vb,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{...Sb,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{...Cb,sequence:40}).addChild("view_gridlines",["view"],{...Eb,sequence:10}).addChild("view_formulas",["view"],{...wb,sequence:15}).add("insert",{name:r("Insert"),sequence:40}).addChild("insert_row",["insert"],{..._m,sequence:10}).addChild("insert_row_before",["insert","insert_row"],{...Dm,sequence:10}).addChild("insert_row_after",["insert","insert_row"],{...km,sequence:20}).addChild("insert_column",["insert"],{...Um,sequence:20}).addChild("insert_column_before",["insert","insert_column"],{...zm,sequence:10}).addChild("insert_column_after",["insert","insert_column"],{...$m,sequence:20}).addChild("insert_cell",["insert"],{...Wm,sequence:43}).addChild("insert_cell_down",["insert","insert_cell"],{...Gm,name:r("Shift down"),sequence:10}).addChild("insert_cell_right",["insert","insert_cell"],{...qm,name:r("Shift right"),sequence:20}).addChild("insert_sheet",["insert"],{...sf,sequence:80,separator:!0}).addChild("insert_chart",["insert"],{...Zm,sequence:50}).addChild("insert_image",["insert"],{...jm,sequence:55}).addChild("insert_function",["insert"],{...Ym,sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{...Xm,sequence:0}).addChild("insert_function_average",["insert","insert_function"],{...Km,sequence:10}).addChild("insert_function_count",["insert","insert_function"],{...Qm,sequence:20}).addChild("insert_function_max",["insert","insert_function"],{...Jm,sequence:30}).addChild("insert_function_min",["insert","insert_function"],{...ef,sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{...tf,sequence:50}).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=tu.content;return[...new Set(tu.getAll().map((e=>e.category)))].filter(He).sort().map(((t,o)=>{const i=Object.keys(e).filter((o=>e[o].category===t));return{name:t,children:rf(i)}}))})).addChild("insert_link",["insert"],{...of,separator:!0,sequence:70}).add("format",{name:r("Format"),sequence:50}).addChild("format_number",["format"],{...Ob,name:r("Number"),sequence:10,separator:!0}).addChild("format_bold",["format"],{..._f,sequence:20}).addChild("format_italic",["format"],{...Ff,sequence:30}).addChild("format_underline",["format"],{...Df,sequence:40}).addChild("format_strikethrough",["format"],{...Lf,sequence:50,separator:!0}).addChild("format_font_size",["format"],{...Pf,sequence:60,separator:!0}).addChild("format_alignment",["format"],{...kf,sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{...Vf,sequence:10}).addChild("format_alignment_center",["format","format_alignment"],{...zf,sequence:20}).addChild("format_alignment_right",["format","format_alignment"],{...Bf,sequence:30,separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{...$f,sequence:40}).addChild("format_alignment_middle",["format","format_alignment"],{...Wf,sequence:50}).addChild("format_alignment_bottom",["format","format_alignment"],{...Gf,sequence:60,separator:!0}).addChild("format_wrapping",["format"],{...qf,sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{...Zf,sequence:10}).addChild("format_wrapping_wrap",["format","format_wrapping"],{...jf,sequence:20}).addChild("format_wrapping_clip",["format","format_wrapping"],{...Yf,sequence:30}).addChild("format_cf",["format"],{...Qf,sequence:90,separator:!0}).addChild("format_clearFormat",["format"],{...eb,sequence:100,separator:!0}).add("data",{name:r("Data"),sequence:60}).addChild("sort_range",["data"],{...gf,sequence:10,separator:!0}).addChild("sort_ascending",["data","sort_range"],{...pf,sequence:10}).addChild("sort_descending",["data","sort_range"],{...mf,sequence:20}).addChild("split_to_columns",["data"],{...vf,sequence:20,separator:!0}).addChild("add_data_filter",["data"],{...ff,sequence:30}).addChild("remove_data_filter",["data"],{...bf,sequence:30});const _b=new class extends $i{addTransformation(e,t,o){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},Fb={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function Db(e,t){const o=Fb[e.key];e.shiftKey?t.resizeAnchorZone(o,e.ctrlKey?"end":1):t.moveAnchorCell(o,e.ctrlKey?"end":1)}const Lb=new Ni;Di`
353
353
  .o-selection {
354
354
  .o-selection-input {
355
355
  padding: 2px 0px;
@@ -400,7 +400,7 @@
400
400
  font-size: calc(100% + 4px);
401
401
  }
402
402
  }
403
- `;class Nb extends t.Component{static template="o-spreadsheet-SelectionInput";id=Ob.uuidv4();previousRanges=this.props.ranges()||[];originSheet=this.env.model.getters.getActiveSheetId();state=t.useState({isMissing:!1,mode:"select-range"});focusedInput=t.useRef("focusedInput");get ranges(){const e=this.env.model.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges()?this.props.ranges().map(((e,t)=>({xc:e,id:t,isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.env.model.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}get isConfirmable(){return this.hasFocus&&this.ranges.every((e=>e.isValidRange))}get isResettable(){return this.previousRanges.join()!==this.ranges.map((e=>e.xc)).join()}setup(){t.useEffect((()=>this.focusedInput.el?.focus()),(()=>[this.focusedInput.el])),t.onMounted((()=>this.enableNewSelectionInput())),t.onWillUnmount((async()=>this.disableNewSelectionInput())),t.onPatched((()=>this.checkChange()))}enableNewSelectionInput(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges(),hasSingleRange:this.props.hasSingleRange})}disableNewSelectionInput(){this.env.model.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}checkChange(){const e=this.env.model.getters.getSelectionInputValue(this.id),t=!this.isInvalid&&this.ranges.every((e=>e.isValidRange));t&&this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.props.onSelectionChanged?.(e)}onKeydown(e){if("F2"===e.key)e.preventDefault(),e.stopPropagation(),this.state.mode="select-range"===this.state.mode?"text-edit":"select-range";else if(e.key.startsWith("Arrow"))e.stopPropagation(),"select-range"===this.state.mode&&(e.preventDefault(),Ab(e,this.env.model.selection));else if("Enter"===e.key){e.target.blur(),this.confirm()}}extractRanges(e){return this.props.hasSingleRange?e.split(",")[0]:e}focus(e){this.state.isMissing=!1,this.state.mode="select-range",this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),this.props.onSelectionConfirmed?.()}onInputChanged(e,t){const o=t.target,i=this.extractRanges(o.value);this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:i}),this.triggerChange()}reset(){const e=this.env.model.getters.getSelectionInput(this.id);for(const t of e)this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:t.id});for(const e of this.previousRanges)this.env.model.dispatch("ADD_RANGE",{id:this.id,value:e});this.confirm()}confirm(){let e=!1;const t=this.env.model.getters.getSelectionInput(this.id),o=[];for(const i of t)""!==i.xc?(o.push(i.xc),this.env.model.getters.isRangeValid(i.xc)&&(e=!0)):this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:i.id});this.props.required&&!e&&(this.state.isMissing=!0);const i=this.env.model.getters.getActiveSheetId();this.originSheet!==i&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:this.originSheet}),this.props.onSelectionChanged?.(o),this.props.onSelectionConfirmed?.(),this.previousRanges=this.props.ranges(),o.join()!==this.previousRanges.join()&&this.enableNewSelectionInput(),this.env.model.dispatch("UNFOCUS_SELECTION_INPUT")}}Nb.props={ranges:Function,hasSingleRange:{type:Boolean,optional:!0},required:{type:Boolean,optional:!0},isInvalid:{type:Boolean,optional:!0},class:{type:String,optional:!0},onSelectionChanged:{type:Function,optional:!0},onSelectionConfirmed:{type:Function,optional:!0}},Di`
403
+ `;class Pb extends t.Component{static template="o-spreadsheet-SelectionInput";id=Lb.uuidv4();previousRanges=this.props.ranges()||[];originSheet=this.env.model.getters.getActiveSheetId();state=t.useState({isMissing:!1,mode:"select-range"});focusedInput=t.useRef("focusedInput");get ranges(){const e=this.env.model.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges()?this.props.ranges().map(((e,t)=>({xc:e,id:t,isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.env.model.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}get isConfirmable(){return this.hasFocus&&this.ranges.every((e=>e.isValidRange))}get isResettable(){return this.previousRanges.join()!==this.ranges.map((e=>e.xc)).join()}setup(){t.useEffect((()=>this.focusedInput.el?.focus()),(()=>[this.focusedInput.el])),t.onMounted((()=>this.enableNewSelectionInput())),t.onWillUnmount((async()=>this.disableNewSelectionInput())),t.onPatched((()=>this.checkChange()))}enableNewSelectionInput(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges(),hasSingleRange:this.props.hasSingleRange})}disableNewSelectionInput(){this.env.model.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}checkChange(){const e=this.env.model.getters.getSelectionInputValue(this.id),t=!this.isInvalid&&this.ranges.every((e=>e.isValidRange));t&&this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.props.onSelectionChanged?.(e)}onKeydown(e){if("F2"===e.key)e.preventDefault(),e.stopPropagation(),this.state.mode="select-range"===this.state.mode?"text-edit":"select-range";else if(e.key.startsWith("Arrow"))e.stopPropagation(),"select-range"===this.state.mode&&(e.preventDefault(),Db(e,this.env.model.selection));else if("Enter"===e.key){e.target.blur(),this.confirm()}}extractRanges(e){return this.props.hasSingleRange?e.split(",")[0]:e}focus(e){this.state.isMissing=!1,this.state.mode="select-range",this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),this.props.onSelectionConfirmed?.()}onInputChanged(e,t){const o=t.target,i=this.extractRanges(o.value);this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:i}),this.triggerChange()}reset(){const e=this.env.model.getters.getSelectionInput(this.id);for(const t of e)this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:t.id});for(const e of this.previousRanges)this.env.model.dispatch("ADD_RANGE",{id:this.id,value:e});this.confirm()}confirm(){let e=!1;const t=this.env.model.getters.getSelectionInput(this.id),o=[];for(const i of t)""!==i.xc?(o.push(i.xc),this.env.model.getters.isRangeValid(i.xc)&&(e=!0)):this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:i.id});this.props.required&&!e&&(this.state.isMissing=!0);const i=this.env.model.getters.getActiveSheetId();this.originSheet!==i&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:this.originSheet}),this.props.onSelectionChanged?.(o),this.props.onSelectionConfirmed?.(),this.previousRanges=this.props.ranges(),o.join()!==this.previousRanges.join()&&this.enableNewSelectionInput(),this.env.model.dispatch("UNFOCUS_SELECTION_INPUT")}}Pb.props={ranges:Function,hasSingleRange:{type:Boolean,optional:!0},required:{type:Boolean,optional:!0},isInvalid:{type:Boolean,optional:!0},class:{type:String,optional:!0},onSelectionChanged:{type:Function,optional:!0},onSelectionConfirmed:{type:Function,optional:!0}},Di`
404
404
  .o-sidepanel-error,
405
405
  .o-sidepanel-warning {
406
406
  margin-top: 10px;
@@ -411,7 +411,7 @@
411
411
  width: 1.2em;
412
412
  }
413
413
  }
414
- `;class Mb extends t.Component{static template="o-spreadsheet-SidePanelErrors";get divClasses(){return"warning"===this.props.msgType?"o-sidepanel-warning text-warning":"o-sidepanel-error text-danger"}}Mb.props={messages:Array,msgType:String};class _b extends t.Component{static template="o-spreadsheet-LineBarPieConfigPanel";static components={SelectionInput:Nb,SidePanelErrors:Mb};state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0});dataSeriesRanges=[];labelRange;setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}get errorMessages(){return[...this.state.datasetDispatchResult?.reasons||[],...this.state.labelsDispatchResult?.reasons||[]].map((e=>$g.Errors[e]||$g.Errors.Unexpected))}get isDatasetInvalid(){return!!this.state.datasetDispatchResult?.isCancelledBecause(33)}get isLabelInvalid(){return!!this.state.labelsDispatchResult?.isCancelledBecause(34)}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.figureId,{dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e,this.state.datasetDispatchResult=this.props.canUpdateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}onDataSeriesConfirmed(){this.dataSeriesRanges=function(e,t){const o=[];for(const i of t){if(!e.isRangeValid(i)){o.push(i);continue}const{sheetName:t}=Ko(i),s=t?`${t}!`:"",r=Qo(i);if(r.bottom!==r.top&&r.left!=r.right)if(r.right)for(let e=r.left;e<=r.right;++e)o.push(`${s}${ti({left:e,right:e,top:r.top,bottom:r.bottom})}`);else for(let e=r.top;e<=r.bottom;++e)o.push(`${s}${ti({left:r.left,right:r.right,top:e,bottom:e})}`);else o.push(i)}return o}(this.env.model.getters,this.dataSeriesRanges),this.state.datasetDispatchResult=this.props.updateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}getDataSeriesRanges(){return this.dataSeriesRanges}onLabelRangeChanged(e){this.labelRange=e[0],this.state.labelsDispatchResult=this.props.canUpdateChart(this.props.figureId,{labelRange:this.labelRange})}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.figureId,{labelRange:this.labelRange})}getLabelRange(){return this.labelRange||""}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}calculateHeaderPosition(){if(this.isDatasetInvalid||this.isLabelInvalid)return;const e=this.env.model.getters,t=e.getActiveSheetId(),o=Ti(e,t,this.labelRange),i=Tg(e,this.dataSeriesRanges,t,this.props.definition.dataSetsHaveTitle);return i.length?i[0].dataRange.zone.top+1:o?o.zone.top+1:void 0}}_b.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class Fb extends _b{static template="o-spreadsheet-BarConfigPanel";onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}function Db(e,t,o=(()=>{})){const i=e=>{e.preventDefault(),o(e)},s=t=>{t.preventDefault(),e(t)},r=e=>{e.preventDefault(),t(e),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",r),window.removeEventListener("dragstart",n),window.removeEventListener("mousemove",s),window.removeEventListener("wheel",s)};function n(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",r),window.addEventListener("dragstart",n),window.addEventListener("mousemove",s),window.addEventListener("wheel",s,{passive:!1})}function Lb(e,t,o,i=!1){let s,r,n,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=gr();let g,p;const m=o=>{if(s=o,c)return;const{x:n,y:f}=h.getMainViewportCoordinates();let{top:b,left:v,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let I=!1,R=Kt;const T=s.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==i){const t=r.clientX-u.left,o=h.getEdgeScrollCol(T,t,a);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":g=y,t=y;break;case 1:g=C,t=v+1;break;case-1:for(g=v-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-n}}const A=s.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==i){const t=r.clientY-u.top,o=h.getEdgeScrollRow(A,t,l);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":p=x,t=x;break;case 1:p=S,t=b+o.direction;break;case-1:for(p=b-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,s),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(s)}),Math.round(R))),r=s};Db(m,(()=>{clearTimeout(c),o()}),(e=>{r=e,n=e,a=n.clientX-u.left,l=n.clientY-u.top}))}const Pb=216,kb=186;Di`
414
+ `;class kb extends t.Component{static template="o-spreadsheet-SidePanelErrors";get divClasses(){return"warning"===this.props.msgType?"o-sidepanel-warning text-warning":"o-sidepanel-error text-danger"}}kb.props={messages:Array,msgType:String};class Ub extends t.Component{static template="o-spreadsheet-LineBarPieConfigPanel";static components={SelectionInput:Pb,SidePanelErrors:kb};state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0});dataSeriesRanges=[];labelRange;setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}get errorMessages(){return[...this.state.datasetDispatchResult?.reasons||[],...this.state.labelsDispatchResult?.reasons||[]].map((e=>Yg.Errors[e]||Yg.Errors.Unexpected))}get isDatasetInvalid(){return!!this.state.datasetDispatchResult?.isCancelledBecause(33)}get isLabelInvalid(){return!!this.state.labelsDispatchResult?.isCancelledBecause(34)}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.figureId,{dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e,this.state.datasetDispatchResult=this.props.canUpdateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}onDataSeriesConfirmed(){this.dataSeriesRanges=function(e,t){const o=[];for(const i of t){if(!e.isRangeValid(i)){o.push(i);continue}const{sheetName:t}=Ko(i),s=t?`${t}!`:"",r=Qo(i);if(r.bottom!==r.top&&r.left!=r.right)if(r.right)for(let e=r.left;e<=r.right;++e)o.push(`${s}${ti({left:e,right:e,top:r.top,bottom:r.bottom})}`);else for(let e=r.top;e<=r.bottom;++e)o.push(`${s}${ti({left:r.left,right:r.right,top:e,bottom:e})}`);else o.push(i)}return o}(this.env.model.getters,this.dataSeriesRanges),this.state.datasetDispatchResult=this.props.updateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}getDataSeriesRanges(){return this.dataSeriesRanges}onLabelRangeChanged(e){this.labelRange=e[0],this.state.labelsDispatchResult=this.props.canUpdateChart(this.props.figureId,{labelRange:this.labelRange})}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.figureId,{labelRange:this.labelRange})}getLabelRange(){return this.labelRange||""}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}calculateHeaderPosition(){if(this.isDatasetInvalid||this.isLabelInvalid)return;const e=this.env.model.getters,t=e.getActiveSheetId(),o=Ti(e,t,this.labelRange),i=Fg(e,this.dataSeriesRanges,t,this.props.definition.dataSetsHaveTitle);return i.length?i[0].dataRange.zone.top+1:o?o.zone.top+1:void 0}}Ub.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class Vb extends Ub{static template="o-spreadsheet-BarConfigPanel";onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}function zb(e,t,o=(()=>{})){const i=e=>{e.preventDefault(),o(e)},s=t=>{t.preventDefault(),e(t)},r=e=>{e.preventDefault(),t(e),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",r),window.removeEventListener("dragstart",n),window.removeEventListener("mousemove",s),window.removeEventListener("wheel",s)};function n(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",r),window.addEventListener("dragstart",n),window.addEventListener("mousemove",s),window.addEventListener("wheel",s,{passive:!1})}function Bb(e,t,o,i=!1){let s,r,n,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=gr();let g,p;const m=o=>{if(s=o,c)return;const{x:n,y:f}=h.getMainViewportCoordinates();let{top:b,left:v,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let I=!1,R=Kt;const T=s.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==i){const t=r.clientX-u.left,o=h.getEdgeScrollCol(T,t,a);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":g=y,t=y;break;case 1:g=C,t=v+1;break;case-1:for(g=v-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-n}}const A=s.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==i){const t=r.clientY-u.top,o=h.getEdgeScrollRow(A,t,l);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":p=x,t=x;break;case 1:p=S,t=b+o.direction;break;case-1:for(p=b-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,s),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(s)}),Math.round(R))),r=s};zb(m,(()=>{clearTimeout(c),o()}),(e=>{r=e,n=e,a=n.clientX-u.left,l=n.clientY-u.top}))}const Hb=216,$b=186;Di`
415
415
  .o-color-picker {
416
416
  padding: ${8}px 0;
417
417
  /** FIXME: this is useless, overiden by the popover container */
@@ -578,7 +578,7 @@
578
578
  }
579
579
  }
580
580
  }
581
- `;class Ub extends t.Component{static template="o-spreadsheet-ColorPicker";static defaultProps={currentColor:""};static components={Popover:Er};COLORS=M;state=t.useState({showGradient:!1,currentHslaColor:dt(this.props.currentColor)?{...Ct(this.props.currentColor),a:1}:{h:0,s:100,l:100,a:1},customHexColor:dt(this.props.currentColor)?ht(this.props.currentColor):""});get colorPickerStyle(){return void 0!==this.props.maxHeight&&this.props.maxHeight<=0?Ui({display:"none"}):""}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}get gradientHueStyle(){return Ui({background:`hsl(${this.state.currentHslaColor?.h||0} 100% 50%)`})}get sliderStyle(){const e=this.state.currentHslaColor?.h||0;return Ui({"margin-left":`${we(Math.round(e/360*Pb),1,Pb)-9}px`})}get pointerStyle(){const{s:e,l:t}=this.state.currentHslaColor||{s:0,l:0};return Ui({left:`${-8+Math.round(Pb*we(e/100,0,1))}px`,top:`${-8+Math.round(kb*we(1-2*t/(200-e),0,1))}px`,background:St(this.state.currentHslaColor)})}get colorPreviewStyle(){return Ui({"background-color":St(this.state.currentHslaColor)})}get checkmarkColor(){return Dg(this.props.currentColor)}get isHexColorInputValid(){return!this.state.customHexColor||dt(this.state.customHexColor)}setCustomGradient({x:e,y:t}){const o=we(e,0,Pb),i=we(t,0,kb),s=o/Pb,r=100*s,n=100*(1-i/kb)*(1-.5*s);this.updateColor({s:r,l:n})}setCustomHue(e){const t=Math.round(we(360*e/Pb,0,359));this.updateColor({h:t})}updateColor(e){this.state.currentHslaColor={...this.state.currentHslaColor,...e},this.state.customHexColor=St(this.state.currentHslaColor)}onColorClick(e){e&&this.props.onColorPicked(ht(e))}resetColor(){this.props.onColorPicked("")}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}dragGradientPointer(e){const t={x:e.offsetX,y:e.offsetY};this.setCustomGradient(t);const o=e.clientX,i=e.clientY;Db((e=>{const s=e.clientX,r=e.clientY,n={x:t.x+(s-o),y:t.y+(r-i)};this.setCustomGradient(n)}),(()=>{}))}dragHuePointer(e){const t=e.offsetX,o=e.clientX;this.setCustomHue(t);Db((e=>{const i=e.clientX,s=t+(i-o);this.setCustomHue(s)}),(()=>{}))}setHexColor(e){const t=e.target.value.slice(0,7);this.state.customHexColor=t,dt(t)&&(this.state.currentHslaColor={...Ct(t),a:1})}addCustomColor(e){(function(e){try{return St(e),!0}catch(e){return!1}})(this.state.currentHslaColor)&&dt(this.state.customHexColor)&&this.props.onColorPicked(ht(this.state.customHexColor))}isSameColor(e,t){return function(e,t,o=0){if(!dt(e)||!dt(t))return!1;const i=ft(e),s=ft(t);return i.a===s.a&&Math.sqrt(((i.r-s.r)/255)**2+((i.g-s.g)/255)**2+((i.b-s.b)/255)**2)<=o}(e,t)}}Ub.props={onColorPicked:Function,currentColor:{type:String,optional:!0},maxHeight:{type:Number,optional:!0},anchorRect:Object},Di`
581
+ `;class Wb extends t.Component{static template="o-spreadsheet-ColorPicker";static defaultProps={currentColor:""};static components={Popover:Er};COLORS=M;state=t.useState({showGradient:!1,currentHslaColor:dt(this.props.currentColor)?{...Ct(this.props.currentColor),a:1}:{h:0,s:100,l:100,a:1},customHexColor:dt(this.props.currentColor)?ht(this.props.currentColor):""});get colorPickerStyle(){return void 0!==this.props.maxHeight&&this.props.maxHeight<=0?Ui({display:"none"}):""}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}get gradientHueStyle(){return Ui({background:`hsl(${this.state.currentHslaColor?.h||0} 100% 50%)`})}get sliderStyle(){const e=this.state.currentHslaColor?.h||0;return Ui({"margin-left":`${we(Math.round(e/360*Hb),1,Hb)-9}px`})}get pointerStyle(){const{s:e,l:t}=this.state.currentHslaColor||{s:0,l:0};return Ui({left:`${-8+Math.round(Hb*we(e/100,0,1))}px`,top:`${-8+Math.round($b*we(1-2*t/(200-e),0,1))}px`,background:St(this.state.currentHslaColor)})}get colorPreviewStyle(){return Ui({"background-color":St(this.state.currentHslaColor)})}get checkmarkColor(){return zg(this.props.currentColor)}get isHexColorInputValid(){return!this.state.customHexColor||dt(this.state.customHexColor)}setCustomGradient({x:e,y:t}){const o=we(e,0,Hb),i=we(t,0,$b),s=o/Hb,r=100*s,n=100*(1-i/$b)*(1-.5*s);this.updateColor({s:r,l:n})}setCustomHue(e){const t=Math.round(we(360*e/Hb,0,359));this.updateColor({h:t})}updateColor(e){this.state.currentHslaColor={...this.state.currentHslaColor,...e},this.state.customHexColor=St(this.state.currentHslaColor)}onColorClick(e){e&&this.props.onColorPicked(ht(e))}resetColor(){this.props.onColorPicked("")}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}dragGradientPointer(e){const t={x:e.offsetX,y:e.offsetY};this.setCustomGradient(t);const o=e.clientX,i=e.clientY;zb((e=>{const s=e.clientX,r=e.clientY,n={x:t.x+(s-o),y:t.y+(r-i)};this.setCustomGradient(n)}),(()=>{}))}dragHuePointer(e){const t=e.offsetX,o=e.clientX;this.setCustomHue(t);zb((e=>{const i=e.clientX,s=t+(i-o);this.setCustomHue(s)}),(()=>{}))}setHexColor(e){const t=e.target.value.slice(0,7);this.state.customHexColor=t,dt(t)&&(this.state.currentHslaColor={...Ct(t),a:1})}addCustomColor(e){(function(e){try{return St(e),!0}catch(e){return!1}})(this.state.currentHslaColor)&&dt(this.state.customHexColor)&&this.props.onColorPicked(ht(this.state.customHexColor))}isSameColor(e,t){return function(e,t,o=0){if(!dt(e)||!dt(t))return!1;const i=ft(e),s=ft(t);return i.a===s.a&&Math.sqrt(((i.r-s.r)/255)**2+((i.g-s.g)/255)**2+((i.b-s.b)/255)**2)<=o}(e,t)}}Wb.props={onColorPicked:Function,currentColor:{type:String,optional:!0},maxHeight:{type:Number,optional:!0},anchorRect:Object},Di`
582
582
  .o-color-picker-widget {
583
583
  display: flex;
584
584
  position: relative;
@@ -611,7 +611,7 @@
611
611
  }
612
612
  }
613
613
  }
614
- `;class Vb extends t.Component{static template="o-spreadsheet-ColorPickerWidget";static components={ColorPicker:Ub};colorPickerButtonRef=t.useRef("colorPickerButton");get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:"border-bottom-style: hidden"}get colorPickerAnchorRect(){const e=this.colorPickerButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}}Vb.props={currentColor:{type:String,optional:!0},toggleColorPicker:Function,showColorPicker:Boolean,onColorPicked:Function,icon:String,title:{type:String,optional:!0},disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};class zb extends t.Component{static template="o-spreadsheet-LineBarPieDesignPanel";static components={ColorPickerWidget:Vb};state=t.useState({title:"",fillColorTool:!1});onClick(e){this.state.fillColorTool=!1}setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart(this.props.figureId,{background:e})}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}updateSelect(e,t){this.props.updateChart(this.props.figureId,{[e]:t.target.value})}}zb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class Bb extends t.Component{static template="o-spreadsheet-GaugeChartConfigPanel";static components={SelectionInput:Nb,SidePanelErrors:Mb};state=t.useState({dataRangeDispatchResult:void 0});dataRange=this.props.definition.dataRange;get configurationErrorMessages(){return[...this.state.dataRangeDispatchResult?.reasons||[]].map((e=>$g.Errors[e]||$g.Errors.Unexpected))}get isDataRangeInvalid(){return!!this.state.dataRangeDispatchResult?.isCancelledBecause(37)}onDataRangeChanged(e){this.dataRange=e[0],this.state.dataRangeDispatchResult=this.props.canUpdateChart(this.props.figureId,{dataRange:this.dataRange})}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart(this.props.figureId,{dataRange:this.dataRange})}getDataRange(){return this.dataRange||""}}Bb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function},Di`
614
+ `;class Gb extends t.Component{static template="o-spreadsheet-ColorPickerWidget";static components={ColorPicker:Wb};colorPickerButtonRef=t.useRef("colorPickerButton");get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:"border-bottom-style: hidden"}get colorPickerAnchorRect(){const e=this.colorPickerButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}}Gb.props={currentColor:{type:String,optional:!0},toggleColorPicker:Function,showColorPicker:Boolean,onColorPicked:Function,icon:String,title:{type:String,optional:!0},disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};class qb extends t.Component{static template="o-spreadsheet-LineBarPieDesignPanel";static components={ColorPickerWidget:Gb};state=t.useState({title:"",fillColorTool:!1});onClick(e){this.state.fillColorTool=!1}setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart(this.props.figureId,{background:e})}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}updateSelect(e,t){this.props.updateChart(this.props.figureId,{[e]:t.target.value})}}qb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class Zb extends t.Component{static template="o-spreadsheet-GaugeChartConfigPanel";static components={SelectionInput:Pb,SidePanelErrors:kb};state=t.useState({dataRangeDispatchResult:void 0});dataRange=this.props.definition.dataRange;get configurationErrorMessages(){return[...this.state.dataRangeDispatchResult?.reasons||[]].map((e=>Yg.Errors[e]||Yg.Errors.Unexpected))}get isDataRangeInvalid(){return!!this.state.dataRangeDispatchResult?.isCancelledBecause(37)}onDataRangeChanged(e){this.dataRange=e[0],this.state.dataRangeDispatchResult=this.props.canUpdateChart(this.props.figureId,{dataRange:this.dataRange})}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart(this.props.figureId,{dataRange:this.dataRange})}getDataRange(){return this.dataRange||""}}Zb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function},Di`
615
615
  .o-gauge-color-set {
616
616
  table {
617
617
  table-layout: fixed;
@@ -641,7 +641,7 @@
641
641
  box-sizing: border-box;
642
642
  }
643
643
  }
644
- `;class Hb extends t.Component{static template="o-spreadsheet-GaugeChartDesignPanel";static components={ColorPickerWidget:Vb,SidePanelErrors:Mb};state=t.useState({title:"",openedMenu:void 0,sectionRuleDispatchResult:void 0,sectionRule:Se(this.props.definition.sectionRule)});setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.closeMenus)}get designErrorMessages(){return[...this.state.sectionRuleDispatchResult?.reasons||[]].map((e=>$g.Errors[e]||$g.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart(this.props.figureId,{background:e})}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}isRangeMinInvalid(){return!!(this.state.sectionRuleDispatchResult?.isCancelledBecause(38)||this.state.sectionRuleDispatchResult?.isCancelledBecause(39)||this.state.sectionRuleDispatchResult?.isCancelledBecause(42))}isRangeMaxInvalid(){return!!(this.state.sectionRuleDispatchResult?.isCancelledBecause(40)||this.state.sectionRuleDispatchResult?.isCancelledBecause(41)||this.state.sectionRuleDispatchResult?.isCancelledBecause(42))}get isLowerInflectionPointInvalid(){return!(!this.state.sectionRuleDispatchResult?.isCancelledBecause(43)&&!this.state.sectionRuleDispatchResult?.isCancelledBecause(45))}get isUpperInflectionPointInvalid(){return!(!this.state.sectionRuleDispatchResult?.isCancelledBecause(44)&&!this.state.sectionRuleDispatchResult?.isCancelledBecause(45))}updateSectionColor(e,t){const o=Se(this.state.sectionRule);o.colors[e]=t,this.updateSectionRule(o),this.closeMenus()}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart(this.props.figureId,{sectionRule:e})}canUpdateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.canUpdateChart(this.props.figureId,{sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}Hb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class $b extends _b{static template="o-spreadsheet-LineConfigPanel";get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof gp)&&pp(e.labelRange,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart(this.props.figureId,{labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}class Wb extends t.Component{static template="o-spreadsheet-ScorecardChartConfigPanel";static components={SelectionInput:Nb,SidePanelErrors:Mb};state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0});keyValue=this.props.definition.keyValue;baseline=this.props.definition.baseline;get errorMessages(){return[...this.state.keyValueDispatchResult?.reasons||[],...this.state.baselineDispatchResult?.reasons||[]].map((e=>$g.Errors[e]||$g.Errors.Unexpected))}get isKeyValueInvalid(){return!!this.state.keyValueDispatchResult?.isCancelledBecause(35)}get isBaselineInvalid(){return!!this.state.keyValueDispatchResult?.isCancelledBecause(36)}onKeyValueRangeChanged(e){this.keyValue=e[0],this.state.keyValueDispatchResult=this.props.canUpdateChart(this.props.figureId,{keyValue:this.keyValue})}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart(this.props.figureId,{keyValue:this.keyValue})}getKeyValueRange(){return this.keyValue||""}onBaselineRangeChanged(e){this.baseline=e[0],this.state.baselineDispatchResult=this.props.canUpdateChart(this.props.figureId,{baseline:this.baseline})}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart(this.props.figureId,{baseline:this.baseline})}getBaselineRange(){return this.baseline||""}updateBaselineMode(e){this.props.updateChart(this.props.figureId,{baselineMode:e.target.value})}}Wb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class Gb extends t.Component{static template="o-spreadsheet-ScorecardChartDesignPanel";static components={ColorPickerWidget:Vb};state=t.useState({title:"",openedColorPicker:void 0});setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.closeMenus)}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}updateBaselineDescr(e){this.props.updateChart(this.props.figureId,{baselineDescr:e.target.value})}toggleColorPicker(e){this.state.openedColorPicker===e?this.state.openedColorPicker=void 0:this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart(this.props.figureId,{background:e});break;case"baselineColorDown":this.props.updateChart(this.props.figureId,{baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart(this.props.figureId,{baselineColorUp:e})}this.closeMenus()}closeMenus(){this.state.openedColorPicker=void 0}}Gb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};const qb=new $i;qb.add("line",{configuration:$b,design:class extends zb{static template="o-spreadsheet-LineChartDesignPanel"}}).add("bar",{configuration:Fb,design:class extends zb{static template="o-spreadsheet-BarChartDesignPanel"}}).add("pie",{configuration:_b,design:zb}).add("gauge",{configuration:Bb,design:Hb}).add("scorecard",{configuration:Wb,design:Gb}),Di`
644
+ `;class jb extends t.Component{static template="o-spreadsheet-GaugeChartDesignPanel";static components={ColorPickerWidget:Gb,SidePanelErrors:kb};state=t.useState({title:"",openedMenu:void 0,sectionRuleDispatchResult:void 0,sectionRule:Se(this.props.definition.sectionRule)});setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.closeMenus)}get designErrorMessages(){return[...this.state.sectionRuleDispatchResult?.reasons||[]].map((e=>Yg.Errors[e]||Yg.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart(this.props.figureId,{background:e})}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}isRangeMinInvalid(){return!!(this.state.sectionRuleDispatchResult?.isCancelledBecause(38)||this.state.sectionRuleDispatchResult?.isCancelledBecause(39)||this.state.sectionRuleDispatchResult?.isCancelledBecause(42))}isRangeMaxInvalid(){return!!(this.state.sectionRuleDispatchResult?.isCancelledBecause(40)||this.state.sectionRuleDispatchResult?.isCancelledBecause(41)||this.state.sectionRuleDispatchResult?.isCancelledBecause(42))}get isLowerInflectionPointInvalid(){return!(!this.state.sectionRuleDispatchResult?.isCancelledBecause(43)&&!this.state.sectionRuleDispatchResult?.isCancelledBecause(45))}get isUpperInflectionPointInvalid(){return!(!this.state.sectionRuleDispatchResult?.isCancelledBecause(44)&&!this.state.sectionRuleDispatchResult?.isCancelledBecause(45))}updateSectionColor(e,t){const o=Se(this.state.sectionRule);o.colors[e]=t,this.updateSectionRule(o),this.closeMenus()}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart(this.props.figureId,{sectionRule:e})}canUpdateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.canUpdateChart(this.props.figureId,{sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}jb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class Yb extends Ub{static template="o-spreadsheet-LineConfigPanel";get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof Sp)&&Cp(e.labelRange,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart(this.props.figureId,{labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}class Xb extends t.Component{static template="o-spreadsheet-ScorecardChartConfigPanel";static components={SelectionInput:Pb,SidePanelErrors:kb};state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0});keyValue=this.props.definition.keyValue;baseline=this.props.definition.baseline;get errorMessages(){return[...this.state.keyValueDispatchResult?.reasons||[],...this.state.baselineDispatchResult?.reasons||[]].map((e=>Yg.Errors[e]||Yg.Errors.Unexpected))}get isKeyValueInvalid(){return!!this.state.keyValueDispatchResult?.isCancelledBecause(35)}get isBaselineInvalid(){return!!this.state.keyValueDispatchResult?.isCancelledBecause(36)}onKeyValueRangeChanged(e){this.keyValue=e[0],this.state.keyValueDispatchResult=this.props.canUpdateChart(this.props.figureId,{keyValue:this.keyValue})}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart(this.props.figureId,{keyValue:this.keyValue})}getKeyValueRange(){return this.keyValue||""}onBaselineRangeChanged(e){this.baseline=e[0],this.state.baselineDispatchResult=this.props.canUpdateChart(this.props.figureId,{baseline:this.baseline})}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart(this.props.figureId,{baseline:this.baseline})}getBaselineRange(){return this.baseline||""}updateBaselineMode(e){this.props.updateChart(this.props.figureId,{baselineMode:e.target.value})}}Xb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class Kb extends t.Component{static template="o-spreadsheet-ScorecardChartDesignPanel";static components={ColorPickerWidget:Gb};state=t.useState({title:"",openedColorPicker:void 0});setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.closeMenus)}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}updateBaselineDescr(e){this.props.updateChart(this.props.figureId,{baselineDescr:e.target.value})}toggleColorPicker(e){this.state.openedColorPicker===e?this.state.openedColorPicker=void 0:this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart(this.props.figureId,{background:e});break;case"baselineColorDown":this.props.updateChart(this.props.figureId,{baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart(this.props.figureId,{baselineColorUp:e})}this.closeMenus()}closeMenus(){this.state.openedColorPicker=void 0}}Kb.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};const Qb=new $i;Qb.add("line",{configuration:Yb,design:class extends qb{static template="o-spreadsheet-LineChartDesignPanel"}}).add("bar",{configuration:Vb,design:class extends qb{static template="o-spreadsheet-BarChartDesignPanel"}}).add("pie",{configuration:Ub,design:qb}).add("gauge",{configuration:Zb,design:jb}).add("scorecard",{configuration:Xb,design:Kb}),Di`
645
645
  .o-chart {
646
646
  .o-panel {
647
647
  display: flex;
@@ -664,7 +664,7 @@
664
664
  }
665
665
  }
666
666
  }
667
- `;class Zb extends t.Component{static template="o-spreadsheet-ChartPanel";state;get figureId(){return this.state.figureId}setup(){const e=this.env.model.getters.getSelectedFigureId();e?(this.state=t.useState({panel:"configuration",figureId:e}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId&&(this.state.figureId=e),this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))):this.props.onCloseSidePanel()}updateChart(e,t){if(e!==this.figureId)return;const o={...this.getChartDefinition(),...t};return this.env.model.dispatch("UPDATE_CHART",{definition:o,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}canUpdateChart(e,t){if(e!==this.figureId)return;const o={...this.getChartDefinition(),...t};return this.env.model.canDispatch("UPDATE_CHART",{definition:o,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const o=function(e,t){return yp.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:o,id:this.figureId,sheetId:this.env.model.getters.getFigureSheetId(this.figureId)})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=qb.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}getChartDefinition(e=this.figureId){return this.env.model.getters.getChartDefinition(e)}get chartTypes(){return function(){const e={};for(const t of yp.getKeys())e[t]=yp.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}Zb.props={onCloseSidePanel:Function},Di`
667
+ `;class Jb extends t.Component{static template="o-spreadsheet-ChartPanel";state;get figureId(){return this.state.figureId}setup(){const e=this.env.model.getters.getSelectedFigureId();e?(this.state=t.useState({panel:"configuration",figureId:e}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId&&(this.state.figureId=e),this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))):this.props.onCloseSidePanel()}updateChart(e,t){if(e!==this.figureId)return;const o={...this.getChartDefinition(),...t};return this.env.model.dispatch("UPDATE_CHART",{definition:o,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}canUpdateChart(e,t){if(e!==this.figureId)return;const o={...this.getChartDefinition(),...t};return this.env.model.canDispatch("UPDATE_CHART",{definition:o,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const o=function(e,t){return Op.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:o,id:this.figureId,sheetId:this.env.model.getters.getFigureSheetId(this.figureId)})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=Qb.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}getChartDefinition(e=this.figureId){return this.env.model.getters.getChartDefinition(e)}get chartTypes(){return function(){const e={};for(const t of Op.getKeys())e[t]=Op.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}Jb.props={onCloseSidePanel:Function},Di`
668
668
  .o-spreadsheet {
669
669
  .o-icon {
670
670
  .small-text {
@@ -675,7 +675,7 @@
675
675
  }
676
676
  }
677
677
  }
678
- `;function jb(e){e=`<svg xmlns="http://www.w3.org/2000/svg" ${e.slice(4)}`;const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const Yb={arrowGood:{template:"ARROW_UP",img:jb('<svg class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>')},arrowNeutral:{template:"ARROW_RIGHT",img:jb('<svg class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>')},arrowBad:{template:"ARROW_DOWN",img:jb('<svg class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>')},smileyGood:{template:"SMILE",img:jb('<svg class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>')},smileyNeutral:{template:"MEH",img:jb('<svg class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>')},smileyBad:{template:"FROWN",img:jb('<svg class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>')},dotGood:{template:"GREEN_DOT",img:jb('<svg class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotNeutral:{template:"YELLOW_DOT",img:jb('<svg class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotBad:{template:"RED_DOT",img:jb('<svg class="o-cf-icon red-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#DC6965" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')}},Xb={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};Di`
678
+ `;function ev(e){e=`<svg xmlns="http://www.w3.org/2000/svg" ${e.slice(4)}`;const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const tv={arrowGood:{template:"ARROW_UP",img:ev('<svg class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>')},arrowNeutral:{template:"ARROW_RIGHT",img:ev('<svg class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>')},arrowBad:{template:"ARROW_DOWN",img:ev('<svg class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>')},smileyGood:{template:"SMILE",img:ev('<svg class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>')},smileyNeutral:{template:"MEH",img:ev('<svg class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>')},smileyBad:{template:"FROWN",img:ev('<svg class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>')},dotGood:{template:"GREEN_DOT",img:ev('<svg class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotNeutral:{template:"YELLOW_DOT",img:ev('<svg class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotBad:{template:"RED_DOT",img:ev('<svg class="o-cf-icon red-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#DC6965" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')}},ov={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};Di`
679
679
  .o-icon-picker {
680
680
  position: absolute;
681
681
  z-index: ${de.IconPicker};
@@ -694,7 +694,7 @@
694
694
  outline: 1px solid gray;
695
695
  }
696
696
  }
697
- `;class Kb extends t.Component{static template="o-spreadsheet-IconPicker";icons=Yb;iconSets=Xb;onIconClick(e){e&&this.props.onIconPicked(e)}}Kb.props={onIconPicked:Function},Di`
697
+ `;class iv extends t.Component{static template="o-spreadsheet-IconPicker";icons=tv;iconSets=ov;onIconClick(e){e&&this.props.onIconPicked(e)}}iv.props={onIconPicked:Function},Di`
698
698
  label {
699
699
  vertical-align: middle;
700
700
  }
@@ -964,13 +964,13 @@
964
964
  }
965
965
  }
966
966
  }
967
- `;class Qb extends t.Component{static template="o-spreadsheet-ConditionalFormattingPanel";static components={SelectionInput:Nb,IconPicker:Kb,ColorPickerWidget:Vb};icons=Yb;cellIsOperators=Hg;iconSets=Xb;getTextDecoration=Li;colorNumberString=ct;activeSheetId;state;setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId()).map((e=>({...e,rule:og(e.rule,this.env.model.getters.getLocale())})))}get isRangeValid(){return this.state.errors.includes(25)}errorMessage(e){return Bg.Errors[e]||Bg.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type)return Ui({"font-weight":e.style.bold?"bold":"normal","text-decoration":Li(e.style),"font-style":e.style.italic?"italic":"normal",color:e.style.textColor||"none","background-color":e.style.fillColor||"none"});if("ColorScaleRule"===e.type){const t=ct(e.minimum.color),o=e.midpoint?ct(e.midpoint.color):null,i=ct(e.maximum.color),s="background-image: linear-gradient(to right, ";return o?s+t+", "+o+", "+i+")":s+t+", "+i+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Hg[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?s("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Bg.ColorScale;case"IconSetRule":return Bg.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(qo))))return void(this.state.errors=[26]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getLocale(),o=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:tg(this.getEditorRule(),t),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});o.isSuccessful?this.switchToList():this.state.errors=o.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){return!!this.state.errors?.includes(52)}get isValue2Invalid(){return!!this.state.errors?.includes(53)}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(59)||this.state.errors.includes(51)||this.state.errors.includes(48)||this.state.errors.includes(54);case"midpoint":return this.state.errors.includes(60)||this.state.errors.includes(55)||this.state.errors.includes(50);case"maximum":return this.state.errors.includes(61)||this.state.errors.includes(56);default:return!1}}setColorScaleColor(e,t){const o=this.state.rules.colorScale[e];o&&(o.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){const e=this.state.rules.colorScale,t=ct(e.minimum.color),o=ct(e.midpoint?.color||x),i=ct(e.maximum.color),s="background-image: linear-gradient(to right, ";return void 0===e.midpoint?s+t+", "+i+")":s+t+", "+o+", "+i+")"}getThresholdColor(e){return ct(e?e.color:x)}onMidpointChange(e){const t=e.target.value,o=this.state.rules.colorScale;o.midpoint="none"===t?void 0:{color:x,value:"",...o.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(58)||this.state.errors.includes(63)||this.state.errors.includes(49);case"upperInflectionPoint":return this.state.errors.includes(57)||this.state.errors.includes(62)||this.state.errors.includes(49);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}Qb.props={selection:{type:Object,optional:!0},onCloseSidePanel:Function},Di`
967
+ `;class sv extends t.Component{static template="o-spreadsheet-ConditionalFormattingPanel";static components={SelectionInput:Pb,IconPicker:iv,ColorPickerWidget:Gb};icons=tv;cellIsOperators=jg;iconSets=ov;getTextDecoration=Li;colorNumberString=ct;activeSheetId;state;setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId()).map((e=>({...e,rule:lg(e.rule,this.env.model.getters.getLocale())})))}get isRangeValid(){return this.state.errors.includes(25)}errorMessage(e){return Zg.Errors[e]||Zg.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type)return Ui({"font-weight":e.style.bold?"bold":"normal","text-decoration":Li(e.style),"font-style":e.style.italic?"italic":"normal",color:e.style.textColor||"none","background-color":e.style.fillColor||"none"});if("ColorScaleRule"===e.type){const t=ct(e.minimum.color),o=e.midpoint?ct(e.midpoint.color):null,i=ct(e.maximum.color),s="background-image: linear-gradient(to right, ";return o?s+t+", "+o+", "+i+")":s+t+", "+i+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=jg[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?s("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Zg.ColorScale;case"IconSetRule":return Zg.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(qo))))return void(this.state.errors=[26]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getLocale(),o=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:ag(this.getEditorRule(),t),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});o.isSuccessful?this.switchToList():this.state.errors=o.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){return!!this.state.errors?.includes(52)}get isValue2Invalid(){return!!this.state.errors?.includes(53)}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(59)||this.state.errors.includes(51)||this.state.errors.includes(48)||this.state.errors.includes(54);case"midpoint":return this.state.errors.includes(60)||this.state.errors.includes(55)||this.state.errors.includes(50);case"maximum":return this.state.errors.includes(61)||this.state.errors.includes(56);default:return!1}}setColorScaleColor(e,t){const o=this.state.rules.colorScale[e];o&&(o.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){const e=this.state.rules.colorScale,t=ct(e.minimum.color),o=ct(e.midpoint?.color||x),i=ct(e.maximum.color),s="background-image: linear-gradient(to right, ";return void 0===e.midpoint?s+t+", "+i+")":s+t+", "+o+", "+i+")"}getThresholdColor(e){return ct(e?e.color:x)}onMidpointChange(e){const t=e.target.value,o=this.state.rules.colorScale;o.midpoint="none"===t?void 0:{color:x,value:"",...o.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(58)||this.state.errors.includes(63)||this.state.errors.includes(49);case"upperInflectionPoint":return this.state.errors.includes(57)||this.state.errors.includes(62)||this.state.errors.includes(49);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}sv.props={selection:{type:Object,optional:!0},onCloseSidePanel:Function},Di`
968
968
  .o-custom-currency {
969
969
  .o-format-proposals {
970
970
  color: black;
971
971
  }
972
972
  }
973
- `;class Jb extends t.Component{static template="o-spreadsheet-CustomCurrencyPanel";availableCurrencies;state;setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),o=e.position,i="before"===e.position?"after":"before",s=this.state.currencySymbol.trim()?this.state.currencySymbol:"",r=this.state.currencyCode.trim()?this.state.currencyCode:"";return r||s?[...this.createFormatProposals(t,s,r,o),...this.createFormatProposals(t,s,r,i)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){if(0===Ip.getAll().length){(await(this.env.loadCurrencies?.())||[]).forEach(((e,t)=>{Ip.add(t.toString(),e)}))}const e={name:this.env._t(Wg.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[e,...Ip.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const o=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=o.code,this.state.currencySymbol=o.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],o=e?"."+"0".repeat(e):"";return o&&t.push({format:"#,##0"+o,example:"1,000"+o}),t}createFormatProposals(e,t,o,i){let s=[];if(t)for(let o of e)s.push(this.createFormatProposal(i,o.example,o.format,t));if(o)for(let r of e){const e=("after"===i?" ":"")+o+" "+t;s.push(this.createFormatProposal(i,r.example,r.format,e))}return s}createFormatProposal(e,t,o,i){const s="[$"+i+"]";return{example:"before"===e?i+t:t+i,format:"before"===e?s+o:o+s}}getCommonFormat(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId(),o=e.map((e=>this.env.model.getters.getEvaluatedCellsInZone(t,e))).flat(),i=o[0].format;return o.every((e=>e.format===i))?i:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}Jb.props={onCloseSidePanel:Function},Di`
973
+ `;class rv extends t.Component{static template="o-spreadsheet-CustomCurrencyPanel";availableCurrencies;state;setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),o=e.position,i="before"===e.position?"after":"before",s=this.state.currencySymbol.trim()?this.state.currencySymbol:"",r=this.state.currencyCode.trim()?this.state.currencyCode:"";return r||s?[...this.createFormatProposals(t,s,r,o),...this.createFormatProposals(t,s,r,i)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){if(0===Mp.getAll().length){(await(this.env.loadCurrencies?.())||[]).forEach(((e,t)=>{Mp.add(t.toString(),e)}))}const e={name:this.env._t(Xg.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[e,...Mp.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const o=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=o.code,this.state.currencySymbol=o.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],o=e?"."+"0".repeat(e):"";return o&&t.push({format:"#,##0"+o,example:"1,000"+o}),t}createFormatProposals(e,t,o,i){let s=[];if(t)for(let o of e)s.push(this.createFormatProposal(i,o.example,o.format,t));if(o)for(let r of e){const e=("after"===i?" ":"")+o+" "+t;s.push(this.createFormatProposal(i,r.example,r.format,e))}return s}createFormatProposal(e,t,o,i){const s="[$"+i+"]";return{example:"before"===e?i+t:t+i,format:"before"===e?s+o:o+s}}getCommonFormat(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId(),o=e.map((e=>this.env.model.getters.getEvaluatedCellsInZone(t,e))).flat(),i=o[0].format;return o.every((e=>e.format===i))?i:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}rv.props={onCloseSidePanel:Function},Di`
974
974
  .o-find-and-replace {
975
975
  .o-far-item {
976
976
  display: block;
@@ -1003,11 +1003,11 @@
1003
1003
  }
1004
1004
  }
1005
1005
  }
1006
- `;class ev extends t.Component{static template="o-spreadsheet-FindAndReplacePanel";state=t.useState(this.initialState());debounceTimeoutId;showFormulaState=!1;findAndReplaceRef=t.useRef("findAndReplace");get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}get pendingSearch(){return void 0!==this.debounceTimeoutId}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})}))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.env.model.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.debounceTimeoutId),this.debounceTimeoutId=setTimeout((()=>{this.updateSearch(),this.debounceTimeoutId=void 0}),400)}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}ev.props={onCloseSidePanel:Function},Di`
1006
+ `;class nv extends t.Component{static template="o-spreadsheet-FindAndReplacePanel";state=t.useState(this.initialState());debounceTimeoutId;showFormulaState=!1;findAndReplaceRef=t.useRef("findAndReplace");get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}get pendingSearch(){return void 0!==this.debounceTimeoutId}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})}))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.env.model.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.debounceTimeoutId),this.debounceTimeoutId=setTimeout((()=>{this.updateSearch(),this.debounceTimeoutId=void 0}),400)}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}nv.props={onCloseSidePanel:Function},Di`
1007
1007
  .o-locale-preview {
1008
1008
  color: dimgrey;
1009
1009
  }
1010
- `;class tv extends t.Component{static template="o-spreadsheet-SettingsPanel";loadedLocales=[];setup(){t.onWillStart((()=>this.loadLocales()))}onLocaleChange(e){const t=this.loadedLocales.find((t=>t.code===e));t&&this.env.model.dispatch("UPDATE_LOCALE",{locale:t})}async loadLocales(){this.loadedLocales=(await this.env.loadLocales()).filter(Yu).sort(((e,t)=>e.name.localeCompare(t.name)))}get numberFormatPreview(){return vo(1234567.89,{format:"#,##0.00",locale:this.env.model.getters.getLocale()})}get dateFormatPreview(){const e=this.env.model.getters.getLocale();return vo(1.6,{format:e.dateFormat,locale:e})}get dateTimeFormatPreview(){const e=this.env.model.getters.getLocale();return vo(1.6,{format:e.dateFormat+" "+e.timeFormat,locale:e})}get currentLocale(){return this.env.model.getters.getLocale()}get supportedLocales(){const e=this.currentLocale,t=this.loadedLocales.find((t=>t.code===e.code));if(!t){return[...this.loadedLocales,e].sort(((e,t)=>e.name.localeCompare(t.name)))}if(!Ye(e,t)){const o=this.loadedLocales.indexOf(t),i=[...this.loadedLocales];return i[o]=e,i.sort(((e,t)=>e.name.localeCompare(t.name))),i}return this.loadedLocales}}tv.props={onCloseSidePanel:Function};const ov={SplitIsDestructive:r("This will overwrite data in the subsequent columns. Split anyway?")};const iv=[{name:r("Detect automatically"),value:"auto"},{name:r("Custom separator"),value:"custom"},{name:r("Space"),value:" "},{name:r("Comma"),value:","},{name:r("Semicolon"),value:";"},{name:r("Line Break"),value:pe}];class sv extends t.Component{static template="o-spreadsheet-SplitIntoColumnsPanel";static components={SidePanelErrors:Mb};state=t.useState({separatorValue:"auto",addNewColumns:!1,customSeparator:""});setup(){t.onWillUpdateProps((()=>{"inactive"!==this.env.model.getters.getEditionMode()&&this.props.onCloseSidePanel()})),t.onMounted((()=>{this.env.model.dispatch("STOP_EDITION")}))}onSeparatorChange(e){this.state.separatorValue=e}updateCustomSeparator(e){e.target&&(this.state.customSeparator=e.target.value)}updateAddNewColumnsCheckbox(e){e.target&&(this.state.addNewColumns=e.target.checked)}confirm(){(function(e,t,o){let i=e.model.dispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:t,addNewColumns:o});return i.isCancelledBecause(91)&&e.askConfirmation(ov.SplitIsDestructive,(()=>{i=e.model.dispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:t,addNewColumns:o,force:!0})})),i})(this.env,this.separatorValue,this.state.addNewColumns).isSuccessful&&this.props.onCloseSidePanel()}get errorMessages(){const e=this.env.model.canDispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:this.separatorValue,addNewColumns:this.state.addNewColumns,force:!0}).reasons,t=new Set;for(const o of e)switch(o){case 91:case 90:break;default:t.add(qg.Errors[o]||qg.Errors.Unexpected)}return Array.from(t)}get warningMessages(){const e=[];return this.env.model.canDispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:this.separatorValue,addNewColumns:this.state.addNewColumns,force:!1}).reasons.includes(91)&&e.push(qg.Errors[91]),e}get separatorValue(){return"custom"===this.state.separatorValue?this.state.customSeparator:"auto"===this.state.separatorValue?this.env.model.getters.getAutomaticSeparator():this.state.separatorValue}get separators(){return iv}get isConfirmDisabled(){return!this.separatorValue||this.errorMessages.length>0}}sv.props={onCloseSidePanel:Function};const rv=new $i;rv.add("ConditionalFormatting",{title:r("Conditional formatting"),Body:Qb}),rv.add("ChartPanel",{title:r("Chart"),Body:Zb}),rv.add("FindAndReplace",{title:r("Find and Replace"),Body:ev}),rv.add("CustomCurrency",{title:r("Custom currency format"),Body:Jb}),rv.add("SplitToColumns",{title:r("Split text into columns"),Body:sv}),rv.add("Settings",{title:r("Spreadsheet settings"),Body:tv});const nv=new class extends $i{mapping={};uuidGenerator=new Ni;add(e,t){const o={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,o)}};Di`
1010
+ `;class av extends t.Component{static template="o-spreadsheet-SettingsPanel";loadedLocales=[];setup(){t.onWillStart((()=>this.loadLocales()))}onLocaleChange(e){const t=this.loadedLocales.find((t=>t.code===e));t&&this.env.model.dispatch("UPDATE_LOCALE",{locale:t})}async loadLocales(){this.loadedLocales=(await this.env.loadLocales()).filter(tg).sort(((e,t)=>e.name.localeCompare(t.name)))}get numberFormatPreview(){return vo(1234567.89,{format:"#,##0.00",locale:this.env.model.getters.getLocale()})}get dateFormatPreview(){const e=this.env.model.getters.getLocale();return vo(1.6,{format:e.dateFormat,locale:e})}get dateTimeFormatPreview(){const e=this.env.model.getters.getLocale();return vo(1.6,{format:e.dateFormat+" "+e.timeFormat,locale:e})}get currentLocale(){return this.env.model.getters.getLocale()}get supportedLocales(){const e=this.currentLocale,t=this.loadedLocales.find((t=>t.code===e.code));if(!t){return[...this.loadedLocales,e].sort(((e,t)=>e.name.localeCompare(t.name)))}if(!Ye(e,t)){const o=this.loadedLocales.indexOf(t),i=[...this.loadedLocales];return i[o]=e,i.sort(((e,t)=>e.name.localeCompare(t.name))),i}return this.loadedLocales}}av.props={onCloseSidePanel:Function};const lv={SplitIsDestructive:r("This will overwrite data in the subsequent columns. Split anyway?")};const cv=[{name:r("Detect automatically"),value:"auto"},{name:r("Custom separator"),value:"custom"},{name:r("Space"),value:" "},{name:r("Comma"),value:","},{name:r("Semicolon"),value:";"},{name:r("Line Break"),value:pe}];class hv extends t.Component{static template="o-spreadsheet-SplitIntoColumnsPanel";static components={SidePanelErrors:kb};state=t.useState({separatorValue:"auto",addNewColumns:!1,customSeparator:""});setup(){t.onWillUpdateProps((()=>{"inactive"!==this.env.model.getters.getEditionMode()&&this.props.onCloseSidePanel()})),t.onMounted((()=>{this.env.model.dispatch("STOP_EDITION")}))}onSeparatorChange(e){this.state.separatorValue=e}updateCustomSeparator(e){e.target&&(this.state.customSeparator=e.target.value)}updateAddNewColumnsCheckbox(e){e.target&&(this.state.addNewColumns=e.target.checked)}confirm(){(function(e,t,o){let i=e.model.dispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:t,addNewColumns:o});return i.isCancelledBecause(91)&&e.askConfirmation(lv.SplitIsDestructive,(()=>{i=e.model.dispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:t,addNewColumns:o,force:!0})})),i})(this.env,this.separatorValue,this.state.addNewColumns).isSuccessful&&this.props.onCloseSidePanel()}get errorMessages(){const e=this.env.model.canDispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:this.separatorValue,addNewColumns:this.state.addNewColumns,force:!0}).reasons,t=new Set;for(const o of e)switch(o){case 91:case 90:break;default:t.add(Qg.Errors[o]||Qg.Errors.Unexpected)}return Array.from(t)}get warningMessages(){const e=[];return this.env.model.canDispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:this.separatorValue,addNewColumns:this.state.addNewColumns,force:!1}).reasons.includes(91)&&e.push(Qg.Errors[91]),e}get separatorValue(){return"custom"===this.state.separatorValue?this.state.customSeparator:"auto"===this.state.separatorValue?this.env.model.getters.getAutomaticSeparator():this.state.separatorValue}get separators(){return cv}get isConfirmDisabled(){return!this.separatorValue||this.errorMessages.length>0}}hv.props={onCloseSidePanel:Function};const dv=new $i;dv.add("ConditionalFormatting",{title:r("Conditional formatting"),Body:sv}),dv.add("ChartPanel",{title:r("Chart"),Body:Jb}),dv.add("FindAndReplace",{title:r("Find and Replace"),Body:nv}),dv.add("CustomCurrency",{title:r("Custom currency format"),Body:rv}),dv.add("SplitToColumns",{title:r("Split text into columns"),Body:hv}),dv.add("Settings",{title:r("Spreadsheet settings"),Body:av});const uv=new class extends $i{mapping={};uuidGenerator=new Ni;add(e,t){const o={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,o)}};Di`
1011
1011
  div.o-figure {
1012
1012
  box-sizing: border-box;
1013
1013
  position: absolute;
@@ -1080,7 +1080,7 @@
1080
1080
  }
1081
1081
  }
1082
1082
  }
1083
- `;class av extends t.Component{static template="o-spreadsheet-FigureComponent";static components={Menu:Ir};static defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}};menuState=t.useState({isOpen:!1,position:null,menuItems:[]});figureRef=t.useRef("figure");menuButtonRef=t.useRef("menuButton");menuButtonRect=br(this.menuButtonRef);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}get figureRegistry(){return Op}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:o,height:i}=this.props.figure;return Ui({left:`${e}px`,top:`${t}px`,width:`${o}px`,height:`${i}px`,"z-index":String(de.Figure+(this.isSelected?1:0))})}getResizerPosition(e){let t={};return e.includes("top")?t.top="-3px":e.includes("bottom")?t.bottom="-3px":t.bottom="calc(50% - 3px)",e.includes("left")?t.left="-3px":e.includes("right")?t.right="-3px":t.right="calc(50% - 3px)",Ui(t)}setup(){const e=Op.get(this.props.figure.tag).borderWidth;this.borderWidth=void 0!==e?e:1,t.useEffect(((e,t,o)=>{e===t&&o?.focus({preventScroll:!0})}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,o){this.props.onClickAnchor(e,t,o)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.stopPropagation(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const o={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+o[0],y:t.y+o[1]}),e.stopPropagation(),e.preventDefault()}}onContextMenu(e){if(this.env.isDashboard())return;const t={x:e.clientX,y:e.clientY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:o}=this.menuButtonRect,i={x:e>=W?e-W:e+o,y:t};this.openContextMenu(i)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e,this.menuState.menuItems=Op.get(this.props.figure.tag).menuBuilder(this.props.figure.id,this.props.onFigureDeleted,this.env)}}av.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}},Di`
1083
+ `;class gv extends t.Component{static template="o-spreadsheet-FigureComponent";static components={Menu:Ir};static defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}};menuState=t.useState({isOpen:!1,position:null,menuItems:[]});figureRef=t.useRef("figure");menuButtonRef=t.useRef("menuButton");menuButtonRect=br(this.menuButtonRef);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}get figureRegistry(){return Lp}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:o,height:i}=this.props.figure;return Ui({left:`${e}px`,top:`${t}px`,width:`${o}px`,height:`${i}px`,"z-index":String(de.Figure+(this.isSelected?1:0))})}getResizerPosition(e){let t={};return e.includes("top")?t.top="-3px":e.includes("bottom")?t.bottom="-3px":t.bottom="calc(50% - 3px)",e.includes("left")?t.left="-3px":e.includes("right")?t.right="-3px":t.right="calc(50% - 3px)",Ui(t)}setup(){const e=Lp.get(this.props.figure.tag).borderWidth;this.borderWidth=void 0!==e?e:1,t.useEffect(((e,t,o)=>{e===t&&o?.focus({preventScroll:!0})}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,o){this.props.onClickAnchor(e,t,o)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.stopPropagation(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const o={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+o[0],y:t.y+o[1]}),e.stopPropagation(),e.preventDefault()}}onContextMenu(e){if(this.env.isDashboard())return;const t={x:e.clientX,y:e.clientY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:o}=this.menuButtonRect,i={x:e>=W?e-W:e+o,y:t};this.openContextMenu(i)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e,this.menuState.menuItems=Lp.get(this.props.figure.tag).menuBuilder(this.props.figure.id,this.props.onFigureDeleted,this.env)}}gv.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}},Di`
1084
1084
  .o-autofill {
1085
1085
  position: absolute;
1086
1086
  height: ${8}px;
@@ -1108,9 +1108,9 @@
1108
1108
  pointer-events: none;
1109
1109
  white-space: nowrap;
1110
1110
  }
1111
- `;class lv extends t.Component{static template="o-spreadsheet-Autofill";state=t.useState({position:{left:0,top:0},handler:!1});get style(){const{left:e,top:t}=this.props.position;return Ui({top:`${t}px`,left:`${e}px`,visibility:this.props.isVisible?"visible":"hidden"})}get handlerStyle(){const{left:e,top:t}=this.state.handler?this.state.position:this.props.position;return Ui({top:`${t}px`,left:`${e}px`})}get styleNextValue(){const{left:e,top:t}=this.state.position;return Ui({top:`${t+5}px`,left:`${e+15}px`})}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=cv),e}onMouseDown(e){let t,o;this.state.handler=!0;const i=e.clientX-this.props.position.left,s=e.clientY-this.props.position.top;Lb(this.env,((e,r,n)=>{if(this.state.position={left:n.clientX-i,top:n.clientY-s},t!==e||o!==r){const i=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getNumberCols(i),n=this.env.model.getters.getNumberRows(i);t=-1===e?t:we(e,0,s),o=-1===r?o:we(r,0,n),void 0!==t&&void 0!==o&&this.env.model.dispatch("AUTOFILL_SELECT",{col:t,row:o})}}),(()=>{this.state.handler=!1,this.state.position={...this.props.position},this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}lv.props={position:Object,isVisible:Boolean};class cv extends t.Component{static template=t.xml`
1111
+ `;class pv extends t.Component{static template="o-spreadsheet-Autofill";state=t.useState({position:{left:0,top:0},handler:!1});get style(){const{left:e,top:t}=this.props.position;return Ui({top:`${t}px`,left:`${e}px`,visibility:this.props.isVisible?"visible":"hidden"})}get handlerStyle(){const{left:e,top:t}=this.state.handler?this.state.position:this.props.position;return Ui({top:`${t}px`,left:`${e}px`})}get styleNextValue(){const{left:e,top:t}=this.state.position;return Ui({top:`${t+5}px`,left:`${e+15}px`})}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=mv),e}onMouseDown(e){let t,o;this.state.handler=!0;const i=e.clientX-this.props.position.left,s=e.clientY-this.props.position.top;Bb(this.env,((e,r,n)=>{if(this.state.position={left:n.clientX-i,top:n.clientY-s},t!==e||o!==r){const i=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getNumberCols(i),n=this.env.model.getters.getNumberRows(i);t=-1===e?t:we(e,0,s),o=-1===r?o:we(r,0,n),void 0!==t&&void 0!==o&&this.env.model.dispatch("AUTOFILL_SELECT",{col:t,row:o})}}),(()=>{this.state.handler=!1,this.state.position={...this.props.position},this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}pv.props={position:Object,isVisible:Boolean};class mv extends t.Component{static template=t.xml`
1112
1112
  <div t-esc="props.content"/>
1113
- `}cv.props={content:String},Di`
1113
+ `}mv.props={content:String},Di`
1114
1114
  .o-client-tag {
1115
1115
  position: absolute;
1116
1116
  border-top-left-radius: 4px;
@@ -1120,7 +1120,7 @@
1120
1120
  opacity: 0;
1121
1121
  pointer-events: none;
1122
1122
  }
1123
- `;class hv extends t.Component{static template="o-spreadsheet-ClientTag";get tagStyle(){const{col:e,row:t,color:o}=this.props,{height:i}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:s,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return Ui({bottom:i-r+15+"px",left:s-1+"px",border:`1px solid ${o}`,"background-color":o,opacity:this.props.active?"opacity:1 !important":void 0})}}hv.props={active:Boolean,name:String,color:String,col:Number,row:Number},Di`
1123
+ `;class fv extends t.Component{static template="o-spreadsheet-ClientTag";get tagStyle(){const{col:e,row:t,color:o}=this.props,{height:i}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:s,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return Ui({bottom:i-r+15+"px",left:s-1+"px",border:`1px solid ${o}`,"background-color":o,opacity:this.props.active?"opacity:1 !important":void 0})}}fv.props={active:Boolean,name:String,color:String,col:Number,row:Number},Di`
1124
1124
  .o-autocomplete-dropdown {
1125
1125
  pointer-events: auto;
1126
1126
  background-color: #fff;
@@ -1139,7 +1139,7 @@
1139
1139
  }
1140
1140
  }
1141
1141
  }
1142
- `;class dv extends t.Component{static template="o-spreadsheet-TextValueProvider"}dv.props={values:Array,selectedIndex:Number,onValueSelected:Function};class uv{el;constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let o=window.getSelection();const{start:i,end:s}=this.getCurrentSelection();if(i===e&&s===t)return;const r=o.getRangeAt(0);let n;if(this.el.contains(r.startContainer)?n=r:(n=document.createRange(),o.removeAllRanges(),o.addRange(n)),e==t&&0===e)n.setStart(this.el,0),n.setEnd(this.el,0);else{const i=this.getText().length;(e<0||t>i)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${i}`),e<0&&(e=0),t>i&&(t=i),e>i&&(e=i));let s=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);n.setStart(s.node,s.offset),o.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,o,i=mr(this.el),s=e,r=!0;do{t=i.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<s?s-=t.value.textContent.length:t.value.textContent&&t.value.textContent.length>=s&&i.return(t.value),o=t.value),t.done||"P"!==t.value.nodeName||(r?r=!1:s--)}while(!t.done&&s);return t.value?{node:t.value,offset:s}:{node:o,offset:s}}setText(e){if(0===e.length)return void this.removeAll();const t=Array.from(this.el.childNodes),o=e.length;for(let i=0;i<o;i++){const o=e[i],s=t[i];let r,n=!1;s&&"P"===s.nodeName?r=s:(n=!0,r=document.createElement("p"));const a=o.length,l=Array.from(r.childNodes);for(let e=0;e<a;e++){const t=o[e],i=l[e];if(i&&"tagName"in i&&"SPAN"===i.tagName&&gv(t,i))continue;if(!t.value&&!t.class){i&&r.removeChild(i);continue}const s=document.createElement("span");s.innerText=t.value,s.style.color=t.color||"",t.class&&s.classList.add(t.class),i?r.replaceChild(s,i):r.appendChild(s)}if(l.length>a)for(let e=a;e<l.length;e++)r.removeChild(l[e]);if(!r.hasChildNodes()){const e=document.createElement("span");e.appendChild(document.createElement("br")),r.appendChild(e)}n&&(s?this.el.replaceChild(r,s):this.el.appendChild(r))}if(t.length>o)for(let e=o;e<t.length;e++)this.el.removeChild(t[e])}scrollSelectionIntoView(){const e=document.getSelection()?.focusNode;if(!e||!this.el.contains(e))return;(e instanceof HTMLElement?e:e.parentElement)?.scrollIntoView({block:"nearest"})}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:o,endSelectionOffset:i}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,o),end:this.findSelectionIndex(t,i)}}findSelectionIndex(e,t){let o=0,i=mr(this.el),s=i.next(),r=!0;for(;!s.done&&s.value!==e;)s.value.hasChildNodes()||s.value.textContent&&(o+=s.value.textContent.length),("P"===s.value.nodeName||"DIV"===s.value.nodeName&&s.value!==this.el)&&(r?r=!1:o++),s=i.next();if(s.value!==e)return 0;if(s.value.hasChildNodes()){const e=[...s.value.childNodes].slice(0,t);o+=e.reduce(((t,o,i)=>{if(null!==o.textContent){let s=o.textContent.length;return"P"===o.nodeName&&i!==e.length-1&&s++,t+s}return t}),0)}else o+=t;return"P"!==e.nodeName||r||""!=e.textContent||o++,o}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}getText(){let e="",t=mr(this.el),o=t.next(),i=!0;for(;!o.done;)o.value.hasChildNodes()||(e+=o.value.textContent),("P"===o.value.nodeName||"DIV"===o.value.nodeName&&o.value!==this.el)&&(i?i=!1:e+=pe),o=t.next();return e}}function gv(e,t){const o=(e.color?ht(e.color):"")===(t.style?.color?ht(t.style.color):""),i=Ye([e.class],[...t.classList]),s=t.innerText===e.value;return o&&i&&s}Di`
1142
+ `;class bv extends t.Component{static template="o-spreadsheet-TextValueProvider"}bv.props={values:Array,selectedIndex:Number,onValueSelected:Function};class vv{el;constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let o=window.getSelection();const{start:i,end:s}=this.getCurrentSelection();if(i===e&&s===t)return;const r=o.getRangeAt(0);let n;if(this.el.contains(r.startContainer)?n=r:(n=document.createRange(),o.removeAllRanges(),o.addRange(n)),e==t&&0===e)n.setStart(this.el,0),n.setEnd(this.el,0);else{const i=this.getText().length;(e<0||t>i)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${i}`),e<0&&(e=0),t>i&&(t=i),e>i&&(e=i));let s=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);n.setStart(s.node,s.offset),o.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,o,i=mr(this.el),s=e,r=!0;do{t=i.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<s?s-=t.value.textContent.length:t.value.textContent&&t.value.textContent.length>=s&&i.return(t.value),o=t.value),t.done||"P"!==t.value.nodeName||(r?r=!1:s--)}while(!t.done&&s);return t.value?{node:t.value,offset:s}:{node:o,offset:s}}setText(e){if(0===e.length)return void this.removeAll();const t=Array.from(this.el.childNodes),o=e.length;for(let i=0;i<o;i++){const o=e[i],s=t[i];let r,n=!1;s&&"P"===s.nodeName?r=s:(n=!0,r=document.createElement("p"));const a=o.length,l=Array.from(r.childNodes);for(let e=0;e<a;e++){const t=o[e],i=l[e];if(i&&"tagName"in i&&"SPAN"===i.tagName&&Sv(t,i))continue;if(!t.value&&!t.class){i&&r.removeChild(i);continue}const s=document.createElement("span");s.innerText=t.value,s.style.color=t.color||"",t.class&&s.classList.add(t.class),i?r.replaceChild(s,i):r.appendChild(s)}if(l.length>a)for(let e=a;e<l.length;e++)r.removeChild(l[e]);if(!r.hasChildNodes()){const e=document.createElement("span");e.appendChild(document.createElement("br")),r.appendChild(e)}n&&(s?this.el.replaceChild(r,s):this.el.appendChild(r))}if(t.length>o)for(let e=o;e<t.length;e++)this.el.removeChild(t[e])}scrollSelectionIntoView(){const e=document.getSelection()?.focusNode;if(!e||!this.el.contains(e))return;(e instanceof HTMLElement?e:e.parentElement)?.scrollIntoView({block:"nearest"})}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:o,endSelectionOffset:i}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,o),end:this.findSelectionIndex(t,i)}}findSelectionIndex(e,t){let o=0,i=mr(this.el),s=i.next(),r=!0;for(;!s.done&&s.value!==e;)s.value.hasChildNodes()||s.value.textContent&&(o+=s.value.textContent.length),("P"===s.value.nodeName||"DIV"===s.value.nodeName&&s.value!==this.el)&&(r?r=!1:o++),s=i.next();if(s.value!==e)return 0;if(s.value.hasChildNodes()){const e=[...s.value.childNodes].slice(0,t);o+=e.reduce(((t,o,i)=>{if(null!==o.textContent){let s=o.textContent.length;return"P"===o.nodeName&&i!==e.length-1&&s++,t+s}return t}),0)}else o+=t;return"P"!==e.nodeName||r||""!=e.textContent||o++,o}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}getText(){let e="",t=mr(this.el),o=t.next(),i=!0;for(;!o.done;)o.value.hasChildNodes()||(e+=o.value.textContent),("P"===o.value.nodeName||"DIV"===o.value.nodeName&&o.value!==this.el)&&(i?i=!1:e+=pe),o=t.next();return e}}function Sv(e,t){const o=(e.color?ht(e.color):"")===(t.style?.color?ht(t.style.color):""),i=Ye([e.class],[...t.classList]),s=t.innerText===e.value;return o&&i&&s}Di`
1143
1143
  .o-formula-assistant {
1144
1144
  .o-formula-assistant-head {
1145
1145
  background-color: #f2f2f2;
@@ -1165,7 +1165,7 @@
1165
1165
  color: gray;
1166
1166
  }
1167
1167
  }
1168
- `;class pv extends t.Component{static template="o-spreadsheet-FunctionDescriptionProvider";assistantState=t.useState({allowCellSelectionBehind:!1});timeOutId=0;setup(){t.onWillUnmount((()=>{this.timeOutId&&clearTimeout(this.timeOutId)}))}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}pv.props={functionName:String,functionDescription:Object,argToFocus:Number};const mv=Jd.content,fv="selector-flag",bv="#4a4e4d",vv="#3da4ab",Sv={OPERATOR:vv,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:bv,DEBUGGER:vv,LEFT_PAREN:bv,RIGHT_PAREN:bv,ARG_SEPARATOR:bv,MATCHING_PAREN:"#000000"};Di`
1168
+ `;class Cv extends t.Component{static template="o-spreadsheet-FunctionDescriptionProvider";assistantState=t.useState({allowCellSelectionBehind:!1});timeOutId=0;setup(){t.onWillUnmount((()=>{this.timeOutId&&clearTimeout(this.timeOutId)}))}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}Cv.props={functionName:String,functionDescription:Object,argToFocus:Number};const Ev=tu.content,wv="selector-flag",yv="#4a4e4d",xv="#3da4ab",Iv={OPERATOR:xv,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:yv,DEBUGGER:xv,LEFT_PAREN:yv,RIGHT_PAREN:yv,ARG_SEPARATOR:yv,MATCHING_PAREN:"#000000"};Di`
1169
1169
  .o-composer-container {
1170
1170
  .o-composer {
1171
1171
  overflow-y: auto;
@@ -1181,16 +1181,12 @@
1181
1181
  padding-right: 3px;
1182
1182
  outline: none;
1183
1183
 
1184
- &.unfocusable {
1185
- pointer-events: none;
1186
- }
1187
-
1188
1184
  p {
1189
1185
  margin-bottom: 0px;
1190
1186
 
1191
1187
  span {
1192
1188
  white-space: pre-wrap;
1193
- &.${fv}:after {
1189
+ &.${wv}:after {
1194
1190
  content: "${"␣"}";
1195
1191
  color: ${"#a9a9a9"};
1196
1192
  }
@@ -1204,12 +1200,12 @@
1204
1200
  pointer-events: none;
1205
1201
  }
1206
1202
  }
1207
- `;class Cv extends t.Component{static template="o-spreadsheet-Composer";static components={TextValueProvider:dv,FunctionDescriptionProvider:pv};static defaultProps={inputStyle:""};composerRef=t.useRef("o_composer");contentHelper=new uv(this.composerRef.el);composerState=t.useState({positionStart:0,positionEnd:0});autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0});functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0});compositionActive=!1;get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:o}=this.props.rect;let i={};return t>this.props.delimitation.height-(t+o)&&(i.top="-3px",i.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(i.right="0px"),i.width="300px",Ui(i)}return Ui({width:"300px"})}shouldProcessInputEvents=!1;tokens=[];keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:this.processF4Key,Tab:e=>this.processTabKey(e)," ":e=>this.processSpaceKey(e)};keyCodeMapping={NumpadDecimal:this.processNumpadDecimal};setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e)})),t.onWillUnmount((()=>{this.props.onComposerUnmounted?.()})),t.useEffect((()=>{this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void Ab(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length)}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}const t=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(t,1)}processSpaceKey(e){e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),this.showAutocomplete(""),this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"))}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey)return void this.composerRef.el?.dispatchEvent(new InputEvent("input",{inputType:"insertParagraph",bubbles:!0,isComposing:!1}));if(this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const t=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(t,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}processNumpadDecimal(e){e.stopPropagation(),e.preventDefault();const t=this.env.model.getters.getLocale(),o=this.contentHelper.getCurrentSelection(),i=this.env.model.getters.getCurrentContent(),s=i.slice(0,o.start)+t.decimalSeparator+i.slice(o.end);this.env.model.dispatch("SET_CURRENT_CONTENT",{content:s,selection:{start:o.start+1,end:o.start+1}}),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key]||this.keyCodeMapping[e.code];t?t.call(this,e):e.stopPropagation()}onInput(e){if("inactive"===this.props.focus||!this.shouldProcessInputEvents)return;let t=this.contentHelper.getText(),o=this.contentHelper.getCurrentSelection();if("insertParagraph"===e.inputType){const e=Math.min(o.start,o.end),i=Math.max(o.start,o.end);t=t.slice(0,e)+pe+t.slice(i),o={start:e+1,end:e+1}}this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:t,selection:o}),this.processTokenAtCursor()}onKeyup(){if(this.contentHelper.el===document.activeElement){const{start:e,end:t}=this.env.model.getters.getComposerSelection(),{start:o,end:i}=this.contentHelper.getCurrentSelection();o===e&&i===t||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}}showAutocomplete(e){if(!this.env.model.getters.getCurrentContent().startsWith("="))return;this.autoCompleteState.showProvider=!0;let t=Object.entries(Jd.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?Ai(e,t,(e=>e.text)):t.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=t.slice(0,10),this.autoCompleteState.selectedIndex=0}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onDblClick(){if(this.env.model.getters.isReadonly())return;const e=this.env.model.getters.getCurrentContent();if(e.startsWith("=")){const t=this.env.model.getters.getCurrentTokens(),o=this.contentHelper.getCurrentSelection();if(o.start===o.end)return;const i=e.substring(o.start,o.end),s=t.filter((e=>e.value.includes(i)&&e.start<=o.start&&e.end>=o.end))[0];"REFERENCE"===s.type&&this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:s.start,end:s.end})}}processContent(){if(this.compositionActive)return;this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&this.contentHelper.el.focus();const e=this.getContentLines();if(this.contentHelper.setText(e),0!==e.length&&0!==e.length[0]){if("inactive"!==this.props.focus){const{start:e,end:t}=this.env.model.getters.getComposerSelection();this.contentHelper.selectRange(e,t)}this.contentHelper.scrollSelectionIntoView()}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=");return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),o=[],{end:i,start:s}=this.env.model.getters.getComposerSelection();for(const r of e){switch(r.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"ARG_SEPARATOR":case"STRING":o.push({value:r.value,color:Sv[r.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:i}=Ko(r.value);o.push({value:r.value,color:this.rangeColor(e,i)||"#000"});break;case"SYMBOL":let s=r.value;["TRUE","FALSE"].includes(s.toUpperCase())?o.push({value:r.value,color:Sv.NUMBER}):o.push({value:r.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===r.parenIndex?o.push({value:r.value,color:Sv.MATCHING_PAREN}):o.push({value:r.value,color:Sv[r.type]||"#000"});break;default:o.push({value:r.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===s&&i===r.end&&(o[o.length-1].class=fv)}return o}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const i of e)if(i.value.includes(pe)){const e=i.value.split(pe),s=e.pop();for(const s of e)o.push({color:i.color,value:s}),t.push(o),o=[];o.push({...i,value:s})}else o.push(i);o.length&&t.push(o);const i=[];for(const e of t)e.every(this.isContentEmpty)?i.push([e[0]]):i.push(e.filter((e=>!this.isContentEmpty(e))));return i}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),i=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getCurrentEditedCell().sheetId,s=o.find((t=>{if(t.sheetId!==i)return!1;let o=this.env.model.getters.getRangeFromSheetXC(i,e).zone;return o=1===yi(o)?this.env.model.getters.expandZone(i,o):o,li(o,t.zone)}));return s&&s.color?s.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=Ko(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!qo.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,o=t.parent.toUpperCase(),i=mv[o],s=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=i,this.functionDescriptionState.argToFocus=i.getArgToFocus(s+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const s=this.env.model.getters.getCurrentTokens();if(s.length){e+="(";const o=s.map((e=>e.start)).indexOf(t.start);if(o+1<s.length){"LEFT_PAREN"===s[o+1].type&&i++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Cv.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerUnmounted:{type:Function,optional:!0}};const Ev=3*.4*window.devicePixelRatio||1;Di`
1203
+ `;class Rv extends t.Component{static template="o-spreadsheet-Composer";static components={TextValueProvider:bv,FunctionDescriptionProvider:Cv};static defaultProps={inputStyle:""};composerRef=t.useRef("o_composer");contentHelper=new vv(this.composerRef.el);composerState=t.useState({positionStart:0,positionEnd:0});autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0});functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0});compositionActive=!1;get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:o}=this.props.rect;let i={};return t>this.props.delimitation.height-(t+o)&&(i.top="-3px",i.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(i.right="0px"),i.width="300px",Ui(i)}return Ui({width:"300px"})}shouldProcessInputEvents=!1;tokens=[];keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:this.processF4Key,Tab:e=>this.processTabKey(e)," ":e=>this.processSpaceKey(e)};keyCodeMapping={NumpadDecimal:this.processNumpadDecimal};setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e)})),t.onWillUnmount((()=>{this.props.onComposerUnmounted?.()})),t.useEffect((()=>{this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void Db(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length)}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}const t=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(t,1)}processSpaceKey(e){e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),this.showAutocomplete(""),this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"))}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey)return void this.composerRef.el?.dispatchEvent(new InputEvent("input",{inputType:"insertParagraph",bubbles:!0,isComposing:!1}));if(this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const t=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(t,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}processNumpadDecimal(e){e.stopPropagation(),e.preventDefault();const t=this.env.model.getters.getLocale(),o=this.contentHelper.getCurrentSelection(),i=this.env.model.getters.getCurrentContent(),s=i.slice(0,o.start)+t.decimalSeparator+i.slice(o.end);this.env.model.dispatch("SET_CURRENT_CONTENT",{content:s,selection:{start:o.start+1,end:o.start+1}}),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key]||this.keyCodeMapping[e.code];t?t.call(this,e):e.stopPropagation()}onInput(e){if("inactive"===this.props.focus||!this.shouldProcessInputEvents)return;let t=this.contentHelper.getText(),o=this.contentHelper.getCurrentSelection();if("insertParagraph"===e.inputType){const e=Math.min(o.start,o.end),i=Math.max(o.start,o.end);t=t.slice(0,e)+pe+t.slice(i),o={start:e+1,end:e+1}}this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:t,selection:o}),this.processTokenAtCursor()}onKeyup(){if(this.contentHelper.el===document.activeElement){const{start:e,end:t}=this.env.model.getters.getComposerSelection(),{start:o,end:i}=this.contentHelper.getCurrentSelection();o===e&&i===t||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}}showAutocomplete(e){const t=e.toUpperCase();if(!this.env.model.getters.getCurrentContent().startsWith("=")||"TRUE"===t||"FALSE"===t)return;this.autoCompleteState.showProvider=!0;let o=Object.entries(tu.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));o=e?Ai(e,o,(e=>e.text)):o.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=o.slice(0,10),this.autoCompleteState.selectedIndex=0}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onDblClick(){if(this.env.model.getters.isReadonly())return;const e=this.env.model.getters.getCurrentContent();if(e.startsWith("=")){const t=this.env.model.getters.getCurrentTokens(),o=this.contentHelper.getCurrentSelection();if(o.start===o.end)return;const i=e.substring(o.start,o.end),s=t.filter((e=>e.value.includes(i)&&e.start<=o.start&&e.end>=o.end))[0];"REFERENCE"===s.type&&this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:s.start,end:s.end})}}processContent(){if(this.compositionActive)return;this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&this.contentHelper.el.focus();const e=this.getContentLines();if(this.contentHelper.setText(e),0!==e.length&&0!==e.length[0]){if("inactive"!==this.props.focus){const{start:e,end:t}=this.env.model.getters.getComposerSelection();this.contentHelper.selectRange(e,t)}this.contentHelper.scrollSelectionIntoView()}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=");return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),o=[],{end:i,start:s}=this.env.model.getters.getComposerSelection();for(const r of e){switch(r.type){case"OPERATOR":case"NUMBER":case"ARG_SEPARATOR":case"STRING":o.push({value:r.value,color:Iv[r.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:i}=Ko(r.value);o.push({value:r.value,color:this.rangeColor(e,i)||"#000"});break;case"SYMBOL":const s=r.value.toUpperCase();"TRUE"===s||"FALSE"===s?o.push({value:r.value,color:Iv.NUMBER}):s in tu.content?o.push({value:r.value,color:Iv.FUNCTION}):o.push({value:r.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===r.parenIndex?o.push({value:r.value,color:Iv.MATCHING_PAREN}):o.push({value:r.value,color:Iv[r.type]||"#000"});break;default:o.push({value:r.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===s&&i===r.end&&(o[o.length-1].class=wv)}return o}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const i of e)if(i.value.includes(pe)){const e=i.value.split(pe),s=e.pop();for(const s of e)o.push({color:i.color,value:s}),t.push(o),o=[];o.push({...i,value:s})}else o.push(i);o.length&&t.push(o);const i=[];for(const e of t)e.every(this.isContentEmpty)?i.push([e[0]]):i.push(e.filter((e=>!this.isContentEmpty(e))));return i}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),i=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getCurrentEditedCell().sheetId,s=o.find((t=>{if(t.sheetId!==i)return!1;let o=this.env.model.getters.getRangeFromSheetXC(i,e).zone;return o=1===yi(o)?this.env.model.getters.expandZone(i,o):o,li(o,t.zone)}));return s&&s.color?s.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(!e)return;if("SYMBOL"===e.type)return void this.showAutocomplete(e.value);const t=e.functionContext,o=t?.parent.toUpperCase();if(t&&o&&o in Ev&&"UNKNOWN"!==e.type){const e=Ev[o],i=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=e,this.functionDescriptionState.argToFocus=e.getArgToFocus(i+1)-1,this.functionDescriptionState.showDescription=!0}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const s=this.env.model.getters.getCurrentTokens();if(s.length){e+="(";const o=s.map((e=>e.start)).indexOf(t.start);if(o+1<s.length){"LEFT_PAREN"===s[o+1].type&&i++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Rv.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerUnmounted:{type:Function,optional:!0}};const Tv=3*.4*window.devicePixelRatio||1;Di`
1208
1204
  div.o-grid-composer {
1209
1205
  z-index: ${de.GridComposer};
1210
1206
  box-sizing: border-box;
1211
1207
  position: absolute;
1212
- border: ${Ev}px solid ${E};
1208
+ border: ${Tv}px solid ${E};
1213
1209
 
1214
1210
  display: flex;
1215
1211
  align-items: center;
@@ -1225,7 +1221,7 @@
1225
1221
  padding: 6px 7px;
1226
1222
  border-radius: 4px;
1227
1223
  }
1228
- `;class wv extends t.Component{static template="o-spreadsheet-GridComposer";static components={Composer:Cv};gridComposerRef;zone;rect;isCellReferenceVisible;composerState;setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:void 0,delimitation:void 0});const{sheetId:e,col:o,row:i}=this.env.model.getters.getActivePosition();this.zone=this.env.model.getters.expandZone(e,Ei({col:o,row:i})),this.rect=this.env.model.getters.getVisibleRect(this.zone),this.isCellReferenceVisible=!1,t.onMounted((()=>{const e=this.gridComposerRef.el;this.composerState.rect={x:this.rect.x,y:this.rect.y,width:e.clientWidth,height:e.clientHeight},this.composerState.delimitation={width:this.props.gridDims.width,height:this.props.gridDims.height}})),t.onWillUpdateProps((()=>{if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();Ye(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){const{col:e,row:t,sheetId:o}=this.env.model.getters.getCurrentEditedCell();return`${o!==this.env.model.getters.getActiveSheetId()?Ee(this.env.model.getters.getSheetName(o))+"!":""}${Tt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return Ui({left:e-Ev+"px",top:t-28+"px"})}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),o=this.env.model.getters.getActivePosition(),i=this.env.model.getters.getCellComputedStyle(o),{x:s,y:r,width:n,height:a}=this.rect,l=!e&&i.fillColor||"#ffffff",c=!e&&i.textColor||"#000000",h=!e&&i.fontSize||10,d=!e&&i.bold?"bold":void 0,u=!e&&i.italic?"italic":"normal",g=e?"none":Li(i);let p="left";return e||(p=i.align||t.defaultAlign),Ui({left:s-1+"px",top:`${r}px`,"min-width":`${n+1}px`,"min-height":`${a+1}px`,background:l,color:c,"font-size":`${Re(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}get composerStyle(){const e=this.props.gridDims.height-this.rect.y;return Ui({"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${e}px`})}}wv.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerUnmounted:Function,onComposerContentFocused:Function,gridDims:Object};const yv=Di`
1224
+ `;class Av extends t.Component{static template="o-spreadsheet-GridComposer";static components={Composer:Rv};gridComposerRef;zone;rect;isCellReferenceVisible;composerState;setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:void 0,delimitation:void 0});const{sheetId:e,col:o,row:i}=this.env.model.getters.getActivePosition();this.zone=this.env.model.getters.expandZone(e,Ei({col:o,row:i})),this.rect=this.env.model.getters.getVisibleRect(this.zone),this.isCellReferenceVisible=!1,t.onMounted((()=>{const e=this.gridComposerRef.el;this.composerState.rect={x:this.rect.x,y:this.rect.y,width:e.clientWidth,height:e.clientHeight},this.composerState.delimitation={width:this.props.gridDims.width,height:this.props.gridDims.height}})),t.onWillUpdateProps((()=>{if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();Ye(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){const{col:e,row:t,sheetId:o}=this.env.model.getters.getCurrentEditedCell();return`${o!==this.env.model.getters.getActiveSheetId()?Ee(this.env.model.getters.getSheetName(o))+"!":""}${Tt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return Ui({left:e-Tv+"px",top:t-28+"px"})}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),o=this.env.model.getters.getActivePosition(),i=this.env.model.getters.getCellComputedStyle(o),{x:s,y:r,width:n,height:a}=this.rect,l=!e&&i.fillColor||"#ffffff",c=!e&&i.textColor||"#000000",h=!e&&i.fontSize||10,d=!e&&i.bold?"bold":void 0,u=!e&&i.italic?"italic":"normal",g=e?"none":Li(i);let p="left";return e||(p=i.align||t.defaultAlign),Ui({left:s-1+"px",top:`${r}px`,"min-width":`${n+1}px`,"min-height":`${a+1}px`,background:l,color:c,"font-size":`${Re(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}get composerStyle(){const e=this.props.gridDims.height-this.rect.y;return Ui({"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${e}px`})}}Av.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerUnmounted:Function,onComposerContentFocused:Function,gridDims:Object};const Ov=Di`
1229
1225
  .o-filter-icon {
1230
1226
  color: ${R};
1231
1227
  position: absolute;
@@ -1239,7 +1235,7 @@
1239
1235
  background: ${R};
1240
1236
  color: #fff;
1241
1237
  }
1242
- `;class xv extends t.Component{static style=yv;static template="o-spreadsheet-FilterIcon";get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}xv.props={position:Object,isActive:Boolean,onClick:Function};const Iv=Di``;class Rv extends t.Component{static style=Iv;static template="o-spreadsheet-FilterIconsOverlay";static components={FilterIcon:xv};static defaultProps={gridPosition:{x:0,y:0}};getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRowDimensionsInViewport(t,e.row),i=this.env.model.getters.getColDimensionsInViewport(t,e.col),s=this.env.model.getters.getCell({sheetId:t,...e}),r=this.getIconVerticalPosition(o,s);return{x:i.end-$+this.props.gridPosition.x-2-1,y:r+this.props.gridPosition.y}}getIconVerticalPosition(e,t){const o=Math.floor((e.size-$)/2);switch(t?.style?.verticalAlign){case"bottom":return e.end-2-$;case"top":return e.start+2;default:return e.end-$-o}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive({sheetId:t,...e})}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:o,row:i}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:o,row:i,popoverType:"FilterMenu"})}isPositionVisible(e,t){const o=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===o.width||0===o.height)}}function Tv(e,t){return{...t,...Ov(e,{x:t.x,y:t.y})}}function Av(e,t){return{...t,...Nv(e,{x:t.x,y:t.y})}}function Ov(e,{x:t,y:o}){const{x:i,y:s}=e.getMainViewportCoordinates(),{scrollX:r,scrollY:n}=e.getActiveSheetScrollInfo();return{x:t=t<i?t:t-r,y:o=o<s?o:o-n}}function Nv(e,{x:t,y:o}){const{x:i,y:s}=e.getMainViewportCoordinates(),{scrollX:r,scrollY:n}=e.getActiveSheetScrollInfo();return{x:t=i&&t<i?t:t+r,y:o=s&&o<s?o:o+n}}function Mv(e,t,o){return Math.min(Math.max(e,t),o)}Rv.props={gridPosition:{type:Object,optional:!0}};const _v=5;function Fv(e,t,o){return o.map((e=>Lv(t,e))).filter((o=>function(e,t,o){const{x:i,y:s}=e.getMainViewportCoordinates(),r=[];switch(o.axisType){case"top":case"bottom":case"vCenter":if(t.y<s)return!0;r.push({x:t.x,y:o.position}),r.push({x:t.x+t.width,y:o.position});break;case"left":case"right":case"hCenter":if(t.x<i)return!0;r.push({x:o.position,y:t.y}),r.push({x:o.position,y:t.y+t.height})}return r.some(e.isPositionVisible)}(e,t,o))).map((o=>function(e,t,o){const i=Tv(e,t);return Lv(i,o.axisType)}(e,t,o)))}function Dv(e,t,o,i,s){const r=Fv(e,t,o);let n;for(const t of i){const o=Fv(e,t,s);for(const e of r)for(const i of o){if(a=e.position,l=i.position,!(Math.abs(a-l)<=_v))continue;const o=e.position-i.position;n&&o===n.snapOffset?n.matchedFigIds.push(t.id):(!n||Math.abs(o)<=Math.abs(n.snapOffset))&&(n={matchedFigIds:[t.id],snapOffset:o,snappedAxisType:e.axisType,position:i.position})}}var a,l;return n}function Lv(e,t){let o=0;switch(t){case"top":o=e.y;break;case"bottom":o=e.y+e.height-ee;break;case"vCenter":o=e.y+Math.floor(e.height/2)-ee;break;case"left":o=e.x;break;case"right":o=e.x+e.width-ee;break;case"hCenter":o=e.x+Math.floor(e.width/2)-ee}return{position:o,axisType:t}}Di`
1238
+ `;class Nv extends t.Component{static style=Ov;static template="o-spreadsheet-FilterIcon";get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Nv.props={position:Object,isActive:Boolean,onClick:Function};const Mv=Di``;class _v extends t.Component{static style=Mv;static template="o-spreadsheet-FilterIconsOverlay";static components={FilterIcon:Nv};static defaultProps={gridPosition:{x:0,y:0}};getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRowDimensionsInViewport(t,e.row),i=this.env.model.getters.getColDimensionsInViewport(t,e.col),s=this.env.model.getters.getCell({sheetId:t,...e}),r=this.getIconVerticalPosition(o,s);return{x:i.end-$+this.props.gridPosition.x-2-1,y:r+this.props.gridPosition.y}}getIconVerticalPosition(e,t){const o=Math.floor((e.size-$)/2);switch(t?.style?.verticalAlign){case"bottom":return e.end-2-$;case"top":return e.start+2;default:return e.end-$-o}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive({sheetId:t,...e})}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:o,row:i}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:o,row:i,popoverType:"FilterMenu"})}isPositionVisible(e,t){const o=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===o.width||0===o.height)}}function Fv(e,t){return{...t,...Lv(e,{x:t.x,y:t.y})}}function Dv(e,t){return{...t,...Pv(e,{x:t.x,y:t.y})}}function Lv(e,{x:t,y:o}){const{x:i,y:s}=e.getMainViewportCoordinates(),{scrollX:r,scrollY:n}=e.getActiveSheetScrollInfo();return{x:t=t<i?t:t-r,y:o=o<s?o:o-n}}function Pv(e,{x:t,y:o}){const{x:i,y:s}=e.getMainViewportCoordinates(),{scrollX:r,scrollY:n}=e.getActiveSheetScrollInfo();return{x:t=i&&t<i?t:t+r,y:o=s&&o<s?o:o+n}}function kv(e,t,o){return Math.min(Math.max(e,t),o)}_v.props={gridPosition:{type:Object,optional:!0}};const Uv=5;function Vv(e,t,o){return o.map((e=>Bv(t,e))).filter((o=>function(e,t,o){const{x:i,y:s}=e.getMainViewportCoordinates(),r=[];switch(o.axisType){case"top":case"bottom":case"vCenter":if(t.y<s)return!0;r.push({x:t.x,y:o.position}),r.push({x:t.x+t.width,y:o.position});break;case"left":case"right":case"hCenter":if(t.x<i)return!0;r.push({x:o.position,y:t.y}),r.push({x:o.position,y:t.y+t.height})}return r.some(e.isPositionVisible)}(e,t,o))).map((o=>function(e,t,o){const i=Fv(e,t);return Bv(i,o.axisType)}(e,t,o)))}function zv(e,t,o,i,s){const r=Vv(e,t,o);let n;for(const t of i){const o=Vv(e,t,s);for(const e of r)for(const i of o){if(a=e.position,l=i.position,!(Math.abs(a-l)<=Uv))continue;const o=e.position-i.position;n&&o===n.snapOffset?n.matchedFigIds.push(t.id):(!n||Math.abs(o)<=Math.abs(n.snapOffset))&&(n={matchedFigIds:[t.id],snapOffset:o,snappedAxisType:e.axisType,position:i.position})}}var a,l;return n}function Bv(e,t){let o=0;switch(t){case"top":o=e.y;break;case"bottom":o=e.y+e.height-ee;break;case"vCenter":o=e.y+Math.floor(e.height/2)-ee;break;case"left":o=e.x;break;case"right":o=e.x+e.width-ee;break;case"hCenter":o=e.x+Math.floor(e.width/2)-ee}return{position:o,axisType:t}}Di`
1243
1239
  .o-figure-snap-line {
1244
1240
  position: relative;
1245
1241
  z-index: ${de.FigureSnapLine};
@@ -1252,7 +1248,7 @@
1252
1248
  height: 0px;
1253
1249
  }
1254
1250
  }
1255
- `;class Pv extends t.Component{static template="o-spreadsheet-FiguresContainer";static components={FigureComponent:av};dnd=t.useState({draggedFigure:void 0,horizontalSnap:void 0,verticalSnap:void 0});setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.draggedFigure&&!e.some((e=>e.id===this.dnd.draggedFigure?.id))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.draggedFigure?.id)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const i=e.filter((e=>this.getFigureContainer(e)===o));i.length>0&&t.push({type:o,figures:i,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.draggedFigure&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){return this.rectToCss(this.getContainerRect(e))}rectToCss(e){return Ui({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`})}getContainerRect(e){const{width:t,height:o}=this.env.model.getters.getMainViewportRect(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?i:0,n=t-r,a=["bottomRight","bottomLeft"].includes(e)?s:0;return{x:r,y:a,width:n,height:o-a}}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates();return Ui({left:`${["bottomRight","topRight"].includes(e)?-(i+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(s+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.draggedFigure?.id?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const o=this.env.model.getters.getActiveSheetId(),i={x:t.clientX,y:t.clientY},s={maxX:this.env.model.getters.getColDimensions(o,this.env.model.getters.getNumberCols(o)-1).end,maxY:this.env.model.getters.getRowDimensions(o,this.env.model.getters.getNumberRows(o)-1).end},{x:r,y:n}=Tv(this.env.model.getters,e),a={...e,x:r,y:n};Db((t=>{const o=this.env.model.getters,r=function({x:e,y:t},{x:o,y:i},s,{x:r,y:n},{maxX:a,maxY:l},{scrollX:c,scrollY:h}){const d=r?0:-c,u=n?0:-h,g=e-o,p=Mv(s.x+g,d,a-s.width-c),m=t-i,f=Mv(s.y+m,u,l-s.height-h);return{...s,x:p,y:f}}({x:t.clientX,y:t.clientY},i,a,this.env.model.getters.getMainViewportCoordinates(),s,o.getActiveSheetScrollInfo()),n=this.getOtherFigures(e.id),l=function(e,t,o){const i={...t},s=Dv(e,i,["hCenter","right","left"],o,["hCenter","right","left"]),r=Dv(e,i,["vCenter","bottom","top"],o,["vCenter","bottom","top"]),{y:n,x:a}=e.getMainViewportCoordinates(),{scrollY:l,scrollX:c}=e.getActiveSheetScrollInfo();if(r){i.y-=r.snapOffset;const e=t.y<n,o=i.y<n;e&&!o?i.y+=l:!e&&o&&(i.y-=l)}if(s){i.x-=s.snapOffset;const e=t.x<a,o=i.x<a;e&&!o?i.x+=c:!e&&o&&(i.x-=c)}return{snappedFigure:i,verticalSnapLine:s,horizontalSnapLine:r}}(o,Av(o,r),n);this.dnd.draggedFigure=Tv(o,l.snappedFigure),this.dnd.horizontalSnap=this.getSnap(l.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(l.verticalSnapLine)}),(t=>{if(!this.dnd.draggedFigure)return;let{x:i,y:s}=Av(this.env.model.getters,this.dnd.draggedFigure);this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:i,y:s})}))}startResize(e,t,o,i){i.stopPropagation();const s={x:i.clientX,y:i.clientY},{x:r,y:n}=Tv(this.env.model.getters,e),a={...e,x:r,y:n},l=Op.get(e.tag).keepRatio||!1,c=Op.get(e.tag).minFigSize||80;Db((i=>{const r={x:i.clientX,y:i.clientY},n=function(e,t,o,{x:i,y:s},{x:r,y:n},a,l){let{x:c,y:h,width:d,height:u}=e;if(a&&0!=t&&0!=o){const a=Math.min(t*(r-i),e.width-l),g=Math.min(o*(n-s),e.height-l),p=Math.min(a/e.width,g/e.height);d=e.width*(1-p),u=e.height*(1-p),t<0&&(c=e.x+e.width*p),o<0&&(h=e.y+e.height*p)}else{const a=Math.max(t*(i-r),l-e.width),g=Math.max(o*(s-n),l-e.height);d=e.width+a,u=e.height+g,t<0&&(c=e.x-a),o<0&&(h=e.y-g)}return{...e,x:c,y:h,width:d,height:u}}(a,t,o,r,s,l,c),h=this.getOtherFigures(e.id),d=function(e,t,o,i,s){const r={...i},n=Dv(e,r,[-1===t?"left":"right"],s,["right","left"]);n&&(1===t?r.width-=n.snapOffset:-1===t&&(r.x-=n.snapOffset,r.width+=n.snapOffset));const a=Dv(e,r,[-1===o?"top":"bottom"],s,["bottom","top"]);return a&&(1===o?r.height-=a.snapOffset:-1===o&&(r.y-=a.snapOffset,r.height+=a.snapOffset)),r.x=Math.round(r.x),r.y=Math.round(r.y),r.height=Math.round(r.height),r.width=Math.round(r.width),{snappedFigure:r,verticalSnapLine:n,horizontalSnapLine:a}}(this.env.model.getters,t,o,n,h);this.dnd.draggedFigure=d.snappedFigure,this.dnd.horizontalSnap=this.getSnap(d.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(d.verticalSnapLine)}),(i=>{if(!this.dnd.draggedFigure)return;let{x:s,y:r}=Av(this.env.model.getters,this.dnd.draggedFigure);const n={x:s,y:r};t&&(n.width=this.dnd.draggedFigure.width),o&&(n.height=this.dnd.draggedFigure.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...n}),this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0}))}getOtherFigures(e){return this.getVisibleFigures().filter((t=>t.id!==e))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.draggedFigure?.id));if(!e)throw new Error("Dnd figure not found");return{...e,...this.dnd.draggedFigure}}getFigureStyle(e){return e.id!==this.dnd.draggedFigure?.id?"":Ui({opacity:"0.9",cursor:"grabbing"})}getSnap(e){if(!e||!this.dnd.draggedFigure)return;const t=e.matchedFigIds.map((e=>this.getVisibleFigures().find((t=>t.id===e)))).filter(He).map((e=>{const t=Tv(this.env.model.getters,e),o=this.getFigureContainer(e);return vr(t,this.getContainerRect(o))})).filter(He),o=function(...e){return Cr(ni(...e.map(Sr)))}(this.dnd.draggedFigure,...t);return{line:e,containerStyle:this.rectToCss(o),lineStyle:this.getSnapLineStyle(e,o)}}getSnapLineStyle(e,t){return e?["top","vCenter","bottom"].includes(e.snappedAxisType)?Ui({top:e.position-t.y+"px",left:"0px",width:"100%"}):Ui({top:"0px",left:e.position-t.x+"px",height:"100%"}):""}}function kv(e,...o){t.useEffect((e=>(e?.addEventListener(...o),()=>e?.removeEventListener(...o))),(()=>[e.el]))}function Uv(e,o,i){let s={col:void 0,row:void 0};const{Date:r}=window;let n=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(n),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,o){let i;const{setInterval:s,clearInterval:r}=window;return t.useEffect((()=>(i=s(e,o),()=>r(i))),(()=>[o])),{pause:()=>{r(i),i=void 0},resume:()=>{void 0===i&&(i=s(e,o))}}}((function(){const{col:e,row:t}=c(),o=r.now()-l;o>300&&(e!==s.col||t!==s.row)&&u(void 0,void 0);if(o>300){if(e<0||t<0)return;u(e,t)}}),200);function u(e,t){e===s.col&&t===s.row||(s.col=e,s.row=t,i({col:e,row:t}))}return kv(o,"mousemove",(function(e){n=e.offsetX,a=e.offsetY,l=r.now()})),kv(o,"mouseleave",h),kv(o,"mouseenter",d),kv(o,"mousedown",(function(){const{col:e,row:t}=c();e===s.col&&t===s.row||u(void 0,void 0)})),s}Pv.props={onFigureDeleted:Function};class Vv extends t.Component{static template="o-spreadsheet-GridOverlay";static components={FiguresContainer:Pv};static defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}};gridOverlay;setup(){this.gridOverlay=t.useRef("gridOverlay"),Uv(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,t,o){let i=null,s=null;kv(e,"touchstart",(function(e){1===e.touches.length&&(i=e.touches[0].clientX,s=e.touches[0].clientY)})),kv(e,"touchend",(function(){i=null,s=null})),kv(e,"touchmove",(function(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const r=e.touches[0].clientX,n=e.touches[0].clientY;t(i-r,s-n),i=r,s=n}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){e.preventDefault();const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Vv.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class zv extends t.Component{static template="o-spreadsheet-GridPopover";static components={Popover:Er};zIndex=de.GridPopover;get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}zv.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class Bv extends t.Component{PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0});_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const i=this._getDimensionsInViewport(o);t-i.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start,this.state.activeElement=this._getPreviousVisibleElement(o)):i.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),i=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();o.has(i)&&i<=t&&t<=s?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),o=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),s=o-i+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();Db((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<s&&(this.state.draggerLinePosition=s,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=t.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=o.end-t.start;Lb(this.env,((e,o)=>{let i="COL"===this._getType()?e:o;if(i>=0){const e=this._getDimensionsInViewport(i);i<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=i):this._getSelectedZoneEnd()<i?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=i+1):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;Lb(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}Di`
1251
+ `;class Hv extends t.Component{static template="o-spreadsheet-FiguresContainer";static components={FigureComponent:gv};dnd=t.useState({draggedFigure:void 0,horizontalSnap:void 0,verticalSnap:void 0});setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.draggedFigure&&!e.some((e=>e.id===this.dnd.draggedFigure?.id))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.draggedFigure?.id)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const i=e.filter((e=>this.getFigureContainer(e)===o));i.length>0&&t.push({type:o,figures:i,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.draggedFigure&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){return this.rectToCss(this.getContainerRect(e))}rectToCss(e){return Ui({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`})}getContainerRect(e){const{width:t,height:o}=this.env.model.getters.getMainViewportRect(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?i:0,n=t-r,a=["bottomRight","bottomLeft"].includes(e)?s:0;return{x:r,y:a,width:n,height:o-a}}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates();return Ui({left:`${["bottomRight","topRight"].includes(e)?-(i+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(s+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.draggedFigure?.id?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const o=this.env.model.getters.getActiveSheetId(),i={x:t.clientX,y:t.clientY},s={maxX:this.env.model.getters.getColDimensions(o,this.env.model.getters.getNumberCols(o)-1).end,maxY:this.env.model.getters.getRowDimensions(o,this.env.model.getters.getNumberRows(o)-1).end},{x:r,y:n}=Fv(this.env.model.getters,e),a={...e,x:r,y:n};zb((t=>{const o=this.env.model.getters,r=function({x:e,y:t},{x:o,y:i},s,{x:r,y:n},{maxX:a,maxY:l},{scrollX:c,scrollY:h}){const d=r?0:-c,u=n?0:-h,g=e-o,p=kv(s.x+g,d,a-s.width-c),m=t-i,f=kv(s.y+m,u,l-s.height-h);return{...s,x:p,y:f}}({x:t.clientX,y:t.clientY},i,a,this.env.model.getters.getMainViewportCoordinates(),s,o.getActiveSheetScrollInfo()),n=this.getOtherFigures(e.id),l=function(e,t,o){const i={...t},s=zv(e,i,["hCenter","right","left"],o,["hCenter","right","left"]),r=zv(e,i,["vCenter","bottom","top"],o,["vCenter","bottom","top"]),{y:n,x:a}=e.getMainViewportCoordinates(),{scrollY:l,scrollX:c}=e.getActiveSheetScrollInfo();if(r){i.y-=r.snapOffset;const e=t.y<n,o=i.y<n;e&&!o?i.y+=l:!e&&o&&(i.y-=l)}if(s){i.x-=s.snapOffset;const e=t.x<a,o=i.x<a;e&&!o?i.x+=c:!e&&o&&(i.x-=c)}return{snappedFigure:i,verticalSnapLine:s,horizontalSnapLine:r}}(o,Dv(o,r),n);this.dnd.draggedFigure=Fv(o,l.snappedFigure),this.dnd.horizontalSnap=this.getSnap(l.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(l.verticalSnapLine)}),(t=>{if(!this.dnd.draggedFigure)return;let{x:i,y:s}=Dv(this.env.model.getters,this.dnd.draggedFigure);this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:i,y:s})}))}startResize(e,t,o,i){i.stopPropagation();const s={x:i.clientX,y:i.clientY},{x:r,y:n}=Fv(this.env.model.getters,e),a={...e,x:r,y:n},l=Lp.get(e.tag).keepRatio||!1,c=Lp.get(e.tag).minFigSize||80;zb((i=>{const r={x:i.clientX,y:i.clientY},n=function(e,t,o,{x:i,y:s},{x:r,y:n},a,l){let{x:c,y:h,width:d,height:u}=e;if(a&&0!=t&&0!=o){const a=Math.min(t*(r-i),e.width-l),g=Math.min(o*(n-s),e.height-l),p=Math.min(a/e.width,g/e.height);d=e.width*(1-p),u=e.height*(1-p),t<0&&(c=e.x+e.width*p),o<0&&(h=e.y+e.height*p)}else{const a=Math.max(t*(i-r),l-e.width),g=Math.max(o*(s-n),l-e.height);d=e.width+a,u=e.height+g,t<0&&(c=e.x-a),o<0&&(h=e.y-g)}return{...e,x:c,y:h,width:d,height:u}}(a,t,o,r,s,l,c),h=this.getOtherFigures(e.id),d=function(e,t,o,i,s){const r={...i},n=zv(e,r,[-1===t?"left":"right"],s,["right","left"]);n&&(1===t?r.width-=n.snapOffset:-1===t&&(r.x-=n.snapOffset,r.width+=n.snapOffset));const a=zv(e,r,[-1===o?"top":"bottom"],s,["bottom","top"]);return a&&(1===o?r.height-=a.snapOffset:-1===o&&(r.y-=a.snapOffset,r.height+=a.snapOffset)),r.x=Math.round(r.x),r.y=Math.round(r.y),r.height=Math.round(r.height),r.width=Math.round(r.width),{snappedFigure:r,verticalSnapLine:n,horizontalSnapLine:a}}(this.env.model.getters,t,o,n,h);this.dnd.draggedFigure=d.snappedFigure,this.dnd.horizontalSnap=this.getSnap(d.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(d.verticalSnapLine)}),(i=>{if(!this.dnd.draggedFigure)return;let{x:s,y:r}=Dv(this.env.model.getters,this.dnd.draggedFigure);const n={x:s,y:r};t&&(n.width=this.dnd.draggedFigure.width),o&&(n.height=this.dnd.draggedFigure.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...n}),this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0}))}getOtherFigures(e){return this.getVisibleFigures().filter((t=>t.id!==e))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.draggedFigure?.id));if(!e)throw new Error("Dnd figure not found");return{...e,...this.dnd.draggedFigure}}getFigureStyle(e){return e.id!==this.dnd.draggedFigure?.id?"":Ui({opacity:"0.9",cursor:"grabbing"})}getSnap(e){if(!e||!this.dnd.draggedFigure)return;const t=e.matchedFigIds.map((e=>this.getVisibleFigures().find((t=>t.id===e)))).filter(He).map((e=>{const t=Fv(this.env.model.getters,e),o=this.getFigureContainer(e);return vr(t,this.getContainerRect(o))})).filter(He),o=function(...e){return Cr(ni(...e.map(Sr)))}(this.dnd.draggedFigure,...t);return{line:e,containerStyle:this.rectToCss(o),lineStyle:this.getSnapLineStyle(e,o)}}getSnapLineStyle(e,t){return e?["top","vCenter","bottom"].includes(e.snappedAxisType)?Ui({top:e.position-t.y+"px",left:"0px",width:"100%"}):Ui({top:"0px",left:e.position-t.x+"px",height:"100%"}):""}}function $v(e,...o){t.useEffect((e=>(e?.addEventListener(...o),()=>e?.removeEventListener(...o))),(()=>[e.el]))}function Wv(e,o,i){let s={col:void 0,row:void 0};const{Date:r}=window;let n=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(n),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,o){let i;const{setInterval:s,clearInterval:r}=window;return t.useEffect((()=>(i=s(e,o),()=>r(i))),(()=>[o])),{pause:()=>{r(i),i=void 0},resume:()=>{void 0===i&&(i=s(e,o))}}}((function(){const{col:e,row:t}=c(),o=r.now()-l;o>300&&(e!==s.col||t!==s.row)&&u(void 0,void 0);if(o>300){if(e<0||t<0)return;u(e,t)}}),200);function u(e,t){e===s.col&&t===s.row||(s.col=e,s.row=t,i({col:e,row:t}))}return $v(o,"mousemove",(function(e){n=e.offsetX,a=e.offsetY,l=r.now()})),$v(o,"mouseleave",h),$v(o,"mouseenter",d),$v(o,"mousedown",(function(){const{col:e,row:t}=c();e===s.col&&t===s.row||u(void 0,void 0)})),s}Hv.props={onFigureDeleted:Function};class Gv extends t.Component{static template="o-spreadsheet-GridOverlay";static components={FiguresContainer:Hv};static defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}};gridOverlay;setup(){this.gridOverlay=t.useRef("gridOverlay"),Wv(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,t,o){let i=null,s=null;$v(e,"touchstart",(function(e){1===e.touches.length&&(i=e.touches[0].clientX,s=e.touches[0].clientY)})),$v(e,"touchend",(function(){i=null,s=null})),$v(e,"touchmove",(function(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const r=e.touches[0].clientX,n=e.touches[0].clientY;t(i-r,s-n),i=r,s=n}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){e.preventDefault();const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Gv.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class qv extends t.Component{static template="o-spreadsheet-GridPopover";static components={Popover:Er};zIndex=de.GridPopover;get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}qv.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class Zv extends t.Component{PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0});_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const i=this._getDimensionsInViewport(o);t-i.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start,this.state.activeElement=this._getPreviousVisibleElement(o)):i.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),i=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();o.has(i)&&i<=t&&t<=s?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),o=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),s=o-i+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();zb((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<s&&(this.state.draggerLinePosition=s,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=t.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=o.end-t.start;Bb(this.env,((e,o)=>{let i="COL"===this._getType()?e:o;if(i>=0){const e=this._getDimensionsInViewport(i);i<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=i):this._getSelectedZoneEnd()<i?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=i+1):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;Bb(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}Di`
1256
1252
  .o-col-resizer {
1257
1253
  position: absolute;
1258
1254
  top: 0;
@@ -1311,7 +1307,7 @@
1311
1307
  top: calc(${U}px / 2 - ${k}px / 2);
1312
1308
  }
1313
1309
  }
1314
- `,Bv.props={onOpenContextMenu:Function};class Hv extends Bv{static template="o-spreadsheet-ColResizer";colResizerRef;setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let i=t;i<=o;i++)e.push(i);const i=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!i.isSuccessful&&i.reasons.includes(2)&&this.env.raiseError(Gg)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isColHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Di`
1310
+ `,Zv.props={onOpenContextMenu:Function};class jv extends Zv{static template="o-spreadsheet-ColResizer";colResizerRef;setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let i=t;i<=o;i++)e.push(i);const i=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!i.isSuccessful&&i.reasons.includes(2)&&this.env.raiseError(Kg)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isColHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Di`
1315
1311
  .o-row-resizer {
1316
1312
  position: absolute;
1317
1313
  top: ${_}px;
@@ -1372,7 +1368,7 @@
1372
1368
  background-color: lightgrey;
1373
1369
  }
1374
1370
  }
1375
- `,Hv.props={onOpenContextMenu:Function};class $v extends Bv{static template="o-spreadsheet-RowResizer";setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}rowResizerRef;_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let i=t;i<=o;i++)e.push(i);const i=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!i.isSuccessful&&i.reasons.includes(2)&&this.env.raiseError(Gg)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isRowHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Di`
1371
+ `,jv.props={onOpenContextMenu:Function};class Yv extends Zv{static template="o-spreadsheet-RowResizer";setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}rowResizerRef;_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let i=t;i<=o;i++)e.push(i);const i=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!i.isSuccessful&&i.reasons.includes(2)&&this.env.raiseError(Kg)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isRowHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Di`
1376
1372
  .o-overlay {
1377
1373
  .all {
1378
1374
  position: absolute;
@@ -1383,7 +1379,7 @@
1383
1379
  height: ${_}px;
1384
1380
  }
1385
1381
  }
1386
- `,$v.props={onOpenContextMenu:Function};class Wv extends t.Component{static template="o-spreadsheet-HeadersOverlay";static components={ColResizer:Hv,RowResizer:$v};selectAll(){this.env.model.selection.selectAll()}}function Gv(e,o,i){const s=t.useRef(e);t.useEffect((function(){const e=s.el,t=window.devicePixelRatio||1,r=e.getContext("2d",{alpha:!1}),n={ctx:r,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=i();e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),r.translate(-m,-m),r.scale(t,t),o.drawGrid(n)}))}function qv(e){function t(e,t){return e*(0===t?1:L)}return o=>{const i=t(o.shiftKey?o.deltaY:o.deltaX,o.deltaMode),s=t(o.shiftKey?o.deltaX:o.deltaY,o.deltaMode);e(i,s)}}Wv.props={onOpenContextMenu:Function},Di`
1382
+ `,Yv.props={onOpenContextMenu:Function};class Xv extends t.Component{static template="o-spreadsheet-HeadersOverlay";static components={ColResizer:jv,RowResizer:Yv};selectAll(){this.env.model.selection.selectAll()}}function Kv(e,o,i){const s=t.useRef(e);t.useEffect((function(){const e=s.el,t=window.devicePixelRatio||1,r=e.getContext("2d",{alpha:!1}),n={ctx:r,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=i();e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),r.translate(-m,-m),r.scale(t,t),o.drawGrid(n)}))}function Qv(e){function t(e,t){return e*(0===t?1:L)}return o=>{const i=t(o.shiftKey?o.deltaY:o.deltaX,o.deltaMode),s=t(o.shiftKey?o.deltaX:o.deltaY,o.deltaMode);e(i,s)}}Xv.props={onOpenContextMenu:Function},Di`
1387
1383
  .o-border {
1388
1384
  position: absolute;
1389
1385
  &:hover {
@@ -1393,7 +1389,7 @@
1393
1389
  .o-moving {
1394
1390
  cursor: grabbing;
1395
1391
  }
1396
- `;class Zv extends t.Component{static template="o-spreadsheet-Border";get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),o=["n","s"].includes(this.props.orientation),i=["w","e"].includes(this.props.orientation),s=this.props.zone,r=this.env.model.getters.getVisibleRect(s),n=r.x,a=r.x+r.width-4,l=r.y,c=r.y+r.height-4;return Ui({left:`${t?n:a}px`,top:`${e?l:c}px`,width:`${o?a-n:4}px`,height:`${i?c-l:4}px`})}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}Zv.props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function},Di`
1392
+ `;class Jv extends t.Component{static template="o-spreadsheet-Border";get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),o=["n","s"].includes(this.props.orientation),i=["w","e"].includes(this.props.orientation),s=this.props.zone,r=this.env.model.getters.getVisibleRect(s),n=r.x,a=r.x+r.width-4,l=r.y,c=r.y+r.height-4;return Ui({left:`${t?n:a}px`,top:`${e?l:c}px`,width:`${o?a-n:4}px`,height:`${i?c-l:4}px`})}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}Jv.props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function},Di`
1397
1393
  .o-corner {
1398
1394
  position: absolute;
1399
1395
  height: 6px;
@@ -1415,11 +1411,11 @@
1415
1411
  .o-resizing {
1416
1412
  cursor: grabbing;
1417
1413
  }
1418
- `;class jv extends t.Component{static template="o-spreadsheet-Corner";isTop="n"===this.props.orientation[0];isLeft="w"===this.props.orientation[1];get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,o=this.isTop?e.top:e.bottom,i=this.env.model.getters.getVisibleRect({left:t,right:t,top:o,bottom:o});if(i.width*i.height==0)return"display:none";return Ui({left:(this.isLeft?i.x:i.x+i.width)-4+"px",top:(this.isTop?i.y:i.y+i.height)-4+"px","background-color":this.props.color})}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}jv.props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function},Di`
1414
+ `;class eS extends t.Component{static template="o-spreadsheet-Corner";isTop="n"===this.props.orientation[0];isLeft="w"===this.props.orientation[1];get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,o=this.isTop?e.top:e.bottom,i=this.env.model.getters.getVisibleRect({left:t,right:t,top:o,bottom:o});if(i.width*i.height==0)return"display:none";return Ui({left:(this.isLeft?i.x:i.x+i.width)-4+"px",top:(this.isTop?i.y:i.y+i.height)-4+"px","background-color":this.props.color})}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}eS.props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function},Di`
1419
1415
  .o-highlight {
1420
1416
  z-index: ${de.Highlight};
1421
1417
  }
1422
- `;class Yv extends t.Component{static template="o-spreadsheet-Highlight";static components={Corner:jv,Border:Zv};highlightState=t.useState({shiftingMode:"none"});onResizeHighlight(e,t){const o=this.env.model.getters.getActiveSheetId();this.highlightState.shiftingMode="isResizing";const i=this.props.zone,s=e?i.right:i.left,r=t?i.bottom:i.top;let n=e?i.left:i.right,a=t?i.top:i.bottom,l=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o,l)});Lb(this.env,((e,t)=>{if(n!==e||a!==t){n=we(-1===e?n:e,0,this.env.model.getters.getNumberCols(o)-1),a=we(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let i={left:Math.min(s,n),top:Math.min(r,a),right:Math.max(s,n),bottom:Math.max(r,a)};i=this.env.model.getters.expandZone(o,i),li(i,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeFromZone(o,this.env.model.getters.getUnboundedZone(o,i)).rangeData}),l=i)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const o=this.props.zone,i=gr(),s=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getColIndex(e-i.left),n=this.env.model.getters.getRowIndex(t-i.top),a=-o.left,l=this.env.model.getters.getNumberCols(s)-o.right-1,c=-o.top,h=this.env.model.getters.getNumberRows(s)-o.bottom-1;let d=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(s,d)});let u=r,g=n;Lb(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const i=we(u-r,a,l),p=we(g-n,c,h);let m={left:o.left+i,top:o.top+p,right:o.right+i,bottom:o.bottom+p};m=this.env.model.getters.expandZone(s,m),li(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeFromZone(s,this.env.model.getters.getUnboundedZone(s,m)).rangeData}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}Yv.props={zone:Object,color:String};class Xv{direction;el;constructor(e,t){this.el=e,this.direction=t}get scroll(){return"horizontal"===this.direction?this.el.scrollLeft:this.el.scrollTop}set scroll(e){"horizontal"===this.direction?this.el.scrollLeft=e:this.el.scrollTop=e}}Di`
1418
+ `;class tS extends t.Component{static template="o-spreadsheet-Highlight";static components={Corner:eS,Border:Jv};highlightState=t.useState({shiftingMode:"none"});onResizeHighlight(e,t){const o=this.env.model.getters.getActiveSheetId();this.highlightState.shiftingMode="isResizing";const i=this.props.zone,s=e?i.right:i.left,r=t?i.bottom:i.top;let n=e?i.left:i.right,a=t?i.top:i.bottom,l=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o,l)});Bb(this.env,((e,t)=>{if(n!==e||a!==t){n=we(-1===e?n:e,0,this.env.model.getters.getNumberCols(o)-1),a=we(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let i={left:Math.min(s,n),top:Math.min(r,a),right:Math.max(s,n),bottom:Math.max(r,a)};i=this.env.model.getters.expandZone(o,i),li(i,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeFromZone(o,this.env.model.getters.getUnboundedZone(o,i)).rangeData}),l=i)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const o=this.props.zone,i=gr(),s=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getColIndex(e-i.left),n=this.env.model.getters.getRowIndex(t-i.top),a=-o.left,l=this.env.model.getters.getNumberCols(s)-o.right-1,c=-o.top,h=this.env.model.getters.getNumberRows(s)-o.bottom-1;let d=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(s,d)});let u=r,g=n;Bb(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const i=we(u-r,a,l),p=we(g-n,c,h);let m={left:o.left+i,top:o.top+p,right:o.right+i,bottom:o.bottom+p};m=this.env.model.getters.expandZone(s,m),li(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeFromZone(s,this.env.model.getters.getUnboundedZone(s,m)).rangeData}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}tS.props={zone:Object,color:String};class oS{direction;el;constructor(e,t){this.el=e,this.direction=t}get scroll(){return"horizontal"===this.direction?this.el.scrollLeft:this.el.scrollTop}set scroll(e){"horizontal"===this.direction?this.el.scrollLeft=e:this.el.scrollTop=e}}Di`
1423
1419
  .o-scrollbar {
1424
1420
  position: absolute;
1425
1421
  overflow: auto;
@@ -1435,7 +1431,7 @@
1435
1431
  border-left: 1px solid #e2e3e3;
1436
1432
  }
1437
1433
  }
1438
- `;class Kv extends t.Component{static template=t.xml`
1434
+ `;class iS extends t.Component{static template=t.xml`
1439
1435
  <div
1440
1436
  t-attf-class="o-scrollbar {{props.direction}}"
1441
1437
  t-on-scroll="onScroll"
@@ -1443,7 +1439,7 @@
1443
1439
  t-att-style="positionCss">
1444
1440
  <div t-att-style="sizeCss"/>
1445
1441
  </div>
1446
- `;static defaultProps={width:1,height:1};scrollbarRef;scrollbar;setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new Xv(this.scrollbarRef.el,this.props.direction),t.onMounted((()=>{this.scrollbar.el=this.scrollbarRef.el})),t.useEffect((()=>{this.scrollbar.scroll!==this.props.offset&&(this.scrollbar.scroll=this.props.offset)}),(()=>[this.scrollbar.scroll,this.props.offset]))}get sizeCss(){return Ui({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return Ui(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}Kv.props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};class Qv extends t.Component{static components={ScrollBar:Kv};static template=t.xml`
1442
+ `;static defaultProps={width:1,height:1};scrollbarRef;scrollbar;setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new oS(this.scrollbarRef.el,this.props.direction),t.onMounted((()=>{this.scrollbar.el=this.scrollbarRef.el})),t.useEffect((()=>{this.scrollbar.scroll!==this.props.offset&&(this.scrollbar.scroll=this.props.offset)}),(()=>[this.scrollbar.scroll,this.props.offset]))}get sizeCss(){return Ui({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return Ui(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}iS.props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};class sS extends t.Component{static components={ScrollBar:iS};static template=t.xml`
1447
1443
  <ScrollBar
1448
1444
  t-if="isDisplayed"
1449
1445
  width="width"
@@ -1451,7 +1447,7 @@
1451
1447
  offset="offset"
1452
1448
  direction="'horizontal'"
1453
1449
  onScroll.bind="onScroll"
1454
- />`;static defaultProps={leftOffset:0};get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollX}get width(){return this.env.model.getters.getMainViewportRect().width}get isDisplayed(){const{xRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{x:e}=this.env.model.getters.getMainViewportRect();return{left:`${this.props.leftOffset+e}px`,bottom:"0px",height:"15px",right:"0px"}}onScroll(e){const{scrollY:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t})}}Qv.props={leftOffset:{type:Number,optional:!0}};class Jv extends t.Component{static components={ScrollBar:Kv};static template=t.xml`
1450
+ />`;static defaultProps={leftOffset:0};get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollX}get width(){return this.env.model.getters.getMainViewportRect().width}get isDisplayed(){const{xRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{x:e}=this.env.model.getters.getMainViewportRect();return{left:`${this.props.leftOffset+e}px`,bottom:"0px",height:"15px",right:"0px"}}onScroll(e){const{scrollY:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t})}}sS.props={leftOffset:{type:Number,optional:!0}};class rS extends t.Component{static components={ScrollBar:iS};static template=t.xml`
1455
1451
  <ScrollBar
1456
1452
  t-if="isDisplayed"
1457
1453
  height="height"
@@ -1459,13 +1455,13 @@
1459
1455
  offset="offset"
1460
1456
  direction="'vertical'"
1461
1457
  onScroll.bind="onScroll"
1462
- />`;static defaultProps={topOffset:0};get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.topOffset+e}px`,right:"0px",width:"15px",bottom:"0px"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}Jv.props={topOffset:{type:Number,optional:!0}};const eS={ROW:xb,COL:Eb,CELL:tf};class tS extends t.Component{static template="o-spreadsheet-Grid";static components={GridComposer:wv,GridOverlay:Vv,GridPopover:zv,HeadersOverlay:Wv,Menu:Ir,Autofill:lv,ClientTag:hv,Highlight:Yv,Popover:Er,VerticalScrollBar:Jv,HorizontalScrollBar:Qv,FilterIconsOverlay:Rv};HEADER_HEIGHT=_;HEADER_WIDTH=F;menuState;gridRef;hiddenInput;onMouseWheel;canvasPosition;hoveredCell;setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=br(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),Gv("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=qv(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return Ui({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focus()}keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===Qi.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===Qi.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():this.env.model.dispatch("CLEAN_CLIPBOARD_HIGHLIGHT")},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),F4:()=>this.env.model.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"CTRL+O":()=>Qp(this.env),"ALT+=":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),i=this.env.model.getters.getAutomaticSums(e,t,o.cell);if(this.env.model.getters.isSingleCellOrMerge(e,t)||this.env.model.getters.isEmpty(e,t)&&i.length<=1){const t=i[0]?.zone,o=t?this.env.model.getters.zoneToXC(e,i[0].zone):"",s=`=SUM(${o})`;this.props.onGridComposerCellFocused(s,{start:5,end:5+o.length})}else this.env.model.dispatch("SUM_SELECTION")},"ALT+ENTER":()=>{const e=this.env.model.getters.getActiveCell();e.link&&Xi(e.link,this.env)},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,o)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),o=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,o)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+SHIFT+E":()=>this.setHorizontalAlign("center"),"CTRL+SHIFT+L":()=>this.setHorizontalAlign("left"),"CTRL+SHIFT+R":()=>this.setHorizontalAlign("right"),"CTRL+SHIFT+V":()=>Gp(this.env),"CTRL+SHIFT+<":()=>this.clearFormatting(),"CTRL+<":()=>this.clearFormatting(),"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"CTRL+ALT+=":()=>{const e=this.env.model.getters.getActiveCols(),t=this.env.model.getters.getActiveRows(),o=1===this.env.model.getters.getSelectedZones().length,i=e.size>0&&o,s=t.size>0&&o;i&&!s?Xp(this.env):s&&!i&&Yp(this.env)},"CTRL+ALT+-":()=>{const e=[...this.env.model.getters.getActiveCols()],t=[...this.env.model.getters.getActiveRows()];e.length>0&&0===t.length?this.env.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",elements:e}):t.length>0&&0===e.length&&this.env.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP"),"CTRL+K":()=>em(this.env)};focus(){this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||this.hiddenInput.el?.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}get isAutofillVisible(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:F,gridOffsetY:_})}moveCanvas(e,t){const{scrollX:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getClientPositionKey(e){return`${e.id}-${e.position?.sheetId}-${e.position?.col}-${e.position?.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{ctrlKey:o,shiftKey:i}){o&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),i?this.env.model.selection.setAnchorCorner(e,t):o?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let s=e,r=t;Lb(this.env,((e,t)=>{(e!==s&&-1!=e||t!==r&&-1!=t)&&(s=-1===e?s:e,r=-1===t?r:t,this.env.model.selection.setAnchorCorner(s,r))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const o=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:o,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t}).type===Qi.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),Ab(e,this.env.model.selection),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];return o?(e.preventDefault(),e.stopPropagation(),void o()):void 0}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:o,top:i}=t;let s="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(o)?s="COL":this.env.model.getters.getActiveRows().has(i)&&(s="ROW");const{x:r,y:n,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(s,r+a,n+l)}onCellRightClicked(e,t,{x:o,y:i}){const s=this.env.model.getters.getSelectedZones();let r="CELL";hi(e,t,s[s.length-1])?this.env.model.getters.getActiveCols().has(e)?r="COL":this.env.model.getters.getActiveRows().has(t)&&(r="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(r,o,i)}toggleContextMenu(e,t,o){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:o},this.menuState.menuItems=eS[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const o=t.clipboardData;if(!o)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?Lp(this.env):this.env.model.dispatch("COPY");const i=this.env.model.getters.getClipboardContent();for(const e in i)o.setData(e,i[e]);t.preventDefault()}async paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(Ji.PlainText)>-1){const e=t.getData(Ji.PlainText),o=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?Vp(this.env,o):zp(this.env,o,e),this.env.model.getters.isCutOperation()&&await this.env.clipboard.write({[Ji.PlainText]:""})}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(r("Copy/Paste is not supported in this browser."))}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setHorizontalAlign(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{align:e}})}closeMenu(){this.menuState.isOpen=!1,this.focus()}}tS.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class oS{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}}const iS=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],sS="000000",rS={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},nS={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",table:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",revision:"http://schemas.microsoft.com/office/spreadsheetml/2014/revision",revision3:"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3",markupCompatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006"},aS="http://schemas.openxmlformats.org/drawingml/2006/main",lS="http://schemas.openxmlformats.org/drawingml/2006/chart",cS={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",themes:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",pivot:"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",externalLink:"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"},hS={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",sharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",drawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"},dS="http://schemas.openxmlformats.org/officeDocument/2006/relationships",uS=.75,gS=.1317,pS=8.43,mS=12.75,fS=30,bS=100,vS=164,SS={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},CS=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"],ES="[Content_Types].xml";var wS;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(wS||(wS={}));class yS{_parsingWarnings=new Set;_conversionWarnings=new Set;addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,o){let i=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;o&&(i+=`Only ${o.join(", ")} are currently supported.`),this._conversionWarnings.has(i)||this._conversionWarnings.add(i)}}const xS=["thin"],IS=["general","left","center","right"],RS=["top","center","bottom"],TS=["Arial"],AS=["solid"],OS=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],NS={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},MS={dashDot:"thin",dashDotDot:"thin",dashed:"dashed",dotted:"dotted",double:"thin",hair:"thin",medium:"medium",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thick",thin:"thin"},_S={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"},FS={top:"top",center:"middle",bottom:"bottom",justify:"middle",distributed:"middle"},DS={top:"top",middle:"center",bottom:"bottom"};const LS={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},PS={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},kS={NoIcons:void 0,"3Arrows":"arrows","3ArrowsGray":"arrows","3Symbols":"smiley","3Symbols2":"smiley","3Signs":"dots","3Flags":"dots","3TrafficLights1":"dots","3TrafficLights2":"dots","4Arrows":"arrows","4ArrowsGray":"arrows","4RedToBlack":"dots","4Rating":"smiley","4TrafficLights":"dots","5Arrows":"arrows","5ArrowsGray":"arrows","5Rating":"smiley","5Quarters":"dots","3Stars":"smiley","3Triangles":"arrows","5Boxes":"dots"},US={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},VS={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},zS={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV",8:"STDEVP",9:"SUM",10:"VAR",11:"VARP",101:"AVERAGE",102:"COUNT",103:"COUNTA",104:"MAX",105:"MIN",106:"PRODUCT",107:"STDEV",108:"STDEVP",109:"SUM",110:"VAR",111:"VARP"},BS={0:"",1:"0",2:"0.00",3:"#,#00",4:"#,##0.00",9:"0%",10:"0.00%",11:void 0,12:void 0,13:void 0,14:"m/d/yyyy",15:"m/d/yyyy",16:"m/d/yyyy",17:"m/d/yyyy",18:"hh:mm:ss a",19:"hh:mm:ss a",20:"hhhh:mm:ss",21:"hhhh:mm:ss",22:"m/d/yy h:mm",37:void 0,38:void 0,39:void 0,40:void 0,45:"hhhh:mm:ss",46:"hhhh:mm:ss",47:"hhhh:mm:ss",48:void 0,49:void 0},HS={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},$S={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF",16:"800000",17:"008000",18:"000080",19:"808000",20:"800080",21:"008080",22:"C0C0C0",23:"808080",24:"9999FF",25:"993366",26:"FFFFCC",27:"CCFFFF",28:"660066",29:"FF8080",30:"0066CC",31:"CCCCFF",32:"000080",33:"FF00FF",34:"FFFF00",35:"00FFFF",36:"800080",37:"800000",38:"008080",39:"0000FF",40:"00CCFF",41:"CCFFFF",42:"CCFFCC",43:"FFFF99",44:"99CCFF",45:"FF99CC",46:"CC99FF",47:"FFCC99",48:"3366FF",49:"33CCCC",50:"99CC00",51:"FFCC00",52:"FF9900",53:"FF6600",54:"666699",55:"969696",56:"003366",57:"339966",58:"003300",59:"333300",60:"993300",61:"993366",62:"333399",63:"333333",64:"000000",65:"FFFFFF"},WS={"image/avif":"avif","image/bmp":"bmp","image/gif":"gif","image/vnd.microsoft.icon":"ico","image/jpeg":"jpeg","image/png":"png","image/tiff":"tiff","image/webp":"webp"};function GS(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=sS;else{if(!e.indexed)return;t=$S[e.indexed]}var o;return t=6===(o=t).length?"#"+o+"FF":"#"+o.slice(2)+o.slice(0,2),e.tint&&(t=function(e,t){const o=ft(e),i=vt(o);t<0&&(i.l=i.l*(1+t));t>0&&(i.l=i.l*(1-t)+(100-100*(1-t)));return mt(bt(i))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function qS(e,t){const o=e.split("/"),i=t.split("/");let s="",r=0;for(let e=0;e<o.length-1;e++)o[e]===i[e]?r++:s+="../";return s+=i.slice(r).join("/"),s}function ZS(e,t=0){const o={};for(let i=0;i<e.length;i++)e[i]&&(o[i+t]=e[i]);return o}function jS(e){const t=[];for(let o of Object.keys(e).map(Number))t[o]=e[o];return t}function YS(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const XS=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function KS(e,t,o){if(0===e)return;let i=BS[e]||t.find((t=>t.id===e))?.format;if(i)try{let e=i.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=e.match(/"/g)?.length||0;if(t/2+(e.match(/\[/g)?.length||0)>1)throw new Error("Multiple escaped blocks in format");if(e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),e=e.replace(/\\./g,(e=>e[1])),function(e){return XS.test(e)}(e)&&(e=function(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,"mmm"),e=e.replace(/am\/pm|a\/m/g,"a"),e=e.replace(/hhhh/g,"hh"),e=e.replace(/\bh\b/g,"hh"),e}(e)),function(e){try{return vo(0,{format:e,locale:oo}),!0}catch(e){return!1}}(e))return e}catch(e){}o.generateNotSupportedWarning(wS.NumFmtIdNotSupported,i||`nmFmtId ${e}`)}function QS(e,t){const o=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(wS.DiagonalBorderNotSupported)}(e,t);const o={top:JS(e.top,t),bottom:JS(e.bottom,t),left:JS(e.left,t),right:JS(e.right,t)};return Object.keys(o).forEach((e=>void 0===o[e]&&delete o[e])),o}));return ZS(o,1)}function JS(e,t){if(!e)return;!function(e,t){xS.includes(e.style)||t.generateNotSupportedWarning(wS.BorderStyleNotSupported,e.style,xS)}(e,t);const o=MS[e.style];return o?{style:o,color:GS(e.color)}:void 0}function eC(e,t){return ZS(e.styles.map((o=>tC({fontStyle:e.fonts[o.fontId],fillStyle:e.fills[o.fillId],alignment:o.alignment},t))),1)}function tC(e,t){return function(e,t,o){e&&e.name&&!TS.includes(e.name)&&o.generateNotSupportedWarning(wS.FontNotSupported,e.name,TS);t&&t.patternType&&!AS.includes(t.patternType)&&o.generateNotSupportedWarning(wS.FillStyleNotSupported,t.patternType,AS)}(e?.fontStyle,e?.fillStyle,t),function(e,t){e&&!IS.includes(e)&&t.generateNotSupportedWarning(wS.HorizontalAlignmentNotSupported,e,IS)}(e?.alignment?.horizontal,t),function(e,t){e&&!RS.includes(e)&&t.generateNotSupportedWarning(wS.VerticalAlignmentNotSupported,e,RS)}(e?.alignment?.vertical,t),{bold:e.fontStyle?.bold,italic:e.fontStyle?.italic,strikethrough:e.fontStyle?.strike,underline:e.fontStyle?.underline,verticalAlign:e.alignment?.vertical?FS[e.alignment.vertical]:void 0,align:e.alignment?.horizontal?_S[e.alignment.horizontal]:void 0,fillColor:"solid"===e.fillStyle?.patternType?GS(e.fillStyle?.fgColor):GS(e.fillStyle?.bgColor),textColor:GS(e.fontStyle?.color),fontSize:e.fontStyle?.size,wrapping:e.alignment?.wrapText?"wrap":"overflow"}}function oC(e,t){const o=[];for(let i of e.styles){const s=KS(i.numFmtId,e.numFmts,t);s&&(o[i.numFmtId]=s)}return ZS(o,1)}function iC(e,t,o){const i=[];let s=1;for(let n of e){if(0===n.cfRules.length)continue;aC(n,t,o);const e=n.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=sC(s++,n);t&&i.push(t);continue;case"iconSet":const c=rC(s++,n,o);c&&i.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=LS[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=LS[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(r=e.operator).slice(0,1).toUpperCase()+r.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&i.push({id:(s++).toString(),ranges:n.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:tC({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},o)}})}}var r;return i}function sC(e,t){const o=t.cfRules[0].colorScale;if(!o||o.cfvos.length!==o.colors.length||o.cfvos.length<2||o.cfvos.length>3)return;const i=[];for(let e=0;e<o.cfvos.length;e++)i.push({color:(s=GS(o.colors[e])||"#FFFFFF",9===s.length&&(s=s.slice(0,7)),parseInt(s.replace("#",""),16)),type:PS[o.cfvos[e].type],value:o.cfvos[e].value});var s;const r=i[0],n=2===i.length?i[1]:i[2],a=3===i.length?i[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:r,midpoint:a,maximum:n}}}function rC(e,t,o){const i=t.cfRules[0].iconSet;if(!i)return;let s=i.cfvos,r=i.cfIcons;if(s.length<3||r&&r.length<3)return;s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]),r&&r.length>3&&(r=[r[0],r[Math.floor(r.length/2)],r[r.length-1]]);const n=[];for(let e=1;e<=2;e++){const t=PS[s[e].type];if("value"===t)return;n.push({value:s[e].value||"",operator:s[e].gte?"ge":"gt",type:t})}let a={lower:r?nC(r[0].iconSet,r[0].iconId):nC(i.iconSet,0),middle:r?nC(r[1].iconSet,r[1].iconId):nC(i.iconSet,1),upper:r?nC(r[2].iconSet,r[2].iconId):nC(i.iconSet,2)};i.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(o.generateNotSupportedWarning(wS.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=Xb.dots.good;break;case"middle":a[e]=Xb.dots.neutral;break;case"lower":a[e]=Xb.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:n[1],lowerInflectionPoint:n[0]}}}function nC(e,t){const o=kS[e];return o?0===t?Xb[o].bad:1===t?Xb[o].neutral:Xb[o].good:""}function aC(e,t,o){if(e.cfRules.length>1&&o.generateNotSupportedWarning(wS.MultipleRulesCfNotSupported),OS.includes(e.cfRules[0].type)||o.generateNotSupportedWarning(wS.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const i=t[e.cfRules[0].dxfId];i.border&&o.generateNotSupportedWarning(wS.CfFormatBorderNotSupported),i.alignment&&o.generateNotSupportedWarning(wS.CfFormatAlignmentNotSupported),i.numFmt&&o.generateNotSupportedWarning(wS.CfFormatNumFmtNotSupported)}}function lC(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function cC(e){return Math.round(uS*e*100)/100}function hC(e){return Math.round(gS*e*100)/100}function dC(e){if(e)return{style:e.style,color:{rgb:e.color}}}function uC(e,t){let o={};e.style&&(o=t.styles[e.style]);const i=function(e,t){if(e.format)return t.formats[e.format];return}(e,t),s={};if(e.border){const o=t.borders[e.border];s.left=dC(o.left),s.right=dC(o.right),s.bottom=dC(o.bottom),s.top=dC(o.top)}const r={font:{size:o?.fontSize||q,color:{rgb:o?.textColor?o.textColor:"000000"},family:2,name:"Arial"},fill:o?.fillColor?{fgColor:{rgb:o.fillColor}}:{reservedAttribute:"none"},numFmt:i?{format:i,id:0}:void 0,border:s||{},alignment:{horizontal:o.align,vertical:o.verticalAlign?DS[o.verticalAlign]:void 0,wrapText:"wrap"===o.wrapping}};return r.font.strike=!!o?.strikethrough||void 0,r.font.underline=!!o?.underline||void 0,r.font.bold=!!o?.bold||void 0,r.font.italic=!!o?.italic||void 0,r}function gC(e,t){const{id:o}=mC(t.font,e.fonts),{id:i}=mC(t.fill,e.fills),{id:s}=mC(t.border,e.borders),r=function(e,t){if(!e)return 0;let o=HS[e.format];if(!o){const{id:i}=mC(e,t);o=i+vS}return o}(t.numFmt,e.numFmts),n={fontId:o,fillId:i,borderId:s,numFmtId:r,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal,wrapText:t.alignment.wrapText}},{id:a}=mC(n,e.styles);return a}function pC(e,t,o){let i,s=e.find((e=>e.path===t));return s?(i=`rId${(s.rels.length+1).toString()}`,s.rels.push({...o,id:i})):(i="rId1",e.push({path:t,rels:[{...o,id:i}]})),i}function mC(e,t){for(let[o,i]of Object.entries(t))if(JSON.stringify(i)===JSON.stringify(e))return{id:parseInt(o,10),list:t};let o=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===o&&(t.push(e),o=t.length-1),{id:o,list:t}}const fC=[];function bC(e){const t=fC.findIndex((t=>t===e));return-1===t?(fC.push(e),fC.length):t+1}const vC=[];function SC(e){const t=vC.findIndex((t=>t===e));return-1===t?(vC.push(e),vC.length):t+1}function CC(e){return Math.round(914400*e/96)}function EC(e,t,o){let i,s,r=e;if(({xc:r,sheetName:i}=Ko(e)),i){const e=o.sheets.findIndex((e=>e.name===i));if(e<0)throw new Error("Unable to find a sheet with the name "+i);s=e}else s=Number(t);const n=Qo(r);return void 0===n.right&&(n.right=o.sheets[s].colNumber),void 0===n.bottom&&(n.bottom=o.sheets[s].rowNumber),(n.right-n.left+1)*(n.bottom-n.top+1)}function wC(e){return Math.round(96*e/914400)}function yC(e,t){let o=0;for(let i=0;i<e;i++){const e=t.cols.find((e=>i>=e.min&&i<=e.max));e?.width?o+=e.width:t.sheetFormat?.defaultColWidth?o+=t.sheetFormat.defaultColWidth:o+=pS}return o/gS}function xC(e,t){let o=0;for(let i=0;i<e;i++){const e=t.rows[i];e?.height?o+=e.height:t.sheetFormat?.defaultRowHeight?o+=t.sheetFormat.defaultRowHeight:o+=mS}return o/uS}function IC(e){let t=1;return e.figures.map((o=>function(e,t,o){const i=yC(e.anchors[0].col,o)+wC(e.anchors[0].colOffset),s=yC(e.anchors[1].col,o)+wC(e.anchors[1].colOffset),r=xC(e.anchors[0].row,o)+wC(e.anchors[0].rowOffset),n=xC(e.anchors[1].row,o)+wC(e.anchors[1].rowOffset),a=s-i,l=n-r,c=RC(e.data);return c?{id:t,x:i,y:r,width:a,height:l,tag:"chart",data:RC(e.data)}:void 0}(o,(t++).toString(),e))).filter(He)}function RC(e){const t=void 0!==e.dataSets[0].label,o=e.labelRange?TC(e.labelRange,t):void 0;let i=e.dataSets.map((e=>TC(e.range,t)));return"pie"===e.type&&i.reverse(),{dataSets:i,dataSetsHaveTitle:t,labelRange:o,title:e.title||"",type:e.type,background:GS({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,labelsAsText:!1}}function TC(e,t){let{sheetName:o,xc:i}=Ko(e);o=o?Ee(o)+"!":"";let s=Qo(i);if(t&&void 0!==s.bottom&&void 0!==s.right){const e=s.bottom-s.top+1,t=s.right-s.left+1;1===e?s={...s,left:s.left-1}:1===t&&(s={...s,top:s.top-1})}return o+ti(s)}const AC=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),OC=new RegExp(/SUBTOTAL\(([0-9]*),/g),NC=new RegExp(Bo.source,"ig");function MC(e,t){const o=function(e){const t={};for(let o of e.rows)for(let e of o.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let i of e.rows.map((e=>e.cells)).flat())i?.formula&&(i.formula.content=void 0===i.formula.sharedIndex||i.formula.content?"="+i.formula.content:"="+FC(i.xc,o[i.formula.sharedIndex]),i.formula.content=_C(i.formula.content,t))}function _C(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(OC,((e,t)=>{const o=zS[t];return o?o+"(":e}))).replace(AC,((e,o,i,s)=>{o=Number(o)-1,s=s.replace(/\$/g,"");const r=t.externalBooks[o].sheetNames.findIndex((e=>e===i));if(-1===r)return e;const n=t.externalBooks[o].datasets.find((e=>e.sheetId===r))?.data;if(!n)return e;const a=n&&n[s];return(Number(a)?a:`"${a}"`)||e}))}function FC(e,t){const o=Rt(t.refCellXc);let i,s=t.formula.slice();do{if(i=NC.exec(s),i){const t=Rt(i[0].replace("$","")),r=Rt(e),n={colFixed:i[0].startsWith("$"),rowFixed:i[0].includes("$",1)},a={col:r.col-o.col,row:r.row-o.row},l={col:n.colFixed?t.col:t.col+a.col,row:n.rowFixed?t.row:t.row+a.row};s=s.slice(0,i.index)+Tt(l.col,l.row,n)+s.slice(i.index+i[0].length)}}while(i);return s}function DC(e,t){return e.sheets.map((o=>{MC(o,e);const i=function(e){const t=[0,0];for(let o of e.rows)t[0]=Math.max(t[0],...o.cells.map((e=>Rt(e.xc).col))),t[1]=Math.max(t[1],o.index);return t[0]=Math.max(t[0],fS),t[1]=Math.max(t[1],bS),t}(o),s=o.sheetViews[0];return{id:o.sheetName,areGridLinesVisible:!s||s.showGridLines,name:o.sheetName,colNumber:i[0],rowNumber:i[1],cells:kC(o,e,i,t),merges:o.merges,cols:LC(o,i[0]),rows:PC(o,i[1]),conditionalFormats:iC(o.cfs,e.dxfs,t),figures:IC(o),isVisible:o.isVisible,panes:s?{xSplit:s.pane.xSplit,ySplit:s.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function LC(e,t){const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:e.sheetFormat?.defaultColWidth?e.sheetFormat.defaultColWidth:pS,o[s-1]={size:(i=r,i?Math.round(i/gS*100)/100:i),isHidden:t?.hidden}}var i;return o}function PC(e,t){const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:e.sheetFormat?.defaultRowHeight?e.sheetFormat.defaultRowHeight:mS,o[s-1]={size:(i=r,i?Math.round(i/uS*100)/100:i),isHidden:t?.hidden}}var i;return o}function kC(e,t,o,i){const s={},r=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const n=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let o of e.rows)for(let e of o.cells)s[e.xc]={content:UC(e,n,r,i),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let i of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=o[0];e++){const o=Tt(e-1,i.index-1);let r=s[o];r||(r={},s[o]=r),r.style=r.style?r.style:i.styleIndex+1,r.border=r.border?r.border:t.styles[i.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[i.styleIndex].numFmtId+1}for(let i of e.cols.filter((e=>e.styleIndex)))for(let e=i.min;e<=Math.min(i.max,o[0]);e++)for(let r=1;r<=o[1];r++){const o=Tt(e-1,r-1);let n=s[o];n||(n={},s[o]=n),n.style=n.style?n.style:i.styleIndex+1,n.border=n.border?n.border:t.styles[i.styleIndex].borderId+1,n.format=n.format?n.format:t.styles[i.styleIndex].numFmtId+1}return s}function UC(e,t,o,i){let s;switch(e.type){case"sharedString":s=o[parseInt(e.value,10)];break;case"boolean":s=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":s=e.value}return s&&t[e.xc]&&(s=function(e,t,o){const i=e.display||t;e.relTarget||e.location||o.generateNotSupportedWarning(wS.BadlyFormattedHyperlink);const s=e.relTarget?e.relTarget:ze(Ko(e.location).sheetName);return Pe(i,s)}(t[e.xc],s,i)),e.formula&&(s=e.formula.content),s}const VC={fillColor:"#000000",textColor:"#ffffff",bold:!0},zC={bold:!0},BC={style:"thin",color:"#000000FF"};function HC(e,t){for(const o of t.sheets)for(const t of o.tables){const i=e.sheets.find((e=>e.name===o.sheetName));i&&t.autoFilter&&(i.filterTables||(i.filterTables=[]),i.filterTables.push({range:t.ref}))}!function(e,t){const o=jS(e.styles),i=jS(e.borders);for(let s of t.sheets)for(let t of s.tables){const r=e.sheets.find((e=>e.name===s.sheetName));if(!r)continue;const n=Jo(t.ref);for(let e=0;e<t.headerRowCount;e++)$C(VC,{...n,bottom:n.top+e},r.cells,o);for(let e=0;e<t.totalsRowCount;e++)$C(zC,{...n,top:n.bottom-e},r.cells,o);t.style?.showFirstColumn&&$C(zC,{...n,right:n.left},r.cells,o),t.style?.showLastColumn&&$C(zC,{...n,left:n.right},r.cells,o);for(let e=n.left;e<=n.right;e++)for(let o=n.top;o<=n.bottom;o++){const s=Tt(e,o),a=r.cells[s],l={left:e===n.left||t.style?.showColumnStripes?BC:void 0,right:e===n.right?BC:void 0,top:o===n.top||t.style?.showRowStripes||o>n.bottom-t.totalsRowCount?BC:void 0,bottom:o===n.bottom?BC:void 0},c=a?.border?{...i[a.border],...l}:l;let h=i.findIndex((e=>Ye(e,c)));-1===h&&(h=i.length,i.push(c)),a?a.border=h:r.cells[s]={border:h}}}e.styles=ZS(o),e.borders=ZS(i)}(e,t),function(e,t){for(let o of e){const e=t.find((e=>e.sheetName===o.name)).tables;for(let t of e){const e=t.name+"[";for(let i of fi(Jo(t.ref))){const s=Tt(i.col,i.row),r=o.cells[s];if(r&&r.content&&r.content.startsWith("=")){let o;for(;-1!==(o=r.content.indexOf(e));){let i=r.content.slice(o+e.length),n=i.indexOf("]");i.startsWith("[")&&(n=i.indexOf("]",n+1),n=i.indexOf("]",n+1)),i=i.slice(0,n);const a=WC(i,t,s);r.content=r.content.slice(0,o)+a+r.content.slice(e.length+o+n+1)}}}}}}(e.sheets,t.sheets)}function $C(e,t,o,i){for(let s=t.left;s<=t.right;s++)for(let r=t.top;r<=t.bottom;r++){const t=Tt(s,r),n=o[t],a=n?.style?{...i[n.style],...e}:e;let l=i.findIndex((e=>Ye(e,a)));-1===l&&(l=i.length,i.push(a)),n?n.style=l:o[t]={style:l}}}function WC(e,t,o){const i=e.split(","),s=Jo(t.ref),r={...s};let n=!0;if(1===i.length){const e=t.cols.findIndex((e=>e.name===i[0]));r.left=r.right=e+s.left,t.headerRowCount&&(r.top+=t.headerRowCount),t.totalsRowCount&&(r.bottom-=1)}else{switch(i[0].slice(1,i[0].length-1)){case"#All":r.top=t.headerRowCount?s.top+t.headerRowCount:s.top,r.bottom=s.bottom;break;case"#Data":r.top=t.headerRowCount?s.top+t.headerRowCount:s.top,r.bottom=t.totalsRowCount?s.bottom+1:s.bottom;break;case"#This Row":r.top=r.bottom=Rt(o).row;break;case"#Headers":r.top=r.bottom=s.top,t.headerRowCount||(n=!1);break;case"#Totals":r.top=r.bottom=s.bottom,t.totalsRowCount||(n=!1)}const e=i[1].slice(1,i[1].length-1),a=t.cols.findIndex((t=>t.name===e));r.left=r.right=a+s.left}return n?r.top!==r.bottom?ti(r):Tt(r.left,r.top):Q}function GC(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function qC(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;")}function ZC(e){return new oS(e.map((([e,t])=>`${e}="${qC(t)}"`)).join(" "))}function jC(e,t="text/xml"){const o=(new DOMParser).parseFromString(e.toString(),t),i=o.querySelector("parsererror");if(i){const t=i.innerHTML,o=parseInt(t.split(":")[0],10),s=e.toString().trim().split("\n"),r=s.slice(Math.max(o-3,0),Math.min(o+2,s.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${r}`)}return o}function YC(e,t){return KC`
1458
+ />`;static defaultProps={topOffset:0};get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.topOffset+e}px`,right:"0px",width:"15px",bottom:"0px"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}rS.props={topOffset:{type:Number,optional:!0}};const nS={ROW:Nb,COL:Tb,CELL:lf};class aS extends t.Component{static template="o-spreadsheet-Grid";static components={GridComposer:Av,GridOverlay:Gv,GridPopover:qv,HeadersOverlay:Xv,Menu:Ir,Autofill:pv,ClientTag:fv,Highlight:tS,Popover:Er,VerticalScrollBar:rS,HorizontalScrollBar:sS,FilterIconsOverlay:_v};HEADER_HEIGHT=_;HEADER_WIDTH=F;menuState;gridRef;hiddenInput;onMouseWheel;canvasPosition;hoveredCell;setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=br(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),Kv("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=Qv(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return Ui({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focus()}keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===Qi.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===Qi.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():this.env.model.dispatch("CLEAN_CLIPBOARD_HIGHLIGHT")},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),F4:()=>this.env.model.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"CTRL+O":()=>sm(this.env),"ALT+=":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),i=this.env.model.getters.getAutomaticSums(e,t,o.cell);if(this.env.model.getters.isSingleCellOrMerge(e,t)||this.env.model.getters.isEmpty(e,t)&&i.length<=1){const t=i[0]?.zone,o=t?this.env.model.getters.zoneToXC(e,i[0].zone):"",s=`=SUM(${o})`;this.props.onGridComposerCellFocused(s,{start:5,end:5+o.length})}else this.env.model.dispatch("SUM_SELECTION")},"ALT+ENTER":()=>{const e=this.env.model.getters.getActiveCell();e.link&&Xi(e.link,this.env)},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,o)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),o=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,o)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+SHIFT+E":()=>this.setHorizontalAlign("center"),"CTRL+SHIFT+L":()=>this.setHorizontalAlign("left"),"CTRL+SHIFT+R":()=>this.setHorizontalAlign("right"),"CTRL+SHIFT+V":()=>Kp(this.env),"CTRL+SHIFT+<":()=>this.clearFormatting(),"CTRL+<":()=>this.clearFormatting(),"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"CTRL+ALT+=":()=>{const e=this.env.model.getters.getActiveCols(),t=this.env.model.getters.getActiveRows(),o=1===this.env.model.getters.getSelectedZones().length,i=e.size>0&&o,s=t.size>0&&o;i&&!s?om(this.env):s&&!i&&tm(this.env)},"CTRL+ALT+-":()=>{const e=[...this.env.model.getters.getActiveCols()],t=[...this.env.model.getters.getActiveRows()];e.length>0&&0===t.length?this.env.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",elements:e}):t.length>0&&0===e.length&&this.env.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP"),"CTRL+K":()=>nm(this.env)};focus(){this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||this.hiddenInput.el?.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}get isAutofillVisible(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:F,gridOffsetY:_})}moveCanvas(e,t){const{scrollX:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getClientPositionKey(e){return`${e.id}-${e.position?.sheetId}-${e.position?.col}-${e.position?.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{ctrlKey:o,shiftKey:i}){o&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),i?this.env.model.selection.setAnchorCorner(e,t):o?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let s=e,r=t;Bb(this.env,((e,t)=>{(e!==s&&-1!=e||t!==r&&-1!=t)&&(s=-1===e?s:e,r=-1===t?r:t,this.env.model.selection.setAnchorCorner(s,r))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const o=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:o,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t}).type===Qi.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),Db(e,this.env.model.selection),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];return o?(e.preventDefault(),e.stopPropagation(),void o()):void 0}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:o,top:i}=t;let s="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(o)?s="COL":this.env.model.getters.getActiveRows().has(i)&&(s="ROW");const{x:r,y:n,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(s,r+a,n+l)}onCellRightClicked(e,t,{x:o,y:i}){const s=this.env.model.getters.getSelectedZones();let r="CELL";hi(e,t,s[s.length-1])?this.env.model.getters.getActiveCols().has(e)?r="COL":this.env.model.getters.getActiveRows().has(t)&&(r="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(r,o,i)}toggleContextMenu(e,t,o){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:o},this.menuState.menuItems=nS[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const o=t.clipboardData;if(!o)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?Bp(this.env):this.env.model.dispatch("COPY");const i=this.env.model.getters.getClipboardContent();for(const e in i)o.setData(e,i[e]);t.preventDefault()}async paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(Ji.PlainText)>-1){const e=t.getData(Ji.PlainText),o=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?Gp(this.env,o):qp(this.env,o,e),this.env.model.getters.isCutOperation()&&await this.env.clipboard.write({[Ji.PlainText]:""})}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(r("Copy/Paste is not supported in this browser."))}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setHorizontalAlign(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{align:e}})}closeMenu(){this.menuState.isOpen=!1,this.focus()}}aS.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class lS{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}}const cS=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],hS="000000",dS={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},uS={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",table:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",revision:"http://schemas.microsoft.com/office/spreadsheetml/2014/revision",revision3:"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3",markupCompatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006"},gS="http://schemas.openxmlformats.org/drawingml/2006/main",pS="http://schemas.openxmlformats.org/drawingml/2006/chart",mS={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",themes:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",pivot:"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",externalLink:"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"},fS={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",sharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",drawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"},bS="http://schemas.openxmlformats.org/officeDocument/2006/relationships",vS=.75,SS=.143,CS=8.43,ES=12.75,wS=30,yS=100,xS=164,IS={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},RS=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"],TS="[Content_Types].xml";var AS;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(AS||(AS={}));class OS{_parsingWarnings=new Set;_conversionWarnings=new Set;addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,o){let i=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;o&&(i+=`Only ${o.join(", ")} are currently supported.`),this._conversionWarnings.has(i)||this._conversionWarnings.add(i)}}const NS=["thin"],MS=["general","left","center","right"],_S=["top","center","bottom"],FS=["Arial"],DS=["solid"],LS=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],PS={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},kS={dashDot:"thin",dashDotDot:"thin",dashed:"dashed",dotted:"dotted",double:"thin",hair:"thin",medium:"medium",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thick",thin:"thin"},US={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"},VS={top:"top",center:"middle",bottom:"bottom",justify:"middle",distributed:"middle"},zS={top:"top",middle:"center",bottom:"bottom"};const BS={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},HS={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},$S={NoIcons:void 0,"3Arrows":"arrows","3ArrowsGray":"arrows","3Symbols":"smiley","3Symbols2":"smiley","3Signs":"dots","3Flags":"dots","3TrafficLights1":"dots","3TrafficLights2":"dots","4Arrows":"arrows","4ArrowsGray":"arrows","4RedToBlack":"dots","4Rating":"smiley","4TrafficLights":"dots","5Arrows":"arrows","5ArrowsGray":"arrows","5Rating":"smiley","5Quarters":"dots","3Stars":"smiley","3Triangles":"arrows","5Boxes":"dots"},WS={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},GS={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},qS={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV",8:"STDEVP",9:"SUM",10:"VAR",11:"VARP",101:"AVERAGE",102:"COUNT",103:"COUNTA",104:"MAX",105:"MIN",106:"PRODUCT",107:"STDEV",108:"STDEVP",109:"SUM",110:"VAR",111:"VARP"},ZS={0:"",1:"0",2:"0.00",3:"#,#00",4:"#,##0.00",9:"0%",10:"0.00%",11:void 0,12:void 0,13:void 0,14:"m/d/yyyy",15:"m/d/yyyy",16:"m/d/yyyy",17:"m/d/yyyy",18:"hh:mm:ss a",19:"hh:mm:ss a",20:"hhhh:mm:ss",21:"hhhh:mm:ss",22:"m/d/yy h:mm",37:void 0,38:void 0,39:void 0,40:void 0,45:"hhhh:mm:ss",46:"hhhh:mm:ss",47:"hhhh:mm:ss",48:void 0,49:void 0},jS={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},YS={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF",16:"800000",17:"008000",18:"000080",19:"808000",20:"800080",21:"008080",22:"C0C0C0",23:"808080",24:"9999FF",25:"993366",26:"FFFFCC",27:"CCFFFF",28:"660066",29:"FF8080",30:"0066CC",31:"CCCCFF",32:"000080",33:"FF00FF",34:"FFFF00",35:"00FFFF",36:"800080",37:"800000",38:"008080",39:"0000FF",40:"00CCFF",41:"CCFFFF",42:"CCFFCC",43:"FFFF99",44:"99CCFF",45:"FF99CC",46:"CC99FF",47:"FFCC99",48:"3366FF",49:"33CCCC",50:"99CC00",51:"FFCC00",52:"FF9900",53:"FF6600",54:"666699",55:"969696",56:"003366",57:"339966",58:"003300",59:"333300",60:"993300",61:"993366",62:"333399",63:"333333",64:"000000",65:"FFFFFF"},XS={"image/avif":"avif","image/bmp":"bmp","image/gif":"gif","image/vnd.microsoft.icon":"ico","image/jpeg":"jpeg","image/png":"png","image/tiff":"tiff","image/webp":"webp"},KS={avif:"image/avif",bmp:"image/bmp",gif:"image/gif",ico:"image/vnd.microsoft.icon",jpeg:"image/jpeg",png:"image/png",tiff:"image/tiff",webp:"image/webp",jpg:"image/jpeg"};function QS(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=hS;else{if(!e.indexed)return;t=YS[e.indexed]}var o;return t=6===(o=t).length?"#"+o+"FF":"#"+o.slice(2)+o.slice(0,2),e.tint&&(t=function(e,t){const o=ft(e),i=vt(o);t<0&&(i.l=i.l*(1+t));t>0&&(i.l=i.l*(1-t)+(100-100*(1-t)));return mt(bt(i))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function JS(e,t){const o=e.split("/"),i=t.split("/");let s="",r=0;for(let e=0;e<o.length-1;e++)o[e]===i[e]?r++:s+="../";return s+=i.slice(r).join("/"),s}function eC(e,t=0){const o={};for(let i=0;i<e.length;i++)e[i]&&(o[i+t]=e[i]);return o}function tC(e){const t=[];for(let o of Object.keys(e).map(Number))t[o]=e[o];return t}function oC(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const iC=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function sC(e,t,o){if(0===e)return;let i=ZS[e]||t.find((t=>t.id===e))?.format;if(i)try{let e=i.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=e.match(/"/g)?.length||0;if(t/2+(e.match(/\[/g)?.length||0)>1)throw new Error("Multiple escaped blocks in format");if(e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),e=e.replace(/\\./g,(e=>e[1])),function(e){return iC.test(e)}(e)&&(e=function(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,"mmm"),e=e.replace(/am\/pm|a\/m/g,"a"),e=e.replace(/hhhh/g,"hh"),e=e.replace(/\bh\b/g,"hh"),e}(e)),function(e){try{return vo(0,{format:e,locale:oo}),!0}catch(e){return!1}}(e))return e}catch(e){}o.generateNotSupportedWarning(AS.NumFmtIdNotSupported,i||`nmFmtId ${e}`)}function rC(e,t){const o=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(AS.DiagonalBorderNotSupported)}(e,t);const o={top:nC(e.top,t),bottom:nC(e.bottom,t),left:nC(e.left,t),right:nC(e.right,t)};return Object.keys(o).forEach((e=>void 0===o[e]&&delete o[e])),o}));return eC(o,1)}function nC(e,t){if(!e)return;!function(e,t){NS.includes(e.style)||t.generateNotSupportedWarning(AS.BorderStyleNotSupported,e.style,NS)}(e,t);const o=kS[e.style];return o?{style:o,color:QS(e.color)}:void 0}function aC(e,t){return eC(e.styles.map((o=>lC({fontStyle:e.fonts[o.fontId],fillStyle:e.fills[o.fillId],alignment:o.alignment},t))),1)}function lC(e,t){return function(e,t,o){e&&e.name&&!FS.includes(e.name)&&o.generateNotSupportedWarning(AS.FontNotSupported,e.name,FS);t&&t.patternType&&!DS.includes(t.patternType)&&o.generateNotSupportedWarning(AS.FillStyleNotSupported,t.patternType,DS)}(e?.fontStyle,e?.fillStyle,t),function(e,t){e&&!MS.includes(e)&&t.generateNotSupportedWarning(AS.HorizontalAlignmentNotSupported,e,MS)}(e?.alignment?.horizontal,t),function(e,t){e&&!_S.includes(e)&&t.generateNotSupportedWarning(AS.VerticalAlignmentNotSupported,e,_S)}(e?.alignment?.vertical,t),{bold:e.fontStyle?.bold,italic:e.fontStyle?.italic,strikethrough:e.fontStyle?.strike,underline:e.fontStyle?.underline,verticalAlign:e.alignment?.vertical?VS[e.alignment.vertical]:void 0,align:e.alignment?.horizontal?US[e.alignment.horizontal]:void 0,fillColor:"solid"===e.fillStyle?.patternType?QS(e.fillStyle?.fgColor):QS(e.fillStyle?.bgColor),textColor:QS(e.fontStyle?.color),fontSize:e.fontStyle?.size,wrapping:e.alignment?.wrapText?"wrap":"overflow"}}function cC(e,t){const o=[];for(let i of e.styles){const s=sC(i.numFmtId,e.numFmts,t);s&&(o[i.numFmtId]=s)}return eC(o,1)}function hC(e,t,o){const i=[];let s=1;for(let n of e){if(0===n.cfRules.length)continue;pC(n,t,o);const e=n.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=dC(s++,n);t&&i.push(t);continue;case"iconSet":const c=uC(s++,n,o);c&&i.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=BS[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=BS[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(r=e.operator).slice(0,1).toUpperCase()+r.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&i.push({id:(s++).toString(),ranges:n.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:lC({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},o)}})}}var r;return i}function dC(e,t){const o=t.cfRules[0].colorScale;if(!o||o.cfvos.length!==o.colors.length||o.cfvos.length<2||o.cfvos.length>3)return;const i=[];for(let e=0;e<o.cfvos.length;e++)i.push({color:(s=QS(o.colors[e])||"#FFFFFF",9===s.length&&(s=s.slice(0,7)),parseInt(s.replace("#",""),16)),type:HS[o.cfvos[e].type],value:o.cfvos[e].value});var s;const r=i[0],n=2===i.length?i[1]:i[2],a=3===i.length?i[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:r,midpoint:a,maximum:n}}}function uC(e,t,o){const i=t.cfRules[0].iconSet;if(!i)return;let s=i.cfvos,r=i.cfIcons;if(s.length<3||r&&r.length<3)return;s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]),r&&r.length>3&&(r=[r[0],r[Math.floor(r.length/2)],r[r.length-1]]);const n=[];for(let e=1;e<=2;e++){const t=HS[s[e].type];if("value"===t)return;n.push({value:s[e].value||"",operator:s[e].gte?"ge":"gt",type:t})}let a={lower:r?gC(r[0].iconSet,r[0].iconId):gC(i.iconSet,0),middle:r?gC(r[1].iconSet,r[1].iconId):gC(i.iconSet,1),upper:r?gC(r[2].iconSet,r[2].iconId):gC(i.iconSet,2)};i.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(o.generateNotSupportedWarning(AS.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=ov.dots.good;break;case"middle":a[e]=ov.dots.neutral;break;case"lower":a[e]=ov.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:n[1],lowerInflectionPoint:n[0]}}}function gC(e,t){const o=$S[e];return o?0===t?ov[o].bad:1===t?ov[o].neutral:ov[o].good:""}function pC(e,t,o){if(e.cfRules.length>1&&o.generateNotSupportedWarning(AS.MultipleRulesCfNotSupported),LS.includes(e.cfRules[0].type)||o.generateNotSupportedWarning(AS.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const i=t[e.cfRules[0].dxfId];i.border&&o.generateNotSupportedWarning(AS.CfFormatBorderNotSupported),i.alignment&&o.generateNotSupportedWarning(AS.CfFormatAlignmentNotSupported),i.numFmt&&o.generateNotSupportedWarning(AS.CfFormatNumFmtNotSupported)}}function mC(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function fC(e){return Math.round(vS*e*100)/100}function bC(e){return Math.round(SS*e*100)/100}function vC(e){if(e)return{style:e.style,color:{rgb:e.color}}}function SC(e,t){let o={};e.style&&(o=t.styles[e.style]);const i=function(e,t){if(e.format)return t.formats[e.format];return}(e,t),s={};if(e.border){const o=t.borders[e.border];s.left=vC(o.left),s.right=vC(o.right),s.bottom=vC(o.bottom),s.top=vC(o.top)}const r={font:{size:o?.fontSize||q,color:{rgb:o?.textColor?o.textColor:"000000"},family:2,name:"Arial"},fill:o?.fillColor?{fgColor:{rgb:o.fillColor}}:{reservedAttribute:"none"},numFmt:i?{format:i,id:0}:void 0,border:s||{},alignment:{horizontal:o.align,vertical:o.verticalAlign?zS[o.verticalAlign]:void 0,wrapText:"wrap"===o.wrapping}};return r.font.strike=!!o?.strikethrough||void 0,r.font.underline=!!o?.underline||void 0,r.font.bold=!!o?.bold||void 0,r.font.italic=!!o?.italic||void 0,r}function CC(e,t){const{id:o}=wC(t.font,e.fonts),{id:i}=wC(t.fill,e.fills),{id:s}=wC(t.border,e.borders),r=function(e,t){if(!e)return 0;let o=jS[e.format];if(!o){const{id:i}=wC(e,t);o=i+xS}return o}(t.numFmt,e.numFmts),n={fontId:o,fillId:i,borderId:s,numFmtId:r,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal,wrapText:t.alignment.wrapText}},{id:a}=wC(n,e.styles);return a}function EC(e,t,o){let i,s=e.find((e=>e.path===t));return s?(i=`rId${(s.rels.length+1).toString()}`,s.rels.push({...o,id:i})):(i="rId1",e.push({path:t,rels:[{...o,id:i}]})),i}function wC(e,t){for(let[o,i]of Object.entries(t))if(JSON.stringify(i)===JSON.stringify(e))return{id:parseInt(o,10),list:t};let o=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===o&&(t.push(e),o=t.length-1),{id:o,list:t}}const yC=[];function xC(e){const t=yC.findIndex((t=>t===e));return-1===t?(yC.push(e),yC.length):t+1}const IC=[];function RC(e){const t=IC.findIndex((t=>t===e));return-1===t?(IC.push(e),IC.length):t+1}function TC(e){return Math.round(914400*e/96)}function AC(e,t,o){let i,s,r=e;if(({xc:r,sheetName:i}=Ko(e)),i){const e=o.sheets.findIndex((e=>e.name===i));if(e<0)throw new Error("Unable to find a sheet with the name "+i);s=e}else s=Number(t);const n=Qo(r);return void 0===n.right&&(n.right=o.sheets[s].colNumber),void 0===n.bottom&&(n.bottom=o.sheets[s].rowNumber),(n.right-n.left+1)*(n.bottom-n.top+1)}function OC(e){return Math.round(96*e/914400)}function NC(e,t){let o=0;for(let i=0;i<e;i++){const e=t.cols.find((e=>i>=e.min&&i<=e.max));e?.width?o+=e.width:t.sheetFormat?.defaultColWidth?o+=t.sheetFormat.defaultColWidth:o+=CS}return o/SS}function MC(e,t){let o=0;for(let i=0;i<e;i++){const e=t.rows[i];e?.height?o+=e.height:t.sheetFormat?.defaultRowHeight?o+=t.sheetFormat.defaultRowHeight:o+=ES}return o/vS}function _C(e){let t=1;return e.figures.map((o=>function(e,t,o){const i=NC(e.anchors[0].col,o)+OC(e.anchors[0].colOffset),s=NC(e.anchors[1].col,o)+OC(e.anchors[1].colOffset),r=MC(e.anchors[0].row,o)+OC(e.anchors[0].rowOffset),n=MC(e.anchors[1].row,o)+OC(e.anchors[1].rowOffset),a={id:t,x:i,y:r};if("dataSets"in e.data)return{...a,width:s-i,height:n-r,tag:"chart",data:FC(e.data)};if(function(e){return"imageSrc"in e}(e.data))return{...a,width:OC(e.data.size.cx),height:OC(e.data.size.cy),tag:"image",data:{path:e.data.imageSrc,mimetype:e.data.mimetype}};return}(o,(t++).toString(),e))).filter(He)}function FC(e){const t=void 0!==e.dataSets[0].label,o=e.labelRange?DC(e.labelRange,t):void 0;let i=e.dataSets.map((e=>DC(e.range,t)));return"pie"===e.type&&i.reverse(),{dataSets:i,dataSetsHaveTitle:t,labelRange:o,title:e.title||"",type:e.type,background:QS({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,labelsAsText:!1}}function DC(e,t){let{sheetName:o,xc:i}=Ko(e);o=o?Ee(o)+"!":"";let s=Qo(i);if(t&&void 0!==s.bottom&&void 0!==s.right){const e=s.bottom-s.top+1,t=s.right-s.left+1;1===e?s={...s,left:s.left-1}:1===t&&(s={...s,top:s.top-1})}return o+ti(s)}const LC=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),PC=new RegExp(/SUBTOTAL\(([0-9]*),/g),kC=new RegExp(Bo.source,"ig");function UC(e,t){const o=function(e){const t={};for(let o of e.rows)for(let e of o.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let i of e.rows.map((e=>e.cells)).flat())i?.formula&&(i.formula.content=void 0===i.formula.sharedIndex||i.formula.content?"="+i.formula.content:"="+zC(i.xc,o[i.formula.sharedIndex]),i.formula.content=VC(i.formula.content,t))}function VC(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(PC,((e,t)=>{const o=qS[t];return o?o+"(":e}))).replace(LC,((e,o,i,s)=>{o=Number(o)-1,s=s.replace(/\$/g,"");const r=t.externalBooks[o].sheetNames.findIndex((e=>e===i));if(-1===r)return e;const n=t.externalBooks[o].datasets.find((e=>e.sheetId===r))?.data;if(!n)return e;const a=n&&n[s];return(Number(a)?a:`"${a}"`)||e}))}function zC(e,t){const o=Rt(t.refCellXc);let i,s=t.formula.slice();do{if(i=kC.exec(s),i){const t=Rt(i[0].replace("$","")),r=Rt(e),n={colFixed:i[0].startsWith("$"),rowFixed:i[0].includes("$",1)},a={col:r.col-o.col,row:r.row-o.row},l={col:n.colFixed?t.col:t.col+a.col,row:n.rowFixed?t.row:t.row+a.row};s=s.slice(0,i.index)+Tt(l.col,l.row,n)+s.slice(i.index+i[0].length)}}while(i);return s}function BC(e,t){return e.sheets.map((o=>{UC(o,e);const i=function(e){const t=[0,0];for(let o of e.rows)t[0]=Math.max(t[0],...o.cells.map((e=>Rt(e.xc).col))),t[1]=Math.max(t[1],o.index);return t[0]=Math.max(t[0],wS),t[1]=Math.max(t[1],yS),t}(o),s=o.sheetViews[0];return{id:o.sheetName,areGridLinesVisible:!s||s.showGridLines,name:o.sheetName,colNumber:i[0],rowNumber:i[1],cells:WC(o,e,i,t),merges:o.merges,cols:HC(o,i[0]),rows:$C(o,i[1]),conditionalFormats:hC(o.cfs,e.dxfs,t),figures:_C(o),isVisible:o.isVisible,panes:s?{xSplit:s.pane.xSplit,ySplit:s.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function HC(e,t){const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:e.sheetFormat?.defaultColWidth?e.sheetFormat.defaultColWidth:CS,o[s-1]={size:(i=r,i?Math.round(i/SS*100)/100:i),isHidden:t?.hidden}}var i;return o}function $C(e,t){const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:e.sheetFormat?.defaultRowHeight?e.sheetFormat.defaultRowHeight:ES,o[s-1]={size:(i=r,i?Math.round(i/vS*100)/100:i),isHidden:t?.hidden}}var i;return o}function WC(e,t,o,i){const s={},r=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const n=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let o of e.rows)for(let e of o.cells)s[e.xc]={content:GC(e,n,r,i),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let i of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=o[0];e++){const o=Tt(e-1,i.index-1);let r=s[o];r||(r={},s[o]=r),r.style=r.style?r.style:i.styleIndex+1,r.border=r.border?r.border:t.styles[i.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[i.styleIndex].numFmtId+1}for(let i of e.cols.filter((e=>e.styleIndex)))for(let e=i.min;e<=Math.min(i.max,o[0]);e++)for(let r=1;r<=o[1];r++){const o=Tt(e-1,r-1);let n=s[o];n||(n={},s[o]=n),n.style=n.style?n.style:i.styleIndex+1,n.border=n.border?n.border:t.styles[i.styleIndex].borderId+1,n.format=n.format?n.format:t.styles[i.styleIndex].numFmtId+1}return s}function GC(e,t,o,i){let s;switch(e.type){case"sharedString":s=o[parseInt(e.value,10)];break;case"boolean":s=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":s=e.value}return s&&t[e.xc]&&(s=function(e,t,o){const i=e.display||t;e.relTarget||e.location||o.generateNotSupportedWarning(AS.BadlyFormattedHyperlink);const s=e.relTarget?e.relTarget:ze(Ko(e.location).sheetName);return Pe(i,s)}(t[e.xc],s,i)),e.formula&&(s=e.formula.content),s}const qC={fillColor:"#000000",textColor:"#ffffff",bold:!0},ZC={bold:!0},jC={style:"thin",color:"#000000FF"};function YC(e,t){for(const o of t.sheets)for(const t of o.tables){const i=e.sheets.find((e=>e.name===o.sheetName));i&&t.autoFilter&&(i.filterTables||(i.filterTables=[]),i.filterTables.push({range:t.ref}))}!function(e,t){const o=tC(e.styles),i=tC(e.borders);for(let s of t.sheets)for(let t of s.tables){const r=e.sheets.find((e=>e.name===s.sheetName));if(!r)continue;const n=Jo(t.ref);for(let e=0;e<t.headerRowCount;e++)XC(qC,{...n,bottom:n.top+e},r.cells,o);for(let e=0;e<t.totalsRowCount;e++)XC(ZC,{...n,top:n.bottom-e},r.cells,o);t.style?.showFirstColumn&&XC(ZC,{...n,right:n.left},r.cells,o),t.style?.showLastColumn&&XC(ZC,{...n,left:n.right},r.cells,o);for(let e=n.left;e<=n.right;e++)for(let o=n.top;o<=n.bottom;o++){const s=Tt(e,o),a=r.cells[s],l={left:e===n.left||t.style?.showColumnStripes?jC:void 0,right:e===n.right?jC:void 0,top:o===n.top||t.style?.showRowStripes||o>n.bottom-t.totalsRowCount?jC:void 0,bottom:o===n.bottom?jC:void 0},c=a?.border?{...i[a.border],...l}:l;let h=i.findIndex((e=>Ye(e,c)));-1===h&&(h=i.length,i.push(c)),a?a.border=h:r.cells[s]={border:h}}}e.styles=eC(o),e.borders=eC(i)}(e,t),function(e,t){for(let o of e){const e=t.find((e=>e.sheetName===o.name)).tables;for(let t of e){const e=t.name+"[";for(let i of fi(Jo(t.ref))){const s=Tt(i.col,i.row),r=o.cells[s];if(r&&r.content&&r.content.startsWith("=")){let o;for(;-1!==(o=r.content.indexOf(e));){let i=r.content.slice(o+e.length),n=i.indexOf("]");i.startsWith("[")&&(n=i.indexOf("]",n+1),n=i.indexOf("]",n+1)),i=i.slice(0,n);const a=KC(i,t,s);r.content=r.content.slice(0,o)+a+r.content.slice(e.length+o+n+1)}}}}}}(e.sheets,t.sheets)}function XC(e,t,o,i){for(let s=t.left;s<=t.right;s++)for(let r=t.top;r<=t.bottom;r++){const t=Tt(s,r),n=o[t],a=n?.style?{...i[n.style],...e}:e;let l=i.findIndex((e=>Ye(e,a)));-1===l&&(l=i.length,i.push(a)),n?n.style=l:o[t]={style:l}}}function KC(e,t,o){const i=e.split(","),s=Jo(t.ref),r={...s};let n=!0;if(1===i.length){const e=t.cols.findIndex((e=>e.name===i[0]));r.left=r.right=e+s.left,t.headerRowCount&&(r.top+=t.headerRowCount),t.totalsRowCount&&(r.bottom-=1)}else{switch(i[0].slice(1,i[0].length-1)){case"#All":r.top=t.headerRowCount?s.top+t.headerRowCount:s.top,r.bottom=s.bottom;break;case"#Data":r.top=t.headerRowCount?s.top+t.headerRowCount:s.top,r.bottom=t.totalsRowCount?s.bottom+1:s.bottom;break;case"#This Row":r.top=r.bottom=Rt(o).row;break;case"#Headers":r.top=r.bottom=s.top,t.headerRowCount||(n=!1);break;case"#Totals":r.top=r.bottom=s.bottom,t.totalsRowCount||(n=!1)}const e=i[1].slice(1,i[1].length-1),a=t.cols.findIndex((t=>t.name===e));r.left=r.right=a+s.left}return n?r.top!==r.bottom?ti(r):Tt(r.left,r.top):Q}function QC(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function JC(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;")}function eE(e){return new lS(e.map((([e,t])=>`${e}="${JC(t)}"`)).join(" "))}function tE(e,t="text/xml"){const o=(new DOMParser).parseFromString(e.toString(),t),i=o.querySelector("parsererror");if(i){const t=i.innerHTML,o=parseInt(t.split(":")[0],10),s=e.toString().trim().split("\n"),r=s.slice(Math.max(o-3,0),Math.min(o+2,s.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${r}`)}return o}function oE(e,t){return sE`
1463
1459
  <Override ContentType="${t}" PartName="${e}" />
1464
- `}function XC(e){return new oS(e.join("\n"))}function KC(e,...t){let o=[e[0]];for(let i=0;i<t.length;i++){const s=t[i]instanceof oS?t[i]:qC(t[i]);o.push(s+e[i+1])}return new oS(Ge(o))}function QC(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function JC(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class eE{value;constructor(e){this.value=e}asString(){return YS(String(this.value))}asBool(){return"true"===this.value||"false"!==this.value&&Boolean(Number(this.value))}asNum(){return Number(this.value)}}class tE{rootFile;xlsxFileStructure;warningManager;relationships;currentFile=void 0;areNamespaceIgnored;constructor(e,t,o){this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=o,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(He)}mapOnElements(e,t){const o=[],i=this.currentFile;let s;if(e.children){const t=this.querySelector(e.parent,e.query)?.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=i,o}catchErrorOnElement(e,t){const o=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([o,e.message].join("\n"))}extractAttr(e,t,o){const i=e.attributes[t];i||this.handleMissingValue(e,`attribute "${t}"`,o);const s=i?.value?i.value:o?.default;return void 0===s?void 0:new eE(s)}extractTextContent(e,t){if(void 0!==t?.default&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===e?.attributes["xml:space"]?.value;let i=e?.textContent;return e&&null!==i||this.handleMissingValue(e,"text content",t),i&&(i=o?i:i.trim()),i?YS(i):t?.default}extractChildAttr(e,t,o,i){let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,i);const r=s?this.extractAttr(s,o,i)?.asString():i?.default;return void 0!==r?new eE(r):void 0}extractChildTextContent(e,t,o){if(void 0!==o?.default&&"string"!=typeof o.default)throw new Error("extractTextContent default value should be a string");let i=this.querySelector(e,t);return i||this.handleMissingValue(e,`child <${t}>`,o),i?this.extractTextContent(i,o):o?.default}handleMissingValue(e,t,o){if(o?.required){if(!o?.default)throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${o.default}`)}}extractColor(e,t,o){if(!e)return o?{rgb:o}:void 0;const i=this.extractAttr(e,"theme")?.asString();let s;if(void 0!==i){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");s=this.getThemeColor(i,t.clrScheme)}else s=this.extractAttr(e,"rgb")?.asString();return{rgb:s,auto:this.extractAttr(e,"auto")?.asBool(),indexed:this.extractAttr(e,"indexed")?.asNum(),tint:this.extractAttr(e,"tint")?.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");let t=e.target;t=t.replace("../",""),t=t.replace("./","");const o=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!o||!o.file)throw new Error("Cannot find target file");return o}querySelector(e,t){return t=this.areNamespaceIgnored?QC(t):JC(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?QC(t):JC(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}}class oE extends tE{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:sS}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:sS}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class iE extends tE{theme;constructor(e,t,o,i){super(e,t,o),this.theme=i}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>({sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:this.extractAttr(e,"pivot")?.asBool(),cfRules:this.extractCFRules(e,this.theme)})));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>({sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:this.extractAttr(e,"xm:pivot")?.asBool(),cfRules:this.extractCFRules(e,this.theme)})))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{const o=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===o)throw new Error("Databars conditional formats are not supported.");return{type:o,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:this.extractAttr(e,"dxfId")?.asNum(),stopIfTrue:this.extractAttr(e,"stopIfTrue")?.asBool(),aboveAverage:this.extractAttr(e,"aboveAverage")?.asBool(),percent:this.extractAttr(e,"percent")?.asBool(),bottom:this.extractAttr(e,"bottom")?.asBool(),operator:this.extractAttr(e,"operator")?.asString(),text:this.extractAttr(e,"text")?.asString(),timePeriod:this.extractAttr(e,"timePeriod")?.asString(),rank:this.extractAttr(e,"rank")?.asNum(),stdDev:this.extractAttr(e,"stdDev")?.asNum(),equalAverage:this.extractAttr(e,"equalAverage")?.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const o=this.querySelector(e,"colorScale");if(o)return{colors:this.mapOnElements({parent:o,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(o)}}extractCfIconSet(e){const t=this.querySelector(e,"iconSet, x14:iconSet");if(t)return{iconSet:this.extractAttr(t,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(t,"showValue",{default:!0}).asBool(),percent:this.extractAttr(t,"percent",{default:!0}).asBool(),reverse:this.extractAttr(t,"reverse")?.asBool(),custom:this.extractAttr(t,"custom")?.asBool(),cfvos:this.extractCFVos(t),cfIcons:this.extractCfIcons(t)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>({type:this.extractAttr(e,"type",{required:!0}).asString(),gte:this.extractAttr(e,"gte",{default:!0})?.asBool(),value:e.attributes.val?this.extractAttr(e,"val")?.asString():this.extractChildTextContent(e,"f, xm:f")})))}}class sE extends tE{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!VS[t])throw new Error(`Unsupported chart type ${t}`);const o=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),i=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:o,type:VS[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),labelRange:this.extractChildTextContent(e,"c:ser c:cat c:f"),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:US[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===i,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:tx c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=QC(e.tagName);if(iS.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class rE extends tE{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==QC(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const o=this.querySelector(t,e);if(!o)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(o,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(o,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(o,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(o,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),o=this.getTargetXmlFile(this.relationships[t]),i=new sE(o,this.xlsxFileStructure,this.warningManager).extractChart();if(!i)throw new Error("Unable to extract chart definition");return i}}class nE extends tE{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class aE extends tE{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:this.extractAttr(e,"name")?.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)})))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>({name:this.extractAttr(e,"name")?.asString(),showFirstColumn:this.extractAttr(e,"showFirstColumn")?.asBool(),showLastColumn:this.extractAttr(e,"showLastColumn")?.asBool(),showRowStripes:this.extractAttr(e,"showRowStripes")?.asBool(),showColumnStripes:this.extractAttr(e,"showColumnStripes")?.asBool()})))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class lE extends tE{theme;constructor(e,t,o,i){super(e,t,o),this.theme=i}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=qS(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=qS(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,o=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!o)throw new Error("Cannot find corresponding workbook sheet");return o}extractConditionalFormats(){return new iE(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{const t=this.extractAttr(e,"r:id",{required:!0})?.asString(),o=this.getTargetXmlFile(this.relationships[t]);return new rE(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{const t=this.extractAttr(e,"r:id",{required:!0})?.asString(),o=this.getTargetXmlFile(this.relationships[t]);return new aE(o,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new nE(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:pS.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:mS.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>({width:this.extractAttr(e,"width")?.asNum(),customWidth:this.extractAttr(e,"customWidth")?.asBool(),bestFit:this.extractAttr(e,"bestFit")?.asBool(),hidden:this.extractAttr(e,"hidden")?.asBool(),min:this.extractAttr(e,"min",{required:!0})?.asNum(),max:this.extractAttr(e,"max",{required:!0})?.asNum(),styleIndex:this.extractAttr(e,"style")?.asNum()})))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>({index:this.extractAttr(e,"r",{required:!0})?.asNum(),cells:this.extractCells(e),height:this.extractAttr(e,"ht")?.asNum(),customHeight:this.extractAttr(e,"customHeight")?.asBool(),hidden:this.extractAttr(e,"hidden")?.asBool(),styleIndex:this.extractAttr(e,"s")?.asNum()})))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>({xc:this.extractAttr(e,"r",{required:!0})?.asString(),styleIndex:this.extractAttr(e,"s")?.asNum(),type:NS[this.extractAttr(e,"t",{default:"n"})?.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)})))}extractCellFormula(e){const t=this.querySelector(e,"f");if(t)return{content:this.extractTextContent(t),sharedIndex:this.extractAttr(t,"si")?.asNum(),ref:this.extractAttr(t,"ref")?.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{const t=this.extractAttr(e,"r:id")?.asString();return{xc:this.extractAttr(e,"ref",{required:!0})?.asString(),location:this.extractAttr(e,"location")?.asString(),display:this.extractAttr(e,"display")?.asString(),relTarget:t?this.relationships[t].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),o={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),i=this.extractTextContent(e,{required:!0});o[t]=i}const i=[];for(let e=0;e<Object.keys(o).length;e++)o[e]?i.push(o[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),i.push(""));return i}}class cE extends tE{theme;constructor(e,t,o){super(e.styles,e,t),this.theme=o}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){const t=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),o=this.extractChildAttr(e,"sz","val",{default:q.toString()}).asNum(),i=this.extractColor(this.querySelector(e,"color"),this.theme),s=this.querySelector(e,"i")||void 0,r=s&&"0"!==s.attributes.val?.value,n=this.querySelector(e,"b")||void 0,a=n&&"0"!==n.attributes.val?.value,l=this.querySelector(e,"strike")||void 0,c=l&&"0"!==l.attributes.val?.value,h=this.querySelector(e,"u")||void 0;return{name:t,size:o,color:i,italic:r,bold:a,underline:h&&"none"!==h.attributes.val?.value,strike:c}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){const t=e.children[0];return"patternFill"===t.tagName?{patternType:t.attributes.patternType?.value,bgColor:this.extractColor(this.querySelector(t,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(t,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(t,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){const t={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return t.diagonal&&(t.diagonalUp=this.extractAttr(e,"diagonalUp")?.asBool(),t.diagonalDown=this.extractAttr(e,"diagonalDown")?.asBool()),t}extractSingleBorder(e,t,o){const i=this.querySelector(e,t);if(i&&i.attributes.style)return{style:this.extractAttr(i,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(i.children[0],o,"000000")}}extractAlignment(e){return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"bottom"}).asString(),textRotation:this.extractAttr(e,"textRotation")?.asNum(),wrapText:this.extractAttr(e,"wrapText")?.asBool(),indent:this.extractAttr(e,"indent")?.asNum(),relativeIndent:this.extractAttr(e,"relativeIndent")?.asNum(),justifyLastLine:this.extractAttr(e,"justifyLastLine")?.asBool(),shrinkToFit:this.extractAttr(e,"shrinkToFit")?.asBool(),readingOrder:this.extractAttr(e,"readingOrder")?.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),o=this.querySelector(e,"fill"),i=this.querySelector(e,"border"),s=this.querySelector(e,"numFmt"),r=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:o?this.extractFill(o):void 0,numFmt:s?this.extractNumFormats(s):void 0,alignment:r?this.extractAlignment(r):void 0,border:i?this.extractBorder(i):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class hE extends tE{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),o={};for(let e of t)o[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:o}}))}}function dE(e,t){const o=function(e,t){const o=t[ES],i=o.querySelectorAll(`Override[ContentType="${e}"]`),s=[];for(let e of i){const t=e?.attributes.PartName.value;s.push(t.substring(1))}return s}(e,t);return function(e,t){const o=[];for(let i of e){const e=uE(i,t);o.push({file:{fileName:i,xml:t[i]},rels:e?{fileName:e,xml:t[e]}:void 0})}return o}(o,t)}function uE(e,t){if(e===ES)return"_rels/.rels";let o="";const i=e.split("/");for(let e=0;e<i.length-1;e++)o+=i[e]+"/";return o+="_rels/",o+=i[i.length-1]+".rels",t[o]||(o=void 0),o}class gE{warningManager;xmls;constructor(e){this.warningManager=new yS,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=jC(new oS(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new oE(e.theme,e,this.warningManager).getTheme():void 0,o=e.sharedStrings?new oE(e.sharedStrings,e,this.warningManager).getSharedStrings():[],i=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((o=>new lE(o,e,this.warningManager,t).getSheet())),s=e.externalLinks.map((t=>new hE(t,e,this.warningManager).getExternalBook())),r=new cE(e,this.warningManager,t);return{fonts:r.getFonts(),fills:r.getFills(),borders:r.getBorders(),dxfs:r.getDxfs(),numFmts:r.getNumFormats(),styles:r.getStyles(),sheets:i,sharedStrings:o,externalBooks:s}}buildXlsxFileStructure(){const e={sheets:dE(cS.sheet,this.xmls),workbook:dE(cS.workbook,this.xmls)[0],styles:dE(cS.styles,this.xmls)[0],sharedStrings:dE(cS.sharedStrings,this.xmls)[0],theme:dE(cS.themes,this.xmls)[0],charts:dE(cS.chart,this.xmls),figures:dE(cS.drawing,this.xmls),tables:dE(cS.table,this.xmls),pivots:dE(cS.pivot,this.xmls),externalLinks:dE(cS.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(r("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:DC(e,this.warningManager),styles:eC(e,this.warningManager),formats:oC(e,this.warningManager),borders:QS(e,this.warningManager),entities:{},revisionId:J};return HC(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=Xe(e.styles[t])})),t}}function pE(e){const t=zu(e);let o=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Bo.test(e.value)){const t=e.value.trim();return o.includes(t)||o.push(t),`${ce}${o.indexOf(t)}${ce}`}return e.value}))),dependencies:o}}const mE=14,fE="Sheet1";function bE(e,t){if(!e)return wE();if(e["[Content_Types].xml"]){const o=new gE(e);if(e=o.convertXlsx(),t)for(let e of o.warningManager.warnings.sort())console.warn(e)}return"version"in e&&e.version<mE&&(e=function(e){for(let t=vE.findIndex((t=>t.from===e.version));t<vE.length;t++)e=vE[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,o=new Ni;for(const i of e.sheets||[])for(const e of i.figures||[])t.has(e.id)&&(e.id+=o.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){const t=Object.assign(wE(),e,{version:mE});t.sheets=t.sheets?t.sheets.map(((e,t)=>Object.assign(EE(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===t.sheets.length&&t.sheets.push(EE(fE,"Sheet1"));Yu(t.settings.locale)||(t.settings.locale=oo);return t}(e),e}(e),e}const vE=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];o.content&&o.content.startsWith("=")&&(o.formula=pE(o.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:o,...i}=t.figures[e].data,s=[];for(let e of o)if(e.labelCell){const t=Jo(e.dataRange),o=e.labelCell+":"+Tt(t.right,t.bottom);s.push(o)}else s.push(e.dataRange);i.dataSetsHaveTitle=Boolean(o[0].labelCell),i.dataSets=s,t.figures[e].data=i}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){const t=[],o=new RegExp(le,"g");for(let i of e.sheets||[]){if(!i.name)continue;const e=i.name,s=e.replace(o,"_");let r=1,n=s;for(;t.includes(n);)n=`${s}${r}`,r++;i.name=n,t.push(n);const a=t=>{if(void 0===t)return t;let o=t.replace(e,n),i=t;for(;i!==o;)i=o,o=i.replace(e,n);return i};for(let e in i.cells){const t=i.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(a))}for(let e of i.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(a),o=a(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:o}}for(let e of i.conditionalFormats||[]){e.ranges=e.ranges.map(a);for(const t of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===e.rule[t]?.type&&(e.rule[t].value=a(e.rule[t].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];if(o.formula){let{text:e,dependencies:t}=o.formula;for(let[o,i]of Object.entries(t)){const t=`\\${ce}${o}\\${ce}`;e=e.replace(new RegExp(t,"g"),i)}o.content=e,delete o.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let o of e.sheets||[])for(let e in o.cells||[]){const i=o.cells[e];i.format&&(i.format=We(i.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}},{description:"Change Border description structure",from:12,to:13,applyMigration(e){for(const t in e.borders){const o=e.borders[t];for(const e in o)Array.isArray(o[e])&&(o[e]={style:o[e][0],color:o[e][1]})}return e}},{description:"Add locale to spreadsheet settings",from:13,to:14,applyMigration:e=>(e.settings||(e.settings={}),e.settings.locale||(e.settings.locale=oo),e)}];function SE(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const o=[],i=[],s=e=>{if("CREATE_SHEET"===e.type)o.push(e.sheetId);else if("sheetId"in e&&!o.includes(e.sheetId))return{...e,sheetId:fE};return e};for(const e of t)"REMOTE_REVISION"===e.type?i.push({...e,commands:e.commands.map(s)}):i.push(e);return i}(e,t),t=CE(t,"SORT_CELLS"),t=function(e,t){const o=[],i={};for(const t of e.sheets||[])t.figures?.forEach((e=>{"chart"===e.tag&&(i[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const o of e.commands){let e=o;switch(o.type){case"CREATE_CHART":i[o.id]=o.definition;break;case"UPDATE_CHART":if(!i[o.id]){console.log(`Fix chart definition: chart with id ${o.id} not found.`);continue}const t={...i[o.id],...o.definition};e={...o,definition:t},i[o.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=CE(t,"SET_DECIMAL")),t}function CE(e,t){const o=[];for(const i of e)"REMOTE_REVISION"===i.type?o.push({...i,commands:i.commands.filter((e=>e.type!==t))}):o.push(i);return o}function EE(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function wE(e="Sheet1"){return{version:mE,sheets:[EE(fE,e)],entities:{},styles:{},formats:{},borders:{},revisionId:J,uniqueFigureIds:!0,settings:{locale:oo}}}function yE(e,t){return{...EE(e,t),charts:[],images:[]}}class xE{static getters=[];history;dispatch;constructor(e,t){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const o of e){let e=o.call(this,t);Array.isArray(e)||(e=[e]);const i=e.filter((e=>0!==e));if(i.length)return i}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}class IE extends xE{getters;uuidGenerator;constructor({getters:e,stateObserver:t,range:o,dispatch:i,uuidGenerator:s}){super(t,i),o.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=s}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class RE{id;compiledFormula;format;style;dependencies;sheetId;buildFormulaContent;isFormula=!0;constructor(e,t,o,i,s,r,n){this.id=e,this.compiledFormula=t,this.format=o,this.style=i,this.dependencies=s,this.sheetId=r,this.buildFormulaContent=n}get content(){return this.buildFormulaContent(this.sheetId,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})}}function TE(e){return""===e?NaN:Number(e)}class AE{id;zone;filters;constructor(e){this.filters=[],this.zone=e;const t=new Ni;this.id=t.uuidv4();for(const o of Oe(e.left,e.right+1)){const e={...this.zone,left:o,right:o};this.filters.push(new OE(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){return this.filters.find((t=>t.col===e))?.id}clone(){return new AE(this.zone)}}class OE{id;zoneWithHeaders;constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}function NE(e){return Object.entries(e).map((([e,t])=>t?ME(parseInt(e,10),t):void 0)).filter(He).map((e=>Tt(e.left,e.top)+":"+Tt(e.right,e.bottom)))}function ME(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}class _E{getters;providers=[];constructor(e){this.getters=e}static getters=["getRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData","getRangeFromZone"];allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:27:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";const s=[...e.elements];s.sort(((e,t)=>t-e));const r=Ne(s);this.executeOnAllRanges((s=>{if(s.sheetId!==e.sheetId)return{changeType:"NONE"};let n=s,a="NONE";for(let e of r){const r=Math.min(...e),l=Math.max(...e);if(s.zone[t]<=r&&r<=s.zone[o]){const e=Math.min(s.zone[o],l)-r+1;a="RESIZE",n=this.createAdaptedRange(n,i,a,-e)}else if(s.zone[t]>=r&&s.zone[o]<=l)a="REMOVE",n=s.clone({...this.getInvalidRange()});else if(s.zone[t]<=l&&s.zone[o]>=l){const e=l-s.zone[t]+1;a="RESIZE",n=this.createAdaptedRange(n,i,a,-e),n=this.createAdaptedRange(n,i,"MOVE",-(s.zone[t]-r))}else r<s.zone[t]&&(a="MOVE",n=this.createAdaptedRange(n,i,a,-(l-r+1)))}return"NONE"!==a?{changeType:a,range:n}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((s=>{if(s.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(s.zone[t]<=e.base&&e.base<s.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(s,i,"RESIZE",e.quantity)};if(e.base<s.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(s,i,"MOVE",e.quantity)}}else{if(s.zone[t]<e.base&&e.base<=s.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(s,i,"RESIZE",e.quantity)};if(e.base<=s.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(s,i,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const o=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:o})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const o=void 0,i=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:i,invalidSheetName:o})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId||!di(o.zone,t))return{changeType:"NONE"};const i=e.targetSheetId,s=e.col-t.left,r=e.row-t.top,n=this.createAdaptedRange(o,"both","MOVE",[s,r]),a=e.sheetId!==i||n.prefixSheet;return{changeType:"MOVE",range:n.clone({sheetId:i,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const o=e(t);return"NONE"===o.changeType||ei(o.range.zone)?o:{range:o.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,o,i){const s=vi(e.unboundedZone,t,o,i);return e.clone({zone:s})}executeOnAllRanges(e,t){const o=this.verifyRangeRemoved(e);for(const e of this.providers)e(o,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,o,i){const s=e.map((e=>Ii.fromRange(e,this.getters)));return s.map((e=>{if(!ei(e.zone))return e;const s=e.prefixSheet?e.sheetId:i,r={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:o),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:o)};return e.clone({sheetId:s,zone:r}).orderZone()}))}getRangeFromSheetXC(e,t){if(!qo.test(t))return new Ii({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let o,i=t,s=!1;t.includes("!")&&(({xc:i,sheetName:o}=Ko(t)),o&&(s=!0));const r=Qo(i),n=Ii.getRangeParts(i,r),a=o&&!this.getters.getSheetIdByName(o)?o:void 0,l=this.getters.getSheetIdByName(o)||e;return new Ii({prefixSheet:s,zone:r,sheetId:l,invalidSheetName:a,parts:n},this.getters.getSheetSize).orderZone()}getRangeString(e,t){if(!e)return Q;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return Q;if(e.zone.left<0||e.zone.top<0)return Q;const o=Ii.fromRange(e,this.getters);let i=o.sheetId!==t||o.invalidSheetName||o.prefixSheet,s="";if(i&&(s=o.invalidSheetName?o.invalidSheetName:Ee(this.getters.getSheetName(o.sheetId))),i&&!s)return Q;let r=this.getRangePartString(o,0);return o.parts&&2===o.parts.length&&(o.zone.top!==o.zone.bottom||o.zone.left!==o.zone.right||o.parts[0].rowFixed||o.parts[0].colFixed||o.parts[1].rowFixed||o.parts[1].colFixed)&&(r+=":",r+=this.getRangePartString(o,1)),`${i?s+"!":""}${r}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromZone(e,t){return new Ii({sheetId:e,zone:t,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}],prefixSheet:!1},this.getters.getSheetSize)}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new Ii(t,this.getters.getSheetSize)}getRangePartString(e,t){const o=e.parts&&e.parts[t].colFixed?"$":"",i=Et(0===t?e.zone.left:e.zone.right),s=e.parts&&e.parts[t].rowFixed?"$":"",r=String(0===t?e.zone.top+1:e.zone.bottom+1);let n="";return n=e.isFullCol?0===t&&e.unboundedZone.hasHeader?o+i+s+r:o+i:e.isFullRow?0===t&&e.unboundedZone.hasHeader?o+i+s+r:s+r:o+i+s+r,n}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:Q}}}class FE extends xE{static layers=[];getters;ui;selection;constructor({getters:e,stateObserver:t,dispatch:o,uiActions:i,selection:s}){super(t,o),this.getters=e,this.ui=i,this.selection=s}drawGrid(e,t){}}const DE=Jd.mapping;function LE(e,t,o){return new PE(e,t,o).getParameters()}class PE{getters;computeCell;evalContext;constructor(e,t,o){this.getters=t,this.computeCell=o,this.evalContext=Object.assign(Object.create(DE),e,{getters:this.getters,locale:this.getters.getLocale()})}getParameters(){return[this.refFn.bind(this),this.range.bind(this),this.evalContext]}refFn(e,t,o,i){if(t)return{value:ti(e.zone)};if(!ei(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(i?r("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",o.toString(),i.toString()):r("Function %s expects its parameters to be single values or single cell references, not ranges.",o.toString()));if(e.invalidSheetName)throw new Error(r("Invalid sheet name: %s",e.invalidSheetName));return this.readCell(e)}readCell(e){if(!this.getters.tryGetSheet(e.sheetId))throw new Error(r("Invalid sheet name"));const t={sheetId:e.sheetId,col:e.zone.left,row:e.zone.top},o=this.getEvaluatedCellIfNotEmpty(t);return void 0===o?{value:null,format:this.getters.getCell(t)?.format}:o}getEvaluatedCellIfNotEmpty(e){const t=this.getEvaluatedCell(e);if(t.type===Qi.empty){const t=this.getters.getCell(e);if(!t||""===t.content)return}return t}getEvaluatedCell(e){const t=this.computeCell(e);if(t.type===Qi.error)throw t.error;return t}range({sheetId:e,zone:t}){if(!ei(t))throw new u;const o=ai(t,this.getters.getSheetZone(e));if(!o)return{value:[[]],format:[[]]};const i=o.bottom-o.top+1,s=o.right-o.left+1,r=Array.from({length:s},(()=>Array.from({length:i}))),n=Array.from({length:s},(()=>Array.from({length:i})));for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++){const s=this.getEvaluatedCellIfNotEmpty({sheetId:e,col:t,row:i});if(s){const e=t-o.left,a=i-o.top;r[e][a]=s.value,void 0!==s.format&&(n[e][a]=s.format)}}return{value:r,format:n}}}class kE{inverseDependencies=new Map;dependencies=new Map;removeAllDependencies(e){const t=this.dependencies.get(e);if(t){for(const o of t)this.inverseDependencies.get(o)?.delete(e);this.dependencies.delete(e)}}addDependencies(e,t){for(const o of t){const t=this.inverseDependencies.get(o);t?t.add(e):this.inverseDependencies.set(o,new Set([e]))}const o=this.dependencies.get(e);o?o.push(...t):this.dependencies.set(e,t)}getCellsDependingOn(e){const t=new st,o=Array.from(e);for(;o.length>0;){const e=o.shift();t.add(e);const i=this.inverseDependencies.get(e)||new Set;for(const e of i)t.has(e)||o.push(e)}return t.delete(...e),t}}class UE{resultsToArrayFormulas=new Map;arrayFormulasToResults=new Map;getFormulaPositionsSpreadingOn(e){return this.resultsToArrayFormulas.get(e)||VE}getArrayResultPositionIds(e){return this.arrayFormulasToResults.get(e)||VE}removeNode(e){this.resultsToArrayFormulas.delete(e),this.arrayFormulasToResults.delete(e)}addRelation({arrayFormulaPositionId:e,resultPositionId:t}){this.resultsToArrayFormulas.has(t)||this.resultsToArrayFormulas.set(t,new Set),this.resultsToArrayFormulas.get(t)?.add(e),this.arrayFormulasToResults.has(e)||this.arrayFormulasToResults.set(e,new Set),this.arrayFormulasToResults.get(e)?.add(t)}hasArrayFormulaResult(e){return this.resultsToArrayFormulas.has(e)}isArrayFormula(e){return this.arrayFormulasToResults.has(e)}}const VE=[];class zE{context;getters;compilationParams;positionEncoder=new $E;evaluatedCells=new Map;formulaDependencies=qe(new kE);blockedArrayFormulas=new Set;spreadingRelations=new UE;constructor(e,t){this.context=e,this.getters=t,this.compilationParams=LE(e,t,(e=>this.computeCell(this.encodePosition(e))))}getEvaluatedCell(e){return this.evaluatedCells.get(this.encodePosition(e))||Zs("",{locale:this.getters.getLocale()})}getArrayFormulaSpreadingOn(e){const t=this.encodePosition(e),o=this.getArrayFormulaSpreadingOnId(t);return void 0!==o?this.decodePosition(o):void 0}getEvaluatedPositions(){return[...this.evaluatedCells.keys()].map(this.decodePosition.bind(this))}getArrayFormulaSpreadingOnId(e){if(!this.spreadingRelations.hasArrayFormulaResult(e))return;const t=this.spreadingRelations.getFormulaPositionsSpreadingOn(e);return Array.from(t).find((e=>!this.blockedArrayFormulas.has(e)))}updateDependencies(e){const t=this.encodePosition(e);this.formulaDependencies().removeAllDependencies(t);const o=this.getDirectDependencies(t);this.formulaDependencies().addDependencies(t,o)}updateCompilationParameters(){this.compilationParams=LE(this.context,this.getters,(e=>this.computeCell(this.encodePosition(e))))}evaluateCells(e){const t=e.map(this.encodePosition.bind(this)),o=new st(t),i=this.getArrayFormulasImpactedByChangesOf(t);o.add(...this.getCellsDependingOn(t)),o.add(...i),o.add(...this.getCellsDependingOn(i)),this.evaluate(o)}getArrayFormulasImpactedByChangesOf(e){const t=new st;for(const o of e){const e=this.getCell(o)?.content,i=this.getArrayFormulaSpreadingOnId(o);void 0!==i&&t.add(i),e||t.add(...this.getArrayFormulasBlockedByOrSpreadingOn(o))}return t}buildDependencyGraph(){this.blockedArrayFormulas=new Set,this.spreadingRelations=new UE,this.formulaDependencies=qe((()=>{const e=new kE;for(const t of this.getAllCells()){const o=this.getDirectDependencies(t);e.addDependencies(t,o)}return e}))}evaluateAllCells(){this.evaluatedCells=new Map,this.evaluate(this.getAllCells())}getAllCells(){const e=new st;for(const t of this.getters.getSheetIds()){const o=this.getters.getCells(t);for(const t in o)e.add(this.encodePosition(this.getters.getCellPosition(t)))}return e}getArrayFormulasBlockedByOrSpreadingOn(e){if(!this.spreadingRelations.hasArrayFormulaResult(e))return[];const t=this.spreadingRelations.getFormulaPositionsSpreadingOn(e),o=new st(t);return o.add(...this.getCellsDependingOn(t)),o}nextPositionsToUpdate=new st;cellsBeingComputed=new Set;evaluate(e){this.cellsBeingComputed=new Set,this.nextPositionsToUpdate=e;let t=0;for(;this.nextPositionsToUpdate.size&&t++<30;){const e=Array.from(this.nextPositionsToUpdate);this.nextPositionsToUpdate.clear();for(let t=0;t<e.length;++t){const o=e[t];this.evaluatedCells.delete(o)}for(let t=0;t<e.length;++t){const o=e[t];this.setEvaluatedCell(o,this.computeCell(o))}}}setEvaluatedCell(e,t){this.nextPositionsToUpdate.has(e)&&this.nextPositionsToUpdate.delete(e),this.evaluatedCells.set(e,t)}computeCell(e){const t=this.evaluatedCells.get(e);if(t)return t;this.blockedArrayFormulas.has(e)||this.invalidateSpreading(e);const o=this.getCell(e);if(void 0===o)return Zs("",{locale:this.getters.getLocale()});const i=o.id;try{if(this.cellsBeingComputed.has(i))throw new d;return this.cellsBeingComputed.add(i),o.isFormula?this.computeFormulaCell(o):Gs(o.content,{format:o.format,locale:this.getters.getLocale()})}catch(e){return this.handleError(e,o)}finally{this.cellsBeingComputed.delete(i)}}handleError(e,t){e instanceof Error||(e=new Error(e));const o=e?.errorType||a.GenericError,i=this.compilationParams[2].__lastFnCalled||"",s=new c(o,e.message.replace("[[FUNCTION_NAME]]",i),void 0!==e.logLevel?e.logLevel:l.error);return Ks(t.content,s)}computeFormulaCell(e){const t=e.id;this.compilationParams[2].__originCellXC=()=>{const e=this.compilationParams[2].getters.getCellPosition(t);return Tt(e.col,e.row)};const o=e.compiledFormula.execute(e.dependencies,...this.compilationParams);!function(e){const{value:t,format:o}=e;if(!cs(t)){if(cs(o))throw new Error("A format matrix should never be associated with a scalar value");return}if(cs(o)){if(!(t.length===o.length&&t[0].length===o[0].length))throw new Error("Formats and values should have the same dimensions!")}}(o);const{value:i,format:s}=o;if(!cs(i))return Zs(i,{format:e.format||s,locale:this.getters.getLocale()});const r=this.getters.getCellPosition(t);this.assertSheetHasEnoughSpaceToSpreadFormulaResult(r,i),BE(i,this.updateSpreadRelation(r)),BE(i,this.checkCollision(r)),BE(i,this.spreadValues(r,o));const n=HE(s);return Zs(i[0][0],{format:e.format||n(0,0),locale:this.getters.getLocale()})}assertSheetHasEnoughSpaceToSpreadFormulaResult({sheetId:e,col:t,row:o},i){const s=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),a=t+i.length<=s,l=o+i[0].length<=n;if(!a||!l){if(a)throw new Error(r("Result couldn't be automatically expanded. Please insert more rows."));if(l)throw new Error(r("Result couldn't be automatically expanded. Please insert more columns."));throw new Error(r("Result couldn't be automatically expanded. Please insert more columns and rows."))}}updateSpreadRelation({sheetId:e,col:t,row:o}){const i=this.encodePosition({sheetId:e,col:t,row:o});return(s,r)=>{const n={sheetId:e,col:s+t,row:r+o},a=this.encodePosition(n);this.spreadingRelations.addRelation({resultPositionId:a,arrayFormulaPositionId:i})}}checkCollision({sheetId:e,col:t,row:o}){const i=this.encodePosition({sheetId:e,col:t,row:o});return(s,n)=>{const a={sheetId:e,col:s+t,row:n+o};if(this.getters.getCell(a)?.content||this.getters.getEvaluatedCell(a).type!==Qi.empty)throw this.blockedArrayFormulas.add(i),new Error(r("Array result was not expanded because it would overwrite data in %s.",Tt(a.col,a.row)));this.blockedArrayFormulas.delete(i)}}spreadValues({sheetId:e,col:t,row:o},i){const s=HE(i.format);return(r,n)=>{const a={sheetId:e,col:r+t,row:n+o},l=this.getters.getCell(a)?.format,c=Zs(i.value[r][n],{format:l||s(r,n),locale:this.getters.getLocale()}),h=this.encodePosition(a);this.setEvaluatedCell(h,c),this.nextPositionsToUpdate.add(...this.getCellsDependingOn([h]))}}invalidateSpreading(e){if(this.spreadingRelations.isArrayFormula(e)){for(const t of this.spreadingRelations.getArrayResultPositionIds(e)){const e=this.getCell(t)?.content;e||(this.evaluatedCells.delete(t),this.nextPositionsToUpdate.add(...this.getCellsDependingOn([t])),this.nextPositionsToUpdate.add(...this.getArrayFormulasBlockedByOrSpreadingOn(t)))}this.spreadingRelations.removeNode(e)}}getDirectDependencies(e){const t=this.getCell(e);if(!t?.isFormula)return[];const o=[];for(const e of t.dependencies){if(e.invalidSheetName||e.invalidXc)continue;const t=e.sheetId;bi(e.zone,((e,i)=>{o.push(this.encodePosition({sheetId:t,col:e,row:i}))}))}return o}getCellsDependingOn(e){return this.formulaDependencies().getCellsDependingOn(e)}getCell(e){return this.getters.getCell(this.decodePosition(e))}encodePosition(e){return this.positionEncoder.encode(e)}decodePosition(e){return this.positionEncoder.decode(e)}}function BE(e,t){for(let o=0;o<e.length;++o)for(let i=0;i<e[o].length;++i)0===o&&0===i||t(o,i)}function HE(e){return cs(e)?(t,o)=>e[t][o]:()=>e}class $E{sheetMapping={};inverseSheetMapping=new Map;constructor(){try{o_spreadsheet.__DEBUG__=o_spreadsheet.__DEBUG__||{},o_spreadsheet.__DEBUG__.decodePosition=this.decode.bind(this),o_spreadsheet.__DEBUG__.encodePosition=this.encode.bind(this)}catch(e){}}encode({sheetId:e,col:t,row:o}){return this.encodeSheet(e)<<42n|BigInt(t)<<21n|BigInt(o)}decode(e){const t=Number(2097151n&e),o=Number(e>>21n&2097151n);return{sheetId:this.decodeSheet(e>>42n),col:o,row:t}}encodeSheet(e){const t=this.sheetMapping[e];if(void 0===t){const t=BigInt(Object.keys(this.sheetMapping).length);return this.sheetMapping[e]=t,this.inverseSheetMapping.set(t,e),t}return t}decodeSheet(e){const t=this.inverseSheetMapping.get(e);if(void 0===t)throw new Error("Sheet id not found");return t}}const WE=Jd.content;class GE{cells;getters;index=0;direction;constructor(e,t,o){this.cells=e,this.getters=t,this.direction=o}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:o,tooltip:i}=Js.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:o,tooltip:i,origin:{col:e.data.col,row:e.data.row}}}}class qE{subscriptions={};on(e,t,o){if(!o)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:o})}trigger(e,t){const o=this.subscriptions[e]||[];for(let e=0,i=o.length;e<i;e++){const i=o[e];i.callback.call(i.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function ZE(e,t){return{...e,definition:Bp(e.definition,t)}}function jE(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let o=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)o>t&&o--}if("ADD_COLUMNS_ROWS"===t.type){o=o>("before"===t.position?t.base-1:t.base)?o+t.quantity:o}return o>0?{...e,quantity:o}:void 0}Rb.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],ZE),Rb.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],ZE),Rb.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const o=t.sheetId;if(e.targetSheetId===o||e.sheetId===o)return;return e})),Rb.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),Rb.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){if(e.name===t.name)return{...e,name:e.name?.match(/\d+/)?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),Rb.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const o=[];for(const i of e.target)for(const e of t.target)ci(i,e)||o.push({...i});if(o.length)return{...e,target:o};return})),Rb.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],jE),Rb.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],jE),Rb.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const o of e.target)for(const e of t.target)if(ci(e,o))return;return e}));const YE=[{match:function(e){return"sheetId"in e},fn:QE},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const o=QE(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;const i=[];for(const o of e.target){const e=wg(o,t);e&&i.push(e)}if(!i.length)return"IGNORE_COMMAND";return{...e,target:i}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const o=QE(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const o="COL"===t.dimension?"col":"row";let i=e[o];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(i))return"IGNORE_COMMAND";for(let t of e)i>=t&&i--}"ADD_COLUMNS_ROWS"===t.type&&(i>t.base||i===t.base&&"before"===t.position)&&(i+=t.quantity);return{...e,[o]:i}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const o of t.target){if(!(e.col===o.left&&e.row===o.top)&&hi(e.col,e.row,o))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const o=QE(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const o="ADD_COLUMNS_ROWS"===e.type,i=o?"base":"elements";let s=o?[e[i]]:e[i];if("REMOVE_COLUMNS_ROWS"===t.type&&(s=s.map((e=>{if(t.elements.includes(e))return;const o=t.elements.sort(((e,t)=>t-e));for(let t of o)e>t&&e--;return e})).filter(He)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;s=s.map((o=>o>e?o+t.quantity:o))}if(s.length){let t=s;return o&&(t=s[0]),{...e,[i]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){if(!("sheetId"in t))return e;const o=[],i="DELETE_SHEET"===t.type&&t.sheetId;for(const s of e.ranges)if(s._sheetId!==t.sheetId)o.push({...s,_zone:s._zone});else{const e=wg(s._zone,t);e&&i!==s._sheetId&&o.push({...s,_zone:e})}if(!o.length)return"IGNORE_COMMAND";return{...e,ranges:o}}}];function XE(e,t){const o=Rb.getTransformation(e.type,t.type);return o?o(e,t):function(e,t){for(const{match:o,fn:i}of YE)if(o(e)){const o=i(e,t);if("SKIP_TRANSFORMATION"===o)continue;if("IGNORE_COMMAND"===o)return;e=o}return e}(e,t)}function KE(e,t){let o=[...e];for(const e of t)o=o.map((t=>XE(t,e))).filter(He);return o}function QE(e,t){if(!("sheetId"in t))return e;const o="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===o?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class JE{rootCommand;timestamp;id;clientId;_commands=[];_changes=[];constructor(e,t,o,i,s,r){this.rootCommand=i,this.timestamp=r,this.id=e,this.clientId=t,this._commands=[...o],this._changes=s?[...s]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class ew extends Error{}class tw extends qE{revisions;transportService;serverRevisionId;clients={};clientId="local";debouncedMove;pendingMessages=[];waitingAck=!1;waitingUndoRedoAck=!1;isReplayingInitialRevisions=!1;processedRevisions=new Set;uuidGenerator=new Ni;constructor(e,t,o=J){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=o,this.debouncedMove=function(e,t,o){let i;return function(){const s=this,r=arguments,n=o&&!i;clearTimeout(i),i=setTimeout((function(){i=null,o||e.apply(s,r)}),t),n&&e.apply(s,r)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t,o){if(!t.length||!o.length||!this.canApplyOptimisticUpdate())return;const i=new JE(this.uuidGenerator.uuidv4(),this.clientId,t,e,o,Date.now());this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new ew("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(He))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}getLastLocalNonEmptyRevision(e){const t=this.revisions.getRevertedExecution();for(const o of t){if("SNAPSHOT"===o.rootCommand)return;if(o.rootCommand&&"REMOTE"!==o.rootCommand&&(!e.includes(o.rootCommand?.type)&&o.commands.length))return o}}_move(e){if(!this.clients[this.clientId])return;const t=this.clients[this.clientId]?.position;if(t?.col===e.col&&t.row===e.row&&t.sheetId===e.sheetId)return;const o=t?"CLIENT_MOVED":"CLIENT_JOINED",i=this.getClient();this.clients[this.clientId]={...i,position:e},this.transportService.sendMessage({type:o,version:1,client:{...i,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":const{clientId:t,commands:o,timestamp:i}=e,s=new JE(e.nextRevisionId,t,o,"REMOTE",void 0,i);if(s.clientId!==this.clientId){this.revisions.insert(s.id,s,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:KE(o,t)})}break;case"SNAPSHOT_CREATED":{const t=new JE(e.nextRevisionId,"server",[],"SNAPSHOT",void 0,Date.now());this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const ow=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];var iw;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(iw||(iw={}));class sw extends FE{inputHasSingleRange;static layers=[1];static getters=[];ranges=[];focusedRangeIndex=null;activeSheet;willAddNewRange=!1;constructor(e,t,o){if(o&&t.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e),this.inputHasSingleRange=o,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){switch(e.type){case"ADD_RANGE":case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange&&1===this.ranges.length)return 31;break;case"CHANGE_RANGE":if(this.inputHasSingleRange&&e.value.split(",").length>1)return 31}return 0}handleEvent(e){const t=this.activeSheet,o=this.getters.getActiveSheetId(),i=e.anchor.zone,s=this.getters.getRangeFromZone(o,e.options.unbounded?this.getters.getUnboundedZone(o,i):i);this.add([this.getters.getSelectionRangeString(s,t)])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const o=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"ADD_RANGE":this.insertNewRange(this.ranges.length,[e.value]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),i=this.getters.expandZone(e.sheetIdTo,Ei({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:i})}}}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],xc:t}}insertNewRange(e,t){const o=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:o+t+1,color:lt[(o+t)%lt.length]}))))}setRange(e,t){const[,...o]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,o),o.length&&this.focus(e+o.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const o=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return o.map((e=>{const{sheetName:o}=Ko(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:o&&this.getters.getSheetIdByName(o)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:o}=Ko(t),i=this.getters.getSheetIdByName(o),s=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(i===s||void 0===i&&s===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}const rw=[nw,function(e,t){return"target"in t&&Array.isArray(t.target)?{...Se(t),target:e.getSelectedZones()}:t},function(e,t){if(!("row"in t)||!("col"in t))return t;const{col:o,row:i}=e.getActivePosition();return{...Se(t),col:o,row:i}}];function nw(e,t){return"sheetId"in t?{...Se(t),sheetId:e.getActiveSheetId()}:t}const aw=new Ni;function lw(e,t){const o=e.getSelectedZone();return{...nw(e,t),elements:"COL"===t.dimension?Oe(o.left,o.right+1):Oe(o.top,o.bottom+1)}}function cw(e,t){const o=e.getSelectedZone();return{...Se(t),zone:o}}function hw(e,t){const o=Se(t),i=e.getSelectedZone(),{top:s,bottom:r,left:n,right:a}=i;return"cols"in o?o.cols=Oe(n,a+1):"rows"in o&&(o.rows=Oe(s,r+1)),o}const dw=new $i;dw.add("UPDATE_CELL",gw),dw.add("CLEAR_CELL",gw),dw.add("DELETE_CONTENT",gw),dw.add("ADD_MERGE",gw),dw.add("REMOVE_MERGE",gw),dw.add("SET_FORMATTING",gw),dw.add("CLEAR_FORMATTING",gw),dw.add("SET_BORDER",gw),dw.add("CREATE_FILTER_TABLE",gw),dw.add("REMOVE_FILTER_TABLE",gw),dw.add("HIDE_SHEET",gw),dw.add("ADD_COLUMNS_ROWS",(function(e,t){const o=e.getActivePosition();return{...nw(e,t),base:"COL"===t.dimension?o.col:o.row}})),dw.add("REMOVE_COLUMNS_ROWS",lw),dw.add("HIDE_COLUMNS_ROWS",lw),dw.add("RESIZE_COLUMNS_ROWS",lw),dw.add("CREATE_SHEET",(function(e,t){const o=Se(t);o.sheetId=aw.uuidv4();const i=t.name||e.getSheet(e.getActiveSheetId()).name,s=i.match(/(.+?)\d*$/)?.[1]||i;return o.name=e.getNextSheetName(s),o})),dw.add("CREATE_FIGURE",(function(e,t){const o=nw(e,t);return o.figure.id=aw.uuidv4(),o})),dw.add("CREATE_CHART",(function(e,t){return{...nw(e,t),id:aw.uuidv4()}})),dw.add("CREATE_IMAGE",(function(e,t){return{...nw(e,t),figureId:aw.uuidv4()}}));const uw=new $i;function gw(e,t){let o=Se(t);for(const t of rw)o=t(e,o);return o}function pw(e,t){if(!t)return;if(!dw.contains(t.type))return;return dw.get(t.type)(e,t)}function mw(e,t){if(e.rootCommand&&"object"==typeof e.rootCommand)return rs(e.rootCommand)?pw(t,e.rootCommand):function(e,t,o){if(!uw.contains(t.type))return;return uw.get(t.type)(e,t,o)}(t,e.rootCommand,e.commands)}uw.add("STOP_EDITION",(function(e,t,o){return o.map((t=>pw(e,t))).filter(He)})),uw.add("PASTE",(function(e,t){return{type:"REPEAT_PASTE",pasteOption:Se(t.pasteOption),target:e.getSelectedZones()}})),uw.add("INSERT_CELL",cw),uw.add("DELETE_CELL",cw),uw.add("AUTORESIZE_COLUMNS",hw),uw.add("AUTORESIZE_ROWS",hw),uw.add("SORT_CELLS",(function(e,t){const o=e.getSelectedZone();return{...nw(e,t),col:o.left,row:o.top,zone:o}})),uw.add("SUM_SELECTION",gw),uw.add("SET_DECIMAL",gw);class fw{getters;dispatch;selection;operation;sheetId;constructor(e,t,o,i){this.getters=t,this.dispatch=o,this.selection=i,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,o,i){const s=this.getters.getActiveSheetId(),r=t+i-this.getters.getNumberRows(s);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(s)-1,sheetId:s,quantity:r,position:"after"});const n=e+o-this.getters.getNumberCols(s);n>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(s)-1,sheetId:s,quantity:n,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class bw extends fw{cells;copiedTables;zones;constructor(e,t,o,i,s){if(super(t,o,i,s),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const r=new Set(e.map((e=>e.left))),n=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===r.size&&1===n.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let i=0;i<o;i++)if(ci(e[i],t))return e[i]=ni(e[i],t),e;return e[o]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>fi(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=o.getActiveSheetId();for(let e of u){let t=[];for(let i of d){const s={col:i,row:e,sheetId:p};t.push({cell:o.getCell(s),style:o.getCellComputedStyle(s),evaluatedCell:o.getEvaluatedCell(s),border:o.getCellBorder(s)||void 0,position:s})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const o of Oe(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:o,row:e.zone.top}));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?20:0}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==t?.pasteOption)return 22;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 21;const i=this.cells.length,s=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(o,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(o,e[0])||i*s!=1))return 2;const{xSplit:r,ySplit:n}=this.getters.getPaneDivisions(o);for(const t of this.getPasteZones(e))if(t.left<r&&t.right>=r||t.top<n&&t.bottom>=n)return 76;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const o=this.cells.length,i=this.cells[0].length,s="CUT"===this.operation;t?.selectTarget&&this.selectPastedZone(i,o,s,e)}pasteFromCopy(e,t){if(1===e.length){const o=this.cells.length,i=this.cells[0].length,s=this.pastedZones(e,i,o);for(const e of s)this.pasteZone(e.left,e.top,t)}else for(const o of e)for(let e=o.left;e<=o.right;e++)for(let i=o.top;i<=o.bottom;i++)this.pasteZone(e,i,t);void 0===t?.pasteOption&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const o=e[0];this.pasteZone(o.left,o.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:o.left,row:o.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e),this.cells.forEach((e=>{e.forEach((e=>{e.cell&&(e.cell=void 0)}))}))}pastedZones(e,t,o){const i=e[0],s=Math.max(1,Math.floor((i.right+1-i.left)/t)),r=Math.max(1,Math.floor((i.bottom+1-i.top)/o)),n=[];for(let e=0;e<s;e++)for(let s=0;s<r;s++){const r=i.top+s*o,a=i.left+e*t;n.push({left:a,top:r,bottom:r+o-1,right:a+t-1})}return n}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const o=[],i=t.length,s=t[0].length,r=e[e.length-1],n=r.left,a=r.top,l=Math.max(1,Math.floor((r.right+1-n)/s)),c=Math.max(1,Math.floor((r.bottom+1-a)/i));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)o.push({left:n,top:a,right:n-1+e*s,bottom:a-1+t*i});return o}selectPastedZone(e,t,o,i){const s=i[0],r=s.left,n=s.top;if(t>1||e>1||o){const s=this.pastedZones(i,e,t),a=o?s[0]:ni(...s);this.selection.selectZone({cell:{col:r,row:n},zone:a},{scrollIntoView:!1})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,o){const i=this.cells.length,s=this.cells[0].length,r="onlyValue"!==o?.pasteOption&&o?.shouldPasteCF,n=this.getters.getActiveSheetId();this.addMissingDimensions(s,i,e,t);for(let a=0;a<i;a++){const i=this.cells[a];for(let l=0;l<s;l++){const s=i[l],c={col:e+l,row:t+a,sheetId:n};"CUT"!==this.operation&&this.pasteMergeIfExist(s.position,c),this.pasteCell(s,c,this.operation,o),r&&this.pasteCf(s.position,c)}}}pasteCell(e,t,o,i){const{sheetId:s,col:r,row:n}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==i?.pasteOption){const o=this.getters.getCellBorder(t),i=e.border,a={top:o?.top||i?.top,bottom:o?.bottom||i?.bottom,left:o?.left||i?.left,right:o?.right||i?.right};this.dispatch("SET_BORDER",{sheetId:s,col:r,row:n,border:a})}if(e.cell){if("onlyFormat"===i?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===i?.pasteOption){const o=this.getters.getLocale(),i=vo(e.evaluatedCell.value,{locale:o});return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===o){const t=r-e.position.col,i=n-e.position.row;a=this.getUpdatedContent(s,e.cell,t,i,o)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===i?.pasteOption?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===i?.pasteOption?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,o,i,s){const r=this.getters.createAdaptedRanges(t.dependencies,o,i,e);return this.getters.buildFormulaContent(e,t,r)}pasteMergeIfExist(e,t){let{sheetId:o,col:i,row:s}=e;const{col:r,row:n}=this.getters.getMainCellPosition(e);if(r===i&&n===s){const r=this.getters.getMerge(e);if(!r)return;({sheetId:o,col:i,row:s}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:i,top:s,right:i+r.right-r.left,bottom:s+r.bottom-r.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),o=e[0],i=this.zones[0],s=[o.left-i.left,o.top-i.top];for(const e of this.copiedTables){const o=vi(e.zone,"both","MOVE",s);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[o]});for(const i of Oe(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:o.left+i,row:o.top,values:e.filtersValues[i]})}}getClipboardContent(){return{[Ji.PlainText]:this.getPlainTextContent(),[Ji.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>this.getters.shouldShowFormulas()&&e.cell?.isFormula?e.cell?.content||"":e.evaluatedCell?.formattedValue||"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1==this.cells.length&&1==this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const o of t){e+=`<td style="${Ui(Pi(o.style))}">`+qC(this.getters.getCellText(o.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let o of this.zones){if("COL"===t&&e<=o.right)return!0;if("ROW"===t&&e<=o.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:o}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*o;for(const e of this.zones){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e);s>0&&r>0&&t.strokeRect(o,i,s,r)}}}pasteCf(e,t){const o=Tt(t.col,t.row);for(let i of this.getters.getConditionalFormats(e.sheetId))for(let s of i.ranges)if(hi(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=i,r=[];"CUT"===this.operation&&r.push(Tt(e.col,e.row)),e.sheetId===t.sheetId?this.adaptCFRules(e.sheetId,s,[o],r):(this.adaptCFRules(t.sheetId,s,[o],[]),this.adaptCFRules(e.sheetId,s,[],r))}}adaptCFRules(e,t,o,i){const s=this.getters.getAdaptedCfRanges(e,t,o,i);s&&this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:s.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}}class vw{operation;getters;dispatch;sheetId;copiedFigure;copiedFigureContent;constructor(e,t,o){this.operation=e,this.getters=t,this.dispatch=o,this.sheetId=t.getActiveSheetId();const i=t.getSelectedFigureId();if(!i)throw new Error("No figure selected");const s=t.getFigure(this.sheetId,i);if(!s)throw new Error(`No figure for the given id: ${i}`);switch(this.copiedFigure={...s},s.tag){case"chart":this.copiedFigureContent=new Sw(o,t,this.sheetId,i);break;case"image":this.copiedFigureContent=new Cw(o,t,this.sheetId,i);break;default:throw new Error(`Unknow tag '${s.tag}' for the given figure id: ${i}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?74:void 0!==t?.pasteOption?23:0}paste(e){const t=this.getters.getActiveSheetId(),{width:o,height:i}=this.copiedFigure,s=this.getters.getNumberCols(t),r=this.getters.getNumberRows(t),n=this.getters.getColDimensions(t,e[0].left).start,a=this.getters.getRowDimensions(t,e[0].top).start,l=this.getters.getColDimensions(t,s-1).end,c=this.getters.getRowDimensions(t,r-1).end,h={x:l<o?0:Math.min(n,l-o),y:c<i?0:Math.min(a,c-i)},d=(new Ni).uuidv4();this.copiedFigureContent.paste(t,d,h,{height:i,width:o}),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:d})}getClipboardContent(){return{[Ji.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Sw{dispatch;sheetId;copiedChart;constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const s=t.getChart(i);if(!s)throw new Error(`No chart for the given id: ${i}`);this.copiedChart=s.copyInSheetId(o)}paste(e,t,o,i){const s=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:o,size:i,definition:s.getDefinition()})}}class Cw{dispatch;sheetId;copiedImage;constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const s=t.getImage(i);this.copiedImage=Se(s)}paste(e,t,o,i){const s=Se(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:o,size:i,definition:s})}}function Ew(e,t){return e.startsWith("=")?function(e,t){return function(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const i=au(e,t);let s="";for(const e of i)"NUMBER"===e.type?s+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?s+=o.formulaArgSeparator:s+=e.value;return s}(e,t,oo)}(e,t):eg(e,t)}class ww extends fw{values;constructor(e,t,o,i){super("COPY",t,o,i),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId(),i=this.getPasteZone(e);return this.getters.doesIntersectMerge(o,i)?2:0}paste(e,t){if("onlyFormat"===t?.pasteOption)return;const o=this.values,i=this.getPasteZone(e),{left:s,top:r}=i,{numberOfCols:n,numberOfRows:a}=pi(i),l=this.getters.getActiveSheetId(),c=this.getters.getLocale();this.addMissingDimensions(n,a,s,r);for(let e=0;e<o.length;e++)for(let t=0;t<o[e].length;t++)this.dispatch("UPDATE_CELL",{row:r+e,col:s+t,content:Ew(o[e][t],c),sheetId:l});const h={left:s,top:r,right:s+n-1,bottom:r+a-1};this.selection.selectZone({cell:{col:s,row:r},zone:h},{scrollIntoView:!1})}getClipboardContent(){return{[Ji.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,o=Math.max(...this.values.map((e=>e.length))),{left:i,top:s}=e[0];return{top:s,left:i,bottom:s+t-1,right:i+o-1}}}function yw(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Ko(e.value),[i,s]=t.split(":"),r=o?`${Ee(o)}!`:"",n=xw(i),a=s?`:${xw(s)}`:"";return{...e,value:r+n+a}}function xw(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=Iw(e,"colrow");break;case"colrow":e=Iw(e,"row");break;case"row":e=Iw(e,"col");break;case"col":e=Iw(e,"none")}return e}function Iw(e,t){let o;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return o=e.search(/[0-9]/),e.slice(0,o)+"$"+e.slice(o);case"colrow":return o=e.search(/[0-9]/),"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}const Rw=r("The cell you are trying to edit has been deleted.");const Tw=[{name:r("Sum"),types:[Qi.number],compute:(e,t)=>da.compute.bind({locale:t})([e])},{name:r("Avg"),types:[Qi.number],compute:(e,t)=>wa.compute.bind({locale:t})([e])},{name:r("Min"),types:[Qi.number],compute:(e,t)=>Va.compute.bind({locale:t})([e])},{name:r("Max"),types:[Qi.number],compute:(e,t)=>La.compute.bind({locale:t})([e])},{name:r("Count"),types:[Qi.number,Qi.text,Qi.boolean,Qi.error],compute:(e,t)=>Na.compute.bind({locale:t})([e])},{name:r("Count Numbers"),types:[Qi.number,Qi.text,Qi.boolean,Qi.error],compute:(e,t)=>Oa.compute.bind({locale:t})([e])}];class Aw{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;offsetScrollbarX;offsetScrollbarY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,o,i,s,r){this.getters=e,this.sheetId=t,this.boundaries=o,this.viewportWidth=i.width,this.viewportHeight=i.height,this.offsetScrollbarX=r.x,this.offsetScrollbarY=r.y,this.canScrollVertically=s.canScrollVertically,this.canScrollHorizontally=s.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const e=this.getters.findLastVisibleColRowIndex(this.sheetId,"COL",{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,"ROW",{first:this.boundaries.top,last:this.boundaries.bottom}),{end:o,size:i}=this.getters.getColDimensions(this.sheetId,e),{end:s,size:r}=this.getters.getRowDimensions(this.sheetId,t),n=this.searchHeaderIndex("COL",o-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,n),l=this.searchHeaderIndex("ROW",s-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=o-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(D,Math.min(a,this.viewportWidth-i)),h=Math.max(h,this.viewportWidth));let d=s-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(L+5,Math.min(c,this.viewportHeight-r)),d=Math.max(d,this.viewportHeight)),{width:h,height:d}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const o=this.getters.getMainCellPosition({sheetId:t,...e}),{col:i,row:s}=this.getters.getNextVisibleCellPosition(o);hi(i,this.boundaries.top,this.boundaries)&&this.adjustPositionX(i),hi(this.boundaries.left,s,this.boundaries)&&this.adjustPositionY(s)}adjustPositionX(e){const t=this.sheetId,{end:o}=this.getters.getColDimensions(t,e),i=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<o)for(let e=this.left;this.offsetX+this.offsetCorrectionX+this.viewportWidth<o&&!(e>i);e++)this.getters.isColHidden(t,e)||(this.offsetX=this.getters.getColDimensions(t,e).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX());else if(this.left>e)for(let o=this.left;o>=e&&!(o<0);o--)this.getters.isColHidden(t,o)||(this.offsetX=this.getters.getColDimensions(t,o).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX())}adjustPositionY(e){const t=this.sheetId,{end:o}=this.getters.getRowDimensions(t,e),i=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<o)for(let e=this.top;this.offsetY+this.viewportHeight+this.offsetCorrectionY<o&&!(e>i);e++)this.getters.isRowHidden(t,e)||(this.offsetY=this.getters.getRowDimensions(t,e).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY());else if(this.top>e)for(let o=this.top;o>=e&&!(o<0);o--)this.getters.isRowHidden(t,o)||(this.offsetY=this.getters.getRowDimensions(t,o).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY())}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=ai(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.viewportWidth),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.viewportHeight)}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,o=0,i=!1){let s=0;const r=this.sheetId,n=this.getters.getNumberHeaders(r,e);for(let a=o;a<=n-1;a++){const o=i||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(r,e,a)&&!o&&(s+="COL"===e?this.getters.getColSize(r,a):this.getters.getRowSize(r,a),s>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportWidth,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.viewportWidth,this.left)),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.viewportHeight,this.top)),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}const Ow=(new $i).add("settings",class extends IE{static getters=["getLocale"];locale=oo;allowDispatch(e){return"UPDATE_LOCALE"===e.type?Yu(e.locale)?0:94:0}handle(e){if("UPDATE_LOCALE"===e.type)this.history.update("locale",e.locale)}getLocale(){return this.locale}import(e){this.locale=e.settings?.locale??oo}export(e){e.settings={locale:this.locale}}}).add("sheet",class extends IE{static getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions","checkZonesExistInSheet","getCommandZones","getUnboundedZone"];sheetIdsMapName={};orderedSheetIds=[];sheets={};cellPosition={};allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 15}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>t?87:e.quantity<=0?88:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return Math.min(...e.elements)<0||Math.max(...e.elements)>t?87:0}case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.delta);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let t of e.sheets){const e=t.name||s("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:o,rowNumber:i}=this.getImportedSheetSize(t),r={id:t.id,name:e,numberOfCols:o,rows:Oi(i),areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible,panes:{xSplit:t.panes?.xSplit||0,ySplit:t.panes?.ySplit||0}};this.orderedSheetIds.push(r.id),this.sheets[r.id]=r}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(He).map((e=>{const t=this.sheets[e],o={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(o.panes=t.panes),o}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){return this.tryGetSheet(e)?.name}getSheetIdByName(e){if(e){const t=Ce(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,o){return"COL"===t?o>=0&&o<this.getNumberCols(e):o>=0&&o<this.getNumberRows(e)}getRow(e,t){const o=this.getSheet(e).rows[t];if(!o)throw new Error(`Row ${o} not found.`);return o}getCell({sheetId:e,col:t,row:o}){const i=this.tryGetSheet(e)?.rows[o]?.cells[t];if(void 0!==i)return this.getters.getCellById(i)}getColsZone(e,t,o){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:o}}getRowCells(e,t){return Object.values(this.getSheet(e).rows[t]?.cells).filter(He)}getRowsZone(e,t,o){return{top:t,bottom:o,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this));let i=`${e}${t}`;for(;o.includes(i);)i=`${e}${t}`,t++;return i}getSheetSize(e){return{numberOfRows:this.getNumberRows(e),numberOfCols:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getUnboundedZone(e,t){const o=0===t.left&&t.right===this.getNumberCols(e)-1,i=0===t.top&&t.bottom===this.getNumberRows(e)-1;return{...t,bottom:i?void 0:t.bottom,right:o&&!i?void 0:t.right}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,o){const i={...this.getPaneDivisions(e)};"COL"===o?i.xSplit=t:"ROW"===o&&(i.ySplit=t),this.history.update("sheets",e,"panes",i)}isEmpty(e,t){return fi(t).map((({col:t,row:o})=>this.getCell({sheetId:e,col:t,row:o}))).every((e=>!e||""===e.content))}getCommandZones(e){const t=[];return"zone"in e&&t.push(e.zone),"target"in e&&t.push(...e.target),"ranges"in e&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),"col"in e&&"row"in e&&t.push({top:e.row,left:e.col,bottom:e.row,right:e.col}),t}checkZonesExistInSheet(e,t){if(!t.every(ei))return 26;if(t.length){const o=this.getSheetZone(e);return t.every((e=>di(e,o)))?0:19}return 0}updateCellPosition(e){const{sheetId:t,cellId:o,col:i,row:s}=e;o?this.setNewPosition(o,t,i,s):this.clearPosition(t,i,s)}setNewPosition(e,t,o,i){const s=this.cellPosition[e];s&&this.clearPosition(t,s.col,s.row),this.history.update("cellPosition",e,{row:i,col:o,sheetId:t}),this.history.update("sheets",t,"rows",i,"cells",o,e)}clearPosition(e,t,o){const i=this.sheets[e]?.rows[o].cells[t];i&&(this.history.update("cellPosition",i,void 0),this.history.update("sheets",e,"rows",o,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++){this.sheets[e].rows[i].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:i})}}createSheet(e,t,o,i,s){const r={id:e,name:t,numberOfCols:o,rows:Oi(i),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},n=this.orderedSheetIds.slice();n.splice(s,0,r.id);const a=this.sheets;return this.history.update("orderedSheetIds",n),this.history.update("sheets",Object.assign({},a,{[r.id]:r})),r}moveSheet(e,t){const o=this.orderedSheetIds.slice(),i=o.findIndex((t=>t===e)),s=o.splice(i,1);let r=this.findIndexOfTargetSheet(i,t);o.splice(r,0,s[0]),this.history.update("orderedSheetIds",o)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(r("There is not enough visible sheets"))}checkSheetName(e){const t=this.getters.tryGetSheetName(e.sheetId);if(void 0!==t&&e.name===t)return 11;const{orderedSheetIds:o,sheets:i}=this,s=e.name&&e.name.trim().toLowerCase();return o.find((t=>i[t]?.name.toLowerCase()===s&&t!==e.sheetId))?12:le.test(s)?14:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?16:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:75}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:75}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.top<e.quantity&&e.quantity<=o.bottom)return 66;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.left<e.quantity&&e.quantity<=o.right)return 66;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const o=e.name;this.history.update("sheets",e.id,"name",t.trim());const i=Object.assign({},this.sheetIdsMapName);delete i[o],i[t]=e.id,this.history.update("sheetIdsMapName",i)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const o=this.getSheet(e),i=this.getDuplicateSheetName(o.name),s=Se(o);s.id=t,s.name=i;for(let e=0;e<=s.numberOfCols;e++)for(let t=0;t<=s.rows.length;t++)s.rows[t]&&(s.rows[t].cells[e]=void 0);const r=this.orderedSheetIds.slice(),n=r.indexOf(e);r.splice(n+1,0,s.id),this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},this.sheets,{[s.id]:s}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:o}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:s.id,col:e,row:o,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[s.name]=s.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this)),i=r("Copy of %s",e);let s=i.toString();for(;o.includes(s);)s=`${i} (${t})`,t++;return s}deleteSheet(e){const t=e.name,o=Object.assign({},this.sheets);delete o[e.id],this.history.update("sheets",o);const i=this.orderedSheetIds.slice(),s=i.indexOf(e.id);i.splice(s,1),this.history.update("orderedSheetIds",i);const r=Object.assign({},this.sheetIdsMapName);delete r[t],this.history.update("sheetIdsMapName",r)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let o of t)this.moveCellOnColumnsDeletion(e,o);const o=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",o-t.length);const i=t.filter((t=>t<e.panes.xSplit)).length;i&&this.setPaneDivisions(e.id,e.panes.xSplit-i,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let o of Ne(t))this.moveCellOnRowsDeletion(e,o[o.length-1],o[0]),o.map((t=>this.updateRowsStructureOnDeletion(t,e)));const o=t.filter((t=>t<e.panes.ySplit)).length;o&&this.setPaneDivisions(e.id,e.panes.ySplit-o,"ROW")}addColumns(e,t,o,i){const s="before"===o?t:t+1;this.moveCellsOnAddition(e,s,i,"columns");const r=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",r+i),s<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+i,"COL")}addRows(e,t,o,i){const s="before"===o?t:t+1;this.addEmptyRows(e,i),this.moveCellsOnAddition(e,s,i,"rows"),this.updateRowsStructureOnAddition(e,t,i),s<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+i,"ROW")}moveCellOnColumnsDeletion(e,t){for(let o=0;o<e.rows.length;o++){const i=e.rows[o];for(let s in i.cells){const r=Number(s),n=i.cells[s];n&&(r===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:r,row:o}),r>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:r-1,row:o}))}}}moveCellsOnAddition(e,t,o,i){const s=[];for(let r=0;r<e.rows.length;r++){const n=e.rows[r];if("rows"!==i||r>=t)for(let a in n.cells){const l=Number(a),c=n.cells[a];c&&("rows"===i||l>=t)&&s.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===i?o:0),row:r+("rows"===i?o:0)})}}for(let e of s.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,o){const i=o-t+1;for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if(s>=t&&s<=o)for(let t in r.cells){const o=Number(t);r.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:o,row:s})}if(s>o)for(let t in r.cells){const o=Number(t),n=r.cells[t];n&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:o,row:s-i})}}}updateRowsStructureOnDeletion(e,t){const o=[],i=t.rows.map((e=>e.cells));for(let s in t.rows)Number(s)!==e&&o.push({cells:i.shift()});this.history.update("sheets",t.id,"rows",o)}updateRowsStructureOnAddition(e,t,o){const i=[],s=e.rows.map((e=>e.cells));e.rows.forEach((()=>i.push({cells:s.shift()}))),this.history.update("sheets",e.id,"rows",i)}addEmptyRows(e,t){const o=e.rows.slice();for(let e=0;e<t;e++)o.push({cells:{}});this.history.update("sheets",e.id,"rows",o)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(Rt);let o=e.rowNumber,i=e.colNumber;for(let{col:e,row:s}of t)o=Math.max(o,s+1),i=Math.max(i,e+1);return{rowNumber:o,colNumber:i}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?28:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?13:0}checkZonesAreInSheet(e){return"sheetId"in e?this.checkZonesExistInSheet(e.sheetId,this.getCommandZones(e)):0}}).add("header visibility",class extends IE{static getters=["canRemoveHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];hiddenHeaders={};allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 28;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),o="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=o?67:Math.min(...e.elements)<0||Math.max(...e.elements)>o?87:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.canRemoveHeaders(e.sheetId,e.dimension,e.elements)?0:8:28}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,Se(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],o=je(e.position,e.base);t.splice(o,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}canRemoveHeaders(e,t,o){const i=this.getAllVisibleHeaders(e,t);return s=o,!i.every((e=>s.includes(e)));var s}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],o=this.hiddenHeaders[e].COL;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],o=this.hiddenHeaders[e].ROW;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getAllVisibleHeaders(e,t){return Oe(0,this.hiddenHeaders[e][t].length).filter((o=>!this.hiddenHeaders[e][t][o]))}import(e){for(let t of e.sheets){this.hiddenHeaders[t.id]={COL:[],ROW:[]};for(let e=0;e<t.rowNumber;e++)this.hiddenHeaders[t.id].ROW[e]=Boolean(t.rows[e]?.isHidden);for(let e=0;e<t.colNumber;e++)this.hiddenHeaders[t.id].COL[e]=Boolean(t.cols[e]?.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e=0;e<this.getters.getNumberRows(o.id);e++)(t||this.hiddenHeaders[o.id].ROW[e])&&(void 0===o.rows[e]&&(o.rows[e]={}),o.rows[e].isHidden=this.hiddenHeaders[o.id].ROW[e]);void 0===o.cols&&(o.cols={});for(let e=0;e<this.getters.getNumberCols(o.id);e++)(t||this.hiddenHeaders[o.id].COL[e])&&(void 0===o.cols[e]&&(o.cols[e]={}),o.cols[e].isHidden=this.hiddenHeaders[o.id].COL[e])}}}).add("filters",class extends IE{static getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId","getFilterHeaders","isFilterHeader"];tables={};allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!xi(...e.target))return 82;const t=ni(...e.target),o=()=>this.getFilterTables(e.sheetId).some((e=>ci(e.zone,t)))?79:0,i=()=>{const o=this.getters.getMergesInZone(e.sheetId,t);for(let e of o)if(ci(t,e))return 81;return 0};return this.checkValidations(e,o,i);case"ADD_MERGE":for(let t of e.target)for(let o of this.getFilterTables(e.sheetId))if(ci(o.zone,t))return 81}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":const o={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=Se(t);o[e.id]=e}this.history.update("tables",e.sheetIdTo,o);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=ni(...e.target),o=this.createFilterTable(t);this.history.update("tables",e.sheetId,o.id,o);break}case"REMOVE_FILTER_TABLE":{const t={};for(const o of this.getFilterTables(e.sheetId))e.target.every((e=>!ai(e,o.zone)))&&(t[o.id]=o);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let o of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,o)&&this.extendTableDown(t,o);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(He):[]}getFilter(e){return this.getFilterTable(e)?.filters.find((t=>t.col===e.col))}getFilterId(e){return this.getFilter(e)?.id}getFilterTable({sheetId:e,col:t,row:o}){return this.getFilterTables(e).find((e=>hi(t,o,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>di(e.zone,t)))}doesZonesContainFilter(e,t){for(const o of t)for(const t of this.getFilterTables(e))if(ai(o,t.zone))return!0;return!1}getFilterHeaders(e){const t=[];for(let o of this.getFilterTables(e)){const e=o.zone,i=e.top;for(let o=e.left;o<=e.right;o++)t.push({col:o,row:i})}return t}isFilterHeader({sheetId:e,col:t,row:o}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===o))}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=oi(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i=[];for(const o of t.filters){const t=oi(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);i.push(new OE(o.id,t))}if(i.length<pi(o).numberOfCols){for(let e=o.left;e<=o.right;e++)i.find((t=>t.col===e))||i.push(new OE(this.uuidGenerator.uuidv4(),{...o,left:e,right:e}));i.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=ri(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(o){if(ti(o)!==ti(t.zone)){const i=[];for(const o of t.filters){const t=ri(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&i.push(new OE(o.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}else{const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o)}}}createFilterTable(e){return new AE(e)}extendTableDown(e,t){const o={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",o);for(let o=0;o<t.filters.length;o++){const i=t.filters[o],s={...i.zoneWithHeaders,bottom:i.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",o,"zoneWithHeaders",s)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:o,row:i},s){if(!e)return;const r=s.zone;if(!(r.bottom+1===i&&o>=r.left&&o<=r.right))return!1;for(const e of Oe(r.left,r.right+1)){const o={sheetId:t,col:e,row:i},s=this.getters.getCell(o)?.content;if(s)return!1;if(this.getters.getFilter(o))return!1;if(this.getters.isInMerge(o))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const o=this.createFilterTable(Jo(e.range));this.history.update("tables",t.id,o.id,o)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:ti(e.zone)})}exportForExcel(e){this.export(e)}}).add("cell",class extends IE{static getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];nextId=1;cells={};adaptRanges(e,t){for(const o of Object.keys(this.cells))for(const i of Object.values(this.cells[o]||{}))if(i.isFormula)for(const s of i.dependencies)if(!t||s.sheetId===t){const t=e(s);"NONE"!==t.changeType&&this.history.update("cells",o,i.id,"dependencies",i.dependencies.indexOf(s),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,o){for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let s=i.left;s<=i.right;s++)this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,format:o})}clearFormatting(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:null,format:""})}handleAddColumnsRows(e,t){let o,i;"before"===e.position?(o=Oe(e.base,e.base+e.quantity),i=e.base+e.quantity):(o=Oe(e.base+1,e.base+e.quantity+1),i=e.base),t(e.sheetId,i,o)}import(e){for(let t of e.sheets)for(let o in t.cells){const i=t.cells[o],{col:s,row:r}=Rt(o);if(i?.content||i?.format||i?.style){const o=this.importCell(t.id,i,e.styles,e.formats);this.history.update("cells",t.id,o.id,o),this.dispatch("UPDATE_CELL_POSITION",{cellId:o.id,col:s,row:r,sheetId:t.id})}}}export(e){const t={},o={};for(let i of e.sheets){const e={},s=Object.keys(this.cells[i.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const i of s){const s=this.getters.getCell(i);e[Tt(i.col,i.row)]={style:s.style?We(s.style,t):void 0,format:s.format?We(s.format,o):void 0,content:s.content||void 0}}i.cells=e}e.styles=t,e.formats=o}importCell(e,t,o,i){const s=t.style&&o[t.style]||void 0,r=t.format&&i[t.format]||void 0,n=this.getNextUid();return this.createCell(n,t?.content||"",r,s,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const o=this.cells[t][e];if(o)return o}}buildFormulaContent(e,t,o){const i=o||[...t.dependencies];return Ge(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=i.shift();return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){return this.getters.getCell(e)?.style||{}}zoneToXC(e,t,o=[{colFixed:!1,rowFixed:!1}]){const i=Tt((t=this.getters.expandZone(e,t)).left,t.top,o[0]),s=Tt(t.right,t.bottom,o.length>1?o[1]:o[0]),r=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),n=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=r.col===n.col&&r.row===n.row;return i==s||a?i:i+":"+s}setStyle(e,t,o){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let s=i.top;s<=i.bottom;s++){const i=this.getters.getCell({sheetId:e,col:t,row:s});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:s,style:o?{...i?.style,...o}:void 0})}}copyColumnStyle(e,t,o){for(let i=0;i<this.getters.getNumberRows(e);i++){const s=this.getFormat(e,t,i);if(s.style||s.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,...s})}}copyRowStyle(e,t,o){for(let i=0;i<this.getters.getNumberCols(e);i++){const s=this.getFormat(e,i,t);if(s.style||s.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:i,row:t,...s})}}getFormat(e,t,o){const i={},s=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),r=this.getters.getCell(s);return r&&(r.style&&(i.style=r.style),r.format&&(i.format=r.format)),i}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,o,i){const s=this.getters.getCell({sheetId:e,col:t,row:o}),r="content"in i||"formula"in i,n=r?ot(i?.content):s?.content||"";let a;a=void 0!==i.style?i.style||void 0:s?s.style:void 0;const l=this.getters.getLocale();let c=("format"in i?i.format:s&&s.format)||_o(n,l)||Fo(n);if((r&&!n&&!i.formula||!r&&(!s||""===s.content))&&!a&&!c)return void(s&&(this.history.update("cells",e,s.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:o,sheetId:e})));const h=s?.id||this.getNextUid(),d=this.createCell(h,n,c,a,e);this.history.update("cells",e,d.id,d),this.dispatch("UPDATE_CELL_POSITION",{cellId:d.id,col:t,row:o,sheetId:e})}createCell(e,t,o,i,s){if(!t.startsWith("="))return this.createLiteralCell(e,t,o,i);try{return this.createFormulaCell(e,t,o,i,s)}catch(s){return this.createErrorFormula(e,t,o,i,s)}}createLiteralCell(e,t,o,i){return{id:e,content:t=qs(t,this.getters.getLocale()).toString(),style:i,format:o,isFormula:!1}}createFormulaCell(e,t,o,i,s){const r=Gu(t);return r.dependencies.length?this.createFormulaCellWithDependencies(e,r,o,i,s):{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:r,dependencies:[]}}createFormulaCellWithDependencies(e,t,o,i,s){const r=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(s,e)));return new RE(e,t,o,i,r,s,this.buildFormulaContent.bind(this))}createErrorFormula(e,t,o,i,s){return{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:{dependencies:[],tokens:au(t),execute:function(){throw s}},dependencies:[]}}checkCellOutOfSheet(e,t,o){if(!this.getters.tryGetSheet(e))return 28;return hi(t,o,this.getters.getSheetZone(e))?0:19}}).add("merge",class extends IE{static getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge","getSelectionRangeString"];nextId=1;merges={};mergeCellMap={};allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const o of Object.values(t).filter(He))this.addMerge(e.sheetIdTo,o.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const o=t?[t]:Object.keys(this.merges);for(const t of o)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(He)}getMerge({sheetId:e,col:t,row:o}){const i=this.mergeCellMap[e],s=i?t in i&&i[t]?.[o]:void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){const o=this.mergeCellMap[e];if(!o)return[];const i=new Set;for(const{col:e,row:s}of fi(t)){const t=o[e]?.[s];t&&i.add(t)}return Array.from(i).map((t=>this.getMergeById(e,t))).filter(He)}getSelectionRangeString(e,t){const o=Ii.fromRange(e,this.getters),i=this.getters.expandZone(o.sheetId,o.zone),s=o.clone({zone:{...i,bottom:o.isFullCol?void 0:i.bottom,right:o.isFullRow?void 0:i.right}}),r=this.getters.getRangeString(s,t);if(this.isSingleCellOrMerge(o.sheetId,o.zone)){const{sheetName:e,xc:t}=Ko(r);return`${void 0!==e?Ee(e)+"!":""}${t.split(":")[0]}`}return r}doesIntersectMerge(e,t){return fi(t).some((({col:t,row:o})=>void 0!==this.getMerge({sheetId:e,col:t,row:o})))}doesColumnsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let s=0;s<this.getters.getNumberRows(e);s++)if(this.isInSameMerge(i.id,t,s,o,s))return!0;return!1}doesRowsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let s=0;s<=this.getters.getNumberCols(e);s++)if(this.isInSameMerge(i.id,s,t,s,o))return!0;return!1}expandZone(e,t){let{left:o,right:i,top:s,bottom:r}=t,n={left:o,right:i,top:s,bottom:r};for(let t in this.merges[e]){const o=this.getMergeById(e,parseInt(t));o&&ci(o,n)&&(n=ni(o,n))}return li(n,t)?n:this.expandZone(e,n)}isInSameMerge(e,t,o,i,s){const r=this.getMerge({sheetId:e,col:t,row:o}),n=this.getMerge({sheetId:e,col:i,row:s});return!(!r||!n)&&li(r,n)}isInMerge({sheetId:e,col:t,row:o}){const i=this.mergeCellMap[e];return!!i&&(t in i&&Boolean(i[t]?.[o]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:o}=this.getMerge(e);return{sheetId:e.sheetId,col:o,row:t}}isMergeHidden(e,t){const o=this.getters.getHiddenColsGroups(e),i=this.getters.getHiddenRowsGroups(e);for(let e of o)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of i)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const o=this.getMerge({sheetId:e,col:t.left,row:t.top});if(o)return li(t,o);const{numberOfCols:i,numberOfRows:s}=pi(t);return 1===i&&1===s}isMergeDestructive(e,t){let{left:o,right:i,top:s,bottom:r}=t;i=we(i,0,this.getters.getNumberCols(e)-1),r=we(r,0,this.getters.getNumberRows(e)-1);for(let t=s;t<=r;t++)for(let r=o;r<=i;r++)if(r!==o||t!==s){const o=this.getters.getCell({sheetId:e,col:r,row:t});if(o&&""!==o.content)return!0}return!1}getMergeById(e,t){const o=this.merges[e]?.[t];return void 0!==o?ME(t,o):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const o of e)if(t!==o&&ci(t,o))return 66;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<o&&e.right>=o||e.top<i&&e.bottom>=i)return 76;return 0}checkMergedContentUpdate(e){const{col:t,row:o,content:i}=e;if(void 0===i)return 0;const{col:s,row:r}=this.getMainCellPosition(e);return s===t&&r===o?0:4}checkMergeExists(e){const{sheetId:t,target:o}=e;for(const e of o){const{left:o,top:i}=e,s=this.getMerge({sheetId:t,col:o,row:i});if(void 0===s||!li(e,s))return 5}return 0}addMerge(e,t){let{left:o,right:i,top:s,bottom:r}=t;i=we(i,0,this.getters.getNumberCols(e)-1),r=we(r,0,this.getters.getNumberRows(e)-1);if(Tt(o,s)===Tt(i,r))return;const n=this.getters.getCell({sheetId:e,col:o,row:s});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,ti({left:o,top:s,right:i,bottom:r})));let l=new Set;for(let t=s;t<=r;t++)for(let r=o;r<=i;r++){r===o&&t===s||this.dispatch("UPDATE_CELL",{sheetId:e,col:r,row:t,style:n?n.style:null,content:""});const i=this.getMerge({sheetId:e,col:r,row:t});i&&l.add(i.id),this.history.update("mergeCellMap",e,r,t,a)}for(let t of l){const{top:o,bottom:i,left:s,right:r}=this.getMergeById(e,t);for(let t=o;t<=i;t++)for(let o=s;o<=r;o++){const i={sheetId:e,col:o,row:t},s=this.getMerge(i);s&&s.id===a||(this.history.update("mergeCellMap",e,o,t,void 0),this.dispatch("CLEAR_CELL",i))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:o,top:i,bottom:s,right:r}=t,n=this.getMerge({sheetId:e,col:o,row:i});if(void 0!==n&&li(t,n)){this.history.update("merges",e,n.id,void 0);for(let t=i;t<=s;t++)for(let i=o;i<=r;i++)this.history.update("mergeCellMap",e,i,t,void 0)}}applyRangeChangeOnSheet(e,t){const o=Object.entries(this.merges[e]||{});for(const[i,s]of o)if(s){const o=s.zone,r=t(s);switch(r.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,o);break;default:const{numberOfCols:t,numberOfRows:s}=pi(r.range.zone);1===t&&1===s?this.removeMerge(e,o):this.history.update("merges",e,parseInt(i,10),r.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:o,row:i}of fi(t))this.history.update("mergeCellMap",e,o,i,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let o of t)this.addMerge(e,Jo(o))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...NE(e))}}exportForExcel(e){this.export(e)}}).add("headerSize",class extends IE{static getters=["getRowSize","getColSize"];sizes={};handle(e){switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),o={COL:t.COL.map((e=>({manualSize:void 0,computedSize:qe(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:qe(e)})))};this.history.update("sizes",e.sheetId,o);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Se(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const t={...this.sizes};delete t[e.sheetId],this.history.update("sizes",t);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);const o=Math.min(...e.elements);t=t.map(((t,i)=>"ROW"===e.dimension&&i>=o?{manualSize:t.manualSize,computedSize:qe((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const o=je(e.position,e.base),i=t[e.base];t.splice(o,0,...Array(e.quantity).fill(i)),t=t.map(((t,o)=>"ROW"===e.dimension&&o>e.base+e.quantity?{manualSize:t.manualSize,computedSize:qe((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const o=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:qe(o)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:qe(e.size||D)});break;case"UPDATE_CELL":if(!this.sizes[e.sheetId]?.ROW?.[e.row]?.manualSize){const{sheetId:t,row:o}=e;this.history.update("sizes",t,"ROW",o,"computedSize",qe((()=>this.getRowTallestCellSize(t,o))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let o of Oe(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,o);t!==this.getRowSize(e.sheetId,o)&&this.history.update("sizes",e.sheetId,"ROW",o,"computedSize",qe(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,o){return Math.round(this.sizes[e]?.[t][o]?.manualSize||this.sizes[e]?.[t][o]?.computedSize()||this.getDefaultHeaderSize(t))}computeSheetSizes(e){const t={COL:[],ROW:[]};for(let o of Oe(0,this.getters.getNumberCols(e)))t.COL.push(this.getHeaderSize(e,"COL",o));for(let o of Oe(0,this.getters.getNumberRows(e))){let i=this.sizes[e]?.ROW?.[o].manualSize;if(!i){i=this.getRowTallestCellSize(e,o)}t.ROW.push(i)}return t}getDefaultHeaderSize(e){return"COL"===e?D:L}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return L;return function(e){return e&&e.content?ye(Ae(e.style),e.isFormula?1:e.content.split(pe).length)+2*B:L}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const o=this.getters.getRowCells(e,t);let i=0;for(let e=0;e<o.length;e++){const t=this.getters.getCellById(o[e]);if(!t)continue;const s=this.getters.getCellPosition(t.id),r=this.getCellHeight(s);r>i&&r>L&&(i=r)}return i<=L?L:i}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[o,i]of Object.entries(t.rows))i.size&&(e.ROW[o]=i.size);for(let[o,i]of Object.entries(t.cols))i.size&&(e.COL[o]=i.size);const o=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:o.COL.map(((t,o)=>({manualSize:e.COL[o],computedSize:qe(t)}))),ROW:o.ROW.map(((t,o)=>({manualSize:e.ROW[o],computedSize:qe(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e of Oe(0,this.getters.getNumberRows(o.id)))(t||this.sizes[o.id].ROW[e]?.manualSize)&&(o.rows[e]={...o.rows[e],size:this.getRowSize(o.id,e)});void 0===o.cols&&(o.cols={});for(let e of Oe(0,this.getters.getNumberCols(o.id)))(t||this.sizes[o.id].COL[e]?.manualSize)&&(o.cols[e]={...o.cols[e],size:this.getColSize(o.id,e)})}}}).add("borders",class extends IE{static getters=["getCellBorder","getBordersColors"];borders={};handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const o=t.slice().map((e=>e?.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,o)}break;case"DELETE_SHEET":const o={...this.borders};delete o[e.sheetId],this.history.update("borders",o);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_ZONE_BORDERS":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border.position,""===e.border.color?void 0:{style:e.border.style||Y,color:e.border.color||X})}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,o;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,o)}handleAddRows(e){let t,o;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,o)}getCellBorder({sheetId:e,col:t,row:o}){const i={top:this.borders[e]?.[t]?.[o]?.horizontal,bottom:this.borders[e]?.[t]?.[o+1]?.horizontal,left:this.borders[e]?.[t]?.[o]?.vertical,right:this.borders[e]?.[t+1]?.[o]?.vertical};return i.bottom||i.left||i.right||i.top?i:null}getBordersColors(e){const t=[],o=this.borders[e];if(o)for(const e of o.filter(He))for(const o of e)o?.horizontal&&t.push(o.horizontal.color),o?.vertical&&t.push(o.vertical.color);return t}ensureColumnBorderContinuity(e,t,o){const i=Oe(t+1,o);for(let s=0;s<this.getters.getNumberRows(e);s++){const r=this.getCellBorder({sheetId:e,col:t,row:s}),n=this.getCellBorder({sheetId:e,col:o,row:s});if(r&&n){const t=this.getCommonSides(r,n);for(let o of i)this.addBorder(e,o,s,t)}}}ensureRowBorderContinuity(e,t,o){const i=Oe(t+1,o);for(let s=0;s<this.getters.getNumberCols(e);s++){const r=this.getCellBorder({sheetId:e,col:s,row:t}),n=this.getCellBorder({sheetId:e,col:s,row:o});if(r&&n){const t=this.getCommonSides(r,n);for(let o of i)this.addBorder(e,s,o,t)}}}getCommonSides(e,t){const o={};for(let i of["top","bottom","left","right"])e[i]&&e[i]===t[i]&&(o[i]=e[i]);return o}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?Oe(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,o,{moveFirstLeftBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfColumn(e,t,o,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((s=>{(s===t&&i||s!==t)&&this.moveBordersOfColumn(e,s,o,"vertical"),this.moveBordersOfColumn(e,s,o,"horizontal")})))}shiftBordersVertically(e,t,o,{moveFirstTopBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfRow(e,t,o,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((s=>{(s===t&&i||s!==t)&&this.moveBordersOfRow(e,s,o,"horizontal"),this.moveBordersOfRow(e,s,o,"vertical")})))}moveBordersOfRow(e,t,o,i,{destructive:s}={destructive:!0}){const r=this.borders[e];r&&this.getColumnsWithBorders(e).forEach((n=>{const a=r[n]?.[t+o]?.[i],l=r[n]?.[t]?.[i];this.history.update("borders",e,n,t+o,i,s?l:l||a),this.history.update("borders",e,n,t,i,void 0)}))}moveBordersOfColumn(e,t,o,i,{destructive:s}={destructive:!0}){const r=this.borders[e];r&&this.getRowsRange(e).forEach((n=>{const a=r[t+o]?.[n]?.[i],l=r[t]?.[n]?.[i];this.history.update("borders",e,t+o,n,i,s?l:l||a),this.history.update("borders",e,t,n,i,void 0)}))}setBorder(e,t,o,i,s=!0){!s&&this.borders?.[e]?.[t]?.[o]?.vertical||this.history.update("borders",e,t,o,"vertical",i?.left),!s&&this.borders?.[e]?.[t]?.[o]?.horizontal||this.history.update("borders",e,t,o,"horizontal",i?.top),!s&&this.borders?.[e]?.[t+1]?.[o]?.vertical||this.history.update("borders",e,t+1,o,"vertical",i?.right),!s&&this.borders?.[e]?.[t]?.[o+1]?.horizontal||this.history.update("borders",e,t,o+1,"horizontal",i?.bottom)}clearBorders(e,t){for(let o of t){for(let t=o.top;t<=o.bottom;t++){this.history.update("borders",e,o.right+1,t,"vertical",void 0);for(let i=o.left;i<=o.right;i++)this.history.update("borders",e,i,t,void 0)}for(let t=o.left;t<=o.right;t++)this.history.update("borders",e,t,o.bottom+1,"horizontal",void 0)}}addBorder(e,t,o,i){this.setBorder(e,t,o,{...this.getCellBorder({sheetId:e,col:t,row:o}),...i})}setBorders(e,t,o,i){if("clear"===o)return this.clearBorders(e,t);for(let s of t){if("h"===o||"hv"===o||"all"===o)for(let t=s.top+1;t<=s.bottom;t++)for(let o=s.left;o<=s.right;o++)this.addBorder(e,o,t,{top:i});if("v"===o||"hv"===o||"all"===o)for(let t=s.top;t<=s.bottom;t++)for(let o=s.left+1;o<=s.right;o++)this.addBorder(e,o,t,{left:i});if("left"===o||"all"===o||"external"===o)for(let t=s.top;t<=s.bottom;t++)this.addBorder(e,s.left,t,{left:i});if("right"===o||"all"===o||"external"===o)for(let t=s.top;t<=s.bottom;t++)this.addBorder(e,s.right+1,t,{left:i});if("top"===o||"all"===o||"external"===o)for(let t=s.left;t<=s.right;t++)this.addBorder(e,t,s.top,{top:i});if("bottom"===o||"all"===o||"external"===o)for(let t=s.left;t<=s.right;t++)this.addBorder(e,t,s.bottom+1,{top:i})}}addBordersToMerge(e,t){const{left:o,right:i,top:s,bottom:r}=t,n=this.getCellBorder({sheetId:e,col:o,row:s}),a=this.getCellBorder({sheetId:e,col:i,row:r});this.clearBorders(e,[t]),n?.top&&this.setBorders(e,[{...t,bottom:s}],"top",n.top),n?.left&&this.setBorders(e,[{...t,right:o}],"left",n.left),a?.bottom?this.setBorders(e,[{...t,top:r}],"bottom",a.bottom):n?.bottom&&this.setBorders(e,[{...t,top:r}],"bottom",n.bottom),a?.right?this.setBorders(e,[{...t,left:i}],"right",a.right):n?.right&&this.setBorders(e,[{...t,left:i}],"right",n.right)}import(e){if(Object.keys(e.borders||{}).length)for(let t of e.sheets)for(const o in t.cells){const i=t.cells[o];if(i?.border){const s=e.borders[i.border],{col:r,row:n}=Rt(o);this.setBorder(t.id,r,n,s,!1)}}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,Jo(e))}export(e){let t=0;const o={};function i(e){for(let[t,i]of Object.entries(o))if(fe(i)===fe(e))return parseInt(t,10);return o[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let o=0;o<t.rowNumber;o++){const s=this.getCellBorder({sheetId:t.id,col:e,row:o});if(s){const r=Tt(e,o),n=t.cells[r],a=i(s);n?n.border=a:t.cells[r]={border:a}}}e.borders=o}exportForExcel(e){this.export(e)}}).add("conditional formatting",class extends IE{static getters=["getConditionalFormats","getRulesSelection","getRulesByCell","getAdaptedCfRanges"];cfRules={};loopThroughRangesOfSheet(e,t){for(const o of this.cfRules[e])for(const i of o.ranges){const s=t(i);switch(s.changeType){case"REMOVE":let t=o.ranges.slice();t.splice(o.ranges.indexOf(i),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",t):this.removeConditionalFormatting(o.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",o.ranges.indexOf(i),s.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const o={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(o,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){return this.cfRules[e]?.map((t=>this.mapToConditionalFormat(e,t)))||[]}getRulesSelection(e,t){const o=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{o.add(e)}))})),Array.from(o)}getRulesByZone(e,t){const o=new Set;for(let i=t.top;i<=t.bottom;i++)for(let s=t.left;s<=t.right;s++){this.getRulesByCell(e,s,i).forEach((e=>{o.add(e.id)}))}return o}getRulesByCell(e,t,o){const i=[];for(let s of this.cfRules[e])for(let e of s.ranges)hi(t,o,e.zone)&&i.push(s);return new Set(i.map((t=>this.mapToConditionalFormat(e,t))))}getAdaptedCfRanges(e,t,o,i){if(0===o.length&&0===i.length)return;const s=this.getters.getConditionalFormats(e),r=s.findIndex((e=>e.id===t.id));let n=[];return r>-1&&(n=s[r].ranges),n=n.concat(o),ui(n,i)}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const o={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return o}addConditionalFormatting(e,t){const o=this.cfRules[t].slice(),i=o.findIndex((t=>t.id===e.id)),s=this.mapToConditionalFormatInternal(t,e);i>-1?o.splice(i,1,s):o.push(s),this.history.update("cfRules",t,o)}checkValidReordering(e,t,o){if(!this.cfRules[o])return 28;const i=this.cfRules[o].findIndex((t=>t.id===e));if(-1===i)return 72;const s="up"===t?i-1:i+1;return s<0||s>=this.cfRules[o].length?72:0}checkEmptyRange(e){return e.ranges.length?0:25}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return o=>{if(t.includes(o.operator)){const t=[],i=e=>void 0===e||""===e;return e>=1&&i(o.values[0])&&t.push(52),e>=2&&i(o.values[1])&&t.push(53),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 54;case"max":return 56;case"mid":return 55;case"upperInflectionPoint":return 57;case"lowerInflectionPoint":return 58}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{Gu(e.value||"")}catch(e){switch(t){case"min":return 59;case"max":return 61;case"mid":return 60;case"upperInflectionPoint":return 62;case"lowerInflectionPoint":return 63}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,o=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(o)?49:0}checkMinBiggerThanMax(e){const t=e.minimum.value,o=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&TE(t)>=TE(o)?48:0}checkMidBiggerThanMax(e){const t=e.midpoint?.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&TE(t)>=TE(o)?50:0}checkMinBiggerThanMid(e){const t=e.minimum.value,o=e.midpoint?.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&TE(t)>=TE(o)?51:0}removeConditionalFormatting(e,t){const o=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==o){const e=this.cfRules[t].slice();e.splice(o,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,o){const i=this.cfRules[o].findIndex((t=>t.id===e)),s="up"===t?i-1:i+1;if(!(s<0||s>=this.cfRules[o].length)&&-1!==i&&-1!==s){const e=[...this.cfRules[o]],t=e[i];e[i]=e[s],e[s]=t,this.history.update("cfRules",o,e)}}}).add("figures",class extends IE{static getters=["getFigures","getFigure","getFigureSheetId"];figures={};allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:o,...i}=e,s=i;this.updateFigure(o,s);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId);break;case"REMOVE_COLUMNS_ROWS":this.onRowColDelete(e.sheetId,e.dimension)}}onRowColDelete(e,t){"ROW"===t?this.onRowDeletion(e):this.onColDeletion(e)}onRowDeletion(e){const t=this.getters.getNumberRows(e);let o=0;for(let i=0;i<t;i++)o+=this.getters.getRowSize(e,i);const i=this.getters.getFigures(e);for(const t of i){const i=Math.min(t.y,o-t.height);i!==t.y&&this.dispatch("UPDATE_FIGURE",{sheetId:e,id:t.id,y:i})}}onColDeletion(e){const t=this.getters.getNumberCols(e);let o=0;for(let i=0;i<t;i++)o+=this.getters.getColSize(e,i);const i=this.getters.getFigures(e);for(const t of i){const i=Math.min(t.x,o-t.width);i!==t.x&&this.dispatch("UPDATE_FIGURE",{sheetId:e,id:t.id,x:i})}}updateFigure(e,t){if("id"in t)for(const[o,i]of Object.entries(t))switch(o){case"x":case"y":void 0!==i&&this.history.update("figures",e,t.id,o,Math.max(i,0));break;case"width":case"height":void 0!==i&&this.history.update("figures",e,t.id,o,i)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){return void 0===this.figures[e]?.[t]?71:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>t?.[e]))?83:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(He)}getFigure(e,t){return this.figures[e]?.[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>void 0!==this.figures[t]?.[e]))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const o=void 0;t.figures.push({...e,data:o})}}exportForExcel(e){this.export(e)}}).add("chart",class extends IE{static getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];charts={};createChart=function(e){const t=yp.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,i,s){const r=t.find((e=>e.match(i.type)));if(!r)throw new Error(`No builder for this chart: ${i.type}`);return r.createChart(i,s,e)}}(this.getters);validateChartDefinition=e=>function(e,t){const o=yp.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}(this,e.definition);adaptRanges(e){for(const[t,o]of Object.entries(this.charts))this.history.update("charts",t,o?.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const o of t)if("chart"===o.tag){const t=o.id.split(oe).pop(),i=`${e.sheetIdTo}${oe}${t}`,s=this.charts[o.id]?.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:i,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){return this.charts[e]?.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){const t=this.charts[e]?.type;if(!t)throw new Error("Chart not defined.");return t}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>t?.sheetId===e)).map((([e])=>e))}getChartDefinition(e){const t=this.charts[e]?.getDefinition();if(!t)throw new Error(`There is no chart with the given figureId: ${e}`);return t}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){if(e.sheets)for(let t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(let t of e){const e=t;if(e&&"chart"===e.tag){const t=this.charts[e.id]?.getDefinition();t&&(e.data=t,o.push(e))}else o.push(e)}t.figures=o}}exportForExcel(e){for(let t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(let t of e)if(t&&"chart"===t.tag){const e=this.charts[t.id]?.getDefinitionForExcel();e&&o.push({...t,data:e})}t.charts=o}}addFigure(e,t,o={x:0,y:0},i={width:536,height:335}){if(this.getters.getFigure(t,e))return;const s={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:s})}addChart(e,t){const o=this.getters.getFigureSheetId(e);o&&this.history.update("charts",e,this.createChart(e,t,o))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?85:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:86}}).add("image",class extends IE{static getters=["getImage","getImagePath","getImageSize"];fileStore;images={};syncedImages=new Set;constructor(e){super(e),this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?29:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addFigure(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const o of t)if("image"===o.tag){const t=o.id.split(oe).pop(),i=`${e.sheetIdTo}${oe}${t}`,s=this.getImage(o.id);if(s){const t={width:o.width,height:o.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:i,position:{x:o.x,y:o.y},size:t,definition:Se(s)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){const e=new Set(this.getAllImages().map((e=>e.path)));for(const t of this.syncedImages)e.has(t)||this.fileStore?.delete(t)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addFigure(e,t,o,i){const s={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:s})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const o of e)this.history.update("images",t.id,o.id,o.data),this.syncedImages.add(o.data.path)}}export(e){for(const t of e.sheets){const e=t.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=this.images[t.id]?.[o.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(const t of e)if("image"===t?.tag){const e=this.getImage(t.id);e&&o.push({...t,data:Se(e)})}t.images=o}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(He));return e}}),Nw=(new $i).add("ui_sheet",class extends FE{static getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];ctx=document.createElement("canvas").getContext("2d");allowDispatch(e){return this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(e)}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const o=this.getColMaxWidth(e.sheetId,t);0!==o&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:o,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e){const t=this.getCellText(e),o=this.getters.getCellComputedStyle(e),i=t.split(pe);let s=Math.max(...i.map((e=>this.getTextWidth(e,o))));this.getters.getConditionalIcon(e)&&(s+=function(e){return Ae(e)+2*V}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(s+=20),s>0&&(s+=2*H,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,s)}return s}getTextWidth(e,t){return xe(this.ctx,e,t)}getCellText(e,t=!1){const o=this.getters.getCell(e);return t&&o?.isFormula?Qu(o.content,this.getters.getLocale()):this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const o=this.getters.getCellStyle(e),i=this.getters.getCellText(e,this.getters.shouldShowFormulas()),s=[];for(const e of i.split("\n")){const i=e.split(" ");if(!t){s.push(e);continue}let r="",n=t;for(let e of i){const i=this.splitWordToSpecificWidth(this.ctx,e,t,o),a=i.pop(),l=xe(this.ctx,a,o);if(i.length)""!==r&&(s.push(r),r="",n=t),i.forEach((e=>{s.push(e)})),r=a,n=t-l;else{const e=""===r?a:" "+a,i=xe(this.ctx,e,o);i<=n?(r+=e,n-=i):(s.push(r),r=a,n=t-l)}}""!==r&&s.push(r)}return s}getColDimensions(e,t){const o=this.getColRowOffset("COL",0,t,e),i=this.getters.getColSize(e,t);return{start:o,size:i,end:o+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensions(e,t){const o=this.getColRowOffset("ROW",0,t,e),i=this.getters.getRowSize(e,t);return{start:o,size:i,end:o+(this.getters.isRowHidden(e,t)?0:i)}}getColRowOffset(e,t,o,i=this.getters.getActiveSheetId()){if(o<t)return-this.getColRowOffset(e,o,t);let s=0;for(let r=t;r<o;r++)this.getters.isHeaderHidden(i,e,r)||(s+="COL"===e?this.getters.getColSize(i,r):this.getters.getRowSize(i,r));return s}getColMaxWidth(e,t){const o=fi(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...o)}splitWordToSpecificWidth(e,t,o,i){if(xe(e,t,i)<=o)return[t];const s=[];let r="";for(let n of t){xe(e,r+n,i)>o?(s.push(r),r=n):r+=n}return s.push(r),s}checkSheetExists(e){return"sheetId"in e&&void 0===this.getters.tryGetSheet(e.sheetId)?28:0}checkZonesAreInSheet(e){const t="sheetId"in e?e.sheetId:this.getters.tryGetActiveSheetId(),o=this.getters.getCommandZones(e);return!t&&o.length>0?93:t&&o.length>0?this.getters.checkZonesExistInSheet(t,o):0}}).add("header_visibility_ui",class extends FE{static getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,o){return"COL"===t?this.isColHidden(e,o):this.isRowHidden(e,o)}getNextVisibleCellPosition({sheetId:e,col:t,row:o}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",o,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,o,i){if(o<=i)for(let s=o;s<=i;s++)if(this.getters.doesHeaderExist(e,t,s)&&!this.isHeaderHidden(e,t,s))return s;if(o>i)for(let s=o;s>=i;s--)if(this.getters.doesHeaderExist(e,t,s)&&!this.isHeaderHidden(e,t,s))return s}findLastVisibleColRowIndex(e,t,{last:o,first:i}){return Oe(o,i,-1).find((o=>!this.isHeaderHidden(e,t,o)))||i}findFirstVisibleColRowIndex(e,t){const o=this.getters.getNumberHeaders(e,t);for(let i=0;i<o;i++){if("COL"===t&&!this.isColHidden(e,i))return i;if("ROW"===t&&!this.isRowHidden(e,i))return i}}exportForExcel(e){for(const t of e.sheets)for(const[e,o]of Object.entries(t.rows)){const i=this.isRowHidden(t.id,Number(e));o.isHidden=i}}}).add("ui_options",class extends FE{static getters=["shouldShowFormulas"];showFormulas=!1;handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}).add("selectionInputManager",class extends FE{config;static layers=[1];static getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];inputs={};focusedInputId=null;get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e}allowDispatch(e){if("FOCUS_RANGE"===e.type){const t=this.currentInput?.getIndex(e.rangeId);if(this.focusedInputId===e.id&&this.currentInput?.focusedRangeIndex===t)return 30}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_RANGE":case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:Ei({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}break;case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id],o=t.ranges.find((t=>t.id===e.rangeId));if(this.isRangeValid(o?.xc||"A1")){const e=this.getters.getActiveSheetId(),i=this.getters.getRangeFromSheetXC(e,o?.xc||"A1").zone;this.selection.capture(t,{cell:{col:i.left,row:i.top},zone:i},{handleEvent:t.handleEvent.bind(t)})}this.focusedInputId=e.id}}this.currentInput?.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,o)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===o}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:o}=Ko(e);return null!==t.match(qo)&&(!o||void 0!==this.getters.getSheetIdByName(o))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,o=!1){if(this.inputs[e]=new sw(this.config,t,o),0===t.length){const t=this.inputs[e],o={zone:Ei({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,o,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}).add("highlight",class extends FE{static layers=[1];static getters=["getHighlights"];getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{numberOfRows:t,numberOfCols:o}=pi(e.zone),i=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:i}}))}drawGrid(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId(),s=3*o;t.lineWidth=s;const r=this.getHighlights();for(let e of r.filter(((e,t)=>r.findIndex((t=>li(t.zone,e.zone)&&t.sheetId===i))===t))){const{x:o,y:i,width:r,height:n}=this.getters.getVisibleRect(e.zone);r>0&&n>0&&(t.strokeStyle=e.color,t.strokeRect(o+s/2,i+s/2,r-s,n-s),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+s,i+s,r-2*s,n-2*s))}}}).add("grid renderer",class extends FE{static layers=[0,7];static getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];boxes=[];getColDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleCols()),i=this.getters.getColRowOffsetInViewport("COL",o,t),s=this.getters.getColSize(e,t);return{start:i,size:s,end:i+(this.getters.isColHidden(e,t)?0:s)}}getRowDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleRows()),i=this.getters.getColRowOffsetInViewport("ROW",o,t),s=this.getters.getRowSize(e,t);return{start:i,size:s,end:i+(this.getters.isRowHidden(e,t)?0:s)}}getHeaderOffset(e,t,o){let i=this.getters.getColRowOffsetInViewport(e,t,o);return this.getters.isDashboard()||(i+="ROW"===e?_:F),i}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:o}=e,{width:i,height:s}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,i+m,s+m);const r=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),n=r?.1*o:0;if(r)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=o,t.strokeRect(e.x+n,e.y+n,e.width-2*n,e.height-2*n)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let o=e.style;o.fillColor&&"#ffffff"!==o.fillColor&&(t.fillStyle=o.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawOverflowingCellBackground(e){const{ctx:t,thinLineWidth:o}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const i=e.content.align||"left";let s,r;const n=e.y+o/2,a=e.height-o,l=Math.min(e.clipRect?.width||1/0,e.content.width);"left"===i?(s=e.x+o/2,r=l-2*o):"right"===i?(s=e.x+e.width-o/2,r=2*o-l):(s=(e.clipRect?.x||e.x+e.width/2-e.content.width/2)+o/2,r=l-2*o),t.fillStyle="#ffffff",t.fillRect(s,n,r,a)}}drawBorders(e){const{ctx:t}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:s,width:r,height:n}=e;t.left&&o(t.left,i,s,i,s+n),t.top&&o(t.top,i,s,i+r,s),t.right&&o(t.right,i+r,s,i+r,s+n),t.bottom&&o(t.bottom,i,s+n,i+r,s+n)}}function o({style:e,color:o},i,s,r,n){switch(t.strokeStyle=o,e){case"medium":t.lineWidth=2,s+=(i+=s===n?-.5:.5)===(r+=s===n?1.5:.5)?-.5:.5,n+=i===r?1.5:.5;break;case"thick":t.lineWidth=3,s===n&&(i--,r++),i===r&&(s--,n++);break;case"dashed":t.lineWidth=1,t.setLineDash([1,3]);break;case"dotted":t.lineWidth=1,s===n&&(i+=.5,r+=.5),i===r&&(s+=.5,n+=.5),t.setLineDash([1,1]);break;default:t.lineWidth=1}t.beginPath(),t.moveTo(i,s),t.lineTo(r,n),t.stroke(),t.lineWidth=1,t.setLineDash([])}}drawTexts(e){const{ctx:t,thinLineWidth:o}=e;let i;t.textBaseline="top";for(let e of this.boxes)if(e.content){const s=e.style||{},r=e.content.align||"left",n=Te(s);n!==i&&(i=n,t.font=n),t.fillStyle=s.textColor||"#000";let a=e.x;if(a+="left"===r?z+(e.image?e.image.size+V:0):"right"===r?e.width-z-(e.isFilterHeader?20:0):e.width/2,t.textAlign=r,e.clipRect){t.save(),t.beginPath();const{x:o,y:i,width:s,height:r}=e.clipRect;t.rect(o,i,s,r),t.clip()}const l=Ae(s),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let i of e.content.textLines){if(t.fillText(i,Math.round(a),Math.round(h)),s.strikethrough||s.underline){const e=xe(t,i,s);let n=a;"right"===r?n-=e:"center"===r&&(n-=e/2),s.strikethrough&&t.fillRect(n,h+l/2,e,2.6*o),s.underline&&t.fillRect(n,h+l+1,e,1.3*o)}h+=z+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const o=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:o,y:i,width:s,height:r}=e.image.clipIcon;t.rect(o,i,s,r),t.clip()}const i=e.image.size,s=this.computeTextYCoordinate(e,i);t.drawImage(o,e.x+V,s,i,i),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,o=1){const i=e.y+1,s=ye(t,o),r=e.height>s+2*z,n=e.verticalAlign||j;if(r){if("middle"===n)return i+(e.height-s)/2;if("bottom"===n)return i+e.height-s-z}return i+z}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getSheetViewVisibleCols(),s=i[0],r=i[i.length-1],n=this.getters.getSheetViewVisibleRows(),a=n[0],l=n[n.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let o of e)for(let e of Oe(o.left,o.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let o of e)for(let e of Oe(o.top,o.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${Z}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(let e=s;e<=r;e++){const o={left:e,right:e,top:0,bottom:f-1},{x:i,width:s}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),n=E.has(e),a=u.has(e);t.fillStyle=n?r?R:S:a?r?A:v:r?T:b,t.fillRect(i,0,s,_)}for(let e=a;e<=l;e++){const o={top:e,bottom:e,left:0,right:m-1},{y:i,height:s}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),n=w.has(e),a=g.has(e);t.fillStyle=n?r?R:S:a?r?A:v:r?T:b,t.fillRect(0,i,F,s)}t.beginPath(),t.moveTo(F,0),t.lineTo(F,h),t.moveTo(0,_),t.lineTo(c,_),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of i){const o=this.getters.getColSize(p,e),i=Et(e);t.fillStyle=E.has(e)?"#fff":C;let r=this.getHeaderOffset("COL",s,e);t.fillText(i,r+o/2,13),t.moveTo(r+o,0),t.lineTo(r+o,_)}for(const e of n){const o=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let i=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,i+o/2),t.moveTo(0,i+o),t.lineTo(F,i+o)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:s}=this.getters.getMainViewportCoordinates(),r=this.getters.isDashboard()?0:F,n=this.getters.isDashboard()?0:_;t.lineWidth=6*o,t.strokeStyle="#BCBCBC",t.beginPath(),i&&(t.moveTo(r+i,0),t.lineTo(r+i,n)),s&&(t.moveTo(0,n+s),t.lineTo(r,n+s)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:s}=this.getters.getMainViewportCoordinates(),r=this.getters.getSheetViewVisibleCols(),n=r[0],a=r[r.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:n,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:F,u=this.getters.isDashboard()?0:_;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),i&&(t.moveTo(d+i,u),t.lineTo(d+i,h.height+u)),s&&(t.moveTo(d,u+s),t.lineTo(h.width+d,u+s)),t.stroke()}findNextEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let s=e;for(;s<t;){const e={sheetId:i,col:s+1,row:o},t=this.getters.getEvaluatedCell(e),r=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==Qi.empty||this.getters.isInMerge(e)||r?.left)return s;s++}return s}findPreviousEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let s=e;for(;s>t;){const e={sheetId:i,col:s-1,row:o},t=this.getters.getEvaluatedCell(e),r=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==Qi.empty||this.getters.isInMerge(e)||r?.right)return s;s--}return s}computeCellAlignment(e,t){if(this.getters.getCell(e)?.isFormula&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),i=this.getters.getEvaluatedCell(e);return t&&i.type===Qi.number?"center"!==o?"left":o:o||i.defaultAlign}createZoneBox(e,t,o){const{left:i,right:s}=o,r=t.left,n=t.top,a={sheetId:e,col:r,row:n},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===Qi.empty)return f;const b=this.getters.getConditionalIcon(a),v=Ae(f.style),S=b?V+v:0;b&&(f.image={type:"icon",size:v,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:Yb[b].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",y="wrap"!==w||h?void 0:g-2*z,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+z))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===Qi.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||v>p;if(b||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,o;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,o=r):(e=this.findNextEmptyCol(r,s,n),o=this.findPreviousEmptyCol(r,i,n),f.isOverflow=!0),T){case"left":{const o=Ei({col:e,row:n}),{x:i,y:s,width:r,height:a}=this.getters.getVisibleRect(ni(t,o));(r<R||v>a||x.length>1)&&(f.clipRect={x:i,y:s,width:r,height:a});break}case"right":{const e=Ei({col:o,row:n}),{x:i,y:s,width:r,height:a}=this.getters.getVisibleRect(ni(t,e));(r<R||v>a||x.length>1)&&(f.clipRect={x:i,y:s,width:r,height:a});break}case"center":{const i={...t,left:o,right:e},{x:s,y:r,height:n,width:a}=this.getters.getVisibleRect(i),l=R/2,c=f.x+f.width/2;if(s+a<c+l||s>c-l||v>n||x.length>1){const e=s>c-l?s:c-l,t=s+a-e;f.clipRect={x:e,y:r,width:t,height:n}}break}}}else("clip"===w||"wrap"===w||x.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),o=t[0],i=t[t.length-1],s=this.getters.getSheetViewVisibleRows(),r={left:o,right:i,top:s[0],bottom:s[s.length-1]},n=this.getters.getActiveSheetId();for(const o of s)for(const i of t){const t={sheetId:n,col:i,row:o};this.getters.isInMerge(t)||e.push(this.createZoneBox(n,Ei(t),r))}for(const t of this.getters.getMerges(n))if(!this.getters.isMergeHidden(n,t)&&ci(t,r)){const o=this.createZoneBox(n,t,r),i=this.getters.getCellBorder({sheetId:n,col:t.right,row:t.bottom});o.border={...o.border,bottom:i?i.bottom:void 0,right:i?i.right:void 0},o.isMerge=!0,e.push(o)}return e}}).add("autofill",class extends FE{static layers=[5];static getters=["getAutofillTooltip"];autofillZone;steps;lastCellSelected={};direction;tooltip;allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:we(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:we(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:46;case"AUTOFILL_AUTO":const o=this.getters.getSelectedZone();return o.top===o.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border}),this.autofillCF(e.originCol,e.originRow,e.col,e.row)}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),o=this.autofillZone;switch(this.direction){case"down":for(let i=t.left;i<=t.right;i++){const s=[];for(let e=t.top;e<=t.bottom;e++)s.push(Tt(i,e));const r=this.createGenerator(s);for(let t=o.top;t<=o.bottom;t++)this.computeNewCell(r,i,t,e)}break;case"up":for(let i=t.left;i<=t.right;i++){const s=[];for(let e=t.bottom;e>=t.top;e--)s.push(Tt(i,e));const r=this.createGenerator(s);for(let t=o.bottom;t>=o.top;t--)this.computeNewCell(r,i,t,e)}break;case"left":for(let i=t.top;i<=t.bottom;i++){const s=[];for(let e=t.right;e>=t.left;e--)s.push(Tt(e,i));const r=this.createGenerator(s);for(let t=o.right;t>=o.left;t--)this.computeNewCell(r,t,i,e)}break;case"right":for(let i=t.top;i<=t.bottom;i++){const s=[];for(let e=t.left;e<=t.right;e++)s.push(Tt(e,i));const r=this.createGenerator(s);for(let t=o.left;t<=o.right;t++)this.computeNewCell(r,t,i,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const o=this.getters.getSelectedZone();if(hi(e,t,o))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,o.top-1,o.left,o.right),this.steps=o.top-t;break;case"down":this.saveZone(o.bottom+1,t,o.left,o.right),this.steps=t-o.bottom;break;case"left":this.saveZone(o.top,o.bottom,e,o.left-1),this.steps=o.left-e;break;case"right":this.saveZone(o.top,o.bottom,o.right+1,e),this.steps=e-o.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let o=e.left,i=e.bottom;if(o>0){let e=this.getters.getEvaluatedCell({sheetId:t,col:o-1,row:i});for(;e.type!==Qi.empty;)i+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:o-1,row:i})}if(i===e.bottom&&(o=e.right,o<=this.getters.getNumberCols(t))){let e=this.getters.getEvaluatedCell({sheetId:t,col:o+1,row:i});for(;e.type!==Qi.empty;)i+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:o+1,row:i})}i!==e.bottom&&(this.select(e.left,i-1),this.autofill(!0))}computeNewCell(e,t,o,i){const{cellData:s,tooltip:r,origin:n}=e.next(),{content:a,style:l,border:c,format:h}=s;this.tooltip=r,i&&this.dispatch("AUTOFILL_CELL",{originCol:n.col,originRow:n.row,col:t,row:o,content:a,style:l,border:c,format:h})}getRule(e,t){const o=er.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((o=>o.condition(e,t)));return o&&o.generateRule(e,t)}createGenerator(e){const t=[],o=[],i=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:s}=Rt(t),r=this.getters.getCell({sheetId:i,col:e,row:s});o.push({col:e,row:s,cell:r,sheetId:i})}const s=o.map((e=>e.cell));for(let e of o){let o={type:"COPY_MODIFIER"};if(e&&e.cell){o=this.getRule(e.cell,s)||o}const i=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:i},rule:o})}return new GE(t,this.getters,this.direction)}saveZone(e,t,o,i){this.autofillZone={top:e,bottom:t,left:o,right:i}}getDirection(e,t){const o=this.getters.getSelectedZone(),i={up:{number:o.top-t,value:"up"},down:{number:t-o.bottom,value:"down"},left:{number:o.left-e,value:"left"},right:{number:e-o.right,value:"right"}};if(1===Object.values(i).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(i).find((e=>e.number>0?1:0)).value;const s=i.up.number>0?"up":"down",r=i.left.number>0?"left":"right";return Math.abs(i[s].number)>=Math.abs(i[r].number)?i[s].value:i[r].value}autoFillMerge(e,t,o,i){const s=this.getters.getActiveSheetId(),r={sheetId:s,col:o,row:i},n={sheetId:s,col:e,row:t};if(this.getters.isInMerge(r)&&!this.getters.isInMerge(n)){const e=this.getters.getMerge(r);e&&this.dispatch("REMOVE_MERGE",{sheetId:s,target:[e]})}const a=this.getters.getMerge(n);a?.topLeft.col===e&&a?.topLeft.row===t&&this.dispatch("ADD_MERGE",{sheetId:s,target:[{top:i,bottom:i+a.bottom-a.top,left:o,right:o+a.right-a.left}]})}autofillCF(e,t,o,i){const s=this.getters.getActiveSheetId(),r=this.getters.getRulesByCell(s,e,t);for(const e of r){const t=this.getters.getAdaptedCfRanges(s,e,[Tt(o,i)],[]);t&&this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:Se(e),ranges:t.map((e=>this.getters.getRangeDataFromXc(s,e))),sheetId:s})}}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:o}=e,{x:i,y:s,width:r,height:n}=this.getters.getVisibleRect(this.autofillZone);r>0&&n>0&&(t.strokeStyle="black",t.lineWidth=o,t.setLineDash([3]),t.strokeRect(i,s,r,n),t.setLineDash([]))}}).add("find_and_replace",class extends FE{static layers=[3];static getters=["getSearchMatches","getCurrentSelectedMatchIndex"];searchMatches=[];selectedMatchIndex=null;currentSearchRegex=null;searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1};toSearch="";handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(iw.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(iw.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(iw.current)}updateRegex(){let e=ve(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),o=[];if(this.toSearch)for(const i of Object.values(t)){const{col:t,row:s}=this.getters.getCellPosition(i.id);if(i&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:s}))){const e={col:t,row:s,selected:!1};o.push(e)}}return o.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let o;o=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,o=(o%t.length+t.length)%t.length,this.selectedMatchIndex=o,this.selection.selectCell(t[o].col,t[o].row);for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],o=this.getters.getActiveSheetId();if(this.getters.getCell({sheetId:o,...t})?.isFormula&&!this.searchOptions.searchFormulas)this.selectNextCell(iw.next);else{const i=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),s=this.getSearchableString({sheetId:o,col:t.col,row:t.row}).replace(i,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:Xu(s,this.getters.getLocale())}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(iw.current)}}replaceAll(e){const t=this.searchMatches.length;for(let o=0;o<t;o++)this.replace(e)}getSearchableString(e){return this.getters.getCellText(e,this.searchOptions.searchFormulas)}drawGrid(e){const{ctx:t}=e,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const i=this.getters.getMerge({sheetId:o,col:e.col,row:e.row}),s=i?i.left:e.col,r=i?i.right:e.col,n=i?i.top:e.row,a=i?i.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:n,left:s,right:r,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}).add("sort",class extends FE{static getters=["getContiguousZone"];allowDispatch(e){if("SORT_CELLS"===e.type){if(!hi(e.col,e.row,e.zone))throw new Error(r("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;return fi(t).some((({col:t,row:o})=>!this.getters.isInMerge({sheetId:e,col:t,row:o})))?64:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const o=this.getters.getMerges(e).filter((e=>ci(e,t))),i=pi(o[0]);let[s,r]=[i.numberOfCols,i.numberOfRows];return o.every((e=>{let[t,o]=[e.right-e.left+1,e.bottom-e.top+1];return t===s&&o===r}))?0:64}expand(e,t){const{left:o,right:i,top:s,bottom:r}=this.getters.expandZone(e,t);return{left:Math.max(0,o),right:Math.min(this.getters.getNumberCols(e)-1,i),top:Math.max(0,s),bottom:Math.min(this.getters.getNumberRows(e)-1,r)}}checkExpandedValues(e,t){const o=this.expand(e,t);let i;if(this.getters.doesIntersectMerge(e,o)){const{left:t,right:s,top:r,bottom:n}=o;for(let o=t;o<=s;o++)for(let t=r;t<=n;t++){const{col:s,row:r}=this.getters.getMainCellPosition({sheetId:e,col:o,row:t});if(i=this.getters.getEvaluatedCell({sheetId:e,col:s,row:r}),i.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,o))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let o,{top:i,bottom:s,left:r,right:n}=t,a=!1;for(;!a;)a=!0,i>0&&(o=this.checkExpandedValues(e,{left:r-1,right:n+1,top:i-1,bottom:i-1}),o&&(a=!1,i--)),r>0&&(o=this.checkExpandedValues(e,{left:r-1,right:r-1,top:i-1,bottom:s+1}),o&&(a=!1,r--)),n<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:n+1,right:n+1,top:i-1,bottom:s+1}),o&&(a=!1,n++)),s<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:r-1,right:n+1,top:s+1,bottom:s+1}),o&&(a=!1,s++));return{left:r,right:n,top:i,bottom:s}}hasHeader(e,t){if(1===t[0].length)return!1;let o=t.map((t=>t.map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).type))));return o[0][0]===Qi.empty&&(o=o.slice(1)),!o.some((e=>e[0]===Qi.empty))&&!!o.some((e=>e[1]!==Qi.empty&&e[0]!==e[1]))}sortZone(e,t,o,i,s){const[r,n]=this.mainCellsSteps(e,o);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},o),c=this.mainCells(e,o);!s.sortHeaders&&this.hasHeader(e,c)&&(l.top+=n),c=this.mainCells(e,l);const h=function(e,t,o){const i=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let s=i.filter((e=>e.type===Qi.empty)),r=i.filter((e=>e.type!==Qi.empty));o&&(r.push(...s.map((e=>({...e,type:Qi.number,value:0})))),s=[]);const n="descending"===t?-1:1;return r.sort(((e,t)=>{let o=of.indexOf(e.type)-of.indexOf(t.type);return 0===o&&(o=e.type===Qi.text||e.type===Qi.error?e.value.localeCompare(t.value):e.value-t.value),n*o})).concat(s)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),i,Boolean(s.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++){for(let t=0;t<g;t++){let{col:o,row:i,sheetId:s}=c[e][d[t]];const a=this.getters.getCell({sheetId:s,col:o,row:i});let h=l.left+e*r,u=l.top+t*n,g={sheetId:s,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,o=this.getters.createAdaptedRanges(a.dependencies,0,t,s);e=this.getters.buildFormulaContent(s,a,o)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}for(const e of p)this.dispatch("UPDATE_CELL",e)}}mainCellsSteps(e,t){const o=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[o?o.right-o.left+1:1,o?o.bottom-o.top+1:1]}mainCells(e,t){const[o,i]=this.mainCellsSteps(e,t),s=[],r=Oe(t.left,t.right+1,o),n=Oe(t.top,t.bottom+1,i);for(const t of r){const o=[];s.push(o);for(const i of n)o.push({sheetId:e,col:t,row:i})}return s}}).add("automatic_sum",class extends FE{static getters=["getAutomaticSums"];handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:o}=this.getters.getSelection();for(const i of t){const t=this.getAutomaticSums(e,i,o.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,o){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,o):this.sumData(e,t)}sumData(e,t){const o=this.dimensionsToSum(e,t),i=this.sumDimensions(e,t,o).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return o.has("ROW")&&o.has("COL")&&i.push(this.sumTotal(t)),i}sumAdjacentData(e,t,o){const{col:i,row:s}=hi(o.col,o.row,t)?o:{col:t.left,row:t.top},r=this.findAdjacentData(e,i,s);return r?this.getters.isSingleCellOrMerge(e,t)||mi(ni(r,t))?[{position:{col:i,row:s},zone:r}]:this.sumDimensions(e,ni(r,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,o){const i=this.getters.getSheet(e),s=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),r=this.findSuitableZoneToSum(i,s.col,s.row);if(r)return this.getters.expandZone(e,r)}findSuitableZoneToSum(e,t,o){const i=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:o-1}),s=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:o});if(this.isNumber(s)&&!this.isNumber(i))return this.findHorizontalZone(e,t,o);const r=this.findVerticalZone(e,t,o);if(this.isZoneValid(r))return r;const n=this.findHorizontalZone(e,t,o);return this.isZoneValid(n)?n:void 0}findVerticalZone(e,t,o){const i={top:0,bottom:o-1,left:t,right:t},s=this.reduceZoneStart(e,i,i.bottom);return{...i,top:s}}findHorizontalZone(e,t,o){const i={top:o,bottom:o,left:0,right:t-1},s=this.reduceZoneStart(e,i,i.right);return{...i,left:s}}reduceZoneStart(e,t,o){const i=this.getters.getEvaluatedCellsInZone(e.id,t),s=Oe(o,-1,-1),r=s.filter((e=>i[e]&&!i[e].isAutoSummable)),n=Math.max(...r),a=Ne(s.filter((e=>this.isNumber(i[e]))))[0]||[];return Math.max(...a)<n?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){return e.type===Qi.number&&!(e.format&&Io(e.format))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const o=new Set;return mi(t)?(o.add(1===pi(t).numberOfCols?"COL":"ROW"),o):(this.lastColIsEmpty(e,t)&&o.add("ROW"),this.lastRowIsEmpty(e,t)&&o.add("COL"),0===o.size&&o.add("COL"),o)}sumDimensions(e,t,o){return[...o.has("COL")?this.sumColumns(t,e):[],...o.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:o}=e;return{position:{col:o,row:t},zone:{...e,top:t,right:o-1}}}sumColumns(e,t){const o=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,o.bottom-1)},fi(o).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const o=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,o.right-1)},fi(o).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const o of t){const{col:t,row:i}=o.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,content:`=SUM(${this.getters.zoneToXC(e,o.zone)})`})}}nextEmptyRow(e,t){let o=t.bottom+1;const{left:i,right:s}=t;for(;!this.getters.isEmpty(e,{bottom:o,top:o,left:i,right:s});)o++;return{...t,top:o,bottom:o}}nextEmptyCol(e,t){let o=t.right+1;const{top:i,bottom:s}=t;for(;!this.getters.isEmpty(e,{left:o,right:o,top:i,bottom:s});)o++;return{...t,left:o,right:o}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}).add("format",class extends FE{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,o){for(const i of t)for(const t of fi(i)){const i=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==i){this.getters.getLocale();const s=Lo(i,o);this.dispatch("SET_FORMATTING",{sheetId:e,target:[Ei(t)],format:s})}}}getCellNumberFormat(e){for(const t of[e]){const e=this.getters.getEvaluatedCell(t);if(!(e.type!==Qi.number||e.format&&Io(e.format)))return e.format||Mo(e.value)}}}).add("split_to_columns",class extends FE{static getters=["getAutomaticSeparator"];allowDispatch(e){return"SPLIT_TEXT_INTO_COLUMNS"===e.type?this.chainValidations(this.batchValidations(this.checkSingleColSelected,this.checkNonEmptySelector),this.batchValidations(this.checkNotOverwritingContent,this.checkSeparatorInSelection))(e):0}handle(e){if("SPLIT_TEXT_INTO_COLUMNS"===e.type)this.splitIntoColumns(e)}getAutomaticSeparator(){const e=this.getters.getSelectedCells();for(const t of e)if(t.value&&t.type===Qi.text){const e=this.getAutoSeparatorForString(t.value);if(e)return e}return" "}getAutoSeparatorForString(e){const t=[pe,";",","," ","."];for(const o of t)if(e.includes(o))return o}splitIntoColumns({separator:e,addNewColumns:t}){const o=this.getters.getSelectedZone(),i=this.getters.getActiveSheetId(),s=this.getSplittedCols(o,e);t&&this.addColsToAvoidCollisions(o,s),this.removeMergesInSplitZone(o,s),this.addColumnsToNotOverflowSheet(o,s);for(let e=0;e<s.length;e++){const t=o.top+e,r=s[e],n=o.left,a=this.getters.getCell({sheetId:i,col:n,row:t});if(1!==r.length||r[0]!==a?.content)for(const[e,o]of r.entries())this.dispatch("UPDATE_CELL",{sheetId:i,col:n+e,row:t,content:Xu(o,this.getters.getLocale()),format:"",style:a?.style||null})}}getSplittedCols(e,t){if(!t)throw new Error("Separator cannot be empty");const o=this.getters.getActiveSheetId(),i=[];for(const s of Oe(e.top,e.bottom+1)){const r=this.getters.getEvaluatedCell({sheetId:o,col:e.left,row:s}).formattedValue;i.push(this.splitAndRemoveTrailingEmpty(r,t))}return i}splitAndRemoveTrailingEmpty(e,t){const o=e.split(t);for(;o.length>1&&""===o[o.length-1];)o.pop();return o}willSplittedColsOverwriteContent(e,t){const o=this.getters.getActiveSheetId();for(const i of Oe(e.top,e.bottom+1)){const s=t[i-e.top];for(let t=1;t<s.length;t++){const s=this.getters.getCell({sheetId:o,col:e.left+t,row:i});if(s&&s.content)return!0}}return!1}removeMergesInSplitZone(e,t){const o=this.getters.getActiveSheetId(),i=Math.max(...t.map((e=>e.length))),s={...e,right:e.left+i-1},r=this.getters.getMergesInZone(o,s);this.dispatch("REMOVE_MERGE",{sheetId:o,target:r})}addColsToAvoidCollisions(e,t){const o=this.getters.getActiveSheetId();let i=0;for(const s of Oe(e.top,e.bottom+1)){const r={sheetId:o,col:e.left,row:s},n=t[s-e.top],a=this.getColsToAddToAvoidCollision(r,n);i=Math.max(i,a)}i&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:e.left,sheetId:o,quantity:i,position:"after"})}getColsToAddToAvoidCollision(e,t){const o=t.length;for(let t=1;t<o;t++){const i=e.col+t,s=this.getters.getCell({...e,col:i});if(s&&s.content)return o-t}return 0}addColumnsToNotOverflowSheet(e,t){const o=this.getters.getActiveSheetId(),i=Math.max(...t.map((e=>e.length-1))),s=this.getters.getNumberCols(o)-1;e.left+i>s&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:s,sheetId:o,quantity:e.left+i-s,position:"after"})}checkSingleColSelected(){return this.getters.isSingleColSelected()?0:89}checkNonEmptySelector(e){return""===e.separator?90:0}checkNotOverwritingContent(e){if(e.addNewColumns||e.force)return 0;const t=this.getters.getSelectedZones()[0],o=this.getSplittedCols(t,e.separator);return this.willSplittedColsOverwriteContent(t,o)?91:0}checkSeparatorInSelection({separator:e}){const t=this.getters.getSelectedCells();for(const o of t)if(o.formattedValue.includes(e))return 0;return 92}}).add("cell_popovers",class extends FE{static getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];persistentPopover;allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{Sg.get(e.popoverType)}catch(e){return 73}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){const o=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=Sg.get(this.persistentPopover.type).onOpen?.(e,this.getters);return t?.isOpen?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:o,col:e,row:t}))return{isOpen:!1};const i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}),s=Sg.getAll().map((e=>e.onHover?.(i,this.getters))).find((e=>e?.isOpen));return s?.isOpen?{...s,anchorRect:this.computePopoverAnchorRect(i)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const o=this.getters.getActiveSheetId(),i=this.getters.getMerge({sheetId:o,col:e,row:t});return i?this.getters.getVisibleRect(i):this.getters.getVisibleRect(Ei({col:e,row:t}))}}).add("collaborative",class extends FE{static getters=["getClientsToDisplay","getClient","getConnectedClients","isFullySynchronized"];static layers=[6];availableColors=new Set(ow);colors={};session;constructor(e){super(e),this.session=e.session}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(ow));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClient(){return this.session.getClient()}getConnectedClients(){return this.session.getConnectedClients()}isFullySynchronized(){return this.session.isFullySynchronized()}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof ew)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const o of this.getters.getConnectedClients())if(o.id!==this.getters.getClient().id&&o.position&&o.position.sheetId===e&&this.isPositionValid(o.position)){const e=o.position;this.colors[o.id]||(this.colors[o.id]=this.chooseNewColor());const i=this.colors[o.id];t.push({...o,position:e,color:i})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:s,col:r}=e.position,n=this.getters.expandZone(i,{top:s,bottom:s,left:r,right:r}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(n);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*o,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${q+1}px ${Z}`}}}).add("history",class extends FE{static getters=["canUndo","canRedo"];undoStack=[];redoStack=[];session;constructor(e){super(e),this.session=e.session,this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();if(t)"UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t));else{const e=this.getPossibleRevisionToRepeat();if(!e)return;const t=mw(e,this.getters);if(!t)return;if(!Array.isArray(t))return void this.dispatch(t.type,t);for(const e of t)this.dispatch(e.type,e)}}canUndo(){return this.undoStack.length>0}canRedo(){if(this.redoStack.length>0)return!0;const e=this.getPossibleRevisionToRepeat();return!(!(t=e)||!t.rootCommand||"object"!=typeof t.rootCommand)&&(rs(t.rootCommand)?dw.contains(t.rootCommand.type):uw.contains(t.rootCommand.type));var t}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}getPossibleRevisionToRepeat(){return this.session.getLastLocalNonEmptyRevision(["REQUEST_REDO"])}}),Mw=(new $i).add("selection",class extends FE{static layers=[6];static getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getSelectedCells","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","isSingleColSelected","getElementsFromSelection","tryGetActiveSheetId"];gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]};selectedFigureId=null;sheetsData={};moveClient;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 28}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let o=[];switch(e.mode){case"overrideSelection":o=[t.zone];break;case"updateAnchor":o=[...this.gridSelection.zones];const i=o.findIndex((t=>li(t,e.previousAnchor.zone)));i>=0&&(o[i]=t.zone);break;case"newAnchor":o=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,o),this.selection.resetDefaultAnchor(this,Se(this.gridSelection.anchor));const{col:i,row:s}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:i,row:s}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(o,i),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:Se(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Se(this.gridSelection.anchor));else{const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,o)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const s=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of s)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Se(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:o})}const r=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(r,e))),this.gridSelection.anchor.zone=this.getters.expandZone(r,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,Se(this.gridSelection.anchor))}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let o=t.left;o<=t.right;o++)e.add(o);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let o of this.gridSelection.zones)if(0===o.left&&o.right===this.getters.getNumberCols(t)-1)for(let t=o.top;t<=o.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return Se(this.gridSelection.zones)}getSelectedZone(){return Se(this.gridSelection.anchor.zone)}getSelection(){return Se(this.gridSelection)}getSelectedCells(){const e=this.getters.getActiveSheetId(),t=[];for(const o of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,o));return t}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>e.type!==Qi.empty)));let t=new Set,o=[];for(let i of e)t.add(i.type),o.push(i.value);const i=this.getters.getLocale();let s={};for(let e of Tw){let r;e.types.some((e=>t.has(e)))&&(r=e.compute(o,i)),s[e.name]=r}return s}getAggregate(){let e=0,t=0;const o=this.getters.getActiveSheetId(),i=this.gridSelection.zones.map(fi).flat();for(const{col:s,row:r}of i){const i=this.getters.getEvaluatedCell({sheetId:o,col:s,row:r});i.type===Qi.number&&(t++,e+=i.value)}const s=this.getters.getLocale();return t<2?null:vo(e,{locale:s})}isSelected(e){return!!this.getters.getSelectedZones().find((t=>li(t,e)))}isSingleColSelected(){const e=this.getters.getSelectedZones();return 1===e.length&&e[0].left===e[0].right}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let o=[];const i="COL"===e?"left":"top",s="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[s]-e[i]+1},((t,o)=>e[i]+o));o=o.concat(t)}return[...new Set(o)].sort()}setSelectionMixin(e,t){const{anchor:o,zones:i}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=o,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,o)=>t===o.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(i)}selectCell(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.expandZone(o,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:i,cell:{col:e,row:t}},[i])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),o=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[o]})}onColumnsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=si(o,"left",[...e.elements]);let s={left:t.col,right:t.col,top:t.row,bottom:t.row};s=si(s,"left",[...e.elements]);const r={cell:{col:s.left,row:s.top},zone:i},n=this.gridSelection.zones.map((t=>si(t,"left",[...e.elements])));this.setSelectionMixin(r,n)}onRowsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=si(o,"top",[...e.elements]);let s={left:t.col,right:t.col,top:t.row,bottom:t.row};s=si(s,"top",[...e.elements]);const r={cell:{col:s.left,row:s.top},zone:i},n=this.gridSelection.zones.map((t=>si(t,"top",[...e.elements])));this.setSelectionMixin(r,n)}onAddElements(e){const t="COL"===e.dimension?"left":"top",o=ii(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),i=this.gridSelection.zones.map((o=>ii(o,t,e.base,e.position,e.quantity))),s={cell:{col:o.left,row:o.top},zone:o};this.setSelectionMixin(s,i)}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const o="COL"===e.dimension,i=e.elements[0],s=e.elements[t-1],r=e.base<i,n=r&&o?t:0,a=r&&!o?t:0;this.dispatch("CUT",{cutTarget:[{left:o?i+n:0,right:o?s+n:this.getters.getNumberCols(e.sheetId)-1,top:o?0:i+a,bottom:o?this.getters.getNumberRows(e.sheetId)-1:s+a}]}),this.dispatch("PASTE",{target:[{left:o?e.base:0,right:o?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:o?0:e.base,bottom:o?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=r?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const o="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:o,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,o=e.elements[0],i=e.elements[e.elements.length-1],s=e.sheetId,r=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return r(s,o-1,o)||r(s,i,i+1)||r(s,e.base-1,e.base)?2:0}clipSelection(e,t){const o=this.getters.getNumberCols(e)-1,i=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:we(e.left,0,o),right:we(e.right,0,o),top:we(e.top,0,i),bottom:we(e.bottom,0,i)}))),anchor:{cell:{col:we(t.anchor.cell.col,0,o),row:we(t.anchor.cell.row,0,i)},zone:{left:we(t.anchor.zone.left,0,o),right:we(t.anchor.zone.right,0,o),top:we(t.anchor.zone.top,0,i),bottom:we(t.anchor.zone.bottom,0,i)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getSelectedZones();t.fillStyle="#f3f7fe";const s=1===i.length&&i[0].left===i[0].right&&i[0].top===i[0].bottom;t.fillStyle=s?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*o;for(const e of i){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(o,i,s,r),t.globalCompositeOperation="source-over",t.strokeRect(o,i,s,r)}t.globalCompositeOperation="source-over";const r=this.getActivePosition();let n;t.strokeStyle=E,t.lineWidth=3*o,n=this.getters.isInMerge(r)?this.getters.getMerge(r):Ei(r);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(n);c>0&&h>0&&t.strokeRect(a,l,c,h)}}).add("evaluation_filter",class extends FE{static getters=["getCellBorderWithFilterBorder","getFilterValues","isRowFiltered","isFilterActive"];filterValues={};hiddenRows=new Set;isEvaluationDirty=!1;allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 80;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"HIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const o of this.getters.getFilters(e.sheetIdTo)){const i=o.zoneWithHeaders;t[o.id]=this.getFilterValues({sheetId:e.sheetId,col:i.left,row:i.top})}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e){const{sheetId:t,col:o,row:i}=e;let s;for(let e of this.getters.getFilterTables(t)){const r=e.zone;if(hi(o,i,r)){const e=this.intersectZoneWithViewport(t,r);s={top:i===e.top?K:void 0,bottom:i===e.bottom?K:void 0,left:o===e.left?K:void 0,right:o===e.right?K:void 0}}}const r=this.getters.getCellBorder(e),n={...s,...Xe(r||{})};return $e(n)?null:n}getFilterValues(e){const t=this.getters.getFilterId(e),o=e.sheetId;return t&&this.filterValues[o]&&this.filterValues[o][t]||[]}isFilterActive(e){const t=this.getters.getFilterId(e),o=e.sheetId;return Boolean(t&&this.filterValues[o]?.[t]?.length)}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,"COL",t.left,t.right),right:this.getters.findVisibleHeader(e,"COL",t.right,t.left),top:this.getters.findVisibleHeader(e,"ROW",t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,"ROW",t.bottom,t.top)}}updateFilter({col:e,row:t,values:o,sheetId:i}){const s=this.getters.getFilterId({sheetId:i,col:e,row:t});s&&(this.filterValues[i]||(this.filterValues[i]={}),this.filterValues[i][s]=o)}updateHiddenRows(){const e=this.getters.getActiveSheetId(),t=this.getters.getFilters(e).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),o=new Set;for(let i of t){if(this.getters.isRowHiddenByUser(e,i.zoneWithHeaders.top))continue;if(o.has(i.zoneWithHeaders.top))continue;const t=this.filterValues[e]?.[i.id]?.map(Ke);if(t&&i.filteredZone)for(let s=i.filteredZone.top;s<=i.filteredZone.bottom;s++){const r=this.getCellValueAsString(e,i.col,s);t.includes(r)&&o.add(s)}}this.hiddenRows=o}getCellValueAsString(e,t,o){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets){const e=t.id;for(const o of t.filterTables){const i=Jo(o.range),s=[],r=[];for(const o of Oe(0,pi(i).numberOfCols)){const n={sheetId:t.id,col:i.left+o,row:i.top},a=this.getFilterValues(n),l=this.getters.getFilter(n);if(!l)continue;const c=l.filteredZone?fi(l.filteredZone).map((t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue)):[];if(a.length){const e=c.filter((e=>e)).filter((e=>!a.includes(e)));s.push({colId:o,displayedValues:[...new Set(e)],displayBlanks:!a.includes("")&&c.some((e=>!e))})}const h={col:l.col,row:l.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(h).formattedValue,u=this.getUniqueColNameForExcel(o,d,r);r.push(u),t.cells[Tt(h.col,h.row)]={...t.cells[Tt(h.col,h.row)],content:u,value:u,isFormula:!1}}o.filters=s}}}getUniqueColNameForExcel(e,t,o){t||(t=`Column${e}`);let i=t,s=2;for(;o.includes(i);)i=t+String(s),s++;return i}}).add("viewport",class extends FE{static getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio","isPositionVisible"];viewports={};sheetViewWidth=ge();sheetViewHeight=ge();gridOffsetX=0;gridOffsetY=0;sheetsWithDirtyViewports=new Set;allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){if(e.options.scrollIntoView){let{col:t,row:o}=Si(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const i=e.previousAnchor.zone,s=e.anchor.zone,{top:r,bottom:n,left:a,right:l}=this.getters.getActiveMainViewport();i.left===s.left&&i.right===s.right&&(t=a>t||t>l?a:t),i.top===s.top&&i.bottom===s.bottom&&(o=r>o||o>n?r:o)}const i=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(i)-1),o=Math.min(o,this.getters.getNumberRows(i)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:o})}}handle(e){switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:t}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(o,t).start+this.sheetViewHeight);this.shiftVertically(i);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),o=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(o);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==e.style?.fontSize)&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:s,row:r}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:s,row:r})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){const e=this.getters.getSheetIds();for(const t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>Oe(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>Oe(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);let{width:s,height:r}=t.getMaxSize();return{x:this.getters.getColDimensions(e,o).start,y:this.getters.getRowDimensions(e,i).start,width:s,height:r}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:o}=this.getMainViewportRect(),i=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-i.viewportWidth+1),maxOffsetY:Math.max(0,o-i.viewportHeight+1)}}getColRowOffsetInViewport(e,t,o){const i=this.getters.getActiveSheetId(),s=this.getters.getSheetViewVisibleCols(),r=this.getters.getSheetViewVisibleRows();if(o<t)return-this.getColRowOffsetInViewport(e,o,t);let n=0;const a="COL"===e?s:r;for(let s=t;s<o;s++)a.includes(s)&&(n+="COL"===e?this.getters.getColSize(i,s):this.getters.getRowSize(i,s));return n}isVisibleInViewport({sheetId:e,col:t,row:o}){return this.getSubViewports(e).some((e=>e.isVisible(t,o)))}getEdgeScrollCol(e,t,o){let i=!1,s=0,r=0;const{xSplit:n}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(i=!0,r=eo(e-a),s=1):e<l&&o>=l&&c>0?(i=!0,r=eo(l-e),s=-1):n&&t<l&&e>l&&(i=!0,r=eo(e),s="reset"),{canEdgeScroll:i,direction:s,delay:r}}getEdgeScrollRow(e,t,o){let i=!1,s=0,r=0;const{ySplit:n}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(i=!0,r=eo(e-a),s=1):e<l&&o>=l&&c>0?(i=!0,r=eo(l-e),s=-1):n&&t<l&&e>l&&(i=!0,r=eo(e),s="reset"),{canEdgeScroll:i,direction:s,delay:r}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),o=this.getSubViewports(t).map((t=>t.getRect(e))).filter(He);if(0===o.length)return{x:0,y:0,width:0,height:0};const i=Math.min(...o.map((e=>e.x))),s=Math.min(...o.map((e=>e.y))),r=Math.max(...o.map((e=>e.x+e.width)))-i,n=Math.max(...o.map((e=>e.y+e.height)))-s;return{x:i+this.gridOffsetX,y:s+this.gridOffsetY,width:r,height:n}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,o).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(He)}checkPositiveDimension(e){return e.width<0||e.height<0?69:0}checkValuesAreDifferent(e){const{height:t,width:o}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===o&&e.height===t?77:0}checkScrollingDirection({offsetX:e,offsetY:t}){const o=this.getMainInternalViewport(this.getters.getActiveSheetId());return!o.canScrollHorizontally&&e>0||!o.canScrollVertically&&t>0?70:0}getMainViewport(e){const t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const o=this.getSubViewports(e);Object.values(o).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,o=0,i=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=o,this.gridOffsetY=i,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const o=this.getters.getActiveSheetId(),{maxOffsetX:i,maxOffsetY:s}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(o)).forEach((o=>o.setViewportOffset(we(e,0,i),we(t,0,s))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),o=t-this.sheetViewHeight;return e=Math.min(e,o),e=Math.max(e,0)}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetScrollbarX||0,y:this.viewports[e]?.bottomRight.offsetScrollbarY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getNumberCols(e),s=this.getters.getNumberRows(e),r=this.getters.getColRowOffset("COL",0,t,e),n=this.getters.getColRowOffset("ROW",0,o,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:o&&t&&new Aw(this.getters,e,{left:0,right:t-1,top:0,bottom:o-1},{width:r,height:n},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:o&&new Aw(this.getters,e,{left:t,right:i-1,top:0,bottom:o-1},{width:this.sheetViewWidth-r,height:n},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Aw(this.getters,e,{left:0,right:t-1,top:o,bottom:s-1},{width:r,height:this.sheetViewHeight-n},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Aw(this.getters,e,{left:t,right:i-1,top:o,bottom:s-1},{width:this.sheetViewWidth-r,height:this.sheetViewHeight-n},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:o}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(o,e);const{anchor:i}=this.getters.getSelection(),s=this.getActiveMainViewport().top-t;this.selection.selectCell(i.cell.col,i.cell.row+s)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],o=this.getters.getFigures(e),{scrollX:i,scrollY:s}=this.getActiveSheetScrollInfo(),{x:r,y:n}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of o)e.x>=r&&(e.x+e.width<=r+i||e.x>=a+i+r)||e.y>=n&&(e.y+e.height<=n+s||e.y>=l+s+n)||t.push(e);return t}isPositionVisible(e){const{scrollX:t,scrollY:o}=this.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.getters.getMainViewportCoordinates(),{width:r,height:n}=this.getters.getSheetViewDimension();return!(e.x>=i&&(e.x<i+t||e.x>r+t+i))&&!(e.y>=s&&(e.y<s+o||e.y>n+o+s))}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getColDimensions(e,t).start,s=this.getters.getRowDimensions(e,o).start;return{xRatio:i/(this.sheetViewWidth+this.gridOffsetX),yRatio:s/(this.sheetViewHeight+this.gridOffsetY)}}}).add("clipboard",class extends FE{static layers=[2];static getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];status="invisible";state;lastPasteState;_isPaintingFormat=!1;originSheetId;allowDispatch(e){switch(e.type){case"CUT":const t=e.cutTarget||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 24;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:o});case"PASTE_FROM_OS_CLIPBOARD":return new ww(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target,{pasteOption:e.pasteOption});case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}}return 0}handle(e){switch(e.type){case"COPY":case"CUT":const t="cutTarget"in e&&e.cutTarget||this.getters.getSelectedZones();this.state=this.getClipboardState(t,e.type),this.status="visible",this.originSheetId=this.getters.getActiveSheetId();break;case"PASTE":if(!this.state)break;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:o,shouldPasteCF:!0,selectTarget:!0}),this.lastPasteState=this.state,this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!ei(t[0])){for(const{col:t,row:o}of fi(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:o,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==this.state?.operation)return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==this.state?.operation)return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":this.state=new ww(e.text,this.getters,this.dispatch,this.selection),this.state.paste(e.target,{pasteOption:e.pasteOption}),this.lastPasteState=this.state,this.status="invisible";break;case"REPEAT_PASTE":this.lastPasteState?.paste(e.target,{pasteOption:e.pasteOption,shouldPasteCF:!0,selectTarget:!0});break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}case"DELETE_SHEET":if("CUT"!==this.state?.operation)return;this.originSheetId===e.sheetId&&(this.state=void 0,this.status="invisible");break;default:rs(e)&&(this.status="invisible")}}getClipboardContent(){return this.state?.getClipboardContent()||{[Ji.PlainText]:"\t"}}getClipboardTextContent(){return this.state?.getClipboardContent()[Ji.PlainText]||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i;return i="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(o)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1},{cut:[i],paste:[e]}}getInsertCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i,s;return"COL"===t?(i={...e,right:this.getters.getNumberCols(o)-1},s={...e,left:e.right+1,right:e.right+1}):(i={...e,bottom:this.getters.getNumberRows(o)-1},s={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1}),{cut:[i],paste:[s]}}getClipboardStateForCopyCells(e,t){return new bw(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new vw(t,this.getters,this.dispatch):new bw(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}).add("edition",class extends FE{static getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];col=0;row=0;mode="inactive";sheetId="";currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;selectionInitialStart=0;initialContent="";previousRef="";previousRange=void 0;colorIndexByRange={};allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"!==this.mode)return;const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)this.insertSelectedRange(o);else this.replaceSelectedRanges(o)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),o=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:o,sheetName:i}=Ko(e.value),s=i||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==s)return!1;const n=this.getters.getRangeFromSheetXC(r,o);return li(this.getters.expandZone(r,n.zone),t.zone)}));this.previousRef=o.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=o.start;break;case"CHANGE_HIGHLIGHT":const i=this.getters.getRangeFromRangeData(e.range),s=this.getRangeReference(i,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(s),this.previousRef=s,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),s=this.getters.expandZone(e.sheetIdTo,Ei({col:o,row:i}));this.selection.resetAnchor(this,{cell:{col:o,row:i},zone:s})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:Rw}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const o=e.map(yw).map((e=>e.value)).join(""),i=this.currentContent,s=e[0].start,r=e[e.length-1].end,n=i.slice(0,s)+o+i.slice(r),a=n.length-i.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:n,selection:l})}validateSelection(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e?0:47}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Rw});const{top:t,left:o}=si({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Rw});const{top:t,left:o}=si({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=ii({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=o,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Ei({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){const o=this.getters.getActiveCell(),i=this.getters.getLocale();e&&o.format?.includes("%")&&ro(e,i)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:s,row:r,sheetId:n}=this.getters.getActivePosition();this.col=s,this.sheetId=n,this.row=r,this.initialContent=this.getComposerContent({sheetId:n,col:s,row:r}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=Ei({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const i=this.getters.getActiveSheetId(),s=this.getters.getEvaluatedCell({sheetId:i,col:this.col,row:this.row});if(o=Xu(o,this.getters.getLocale()),o.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,i=e-t;i>0&&(o+=Ge(new Array(i).fill(")")))}else s.link&&(o=Pe(o,s.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:o})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}getComposerContent(e){const t=this.getters.getLocale(),o=this.getters.getCell(e);if(o?.isFormula)return Qu(o.content,t);const{format:i,value:s,type:r,formattedValue:n}=this.getters.getEvaluatedCell(e);switch(r){case Qi.text:case Qi.empty:return s;case Qi.boolean:return n;case Qi.error:return o?.content||"";case Qi.number:return i&&Io(i)?n:this.numberComposerContent(s,i,t)}}numberComposerContent(e,t,o){return t?.includes("%")?`${xo(100*e,o.decimalSeparator)}%`:xo(e,o.decimalSeparator)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const i=this.currentContent!==e;if(this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,i||"inactive"!==this.mode){const t=this.getters.getLocale();this.currentTokens=e.startsWith("=")?ju(e,t):[],this.currentTokens.length>100&&o&&this.ui.notifyUI({type:"ERROR",text:r("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(o,t),this.selectionInitialStart=t):(this.insertText(","+o,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e){const t=this.getters.getCurrentEditedCell().sheetId,o=this.getters.getActiveSheetId(),i=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(i,t)}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let o=[...t];1===t.length&&yi(e.zone)>1?o.push({...t[0]}):2===t.length&&1===yi(e.zone)&&o.pop();const i=e.clone({parts:o});return this.getters.getSelectionRangeString(i,this.getters.getCurrentEditedCell().sheetId)}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(o,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),i=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:i,end:i}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getCurrentEditedCell().sheetId,t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const i=new Set(Object.values(o));let s=0;const r=()=>{for(;i.has(s);)s++;return i.add(s),s};for(const e of t){const t=e in o?o[e]:r();o[e]=t}this.colorIndexByRange=o}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getCurrentEditedCell().sheetId,t=e=>{const t=this.colorIndexByRange[e];return lt[t%lt.length]};return this.getReferencedRanges().map((o=>{const i=this.getters.getRangeString(o,e);return{zone:o.zone,color:t(i),sheetId:o.sheetId}}))}getReferencedRanges(){const e=this.getters.getCurrentEditedCell().sheetId;return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,i=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(i.type)||ru.includes(i.value);){if("SPACE"!==i.type||o<1)return!1;o--,i=this.currentTokens[o]}for(o=t+1,i=this.currentTokens[o];i&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type)return!1;o++,i=this.currentTokens[o]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((o=>o.start<=e&&o.end>=e||o.start>=e&&o.start<t))}}),_w=(new $i).add("evaluation",class extends FE{config;static getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getEvaluatedCellsInZone"];shouldRebuildDependenciesGraph=!0;evaluator;compilationParams;positionsToUpdate=[];constructor(e){super(e),this.config=e,this.compilationParams=this.getCompilationParameters(),this.evaluator=new zE(e.custom,this.getters)}beforeHandle(e){ts.has(e.type)&&(this.shouldRebuildDependenciesGraph=!0)}handle(e){switch(e.type){case"UPDATE_CELL":if(!("content"in e)&&!("format"in e)||this.shouldRebuildDependenciesGraph)return;this.positionsToUpdate.push(e),"content"in e&&this.evaluator.updateDependencies(e);break;case"EVALUATE_CELLS":this.evaluator.evaluateAllCells();break;case"UPDATE_LOCALE":this.compilationParams=this.getCompilationParameters(),this.evaluator.updateCompilationParameters()}}finalize(){this.shouldRebuildDependenciesGraph?(this.evaluator.buildDependencyGraph(),this.evaluator.evaluateAllCells(),this.shouldRebuildDependenciesGraph=!1):this.positionsToUpdate.length&&this.evaluator.evaluateCells(this.positionsToUpdate),this.positionsToUpdate=[]}evaluateFormula(e,t){const o=Gu(t),i=[];for(let t of o.dependencies)i.push(this.getters.getRangeFromSheetXC(e,t));return o.execute(i,...this.compilationParams).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell(e){return this.evaluator.getEvaluatedCell(e)}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},o={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);o[e]=this.getEvaluatedCell(t)}return o}getEvaluatedCellsInZone(e,t){return fi(t).map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o})))}exportForExcel(e){for(const t of this.evaluator.getEvaluatedPositions()){const o=this.evaluator.getEvaluatedCell(t),i=Tt(t.col,t.row),s=o.value;let r,n,a=!1,l=!0;const c=this.getCorrespondingFormulaCell(t);c&&(l=c.compiledFormula.tokens.filter((e=>"FUNCTION"===e.type)).every((e=>WE[e.value.toUpperCase()].isExported)),a=l,l||(r=s.toString(),n=o.format));const h=e.sheets.find((e=>e.id===t.sheetId)),d=h.cells[i]||{},u=n?We(n,e.formats):d.format,g=l?d.content:r;h.cells[i]={...d,value:s,isFormula:a,content:g,format:u}}}getCorrespondingFormulaCell(e){const t=this.getters.getCell(e);if(t&&t.content)return t.isFormula&&!function(e){try{return Gu(e),!1}catch(e){return!0}}(t.content)?t:void 0;const o=this.evaluator.getArrayFormulaSpreadingOn(e);if(void 0===o)return;const i=this.getters.getCell(o);return i?.isFormula?i:void 0}getCompilationParameters(){return LE(this.config.custom,this.getters,(e=>this.evaluator.getEvaluatedCell(e)))}}).add("evaluation_chart",class extends FE{static getters=["getChartRuntime","getBackgroundOfSingleCellChart"];charts={};createRuntimeChart=function(e){const t=yp.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o){const i=t.find((e=>e.match(o.type)));if(!i)throw new Error("No runtime builder for this chart.");return i.getChartRuntime(o,e)}}(this.getters);handle(e){if((es.has(e.type)||os.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)&&"UNDO"!==e.type&&"REDO"!==e.type)for(const e in this.charts)this.history.update("charts",e,void 0);switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||this.history.update("charts",e,void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.history.update("charts",e,this.createRuntimeChart(t))}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const o=t.zone.left,i=t.zone.top,s=t.sheetId;return this.getters.getCellComputedStyle({sheetId:s,col:o,row:i}).fillColor||w}}).add("evaluation_cf",class extends FE{static getters=["getConditionalIcon","getCellComputedStyle"];isStale=!0;computedStyles={};computedIcons={};handle(e){(os.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0)}finalize(){if(this.isStale){for(const e of this.getters.getSheetIds())this.computedStyles[e]=qe((()=>this.getComputedStyles(e))),this.computedIcons[e]=qe((()=>this.getComputedIcons(e)));this.isStale=!1}}getCellComputedStyle(e){const{sheetId:t,col:o,row:i}=e,s=this.getters.getCell(e),r=this.computedStyles[t](),n=r&&r[o]?.[i],a={...s?.style,...n};return this.getters.getEvaluatedCell(e).link&&!a.textColor&&(a.textColor=I),this.getters.isFilterHeader(e)&&(a.bold=!0),a}getConditionalIcon({sheetId:e,col:t,row:o}){const i=this.computedIcons[e]();return i&&i[t]?.[o]}getComputedStyles(e){const t={};for(let o of this.getters.getConditionalFormats(e).reverse())try{switch(o.rule.type){case"ColorScaleRule":for(let i of o.ranges)this.applyColorScale(e,i,o.rule,t);break;case"CellIsRule":for(let i of o.ranges){const s=this.getters.getRangeFromSheetXC(e,i).zone;for(let i=s.top;i<=s.bottom;i++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let n=this.getters.getEvaluatedCell({sheetId:e,col:r,row:i});s&&s(n,o.rule)&&(t[r]||(t[r]=[]),t[r][i]=Object.assign(t[r]?.[i]||{},o.rule.style))}}}}catch(e){}return t}getComputedIcons(e){const t={};for(let o of this.getters.getConditionalFormats(e).reverse())if("IconSetRule"===o.rule.type)for(let i of o.ranges)this.applyIcon(e,i,o.rule,t);return t}parsePoint(e,t,o,i){const s=this.getters.getEvaluatedCellsInZone(e,this.getters.getRangeFromSheetXC(e,t).zone).filter((e=>e.type===Qi.number)).map((e=>e.value));switch(o.type){case"value":return"max"===i?Math.max(...s):Math.min(...s);case"number":return Number(o.value);case"percentage":const t=Math.min(...s);return t+(Math.max(...s)-t)*Number(o.value)/100;case"percentile":return lo(s,Number(o.value)/100,!0);case"formula":const r=o.value&&this.getters.evaluateFormula(e,o.value);return r instanceof Promise?null:r;default:return null}}applyIcon(e,t,o,i){const s=this.parsePoint(e,t,o.lowerInflectionPoint),r=this.parsePoint(e,t,o.upperInflectionPoint);if(null===s||null===r||s>r)return;const n=this.getters.getRangeFromSheetXC(e,t).zone,a=[o.icons.upper,o.icons.middle,o.icons.lower];for(let t=n.top;t<=n.bottom;t++)for(let l=n.left;l<=n.right;l++){const n=this.getters.getEvaluatedCell({sheetId:e,col:l,row:t});if(n.type!==Qi.number)continue;const c=this.computeIcon(n.value,r,o.upperInflectionPoint.operator,s,o.lowerInflectionPoint.operator,a);i[l]||(i[l]=[]),i[l][t]=c}}computeIcon(e,t,o,i,s,r){return"ge"===o&&e>=t||"gt"===o&&e>t?r[0]:"ge"===s&&e>=i||"gt"===s&&e>i?r[1]:r[2]}applyColorScale(e,t,o,i){const s=this.parsePoint(e,t,o.minimum,"min"),r=o.midpoint?this.parsePoint(e,t,o.midpoint):null,n=this.parsePoint(e,t,o.maximum,"max");if(null===s||null===n||s>=n||r&&(s>=r||r>=n))return;const a=this.getters.getRangeFromSheetXC(e,t).zone,l=[];o.midpoint&&r?(l.push({minValue:s,minColor:o.minimum.color,colorDiffUnit:this.computeColorDiffUnits(s,r,o.minimum.color,o.midpoint.color)}),l.push({minValue:r,minColor:o.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(r,n,o.midpoint.color,o.maximum.color)})):l.push({minValue:s,minColor:o.minimum.color,colorDiffUnit:this.computeColorDiffUnits(s,n,o.minimum.color,o.maximum.color)});for(let t=a.top;t<=a.bottom;t++)for(let o=a.left;o<=a.right;o++){const a=this.getters.getEvaluatedCell({sheetId:e,col:o,row:t});if(a.type===Qi.number){const e=we(a.value,s,n);let c;c=2===l.length&&r?e<=r?this.colorCell(e,l[0].minValue,l[0].minColor,l[0].colorDiffUnit):this.colorCell(e,l[1].minValue,l[1].minColor,l[1].colorDiffUnit):this.colorCell(e,l[0].minValue,l[0].minColor,l[0].colorDiffUnit),i[o]||(i[o]=[]),i[o][t]=i[o]?.[t]||{},i[o][t].fillColor=ct(c)}}}computeColorDiffUnits(e,t,o,i){const s=t-e;return[((o>>16)%256-(i>>16)%256)/s,((o>>8)%256-(i>>8)%256)/s,(o%256-i%256)/s]}colorCell(e,t,o,i){const[s,r,n]=i;return Math.round((o>>16)%256-s*(e-t))<<16|Math.round((o>>8)%256-r*(e-t))<<8|Math.round(o%256-n*(e-t))}rulePredicate={CellIsRule:(e,t)=>{if(e.type===Qi.error)return!1;const o=this.getters.getLocale(),i=t.values.map((e=>qs(e,o)));switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==i[0]&&e.value.toString().startsWith(i[0].toString());case"EndsWith":return""!==i[0]&&e.value.toString().endsWith(i[0].toString());case"Between":return e.value>=i[0]&&e.value<=i[1];case"NotBetween":return!(e.value>=i[0]&&e.value<=i[1]);case"ContainsText":return e.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(i[0].toString());case"GreaterThan":return e.value>i[0];case"GreaterThanOrEqual":return e.value>=i[0];case"LessThan":return e.value<i[0];case"LessThanOrEqual":return e.value<=i[0];case"NotEqual":return""!==i[0]&&e.value!==i[0];case"Equal":return""===i[0]||e.value===i[0];default:console.warn(r("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}).add("custom_colors",class extends FE{customColors={};shouldUpdateColors=!1;static getters=["getCustomColors"];handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":case"SET_BORDER":case"SET_ZONE_BORDERS":case"SET_FORMATTING":this.history.update("shouldUpdateColors",!0)}}finalize(){if(this.shouldUpdateColors){this.history.update("shouldUpdateColors",!1);for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds())e=e.concat(this.getColorsFromCells(t),this.getFormattingColors(t),this.getChartColors(t));return function(e){const t=[{leadColor:gt(255,0,0),colors:[]},{leadColor:gt(255,128,0),colors:[]},{leadColor:gt(128,128,0),colors:[]},{leadColor:gt(128,255,0),colors:[]},{leadColor:gt(0,255,0),colors:[]},{leadColor:gt(0,255,128),colors:[]},{leadColor:gt(0,255,255),colors:[]},{leadColor:gt(0,127,255),colors:[]},{leadColor:gt(0,0,255),colors:[]},{leadColor:gt(127,0,255),colors:[]},{leadColor:gt(128,0,128),colors:[]},{leadColor:gt(255,0,128),colors:[]}];for(const o of e.map(ft)){let e=500,i=0;t.forEach(((t,s)=>{const r=(n=o,a=t.leadColor,Math.sqrt(Math.pow(n.r-a.r,2)+Math.pow(n.g-a.g,2)+Math.pow(n.b-a.b,2)));var n,a;e>r&&(e=r,i=s)})),t[i].colors.push(o)}return t.map((e=>e.colors.sort(((e,t)=>vt(e).s-vt(t).s)))).flat().map(mt)}([...new Set([...new Set([...e,...Object.keys(this.customColors)])].filter(dt).map(ht))]).filter((e=>!M.includes(e)))}getColorsFromCells(e){const t=Object.values(this.getters.getCells(e)),o=new Set;for(const e of t)e.style?.textColor&&o.add(e.style.textColor),e.style?.fillColor&&o.add(e.style.fillColor);for(const t of this.getters.getBordersColors(e))o.add(t);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),o=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(o.push(t.style.textColor),o.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(o.push(ct(t.minimum.color)),o.push(t.midpoint?ct(t.midpoint.color):void 0),o.push(ct(t.maximum.color)))}return o.filter(He)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let o=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&o.add(t),e.type){case"gauge":const t=e.sectionRule.colors;o.add(t.lowerColor),o.add(t.middleColor),o.add(t.upperColor);break;case"scorecard":const i=e;o.add(i.baselineColorDown),o.add(i.baselineColorUp)}}return[...o]}tryToAddColor(e){const t=ht(e);e&&!M.includes(t)&&this.history.update("customColors",t,!0)}}),Fw=new $i;Fw.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,execute:(e,t)=>Xi(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class Dw{fileStore;constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageSize(t),mimetype:e.type}}getImageFromUser(){return new Promise(((e,t)=>{const o=document.createElement("input");o.setAttribute("type","file"),o.setAttribute("accept","image/*"),o.addEventListener("change",(async()=>{null===o.files||1!=o.files.length?t():e(o.files[0])})),o.click()}))}getImageSize(e){return new Promise(((t,o)=>{const i=new Image;i.src=e,i.addEventListener("load",(()=>{const e={width:i.width,height:i.height};t(e)})),i.addEventListener("error",o)}))}}const Lw=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];Di`
1460
+ `}function iE(e){return new lS(e.join("\n"))}function sE(e,...t){let o=[e[0]];for(let i=0;i<t.length;i++){const s=t[i]instanceof lS?t[i]:JC(t[i]);o.push(s+e[i+1])}return new lS(Ge(o))}function rE(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function nE(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class aE{value;constructor(e){this.value=e}asString(){return oC(String(this.value))}asBool(){return"true"===this.value||"false"!==this.value&&Boolean(Number(this.value))}asNum(){return Number(this.value)}}class lE{rootFile;xlsxFileStructure;warningManager;relationships;currentFile=void 0;areNamespaceIgnored;constructor(e,t,o){this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=o,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfXMLFiles(){return Object.entries(this.xlsxFileStructure).filter((([e])=>"images"!==e)).map((([e,t])=>t)).flat().filter(He)}mapOnElements(e,t){const o=[],i=this.currentFile;let s;if(e.children){const t=this.querySelector(e.parent,e.query)?.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=i,o}catchErrorOnElement(e,t){const o=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([o,e.message].join("\n"))}extractAttr(e,t,o){const i=e.attributes[t];i||this.handleMissingValue(e,`attribute "${t}"`,o);const s=i?.value?i.value:o?.default;return void 0===s?void 0:new aE(s)}extractTextContent(e,t){if(void 0!==t?.default&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===e?.attributes["xml:space"]?.value;let i=e?.textContent;return e&&null!==i||this.handleMissingValue(e,"text content",t),i&&(i=o?i:i.trim()),i?oC(i):t?.default}extractChildAttr(e,t,o,i){let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,i);const r=s?this.extractAttr(s,o,i)?.asString():i?.default;return void 0!==r?new aE(r):void 0}extractChildTextContent(e,t,o){if(void 0!==o?.default&&"string"!=typeof o.default)throw new Error("extractTextContent default value should be a string");let i=this.querySelector(e,t);return i||this.handleMissingValue(e,`child <${t}>`,o),i?this.extractTextContent(i,o):o?.default}handleMissingValue(e,t,o){if(o?.required){if(!o?.default)throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${o.default}`)}}extractColor(e,t,o){if(!e)return o?{rgb:o}:void 0;const i=this.extractAttr(e,"theme")?.asString();let s;if(void 0!==i){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");s=this.getThemeColor(i,t.clrScheme)}else s=this.extractAttr(e,"rgb")?.asString();return{rgb:s,auto:this.extractAttr(e,"auto")?.asBool(),indexed:this.extractAttr(e,"indexed")?.asNum(),tint:this.extractAttr(e,"tint")?.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");const t=this.processRelationshipTargetName(e.target),o=this.getListOfXMLFiles().find((e=>e.file.fileName.endsWith(t)));if(!o||!o.file)throw new Error("Cannot find target file");return o}getTargetImageFile(e){if(!e)throw new Error("Undefined target file");const t=this.processRelationshipTargetName(e.target),o=this.xlsxFileStructure.images.find((e=>e.fileName.endsWith(t)));if(!o)throw new Error("Cannot find target file");return o}querySelector(e,t){return t=this.areNamespaceIgnored?rE(t):nE(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?rE(t):nE(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}processRelationshipTargetName(e){return e.replace(/\.+\//,"")}}class cE extends lE{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:hS}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:hS}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class hE extends lE{theme;constructor(e,t,o,i){super(e,t,o),this.theme=i}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>({sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:this.extractAttr(e,"pivot")?.asBool(),cfRules:this.extractCFRules(e,this.theme)})));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>({sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:this.extractAttr(e,"xm:pivot")?.asBool(),cfRules:this.extractCFRules(e,this.theme)})))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{const o=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===o)throw new Error("Databars conditional formats are not supported.");return{type:o,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:this.extractAttr(e,"dxfId")?.asNum(),stopIfTrue:this.extractAttr(e,"stopIfTrue")?.asBool(),aboveAverage:this.extractAttr(e,"aboveAverage")?.asBool(),percent:this.extractAttr(e,"percent")?.asBool(),bottom:this.extractAttr(e,"bottom")?.asBool(),operator:this.extractAttr(e,"operator")?.asString(),text:this.extractAttr(e,"text")?.asString(),timePeriod:this.extractAttr(e,"timePeriod")?.asString(),rank:this.extractAttr(e,"rank")?.asNum(),stdDev:this.extractAttr(e,"stdDev")?.asNum(),equalAverage:this.extractAttr(e,"equalAverage")?.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const o=this.querySelector(e,"colorScale");if(o)return{colors:this.mapOnElements({parent:o,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(o)}}extractCfIconSet(e){const t=this.querySelector(e,"iconSet, x14:iconSet");if(t)return{iconSet:this.extractAttr(t,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(t,"showValue",{default:!0}).asBool(),percent:this.extractAttr(t,"percent",{default:!0}).asBool(),reverse:this.extractAttr(t,"reverse")?.asBool(),custom:this.extractAttr(t,"custom")?.asBool(),cfvos:this.extractCFVos(t),cfIcons:this.extractCfIcons(t)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>({type:this.extractAttr(e,"type",{required:!0}).asString(),gte:this.extractAttr(e,"gte",{default:!0})?.asBool(),value:e.attributes.val?this.extractAttr(e,"val")?.asString():this.extractChildTextContent(e,"f, xm:f")})))}}class dE extends lE{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!GS[t])throw new Error(`Unsupported chart type ${t}`);const o=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),i=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:o,type:GS[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),labelRange:this.extractChildTextContent(e,"c:ser c:cat c:f"),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:WS[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===i,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:tx c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=rE(e.tagName);if(cS.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class uE extends lE{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==rE(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart"),o=this.querySelector(e,"a:blip");if(!t&&!o)throw new Error("Only chart and image figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:t?this.extractChart(t):this.extractImage(e)}}))}extractFigureAnchor(e,t){const o=this.querySelector(t,e);if(!o)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(o,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(o,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(o,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(o,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),o=this.getTargetXmlFile(this.relationships[t]),i=new dE(o,this.xlsxFileStructure,this.warningManager).extractChart();if(!i)throw new Error("Unable to extract chart definition");return i}extractImage(e){const t=this.querySelector(e,"a:blip"),o=this.extractAttr(t,"r:embed",{required:!0}).asString(),i=this.getTargetImageFile(this.relationships[o]);if(!i)throw new Error("Unable to extract image");const s=this.querySelector(e,"a:xfrm"),r=i.fileName.split(".").at(-1);return{imageSrc:i.imageSrc,mimetype:r?KS[r]:void 0,size:{cx:this.extractChildAttr(s,"a:ext","cx",{required:!0}).asNum(),cy:this.extractChildAttr(s,"a:ext","cy",{required:!0}).asNum()}}}}class gE extends lE{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class pE extends lE{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:this.extractAttr(e,"name")?.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)})))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>({name:this.extractAttr(e,"name")?.asString(),showFirstColumn:this.extractAttr(e,"showFirstColumn")?.asBool(),showLastColumn:this.extractAttr(e,"showLastColumn")?.asBool(),showRowStripes:this.extractAttr(e,"showRowStripes")?.asBool(),showColumnStripes:this.extractAttr(e,"showColumnStripes")?.asBool()})))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class mE extends lE{theme;constructor(e,t,o,i){super(e,t,o),this.theme=i}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=JS(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=JS(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,o=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!o)throw new Error("Cannot find corresponding workbook sheet");return o}extractConditionalFormats(){return new hE(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{const t=this.extractAttr(e,"r:id",{required:!0})?.asString(),o=this.getTargetXmlFile(this.relationships[t]);return new uE(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{const t=this.extractAttr(e,"r:id",{required:!0})?.asString(),o=this.getTargetXmlFile(this.relationships[t]);return new pE(o,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new gE(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:CS.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:ES.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>({width:this.extractAttr(e,"width")?.asNum(),customWidth:this.extractAttr(e,"customWidth")?.asBool(),bestFit:this.extractAttr(e,"bestFit")?.asBool(),hidden:this.extractAttr(e,"hidden")?.asBool(),min:this.extractAttr(e,"min",{required:!0})?.asNum(),max:this.extractAttr(e,"max",{required:!0})?.asNum(),styleIndex:this.extractAttr(e,"style")?.asNum()})))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>({index:this.extractAttr(e,"r",{required:!0})?.asNum(),cells:this.extractCells(e),height:this.extractAttr(e,"ht")?.asNum(),customHeight:this.extractAttr(e,"customHeight")?.asBool(),hidden:this.extractAttr(e,"hidden")?.asBool(),styleIndex:this.extractAttr(e,"s")?.asNum()})))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>({xc:this.extractAttr(e,"r",{required:!0})?.asString(),styleIndex:this.extractAttr(e,"s")?.asNum(),type:PS[this.extractAttr(e,"t",{default:"n"})?.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)})))}extractCellFormula(e){const t=this.querySelector(e,"f");if(t)return{content:this.extractTextContent(t),sharedIndex:this.extractAttr(t,"si")?.asNum(),ref:this.extractAttr(t,"ref")?.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{const t=this.extractAttr(e,"r:id")?.asString();return{xc:this.extractAttr(e,"ref",{required:!0})?.asString(),location:this.extractAttr(e,"location")?.asString(),display:this.extractAttr(e,"display")?.asString(),relTarget:t?this.relationships[t].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),o={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),i=this.extractTextContent(e,{required:!0});o[t]=i}const i=[];for(let e=0;e<Object.keys(o).length;e++)o[e]?i.push(o[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),i.push(""));return i}}class fE extends lE{theme;constructor(e,t,o){super(e.styles,e,t),this.theme=o}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){const t=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),o=this.extractChildAttr(e,"sz","val",{default:q.toString()}).asNum(),i=this.extractColor(this.querySelector(e,"color"),this.theme),s=this.querySelector(e,"i")||void 0,r=s&&"0"!==s.attributes.val?.value,n=this.querySelector(e,"b")||void 0,a=n&&"0"!==n.attributes.val?.value,l=this.querySelector(e,"strike")||void 0,c=l&&"0"!==l.attributes.val?.value,h=this.querySelector(e,"u")||void 0;return{name:t,size:o,color:i,italic:r,bold:a,underline:h&&"none"!==h.attributes.val?.value,strike:c}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){const t=e.children[0];return"patternFill"===t.tagName?{patternType:t.attributes.patternType?.value,bgColor:this.extractColor(this.querySelector(t,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(t,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(t,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){const t={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return t.diagonal&&(t.diagonalUp=this.extractAttr(e,"diagonalUp")?.asBool(),t.diagonalDown=this.extractAttr(e,"diagonalDown")?.asBool()),t}extractSingleBorder(e,t,o){const i=this.querySelector(e,t);if(i&&i.attributes.style)return{style:this.extractAttr(i,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(i.children[0],o,"000000")}}extractAlignment(e){return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"bottom"}).asString(),textRotation:this.extractAttr(e,"textRotation")?.asNum(),wrapText:this.extractAttr(e,"wrapText")?.asBool(),indent:this.extractAttr(e,"indent")?.asNum(),relativeIndent:this.extractAttr(e,"relativeIndent")?.asNum(),justifyLastLine:this.extractAttr(e,"justifyLastLine")?.asBool(),shrinkToFit:this.extractAttr(e,"shrinkToFit")?.asBool(),readingOrder:this.extractAttr(e,"readingOrder")?.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),o=this.querySelector(e,"fill"),i=this.querySelector(e,"border"),s=this.querySelector(e,"numFmt"),r=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:o?this.extractFill(o):void 0,numFmt:s?this.extractNumFormats(s):void 0,alignment:r?this.extractAlignment(r):void 0,border:i?this.extractBorder(i):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class bE extends lE{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),o={};for(let e of t)o[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:o}}))}}function vE(e,t){const o=function(e,t){const o=t[TS],i=o.querySelectorAll(`Override[ContentType="${e}"]`),s=[];for(let e of i){const t=e?.attributes.PartName.value;s.push(t.substring(1))}return s}(e,t);return function(e,t){const o=[];for(let i of e){const e=SE(i,t);o.push({file:{fileName:i,xml:t[i]},rels:e?{fileName:e,xml:t[e]}:void 0})}return o}(o,t)}function SE(e,t){if(e===TS)return"_rels/.rels";let o="";const i=e.split("/");for(let e=0;e<i.length-1;e++)o+=i[e]+"/";return o+="_rels/",o+=i[i.length-1]+".rels",t[o]||(o=void 0),o}class CE{warningManager;xmls;images;constructor(e){this.warningManager=new OS,this.xmls={},this.images=[];for(let t of Object.keys(e))t.endsWith(".xml")||t.endsWith(".rels")?this.xmls[t]=tE(new lS(e[t])):t.includes("media/image")&&this.images.push({fileName:t,imageSrc:e[t].imageSrc})}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new cE(e.theme,e,this.warningManager).getTheme():void 0,o=e.sharedStrings?new cE(e.sharedStrings,e,this.warningManager).getSharedStrings():[],i=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((o=>new mE(o,e,this.warningManager,t).getSheet())),s=e.externalLinks.map((t=>new bE(t,e,this.warningManager).getExternalBook())),r=new fE(e,this.warningManager,t);return{fonts:r.getFonts(),fills:r.getFills(),borders:r.getBorders(),dxfs:r.getDxfs(),numFmts:r.getNumFormats(),styles:r.getStyles(),sheets:i,sharedStrings:o,externalBooks:s}}buildXlsxFileStructure(){const e={sheets:vE(mS.sheet,this.xmls),workbook:vE(mS.workbook,this.xmls)[0],styles:vE(mS.styles,this.xmls)[0],sharedStrings:vE(mS.sharedStrings,this.xmls)[0],theme:vE(mS.themes,this.xmls)[0],charts:vE(mS.chart,this.xmls),figures:vE(mS.drawing,this.xmls),tables:vE(mS.table,this.xmls),pivots:vE(mS.pivot,this.xmls),externalLinks:vE(mS.externalLink,this.xmls),images:this.images};if(!e.workbook.rels)throw Error(r("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:BC(e,this.warningManager),styles:aC(e,this.warningManager),formats:cC(e,this.warningManager),borders:rC(e,this.warningManager),entities:{},revisionId:J};return YC(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=Xe(e.styles[t])})),t}}function EE(e){const t=Wu(e);let o=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Bo.test(e.value)){const t=e.value.trim();return o.includes(t)||o.push(t),`${ce}${o.indexOf(t)}${ce}`}return e.value}))),dependencies:o}}const wE=14,yE="Sheet1";function xE(e,t){if(!e)return OE();if(e["[Content_Types].xml"]){const o=new CE(e);if(e=o.convertXlsx(),t)for(let e of o.warningManager.warnings.sort())console.warn(e)}return"version"in e&&e.version<wE&&(e=function(e){for(let t=IE.findIndex((t=>t.from===e.version));t<IE.length;t++)e=IE[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,o=new Ni;for(const i of e.sheets||[])for(const e of i.figures||[])t.has(e.id)&&(e.id+=o.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){const t=Object.assign(OE(),e,{version:wE});t.sheets=t.sheets?t.sheets.map(((e,t)=>Object.assign(AE(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===t.sheets.length&&t.sheets.push(AE(yE,"Sheet1"));tg(t.settings.locale)||(t.settings.locale=oo);return t}(e),e}(e),e}const IE=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];o.content&&o.content.startsWith("=")&&(o.formula=EE(o.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:o,...i}=t.figures[e].data,s=[];for(let e of o)if(e.labelCell){const t=Jo(e.dataRange),o=e.labelCell+":"+Tt(t.right,t.bottom);s.push(o)}else s.push(e.dataRange);i.dataSetsHaveTitle=Boolean(o[0].labelCell),i.dataSets=s,t.figures[e].data=i}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){const t=[],o=new RegExp(le,"g");for(let i of e.sheets||[]){if(!i.name)continue;const e=i.name,s=e.replace(o,"_");let r=1,n=s;for(;t.includes(n);)n=`${s}${r}`,r++;i.name=n,t.push(n);const a=t=>{if(void 0===t)return t;let o=t.replace(e,n),i=t;for(;i!==o;)i=o,o=i.replace(e,n);return i};for(let e in i.cells){const t=i.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(a))}for(let e of i.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(a),o=a(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:o}}for(let e of i.conditionalFormats||[]){e.ranges=e.ranges.map(a);for(const t of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===e.rule[t]?.type&&(e.rule[t].value=a(e.rule[t].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];if(o.formula){let{text:e,dependencies:t}=o.formula;for(let[o,i]of Object.entries(t)){const t=`\\${ce}${o}\\${ce}`;e=e.replace(new RegExp(t,"g"),i)}o.content=e,delete o.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let o of e.sheets||[])for(let e in o.cells||[]){const i=o.cells[e];i.format&&(i.format=We(i.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}},{description:"Change Border description structure",from:12,to:13,applyMigration(e){for(const t in e.borders){const o=e.borders[t];for(const e in o)Array.isArray(o[e])&&(o[e]={style:o[e][0],color:o[e][1]})}return e}},{description:"Add locale to spreadsheet settings",from:13,to:14,applyMigration:e=>(e.settings||(e.settings={}),e.settings.locale||(e.settings.locale=oo),e)}];function RE(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const o=[],i=[],s=e=>{if("CREATE_SHEET"===e.type)o.push(e.sheetId);else if("sheetId"in e&&!o.includes(e.sheetId))return{...e,sheetId:yE};return e};for(const e of t)"REMOTE_REVISION"===e.type?i.push({...e,commands:e.commands.map(s)}):i.push(e);return i}(e,t),t=TE(t,"SORT_CELLS"),t=function(e,t){const o=[],i={};for(const t of e.sheets||[])t.figures?.forEach((e=>{"chart"===e.tag&&(i[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const o of e.commands){let e=o;switch(o.type){case"CREATE_CHART":i[o.id]=o.definition;break;case"UPDATE_CHART":if(!i[o.id]){console.log(`Fix chart definition: chart with id ${o.id} not found.`);continue}const t={...i[o.id],...o.definition};e={...o,definition:t},i[o.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=TE(t,"SET_DECIMAL")),t}function TE(e,t){const o=[];for(const i of e)"REMOTE_REVISION"===i.type?o.push({...i,commands:i.commands.filter((e=>e.type!==t))}):o.push(i);return o}function AE(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function OE(e="Sheet1"){return{version:wE,sheets:[AE(yE,e)],entities:{},styles:{},formats:{},borders:{},revisionId:J,uniqueFigureIds:!0,settings:{locale:oo}}}function NE(e,t){return{...AE(e,t),charts:[],images:[]}}class ME{static getters=[];history;dispatch;constructor(e,t){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const o of e){let e=o.call(this,t);Array.isArray(e)||(e=[e]);const i=e.filter((e=>0!==e));if(i.length)return i}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}class _E extends ME{getters;uuidGenerator;constructor({getters:e,stateObserver:t,range:o,dispatch:i,uuidGenerator:s}){super(t,i),o.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=s}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class FE{id;compiledFormula;format;style;dependencies;sheetId;buildFormulaContent;isFormula=!0;constructor(e,t,o,i,s,r,n){this.id=e,this.compiledFormula=t,this.format=o,this.style=i,this.dependencies=s,this.sheetId=r,this.buildFormulaContent=n}get content(){return this.buildFormulaContent(this.sheetId,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})}}function DE(e){return""===e?NaN:Number(e)}class LE{id;zone;filters;constructor(e){this.filters=[],this.zone=e;const t=new Ni;this.id=t.uuidv4();for(const o of Oe(e.left,e.right+1)){const e={...this.zone,left:o,right:o};this.filters.push(new PE(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){return this.filters.find((t=>t.col===e))?.id}clone(){return new LE(this.zone)}}class PE{id;zoneWithHeaders;constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}function kE(e){return Object.entries(e).map((([e,t])=>t?UE(parseInt(e,10),t):void 0)).filter(He).map((e=>Tt(e.left,e.top)+":"+Tt(e.right,e.bottom)))}function UE(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}class VE{getters;providers=[];constructor(e){this.getters=e}static getters=["getRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData","getRangeFromZone"];allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:27:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";const s=[...e.elements];s.sort(((e,t)=>t-e));const r=Ne(s);this.executeOnAllRanges((s=>{if(s.sheetId!==e.sheetId)return{changeType:"NONE"};let n=s,a="NONE";for(let e of r){const r=Math.min(...e),l=Math.max(...e);if(s.zone[t]<=r&&r<=s.zone[o]){const e=Math.min(s.zone[o],l)-r+1;a="RESIZE",n=this.createAdaptedRange(n,i,a,-e)}else if(s.zone[t]>=r&&s.zone[o]<=l)a="REMOVE",n=s.clone({...this.getInvalidRange()});else if(s.zone[t]<=l&&s.zone[o]>=l){const e=l-s.zone[t]+1;a="RESIZE",n=this.createAdaptedRange(n,i,a,-e),n=this.createAdaptedRange(n,i,"MOVE",-(s.zone[t]-r))}else r<s.zone[t]&&(a="MOVE",n=this.createAdaptedRange(n,i,a,-(l-r+1)))}return"NONE"!==a?{changeType:a,range:n}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((s=>{if(s.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(s.zone[t]<=e.base&&e.base<s.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(s,i,"RESIZE",e.quantity)};if(e.base<s.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(s,i,"MOVE",e.quantity)}}else{if(s.zone[t]<e.base&&e.base<=s.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(s,i,"RESIZE",e.quantity)};if(e.base<=s.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(s,i,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const o=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:o})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const o=void 0,i=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:i,invalidSheetName:o})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId||!di(o.zone,t))return{changeType:"NONE"};const i=e.targetSheetId,s=e.col-t.left,r=e.row-t.top,n=this.createAdaptedRange(o,"both","MOVE",[s,r]),a=e.sheetId!==i||n.prefixSheet;return{changeType:"MOVE",range:n.clone({sheetId:i,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const o=e(t);return"NONE"===o.changeType||ei(o.range.zone)?o:{range:o.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,o,i){const s=vi(e.unboundedZone,t,o,i);return e.clone({zone:s})}executeOnAllRanges(e,t){const o=this.verifyRangeRemoved(e);for(const e of this.providers)e(o,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,o,i){const s=e.map((e=>Ii.fromRange(e,this.getters)));return s.map((e=>{if(!ei(e.zone))return e;const s=e.prefixSheet?e.sheetId:i,r={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:o),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:o)};return e.clone({sheetId:s,zone:r}).orderZone()}))}getRangeFromSheetXC(e,t){if(!qo.test(t))return new Ii({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let o,i=t,s=!1;t.includes("!")&&(({xc:i,sheetName:o}=Ko(t)),o&&(s=!0));const r=Qo(i),n=Ii.getRangeParts(i,r),a=o&&!this.getters.getSheetIdByName(o)?o:void 0,l=this.getters.getSheetIdByName(o)||e;return new Ii({prefixSheet:s,zone:r,sheetId:l,invalidSheetName:a,parts:n},this.getters.getSheetSize).orderZone()}getRangeString(e,t){if(!e)return Q;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return Q;if(e.zone.left<0||e.zone.top<0)return Q;const o=Ii.fromRange(e,this.getters);let i=o.sheetId!==t||o.invalidSheetName||o.prefixSheet,s="";if(i&&(s=o.invalidSheetName?o.invalidSheetName:Ee(this.getters.getSheetName(o.sheetId))),i&&!s)return Q;let r=this.getRangePartString(o,0);return o.parts&&2===o.parts.length&&(o.zone.top!==o.zone.bottom||o.zone.left!==o.zone.right||o.parts[0].rowFixed||o.parts[0].colFixed||o.parts[1].rowFixed||o.parts[1].colFixed)&&(r+=":",r+=this.getRangePartString(o,1)),`${i?s+"!":""}${r}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromZone(e,t){return new Ii({sheetId:e,zone:t,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}],prefixSheet:!1},this.getters.getSheetSize)}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new Ii(t,this.getters.getSheetSize)}getRangePartString(e,t){const o=e.parts&&e.parts[t].colFixed?"$":"",i=Et(0===t?e.zone.left:e.zone.right),s=e.parts&&e.parts[t].rowFixed?"$":"",r=String(0===t?e.zone.top+1:e.zone.bottom+1);let n="";return n=e.isFullCol?0===t&&e.unboundedZone.hasHeader?o+i+s+r:o+i:e.isFullRow?0===t&&e.unboundedZone.hasHeader?o+i+s+r:s+r:o+i+s+r,n}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:Q}}}class zE extends ME{static layers=[];getters;ui;selection;constructor({getters:e,stateObserver:t,dispatch:o,uiActions:i,selection:s}){super(t,o),this.getters=e,this.ui=i,this.selection=s}drawGrid(e,t){}}const BE=tu.mapping;function HE(e,t,o){return new $E(e,t,o).getParameters()}class $E{getters;computeCell;evalContext;constructor(e,t,o){this.getters=t,this.computeCell=o,this.evalContext=Object.assign(Object.create(BE),e,{getters:this.getters,locale:this.getters.getLocale()})}getParameters(){return[this.refFn.bind(this),this.range.bind(this),this.evalContext]}refFn(e,t,o,i){if(t)return{value:ti(e.zone)};if(!ei(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(i?r("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",o.toString(),i.toString()):r("Function %s expects its parameters to be single values or single cell references, not ranges.",o.toString()));if(e.invalidSheetName)throw new Error(r("Invalid sheet name: %s",e.invalidSheetName));return this.readCell(e)}readCell(e){if(!this.getters.tryGetSheet(e.sheetId))throw new Error(r("Invalid sheet name"));const t={sheetId:e.sheetId,col:e.zone.left,row:e.zone.top},o=this.getEvaluatedCellIfNotEmpty(t);return void 0===o?{value:null,format:this.getters.getCell(t)?.format}:o}getEvaluatedCellIfNotEmpty(e){const t=this.getEvaluatedCell(e);if(t.type===Qi.empty){const t=this.getters.getCell(e);if(!t||""===t.content)return}return t}getEvaluatedCell(e){const t=this.computeCell(e);if(t.type===Qi.error)throw t.error;return t}range({sheetId:e,zone:t}){if(!ei(t))throw new u;const o=ai(t,this.getters.getSheetZone(e));if(!o)return{value:[[]],format:[[]]};const i=o.bottom-o.top+1,s=o.right-o.left+1,r=Array.from({length:s},(()=>Array.from({length:i}))),n=Array.from({length:s},(()=>Array.from({length:i})));for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++){const s=this.getEvaluatedCellIfNotEmpty({sheetId:e,col:t,row:i});if(s){const e=t-o.left,a=i-o.top;r[e][a]=s.value,void 0!==s.format&&(n[e][a]=s.format)}}return{value:r,format:n}}}class WE{inverseDependencies=new Map;dependencies=new Map;removeAllDependencies(e){const t=this.dependencies.get(e);if(t){for(const o of t)this.inverseDependencies.get(o)?.delete(e);this.dependencies.delete(e)}}addDependencies(e,t){for(const o of t){const t=this.inverseDependencies.get(o);t?t.add(e):this.inverseDependencies.set(o,new Set([e]))}const o=this.dependencies.get(e);o?o.push(...t):this.dependencies.set(e,t)}getCellsDependingOn(e){const t=new st,o=Array.from(e);for(;o.length>0;){const e=o.shift();t.add(e);const i=this.inverseDependencies.get(e)||new Set;for(const e of i)t.has(e)||o.push(e)}return t.delete(...e),t}}class GE{resultsToArrayFormulas=new Map;arrayFormulasToResults=new Map;getFormulaPositionsSpreadingOn(e){return this.resultsToArrayFormulas.get(e)||qE}getArrayResultPositionIds(e){return this.arrayFormulasToResults.get(e)||qE}removeNode(e){this.resultsToArrayFormulas.delete(e),this.arrayFormulasToResults.delete(e)}addRelation({arrayFormulaPositionId:e,resultPositionId:t}){this.resultsToArrayFormulas.has(t)||this.resultsToArrayFormulas.set(t,new Set),this.resultsToArrayFormulas.get(t)?.add(e),this.arrayFormulasToResults.has(e)||this.arrayFormulasToResults.set(e,new Set),this.arrayFormulasToResults.get(e)?.add(t)}hasArrayFormulaResult(e){return this.resultsToArrayFormulas.has(e)}isArrayFormula(e){return this.arrayFormulasToResults.has(e)}}const qE=[];class ZE{context;getters;compilationParams;positionEncoder=new XE;evaluatedCells=new Map;formulaDependencies=qe(new WE);blockedArrayFormulas=new Set;spreadingRelations=new GE;constructor(e,t){this.context=e,this.getters=t,this.compilationParams=HE(e,t,(e=>this.computeCell(this.encodePosition(e))))}getEvaluatedCell(e){return this.evaluatedCells.get(this.encodePosition(e))||Zs("",{locale:this.getters.getLocale()})}getArrayFormulaSpreadingOn(e){const t=this.encodePosition(e),o=this.getArrayFormulaSpreadingOnId(t);return void 0!==o?this.decodePosition(o):void 0}getEvaluatedPositions(){return[...this.evaluatedCells.keys()].map(this.decodePosition.bind(this))}getArrayFormulaSpreadingOnId(e){if(!this.spreadingRelations.hasArrayFormulaResult(e))return;const t=this.spreadingRelations.getFormulaPositionsSpreadingOn(e);return Array.from(t).find((e=>!this.blockedArrayFormulas.has(e)))}updateDependencies(e){const t=this.encodePosition(e);this.formulaDependencies().removeAllDependencies(t);const o=this.getDirectDependencies(t);this.formulaDependencies().addDependencies(t,o)}updateCompilationParameters(){this.compilationParams=HE(this.context,this.getters,(e=>this.computeCell(this.encodePosition(e))))}evaluateCells(e){const t=e.map(this.encodePosition.bind(this)),o=new st(t),i=this.getArrayFormulasImpactedByChangesOf(t);o.add(...this.getCellsDependingOn(t)),o.add(...i),o.add(...this.getCellsDependingOn(i)),this.evaluate(o)}getArrayFormulasImpactedByChangesOf(e){const t=new st;for(const o of e){const e=this.getCell(o)?.content,i=this.getArrayFormulaSpreadingOnId(o);void 0!==i&&t.add(i),e||t.add(...this.getArrayFormulasBlockedByOrSpreadingOn(o))}return t}buildDependencyGraph(){this.blockedArrayFormulas=new Set,this.spreadingRelations=new GE,this.formulaDependencies=qe((()=>{const e=new WE;for(const t of this.getAllCells()){const o=this.getDirectDependencies(t);e.addDependencies(t,o)}return e}))}evaluateAllCells(){this.evaluatedCells=new Map,this.evaluate(this.getAllCells())}getAllCells(){const e=new st;for(const t of this.getters.getSheetIds()){const o=this.getters.getCells(t);for(const t in o)e.add(this.encodePosition(this.getters.getCellPosition(t)))}return e}getArrayFormulasBlockedByOrSpreadingOn(e){if(!this.spreadingRelations.hasArrayFormulaResult(e))return[];const t=this.spreadingRelations.getFormulaPositionsSpreadingOn(e),o=new st(t);return o.add(...this.getCellsDependingOn(t)),o}nextPositionsToUpdate=new st;cellsBeingComputed=new Set;evaluate(e){this.cellsBeingComputed=new Set,this.nextPositionsToUpdate=e;let t=0;for(;this.nextPositionsToUpdate.size&&t++<30;){const e=Array.from(this.nextPositionsToUpdate);this.nextPositionsToUpdate.clear();for(let t=0;t<e.length;++t){const o=e[t];this.evaluatedCells.delete(o)}for(let t=0;t<e.length;++t){const o=e[t];this.setEvaluatedCell(o,this.computeCell(o))}}}setEvaluatedCell(e,t){this.nextPositionsToUpdate.has(e)&&this.nextPositionsToUpdate.delete(e),this.evaluatedCells.set(e,t)}computeCell(e){const t=this.evaluatedCells.get(e);if(t)return t;this.blockedArrayFormulas.has(e)||this.invalidateSpreading(e);const o=this.getCell(e);if(void 0===o)return Zs("",{locale:this.getters.getLocale()});const i=o.id;try{if(this.cellsBeingComputed.has(i))throw new d;return this.cellsBeingComputed.add(i),o.isFormula?this.computeFormulaCell(o):Gs(o.content,{format:o.format,locale:this.getters.getLocale()})}catch(e){return this.handleError(e,o)}finally{this.cellsBeingComputed.delete(i)}}handleError(e,t){e instanceof Error||(e=new Error(e));const o=e?.errorType||a.GenericError,i=this.compilationParams[2].__lastFnCalled||"",s=new c(o,e.message.replace("[[FUNCTION_NAME]]",i),void 0!==e.logLevel?e.logLevel:l.error);return Ks(t.content,s)}computeFormulaCell(e){const t=e.id;this.compilationParams[2].__originCellXC=()=>{const e=this.compilationParams[2].getters.getCellPosition(t);return Tt(e.col,e.row)};const o=e.compiledFormula.execute(e.dependencies,...this.compilationParams);!function(e){const{value:t,format:o}=e;if(!cs(t)){if(cs(o))throw new Error("A format matrix should never be associated with a scalar value");return}if(cs(o)){if(!(t.length===o.length&&t[0].length===o[0].length))throw new Error("Formats and values should have the same dimensions!")}}(o);const{value:i,format:s}=o;if(!cs(i))return Zs(i,{format:e.format||s,locale:this.getters.getLocale()});const r=this.getters.getCellPosition(t);this.assertSheetHasEnoughSpaceToSpreadFormulaResult(r,i),jE(i,this.updateSpreadRelation(r)),jE(i,this.checkCollision(r)),jE(i,this.spreadValues(r,o));const n=YE(s);return Zs(i[0][0],{format:e.format||n(0,0),locale:this.getters.getLocale()})}assertSheetHasEnoughSpaceToSpreadFormulaResult({sheetId:e,col:t,row:o},i){const s=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),a=t+i.length<=s,l=o+i[0].length<=n;if(!a||!l){if(a)throw new Error(r("Result couldn't be automatically expanded. Please insert more rows."));if(l)throw new Error(r("Result couldn't be automatically expanded. Please insert more columns."));throw new Error(r("Result couldn't be automatically expanded. Please insert more columns and rows."))}}updateSpreadRelation({sheetId:e,col:t,row:o}){const i=this.encodePosition({sheetId:e,col:t,row:o});return(s,r)=>{const n={sheetId:e,col:s+t,row:r+o},a=this.encodePosition(n);this.spreadingRelations.addRelation({resultPositionId:a,arrayFormulaPositionId:i})}}checkCollision({sheetId:e,col:t,row:o}){const i=this.encodePosition({sheetId:e,col:t,row:o});return(s,n)=>{const a={sheetId:e,col:s+t,row:n+o};if(this.getters.getCell(a)?.content||this.getters.getEvaluatedCell(a).type!==Qi.empty)throw this.blockedArrayFormulas.add(i),new Error(r("Array result was not expanded because it would overwrite data in %s.",Tt(a.col,a.row)));this.blockedArrayFormulas.delete(i)}}spreadValues({sheetId:e,col:t,row:o},i){const s=YE(i.format);return(r,n)=>{const a={sheetId:e,col:r+t,row:n+o},l=this.getters.getCell(a)?.format,c=Zs(i.value[r][n],{format:l||s(r,n),locale:this.getters.getLocale()}),h=this.encodePosition(a);this.setEvaluatedCell(h,c),this.nextPositionsToUpdate.add(...this.getCellsDependingOn([h]))}}invalidateSpreading(e){if(this.spreadingRelations.isArrayFormula(e)){for(const t of this.spreadingRelations.getArrayResultPositionIds(e)){const e=this.getCell(t)?.content;e||(this.evaluatedCells.delete(t),this.nextPositionsToUpdate.add(...this.getCellsDependingOn([t])),this.nextPositionsToUpdate.add(...this.getArrayFormulasBlockedByOrSpreadingOn(t)))}this.spreadingRelations.removeNode(e)}}getDirectDependencies(e){const t=this.getCell(e);if(!t?.isFormula)return[];const o=[];for(const e of t.dependencies){if(e.invalidSheetName||e.invalidXc)continue;const t=e.sheetId;bi(e.zone,((e,i)=>{o.push(this.encodePosition({sheetId:t,col:e,row:i}))}))}return o}getCellsDependingOn(e){return this.formulaDependencies().getCellsDependingOn(e)}getCell(e){return this.getters.getCell(this.decodePosition(e))}encodePosition(e){return this.positionEncoder.encode(e)}decodePosition(e){return this.positionEncoder.decode(e)}}function jE(e,t){for(let o=0;o<e.length;++o)for(let i=0;i<e[o].length;++i)0===o&&0===i||t(o,i)}function YE(e){return cs(e)?(t,o)=>e[t][o]:()=>e}class XE{sheetMapping={};inverseSheetMapping=new Map;constructor(){try{o_spreadsheet.__DEBUG__=o_spreadsheet.__DEBUG__||{},o_spreadsheet.__DEBUG__.decodePosition=this.decode.bind(this),o_spreadsheet.__DEBUG__.encodePosition=this.encode.bind(this)}catch(e){}}encode({sheetId:e,col:t,row:o}){return this.encodeSheet(e)<<42n|BigInt(t)<<21n|BigInt(o)}decode(e){const t=Number(2097151n&e),o=Number(e>>21n&2097151n);return{sheetId:this.decodeSheet(e>>42n),col:o,row:t}}encodeSheet(e){const t=this.sheetMapping[e];if(void 0===t){const t=BigInt(Object.keys(this.sheetMapping).length);return this.sheetMapping[e]=t,this.inverseSheetMapping.set(t,e),t}return t}decodeSheet(e){const t=this.inverseSheetMapping.get(e);if(void 0===t)throw new Error("Sheet id not found");return t}}class KE{cells;getters;index=0;direction;constructor(e,t,o){this.cells=e,this.getters=t,this.direction=o}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:o,tooltip:i}=Js.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:o,tooltip:i,origin:{col:e.data.col,row:e.data.row}}}}class QE{subscriptions={};on(e,t,o){if(!o)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:o})}trigger(e,t){const o=this.subscriptions[e]||[];for(let e=0,i=o.length;e<i;e++){const i=o[e];i.callback.call(i.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function JE(e,t){return{...e,definition:Zp(e.definition,t)}}function ew(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let o=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)o>t&&o--}if("ADD_COLUMNS_ROWS"===t.type){o=o>("before"===t.position?t.base-1:t.base)?o+t.quantity:o}return o>0?{...e,quantity:o}:void 0}_b.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],JE),_b.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],JE),_b.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const o=t.sheetId;if(e.targetSheetId===o||e.sheetId===o)return;return e})),_b.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),_b.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){if(e.name===t.name)return{...e,name:e.name?.match(/\d+/)?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),_b.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const o=[];for(const i of e.target)for(const e of t.target)ci(i,e)||o.push({...i});if(o.length)return{...e,target:o};return})),_b.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],ew),_b.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],ew),_b.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const o of e.target)for(const e of t.target)if(ci(e,o))return;return e}));const tw=[{match:function(e){return"sheetId"in e},fn:sw},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const o=sw(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;const i=[];for(const o of e.target){const e=Ag(o,t);e&&i.push(e)}if(!i.length)return"IGNORE_COMMAND";return{...e,target:i}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const o=sw(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const o="COL"===t.dimension?"col":"row";let i=e[o];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(i))return"IGNORE_COMMAND";for(let t of e)i>=t&&i--}"ADD_COLUMNS_ROWS"===t.type&&(i>t.base||i===t.base&&"before"===t.position)&&(i+=t.quantity);return{...e,[o]:i}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const o of t.target){if(!(e.col===o.left&&e.row===o.top)&&hi(e.col,e.row,o))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const o=sw(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const o="ADD_COLUMNS_ROWS"===e.type,i=o?"base":"elements";let s=o?[e[i]]:e[i];if("REMOVE_COLUMNS_ROWS"===t.type&&(s=s.map((e=>{if(t.elements.includes(e))return;const o=t.elements.sort(((e,t)=>t-e));for(let t of o)e>t&&e--;return e})).filter(He)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;s=s.map((o=>o>e?o+t.quantity:o))}if(s.length){let t=s;return o&&(t=s[0]),{...e,[i]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){if(!("sheetId"in t))return e;const o=[],i="DELETE_SHEET"===t.type&&t.sheetId;for(const s of e.ranges)if(s._sheetId!==t.sheetId)o.push({...s,_zone:s._zone});else{const e=Ag(s._zone,t);e&&i!==s._sheetId&&o.push({...s,_zone:e})}if(!o.length)return"IGNORE_COMMAND";return{...e,ranges:o}}}];function ow(e,t){const o=_b.getTransformation(e.type,t.type);return o?o(e,t):function(e,t){for(const{match:o,fn:i}of tw)if(o(e)){const o=i(e,t);if("SKIP_TRANSFORMATION"===o)continue;if("IGNORE_COMMAND"===o)return;e=o}return e}(e,t)}function iw(e,t){let o=[...e];for(const e of t)o=o.map((t=>ow(t,e))).filter(He);return o}function sw(e,t){if(!("sheetId"in t))return e;const o="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===o?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class rw{rootCommand;timestamp;id;clientId;_commands=[];_changes=[];constructor(e,t,o,i,s,r){this.rootCommand=i,this.timestamp=r,this.id=e,this.clientId=t,this._commands=[...o],this._changes=s?[...s]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class nw extends Error{}class aw extends QE{revisions;transportService;serverRevisionId;clients={};clientId="local";debouncedMove;pendingMessages=[];waitingAck=!1;waitingUndoRedoAck=!1;isReplayingInitialRevisions=!1;processedRevisions=new Set;uuidGenerator=new Ni;constructor(e,t,o=J){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=o,this.debouncedMove=function(e,t,o){let i;return function(){const s=this,r=arguments,n=o&&!i;clearTimeout(i),i=setTimeout((function(){i=null,o||e.apply(s,r)}),t),n&&e.apply(s,r)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t,o){if(!t.length||!o.length||!this.canApplyOptimisticUpdate())return;const i=new rw(this.uuidGenerator.uuidv4(),this.clientId,t,e,o,Date.now());this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new nw("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(He))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}getLastLocalNonEmptyRevision(e){const t=this.revisions.getRevertedExecution();for(const o of t){if("SNAPSHOT"===o.rootCommand)return;if(o.rootCommand&&"REMOTE"!==o.rootCommand&&(!e.includes(o.rootCommand?.type)&&o.commands.length))return o}}_move(e){if(!this.clients[this.clientId])return;const t=this.clients[this.clientId]?.position;if(t?.col===e.col&&t.row===e.row&&t.sheetId===e.sheetId)return;const o=t?"CLIENT_MOVED":"CLIENT_JOINED",i=this.getClient();this.clients[this.clientId]={...i,position:e},this.transportService.sendMessage({type:o,version:1,client:{...i,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":const{clientId:t,commands:o,timestamp:i}=e,s=new rw(e.nextRevisionId,t,o,"REMOTE",void 0,i);if(s.clientId!==this.clientId){this.revisions.insert(s.id,s,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:iw(o,t)})}break;case"SNAPSHOT_CREATED":{const t=new rw(e.nextRevisionId,"server",[],"SNAPSHOT",void 0,Date.now());this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const lw=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];var cw;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(cw||(cw={}));class hw extends zE{inputHasSingleRange;static layers=[1];static getters=[];ranges=[];focusedRangeIndex=null;activeSheet;willAddNewRange=!1;constructor(e,t,o){if(o&&t.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e),this.inputHasSingleRange=o,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){switch(e.type){case"ADD_RANGE":case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange&&1===this.ranges.length)return 31;break;case"CHANGE_RANGE":if(this.inputHasSingleRange&&e.value.split(",").length>1)return 31}return 0}handleEvent(e){const t=this.activeSheet,o=this.getters.getActiveSheetId(),i=e.anchor.zone,s=this.getters.getRangeFromZone(o,e.options.unbounded?this.getters.getUnboundedZone(o,i):i);this.add([this.getters.getSelectionRangeString(s,t)])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const o=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"ADD_RANGE":this.insertNewRange(this.ranges.length,[e.value]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),i=this.getters.expandZone(e.sheetIdTo,Ei({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:i})}}}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],xc:t}}insertNewRange(e,t){const o=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:o+t+1,color:lt[(o+t)%lt.length]}))))}setRange(e,t){const[,...o]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,o),o.length&&this.focus(e+o.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const o=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return o.map((e=>{const{sheetName:o}=Ko(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:o&&this.getters.getSheetIdByName(o)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:o}=Ko(t),i=this.getters.getSheetIdByName(o),s=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(i===s||void 0===i&&s===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}const dw=[uw,function(e,t){return"target"in t&&Array.isArray(t.target)?{...Se(t),target:e.getSelectedZones()}:t},function(e,t){if(!("row"in t)||!("col"in t))return t;const{col:o,row:i}=e.getActivePosition();return{...Se(t),col:o,row:i}}];function uw(e,t){return"sheetId"in t?{...Se(t),sheetId:e.getActiveSheetId()}:t}const gw=new Ni;function pw(e,t){const o=e.getSelectedZone();return{...uw(e,t),elements:"COL"===t.dimension?Oe(o.left,o.right+1):Oe(o.top,o.bottom+1)}}function mw(e,t){const o=e.getSelectedZone();return{...Se(t),zone:o}}function fw(e,t){const o=Se(t),i=e.getSelectedZone(),{top:s,bottom:r,left:n,right:a}=i;return"cols"in o?o.cols=Oe(n,a+1):"rows"in o&&(o.rows=Oe(s,r+1)),o}const bw=new $i;bw.add("UPDATE_CELL",Sw),bw.add("CLEAR_CELL",Sw),bw.add("DELETE_CONTENT",Sw),bw.add("ADD_MERGE",Sw),bw.add("REMOVE_MERGE",Sw),bw.add("SET_FORMATTING",Sw),bw.add("CLEAR_FORMATTING",Sw),bw.add("SET_BORDER",Sw),bw.add("CREATE_FILTER_TABLE",Sw),bw.add("REMOVE_FILTER_TABLE",Sw),bw.add("HIDE_SHEET",Sw),bw.add("ADD_COLUMNS_ROWS",(function(e,t){const o=e.getActivePosition();return{...uw(e,t),base:"COL"===t.dimension?o.col:o.row}})),bw.add("REMOVE_COLUMNS_ROWS",pw),bw.add("HIDE_COLUMNS_ROWS",pw),bw.add("RESIZE_COLUMNS_ROWS",pw),bw.add("CREATE_SHEET",(function(e,t){const o=Se(t);o.sheetId=gw.uuidv4();const i=t.name||e.getSheet(e.getActiveSheetId()).name,s=i.match(/(.+?)\d*$/)?.[1]||i;return o.name=e.getNextSheetName(s),o})),bw.add("CREATE_FIGURE",(function(e,t){const o=uw(e,t);return o.figure.id=gw.uuidv4(),o})),bw.add("CREATE_CHART",(function(e,t){return{...uw(e,t),id:gw.uuidv4()}})),bw.add("CREATE_IMAGE",(function(e,t){return{...uw(e,t),figureId:gw.uuidv4()}}));const vw=new $i;function Sw(e,t){let o=Se(t);for(const t of dw)o=t(e,o);return o}function Cw(e,t){if(!t)return;if(!bw.contains(t.type))return;return bw.get(t.type)(e,t)}function Ew(e,t){if(e.rootCommand&&"object"==typeof e.rootCommand)return rs(e.rootCommand)?Cw(t,e.rootCommand):function(e,t,o){if(!vw.contains(t.type))return;return vw.get(t.type)(e,t,o)}(t,e.rootCommand,e.commands)}vw.add("STOP_EDITION",(function(e,t,o){return o.map((t=>Cw(e,t))).filter(He)})),vw.add("PASTE",(function(e,t){return{type:"REPEAT_PASTE",pasteOption:Se(t.pasteOption),target:e.getSelectedZones()}})),vw.add("INSERT_CELL",mw),vw.add("DELETE_CELL",mw),vw.add("AUTORESIZE_COLUMNS",fw),vw.add("AUTORESIZE_ROWS",fw),vw.add("SORT_CELLS",(function(e,t){const o=e.getSelectedZone();return{...uw(e,t),col:o.left,row:o.top,zone:o}})),vw.add("SUM_SELECTION",Sw),vw.add("SET_DECIMAL",Sw);class ww{getters;dispatch;selection;operation;sheetId;constructor(e,t,o,i){this.getters=t,this.dispatch=o,this.selection=i,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,o,i){const s=this.getters.getActiveSheetId(),r=t+i-this.getters.getNumberRows(s);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(s)-1,sheetId:s,quantity:r,position:"after"});const n=e+o-this.getters.getNumberCols(s);n>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(s)-1,sheetId:s,quantity:n,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class yw extends ww{cells;copiedTables;zones;constructor(e,t,o,i,s){if(super(t,o,i,s),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const r=new Set(e.map((e=>e.left))),n=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===r.size&&1===n.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let i=0;i<o;i++)if(ci(e[i],t))return e[i]=ni(e[i],t),e;return e[o]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>fi(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=o.getActiveSheetId();for(let e of u){let t=[];for(let i of d){const s={col:i,row:e,sheetId:p};t.push({cell:o.getCell(s),style:o.getCellComputedStyle(s),evaluatedCell:o.getEvaluatedCell(s),border:o.getCellBorder(s)||void 0,position:s})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const o of Oe(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:o,row:e.zone.top}));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?20:0}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==t?.pasteOption)return 22;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 21;const i=this.cells.length,s=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(o,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(o,e[0])||i*s!=1))return 2;const{xSplit:r,ySplit:n}=this.getters.getPaneDivisions(o);for(const t of this.getPasteZones(e))if(t.left<r&&t.right>=r||t.top<n&&t.bottom>=n)return 76;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const o=this.cells.length,i=this.cells[0].length,s="CUT"===this.operation;t?.selectTarget&&this.selectPastedZone(i,o,s,e)}pasteFromCopy(e,t){if(1===e.length){const o=this.cells.length,i=this.cells[0].length,s=this.pastedZones(e,i,o);for(const e of s)this.pasteZone(e.left,e.top,t)}else for(const o of e)for(let e=o.left;e<=o.right;e++)for(let i=o.top;i<=o.bottom;i++)this.pasteZone(e,i,t);void 0===t?.pasteOption&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const o=e[0];this.pasteZone(o.left,o.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:o.left,row:o.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e),this.cells.forEach((e=>{e.forEach((e=>{e.cell&&(e.cell=void 0)}))}))}pastedZones(e,t,o){const i=e[0],s=Math.max(1,Math.floor((i.right+1-i.left)/t)),r=Math.max(1,Math.floor((i.bottom+1-i.top)/o)),n=[];for(let e=0;e<s;e++)for(let s=0;s<r;s++){const r=i.top+s*o,a=i.left+e*t;n.push({left:a,top:r,bottom:r+o-1,right:a+t-1})}return n}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const o=[],i=t.length,s=t[0].length,r=e[e.length-1],n=r.left,a=r.top,l=Math.max(1,Math.floor((r.right+1-n)/s)),c=Math.max(1,Math.floor((r.bottom+1-a)/i));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)o.push({left:n,top:a,right:n-1+e*s,bottom:a-1+t*i});return o}selectPastedZone(e,t,o,i){const s=i[0],r=s.left,n=s.top;if(t>1||e>1||o){const s=this.pastedZones(i,e,t),a=o?s[0]:ni(...s);this.selection.selectZone({cell:{col:r,row:n},zone:a},{scrollIntoView:!1})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,o){const i=this.cells.length,s=this.cells[0].length,r="onlyValue"!==o?.pasteOption&&o?.shouldPasteCF,n=this.getters.getActiveSheetId();this.addMissingDimensions(s,i,e,t);for(let a=0;a<i;a++){const i=this.cells[a];for(let l=0;l<s;l++){const s=i[l],c={col:e+l,row:t+a,sheetId:n};"CUT"!==this.operation&&this.pasteMergeIfExist(s.position,c),this.pasteCell(s,c,this.operation,o),r&&this.pasteCf(s.position,c)}}}pasteCell(e,t,o,i){const{sheetId:s,col:r,row:n}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==i?.pasteOption){const o=this.getters.getCellBorder(t),i=e.border,a={top:o?.top||i?.top,bottom:o?.bottom||i?.bottom,left:o?.left||i?.left,right:o?.right||i?.right};this.dispatch("SET_BORDER",{sheetId:s,col:r,row:n,border:a})}if(e.cell){if("onlyFormat"===i?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===i?.pasteOption){const o=this.getters.getLocale(),i=vo(e.evaluatedCell.value,{locale:o});return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===o){const t=r-e.position.col,i=n-e.position.row;a=this.getUpdatedContent(s,e.cell,t,i,o)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===i?.pasteOption?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===i?.pasteOption?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,o,i,s){const r=this.getters.createAdaptedRanges(t.dependencies,o,i,e);return this.getters.buildFormulaContent(e,t,r)}pasteMergeIfExist(e,t){let{sheetId:o,col:i,row:s}=e;const{col:r,row:n}=this.getters.getMainCellPosition(e);if(r===i&&n===s){const r=this.getters.getMerge(e);if(!r)return;({sheetId:o,col:i,row:s}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:i,top:s,right:i+r.right-r.left,bottom:s+r.bottom-r.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),o=e[0],i=this.zones[0],s=[o.left-i.left,o.top-i.top];for(const e of this.copiedTables){const o=vi(e.zone,"both","MOVE",s);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[o]});for(const i of Oe(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:o.left+i,row:o.top,values:e.filtersValues[i]})}}getClipboardContent(){return{[Ji.PlainText]:this.getPlainTextContent(),[Ji.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>this.getters.shouldShowFormulas()&&e.cell?.isFormula?e.cell?.content||"":e.evaluatedCell?.formattedValue||"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1==this.cells.length&&1==this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const o of t){e+=`<td style="${Ui(Pi(o.style))}">`+JC(this.getters.getCellText(o.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let o of this.zones){if("COL"===t&&e<=o.right)return!0;if("ROW"===t&&e<=o.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:o}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*o;for(const e of this.zones){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e);s>0&&r>0&&t.strokeRect(o,i,s,r)}}}pasteCf(e,t){const o=Tt(t.col,t.row);for(let i of this.getters.getConditionalFormats(e.sheetId))for(let s of i.ranges)if(hi(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=i,r=[];"CUT"===this.operation&&r.push(Tt(e.col,e.row)),e.sheetId===t.sheetId?this.adaptCFRules(e.sheetId,s,[o],r):(this.adaptCFRules(t.sheetId,s,[o],[]),this.adaptCFRules(e.sheetId,s,[],r))}}adaptCFRules(e,t,o,i){const s=this.getters.getAdaptedCfRanges(e,t,o,i);s&&this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:s.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}}class xw{operation;getters;dispatch;sheetId;copiedFigure;copiedFigureContent;constructor(e,t,o){this.operation=e,this.getters=t,this.dispatch=o,this.sheetId=t.getActiveSheetId();const i=t.getSelectedFigureId();if(!i)throw new Error("No figure selected");const s=t.getFigure(this.sheetId,i);if(!s)throw new Error(`No figure for the given id: ${i}`);switch(this.copiedFigure={...s},s.tag){case"chart":this.copiedFigureContent=new Iw(o,t,this.sheetId,i);break;case"image":this.copiedFigureContent=new Rw(o,t,this.sheetId,i);break;default:throw new Error(`Unknow tag '${s.tag}' for the given figure id: ${i}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?74:void 0!==t?.pasteOption?23:0}paste(e){const t=this.getters.getActiveSheetId(),{width:o,height:i}=this.copiedFigure,s=this.getters.getNumberCols(t),r=this.getters.getNumberRows(t),n=this.getters.getColDimensions(t,e[0].left).start,a=this.getters.getRowDimensions(t,e[0].top).start,l=this.getters.getColDimensions(t,s-1).end,c=this.getters.getRowDimensions(t,r-1).end,h={x:l<o?0:Math.min(n,l-o),y:c<i?0:Math.min(a,c-i)},d=(new Ni).uuidv4();this.copiedFigureContent.paste(t,d,h,{height:i,width:o}),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:d})}getClipboardContent(){return{[Ji.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Iw{dispatch;sheetId;copiedChart;constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const s=t.getChart(i);if(!s)throw new Error(`No chart for the given id: ${i}`);this.copiedChart=s.copyInSheetId(o)}paste(e,t,o,i){const s=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:o,size:i,definition:s.getDefinition()})}}class Rw{dispatch;sheetId;copiedImage;constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const s=t.getImage(i);this.copiedImage=Se(s)}paste(e,t,o,i){const s=Se(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:o,size:i,definition:s})}}function Tw(e,t){return e.startsWith("=")?function(e,t){return function(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const i=lu(e,t);let s="";for(const e of i)"NUMBER"===e.type?s+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?s+=o.formulaArgSeparator:s+=e.value;return s}(e,t,oo)}(e,t):ng(e,t)}class Aw extends ww{values;constructor(e,t,o,i){super("COPY",t,o,i),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId(),i=this.getPasteZone(e);return this.getters.doesIntersectMerge(o,i)?2:0}paste(e,t){if("onlyFormat"===t?.pasteOption)return;const o=this.values,i=this.getPasteZone(e),{left:s,top:r}=i,{numberOfCols:n,numberOfRows:a}=pi(i),l=this.getters.getActiveSheetId(),c=this.getters.getLocale();this.addMissingDimensions(n,a,s,r);for(let e=0;e<o.length;e++)for(let t=0;t<o[e].length;t++)this.dispatch("UPDATE_CELL",{row:r+e,col:s+t,content:Tw(o[e][t],c),sheetId:l});const h={left:s,top:r,right:s+n-1,bottom:r+a-1};this.selection.selectZone({cell:{col:s,row:r},zone:h},{scrollIntoView:!1})}getClipboardContent(){return{[Ji.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,o=Math.max(...this.values.map((e=>e.length))),{left:i,top:s}=e[0];return{top:s,left:i,bottom:s+t-1,right:i+o-1}}}function Ow(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Ko(e.value),[i,s]=t.split(":"),r=o?`${Ee(o)}!`:"",n=Nw(i),a=s?`:${Nw(s)}`:"";return{...e,value:r+n+a}}function Nw(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=Mw(e,"colrow");break;case"colrow":e=Mw(e,"row");break;case"row":e=Mw(e,"col");break;case"col":e=Mw(e,"none")}return e}function Mw(e,t){let o;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return o=e.search(/[0-9]/),e.slice(0,o)+"$"+e.slice(o);case"colrow":return o=e.search(/[0-9]/),"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}const _w=r("The cell you are trying to edit has been deleted.");const Fw=[{name:r("Sum"),types:[Qi.number],compute:(e,t)=>da.compute.bind({locale:t})([e])},{name:r("Avg"),types:[Qi.number],compute:(e,t)=>wa.compute.bind({locale:t})([e])},{name:r("Min"),types:[Qi.number],compute:(e,t)=>Va.compute.bind({locale:t})([e])},{name:r("Max"),types:[Qi.number],compute:(e,t)=>La.compute.bind({locale:t})([e])},{name:r("Count"),types:[Qi.number,Qi.text,Qi.boolean,Qi.error],compute:(e,t)=>Na.compute.bind({locale:t})([e])},{name:r("Count Numbers"),types:[Qi.number,Qi.text,Qi.boolean,Qi.error],compute:(e,t)=>Oa.compute.bind({locale:t})([e])}];class Dw{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;offsetScrollbarX;offsetScrollbarY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,o,i,s,r){this.getters=e,this.sheetId=t,this.boundaries=o,this.viewportWidth=i.width,this.viewportHeight=i.height,this.offsetScrollbarX=r.x,this.offsetScrollbarY=r.y,this.canScrollVertically=s.canScrollVertically,this.canScrollHorizontally=s.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const e=this.getters.findLastVisibleColRowIndex(this.sheetId,"COL",{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,"ROW",{first:this.boundaries.top,last:this.boundaries.bottom}),{end:o,size:i}=this.getters.getColDimensions(this.sheetId,e),{end:s,size:r}=this.getters.getRowDimensions(this.sheetId,t),n=this.searchHeaderIndex("COL",o-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,n),l=this.searchHeaderIndex("ROW",s-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=o-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(D,Math.min(a,this.viewportWidth-i)),h=Math.max(h,this.viewportWidth));let d=s-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(L+5,Math.min(c,this.viewportHeight-r)),d=Math.max(d,this.viewportHeight)),{width:h,height:d}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const o=this.getters.getMainCellPosition({sheetId:t,...e}),{col:i,row:s}=this.getters.getNextVisibleCellPosition(o);hi(i,this.boundaries.top,this.boundaries)&&this.adjustPositionX(i),hi(this.boundaries.left,s,this.boundaries)&&this.adjustPositionY(s)}adjustPositionX(e){const t=this.sheetId,{end:o}=this.getters.getColDimensions(t,e),i=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<o)for(let e=this.left;this.offsetX+this.offsetCorrectionX+this.viewportWidth<o&&!(e>i);e++)this.getters.isColHidden(t,e)||(this.offsetX=this.getters.getColDimensions(t,e).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX());else if(this.left>e)for(let o=this.left;o>=e&&!(o<0);o--)this.getters.isColHidden(t,o)||(this.offsetX=this.getters.getColDimensions(t,o).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX())}adjustPositionY(e){const t=this.sheetId,{end:o}=this.getters.getRowDimensions(t,e),i=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<o)for(let e=this.top;this.offsetY+this.viewportHeight+this.offsetCorrectionY<o&&!(e>i);e++)this.getters.isRowHidden(t,e)||(this.offsetY=this.getters.getRowDimensions(t,e).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY());else if(this.top>e)for(let o=this.top;o>=e&&!(o<0);o--)this.getters.isRowHidden(t,o)||(this.offsetY=this.getters.getRowDimensions(t,o).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY())}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=ai(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.viewportWidth),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.viewportHeight)}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,o=0,i=!1){let s=0;const r=this.sheetId,n=this.getters.getNumberHeaders(r,e);for(let a=o;a<=n-1;a++){const o=i||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(r,e,a)&&!o&&(s+="COL"===e?this.getters.getColSize(r,a):this.getters.getRowSize(r,a),s>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportWidth,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.viewportWidth,this.left)),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.viewportHeight,this.top)),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}const Lw=(new $i).add("settings",class extends _E{static getters=["getLocale"];locale=oo;allowDispatch(e){return"UPDATE_LOCALE"===e.type?tg(e.locale)?0:94:0}handle(e){if("UPDATE_LOCALE"===e.type)this.history.update("locale",e.locale)}getLocale(){return this.locale}import(e){this.locale=e.settings?.locale??oo}export(e){e.settings={locale:this.locale}}}).add("sheet",class extends _E{static getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions","checkZonesExistInSheet","getCommandZones","getUnboundedZone"];sheetIdsMapName={};orderedSheetIds=[];sheets={};cellPosition={};allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 15}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>t?87:e.quantity<=0?88:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return Math.min(...e.elements)<0||Math.max(...e.elements)>t?87:0}case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.delta);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let t of e.sheets){const e=t.name||s("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:o,rowNumber:i}=this.getImportedSheetSize(t),r={id:t.id,name:e,numberOfCols:o,rows:Oi(i),areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible,panes:{xSplit:t.panes?.xSplit||0,ySplit:t.panes?.ySplit||0}};this.orderedSheetIds.push(r.id),this.sheets[r.id]=r}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(He).map((e=>{const t=this.sheets[e],o={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(o.panes=t.panes),o}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){return this.tryGetSheet(e)?.name}getSheetIdByName(e){if(e){const t=Ce(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,o){return"COL"===t?o>=0&&o<this.getNumberCols(e):o>=0&&o<this.getNumberRows(e)}getRow(e,t){const o=this.getSheet(e).rows[t];if(!o)throw new Error(`Row ${o} not found.`);return o}getCell({sheetId:e,col:t,row:o}){const i=this.tryGetSheet(e)?.rows[o]?.cells[t];if(void 0!==i)return this.getters.getCellById(i)}getColsZone(e,t,o){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:o}}getRowCells(e,t){return Object.values(this.getSheet(e).rows[t]?.cells).filter(He)}getRowsZone(e,t,o){return{top:t,bottom:o,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this));let i=`${e}${t}`;for(;o.includes(i);)i=`${e}${t}`,t++;return i}getSheetSize(e){return{numberOfRows:this.getNumberRows(e),numberOfCols:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getUnboundedZone(e,t){const o=0===t.left&&t.right===this.getNumberCols(e)-1,i=0===t.top&&t.bottom===this.getNumberRows(e)-1;return{...t,bottom:i?void 0:t.bottom,right:o&&!i?void 0:t.right}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,o){const i={...this.getPaneDivisions(e)};"COL"===o?i.xSplit=t:"ROW"===o&&(i.ySplit=t),this.history.update("sheets",e,"panes",i)}isEmpty(e,t){return fi(t).map((({col:t,row:o})=>this.getCell({sheetId:e,col:t,row:o}))).every((e=>!e||""===e.content))}getCommandZones(e){const t=[];return"zone"in e&&t.push(e.zone),"target"in e&&t.push(...e.target),"ranges"in e&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),"col"in e&&"row"in e&&t.push({top:e.row,left:e.col,bottom:e.row,right:e.col}),t}checkZonesExistInSheet(e,t){if(!t.every(ei))return 26;if(t.length){const o=this.getSheetZone(e);return t.every((e=>di(e,o)))?0:19}return 0}updateCellPosition(e){const{sheetId:t,cellId:o,col:i,row:s}=e;o?this.setNewPosition(o,t,i,s):this.clearPosition(t,i,s)}setNewPosition(e,t,o,i){const s=this.cellPosition[e];s&&this.clearPosition(t,s.col,s.row),this.history.update("cellPosition",e,{row:i,col:o,sheetId:t}),this.history.update("sheets",t,"rows",i,"cells",o,e)}clearPosition(e,t,o){const i=this.sheets[e]?.rows[o].cells[t];i&&(this.history.update("cellPosition",i,void 0),this.history.update("sheets",e,"rows",o,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++){this.sheets[e].rows[i].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:i})}}createSheet(e,t,o,i,s){const r={id:e,name:t,numberOfCols:o,rows:Oi(i),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},n=this.orderedSheetIds.slice();n.splice(s,0,r.id);const a=this.sheets;return this.history.update("orderedSheetIds",n),this.history.update("sheets",Object.assign({},a,{[r.id]:r})),r}moveSheet(e,t){const o=this.orderedSheetIds.slice(),i=o.findIndex((t=>t===e)),s=o.splice(i,1);let r=this.findIndexOfTargetSheet(i,t);o.splice(r,0,s[0]),this.history.update("orderedSheetIds",o)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(r("There is not enough visible sheets"))}checkSheetName(e){const t=this.getters.tryGetSheetName(e.sheetId);if(void 0!==t&&e.name===t)return 11;const{orderedSheetIds:o,sheets:i}=this,s=e.name&&e.name.trim().toLowerCase();return o.find((t=>i[t]?.name.toLowerCase()===s&&t!==e.sheetId))?12:le.test(s)?14:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?16:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:75}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:75}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.top<e.quantity&&e.quantity<=o.bottom)return 66;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.left<e.quantity&&e.quantity<=o.right)return 66;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const o=e.name;this.history.update("sheets",e.id,"name",t.trim());const i=Object.assign({},this.sheetIdsMapName);delete i[o],i[t]=e.id,this.history.update("sheetIdsMapName",i)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const o=this.getSheet(e),i=this.getDuplicateSheetName(o.name),s=Se(o);s.id=t,s.name=i;for(let e=0;e<=s.numberOfCols;e++)for(let t=0;t<=s.rows.length;t++)s.rows[t]&&(s.rows[t].cells[e]=void 0);const r=this.orderedSheetIds.slice(),n=r.indexOf(e);r.splice(n+1,0,s.id),this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},this.sheets,{[s.id]:s}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:o}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:s.id,col:e,row:o,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[s.name]=s.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this)),i=r("Copy of %s",e);let s=i.toString();for(;o.includes(s);)s=`${i} (${t})`,t++;return s}deleteSheet(e){const t=e.name,o=Object.assign({},this.sheets);delete o[e.id],this.history.update("sheets",o);const i=this.orderedSheetIds.slice(),s=i.indexOf(e.id);i.splice(s,1),this.history.update("orderedSheetIds",i);const r=Object.assign({},this.sheetIdsMapName);delete r[t],this.history.update("sheetIdsMapName",r)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let o of t)this.moveCellOnColumnsDeletion(e,o);const o=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",o-t.length);const i=t.filter((t=>t<e.panes.xSplit)).length;i&&this.setPaneDivisions(e.id,e.panes.xSplit-i,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let o of Ne(t))this.moveCellOnRowsDeletion(e,o[o.length-1],o[0]),o.map((t=>this.updateRowsStructureOnDeletion(t,e)));const o=t.filter((t=>t<e.panes.ySplit)).length;o&&this.setPaneDivisions(e.id,e.panes.ySplit-o,"ROW")}addColumns(e,t,o,i){const s="before"===o?t:t+1;this.moveCellsOnAddition(e,s,i,"columns");const r=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",r+i),s<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+i,"COL")}addRows(e,t,o,i){const s="before"===o?t:t+1;this.addEmptyRows(e,i),this.moveCellsOnAddition(e,s,i,"rows"),this.updateRowsStructureOnAddition(e,t,i),s<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+i,"ROW")}moveCellOnColumnsDeletion(e,t){for(let o=0;o<e.rows.length;o++){const i=e.rows[o];for(let s in i.cells){const r=Number(s),n=i.cells[s];n&&(r===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:r,row:o}),r>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:r-1,row:o}))}}}moveCellsOnAddition(e,t,o,i){const s=[];for(let r=0;r<e.rows.length;r++){const n=e.rows[r];if("rows"!==i||r>=t)for(let a in n.cells){const l=Number(a),c=n.cells[a];c&&("rows"===i||l>=t)&&s.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===i?o:0),row:r+("rows"===i?o:0)})}}for(let e of s.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,o){const i=o-t+1;for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if(s>=t&&s<=o)for(let t in r.cells){const o=Number(t);r.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:o,row:s})}if(s>o)for(let t in r.cells){const o=Number(t),n=r.cells[t];n&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:o,row:s-i})}}}updateRowsStructureOnDeletion(e,t){const o=[],i=t.rows.map((e=>e.cells));for(let s in t.rows)Number(s)!==e&&o.push({cells:i.shift()});this.history.update("sheets",t.id,"rows",o)}updateRowsStructureOnAddition(e,t,o){const i=[],s=e.rows.map((e=>e.cells));e.rows.forEach((()=>i.push({cells:s.shift()}))),this.history.update("sheets",e.id,"rows",i)}addEmptyRows(e,t){const o=e.rows.slice();for(let e=0;e<t;e++)o.push({cells:{}});this.history.update("sheets",e.id,"rows",o)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(Rt);let o=e.rowNumber,i=e.colNumber;for(let{col:e,row:s}of t)o=Math.max(o,s+1),i=Math.max(i,e+1);return{rowNumber:o,colNumber:i}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?28:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?13:0}checkZonesAreInSheet(e){return"sheetId"in e?this.checkZonesExistInSheet(e.sheetId,this.getCommandZones(e)):0}}).add("header visibility",class extends _E{static getters=["canRemoveHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];hiddenHeaders={};allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 28;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),o="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=o?67:Math.min(...e.elements)<0||Math.max(...e.elements)>o?87:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.canRemoveHeaders(e.sheetId,e.dimension,e.elements)?0:8:28}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,Se(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],o=je(e.position,e.base);t.splice(o,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}canRemoveHeaders(e,t,o){const i=this.getAllVisibleHeaders(e,t);return s=o,!i.every((e=>s.includes(e)));var s}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],o=this.hiddenHeaders[e].COL;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],o=this.hiddenHeaders[e].ROW;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getAllVisibleHeaders(e,t){return Oe(0,this.hiddenHeaders[e][t].length).filter((o=>!this.hiddenHeaders[e][t][o]))}import(e){for(let t of e.sheets){this.hiddenHeaders[t.id]={COL:[],ROW:[]};for(let e=0;e<t.rowNumber;e++)this.hiddenHeaders[t.id].ROW[e]=Boolean(t.rows[e]?.isHidden);for(let e=0;e<t.colNumber;e++)this.hiddenHeaders[t.id].COL[e]=Boolean(t.cols[e]?.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e=0;e<this.getters.getNumberRows(o.id);e++)(t||this.hiddenHeaders[o.id].ROW[e])&&(void 0===o.rows[e]&&(o.rows[e]={}),o.rows[e].isHidden=this.hiddenHeaders[o.id].ROW[e]);void 0===o.cols&&(o.cols={});for(let e=0;e<this.getters.getNumberCols(o.id);e++)(t||this.hiddenHeaders[o.id].COL[e])&&(void 0===o.cols[e]&&(o.cols[e]={}),o.cols[e].isHidden=this.hiddenHeaders[o.id].COL[e])}}}).add("filters",class extends _E{static getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId","getFilterHeaders","isFilterHeader"];tables={};allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!xi(...e.target))return 82;const t=ni(...e.target),o=()=>this.getFilterTables(e.sheetId).some((e=>ci(e.zone,t)))?79:0,i=()=>{const o=this.getters.getMergesInZone(e.sheetId,t);for(let e of o)if(ci(t,e))return 81;return 0};return this.checkValidations(e,o,i);case"ADD_MERGE":for(let t of e.target)for(let o of this.getFilterTables(e.sheetId))if(ci(o.zone,t))return 81}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":const o={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=Se(t);o[e.id]=e}this.history.update("tables",e.sheetIdTo,o);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=ni(...e.target),o=this.createFilterTable(t);this.history.update("tables",e.sheetId,o.id,o);break}case"REMOVE_FILTER_TABLE":{const t={};for(const o of this.getFilterTables(e.sheetId))e.target.every((e=>!ai(e,o.zone)))&&(t[o.id]=o);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let o of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,o)&&this.extendTableDown(t,o);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(He):[]}getFilter(e){return this.getFilterTable(e)?.filters.find((t=>t.col===e.col))}getFilterId(e){return this.getFilter(e)?.id}getFilterTable({sheetId:e,col:t,row:o}){return this.getFilterTables(e).find((e=>hi(t,o,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>di(e.zone,t)))}doesZonesContainFilter(e,t){for(const o of t)for(const t of this.getFilterTables(e))if(ai(o,t.zone))return!0;return!1}getFilterHeaders(e){const t=[];for(let o of this.getFilterTables(e)){const e=o.zone,i=e.top;for(let o=e.left;o<=e.right;o++)t.push({col:o,row:i})}return t}isFilterHeader({sheetId:e,col:t,row:o}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===o))}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=oi(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i=[];for(const o of t.filters){const t=oi(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);i.push(new PE(o.id,t))}if(i.length<pi(o).numberOfCols){for(let e=o.left;e<=o.right;e++)i.find((t=>t.col===e))||i.push(new PE(this.uuidGenerator.uuidv4(),{...o,left:e,right:e}));i.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=ri(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(o){if(ti(o)!==ti(t.zone)){const i=[];for(const o of t.filters){const t=ri(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&i.push(new PE(o.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}else{const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o)}}}createFilterTable(e){return new LE(e)}extendTableDown(e,t){const o={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",o);for(let o=0;o<t.filters.length;o++){const i=t.filters[o],s={...i.zoneWithHeaders,bottom:i.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",o,"zoneWithHeaders",s)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:o,row:i},s){if(!e)return;const r=s.zone;if(!(r.bottom+1===i&&o>=r.left&&o<=r.right))return!1;for(const e of Oe(r.left,r.right+1)){const o={sheetId:t,col:e,row:i},s=this.getters.getCell(o)?.content;if(s)return!1;if(this.getters.getFilter(o))return!1;if(this.getters.isInMerge(o))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const o=this.createFilterTable(Jo(e.range));this.history.update("tables",t.id,o.id,o)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:ti(e.zone)})}exportForExcel(e){this.export(e)}}).add("cell",class extends _E{static getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];nextId=1;cells={};adaptRanges(e,t){for(const o of Object.keys(this.cells))for(const i of Object.values(this.cells[o]||{}))if(i.isFormula)for(const s of i.dependencies)if(!t||s.sheetId===t){const t=e(s);"NONE"!==t.changeType&&this.history.update("cells",o,i.id,"dependencies",i.dependencies.indexOf(s),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,o){for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let s=i.left;s<=i.right;s++)this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,format:o})}clearFormatting(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:null,format:""})}handleAddColumnsRows(e,t){let o,i;"before"===e.position?(o=Oe(e.base,e.base+e.quantity),i=e.base+e.quantity):(o=Oe(e.base+1,e.base+e.quantity+1),i=e.base),t(e.sheetId,i,o)}import(e){for(let t of e.sheets)for(let o in t.cells){const i=t.cells[o],{col:s,row:r}=Rt(o);if(i?.content||i?.format||i?.style){const o=this.importCell(t.id,i,e.styles,e.formats);this.history.update("cells",t.id,o.id,o),this.dispatch("UPDATE_CELL_POSITION",{cellId:o.id,col:s,row:r,sheetId:t.id})}}}export(e){const t={},o={};for(let i of e.sheets){const e={},s=Object.keys(this.cells[i.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const i of s){const s=this.getters.getCell(i);e[Tt(i.col,i.row)]={style:s.style?We(s.style,t):void 0,format:s.format?We(s.format,o):void 0,content:s.content||void 0}}i.cells=e}e.styles=t,e.formats=o}importCell(e,t,o,i){const s=t.style&&o[t.style]||void 0,r=t.format&&i[t.format]||void 0,n=this.getNextUid();return this.createCell(n,t?.content||"",r,s,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const o=this.cells[t][e];if(o)return o}}buildFormulaContent(e,t,o){const i=o||[...t.dependencies];return Ge(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=i.shift();return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){return this.getters.getCell(e)?.style||{}}zoneToXC(e,t,o=[{colFixed:!1,rowFixed:!1}]){const i=Tt((t=this.getters.expandZone(e,t)).left,t.top,o[0]),s=Tt(t.right,t.bottom,o.length>1?o[1]:o[0]),r=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),n=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=r.col===n.col&&r.row===n.row;return i==s||a?i:i+":"+s}setStyle(e,t,o){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let s=i.top;s<=i.bottom;s++){const i=this.getters.getCell({sheetId:e,col:t,row:s});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:s,style:o?{...i?.style,...o}:void 0})}}copyColumnStyle(e,t,o){for(let i=0;i<this.getters.getNumberRows(e);i++){const s=this.getFormat(e,t,i);if(s.style||s.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,...s})}}copyRowStyle(e,t,o){for(let i=0;i<this.getters.getNumberCols(e);i++){const s=this.getFormat(e,i,t);if(s.style||s.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:i,row:t,...s})}}getFormat(e,t,o){const i={},s=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),r=this.getters.getCell(s);return r&&(r.style&&(i.style=r.style),r.format&&(i.format=r.format)),i}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,o,i){const s=this.getters.getCell({sheetId:e,col:t,row:o}),r="content"in i||"formula"in i,n=r?ot(i?.content):s?.content||"";let a;a=void 0!==i.style?i.style||void 0:s?s.style:void 0;const l=this.getters.getLocale();let c=("format"in i?i.format:s&&s.format)||_o(n,l)||Fo(n);if((r&&!n&&!i.formula||!r&&(!s||""===s.content))&&!a&&!c)return void(s&&(this.history.update("cells",e,s.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:o,sheetId:e})));const h=s?.id||this.getNextUid(),d=this.createCell(h,n,c,a,e);this.history.update("cells",e,d.id,d),this.dispatch("UPDATE_CELL_POSITION",{cellId:d.id,col:t,row:o,sheetId:e})}createCell(e,t,o,i,s){if(!t.startsWith("="))return this.createLiteralCell(e,t,o,i);try{return this.createFormulaCell(e,t,o,i,s)}catch(s){return this.createErrorFormula(e,t,o,i,s)}}createLiteralCell(e,t,o,i){return{id:e,content:t=qs(t,this.getters.getLocale()).toString(),style:i,format:o,isFormula:!1}}createFormulaCell(e,t,o,i,s){const r=Yu(t);return r.dependencies.length?this.createFormulaCellWithDependencies(e,r,o,i,s):{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:r,dependencies:[]}}createFormulaCellWithDependencies(e,t,o,i,s){const r=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(s,e)));return new FE(e,t,o,i,r,s,this.buildFormulaContent.bind(this))}createErrorFormula(e,t,o,i,s){return{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:{dependencies:[],tokens:lu(t),execute:function(){throw s}},dependencies:[]}}checkCellOutOfSheet(e,t,o){if(!this.getters.tryGetSheet(e))return 28;return hi(t,o,this.getters.getSheetZone(e))?0:19}}).add("merge",class extends _E{static getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge","getSelectionRangeString"];nextId=1;merges={};mergeCellMap={};allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const o of Object.values(t).filter(He))this.addMerge(e.sheetIdTo,o.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const o=t?[t]:Object.keys(this.merges);for(const t of o)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(He)}getMerge({sheetId:e,col:t,row:o}){const i=this.mergeCellMap[e],s=i?t in i&&i[t]?.[o]:void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){const o=this.mergeCellMap[e];if(!o)return[];const i=new Set;for(const{col:e,row:s}of fi(t)){const t=o[e]?.[s];t&&i.add(t)}return Array.from(i).map((t=>this.getMergeById(e,t))).filter(He)}getSelectionRangeString(e,t){const o=Ii.fromRange(e,this.getters),i=this.getters.expandZone(o.sheetId,o.zone),s=o.clone({zone:{...i,bottom:o.isFullCol?void 0:i.bottom,right:o.isFullRow?void 0:i.right}}),r=this.getters.getRangeString(s,t);if(this.isSingleCellOrMerge(o.sheetId,o.zone)){const{sheetName:e,xc:t}=Ko(r);return`${void 0!==e?Ee(e)+"!":""}${t.split(":")[0]}`}return r}doesIntersectMerge(e,t){return fi(t).some((({col:t,row:o})=>void 0!==this.getMerge({sheetId:e,col:t,row:o})))}doesColumnsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let s=0;s<this.getters.getNumberRows(e);s++)if(this.isInSameMerge(i.id,t,s,o,s))return!0;return!1}doesRowsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let s=0;s<=this.getters.getNumberCols(e);s++)if(this.isInSameMerge(i.id,s,t,s,o))return!0;return!1}expandZone(e,t){let{left:o,right:i,top:s,bottom:r}=t,n={left:o,right:i,top:s,bottom:r};for(let t in this.merges[e]){const o=this.getMergeById(e,parseInt(t));o&&ci(o,n)&&(n=ni(o,n))}return li(n,t)?n:this.expandZone(e,n)}isInSameMerge(e,t,o,i,s){const r=this.getMerge({sheetId:e,col:t,row:o}),n=this.getMerge({sheetId:e,col:i,row:s});return!(!r||!n)&&li(r,n)}isInMerge({sheetId:e,col:t,row:o}){const i=this.mergeCellMap[e];return!!i&&(t in i&&Boolean(i[t]?.[o]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:o}=this.getMerge(e);return{sheetId:e.sheetId,col:o,row:t}}isMergeHidden(e,t){const o=this.getters.getHiddenColsGroups(e),i=this.getters.getHiddenRowsGroups(e);for(let e of o)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of i)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const o=this.getMerge({sheetId:e,col:t.left,row:t.top});if(o)return li(t,o);const{numberOfCols:i,numberOfRows:s}=pi(t);return 1===i&&1===s}isMergeDestructive(e,t){let{left:o,right:i,top:s,bottom:r}=t;i=we(i,0,this.getters.getNumberCols(e)-1),r=we(r,0,this.getters.getNumberRows(e)-1);for(let t=s;t<=r;t++)for(let r=o;r<=i;r++)if(r!==o||t!==s){const o=this.getters.getCell({sheetId:e,col:r,row:t});if(o&&""!==o.content)return!0}return!1}getMergeById(e,t){const o=this.merges[e]?.[t];return void 0!==o?UE(t,o):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const o of e)if(t!==o&&ci(t,o))return 66;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<o&&e.right>=o||e.top<i&&e.bottom>=i)return 76;return 0}checkMergedContentUpdate(e){const{col:t,row:o,content:i}=e;if(void 0===i)return 0;const{col:s,row:r}=this.getMainCellPosition(e);return s===t&&r===o?0:4}checkMergeExists(e){const{sheetId:t,target:o}=e;for(const e of o){const{left:o,top:i}=e,s=this.getMerge({sheetId:t,col:o,row:i});if(void 0===s||!li(e,s))return 5}return 0}addMerge(e,t){let{left:o,right:i,top:s,bottom:r}=t;i=we(i,0,this.getters.getNumberCols(e)-1),r=we(r,0,this.getters.getNumberRows(e)-1);if(Tt(o,s)===Tt(i,r))return;const n=this.getters.getCell({sheetId:e,col:o,row:s});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,ti({left:o,top:s,right:i,bottom:r})));let l=new Set;for(let t=s;t<=r;t++)for(let r=o;r<=i;r++){r===o&&t===s||this.dispatch("UPDATE_CELL",{sheetId:e,col:r,row:t,style:n?n.style:null,content:""});const i=this.getMerge({sheetId:e,col:r,row:t});i&&l.add(i.id),this.history.update("mergeCellMap",e,r,t,a)}for(let t of l){const{top:o,bottom:i,left:s,right:r}=this.getMergeById(e,t);for(let t=o;t<=i;t++)for(let o=s;o<=r;o++){const i={sheetId:e,col:o,row:t},s=this.getMerge(i);s&&s.id===a||(this.history.update("mergeCellMap",e,o,t,void 0),this.dispatch("CLEAR_CELL",i))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:o,top:i,bottom:s,right:r}=t,n=this.getMerge({sheetId:e,col:o,row:i});if(void 0!==n&&li(t,n)){this.history.update("merges",e,n.id,void 0);for(let t=i;t<=s;t++)for(let i=o;i<=r;i++)this.history.update("mergeCellMap",e,i,t,void 0)}}applyRangeChangeOnSheet(e,t){const o=Object.entries(this.merges[e]||{});for(const[i,s]of o)if(s){const o=s.zone,r=t(s);switch(r.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,o);break;default:const{numberOfCols:t,numberOfRows:s}=pi(r.range.zone);1===t&&1===s?this.removeMerge(e,o):this.history.update("merges",e,parseInt(i,10),r.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:o,row:i}of fi(t))this.history.update("mergeCellMap",e,o,i,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let o of t)this.addMerge(e,Jo(o))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...kE(e))}}exportForExcel(e){this.export(e)}}).add("headerSize",class extends _E{static getters=["getRowSize","getColSize"];sizes={};handle(e){switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),o={COL:t.COL.map((e=>({manualSize:void 0,computedSize:qe(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:qe(e)})))};this.history.update("sizes",e.sheetId,o);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Se(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const t={...this.sizes};delete t[e.sheetId],this.history.update("sizes",t);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);const o=Math.min(...e.elements);t=t.map(((t,i)=>"ROW"===e.dimension&&i>=o?{manualSize:t.manualSize,computedSize:qe((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const o=je(e.position,e.base),i=t[e.base];t.splice(o,0,...Array(e.quantity).fill(i)),t=t.map(((t,o)=>"ROW"===e.dimension&&o>e.base+e.quantity?{manualSize:t.manualSize,computedSize:qe((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const o=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:qe(o)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:qe(e.size||D)});break;case"UPDATE_CELL":if(!this.sizes[e.sheetId]?.ROW?.[e.row]?.manualSize){const{sheetId:t,row:o}=e;this.history.update("sizes",t,"ROW",o,"computedSize",qe((()=>this.getRowTallestCellSize(t,o))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let o of Oe(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,o);t!==this.getRowSize(e.sheetId,o)&&this.history.update("sizes",e.sheetId,"ROW",o,"computedSize",qe(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,o){return Math.round(this.sizes[e]?.[t][o]?.manualSize||this.sizes[e]?.[t][o]?.computedSize()||this.getDefaultHeaderSize(t))}computeSheetSizes(e){const t={COL:[],ROW:[]};for(let o of Oe(0,this.getters.getNumberCols(e)))t.COL.push(this.getHeaderSize(e,"COL",o));for(let o of Oe(0,this.getters.getNumberRows(e))){let i=this.sizes[e]?.ROW?.[o].manualSize;if(!i){i=this.getRowTallestCellSize(e,o)}t.ROW.push(i)}return t}getDefaultHeaderSize(e){return"COL"===e?D:L}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return L;return function(e){return e&&e.content?ye(Ae(e.style),e.isFormula?1:e.content.split(pe).length)+2*B:L}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const o=this.getters.getRowCells(e,t);let i=0;for(let e=0;e<o.length;e++){const t=this.getters.getCellById(o[e]);if(!t)continue;const s=this.getters.getCellPosition(t.id),r=this.getCellHeight(s);r>i&&r>L&&(i=r)}return i<=L?L:i}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[o,i]of Object.entries(t.rows))i.size&&(e.ROW[o]=i.size);for(let[o,i]of Object.entries(t.cols))i.size&&(e.COL[o]=i.size);const o=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:o.COL.map(((t,o)=>({manualSize:e.COL[o],computedSize:qe(t)}))),ROW:o.ROW.map(((t,o)=>({manualSize:e.ROW[o],computedSize:qe(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e of Oe(0,this.getters.getNumberRows(o.id)))(t||this.sizes[o.id].ROW[e]?.manualSize)&&(o.rows[e]={...o.rows[e],size:this.getRowSize(o.id,e)});void 0===o.cols&&(o.cols={});for(let e of Oe(0,this.getters.getNumberCols(o.id)))(t||this.sizes[o.id].COL[e]?.manualSize)&&(o.cols[e]={...o.cols[e],size:this.getColSize(o.id,e)})}}}).add("borders",class extends _E{static getters=["getCellBorder","getBordersColors"];borders={};handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const o=t.slice().map((e=>e?.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,o)}break;case"DELETE_SHEET":const o={...this.borders};delete o[e.sheetId],this.history.update("borders",o);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_ZONE_BORDERS":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border.position,""===e.border.color?void 0:{style:e.border.style||Y,color:e.border.color||X})}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,o;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,o)}handleAddRows(e){let t,o;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,o)}getCellBorder({sheetId:e,col:t,row:o}){const i={top:this.borders[e]?.[t]?.[o]?.horizontal,bottom:this.borders[e]?.[t]?.[o+1]?.horizontal,left:this.borders[e]?.[t]?.[o]?.vertical,right:this.borders[e]?.[t+1]?.[o]?.vertical};return i.bottom||i.left||i.right||i.top?i:null}getBordersColors(e){const t=[],o=this.borders[e];if(o)for(const e of o.filter(He))for(const o of e)o?.horizontal&&t.push(o.horizontal.color),o?.vertical&&t.push(o.vertical.color);return t}ensureColumnBorderContinuity(e,t,o){const i=Oe(t+1,o);for(let s=0;s<this.getters.getNumberRows(e);s++){const r=this.getCellBorder({sheetId:e,col:t,row:s}),n=this.getCellBorder({sheetId:e,col:o,row:s});if(r&&n){const t=this.getCommonSides(r,n);for(let o of i)this.addBorder(e,o,s,t)}}}ensureRowBorderContinuity(e,t,o){const i=Oe(t+1,o);for(let s=0;s<this.getters.getNumberCols(e);s++){const r=this.getCellBorder({sheetId:e,col:s,row:t}),n=this.getCellBorder({sheetId:e,col:s,row:o});if(r&&n){const t=this.getCommonSides(r,n);for(let o of i)this.addBorder(e,s,o,t)}}}getCommonSides(e,t){const o={};for(let i of["top","bottom","left","right"])e[i]&&e[i]===t[i]&&(o[i]=e[i]);return o}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?Oe(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,o,{moveFirstLeftBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfColumn(e,t,o,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((s=>{(s===t&&i||s!==t)&&this.moveBordersOfColumn(e,s,o,"vertical"),this.moveBordersOfColumn(e,s,o,"horizontal")})))}shiftBordersVertically(e,t,o,{moveFirstTopBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfRow(e,t,o,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((s=>{(s===t&&i||s!==t)&&this.moveBordersOfRow(e,s,o,"horizontal"),this.moveBordersOfRow(e,s,o,"vertical")})))}moveBordersOfRow(e,t,o,i,{destructive:s}={destructive:!0}){const r=this.borders[e];r&&this.getColumnsWithBorders(e).forEach((n=>{const a=r[n]?.[t+o]?.[i],l=r[n]?.[t]?.[i];this.history.update("borders",e,n,t+o,i,s?l:l||a),this.history.update("borders",e,n,t,i,void 0)}))}moveBordersOfColumn(e,t,o,i,{destructive:s}={destructive:!0}){const r=this.borders[e];r&&this.getRowsRange(e).forEach((n=>{const a=r[t+o]?.[n]?.[i],l=r[t]?.[n]?.[i];this.history.update("borders",e,t+o,n,i,s?l:l||a),this.history.update("borders",e,t,n,i,void 0)}))}setBorder(e,t,o,i,s=!0){!s&&this.borders?.[e]?.[t]?.[o]?.vertical||this.history.update("borders",e,t,o,"vertical",i?.left),!s&&this.borders?.[e]?.[t]?.[o]?.horizontal||this.history.update("borders",e,t,o,"horizontal",i?.top),!s&&this.borders?.[e]?.[t+1]?.[o]?.vertical||this.history.update("borders",e,t+1,o,"vertical",i?.right),!s&&this.borders?.[e]?.[t]?.[o+1]?.horizontal||this.history.update("borders",e,t,o+1,"horizontal",i?.bottom)}clearBorders(e,t){for(let o of t){for(let t=o.top;t<=o.bottom;t++){this.history.update("borders",e,o.right+1,t,"vertical",void 0);for(let i=o.left;i<=o.right;i++)this.history.update("borders",e,i,t,void 0)}for(let t=o.left;t<=o.right;t++)this.history.update("borders",e,t,o.bottom+1,"horizontal",void 0)}}addBorder(e,t,o,i){this.setBorder(e,t,o,{...this.getCellBorder({sheetId:e,col:t,row:o}),...i})}setBorders(e,t,o,i){if("clear"===o)return this.clearBorders(e,t);for(let s of t){if("h"===o||"hv"===o||"all"===o)for(let t=s.top+1;t<=s.bottom;t++)for(let o=s.left;o<=s.right;o++)this.addBorder(e,o,t,{top:i});if("v"===o||"hv"===o||"all"===o)for(let t=s.top;t<=s.bottom;t++)for(let o=s.left+1;o<=s.right;o++)this.addBorder(e,o,t,{left:i});if("left"===o||"all"===o||"external"===o)for(let t=s.top;t<=s.bottom;t++)this.addBorder(e,s.left,t,{left:i});if("right"===o||"all"===o||"external"===o)for(let t=s.top;t<=s.bottom;t++)this.addBorder(e,s.right+1,t,{left:i});if("top"===o||"all"===o||"external"===o)for(let t=s.left;t<=s.right;t++)this.addBorder(e,t,s.top,{top:i});if("bottom"===o||"all"===o||"external"===o)for(let t=s.left;t<=s.right;t++)this.addBorder(e,t,s.bottom+1,{top:i})}}addBordersToMerge(e,t){const{left:o,right:i,top:s,bottom:r}=t,n=this.getCellBorder({sheetId:e,col:o,row:s}),a=this.getCellBorder({sheetId:e,col:i,row:r});this.clearBorders(e,[t]),n?.top&&this.setBorders(e,[{...t,bottom:s}],"top",n.top),n?.left&&this.setBorders(e,[{...t,right:o}],"left",n.left),a?.bottom?this.setBorders(e,[{...t,top:r}],"bottom",a.bottom):n?.bottom&&this.setBorders(e,[{...t,top:r}],"bottom",n.bottom),a?.right?this.setBorders(e,[{...t,left:i}],"right",a.right):n?.right&&this.setBorders(e,[{...t,left:i}],"right",n.right)}import(e){if(Object.keys(e.borders||{}).length)for(let t of e.sheets)for(const o in t.cells){const i=t.cells[o];if(i?.border){const s=e.borders[i.border],{col:r,row:n}=Rt(o);this.setBorder(t.id,r,n,s,!1)}}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,Jo(e))}export(e){let t=0;const o={};function i(e){for(let[t,i]of Object.entries(o))if(fe(i)===fe(e))return parseInt(t,10);return o[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let o=0;o<t.rowNumber;o++){const s=this.getCellBorder({sheetId:t.id,col:e,row:o});if(s){const r=Tt(e,o),n=t.cells[r],a=i(s);n?n.border=a:t.cells[r]={border:a}}}e.borders=o}exportForExcel(e){this.export(e)}}).add("conditional formatting",class extends _E{static getters=["getConditionalFormats","getRulesSelection","getRulesByCell","getAdaptedCfRanges"];cfRules={};loopThroughRangesOfSheet(e,t){for(const o of this.cfRules[e])for(const i of o.ranges){const s=t(i);switch(s.changeType){case"REMOVE":let t=o.ranges.slice();t.splice(o.ranges.indexOf(i),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",t):this.removeConditionalFormatting(o.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",o.ranges.indexOf(i),s.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const o={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(o,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){return this.cfRules[e]?.map((t=>this.mapToConditionalFormat(e,t)))||[]}getRulesSelection(e,t){const o=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{o.add(e)}))})),Array.from(o)}getRulesByZone(e,t){const o=new Set;for(let i=t.top;i<=t.bottom;i++)for(let s=t.left;s<=t.right;s++){this.getRulesByCell(e,s,i).forEach((e=>{o.add(e.id)}))}return o}getRulesByCell(e,t,o){const i=[];for(let s of this.cfRules[e])for(let e of s.ranges)hi(t,o,e.zone)&&i.push(s);return new Set(i.map((t=>this.mapToConditionalFormat(e,t))))}getAdaptedCfRanges(e,t,o,i){if(0===o.length&&0===i.length)return;const s=this.getters.getConditionalFormats(e),r=s.findIndex((e=>e.id===t.id));let n=[];return r>-1&&(n=s[r].ranges),n=n.concat(o),ui(n,i)}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const o={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return o}addConditionalFormatting(e,t){const o=this.cfRules[t].slice(),i=o.findIndex((t=>t.id===e.id)),s=this.mapToConditionalFormatInternal(t,e);i>-1?o.splice(i,1,s):o.push(s),this.history.update("cfRules",t,o)}checkValidReordering(e,t,o){if(!this.cfRules[o])return 28;const i=this.cfRules[o].findIndex((t=>t.id===e));if(-1===i)return 72;const s="up"===t?i-1:i+1;return s<0||s>=this.cfRules[o].length?72:0}checkEmptyRange(e){return e.ranges.length?0:25}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return o=>{if(t.includes(o.operator)){const t=[],i=e=>void 0===e||""===e;return e>=1&&i(o.values[0])&&t.push(52),e>=2&&i(o.values[1])&&t.push(53),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 54;case"max":return 56;case"mid":return 55;case"upperInflectionPoint":return 57;case"lowerInflectionPoint":return 58}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{Yu(e.value||"")}catch(e){switch(t){case"min":return 59;case"max":return 61;case"mid":return 60;case"upperInflectionPoint":return 62;case"lowerInflectionPoint":return 63}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,o=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(o)?49:0}checkMinBiggerThanMax(e){const t=e.minimum.value,o=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&DE(t)>=DE(o)?48:0}checkMidBiggerThanMax(e){const t=e.midpoint?.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&DE(t)>=DE(o)?50:0}checkMinBiggerThanMid(e){const t=e.minimum.value,o=e.midpoint?.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&DE(t)>=DE(o)?51:0}removeConditionalFormatting(e,t){const o=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==o){const e=this.cfRules[t].slice();e.splice(o,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,o){const i=this.cfRules[o].findIndex((t=>t.id===e)),s="up"===t?i-1:i+1;if(!(s<0||s>=this.cfRules[o].length)&&-1!==i&&-1!==s){const e=[...this.cfRules[o]],t=e[i];e[i]=e[s],e[s]=t,this.history.update("cfRules",o,e)}}}).add("figures",class extends _E{static getters=["getFigures","getFigure","getFigureSheetId"];figures={};allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:o,...i}=e,s=i;this.updateFigure(o,s);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId);break;case"REMOVE_COLUMNS_ROWS":this.onRowColDelete(e.sheetId,e.dimension)}}onRowColDelete(e,t){"ROW"===t?this.onRowDeletion(e):this.onColDeletion(e)}onRowDeletion(e){const t=this.getters.getNumberRows(e);let o=0;for(let i=0;i<t;i++)o+=this.getters.getRowSize(e,i);const i=this.getters.getFigures(e);for(const t of i){const i=Math.min(t.y,o-t.height);i!==t.y&&this.dispatch("UPDATE_FIGURE",{sheetId:e,id:t.id,y:i})}}onColDeletion(e){const t=this.getters.getNumberCols(e);let o=0;for(let i=0;i<t;i++)o+=this.getters.getColSize(e,i);const i=this.getters.getFigures(e);for(const t of i){const i=Math.min(t.x,o-t.width);i!==t.x&&this.dispatch("UPDATE_FIGURE",{sheetId:e,id:t.id,x:i})}}updateFigure(e,t){if("id"in t)for(const[o,i]of Object.entries(t))switch(o){case"x":case"y":void 0!==i&&this.history.update("figures",e,t.id,o,Math.max(i,0));break;case"width":case"height":void 0!==i&&this.history.update("figures",e,t.id,o,i)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){return void 0===this.figures[e]?.[t]?71:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>t?.[e]))?83:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(He)}getFigure(e,t){return this.figures[e]?.[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>void 0!==this.figures[t]?.[e]))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const o=void 0;t.figures.push({...e,data:o})}}exportForExcel(e){this.export(e)}}).add("chart",class extends _E{static getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];charts={};createChart=function(e){const t=Op.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,i,s){const r=t.find((e=>e.match(i.type)));if(!r)throw new Error(`No builder for this chart: ${i.type}`);return r.createChart(i,s,e)}}(this.getters);validateChartDefinition=e=>function(e,t){const o=Op.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}(this,e.definition);adaptRanges(e){for(const[t,o]of Object.entries(this.charts))this.history.update("charts",t,o?.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const o of t)if("chart"===o.tag){const t=o.id.split(oe).pop(),i=`${e.sheetIdTo}${oe}${t}`,s=this.charts[o.id]?.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:i,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){return this.charts[e]?.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){const t=this.charts[e]?.type;if(!t)throw new Error("Chart not defined.");return t}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>t?.sheetId===e)).map((([e])=>e))}getChartDefinition(e){const t=this.charts[e]?.getDefinition();if(!t)throw new Error(`There is no chart with the given figureId: ${e}`);return t}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){if(e.sheets)for(let t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(let t of e){const e=t;if(e&&"chart"===e.tag){const t=this.charts[e.id]?.getDefinition();t&&(e.data=t,o.push(e))}else o.push(e)}t.figures=o}}exportForExcel(e){for(let t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(let t of e)if(t&&"chart"===t.tag){const e=this.charts[t.id]?.getDefinitionForExcel();e&&o.push({...t,data:e})}t.charts=o}}addFigure(e,t,o={x:0,y:0},i={width:536,height:335}){if(this.getters.getFigure(t,e))return;const s={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:s})}addChart(e,t){const o=this.getters.getFigureSheetId(e);o&&this.history.update("charts",e,this.createChart(e,t,o))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?85:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:86}}).add("image",class extends _E{static getters=["getImage","getImagePath","getImageSize"];fileStore;images={};syncedImages=new Set;constructor(e){super(e),this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?29:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addImage(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const o of t)if("image"===o.tag){const t=o.id.split(oe).pop(),i=`${e.sheetIdTo}${oe}${t}`,s=this.getImage(o.id);if(s){const t={width:o.width,height:o.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:i,position:{x:o.x,y:o.y},size:t,definition:Se(s)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){const e=new Set(this.getAllImages().map((e=>e.path)));for(const t of this.syncedImages)e.has(t)||this.fileStore?.delete(t)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addImage(e,t,o,i){const s={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:s})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const o of e)this.history.update("images",t.id,o.id,o.data),this.syncedImages.add(o.data.path)}}export(e){for(const t of e.sheets){const e=t.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=this.images[t.id]?.[o.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(const t of e)if("image"===t?.tag){const e=this.getImage(t.id);e&&o.push({...t,data:Se(e)})}t.images=o}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(He));return e}}),Pw=(new $i).add("ui_sheet",class extends zE{static getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];ctx=document.createElement("canvas").getContext("2d");allowDispatch(e){return this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(e)}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const o=this.getColMaxWidth(e.sheetId,t);0!==o&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:o,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e){const t=this.getCellText(e),o=this.getters.getCellComputedStyle(e),i=t.split(pe);let s=Math.max(...i.map((e=>this.getTextWidth(e,o))));this.getters.getConditionalIcon(e)&&(s+=function(e){return Ae(e)+2*V}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(s+=20),s>0&&(s+=2*H,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,s)}return s}getTextWidth(e,t){return xe(this.ctx,e,t)}getCellText(e,t=!1){const o=this.getters.getCell(e);return t&&o?.isFormula?sg(o.content,this.getters.getLocale()):this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const o=this.getters.getCellStyle(e),i=this.getters.getCellText(e,this.getters.shouldShowFormulas()),s=[];for(const e of i.split("\n")){const i=e.split(" ");if(!t){s.push(e);continue}let r="",n=t;for(let e of i){const i=this.splitWordToSpecificWidth(this.ctx,e,t,o),a=i.pop(),l=xe(this.ctx,a,o);if(i.length)""!==r&&(s.push(r),r="",n=t),i.forEach((e=>{s.push(e)})),r=a,n=t-l;else{const e=""===r?a:" "+a,i=xe(this.ctx,e,o);i<=n?(r+=e,n-=i):(s.push(r),r=a,n=t-l)}}""!==r&&s.push(r)}return s}getColDimensions(e,t){const o=this.getColRowOffset("COL",0,t,e),i=this.getters.getColSize(e,t);return{start:o,size:i,end:o+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensions(e,t){const o=this.getColRowOffset("ROW",0,t,e),i=this.getters.getRowSize(e,t);return{start:o,size:i,end:o+(this.getters.isRowHidden(e,t)?0:i)}}getColRowOffset(e,t,o,i=this.getters.getActiveSheetId()){if(o<t)return-this.getColRowOffset(e,o,t);let s=0;for(let r=t;r<o;r++)this.getters.isHeaderHidden(i,e,r)||(s+="COL"===e?this.getters.getColSize(i,r):this.getters.getRowSize(i,r));return s}getColMaxWidth(e,t){const o=fi(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...o)}splitWordToSpecificWidth(e,t,o,i){if(xe(e,t,i)<=o)return[t];const s=[];let r="";for(let n of t){xe(e,r+n,i)>o?(s.push(r),r=n):r+=n}return s.push(r),s}checkSheetExists(e){return"sheetId"in e&&void 0===this.getters.tryGetSheet(e.sheetId)?28:0}checkZonesAreInSheet(e){const t="sheetId"in e?e.sheetId:this.getters.tryGetActiveSheetId(),o=this.getters.getCommandZones(e);return!t&&o.length>0?93:t&&o.length>0?this.getters.checkZonesExistInSheet(t,o):0}}).add("header_visibility_ui",class extends zE{static getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,o){return"COL"===t?this.isColHidden(e,o):this.isRowHidden(e,o)}getNextVisibleCellPosition({sheetId:e,col:t,row:o}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",o,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,o,i){if(o<=i)for(let s=o;s<=i;s++)if(this.getters.doesHeaderExist(e,t,s)&&!this.isHeaderHidden(e,t,s))return s;if(o>i)for(let s=o;s>=i;s--)if(this.getters.doesHeaderExist(e,t,s)&&!this.isHeaderHidden(e,t,s))return s}findLastVisibleColRowIndex(e,t,{last:o,first:i}){return Oe(o,i,-1).find((o=>!this.isHeaderHidden(e,t,o)))||i}findFirstVisibleColRowIndex(e,t){const o=this.getters.getNumberHeaders(e,t);for(let i=0;i<o;i++){if("COL"===t&&!this.isColHidden(e,i))return i;if("ROW"===t&&!this.isRowHidden(e,i))return i}}exportForExcel(e){for(const t of e.sheets)for(const[e,o]of Object.entries(t.rows)){const i=this.isRowHidden(t.id,Number(e));o.isHidden=i}}}).add("ui_options",class extends zE{static getters=["shouldShowFormulas"];showFormulas=!1;handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}).add("selectionInputManager",class extends zE{config;static layers=[1];static getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];inputs={};focusedInputId=null;get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e}allowDispatch(e){if("FOCUS_RANGE"===e.type){const t=this.currentInput?.getIndex(e.rangeId);if(this.focusedInputId===e.id&&this.currentInput?.focusedRangeIndex===t)return 30}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_RANGE":case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:Ei({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}break;case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id],o=t.ranges.find((t=>t.id===e.rangeId));if(this.isRangeValid(o?.xc||"A1")){const e=this.getters.getActiveSheetId(),i=this.getters.getRangeFromSheetXC(e,o?.xc||"A1").zone;this.selection.capture(t,{cell:{col:i.left,row:i.top},zone:i},{handleEvent:t.handleEvent.bind(t)})}this.focusedInputId=e.id}}this.currentInput?.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,o)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===o}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:o}=Ko(e);return null!==t.match(qo)&&(!o||void 0!==this.getters.getSheetIdByName(o))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,o=!1){if(this.inputs[e]=new hw(this.config,t,o),0===t.length){const t=this.inputs[e],o={zone:Ei({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,o,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}).add("highlight",class extends zE{static layers=[1];static getters=["getHighlights"];getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{numberOfRows:t,numberOfCols:o}=pi(e.zone),i=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:i}}))}drawGrid(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId(),s=3*o;t.lineWidth=s;const r=this.getHighlights();for(let e of r.filter(((e,t)=>r.findIndex((t=>li(t.zone,e.zone)&&t.sheetId===i))===t))){const{x:o,y:i,width:r,height:n}=this.getters.getVisibleRect(e.zone);r>0&&n>0&&(t.strokeStyle=e.color,t.strokeRect(o+s/2,i+s/2,r-s,n-s),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+s,i+s,r-2*s,n-2*s))}}}).add("grid renderer",class extends zE{static layers=[0,7];static getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];boxes=[];getColDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleCols()),i=this.getters.getColRowOffsetInViewport("COL",o,t),s=this.getters.getColSize(e,t);return{start:i,size:s,end:i+(this.getters.isColHidden(e,t)?0:s)}}getRowDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleRows()),i=this.getters.getColRowOffsetInViewport("ROW",o,t),s=this.getters.getRowSize(e,t);return{start:i,size:s,end:i+(this.getters.isRowHidden(e,t)?0:s)}}getHeaderOffset(e,t,o){let i=this.getters.getColRowOffsetInViewport(e,t,o);return this.getters.isDashboard()||(i+="ROW"===e?_:F),i}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:o}=e,{width:i,height:s}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,i+m,s+m);const r=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),n=r?.1*o:0;if(r)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=o,t.strokeRect(e.x+n,e.y+n,e.width-2*n,e.height-2*n)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let o=e.style;o.fillColor&&"#ffffff"!==o.fillColor&&(t.fillStyle=o.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawOverflowingCellBackground(e){const{ctx:t,thinLineWidth:o}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const i=e.content.align||"left";let s,r;const n=e.y+o/2,a=e.height-o,l=Math.min(e.clipRect?.width||1/0,e.content.width);"left"===i?(s=e.x+o/2,r=l-2*o):"right"===i?(s=e.x+e.width-o/2,r=2*o-l):(s=(e.clipRect?.x||e.x+e.width/2-e.content.width/2)+o/2,r=l-2*o),t.fillStyle="#ffffff",t.fillRect(s,n,r,a)}}drawBorders(e){const{ctx:t}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:s,width:r,height:n}=e;t.left&&o(t.left,i,s,i,s+n),t.top&&o(t.top,i,s,i+r,s),t.right&&o(t.right,i+r,s,i+r,s+n),t.bottom&&o(t.bottom,i,s+n,i+r,s+n)}}function o({style:e,color:o},i,s,r,n){switch(t.strokeStyle=o,e){case"medium":t.lineWidth=2,s+=(i+=s===n?-.5:.5)===(r+=s===n?1.5:.5)?-.5:.5,n+=i===r?1.5:.5;break;case"thick":t.lineWidth=3,s===n&&(i--,r++),i===r&&(s--,n++);break;case"dashed":t.lineWidth=1,t.setLineDash([1,3]);break;case"dotted":t.lineWidth=1,s===n&&(i+=.5,r+=.5),i===r&&(s+=.5,n+=.5),t.setLineDash([1,1]);break;default:t.lineWidth=1}t.beginPath(),t.moveTo(i,s),t.lineTo(r,n),t.stroke(),t.lineWidth=1,t.setLineDash([])}}drawTexts(e){const{ctx:t,thinLineWidth:o}=e;let i;t.textBaseline="top";for(let e of this.boxes)if(e.content){const s=e.style||{},r=e.content.align||"left",n=Te(s);n!==i&&(i=n,t.font=n),t.fillStyle=s.textColor||"#000";let a=e.x;if(a+="left"===r?z+(e.image?e.image.size+V:0):"right"===r?e.width-z-(e.isFilterHeader?20:0):e.width/2,t.textAlign=r,e.clipRect){t.save(),t.beginPath();const{x:o,y:i,width:s,height:r}=e.clipRect;t.rect(o,i,s,r),t.clip()}const l=Ae(s),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let i of e.content.textLines){if(t.fillText(i,Math.round(a),Math.round(h)),s.strikethrough||s.underline){const e=xe(t,i,s);let n=a;"right"===r?n-=e:"center"===r&&(n-=e/2),s.strikethrough&&t.fillRect(n,h+l/2,e,2.6*o),s.underline&&t.fillRect(n,h+l+1,e,1.3*o)}h+=z+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const o=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:o,y:i,width:s,height:r}=e.image.clipIcon;t.rect(o,i,s,r),t.clip()}const i=e.image.size,s=this.computeTextYCoordinate(e,i);t.drawImage(o,e.x+V,s,i,i),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,o=1){const i=e.y+1,s=ye(t,o),r=e.height>s+2*z,n=e.verticalAlign||j;if(r){if("middle"===n)return i+(e.height-s)/2;if("bottom"===n)return i+e.height-s-z}return i+z}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getSheetViewVisibleCols(),s=i[0],r=i[i.length-1],n=this.getters.getSheetViewVisibleRows(),a=n[0],l=n[n.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let o of e)for(let e of Oe(o.left,o.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let o of e)for(let e of Oe(o.top,o.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${Z}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(let e=s;e<=r;e++){const o={left:e,right:e,top:0,bottom:f-1},{x:i,width:s}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),n=E.has(e),a=u.has(e);t.fillStyle=n?r?R:S:a?r?A:v:r?T:b,t.fillRect(i,0,s,_)}for(let e=a;e<=l;e++){const o={top:e,bottom:e,left:0,right:m-1},{y:i,height:s}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),n=w.has(e),a=g.has(e);t.fillStyle=n?r?R:S:a?r?A:v:r?T:b,t.fillRect(0,i,F,s)}t.beginPath(),t.moveTo(F,0),t.lineTo(F,h),t.moveTo(0,_),t.lineTo(c,_),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of i){const o=this.getters.getColSize(p,e),i=Et(e);t.fillStyle=E.has(e)?"#fff":C;let r=this.getHeaderOffset("COL",s,e);t.fillText(i,r+o/2,13),t.moveTo(r+o,0),t.lineTo(r+o,_)}for(const e of n){const o=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let i=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,i+o/2),t.moveTo(0,i+o),t.lineTo(F,i+o)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:s}=this.getters.getMainViewportCoordinates(),r=this.getters.isDashboard()?0:F,n=this.getters.isDashboard()?0:_;t.lineWidth=6*o,t.strokeStyle="#BCBCBC",t.beginPath(),i&&(t.moveTo(r+i,0),t.lineTo(r+i,n)),s&&(t.moveTo(0,n+s),t.lineTo(r,n+s)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:s}=this.getters.getMainViewportCoordinates(),r=this.getters.getSheetViewVisibleCols(),n=r[0],a=r[r.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:n,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:F,u=this.getters.isDashboard()?0:_;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),i&&(t.moveTo(d+i,u),t.lineTo(d+i,h.height+u)),s&&(t.moveTo(d,u+s),t.lineTo(h.width+d,u+s)),t.stroke()}findNextEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let s=e;for(;s<t;){const e={sheetId:i,col:s+1,row:o},t=this.getters.getEvaluatedCell(e),r=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==Qi.empty||this.getters.isInMerge(e)||r?.left)return s;s++}return s}findPreviousEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let s=e;for(;s>t;){const e={sheetId:i,col:s-1,row:o},t=this.getters.getEvaluatedCell(e),r=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==Qi.empty||this.getters.isInMerge(e)||r?.right)return s;s--}return s}computeCellAlignment(e,t){if(this.getters.getCell(e)?.isFormula&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),i=this.getters.getEvaluatedCell(e);return t&&i.type===Qi.number?"center"!==o?"left":o:o||i.defaultAlign}createZoneBox(e,t,o){const{left:i,right:s}=o,r=t.left,n=t.top,a={sheetId:e,col:r,row:n},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===Qi.empty)return f;const b=this.getters.getConditionalIcon(a),v=Ae(f.style),S=b?V+v:0;b&&(f.image={type:"icon",size:v,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:tv[b].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",y="wrap"!==w||h?void 0:g-2*z,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+z))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===Qi.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||v>p;if(b||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,o;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,o=r):(e=this.findNextEmptyCol(r,s,n),o=this.findPreviousEmptyCol(r,i,n),f.isOverflow=!0),T){case"left":{const o=Ei({col:e,row:n}),{x:i,y:s,width:r,height:a}=this.getters.getVisibleRect(ni(t,o));(r<R||v>a||x.length>1)&&(f.clipRect={x:i,y:s,width:r,height:a});break}case"right":{const e=Ei({col:o,row:n}),{x:i,y:s,width:r,height:a}=this.getters.getVisibleRect(ni(t,e));(r<R||v>a||x.length>1)&&(f.clipRect={x:i,y:s,width:r,height:a});break}case"center":{const i={...t,left:o,right:e},{x:s,y:r,height:n,width:a}=this.getters.getVisibleRect(i),l=R/2,c=f.x+f.width/2;if(s+a<c+l||s>c-l||v>n||x.length>1){const e=s>c-l?s:c-l,t=s+a-e;f.clipRect={x:e,y:r,width:t,height:n}}break}}}else("clip"===w||"wrap"===w||x.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),o=t[0],i=t[t.length-1],s=this.getters.getSheetViewVisibleRows(),r={left:o,right:i,top:s[0],bottom:s[s.length-1]},n=this.getters.getActiveSheetId();for(const o of s)for(const i of t){const t={sheetId:n,col:i,row:o};this.getters.isInMerge(t)||e.push(this.createZoneBox(n,Ei(t),r))}for(const t of this.getters.getMerges(n))if(!this.getters.isMergeHidden(n,t)&&ci(t,r)){const o=this.createZoneBox(n,t,r),i=this.getters.getCellBorder({sheetId:n,col:t.right,row:t.bottom});o.border={...o.border,bottom:i?i.bottom:void 0,right:i?i.right:void 0},o.isMerge=!0,e.push(o)}return e}}).add("autofill",class extends zE{static layers=[5];static getters=["getAutofillTooltip"];autofillZone;steps;lastCellSelected={};direction;tooltip;allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:we(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:we(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:46;case"AUTOFILL_AUTO":const o=this.getters.getSelectedZone();return o.top===o.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border}),this.autofillCF(e.originCol,e.originRow,e.col,e.row)}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),o=this.autofillZone;switch(this.direction){case"down":for(let i=t.left;i<=t.right;i++){const s=[];for(let e=t.top;e<=t.bottom;e++)s.push(Tt(i,e));const r=this.createGenerator(s);for(let t=o.top;t<=o.bottom;t++)this.computeNewCell(r,i,t,e)}break;case"up":for(let i=t.left;i<=t.right;i++){const s=[];for(let e=t.bottom;e>=t.top;e--)s.push(Tt(i,e));const r=this.createGenerator(s);for(let t=o.bottom;t>=o.top;t--)this.computeNewCell(r,i,t,e)}break;case"left":for(let i=t.top;i<=t.bottom;i++){const s=[];for(let e=t.right;e>=t.left;e--)s.push(Tt(e,i));const r=this.createGenerator(s);for(let t=o.right;t>=o.left;t--)this.computeNewCell(r,t,i,e)}break;case"right":for(let i=t.top;i<=t.bottom;i++){const s=[];for(let e=t.left;e<=t.right;e++)s.push(Tt(e,i));const r=this.createGenerator(s);for(let t=o.left;t<=o.right;t++)this.computeNewCell(r,t,i,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const o=this.getters.getSelectedZone();if(hi(e,t,o))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,o.top-1,o.left,o.right),this.steps=o.top-t;break;case"down":this.saveZone(o.bottom+1,t,o.left,o.right),this.steps=t-o.bottom;break;case"left":this.saveZone(o.top,o.bottom,e,o.left-1),this.steps=o.left-e;break;case"right":this.saveZone(o.top,o.bottom,o.right+1,e),this.steps=e-o.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let o=e.left,i=e.bottom;if(o>0){let e=this.getters.getEvaluatedCell({sheetId:t,col:o-1,row:i});for(;e.type!==Qi.empty;)i+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:o-1,row:i})}if(i===e.bottom&&(o=e.right,o<=this.getters.getNumberCols(t))){let e=this.getters.getEvaluatedCell({sheetId:t,col:o+1,row:i});for(;e.type!==Qi.empty;)i+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:o+1,row:i})}i!==e.bottom&&(this.select(e.left,i-1),this.autofill(!0))}computeNewCell(e,t,o,i){const{cellData:s,tooltip:r,origin:n}=e.next(),{content:a,style:l,border:c,format:h}=s;this.tooltip=r,i&&this.dispatch("AUTOFILL_CELL",{originCol:n.col,originRow:n.row,col:t,row:o,content:a,style:l,border:c,format:h})}getRule(e,t){const o=er.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((o=>o.condition(e,t)));return o&&o.generateRule(e,t)}createGenerator(e){const t=[],o=[],i=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:s}=Rt(t),r=this.getters.getCell({sheetId:i,col:e,row:s});o.push({col:e,row:s,cell:r,sheetId:i})}const s=o.map((e=>e.cell));for(let e of o){let o={type:"COPY_MODIFIER"};if(e&&e.cell){o=this.getRule(e.cell,s)||o}const i=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:i},rule:o})}return new KE(t,this.getters,this.direction)}saveZone(e,t,o,i){this.autofillZone={top:e,bottom:t,left:o,right:i}}getDirection(e,t){const o=this.getters.getSelectedZone(),i={up:{number:o.top-t,value:"up"},down:{number:t-o.bottom,value:"down"},left:{number:o.left-e,value:"left"},right:{number:e-o.right,value:"right"}};if(1===Object.values(i).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(i).find((e=>e.number>0?1:0)).value;const s=i.up.number>0?"up":"down",r=i.left.number>0?"left":"right";return Math.abs(i[s].number)>=Math.abs(i[r].number)?i[s].value:i[r].value}autoFillMerge(e,t,o,i){const s=this.getters.getActiveSheetId(),r={sheetId:s,col:o,row:i},n={sheetId:s,col:e,row:t};if(this.getters.isInMerge(r)&&!this.getters.isInMerge(n)){const e=this.getters.getMerge(r);e&&this.dispatch("REMOVE_MERGE",{sheetId:s,target:[e]})}const a=this.getters.getMerge(n);a?.topLeft.col===e&&a?.topLeft.row===t&&this.dispatch("ADD_MERGE",{sheetId:s,target:[{top:i,bottom:i+a.bottom-a.top,left:o,right:o+a.right-a.left}]})}autofillCF(e,t,o,i){const s=this.getters.getActiveSheetId(),r=this.getters.getRulesByCell(s,e,t);for(const e of r){const t=this.getters.getAdaptedCfRanges(s,e,[Tt(o,i)],[]);t&&this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:Se(e),ranges:t.map((e=>this.getters.getRangeDataFromXc(s,e))),sheetId:s})}}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:o}=e,{x:i,y:s,width:r,height:n}=this.getters.getVisibleRect(this.autofillZone);r>0&&n>0&&(t.strokeStyle="black",t.lineWidth=o,t.setLineDash([3]),t.strokeRect(i,s,r,n),t.setLineDash([]))}}).add("find_and_replace",class extends zE{static layers=[3];static getters=["getSearchMatches","getCurrentSelectedMatchIndex"];searchMatches=[];selectedMatchIndex=null;currentSearchRegex=null;searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1};toSearch="";handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(cw.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(cw.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(cw.current)}updateRegex(){let e=ve(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),o=[];if(this.toSearch)for(const i of Object.values(t)){const{col:t,row:s}=this.getters.getCellPosition(i.id);if(i&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:s}))){const e={col:t,row:s,selected:!1};o.push(e)}}return o.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let o;o=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,o=(o%t.length+t.length)%t.length,this.selectedMatchIndex=o,this.selection.selectCell(t[o].col,t[o].row);for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],o=this.getters.getActiveSheetId();if(this.getters.getCell({sheetId:o,...t})?.isFormula&&!this.searchOptions.searchFormulas)this.selectNextCell(cw.next);else{const i=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),s=this.getSearchableString({sheetId:o,col:t.col,row:t.row}).replace(i,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:og(s,this.getters.getLocale())}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(cw.current)}}replaceAll(e){const t=this.searchMatches.length;for(let o=0;o<t;o++)this.replace(e)}getSearchableString(e){return this.getters.getCellText(e,this.searchOptions.searchFormulas)}drawGrid(e){const{ctx:t}=e,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const i=this.getters.getMerge({sheetId:o,col:e.col,row:e.row}),s=i?i.left:e.col,r=i?i.right:e.col,n=i?i.top:e.row,a=i?i.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:n,left:s,right:r,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}).add("sort",class extends zE{static getters=["getContiguousZone"];allowDispatch(e){if("SORT_CELLS"===e.type){if(!hi(e.col,e.row,e.zone))throw new Error(r("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;return fi(t).some((({col:t,row:o})=>!this.getters.isInMerge({sheetId:e,col:t,row:o})))?64:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const o=this.getters.getMerges(e).filter((e=>ci(e,t))),i=pi(o[0]);let[s,r]=[i.numberOfCols,i.numberOfRows];return o.every((e=>{let[t,o]=[e.right-e.left+1,e.bottom-e.top+1];return t===s&&o===r}))?0:64}expand(e,t){const{left:o,right:i,top:s,bottom:r}=this.getters.expandZone(e,t);return{left:Math.max(0,o),right:Math.min(this.getters.getNumberCols(e)-1,i),top:Math.max(0,s),bottom:Math.min(this.getters.getNumberRows(e)-1,r)}}checkExpandedValues(e,t){const o=this.expand(e,t);let i;if(this.getters.doesIntersectMerge(e,o)){const{left:t,right:s,top:r,bottom:n}=o;for(let o=t;o<=s;o++)for(let t=r;t<=n;t++){const{col:s,row:r}=this.getters.getMainCellPosition({sheetId:e,col:o,row:t});if(i=this.getters.getEvaluatedCell({sheetId:e,col:s,row:r}),i.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,o))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let o,{top:i,bottom:s,left:r,right:n}=t,a=!1;for(;!a;)a=!0,i>0&&(o=this.checkExpandedValues(e,{left:r-1,right:n+1,top:i-1,bottom:i-1}),o&&(a=!1,i--)),r>0&&(o=this.checkExpandedValues(e,{left:r-1,right:r-1,top:i-1,bottom:s+1}),o&&(a=!1,r--)),n<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:n+1,right:n+1,top:i-1,bottom:s+1}),o&&(a=!1,n++)),s<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:r-1,right:n+1,top:s+1,bottom:s+1}),o&&(a=!1,s++));return{left:r,right:n,top:i,bottom:s}}hasHeader(e,t){if(1===t[0].length)return!1;let o=t.map((t=>t.map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).type))));return o[0][0]===Qi.empty&&(o=o.slice(1)),!o.some((e=>e[0]===Qi.empty))&&!!o.some((e=>e[1]!==Qi.empty&&e[0]!==e[1]))}sortZone(e,t,o,i,s){const[r,n]=this.mainCellsSteps(e,o);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},o),c=this.mainCells(e,o);!s.sortHeaders&&this.hasHeader(e,c)&&(l.top+=n),c=this.mainCells(e,l);const h=function(e,t,o){const i=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let s=i.filter((e=>e.type===Qi.empty)),r=i.filter((e=>e.type!==Qi.empty));o&&(r.push(...s.map((e=>({...e,type:Qi.number,value:0})))),s=[]);const n="descending"===t?-1:1;return r.sort(((e,t)=>{let o=cf.indexOf(e.type)-cf.indexOf(t.type);return 0===o&&(o=e.type===Qi.text||e.type===Qi.error?e.value.localeCompare(t.value):e.value-t.value),n*o})).concat(s)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),i,Boolean(s.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++){for(let t=0;t<g;t++){let{col:o,row:i,sheetId:s}=c[e][d[t]];const a=this.getters.getCell({sheetId:s,col:o,row:i});let h=l.left+e*r,u=l.top+t*n,g={sheetId:s,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,o=this.getters.createAdaptedRanges(a.dependencies,0,t,s);e=this.getters.buildFormulaContent(s,a,o)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}for(const e of p)this.dispatch("UPDATE_CELL",e)}}mainCellsSteps(e,t){const o=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[o?o.right-o.left+1:1,o?o.bottom-o.top+1:1]}mainCells(e,t){const[o,i]=this.mainCellsSteps(e,t),s=[],r=Oe(t.left,t.right+1,o),n=Oe(t.top,t.bottom+1,i);for(const t of r){const o=[];s.push(o);for(const i of n)o.push({sheetId:e,col:t,row:i})}return s}}).add("automatic_sum",class extends zE{static getters=["getAutomaticSums"];handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:o}=this.getters.getSelection();for(const i of t){const t=this.getAutomaticSums(e,i,o.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,o){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,o):this.sumData(e,t)}sumData(e,t){const o=this.dimensionsToSum(e,t),i=this.sumDimensions(e,t,o).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return o.has("ROW")&&o.has("COL")&&i.push(this.sumTotal(t)),i}sumAdjacentData(e,t,o){const{col:i,row:s}=hi(o.col,o.row,t)?o:{col:t.left,row:t.top},r=this.findAdjacentData(e,i,s);return r?this.getters.isSingleCellOrMerge(e,t)||mi(ni(r,t))?[{position:{col:i,row:s},zone:r}]:this.sumDimensions(e,ni(r,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,o){const i=this.getters.getSheet(e),s=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),r=this.findSuitableZoneToSum(i,s.col,s.row);if(r)return this.getters.expandZone(e,r)}findSuitableZoneToSum(e,t,o){const i=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:o-1}),s=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:o});if(this.isNumber(s)&&!this.isNumber(i))return this.findHorizontalZone(e,t,o);const r=this.findVerticalZone(e,t,o);if(this.isZoneValid(r))return r;const n=this.findHorizontalZone(e,t,o);return this.isZoneValid(n)?n:void 0}findVerticalZone(e,t,o){const i={top:0,bottom:o-1,left:t,right:t},s=this.reduceZoneStart(e,i,i.bottom);return{...i,top:s}}findHorizontalZone(e,t,o){const i={top:o,bottom:o,left:0,right:t-1},s=this.reduceZoneStart(e,i,i.right);return{...i,left:s}}reduceZoneStart(e,t,o){const i=this.getters.getEvaluatedCellsInZone(e.id,t),s=Oe(o,-1,-1),r=s.filter((e=>i[e]&&!i[e].isAutoSummable)),n=Math.max(...r),a=Ne(s.filter((e=>this.isNumber(i[e]))))[0]||[];return Math.max(...a)<n?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){return e.type===Qi.number&&!(e.format&&Io(e.format))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const o=new Set;return mi(t)?(o.add(1===pi(t).numberOfCols?"COL":"ROW"),o):(this.lastColIsEmpty(e,t)&&o.add("ROW"),this.lastRowIsEmpty(e,t)&&o.add("COL"),0===o.size&&o.add("COL"),o)}sumDimensions(e,t,o){return[...o.has("COL")?this.sumColumns(t,e):[],...o.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:o}=e;return{position:{col:o,row:t},zone:{...e,top:t,right:o-1}}}sumColumns(e,t){const o=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,o.bottom-1)},fi(o).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const o=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,o.right-1)},fi(o).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const o of t){const{col:t,row:i}=o.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,content:`=SUM(${this.getters.zoneToXC(e,o.zone)})`})}}nextEmptyRow(e,t){let o=t.bottom+1;const{left:i,right:s}=t;for(;!this.getters.isEmpty(e,{bottom:o,top:o,left:i,right:s});)o++;return{...t,top:o,bottom:o}}nextEmptyCol(e,t){let o=t.right+1;const{top:i,bottom:s}=t;for(;!this.getters.isEmpty(e,{left:o,right:o,top:i,bottom:s});)o++;return{...t,left:o,right:o}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}).add("format",class extends zE{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,o){for(const i of t)for(const t of fi(i)){const i=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==i){this.getters.getLocale();const s=Lo(i,o);this.dispatch("SET_FORMATTING",{sheetId:e,target:[Ei(t)],format:s})}}}getCellNumberFormat(e){for(const t of[e]){const e=this.getters.getEvaluatedCell(t);if(!(e.type!==Qi.number||e.format&&Io(e.format)))return e.format||Mo(e.value)}}}).add("split_to_columns",class extends zE{static getters=["getAutomaticSeparator"];allowDispatch(e){return"SPLIT_TEXT_INTO_COLUMNS"===e.type?this.chainValidations(this.batchValidations(this.checkSingleColSelected,this.checkNonEmptySelector),this.batchValidations(this.checkNotOverwritingContent,this.checkSeparatorInSelection))(e):0}handle(e){if("SPLIT_TEXT_INTO_COLUMNS"===e.type)this.splitIntoColumns(e)}getAutomaticSeparator(){const e=this.getters.getSelectedCells();for(const t of e)if(t.value&&t.type===Qi.text){const e=this.getAutoSeparatorForString(t.value);if(e)return e}return" "}getAutoSeparatorForString(e){const t=[pe,";",","," ","."];for(const o of t)if(e.includes(o))return o}splitIntoColumns({separator:e,addNewColumns:t}){const o=this.getters.getSelectedZone(),i=this.getters.getActiveSheetId(),s=this.getSplittedCols(o,e);t&&this.addColsToAvoidCollisions(o,s),this.removeMergesInSplitZone(o,s),this.addColumnsToNotOverflowSheet(o,s);for(let e=0;e<s.length;e++){const t=o.top+e,r=s[e],n=o.left,a=this.getters.getCell({sheetId:i,col:n,row:t});if(1!==r.length||r[0]!==a?.content)for(const[e,o]of r.entries())this.dispatch("UPDATE_CELL",{sheetId:i,col:n+e,row:t,content:og(o,this.getters.getLocale()),format:"",style:a?.style||null})}}getSplittedCols(e,t){if(!t)throw new Error("Separator cannot be empty");const o=this.getters.getActiveSheetId(),i=[];for(const s of Oe(e.top,e.bottom+1)){const r=this.getters.getEvaluatedCell({sheetId:o,col:e.left,row:s}).formattedValue;i.push(this.splitAndRemoveTrailingEmpty(r,t))}return i}splitAndRemoveTrailingEmpty(e,t){const o=e.split(t);for(;o.length>1&&""===o[o.length-1];)o.pop();return o}willSplittedColsOverwriteContent(e,t){const o=this.getters.getActiveSheetId();for(const i of Oe(e.top,e.bottom+1)){const s=t[i-e.top];for(let t=1;t<s.length;t++){const s=this.getters.getCell({sheetId:o,col:e.left+t,row:i});if(s&&s.content)return!0}}return!1}removeMergesInSplitZone(e,t){const o=this.getters.getActiveSheetId(),i=Math.max(...t.map((e=>e.length))),s={...e,right:e.left+i-1},r=this.getters.getMergesInZone(o,s);this.dispatch("REMOVE_MERGE",{sheetId:o,target:r})}addColsToAvoidCollisions(e,t){const o=this.getters.getActiveSheetId();let i=0;for(const s of Oe(e.top,e.bottom+1)){const r={sheetId:o,col:e.left,row:s},n=t[s-e.top],a=this.getColsToAddToAvoidCollision(r,n);i=Math.max(i,a)}i&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:e.left,sheetId:o,quantity:i,position:"after"})}getColsToAddToAvoidCollision(e,t){const o=t.length;for(let t=1;t<o;t++){const i=e.col+t,s=this.getters.getCell({...e,col:i});if(s&&s.content)return o-t}return 0}addColumnsToNotOverflowSheet(e,t){const o=this.getters.getActiveSheetId(),i=Math.max(...t.map((e=>e.length-1))),s=this.getters.getNumberCols(o)-1;e.left+i>s&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:s,sheetId:o,quantity:e.left+i-s,position:"after"})}checkSingleColSelected(){return this.getters.isSingleColSelected()?0:89}checkNonEmptySelector(e){return""===e.separator?90:0}checkNotOverwritingContent(e){if(e.addNewColumns||e.force)return 0;const t=this.getters.getSelectedZones()[0],o=this.getSplittedCols(t,e.separator);return this.willSplittedColsOverwriteContent(t,o)?91:0}checkSeparatorInSelection({separator:e}){const t=this.getters.getSelectedCells();for(const o of t)if(o.formattedValue.includes(e))return 0;return 92}}).add("cell_popovers",class extends zE{static getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];persistentPopover;allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{Ig.get(e.popoverType)}catch(e){return 73}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){const o=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=Ig.get(this.persistentPopover.type).onOpen?.(e,this.getters);return t?.isOpen?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:o,col:e,row:t}))return{isOpen:!1};const i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}),s=Ig.getAll().map((e=>e.onHover?.(i,this.getters))).find((e=>e?.isOpen));return s?.isOpen?{...s,anchorRect:this.computePopoverAnchorRect(i)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const o=this.getters.getActiveSheetId(),i=this.getters.getMerge({sheetId:o,col:e,row:t});return i?this.getters.getVisibleRect(i):this.getters.getVisibleRect(Ei({col:e,row:t}))}}).add("collaborative",class extends zE{static getters=["getClientsToDisplay","getClient","getConnectedClients","isFullySynchronized"];static layers=[6];availableColors=new Set(lw);colors={};session;constructor(e){super(e),this.session=e.session}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(lw));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClient(){return this.session.getClient()}getConnectedClients(){return this.session.getConnectedClients()}isFullySynchronized(){return this.session.isFullySynchronized()}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof nw)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const o of this.getters.getConnectedClients())if(o.id!==this.getters.getClient().id&&o.position&&o.position.sheetId===e&&this.isPositionValid(o.position)){const e=o.position;this.colors[o.id]||(this.colors[o.id]=this.chooseNewColor());const i=this.colors[o.id];t.push({...o,position:e,color:i})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:s,col:r}=e.position,n=this.getters.expandZone(i,{top:s,bottom:s,left:r,right:r}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(n);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*o,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${q+1}px ${Z}`}}}).add("history",class extends zE{static getters=["canUndo","canRedo"];undoStack=[];redoStack=[];session;constructor(e){super(e),this.session=e.session,this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();if(t)"UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t));else{const e=this.getPossibleRevisionToRepeat();if(!e)return;const t=Ew(e,this.getters);if(!t)return;if(!Array.isArray(t))return void this.dispatch(t.type,t);for(const e of t)this.dispatch(e.type,e)}}canUndo(){return this.undoStack.length>0}canRedo(){if(this.redoStack.length>0)return!0;const e=this.getPossibleRevisionToRepeat();return!(!(t=e)||!t.rootCommand||"object"!=typeof t.rootCommand)&&(rs(t.rootCommand)?bw.contains(t.rootCommand.type):vw.contains(t.rootCommand.type));var t}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}getPossibleRevisionToRepeat(){return this.session.getLastLocalNonEmptyRevision(["REQUEST_REDO"])}}),kw=(new $i).add("selection",class extends zE{static layers=[6];static getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getSelectedCells","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","isSingleColSelected","getElementsFromSelection","tryGetActiveSheetId"];gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]};selectedFigureId=null;sheetsData={};moveClient;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 28}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let o=[];switch(e.mode){case"overrideSelection":o=[t.zone];break;case"updateAnchor":o=[...this.gridSelection.zones];const i=o.findIndex((t=>li(t,e.previousAnchor.zone)));i>=0&&(o[i]=t.zone);break;case"newAnchor":o=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,o),this.selection.resetDefaultAnchor(this,Se(this.gridSelection.anchor));const{col:i,row:s}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:i,row:s}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(o,i),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:Se(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Se(this.gridSelection.anchor));else{const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,o)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const s=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of s)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Se(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:o})}const r=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(r,e))),this.gridSelection.anchor.zone=this.getters.expandZone(r,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,Se(this.gridSelection.anchor))}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let o=t.left;o<=t.right;o++)e.add(o);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let o of this.gridSelection.zones)if(0===o.left&&o.right===this.getters.getNumberCols(t)-1)for(let t=o.top;t<=o.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return Se(this.gridSelection.zones)}getSelectedZone(){return Se(this.gridSelection.anchor.zone)}getSelection(){return Se(this.gridSelection)}getSelectedCells(){const e=this.getters.getActiveSheetId(),t=[];for(const o of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,o));return t}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>e.type!==Qi.empty)));let t=new Set,o=[];for(let i of e)t.add(i.type),o.push(i.value);const i=this.getters.getLocale();let s={};for(let e of Fw){let r;e.types.some((e=>t.has(e)))&&(r=e.compute(o,i)),s[e.name]=r}return s}getAggregate(){let e=0,t=0;const o=this.getters.getActiveSheetId(),i=this.gridSelection.zones.map(fi).flat();for(const{col:s,row:r}of i){const i=this.getters.getEvaluatedCell({sheetId:o,col:s,row:r});i.type===Qi.number&&(t++,e+=i.value)}const s=this.getters.getLocale();return t<2?null:vo(e,{locale:s})}isSelected(e){return!!this.getters.getSelectedZones().find((t=>li(t,e)))}isSingleColSelected(){const e=this.getters.getSelectedZones();return 1===e.length&&e[0].left===e[0].right}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let o=[];const i="COL"===e?"left":"top",s="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[s]-e[i]+1},((t,o)=>e[i]+o));o=o.concat(t)}return[...new Set(o)].sort()}setSelectionMixin(e,t){const{anchor:o,zones:i}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=o,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,o)=>t===o.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(i)}selectCell(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.expandZone(o,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:i,cell:{col:e,row:t}},[i])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),o=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[o]})}onColumnsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=si(o,"left",[...e.elements]);let s={left:t.col,right:t.col,top:t.row,bottom:t.row};s=si(s,"left",[...e.elements]);const r={cell:{col:s.left,row:s.top},zone:i},n=this.gridSelection.zones.map((t=>si(t,"left",[...e.elements])));this.setSelectionMixin(r,n)}onRowsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=si(o,"top",[...e.elements]);let s={left:t.col,right:t.col,top:t.row,bottom:t.row};s=si(s,"top",[...e.elements]);const r={cell:{col:s.left,row:s.top},zone:i},n=this.gridSelection.zones.map((t=>si(t,"top",[...e.elements])));this.setSelectionMixin(r,n)}onAddElements(e){const t="COL"===e.dimension?"left":"top",o=ii(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),i=this.gridSelection.zones.map((o=>ii(o,t,e.base,e.position,e.quantity))),s={cell:{col:o.left,row:o.top},zone:o};this.setSelectionMixin(s,i)}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const o="COL"===e.dimension,i=e.elements[0],s=e.elements[t-1],r=e.base<i,n=r&&o?t:0,a=r&&!o?t:0;this.dispatch("CUT",{cutTarget:[{left:o?i+n:0,right:o?s+n:this.getters.getNumberCols(e.sheetId)-1,top:o?0:i+a,bottom:o?this.getters.getNumberRows(e.sheetId)-1:s+a}]}),this.dispatch("PASTE",{target:[{left:o?e.base:0,right:o?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:o?0:e.base,bottom:o?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=r?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const o="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:o,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,o=e.elements[0],i=e.elements[e.elements.length-1],s=e.sheetId,r=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return r(s,o-1,o)||r(s,i,i+1)||r(s,e.base-1,e.base)?2:0}clipSelection(e,t){const o=this.getters.getNumberCols(e)-1,i=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:we(e.left,0,o),right:we(e.right,0,o),top:we(e.top,0,i),bottom:we(e.bottom,0,i)}))),anchor:{cell:{col:we(t.anchor.cell.col,0,o),row:we(t.anchor.cell.row,0,i)},zone:{left:we(t.anchor.zone.left,0,o),right:we(t.anchor.zone.right,0,o),top:we(t.anchor.zone.top,0,i),bottom:we(t.anchor.zone.bottom,0,i)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getSelectedZones();t.fillStyle="#f3f7fe";const s=1===i.length&&i[0].left===i[0].right&&i[0].top===i[0].bottom;t.fillStyle=s?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*o;for(const e of i){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(o,i,s,r),t.globalCompositeOperation="source-over",t.strokeRect(o,i,s,r)}t.globalCompositeOperation="source-over";const r=this.getActivePosition();let n;t.strokeStyle=E,t.lineWidth=3*o,n=this.getters.isInMerge(r)?this.getters.getMerge(r):Ei(r);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(n);c>0&&h>0&&t.strokeRect(a,l,c,h)}}).add("evaluation_filter",class extends zE{static getters=["getCellBorderWithFilterBorder","getFilterValues","isRowFiltered","isFilterActive"];filterValues={};hiddenRows=new Set;isEvaluationDirty=!1;allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 80;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"HIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const o of this.getters.getFilters(e.sheetIdTo)){const i=o.zoneWithHeaders;t[o.id]=this.getFilterValues({sheetId:e.sheetId,col:i.left,row:i.top})}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e){const{sheetId:t,col:o,row:i}=e;let s;for(let e of this.getters.getFilterTables(t)){const r=e.zone;if(hi(o,i,r)){const e=this.intersectZoneWithViewport(t,r);s={top:i===e.top?K:void 0,bottom:i===e.bottom?K:void 0,left:o===e.left?K:void 0,right:o===e.right?K:void 0}}}const r=this.getters.getCellBorder(e),n={...s,...Xe(r||{})};return $e(n)?null:n}getFilterValues(e){const t=this.getters.getFilterId(e),o=e.sheetId;return t&&this.filterValues[o]&&this.filterValues[o][t]||[]}isFilterActive(e){const t=this.getters.getFilterId(e),o=e.sheetId;return Boolean(t&&this.filterValues[o]?.[t]?.length)}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,"COL",t.left,t.right),right:this.getters.findVisibleHeader(e,"COL",t.right,t.left),top:this.getters.findVisibleHeader(e,"ROW",t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,"ROW",t.bottom,t.top)}}updateFilter({col:e,row:t,values:o,sheetId:i}){const s=this.getters.getFilterId({sheetId:i,col:e,row:t});s&&(this.filterValues[i]||(this.filterValues[i]={}),this.filterValues[i][s]=o)}updateHiddenRows(){const e=this.getters.getActiveSheetId(),t=this.getters.getFilters(e).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),o=new Set;for(let i of t){if(this.getters.isRowHiddenByUser(e,i.zoneWithHeaders.top))continue;if(o.has(i.zoneWithHeaders.top))continue;const t=this.filterValues[e]?.[i.id]?.map(Ke);if(t&&i.filteredZone)for(let s=i.filteredZone.top;s<=i.filteredZone.bottom;s++){const r=this.getCellValueAsString(e,i.col,s);t.includes(r)&&o.add(s)}}this.hiddenRows=o}getCellValueAsString(e,t,o){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets){const e=t.id;for(const o of t.filterTables){const i=Jo(o.range),s=[],r=[];for(const o of Oe(0,pi(i).numberOfCols)){const n={sheetId:t.id,col:i.left+o,row:i.top},a=this.getFilterValues(n),l=this.getters.getFilter(n);if(!l)continue;const c=l.filteredZone?fi(l.filteredZone).map((t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue)):[];if(a.length){const e=c.filter((e=>e)).filter((e=>!a.includes(e)));s.push({colId:o,displayedValues:[...new Set(e)],displayBlanks:!a.includes("")&&c.some((e=>!e))})}const h={col:l.col,row:l.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(h).formattedValue,u=this.getUniqueColNameForExcel(o,d,r);r.push(u),t.cells[Tt(h.col,h.row)]={...t.cells[Tt(h.col,h.row)],content:u,value:u,isFormula:!1}}o.filters=s}}}getUniqueColNameForExcel(e,t,o){t||(t=`Column${e}`);let i=t,s=2;for(;o.includes(i);)i=t+String(s),s++;return i}}).add("viewport",class extends zE{static getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio","isPositionVisible"];viewports={};sheetViewWidth=ge();sheetViewHeight=ge();gridOffsetX=0;gridOffsetY=0;sheetsWithDirtyViewports=new Set;allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){if(e.options.scrollIntoView){let{col:t,row:o}=Si(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const i=e.previousAnchor.zone,s=e.anchor.zone,{top:r,bottom:n,left:a,right:l}=this.getters.getActiveMainViewport();i.left===s.left&&i.right===s.right&&(t=a>t||t>l?a:t),i.top===s.top&&i.bottom===s.bottom&&(o=r>o||o>n?r:o)}const i=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(i)-1),o=Math.min(o,this.getters.getNumberRows(i)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:o})}}handle(e){switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:t}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(o,t).start+this.sheetViewHeight);this.shiftVertically(i);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),o=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(o);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==e.style?.fontSize)&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:s,row:r}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:s,row:r})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){const e=this.getters.getSheetIds();for(const t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>Oe(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>Oe(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);let{width:s,height:r}=t.getMaxSize();return{x:this.getters.getColDimensions(e,o).start,y:this.getters.getRowDimensions(e,i).start,width:s,height:r}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:o}=this.getMainViewportRect(),i=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-i.viewportWidth+1),maxOffsetY:Math.max(0,o-i.viewportHeight+1)}}getColRowOffsetInViewport(e,t,o){const i=this.getters.getActiveSheetId(),s=this.getters.getSheetViewVisibleCols(),r=this.getters.getSheetViewVisibleRows();if(o<t)return-this.getColRowOffsetInViewport(e,o,t);let n=0;const a="COL"===e?s:r;for(let s=t;s<o;s++)a.includes(s)&&(n+="COL"===e?this.getters.getColSize(i,s):this.getters.getRowSize(i,s));return n}isVisibleInViewport({sheetId:e,col:t,row:o}){return this.getSubViewports(e).some((e=>e.isVisible(t,o)))}getEdgeScrollCol(e,t,o){let i=!1,s=0,r=0;const{xSplit:n}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(i=!0,r=eo(e-a),s=1):e<l&&o>=l&&c>0?(i=!0,r=eo(l-e),s=-1):n&&t<l&&e>l&&(i=!0,r=eo(e),s="reset"),{canEdgeScroll:i,direction:s,delay:r}}getEdgeScrollRow(e,t,o){let i=!1,s=0,r=0;const{ySplit:n}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(i=!0,r=eo(e-a),s=1):e<l&&o>=l&&c>0?(i=!0,r=eo(l-e),s=-1):n&&t<l&&e>l&&(i=!0,r=eo(e),s="reset"),{canEdgeScroll:i,direction:s,delay:r}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),o=this.getSubViewports(t).map((t=>t.getRect(e))).filter(He);if(0===o.length)return{x:0,y:0,width:0,height:0};const i=Math.min(...o.map((e=>e.x))),s=Math.min(...o.map((e=>e.y))),r=Math.max(...o.map((e=>e.x+e.width)))-i,n=Math.max(...o.map((e=>e.y+e.height)))-s;return{x:i+this.gridOffsetX,y:s+this.gridOffsetY,width:r,height:n}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,o).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(He)}checkPositiveDimension(e){return e.width<0||e.height<0?69:0}checkValuesAreDifferent(e){const{height:t,width:o}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===o&&e.height===t?77:0}checkScrollingDirection({offsetX:e,offsetY:t}){const o=this.getMainInternalViewport(this.getters.getActiveSheetId());return!o.canScrollHorizontally&&e>0||!o.canScrollVertically&&t>0?70:0}getMainViewport(e){const t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const o=this.getSubViewports(e);Object.values(o).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,o=0,i=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=o,this.gridOffsetY=i,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const o=this.getters.getActiveSheetId(),{maxOffsetX:i,maxOffsetY:s}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(o)).forEach((o=>o.setViewportOffset(we(e,0,i),we(t,0,s))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),o=t-this.sheetViewHeight;return e=Math.min(e,o),e=Math.max(e,0)}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetScrollbarX||0,y:this.viewports[e]?.bottomRight.offsetScrollbarY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getNumberCols(e),s=this.getters.getNumberRows(e),r=this.getters.getColRowOffset("COL",0,t,e),n=this.getters.getColRowOffset("ROW",0,o,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:o&&t&&new Dw(this.getters,e,{left:0,right:t-1,top:0,bottom:o-1},{width:r,height:n},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:o&&new Dw(this.getters,e,{left:t,right:i-1,top:0,bottom:o-1},{width:this.sheetViewWidth-r,height:n},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Dw(this.getters,e,{left:0,right:t-1,top:o,bottom:s-1},{width:r,height:this.sheetViewHeight-n},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Dw(this.getters,e,{left:t,right:i-1,top:o,bottom:s-1},{width:this.sheetViewWidth-r,height:this.sheetViewHeight-n},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:o}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(o,e);const{anchor:i}=this.getters.getSelection(),s=this.getActiveMainViewport().top-t;this.selection.selectCell(i.cell.col,i.cell.row+s)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],o=this.getters.getFigures(e),{scrollX:i,scrollY:s}=this.getActiveSheetScrollInfo(),{x:r,y:n}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of o)e.x>=r&&(e.x+e.width<=r+i||e.x>=a+i+r)||e.y>=n&&(e.y+e.height<=n+s||e.y>=l+s+n)||t.push(e);return t}isPositionVisible(e){const{scrollX:t,scrollY:o}=this.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.getters.getMainViewportCoordinates(),{width:r,height:n}=this.getters.getSheetViewDimension();return!(e.x>=i&&(e.x<i+t||e.x>r+t+i))&&!(e.y>=s&&(e.y<s+o||e.y>n+o+s))}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getColDimensions(e,t).start,s=this.getters.getRowDimensions(e,o).start;return{xRatio:i/(this.sheetViewWidth+this.gridOffsetX),yRatio:s/(this.sheetViewHeight+this.gridOffsetY)}}}).add("clipboard",class extends zE{static layers=[2];static getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];status="invisible";state;lastPasteState;_isPaintingFormat=!1;originSheetId;allowDispatch(e){switch(e.type){case"CUT":const t=e.cutTarget||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 24;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:o});case"PASTE_FROM_OS_CLIPBOARD":return new Aw(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target,{pasteOption:e.pasteOption});case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}}return 0}handle(e){switch(e.type){case"COPY":case"CUT":const t="cutTarget"in e&&e.cutTarget||this.getters.getSelectedZones();this.state=this.getClipboardState(t,e.type),this.status="visible",this.originSheetId=this.getters.getActiveSheetId();break;case"PASTE":if(!this.state)break;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:o,shouldPasteCF:!0,selectTarget:!0}),this.lastPasteState=this.state,this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!ei(t[0])){for(const{col:t,row:o}of fi(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:o,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==this.state?.operation)return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==this.state?.operation)return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":this.state=new Aw(e.text,this.getters,this.dispatch,this.selection),this.state.paste(e.target,{pasteOption:e.pasteOption}),this.lastPasteState=this.state,this.status="invisible";break;case"REPEAT_PASTE":this.lastPasteState?.paste(e.target,{pasteOption:e.pasteOption,shouldPasteCF:!0,selectTarget:!0});break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}case"DELETE_SHEET":if("CUT"!==this.state?.operation)return;this.originSheetId===e.sheetId&&(this.state=void 0,this.status="invisible");break;default:rs(e)&&(this.status="invisible")}}getClipboardContent(){return this.state?.getClipboardContent()||{[Ji.PlainText]:"\t"}}getClipboardTextContent(){return this.state?.getClipboardContent()[Ji.PlainText]||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i;return i="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(o)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1},{cut:[i],paste:[e]}}getInsertCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i,s;return"COL"===t?(i={...e,right:this.getters.getNumberCols(o)-1},s={...e,left:e.right+1,right:e.right+1}):(i={...e,bottom:this.getters.getNumberRows(o)-1},s={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1}),{cut:[i],paste:[s]}}getClipboardStateForCopyCells(e,t){return new yw(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new xw(t,this.getters,this.dispatch):new yw(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}).add("edition",class extends zE{static getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];col=0;row=0;mode="inactive";sheetId="";currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;selectionInitialStart=0;initialContent="";previousRef="";previousRange=void 0;colorIndexByRange={};allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"!==this.mode)return;const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)this.insertSelectedRange(o);else this.replaceSelectedRanges(o)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),o=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:o,sheetName:i}=Ko(e.value),s=i||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==s)return!1;const n=this.getters.getRangeFromSheetXC(r,o);return li(this.getters.expandZone(r,n.zone),t.zone)}));this.previousRef=o.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=o.start;break;case"CHANGE_HIGHLIGHT":const i=this.getters.getRangeFromRangeData(e.range),s=this.getRangeReference(i,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(s),this.previousRef=s,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),s=this.getters.expandZone(e.sheetIdTo,Ei({col:o,row:i}));this.selection.resetAnchor(this,{cell:{col:o,row:i},zone:s})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:_w}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const o=e.map(Ow).map((e=>e.value)).join(""),i=this.currentContent,s=e[0].start,r=e[e.length-1].end,n=i.slice(0,s)+o+i.slice(r),a=n.length-i.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:n,selection:l})}validateSelection(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e?0:47}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:_w});const{top:t,left:o}=si({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:_w});const{top:t,left:o}=si({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=ii({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=o,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Ei({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){const o=this.getters.getActiveCell(),i=this.getters.getLocale();e&&o.format?.includes("%")&&ro(e,i)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:s,row:r,sheetId:n}=this.getters.getActivePosition();this.col=s,this.sheetId=n,this.row=r,this.initialContent=this.getComposerContent({sheetId:n,col:s,row:r}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=Ei({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const i=this.getters.getActiveSheetId(),s=this.getters.getEvaluatedCell({sheetId:i,col:this.col,row:this.row});if(o=og(o,this.getters.getLocale()),o.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,i=e-t;i>0&&(o+=Ge(new Array(i).fill(")")))}else s.link&&(o=Pe(o,s.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:o})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}getComposerContent(e){const t=this.getters.getLocale(),o=this.getters.getCell(e);if(o?.isFormula)return sg(o.content,t);const{format:i,value:s,type:r,formattedValue:n}=this.getters.getEvaluatedCell(e);switch(r){case Qi.text:case Qi.empty:return s;case Qi.boolean:return n;case Qi.error:return o?.content||"";case Qi.number:return i&&Io(i)?n:this.numberComposerContent(s,i,t)}}numberComposerContent(e,t,o){return t?.includes("%")?`${xo(100*e,o.decimalSeparator)}%`:xo(e,o.decimalSeparator)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const i=this.currentContent!==e;if(this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,i||"inactive"!==this.mode){const t=this.getters.getLocale();this.currentTokens=e.startsWith("=")?Qu(e,t):[],this.currentTokens.length>100&&o&&this.ui.notifyUI({type:"ERROR",text:r("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(o,t),this.selectionInitialStart=t):(this.insertText(","+o,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e){const t=this.getters.getCurrentEditedCell().sheetId,o=this.getters.getActiveSheetId(),i=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(i,t)}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let o=[...t];1===t.length&&yi(e.zone)>1?o.push({...t[0]}):2===t.length&&1===yi(e.zone)&&o.pop();const i=e.clone({parts:o});return this.getters.getSelectionRangeString(i,this.getters.getCurrentEditedCell().sheetId)}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(o,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),i=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:i,end:i}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getCurrentEditedCell().sheetId,t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const i=new Set(Object.values(o));let s=0;const r=()=>{for(;i.has(s);)s++;return i.add(s),s};for(const e of t){const t=e in o?o[e]:r();o[e]=t}this.colorIndexByRange=o}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getCurrentEditedCell().sheetId,t=e=>{const t=this.colorIndexByRange[e];return lt[t%lt.length]};return this.getReferencedRanges().map((o=>{const i=this.getters.getRangeString(o,e);return{zone:o.zone,color:t(i),sheetId:o.sheetId}}))}getReferencedRanges(){const e=this.getters.getCurrentEditedCell().sheetId;return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,i=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(i.type)||nu.includes(i.value);){if("SPACE"!==i.type||o<1)return!1;o--,i=this.currentTokens[o]}for(o=t+1,i=this.currentTokens[o];i&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type)return!1;o++,i=this.currentTokens[o]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((o=>o.start<=e&&o.end>=e||o.start>=e&&o.start<t))}}),Uw=(new $i).add("evaluation",class extends zE{config;static getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getEvaluatedCellsInZone"];shouldRebuildDependenciesGraph=!0;evaluator;compilationParams;positionsToUpdate=[];constructor(e){super(e),this.config=e,this.compilationParams=this.getCompilationParameters(),this.evaluator=new ZE(e.custom,this.getters)}beforeHandle(e){ts.has(e.type)&&(this.shouldRebuildDependenciesGraph=!0)}handle(e){switch(e.type){case"UPDATE_CELL":if(!("content"in e)&&!("format"in e)||this.shouldRebuildDependenciesGraph)return;this.positionsToUpdate.push(e),"content"in e&&this.evaluator.updateDependencies(e);break;case"EVALUATE_CELLS":this.evaluator.evaluateAllCells();break;case"UPDATE_LOCALE":this.compilationParams=this.getCompilationParameters(),this.evaluator.updateCompilationParameters()}}finalize(){this.shouldRebuildDependenciesGraph?(this.evaluator.buildDependencyGraph(),this.evaluator.evaluateAllCells(),this.shouldRebuildDependenciesGraph=!1):this.positionsToUpdate.length&&this.evaluator.evaluateCells(this.positionsToUpdate),this.positionsToUpdate=[]}evaluateFormula(e,t){const o=Yu(t),i=[];for(let t of o.dependencies)i.push(this.getters.getRangeFromSheetXC(e,t));return o.execute(i,...this.compilationParams).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell(e){return this.evaluator.getEvaluatedCell(e)}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},o={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);o[e]=this.getEvaluatedCell(t)}return o}getEvaluatedCellsInZone(e,t){return fi(t).map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o})))}exportForExcel(e){for(const t of this.evaluator.getEvaluatedPositions()){const o=this.evaluator.getEvaluatedCell(t),i=Tt(t.col,t.row),s=o.value;let r,n,a=!1,l=!0;const c=this.getCorrespondingFormulaCell(t);c&&(l=eg(c.compiledFormula.tokens),a=l,l||(r=s.toString(),n=o.format));const h=e.sheets.find((e=>e.id===t.sheetId)),d=h.cells[i]||{},u=n?We(n,e.formats):d.format,g=l?d.content:r;h.cells[i]={...d,value:s,isFormula:a,content:g,format:u}}}getCorrespondingFormulaCell(e){const t=this.getters.getCell(e);if(t&&t.content)return t.isFormula&&!function(e){try{return Yu(e),!1}catch(e){return!0}}(t.content)?t:void 0;const o=this.evaluator.getArrayFormulaSpreadingOn(e);if(void 0===o)return;const i=this.getters.getCell(o);return i?.isFormula?i:void 0}getCompilationParameters(){return HE(this.config.custom,this.getters,(e=>this.evaluator.getEvaluatedCell(e)))}}).add("evaluation_chart",class extends zE{static getters=["getChartRuntime","getBackgroundOfSingleCellChart"];charts={};createRuntimeChart=function(e){const t=Op.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o){const i=t.find((e=>e.match(o.type)));if(!i)throw new Error("No runtime builder for this chart.");return i.getChartRuntime(o,e)}}(this.getters);handle(e){if((es.has(e.type)||os.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)&&"UNDO"!==e.type&&"REDO"!==e.type)for(const e in this.charts)this.history.update("charts",e,void 0);switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||this.history.update("charts",e,void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.history.update("charts",e,this.createRuntimeChart(t))}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const o=t.zone.left,i=t.zone.top,s=t.sheetId;return this.getters.getCellComputedStyle({sheetId:s,col:o,row:i}).fillColor||w}}).add("evaluation_cf",class extends zE{static getters=["getConditionalIcon","getCellComputedStyle"];isStale=!0;computedStyles={};computedIcons={};handle(e){(os.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0)}finalize(){if(this.isStale){for(const e of this.getters.getSheetIds())this.computedStyles[e]=qe((()=>this.getComputedStyles(e))),this.computedIcons[e]=qe((()=>this.getComputedIcons(e)));this.isStale=!1}}getCellComputedStyle(e){const{sheetId:t,col:o,row:i}=e,s=this.getters.getCell(e),r=this.computedStyles[t](),n=r&&r[o]?.[i],a={...s?.style,...n};return this.getters.getEvaluatedCell(e).link&&!a.textColor&&(a.textColor=I),this.getters.isFilterHeader(e)&&(a.bold=!0),a}getConditionalIcon({sheetId:e,col:t,row:o}){const i=this.computedIcons[e]();return i&&i[t]?.[o]}getComputedStyles(e){const t={};for(let o of this.getters.getConditionalFormats(e).reverse())try{switch(o.rule.type){case"ColorScaleRule":for(let i of o.ranges)this.applyColorScale(e,i,o.rule,t);break;case"CellIsRule":for(let i of o.ranges){const s=this.getters.getRangeFromSheetXC(e,i).zone;for(let i=s.top;i<=s.bottom;i++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let n=this.getters.getEvaluatedCell({sheetId:e,col:r,row:i});s&&s(n,o.rule)&&(t[r]||(t[r]=[]),t[r][i]=Object.assign(t[r]?.[i]||{},o.rule.style))}}}}catch(e){}return t}getComputedIcons(e){const t={};for(let o of this.getters.getConditionalFormats(e).reverse())if("IconSetRule"===o.rule.type)for(let i of o.ranges)this.applyIcon(e,i,o.rule,t);return t}parsePoint(e,t,o,i){const s=this.getters.getEvaluatedCellsInZone(e,this.getters.getRangeFromSheetXC(e,t).zone).filter((e=>e.type===Qi.number)).map((e=>e.value));switch(o.type){case"value":return"max"===i?Math.max(...s):Math.min(...s);case"number":return Number(o.value);case"percentage":const t=Math.min(...s);return t+(Math.max(...s)-t)*Number(o.value)/100;case"percentile":return lo(s,Number(o.value)/100,!0);case"formula":const r=o.value&&this.getters.evaluateFormula(e,o.value);return r instanceof Promise?null:r;default:return null}}applyIcon(e,t,o,i){const s=this.parsePoint(e,t,o.lowerInflectionPoint),r=this.parsePoint(e,t,o.upperInflectionPoint);if(null===s||null===r||s>r)return;const n=this.getters.getRangeFromSheetXC(e,t).zone,a=[o.icons.upper,o.icons.middle,o.icons.lower];for(let t=n.top;t<=n.bottom;t++)for(let l=n.left;l<=n.right;l++){const n=this.getters.getEvaluatedCell({sheetId:e,col:l,row:t});if(n.type!==Qi.number)continue;const c=this.computeIcon(n.value,r,o.upperInflectionPoint.operator,s,o.lowerInflectionPoint.operator,a);i[l]||(i[l]=[]),i[l][t]=c}}computeIcon(e,t,o,i,s,r){return"ge"===o&&e>=t||"gt"===o&&e>t?r[0]:"ge"===s&&e>=i||"gt"===s&&e>i?r[1]:r[2]}applyColorScale(e,t,o,i){const s=this.parsePoint(e,t,o.minimum,"min"),r=o.midpoint?this.parsePoint(e,t,o.midpoint):null,n=this.parsePoint(e,t,o.maximum,"max");if(null===s||null===n||s>=n||r&&(s>=r||r>=n))return;const a=this.getters.getRangeFromSheetXC(e,t).zone,l=[];o.midpoint&&r?(l.push({minValue:s,minColor:o.minimum.color,colorDiffUnit:this.computeColorDiffUnits(s,r,o.minimum.color,o.midpoint.color)}),l.push({minValue:r,minColor:o.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(r,n,o.midpoint.color,o.maximum.color)})):l.push({minValue:s,minColor:o.minimum.color,colorDiffUnit:this.computeColorDiffUnits(s,n,o.minimum.color,o.maximum.color)});for(let t=a.top;t<=a.bottom;t++)for(let o=a.left;o<=a.right;o++){const a=this.getters.getEvaluatedCell({sheetId:e,col:o,row:t});if(a.type===Qi.number){const e=we(a.value,s,n);let c;c=2===l.length&&r?e<=r?this.colorCell(e,l[0].minValue,l[0].minColor,l[0].colorDiffUnit):this.colorCell(e,l[1].minValue,l[1].minColor,l[1].colorDiffUnit):this.colorCell(e,l[0].minValue,l[0].minColor,l[0].colorDiffUnit),i[o]||(i[o]=[]),i[o][t]=i[o]?.[t]||{},i[o][t].fillColor=ct(c)}}}computeColorDiffUnits(e,t,o,i){const s=t-e;return[((o>>16)%256-(i>>16)%256)/s,((o>>8)%256-(i>>8)%256)/s,(o%256-i%256)/s]}colorCell(e,t,o,i){const[s,r,n]=i;return Math.round((o>>16)%256-s*(e-t))<<16|Math.round((o>>8)%256-r*(e-t))<<8|Math.round(o%256-n*(e-t))}rulePredicate={CellIsRule:(e,t)=>{if(e.type===Qi.error)return!1;const o=this.getters.getLocale(),i=t.values.map((e=>qs(e,o)));switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==i[0]&&e.value.toString().startsWith(i[0].toString());case"EndsWith":return""!==i[0]&&e.value.toString().endsWith(i[0].toString());case"Between":return e.value>=i[0]&&e.value<=i[1];case"NotBetween":return!(e.value>=i[0]&&e.value<=i[1]);case"ContainsText":return e.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(i[0].toString());case"GreaterThan":return e.value>i[0];case"GreaterThanOrEqual":return e.value>=i[0];case"LessThan":return e.value<i[0];case"LessThanOrEqual":return e.value<=i[0];case"NotEqual":return""!==i[0]&&e.value!==i[0];case"Equal":return""===i[0]||e.value===i[0];default:console.warn(r("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}).add("custom_colors",class extends zE{customColors={};shouldUpdateColors=!1;static getters=["getCustomColors"];handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":case"SET_BORDER":case"SET_ZONE_BORDERS":case"SET_FORMATTING":this.history.update("shouldUpdateColors",!0)}}finalize(){if(this.shouldUpdateColors){this.history.update("shouldUpdateColors",!1);for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds())e=e.concat(this.getColorsFromCells(t),this.getFormattingColors(t),this.getChartColors(t));return function(e){const t=[{leadColor:gt(255,0,0),colors:[]},{leadColor:gt(255,128,0),colors:[]},{leadColor:gt(128,128,0),colors:[]},{leadColor:gt(128,255,0),colors:[]},{leadColor:gt(0,255,0),colors:[]},{leadColor:gt(0,255,128),colors:[]},{leadColor:gt(0,255,255),colors:[]},{leadColor:gt(0,127,255),colors:[]},{leadColor:gt(0,0,255),colors:[]},{leadColor:gt(127,0,255),colors:[]},{leadColor:gt(128,0,128),colors:[]},{leadColor:gt(255,0,128),colors:[]}];for(const o of e.map(ft)){let e=500,i=0;t.forEach(((t,s)=>{const r=(n=o,a=t.leadColor,Math.sqrt(Math.pow(n.r-a.r,2)+Math.pow(n.g-a.g,2)+Math.pow(n.b-a.b,2)));var n,a;e>r&&(e=r,i=s)})),t[i].colors.push(o)}return t.map((e=>e.colors.sort(((e,t)=>vt(e).s-vt(t).s)))).flat().map(mt)}([...new Set([...new Set([...e,...Object.keys(this.customColors)])].filter(dt).map(ht))]).filter((e=>!M.includes(e)))}getColorsFromCells(e){const t=Object.values(this.getters.getCells(e)),o=new Set;for(const e of t)e.style?.textColor&&o.add(e.style.textColor),e.style?.fillColor&&o.add(e.style.fillColor);for(const t of this.getters.getBordersColors(e))o.add(t);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),o=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(o.push(t.style.textColor),o.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(o.push(ct(t.minimum.color)),o.push(t.midpoint?ct(t.midpoint.color):void 0),o.push(ct(t.maximum.color)))}return o.filter(He)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let o=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&o.add(t),e.type){case"gauge":const t=e.sectionRule.colors;o.add(t.lowerColor),o.add(t.middleColor),o.add(t.upperColor);break;case"scorecard":const i=e;o.add(i.baselineColorDown),o.add(i.baselineColorUp)}}return[...o]}tryToAddColor(e){const t=ht(e);e&&!M.includes(t)&&this.history.update("customColors",t,!0)}}),Vw=new $i;Vw.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,execute:(e,t)=>Xi(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class zw{fileStore;constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}getImageFromUser(){return new Promise(((e,t)=>{const o=document.createElement("input");o.setAttribute("type","file"),o.setAttribute("accept","image/*"),o.addEventListener("change",(async()=>{null===o.files||1!=o.files.length?t():e(o.files[0])})),o.click()}))}getImageOriginalSize(e){return new Promise(((t,o)=>{const i=new Image;i.src=e,i.addEventListener("load",(()=>{const e={width:i.width,height:i.height};t(e)})),i.addEventListener("error",o)}))}}const Bw=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];Di`
1465
1461
  .o-ripple {
1466
1462
  z-index: 1;
1467
1463
  }
1468
- `;class Pw extends t.Component{static template="o-spreadsheet-RippleEffect";rippleRef=t.useRef("ripple");setup(){let e;t.onMounted((()=>{const t=this.rippleRef.el;t&&t.animate&&(e=t.animate(Lw,{duration:this.props.duration,easing:"ease-out"}),e.addEventListener("finish",this.props.onAnimationEnd))})),t.onWillUnmount((()=>{e?.removeEventListener("finish",this.props.onAnimationEnd)}))}get rippleStyle(){const{x:e,y:t,width:o,height:i}=this.props;return Ui({transform:"scale(0)",left:e,top:t,"margin-left":`${-o/2+(this.props.offsetX||0)}px`,"margin-top":`${-i/2+(this.props.offsetY||0)}px`,width:`${o}px`,height:`${i}px`,background:this.props.color,"border-radius":"100%",opacity:`${this.props.opacity}`})}}Pw.props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};class kw extends t.Component{static template="o-spreadsheet-Ripple";static components={RippleEffect:Pw};static defaultProps={color:"#aaaaaa",opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:""};childContainer=t.useRef("childContainer");state=t.useState({ripples:[]});currentId=1;onClick(e){if(!this.props.enabled)return;if(!this.childContainer.el)return;const t=this.getRippleChildRectInfo(),{x:o,y:i,width:s,height:r}=t,n=Math.max(s,r),a={x:e.clientX-o,y:e.clientY-i,width:this.props.width||2.85*n,height:this.props.height||2.85*n};this.state.ripples.push({rippleRect:a,id:this.currentId++})}getRippleStyle(){const e=this.childContainer.el;if(!e||1!==e.childElementCount||!e.firstElementChild)return"";const t=this.getRippleChildRectInfo();return Ui({top:t.marginTop+"px",left:t.marginLeft+"px",width:t.width+"px",height:t.height+"px"})}getRippleChildRectInfo(){const e=this.childContainer.el;if(!e)throw new Error("No child container element found");if(1!==e.childElementCount||!e.firstElementChild){return{...pr(e),marginLeft:0,marginTop:0}}const t=e.firstElementChild,o=function(e){const t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}(t);return{...pr(t),marginLeft:o.left,marginTop:o.top}}removeRipple(e){const t=this.state.ripples.findIndex((t=>t.id===e));-1!==t&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){const t=this.state.ripples.find((t=>t.id===e))?.rippleRect;if(!t)throw new Error("Cannot find a ripple with the id "+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?"50%":t.x+"px",y:this.props.ignoreClickPosition?"50%":t.y+"px",width:t.width,height:t.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}}kw.props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}},Di`
1464
+ `;class Hw extends t.Component{static template="o-spreadsheet-RippleEffect";rippleRef=t.useRef("ripple");setup(){let e;t.onMounted((()=>{const t=this.rippleRef.el;t&&t.animate&&(e=t.animate(Bw,{duration:this.props.duration,easing:"ease-out"}),e.addEventListener("finish",this.props.onAnimationEnd))})),t.onWillUnmount((()=>{e?.removeEventListener("finish",this.props.onAnimationEnd)}))}get rippleStyle(){const{x:e,y:t,width:o,height:i}=this.props;return Ui({transform:"scale(0)",left:e,top:t,"margin-left":`${-o/2+(this.props.offsetX||0)}px`,"margin-top":`${-i/2+(this.props.offsetY||0)}px`,width:`${o}px`,height:`${i}px`,background:this.props.color,"border-radius":"100%",opacity:`${this.props.opacity}`})}}Hw.props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};class $w extends t.Component{static template="o-spreadsheet-Ripple";static components={RippleEffect:Hw};static defaultProps={color:"#aaaaaa",opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:""};childContainer=t.useRef("childContainer");state=t.useState({ripples:[]});currentId=1;onClick(e){if(!this.props.enabled)return;if(!this.childContainer.el)return;const t=this.getRippleChildRectInfo(),{x:o,y:i,width:s,height:r}=t,n=Math.max(s,r),a={x:e.clientX-o,y:e.clientY-i,width:this.props.width||2.85*n,height:this.props.height||2.85*n};this.state.ripples.push({rippleRect:a,id:this.currentId++})}getRippleStyle(){const e=this.childContainer.el;if(!e||1!==e.childElementCount||!e.firstElementChild)return"";const t=this.getRippleChildRectInfo();return Ui({top:t.marginTop+"px",left:t.marginLeft+"px",width:t.width+"px",height:t.height+"px"})}getRippleChildRectInfo(){const e=this.childContainer.el;if(!e)throw new Error("No child container element found");if(1!==e.childElementCount||!e.firstElementChild){return{...pr(e),marginLeft:0,marginTop:0}}const t=e.firstElementChild,o=function(e){const t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}(t);return{...pr(t),marginLeft:o.left,marginTop:o.top}}removeRipple(e){const t=this.state.ripples.findIndex((t=>t.id===e));-1!==t&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){const t=this.state.ripples.find((t=>t.id===e))?.rippleRect;if(!t)throw new Error("Cannot find a ripple with the id "+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?"50%":t.x+"px",y:this.props.ignoreClickPosition?"50%":t.y+"px",width:t.width,height:t.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}}$w.props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}},Di`
1469
1465
  .o-sheet {
1470
1466
  padding: 0 15px;
1471
1467
  padding-right: 10px;
@@ -1505,7 +1501,7 @@
1505
1501
  }
1506
1502
  }
1507
1503
  }
1508
- `;class Uw extends t.Component{static template="o-spreadsheet-BottomBarSheet";static components={Ripple:kw};static defaultProps={onMouseDown:()=>{},style:""};state=t.useState({isEditing:!1});sheetDivRef=t.useRef("sheetDiv");sheetNameRef=t.useRef("sheetNameSpan");editionState="initializing";setup(){t.onMounted((()=>{this.isSheetActive&&this.scrollToSheet()})),t.onPatched((()=>{this.sheetNameRef.el&&this.state.isEditing&&"initializing"===this.editionState&&(this.editionState="editing",this.focusInputAndSelectContent())}))}focusInputAndSelectContent(){if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();const e=window.getSelection();e&&this.sheetNameRef.el.firstChild&&e.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,this.sheetNameRef.el.textContent?.length||0)}scrollToSheet(){this.sheetDivRef.el?.scrollIntoView?.()}onFocusOut(){this.state.isEditing&&"initializing"!==this.editionState&&this.stopEdition()}onMouseDown(e){this.activateSheet(),this.props.onMouseDown(e)}activateSheet(){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.startEdition()}onKeyDown(e){this.state.isEditing&&("Enter"===e.key&&(e.preventDefault(),this.stopEdition()),"Escape"===e.key&&this.cancelEdition())}onClickSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState="initializing"}stopEdition(){if(!this.state.isEditing)return;this.state.isEditing=!1,this.editionState="initializing",this.sheetNameRef.el?.blur();const e=this.getInputContent()||"";!function(e,t,o,i){const s=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:o});s.reasons.includes(10)?e.raiseError(r("The sheet name cannot be empty."),i):s.reasons.includes(12)?e.raiseError(r("A sheet with the name %s already exists. Please select another name.",o),i):s.reasons.includes(14)&&e.raiseError(r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ae.join(" ")),i)}(this.env,this.props.sheetId,e,(()=>this.startEdition()))}cancelEdition(){this.state.isEditing=!1,this.editionState="initializing",this.sheetNameRef.el?.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){return this.sheetNameRef.el?.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}get contextMenuRegistry(){return function(e){const t=new mg;return t.add("delete",{...ng,sequence:10}).add("duplicate",{...ag,sequence:20}).add("rename",{...lg(e),sequence:30}).add("move_right",{...cg,sequence:40}).add("move_left",{...hg,sequence:50}).add("hide_sheet",{...dg,sequence:60}),t}({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}}Uw.props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}},Di`
1504
+ `;class Ww extends t.Component{static template="o-spreadsheet-BottomBarSheet";static components={Ripple:$w};static defaultProps={onMouseDown:()=>{},style:""};state=t.useState({isEditing:!1});sheetDivRef=t.useRef("sheetDiv");sheetNameRef=t.useRef("sheetNameSpan");editionState="initializing";setup(){t.onMounted((()=>{this.isSheetActive&&this.scrollToSheet()})),t.onPatched((()=>{this.sheetNameRef.el&&this.state.isEditing&&"initializing"===this.editionState&&(this.editionState="editing",this.focusInputAndSelectContent())}))}focusInputAndSelectContent(){if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();const e=window.getSelection();e&&this.sheetNameRef.el.firstChild&&e.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,this.sheetNameRef.el.textContent?.length||0)}scrollToSheet(){this.sheetDivRef.el?.scrollIntoView?.()}onFocusOut(){this.state.isEditing&&"initializing"!==this.editionState&&this.stopEdition()}onMouseDown(e){this.activateSheet(),this.props.onMouseDown(e)}activateSheet(){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.startEdition()}onKeyDown(e){this.state.isEditing&&("Enter"===e.key&&(e.preventDefault(),this.stopEdition()),"Escape"===e.key&&this.cancelEdition())}onClickSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState="initializing"}stopEdition(){if(!this.state.isEditing)return;this.state.isEditing=!1,this.editionState="initializing",this.sheetNameRef.el?.blur();const e=this.getInputContent()||"";!function(e,t,o,i){const s=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:o});s.reasons.includes(10)?e.raiseError(r("The sheet name cannot be empty."),i):s.reasons.includes(12)?e.raiseError(r("A sheet with the name %s already exists. Please select another name.",o),i):s.reasons.includes(14)&&e.raiseError(r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ae.join(" ")),i)}(this.env,this.props.sheetId,e,(()=>this.startEdition()))}cancelEdition(){this.state.isEditing=!1,this.editionState="initializing",this.sheetNameRef.el?.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){return this.sheetNameRef.el?.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}get contextMenuRegistry(){return function(e){const t=new Eg;return t.add("delete",{...ug,sequence:10}).add("duplicate",{...gg,sequence:20}).add("rename",{...pg(e),sequence:30}).add("move_right",{...mg,sequence:40}).add("move_left",{...fg,sequence:50}).add("hide_sheet",{...bg,sequence:60}),t}({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}}Ww.props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}},Di`
1509
1505
  .o-selection-statistic {
1510
1506
  margin-right: 20px;
1511
1507
  padding: 4px 4px 4px 8px;
@@ -1515,7 +1511,7 @@
1515
1511
  background-color: rgba(0, 0, 0, 0.08) !important;
1516
1512
  }
1517
1513
  }
1518
- `;class Vw extends t.Component{static template="o-spreadsheet-BottomBarStatisic";static components={Ripple:kw};selectedStatisticFn="";statisticFnResults={};setup(){this.statisticFnResults=this.env.model.getters.getStatisticFnResults(),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getStatisticFnResults();Ye(e,this.statisticFnResults)||this.props.closeContextMenu(),this.statisticFnResults=e}))}getSelectedStatistic(){if(!Object.values(this.statisticFnResults).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(this.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn,this.statisticFnResults[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new mg;let o=0;for(let[e,i]of Object.entries(this.statisticFnResults))t.add(e,{name:this.getComposedFnName(e,i),sequence:o,isReadonlyAllowed:!0,execute:()=>{this.selectedStatisticFn=e}}),o++;const i=e.currentTarget,{top:s,left:r,width:n}=i.getBoundingClientRect();this.props.openContextMenu(r+n,s,t)}getComposedFnName(e,t){const o=this.env.model.getters.getLocale();return e+": "+(void 0!==t?vo(t,{locale:o}):"__")}}Vw.props={openContextMenu:Function,closeContextMenu:Function};class zw{draggedItemId;items;containerEl;initialMousePosition;currentMousePosition;minPosition;maxPosition;edgeScrollIntervalId;edgeScrollOffset=0;onChange;onCancel;onDragEnd;deadZone;constructor(e){this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.containerEl=e.containerEl,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.mouseX,this.currentMousePosition=e.mouseX,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size,Db(this.onMouseMove.bind(this),this.onMouseUp.bind(this))}onMouseMove(e){if(0!==e.button)return void this.onCancel();const t=e.clientX;t<this.containerRect.left||t>this.containerRect.right?this.startEdgeScroll(t<this.containerRect.left?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.edgeScrollOffset))}moveDraggedItemToPosition(e){this.currentMousePosition=e;const t=this.getHoveredItemIndex(e,this.items),o=this.items.findIndex((e=>e.id===this.draggedItemId)),i=this.items[o];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:i.position,end:i.position+i.size})&&(this.deadZone=void 0),o===t)return void this.onChange(this.getItemsPositions());const s=Math.min(o,t),r=Math.max(o,t),n=Math.sign(t-o);let a=0;for(let e=s;e<=r;e++)e!==o&&(this.items[e].position-=n*i.size,a+=this.items[e].size);i.position+=n*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=n>0?{start:e,end:i.position}:{start:i.position+i.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel();const t=this.items.findIndex((e=>e.id===this.draggedItemId));this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll()}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let o=this.currentMousePosition+t;o<this.minPosition?o=this.minPosition:o>this.maxPosition&&(o=this.maxPosition),this.edgeScrollOffset+=o-this.currentMousePosition,this.moveDraggedItemToPosition(o),this.containerEl.scrollLeft+=t}),5))}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex((t=>t.position+t.size>=e))}getItemsPositions(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let o=this.currentMousePosition-this.initialMousePosition;o=Math.max(this.minPosition-t.positionAtStart,o),o=Math.min(this.maxPosition-t.positionAtStart-t.size,o),e[t.id]=o}return e}get containerRect(){return this.containerEl.getBoundingClientRect()}isInZone(e,t){return e>=t.start&&e<=t.end}destroy(){this.stopEdgeScroll()}}Di`
1514
+ `;class Gw extends t.Component{static template="o-spreadsheet-BottomBarStatisic";static components={Ripple:$w};selectedStatisticFn="";statisticFnResults={};setup(){this.statisticFnResults=this.env.model.getters.getStatisticFnResults(),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getStatisticFnResults();Ye(e,this.statisticFnResults)||this.props.closeContextMenu(),this.statisticFnResults=e}))}getSelectedStatistic(){if(!Object.values(this.statisticFnResults).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(this.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn,this.statisticFnResults[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new Eg;let o=0;for(let[e,i]of Object.entries(this.statisticFnResults))t.add(e,{name:this.getComposedFnName(e,i),sequence:o,isReadonlyAllowed:!0,execute:()=>{this.selectedStatisticFn=e}}),o++;const i=e.currentTarget,{top:s,left:r,width:n}=i.getBoundingClientRect();this.props.openContextMenu(r+n,s,t)}getComposedFnName(e,t){const o=this.env.model.getters.getLocale();return e+": "+(void 0!==t?vo(t,{locale:o}):"__")}}Gw.props={openContextMenu:Function,closeContextMenu:Function};class qw{draggedItemId;items;containerEl;initialMousePosition;currentMousePosition;minPosition;maxPosition;edgeScrollIntervalId;edgeScrollOffset=0;onChange;onCancel;onDragEnd;deadZone;constructor(e){this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.containerEl=e.containerEl,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.mouseX,this.currentMousePosition=e.mouseX,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size,zb(this.onMouseMove.bind(this),this.onMouseUp.bind(this))}onMouseMove(e){if(0!==e.button)return void this.onCancel();const t=e.clientX;t<this.containerRect.left||t>this.containerRect.right?this.startEdgeScroll(t<this.containerRect.left?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.edgeScrollOffset))}moveDraggedItemToPosition(e){this.currentMousePosition=e;const t=this.getHoveredItemIndex(e,this.items),o=this.items.findIndex((e=>e.id===this.draggedItemId)),i=this.items[o];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:i.position,end:i.position+i.size})&&(this.deadZone=void 0),o===t)return void this.onChange(this.getItemsPositions());const s=Math.min(o,t),r=Math.max(o,t),n=Math.sign(t-o);let a=0;for(let e=s;e<=r;e++)e!==o&&(this.items[e].position-=n*i.size,a+=this.items[e].size);i.position+=n*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=n>0?{start:e,end:i.position}:{start:i.position+i.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel();const t=this.items.findIndex((e=>e.id===this.draggedItemId));this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll()}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let o=this.currentMousePosition+t;o<this.minPosition?o=this.minPosition:o>this.maxPosition&&(o=this.maxPosition),this.edgeScrollOffset+=o-this.currentMousePosition,this.moveDraggedItemToPosition(o),this.containerEl.scrollLeft+=t}),5))}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex((t=>t.position+t.size>=e))}getItemsPositions(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let o=this.currentMousePosition-this.initialMousePosition;o=Math.max(this.minPosition-t.positionAtStart,o),o=Math.min(this.maxPosition-t.positionAtStart-t.size,o),e[t.id]=o}return e}get containerRect(){return this.containerEl.getBoundingClientRect()}isInZone(e,t){return e>=t.start&&e<=t.end}destroy(){this.stopEdgeScroll()}}Di`
1519
1515
  .o-spreadsheet-bottom-bar {
1520
1516
  color: ${C};
1521
1517
  background-color: ${f};
@@ -1557,12 +1553,12 @@
1557
1553
  }
1558
1554
  }
1559
1555
  }
1560
- `;class Bw extends t.Component{static template="o-spreadsheet-BottomBar";static components={Menu:Ir,Ripple:kw,BottomBarSheet:Uw,BottomBarStatistic:Vw};bottomBarRef=t.useRef("bottomBar");sheetListRef=t.useRef("sheetList");dndHelper;targetScroll=void 0;state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1});menuMaxHeight=250;menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]});sheetState=t.useState({sheetList:this.getVisibleSheets(),isDnd:!1,sheetDndPositions:void 0});setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();this.sheetState.isDnd&&!Ye(this.sheetState.sheetList,e)&&this.stopDragging(),this.sheetState.sheetList=e})),t.onWillUnmount((()=>{this.dndHelper?.destroy()}))}isDragged(e){return this.sheetState.isDnd&&this.dndHelper?.draggedItemId===e}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+1,i=this.env.model.uuidGenerator.uuidv4(),s=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:i,position:o,name:s}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}getSheets(){return this.sheetState.sheetList}clickListSheets(e){const t=new mg,o=this.env.model.getters.getActiveSheetId();let i=0;for(const e of this.env.model.getters.getSheetIds()){const s=this.env.model.getters.getSheet(e);t.add(e,{name:s.name,sequence:i,isReadonlyAllowed:!0,textColor:s.isVisible?void 0:"grey",execute:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:e})}}),i++}const s=e.currentTarget,{left:r}=s.getBoundingClientRect(),n=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(r,n,"listSheets",t)}openContextMenu(e,t,o,i){this.menuState.isOpen=!0,this.menuState.menuId=o,this.menuState.menuItems=i.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,o){const i=o.currentTarget,{top:s,left:r}=i.getBoundingClientRect();o.closedMenuId!==e?this.openContextMenu(r,s,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button)return;this.closeMenu();const o=t.clientX;document.body.style.cursor="move";const i=this.getVisibleSheets(),s=this.getSheetItemRects(),r=i.map(((e,t)=>({id:e.id,size:s[t].width,position:s[t].x})));this.dndHelper=new zw({draggedItemId:e,mouseX:o,items:r,containerEl:this.sheetListRef.el,onChange:e=>{this.sheetState.isDnd=!0,this.sheetState.sheetDndPositions=e},onCancel:()=>this.stopDragging(),onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const o=t-this.sheetState.sheetList.findIndex((t=>t.id===e));e&&0!==o&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:o}),this.stopDragging()}getSheetStyle(e){const t={};return this.sheetState.isDnd&&(t.position="relative",t.left=(this.sheetState.sheetDndPositions?.[e]||0)+"px",t.transition="left 0.5s",t.cursor="move"),this.isDragged(e)&&(t.transition="left 0s",t["z-index"]="1000"),Ui(t)}stopDragging(){document.body.style.cursor="",this.sheetState.sheetList=this.getVisibleSheets(),this.sheetState.isDnd=!1,this.sheetState.sheetDndPositions=void 0,this.dndHelper=void 0}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}getSheetClasses(e){let t="";return this.isDragged(e)&&(t+="dragged "),this.sheetState.isDnd&&(t+="dragging "),t}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}Bw.props={onClick:Function},Di`
1556
+ `;class Zw extends t.Component{static template="o-spreadsheet-BottomBar";static components={Menu:Ir,Ripple:$w,BottomBarSheet:Ww,BottomBarStatistic:Gw};bottomBarRef=t.useRef("bottomBar");sheetListRef=t.useRef("sheetList");dndHelper;targetScroll=void 0;state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1});menuMaxHeight=250;menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]});sheetState=t.useState({sheetList:this.getVisibleSheets(),isDnd:!1,sheetDndPositions:void 0});setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();this.sheetState.isDnd&&!Ye(this.sheetState.sheetList,e)&&this.stopDragging(),this.sheetState.sheetList=e})),t.onWillUnmount((()=>{this.dndHelper?.destroy()}))}isDragged(e){return this.sheetState.isDnd&&this.dndHelper?.draggedItemId===e}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+1,i=this.env.model.uuidGenerator.uuidv4(),s=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:i,position:o,name:s}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}getSheets(){return this.sheetState.sheetList}clickListSheets(e){const t=new Eg,o=this.env.model.getters.getActiveSheetId();let i=0;for(const e of this.env.model.getters.getSheetIds()){const s=this.env.model.getters.getSheet(e);t.add(e,{name:s.name,sequence:i,isReadonlyAllowed:!0,textColor:s.isVisible?void 0:"grey",execute:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:e})}}),i++}const s=e.currentTarget,{left:r}=s.getBoundingClientRect(),n=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(r,n,"listSheets",t)}openContextMenu(e,t,o,i){this.menuState.isOpen=!0,this.menuState.menuId=o,this.menuState.menuItems=i.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,o){const i=o.currentTarget,{top:s,left:r}=i.getBoundingClientRect();o.closedMenuId!==e?this.openContextMenu(r,s,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button)return;this.closeMenu();const o=t.clientX;document.body.style.cursor="move";const i=this.getVisibleSheets(),s=this.getSheetItemRects(),r=i.map(((e,t)=>({id:e.id,size:s[t].width,position:s[t].x})));this.dndHelper=new qw({draggedItemId:e,mouseX:o,items:r,containerEl:this.sheetListRef.el,onChange:e=>{this.sheetState.isDnd=!0,this.sheetState.sheetDndPositions=e},onCancel:()=>this.stopDragging(),onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const o=t-this.sheetState.sheetList.findIndex((t=>t.id===e));e&&0!==o&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:o}),this.stopDragging()}getSheetStyle(e){const t={};return this.sheetState.isDnd&&(t.position="relative",t.left=(this.sheetState.sheetDndPositions?.[e]||0)+"px",t.transition="left 0.5s",t.cursor="move"),this.isDragged(e)&&(t.transition="left 0s",t["z-index"]="1000"),Ui(t)}stopDragging(){document.body.style.cursor="",this.sheetState.sheetList=this.getVisibleSheets(),this.sheetState.isDnd=!1,this.sheetState.sheetDndPositions=void 0,this.dndHelper=void 0}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}getSheetClasses(e){let t="";return this.isDragged(e)&&(t+="dragged "),this.sheetState.isDnd&&(t+="dragging "),t}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}Zw.props={onClick:Function},Di`
1561
1557
  .o-dashboard-clickable-cell {
1562
1558
  position: absolute;
1563
1559
  cursor: pointer;
1564
1560
  }
1565
- `;let Hw=1;class $w extends t.Component{static template="o-spreadsheet-SpreadsheetDashboard";static components={GridOverlay:Vv,GridPopover:zv,Popover:Er,VerticalScrollBar:Jv,HorizontalScrollBar:Qv,FilterIconsOverlay:Rv};onMouseWheel;canvasPosition;hoveredCell;setup(){const e=t.useRef("grid");this.canvasPosition=br(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),Gv("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=qv(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:o}=this.env.model.getters.getColDimensions(e,t);return Ui({"max-width":`${o}px`})}get gridOverlayDimensions(){return Ui({height:"100%",width:"100%"})}getCellClickableStyle(e){return Ui({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const o of this.env.model.getters.getSheetViewVisibleCols())for(const i of this.env.model.getters.getSheetViewVisibleRows()){const s={sheetId:t,col:o,row:i},r=this.getClickableAction(s);if(!r)continue;let n;n=this.env.model.getters.isInMerge(s)?this.env.model.getters.getMerge(s):Ei({col:o,row:i});const a=this.env.model.getters.getVisibleRect(n);e.push({coordinates:a,position:{col:o,row:i},action:r,tKey:`${Hw}-${o}-${i}`})}return Hw++,e}getClickableAction(e){for(const t of Fw.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.execute;return!1}selectClickableCell(e){const{position:t,action:o}=e;o({...t,sheetId:this.env.model.getters.getActiveSheetId()},this.env)}onClosePopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){const{scrollX:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}}$w.props={},Di`
1561
+ `;let jw=1;class Yw extends t.Component{static template="o-spreadsheet-SpreadsheetDashboard";static components={GridOverlay:Gv,GridPopover:qv,Popover:Er,VerticalScrollBar:rS,HorizontalScrollBar:sS,FilterIconsOverlay:_v};onMouseWheel;canvasPosition;hoveredCell;setup(){const e=t.useRef("grid");this.canvasPosition=br(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),Kv("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=Qv(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:o}=this.env.model.getters.getColDimensions(e,t);return Ui({"max-width":`${o}px`})}get gridOverlayDimensions(){return Ui({height:"100%",width:"100%"})}getCellClickableStyle(e){return Ui({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const o of this.env.model.getters.getSheetViewVisibleCols())for(const i of this.env.model.getters.getSheetViewVisibleRows()){const s={sheetId:t,col:o,row:i},r=this.getClickableAction(s);if(!r)continue;let n;n=this.env.model.getters.isInMerge(s)?this.env.model.getters.getMerge(s):Ei({col:o,row:i});const a=this.env.model.getters.getVisibleRect(n);e.push({coordinates:a,position:{col:o,row:i},action:r,tKey:`${jw}-${o}-${i}`})}return jw++,e}getClickableAction(e){for(const t of Vw.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.execute;return!1}selectClickableCell(e){const{position:t,action:o}=e;o({...t,sheetId:this.env.model.getters.getActiveSheetId()},this.env)}onClosePopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){const{scrollX:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}}Yw.props={},Di`
1566
1562
  .o-sidePanel {
1567
1563
  display: flex;
1568
1564
  flex-direction: column;
@@ -1731,7 +1727,7 @@
1731
1727
  }
1732
1728
  }
1733
1729
  }
1734
- `;class Ww extends t.Component{static template="o-spreadsheet-SidePanel";state;setup(){this.state=t.useState({panel:rv.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=rv.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}Ww.props={component:String,panelProps:{type:Object,optional:!0},onCloseSidePanel:Function},Di`
1730
+ `;class Xw extends t.Component{static template="o-spreadsheet-SidePanel";state;setup(){this.state=t.useState({panel:dv.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=dv.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}Xw.props={component:String,panelProps:{type:Object,optional:!0},onCloseSidePanel:Function},Di`
1735
1731
  .o-menu-item-button {
1736
1732
  display: flex;
1737
1733
  justify-content: center;
@@ -1744,7 +1740,7 @@
1744
1740
  opacity: 0.6;
1745
1741
  cursor: default;
1746
1742
  }
1747
- `;class Gw extends t.Component{static template="o-spreadsheet-ActionButton";actionButton=pg(this.props.action);setup(){t.onWillUpdateProps((()=>this.actionButton=pg(this.props.action)))}get isVisible(){return this.actionButton.isVisible(this.env)}get isEnabled(){return this.actionButton.isEnabled(this.env)}get isActive(){return this.actionButton.isActive?.(this.env)}get title(){const e=this.actionButton.name(this.env),t=this.actionButton.description;return e+(t?` (${t})`:"")}get iconTitle(){return this.actionButton.icon}onClick(e){this.isEnabled&&(this.props.onClick?.(e),this.actionButton.execute?.(this.env))}get buttonStyle(){return this.props.selectedColor?Ui({"border-bottom":`4px solid ${this.props.selectedColor}`,height:"16px","margin-top":"2px"}):""}}Gw.props={action:Object,hasTriangleDownIcon:{type:Boolean,optional:!0},selectedColor:{type:String,optional:!0},class:{type:String,optional:!0},onClick:{type:Function,optional:!0}};const qw=[[["all","o-spreadsheet-Icon.BORDERS"],["hv","o-spreadsheet-Icon.BORDER_HV"],["h","o-spreadsheet-Icon.BORDER_H"],["v","o-spreadsheet-Icon.BORDER_V"],["external","o-spreadsheet-Icon.BORDER_EXTERNAL"]],[["left","o-spreadsheet-Icon.BORDER_LEFT"],["top","o-spreadsheet-Icon.BORDER_TOP"],["right","o-spreadsheet-Icon.BORDER_RIGHT"],["bottom","o-spreadsheet-Icon.BORDER_BOTTOM"],["clear","o-spreadsheet-Icon.BORDER_CLEAR"]]];Di`
1743
+ `;class Kw extends t.Component{static template="o-spreadsheet-ActionButton";actionButton=Cg(this.props.action);setup(){t.onWillUpdateProps((()=>this.actionButton=Cg(this.props.action)))}get isVisible(){return this.actionButton.isVisible(this.env)}get isEnabled(){return this.actionButton.isEnabled(this.env)}get isActive(){return this.actionButton.isActive?.(this.env)}get title(){const e=this.actionButton.name(this.env),t=this.actionButton.description;return e+(t?` (${t})`:"")}get iconTitle(){return this.actionButton.icon}onClick(e){this.isEnabled&&(this.props.onClick?.(e),this.actionButton.execute?.(this.env))}get buttonStyle(){return this.props.selectedColor?Ui({"border-bottom":`4px solid ${this.props.selectedColor}`,height:"16px","margin-top":"2px"}):""}}Kw.props={action:Object,hasTriangleDownIcon:{type:Boolean,optional:!0},selectedColor:{type:String,optional:!0},class:{type:String,optional:!0},onClick:{type:Function,optional:!0}};const Qw=[[["all","o-spreadsheet-Icon.BORDERS"],["hv","o-spreadsheet-Icon.BORDER_HV"],["h","o-spreadsheet-Icon.BORDER_H"],["v","o-spreadsheet-Icon.BORDER_V"],["external","o-spreadsheet-Icon.BORDER_EXTERNAL"]],[["left","o-spreadsheet-Icon.BORDER_LEFT"],["top","o-spreadsheet-Icon.BORDER_TOP"],["right","o-spreadsheet-Icon.BORDER_RIGHT"],["bottom","o-spreadsheet-Icon.BORDER_BOTTOM"],["clear","o-spreadsheet-Icon.BORDER_CLEAR"]]];Di`
1748
1744
  .o-border-selector {
1749
1745
  padding: 4px;
1750
1746
  }
@@ -1811,7 +1807,7 @@
1811
1807
  margin: 5px 0px 0px 0px !important;
1812
1808
  height: 25px !important;
1813
1809
  }
1814
- `;class Zw extends t.Component{static template="o-spreadsheet-BorderEditor";static components={ColorPickerWidget:Vb,Popover:Er};BORDER_POSITIONS=qw;lineStyleButtonRef=t.useRef("lineStyleButton");borderStyles=ls;state=t.useState({activeTool:void 0});toggleDropdownTool(e){const t=this.state.activeTool===e;this.state.activeTool=t?void 0:e}closeDropdown(){this.state.activeTool=void 0}setBorderPosition(e){this.props.onBorderPositionPicked(e),this.closeDropdown()}setBorderColor(e){this.props.onBorderColorPicked(e),this.closeDropdown()}setBorderStyle(e){this.props.onBorderStylePicked(e),this.closeDropdown()}get lineStylePickerPopoverProps(){return{anchorRect:this.lineStylePickerAnchorRect,positioning:"BottomLeft",verticalOffset:0}}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}get lineStylePickerAnchorRect(){const e=this.lineStyleButtonRef.el;if(null===e)return{x:0,y:0,width:0,height:0};const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}}Zw.props={class:{type:String,optional:!0},currentBorderColor:{type:String,optional:!1},currentBorderStyle:{type:String,optional:!1},currentBorderPosition:{type:String,optional:!0},onBorderColorPicked:Function,onBorderStylePicked:Function,onBorderPositionPicked:Function,maxHeight:{type:Number,optional:!0},anchorRect:Object};class jw extends t.Component{static template="o-spreadsheet-BorderEditorWidget";static components={BorderEditor:Zw};borderEditorButtonRef=t.useRef("borderEditorButton");state=t.useState({currentColor:X,currentStyle:Y,currentPosition:void 0});get borderEditorAnchorRect(){const e=this.borderEditorButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}onBorderPositionPicked(e){this.state.currentPosition=e,this.updateBorder()}onBorderColorPicked(e){this.state.currentColor=e,this.updateBorder()}onBorderStylePicked(e){this.state.currentStyle=e,this.updateBorder()}updateBorder(){void 0!==this.state.currentPosition&&this.env.model.dispatch("SET_ZONE_BORDERS",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:{position:this.state.currentPosition,color:this.state.currentColor,style:this.state.currentStyle}})}}jw.props={toggleBorderEditor:Function,showBorderEditor:Boolean,disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};Di`
1810
+ `;class Jw extends t.Component{static template="o-spreadsheet-BorderEditor";static components={ColorPickerWidget:Gb,Popover:Er};BORDER_POSITIONS=Qw;lineStyleButtonRef=t.useRef("lineStyleButton");borderStyles=ls;state=t.useState({activeTool:void 0});toggleDropdownTool(e){const t=this.state.activeTool===e;this.state.activeTool=t?void 0:e}closeDropdown(){this.state.activeTool=void 0}setBorderPosition(e){this.props.onBorderPositionPicked(e),this.closeDropdown()}setBorderColor(e){this.props.onBorderColorPicked(e),this.closeDropdown()}setBorderStyle(e){this.props.onBorderStylePicked(e),this.closeDropdown()}get lineStylePickerPopoverProps(){return{anchorRect:this.lineStylePickerAnchorRect,positioning:"BottomLeft",verticalOffset:0}}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}get lineStylePickerAnchorRect(){const e=this.lineStyleButtonRef.el;if(null===e)return{x:0,y:0,width:0,height:0};const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}}Jw.props={class:{type:String,optional:!0},currentBorderColor:{type:String,optional:!1},currentBorderStyle:{type:String,optional:!1},currentBorderPosition:{type:String,optional:!0},onBorderColorPicked:Function,onBorderStylePicked:Function,onBorderPositionPicked:Function,maxHeight:{type:Number,optional:!0},anchorRect:Object};class ey extends t.Component{static template="o-spreadsheet-BorderEditorWidget";static components={BorderEditor:Jw};borderEditorButtonRef=t.useRef("borderEditorButton");state=t.useState({currentColor:X,currentStyle:Y,currentPosition:void 0});get borderEditorAnchorRect(){const e=this.borderEditorButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}onBorderPositionPicked(e){this.state.currentPosition=e,this.updateBorder()}onBorderColorPicked(e){this.state.currentColor=e,this.updateBorder()}onBorderStylePicked(e){this.state.currentStyle=e,this.updateBorder()}updateBorder(){void 0!==this.state.currentPosition&&this.env.model.dispatch("SET_ZONE_BORDERS",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:{position:this.state.currentPosition,color:this.state.currentColor,style:this.state.currentStyle}})}}ey.props={toggleBorderEditor:Function,showBorderEditor:Boolean,disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};Di`
1815
1811
  .o-topbar-composer {
1816
1812
  height: fit-content;
1817
1813
  margin-top: -1px;
@@ -1824,7 +1820,11 @@
1824
1820
  top: 20%;
1825
1821
  }
1826
1822
  }
1827
- `;class Yw extends t.Component{static template="o-spreadsheet-TopBarComposer";static components={Composer:Cv};get composerStyle(){const e={padding:"5px 0px 5px 8px","max-height":"100px","line-height":"24px"};return e.height="inactive"===this.props.focus?"34px":"fit-content",Ui(e)}get containerStyle(){return"inactive"===this.props.focus?Ui({"border-color":O,"border-right":"none"}):Ui({"border-color":E})}}Yw.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function},Di`
1823
+
1824
+ .user-select-text {
1825
+ user-select: text;
1826
+ }
1827
+ `;class ty extends t.Component{static template="o-spreadsheet-TopBarComposer";static components={Composer:Rv};get composerStyle(){const e={padding:"5px 0px 5px 8px","max-height":"100px","line-height":"24px"};return e.height="inactive"===this.props.focus?"34px":"fit-content",Ui(e)}get containerStyle(){return"inactive"===this.props.focus?Ui({"border-color":O,"border-right":"none"}):Ui({"border-color":E})}}ty.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function},Di`
1828
1828
  .o-font-size-editor {
1829
1829
  height: calc(100% - 4px);
1830
1830
  input.o-font-size {
@@ -1848,7 +1848,7 @@
1848
1848
  background-color: rgba(0, 0, 0, 0.08);
1849
1849
  }
1850
1850
  }
1851
- `;class Xw extends t.Component{static template="o-spreadsheet-FontSizeEditor";static components={};fontSizes=me;dropdown=t.useState({isOpen:!1});inputRef=t.useRef("inputFontSize");rootEditorRef=t.useRef("FontSizeEditor");setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0})}onExternalClick(e){ur(this.rootEditorRef.el,e)||this.closeFontList()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||q}toggleFontList(){this.dropdown.isOpen?this.closeFontList():(this.props.onToggle(),this.inputRef.el.focus())}closeFontList(){this.dropdown.isOpen=!1}setSize(e){const t=we(Math.floor(parseFloat(e)),1,400);Wp(this.env,{fontSize:t}),this.closeFontList()}setSizeFromInput(e){this.setSize(e.target.value)}setSizeFromList(e){this.setSize(e)}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if("Enter"===e.key||"Escape"===e.key){this.closeFontList();const t=e.target;"Escape"===e.key&&(t.value=`${this.currentFontSize}`),this.props.onToggle()}}}Xw.props={onToggle:Function,dropdownStyle:String,class:String},Di`
1851
+ `;class oy extends t.Component{static template="o-spreadsheet-FontSizeEditor";static components={};fontSizes=me;dropdown=t.useState({isOpen:!1});inputRef=t.useRef("inputFontSize");rootEditorRef=t.useRef("FontSizeEditor");setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0})}onExternalClick(e){ur(this.rootEditorRef.el,e)||this.closeFontList()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||q}toggleFontList(){this.dropdown.isOpen?this.closeFontList():(this.props.onToggle(),this.inputRef.el.focus())}closeFontList(){this.dropdown.isOpen=!1}setSize(e){const t=we(Math.floor(parseFloat(e)),1,400);Xp(this.env,{fontSize:t}),this.closeFontList()}setSizeFromInput(e){this.setSize(e.target.value)}setSizeFromList(e){this.setSize(e)}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if("Enter"===e.key||"Escape"===e.key){this.closeFontList();const t=e.target;"Escape"===e.key&&(t.value=`${this.currentFontSize}`),this.props.onToggle()}}}oy.props={onToggle:Function,dropdownStyle:String,class:String},Di`
1852
1852
  .o-spreadsheet-topbar {
1853
1853
  line-height: 1.2;
1854
1854
  font-size: 13px;
@@ -1932,7 +1932,7 @@
1932
1932
  }
1933
1933
  }
1934
1934
  }
1935
- `;class Kw extends t.Component{static template="o-spreadsheet-TopBar";get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}static components={ColorPickerWidget:Vb,ColorPicker:Ub,Menu:Ir,TopBarComposer:Yw,FontSizeEditor:Xw,ActionButton:Gw,BorderEditorWidget:jw};state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:"",fillColor:"#ffffff",textColor:"#000000"});isSelectingMenu=!1;openedEl=null;menus=[];EDIT=Im;FORMAT=Kf;VIEW=Cb;formatNumberMenuItemSpec=yb;isntToolbarMenu=!1;setup(){t.useExternalListener(window,"click",this.onExternalClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return nv.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.isntToolbarMenu&&this.openMenu(e,t)}toggleDropdownTool(e,t){const o=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=o?"":e,this.openedEl=o?null:t.target}toggleContextMenu(e,t){this.state.menuState.isOpen&&this.isntToolbarMenu?this.closeMenus():(this.openMenu(e,t),this.isntToolbarMenu=!0)}toggleToolbarContextMenu(e,t){if(this.state.menuState.isOpen&&!this.isntToolbarMenu)this.closeMenus();else{const o=pg(e);this.openMenu(o,t),this.isntToolbarMenu=!1}}openMenu(e,t){const{left:o,top:i,height:s}=t.currentTarget.getBoundingClientRect();this.state.activeTool="",this.state.menuState.isOpen=!0,this.state.menuState.position={x:o,y:i+s},this.state.menuState.menuItems=e.children(this.env).sort(((e,t)=>e.sequence-t.sequence)),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target,this.env.model.dispatch("STOP_EDITION")}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){const e=this.env.model.getters.getCurrentStyle();this.state.fillColor=e.fillColor||"#ffffff",this.state.textColor=e.textColor||"#000000",this.menus=Ib.getMenuItems()}getMenuName(e){return e.name(this.env)}setColor(e,t){Wp(this.env,{[e]:t}),this.onClick()}}Kw.props={onClick:Function,focusComposer:String,onComposerContentFocused:Function,dropdownMaxHeight:Number};class Qw{clipboard;constructor(e){this.clipboard=e}async write(e){try{this.clipboard?.write(this.getClipboardItems(e))}catch(e){}}async writeText(e){try{this.clipboard?.writeText(e)}catch(e){}}async readText(){let e;try{e=await navigator.permissions.query({name:"clipboard-read"})}catch(e){}try{return{status:"ok",content:await this.clipboard.readText()}}catch(t){return{status:"denied"===e?.state?"permissionDenied":"notImplemented"}}}getClipboardItems(e){return[new ClipboardItem({[Ji.PlainText]:this.getBlob(e,Ji.PlainText),[Ji.Html]:this.getBlob(e,Ji.Html)})]}getBlob(e,t){return new Blob([e[t]||""],{type:t})}}const Jw="#000";Di`
1935
+ `;class iy extends t.Component{static template="o-spreadsheet-TopBar";get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}static components={ColorPickerWidget:Gb,ColorPicker:Wb,Menu:Ir,TopBarComposer:ty,FontSizeEditor:oy,ActionButton:Kw,BorderEditorWidget:ey};state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:"",fillColor:"#ffffff",textColor:"#000000"});isSelectingMenu=!1;openedEl=null;menus=[];EDIT=Mm;FORMAT=ib;VIEW=Rb;formatNumberMenuItemSpec=Ob;isntToolbarMenu=!1;setup(){t.useExternalListener(window,"click",this.onExternalClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return uv.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.isntToolbarMenu&&this.openMenu(e,t)}toggleDropdownTool(e,t){const o=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=o?"":e,this.openedEl=o?null:t.target}toggleContextMenu(e,t){this.state.menuState.isOpen&&this.isntToolbarMenu?this.closeMenus():(this.openMenu(e,t),this.isntToolbarMenu=!0)}toggleToolbarContextMenu(e,t){if(this.state.menuState.isOpen&&!this.isntToolbarMenu)this.closeMenus();else{const o=Cg(e);this.openMenu(o,t),this.isntToolbarMenu=!1}}openMenu(e,t){const{left:o,top:i,height:s}=t.currentTarget.getBoundingClientRect();this.state.activeTool="",this.state.menuState.isOpen=!0,this.state.menuState.position={x:o,y:i+s},this.state.menuState.menuItems=e.children(this.env).sort(((e,t)=>e.sequence-t.sequence)),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target,this.env.model.dispatch("STOP_EDITION")}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){const e=this.env.model.getters.getCurrentStyle();this.state.fillColor=e.fillColor||"#ffffff",this.state.textColor=e.textColor||"#000000",this.menus=Mb.getMenuItems()}getMenuName(e){return e.name(this.env)}setColor(e,t){Xp(this.env,{[e]:t}),this.onClick()}}iy.props={onClick:Function,focusComposer:String,onComposerContentFocused:Function,dropdownMaxHeight:Number};class sy{clipboard;constructor(e){this.clipboard=e}async write(e){try{this.clipboard?.write(this.getClipboardItems(e))}catch(e){}}async writeText(e){try{this.clipboard?.writeText(e)}catch(e){}}async readText(){let e;try{e=await navigator.permissions.query({name:"clipboard-read"})}catch(e){}try{return{status:"ok",content:await this.clipboard.readText()}}catch(t){return{status:"denied"===e?.state?"permissionDenied":"notImplemented"}}}getClipboardItems(e){return[new ClipboardItem({[Ji.PlainText]:this.getBlob(e,Ji.PlainText),[Ji.Html]:this.getBlob(e,Ji.Html)})]}getBlob(e,t){return new Blob([e[t]||""],{type:t})}}const ry="#000";Di`
1936
1936
  .o-spreadsheet {
1937
1937
  position: relative;
1938
1938
  display: grid;
@@ -1972,9 +1972,9 @@
1972
1972
  }
1973
1973
  &:not(.o-disabled):not(.active):hover {
1974
1974
  background-color: ${y};
1975
- color: ${Jw};
1975
+ color: ${ry};
1976
1976
  .o-icon {
1977
- color: ${Jw};
1977
+ color: ${ry};
1978
1978
  }
1979
1979
  }
1980
1980
  &.active {
@@ -2035,23 +2035,23 @@
2035
2035
  outline: none;
2036
2036
  }
2037
2037
  }
2038
- `;const ey=e=>e;class ty extends t.Component{static template="o-spreadsheet-Spreadsheet";static components={TopBar:Kw,Grid:tS,BottomBar:Bw,SidePanel:Ww,SpreadsheetDashboard:$w};static _t=ey;sidePanel;composer;_focusGrid;keyDownMapping;isViewportTooSmall=!1;get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new Dw(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:ty._t,clipboard:this.env.clipboard||new Qw(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e)}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(isFinite(e)&&isFinite(t))if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:r("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.isOpen&&e!==this.sidePanel.component&&this.sidePanel.panelProps?.onCloseSidePanel?.(),this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid(),this.sidePanel.panelProps?.onCloseSidePanel?.()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}ty.props={model:Object};class oy{listeners=[];sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function iy(e){return Fp.get(e.type)(e)}function sy(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class ry{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:i,operation:s,after:r}=this.locateOperation(t);this.operations=[...i,s,e,...r.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new ry(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class ny{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new ay(this.id,qe((()=>e(this.data))))}}class ay{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new ay(this.id,this.lazyData.map(e))}}class ly{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new ly(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new ly(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new ly(function*(e,t){let o=!0;for(const i of e)o||(yield i),i.operation.id===t&&(o=!1)}(this.operations,e))}}class cy{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new ly(Me(this._execution(e),this._execution(e)))}revertedExecution(e){return new ly(Me(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){const o=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),i=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const s=e.fork(t.id);i&&this.branchingOperationIds.set(s,i),this.insertBranchAfter(e,s),this.transform(s,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const i=this.branchingOperationIds.get(t);i?this.branchingOperationIds.set(e,i):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const i=this.buildTransformation.without(o.data),s=t.fork(o.id);this.branchingOperationIds.set(s,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,s),s.transform(i);const r=this.nextBranch(s);r&&this.rebaseUp(r)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const i=this.branchingOperationIds.get(e),s=this.nextBranch(e);if(i&&s)if(e.getFirstOperationAmong(o,i)===i){const r=this.addToNextBranch(e,s,i,t,o);this.updateNextWith(s,r,o)}else{const e=this.buildTransformation.with(t.data);this.transform(s,e)}}addToNextBranch(e,t,o,i,s){let r=i;return s===o?(r=this.getTransformedOperation(e,o,i),t.prepend(r)):t.contains(s)?(r=this.getTransformedOperation(e,o,i),t.insert(r,s)):t.append(i),r}getTransformedOperation(e,t,o){const i=e.getOperation(t),s=this.buildTransformation.without(i.data);return o.transformed(s)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:i,branchingOperation:s}=this.findPreviousBranchingOperation(e);if(!i||!s)return;const r=this.buildTransformation.with(s.data),n=e.fork(o);n.transform(r),i.cutAfter(o),i.appendBranch(n);const a=t.transformed(r);this.insertPrevious(i,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const i=e.getOperations();for(let s=i.length-1;s>=0;s--){const r=i[s];r.id===t&&(o=!1),o||(yield{operation:r,branch:e,isCancelled:!this.shouldExecute(e,r)})}const s=this.previousBranch(e);yield*s?this._revertedExecution(s):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class hy{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new ry(this.buildTransformation),this.tree=new cy(this.buildTransformation,this.HEAD_BRANCH);const t=e.initialOperationId,o=new ny(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,o),this.HEAD_OPERATION=o}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new ny(e,t),i=this.tree.getLastBranch();this.tree.insertOperationLast(i,o),this.HEAD_BRANCH=i,this.HEAD_OPERATION=o}insert(e,t,o){const i=new ny(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,i,o),this.fastForward()}undo(e,t,o){const{branch:i,operation:s}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(i,s),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}getRevertedExecution(){const e=[],t=this.tree.revertedExecution(this.HEAD_BRANCH);for(const{operation:o}of t)e.push(o.data);return e}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:i}of e)i||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:i}of e)i||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function dy(e){return new hy({initialOperationId:e.initialRevisionId,applyOperation:t=>{const o=t.commands.slice(),{changes:i}=e.recordChanges((()=>{for(const t of o)e.dispatch(t)}));t.setChanges(i)},revertOperation:e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){uy(t.changes[e],"before")}}([e]),buildEmpty:e=>new JE(e,"empty",[]),buildTransformation:{with:e=>t=>new JE(t.id,t.clientId,KE(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new JE(t.id,t.clientId,KE(t.commands,e.commands.map(iy).flat()),t.rootCommand,void 0,t.timestamp)}})}function uy(e,t){let o=e.root,i=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const i=e.path[t];if(void 0===o[i]){const s=e.path[t+1];o[i]=sy(s)}o=o[i]}void 0===e[t]?delete o[i]:o[i]=e[t]}class gy{observers=[];defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class py{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new gy,this.anchor={cell:{col:0,row:0},zone:Ei({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,o){const i=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(i,e.zone)},this.processEvent({options:o,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,"overrideSelection",t)}selectCell(e,t){const o=Ei({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new ns(84);const{col:o,row:i}=this.getNextAvailablePosition(e,t);return this.selectCell(o,i)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:i,row:s}=this.anchor.cell,r={left:Math.min(i,e),top:Math.min(s,t),right:Math.max(i,e),bottom:Math.max(s,t)},n={zone:this.getters.expandZone(o,r),cell:{col:i,row:s}};return this.processEvent({mode:"updateAnchor",anchor:n,options:{scrollIntoView:!1}})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const i=this.getters.expandZone(o,Ei({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:i,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new ns(84);const o=this.getters.getActiveSheetId(),i=this.anchor,{col:s,row:r}=i.cell,{left:n,right:a,top:l,bottom:c}=i.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return ns.Success;let g=i.zone;const p=e=>{e=Ci(e);const{left:t,right:i,top:s,bottom:r}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,i),top:Math.max(0,s),bottom:Math.min(this.getters.getNumberRows(o)-1,r)}},{col:m,row:f}=this.getReferencePosition();let b=0;for(;null!==g;){if(b++,d<0){const e=this.getNextAvailableCol(d,a-(b-1),f);g=m<=a-b?p({top:l,left:n,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,n+(b-1),f);g=n+b<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(b-1));g=f<=c-b?p({top:l,left:n,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(b-1));g=l+b<=f?p({top:e,left:n,bottom:c,right:a}):null}if(g=g?Ci(g):g,g&&!li(g,i.zone))return this.processEvent({options:{scrollIntoView:!0},mode:"updateAnchor",anchor:{zone:g,cell:{col:s,row:r}}})}g=p(ni({top:r,bottom:r,left:s,right:s},Ci({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,n,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const v={zone:g,cell:{col:s,row:r}};return this.processEvent({anchor:v,mode:"updateAnchor",options:{scrollIntoView:!0}})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberRows(o)-1;let s={left:e,right:e,top:0,bottom:i};const r=this.getters.findFirstVisibleColRowIndex(o,"ROW");let n,a;switch(t){case"overrideSelection":case"newAnchor":n=e,a=r;break;case"updateAnchor":({col:n,row:a}=this.anchor.cell),s=ni(s,{left:n,right:n,top:r,bottom:i})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:s,cell:{col:n,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberCols(o)-1;let s={top:e,bottom:e,left:0,right:i};const r=this.getters.findFirstVisibleColRowIndex(o,"COL");let n,a;switch(t){case"overrideSelection":case"newAnchor":n=r,a=e;break;case"updateAnchor":({col:n,row:a}=this.anchor.cell),s=ni(s,{left:r,right:i,top:a,bottom:a})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:s,cell:{col:n,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(li(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:Ei(t.cell)},"updateAnchor",{scrollIntoView:!1});const o=this.expandZoneToTable(t.zone);return Ye(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"updateAnchor",{scrollIntoView:!1})}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor",{scrollIntoView:!1})}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}processEvent(e){const t={...e,previousAnchor:Se(this.anchor)},o=this.checkEventAnchorZone(t);return 0!==o?new ns(o):(this.anchor=t.anchor,this.stream.send(t),ns.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!hi(t.col,t.row,o))return 17;const{left:i,right:s,top:r,bottom:n}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",i,s);return void 0===this.getters.findVisibleHeader(a,"ROW",r,n)||void 0===l?18:0}checkAnchorZoneOrThrow(e){if(17===this.checkAnchorZone(e))throw new Error(s("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:o,row:i}=this.anchor.cell,s=this.deltaToTarget({col:o,row:i},e,t);return{col:this.getNextAvailableCol(s[0],o,i),row:this.getNextAvailableRow(s[1],o,i)}}getNextAvailableCol(e,t,o){const i=this.getters.getActiveSheetId(),s={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,s,(e=>this.getters.isInSameMerge(i,t,o,e,o)))}getNextAvailableRow(e,t,o){const i=this.getters.getActiveSheetId(),s={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,s,(e=>this.getters.isInSameMerge(i,t,o,t,e)))}getNextAvailableHeader(e,t,o,i,s){const r=this.getters.getActiveSheetId();if(0===e)return o;const n=Math.sign(e);let a=o+e;for(;s(a);)a+=n;for(;this.getters.isHeaderHidden(r,t,a);)a+=n;return a<0||a>this.getters.getNumberHeaders(r,t)-1?this.getters.isHeaderHidden(r,t,o)?this.getNextAvailableHeader(-n,t,o,i,s):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:i,top:s,bottom:r}=t.zone,{col:n,row:a}=t.cell;return{col:this.getters.isColHidden(e,n)&&this.getters.findVisibleHeader(e,"COL",o,i)||n,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",s,r)||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const i=this.anchor.zone;switch(e){case"down":case"up":o=o===i.top?i.bottom:i.top;break;case"left":case"right":t=t===i.right?i.left:i.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const i=this.getters.getActiveSheet();let s=e;const r=this.getNextCellPosition(e,t,o);let n=this.isCellEmpty(s,i.id)||this.isCellEmpty(r,i.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(s,t,o);if(s.col===e.col&&s.row===e.row)break;const r=this.isCellEmpty(e,i.id);if("endOfCluster"===n&&r)break;if("nextCluster"===n&&!r){s=e;break}s=e}return"cols"===t?s.col:s.row}isCellEmpty({col:e,row:t},o=this.getters.getActiveSheetId()){const i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t});return this.getters.getEvaluatedCell(i).type===Qi.empty}getNextCellPosition(e,t,o){const i="cols"===t?"col":"row",s={...e},r="cols"===t?this.getNextAvailableCol(o,s.col,s.row):this.getNextAvailableRow(o,s.col,s.row);return s[i]=r,{col:s.col,row:s.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of Oe(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of Oe(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};let o=!1,i=e;do{o=!1;const e=t(i);li(i,e)||(o=!0,i=e)}while(o);return i}}class my{changes=[];commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop(),[o,...i]=e;let s=o,r=i[i.length-1];for(let e=0;e<=i.length-2;e++){const t=i[e];if(void 0===s[t]){const o=i[e+1];s[t]=sy(o)}s=s[t]}s[r]!==t&&(this.changes.push({root:o,path:i,before:s[r],after:t}),void 0===t?delete s[r]:s[r]=t)}}const fy=17781237,by=88853993;function vy(e,t,o){const i=[["xmlns:r",dS],["xmlns:a",aS],["xmlns:c",lS]],s=Sy({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let r=KC``;e.data.title&&(r=KC`
2038
+ `;const ny=e=>e;class ay extends t.Component{static template="o-spreadsheet-Spreadsheet";static components={TopBar:iy,Grid:aS,BottomBar:Zw,SidePanel:Xw,SpreadsheetDashboard:Yw};static _t=ny;sidePanel;composer;_focusGrid;keyDownMapping;isViewportTooSmall=!1;get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new zw(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:ay._t,clipboard:this.env.clipboard||new sy(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e)}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(isFinite(e)&&isFinite(t))if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:r("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.isOpen&&e!==this.sidePanel.component&&this.sidePanel.panelProps?.onCloseSidePanel?.(),this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid(),this.sidePanel.panelProps?.onCloseSidePanel?.()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}ay.props={model:Object};class ly{listeners=[];sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function cy(e){return Vp.get(e.type)(e)}function hy(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class dy{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:i,operation:s,after:r}=this.locateOperation(t);this.operations=[...i,s,e,...r.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new dy(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class uy{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new gy(this.id,qe((()=>e(this.data))))}}class gy{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new gy(this.id,this.lazyData.map(e))}}class py{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new py(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new py(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new py(function*(e,t){let o=!0;for(const i of e)o||(yield i),i.operation.id===t&&(o=!1)}(this.operations,e))}}class my{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new py(Me(this._execution(e),this._execution(e)))}revertedExecution(e){return new py(Me(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){const o=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),i=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const s=e.fork(t.id);i&&this.branchingOperationIds.set(s,i),this.insertBranchAfter(e,s),this.transform(s,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const i=this.branchingOperationIds.get(t);i?this.branchingOperationIds.set(e,i):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const i=this.buildTransformation.without(o.data),s=t.fork(o.id);this.branchingOperationIds.set(s,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,s),s.transform(i);const r=this.nextBranch(s);r&&this.rebaseUp(r)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const i=this.branchingOperationIds.get(e),s=this.nextBranch(e);if(i&&s)if(e.getFirstOperationAmong(o,i)===i){const r=this.addToNextBranch(e,s,i,t,o);this.updateNextWith(s,r,o)}else{const e=this.buildTransformation.with(t.data);this.transform(s,e)}}addToNextBranch(e,t,o,i,s){let r=i;return s===o?(r=this.getTransformedOperation(e,o,i),t.prepend(r)):t.contains(s)?(r=this.getTransformedOperation(e,o,i),t.insert(r,s)):t.append(i),r}getTransformedOperation(e,t,o){const i=e.getOperation(t),s=this.buildTransformation.without(i.data);return o.transformed(s)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:i,branchingOperation:s}=this.findPreviousBranchingOperation(e);if(!i||!s)return;const r=this.buildTransformation.with(s.data),n=e.fork(o);n.transform(r),i.cutAfter(o),i.appendBranch(n);const a=t.transformed(r);this.insertPrevious(i,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const i=e.getOperations();for(let s=i.length-1;s>=0;s--){const r=i[s];r.id===t&&(o=!1),o||(yield{operation:r,branch:e,isCancelled:!this.shouldExecute(e,r)})}const s=this.previousBranch(e);yield*s?this._revertedExecution(s):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class fy{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new dy(this.buildTransformation),this.tree=new my(this.buildTransformation,this.HEAD_BRANCH);const t=e.initialOperationId,o=new uy(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,o),this.HEAD_OPERATION=o}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new uy(e,t),i=this.tree.getLastBranch();this.tree.insertOperationLast(i,o),this.HEAD_BRANCH=i,this.HEAD_OPERATION=o}insert(e,t,o){const i=new uy(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,i,o),this.fastForward()}undo(e,t,o){const{branch:i,operation:s}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(i,s),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}getRevertedExecution(){const e=[],t=this.tree.revertedExecution(this.HEAD_BRANCH);for(const{operation:o}of t)e.push(o.data);return e}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:i}of e)i||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:i}of e)i||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function by(e){return new fy({initialOperationId:e.initialRevisionId,applyOperation:t=>{const o=t.commands.slice(),{changes:i}=e.recordChanges((()=>{for(const t of o)e.dispatch(t)}));t.setChanges(i)},revertOperation:e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){vy(t.changes[e],"before")}}([e]),buildEmpty:e=>new rw(e,"empty",[]),buildTransformation:{with:e=>t=>new rw(t.id,t.clientId,iw(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new rw(t.id,t.clientId,iw(t.commands,e.commands.map(cy).flat()),t.rootCommand,void 0,t.timestamp)}})}function vy(e,t){let o=e.root,i=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const i=e.path[t];if(void 0===o[i]){const s=e.path[t+1];o[i]=hy(s)}o=o[i]}void 0===e[t]?delete o[i]:o[i]=e[t]}class Sy{observers=[];defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class Cy{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new Sy,this.anchor={cell:{col:0,row:0},zone:Ei({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,o){const i=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(i,e.zone)},this.processEvent({options:o,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,"overrideSelection",t)}selectCell(e,t){const o=Ei({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new ns(84);const{col:o,row:i}=this.getNextAvailablePosition(e,t);return this.selectCell(o,i)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:i,row:s}=this.anchor.cell,r={left:Math.min(i,e),top:Math.min(s,t),right:Math.max(i,e),bottom:Math.max(s,t)},n={zone:this.getters.expandZone(o,r),cell:{col:i,row:s}};return this.processEvent({mode:"updateAnchor",anchor:n,options:{scrollIntoView:!1}})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const i=this.getters.expandZone(o,Ei({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:i,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new ns(84);const o=this.getters.getActiveSheetId(),i=this.anchor,{col:s,row:r}=i.cell,{left:n,right:a,top:l,bottom:c}=i.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return ns.Success;let g=i.zone;const p=e=>{e=Ci(e);const{left:t,right:i,top:s,bottom:r}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,i),top:Math.max(0,s),bottom:Math.min(this.getters.getNumberRows(o)-1,r)}},{col:m,row:f}=this.getReferencePosition();let b=0;for(;null!==g;){if(b++,d<0){const e=this.getNextAvailableCol(d,a-(b-1),f);g=m<=a-b?p({top:l,left:n,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,n+(b-1),f);g=n+b<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(b-1));g=f<=c-b?p({top:l,left:n,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(b-1));g=l+b<=f?p({top:e,left:n,bottom:c,right:a}):null}if(g=g?Ci(g):g,g&&!li(g,i.zone))return this.processEvent({options:{scrollIntoView:!0},mode:"updateAnchor",anchor:{zone:g,cell:{col:s,row:r}}})}g=p(ni({top:r,bottom:r,left:s,right:s},Ci({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,n,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const v={zone:g,cell:{col:s,row:r}};return this.processEvent({anchor:v,mode:"updateAnchor",options:{scrollIntoView:!0}})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberRows(o)-1;let s={left:e,right:e,top:0,bottom:i};const r=this.getters.findFirstVisibleColRowIndex(o,"ROW");let n,a;switch(t){case"overrideSelection":case"newAnchor":n=e,a=r;break;case"updateAnchor":({col:n,row:a}=this.anchor.cell),s=ni(s,{left:n,right:n,top:r,bottom:i})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:s,cell:{col:n,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberCols(o)-1;let s={top:e,bottom:e,left:0,right:i};const r=this.getters.findFirstVisibleColRowIndex(o,"COL");let n,a;switch(t){case"overrideSelection":case"newAnchor":n=r,a=e;break;case"updateAnchor":({col:n,row:a}=this.anchor.cell),s=ni(s,{left:r,right:i,top:a,bottom:a})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:s,cell:{col:n,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(li(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:Ei(t.cell)},"updateAnchor",{scrollIntoView:!1});const o=this.expandZoneToTable(t.zone);return Ye(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"updateAnchor",{scrollIntoView:!1})}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor",{scrollIntoView:!1})}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}processEvent(e){const t={...e,previousAnchor:Se(this.anchor)},o=this.checkEventAnchorZone(t);return 0!==o?new ns(o):(this.anchor=t.anchor,this.stream.send(t),ns.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!hi(t.col,t.row,o))return 17;const{left:i,right:s,top:r,bottom:n}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",i,s);return void 0===this.getters.findVisibleHeader(a,"ROW",r,n)||void 0===l?18:0}checkAnchorZoneOrThrow(e){if(17===this.checkAnchorZone(e))throw new Error(s("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:o,row:i}=this.anchor.cell,s=this.deltaToTarget({col:o,row:i},e,t);return{col:this.getNextAvailableCol(s[0],o,i),row:this.getNextAvailableRow(s[1],o,i)}}getNextAvailableCol(e,t,o){const i=this.getters.getActiveSheetId(),s={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,s,(e=>this.getters.isInSameMerge(i,t,o,e,o)))}getNextAvailableRow(e,t,o){const i=this.getters.getActiveSheetId(),s={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,s,(e=>this.getters.isInSameMerge(i,t,o,t,e)))}getNextAvailableHeader(e,t,o,i,s){const r=this.getters.getActiveSheetId();if(0===e)return o;const n=Math.sign(e);let a=o+e;for(;s(a);)a+=n;for(;this.getters.isHeaderHidden(r,t,a);)a+=n;return a<0||a>this.getters.getNumberHeaders(r,t)-1?this.getters.isHeaderHidden(r,t,o)?this.getNextAvailableHeader(-n,t,o,i,s):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:i,top:s,bottom:r}=t.zone,{col:n,row:a}=t.cell;return{col:this.getters.isColHidden(e,n)&&this.getters.findVisibleHeader(e,"COL",o,i)||n,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",s,r)||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const i=this.anchor.zone;switch(e){case"down":case"up":o=o===i.top?i.bottom:i.top;break;case"left":case"right":t=t===i.right?i.left:i.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const i=this.getters.getActiveSheet();let s=e;const r=this.getNextCellPosition(e,t,o);let n=this.isCellEmpty(s,i.id)||this.isCellEmpty(r,i.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(s,t,o);if(s.col===e.col&&s.row===e.row)break;const r=this.isCellEmpty(e,i.id);if("endOfCluster"===n&&r)break;if("nextCluster"===n&&!r){s=e;break}s=e}return"cols"===t?s.col:s.row}isCellEmpty({col:e,row:t},o=this.getters.getActiveSheetId()){const i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t});return this.getters.getEvaluatedCell(i).type===Qi.empty}getNextCellPosition(e,t,o){const i="cols"===t?"col":"row",s={...e},r="cols"===t?this.getNextAvailableCol(o,s.col,s.row):this.getNextAvailableRow(o,s.col,s.row);return s[i]=r,{col:s.col,row:s.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of Oe(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of Oe(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};let o=!1,i=e;do{o=!1;const e=t(i);li(i,e)||(o=!0,i=e)}while(o);return i}}class Ey{changes=[];commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop(),[o,...i]=e;let s=o,r=i[i.length-1];for(let e=0;e<=i.length-2;e++){const t=i[e];if(void 0===s[t]){const o=i[e+1];s[t]=hy(o)}s=s[t]}s[r]!==t&&(this.changes.push({root:o,path:i,before:s[r],after:t}),void 0===t?delete s[r]:s[r]=t)}}const wy=17781237,yy=88853993;function xy(e,t,o){const i=[["xmlns:r",bS],["xmlns:a",gS],["xmlns:c",pS]],s=Iy({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let r=sE``;e.data.title&&(r=sE`
2039
2039
  <c:title>
2040
- ${Ey(e.data.title,e.data.fontColor)}
2040
+ ${Ty(e.data.title,e.data.fontColor)}
2041
2041
  <c:overlay val="0" />
2042
2042
  </c:title>
2043
- `);let n=KC``;switch(e.data.type){case"bar":n=function(e){const t=new Fg,o=[];for(const[i,s]of Object.entries(e.dataSets)){const r=Cg(t.next()),n=Sy({backgroundColor:r,line:{color:r}});o.push(KC`
2043
+ `);let n=sE``;switch(e.data.type){case"bar":n=function(e){const t=new Vg,o=[];for(const[i,s]of Object.entries(e.dataSets)){const r=Rg(t.next()),n=Iy({backgroundColor:r,line:{color:r}});o.push(sE`
2044
2044
  <c:ser>
2045
2045
  <c:idx val="${i}"/>
2046
2046
  <c:order val="${i}"/>
2047
- ${s.label?KC`<c:tx>${Iy(s.label)}</c:tx>`:""}
2047
+ ${s.label?sE`<c:tx>${My(s.label)}</c:tx>`:""}
2048
2048
  ${n}
2049
- ${e.labelRange?KC`<c:cat>${Iy(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2049
+ ${e.labelRange?sE`<c:cat>${My(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2050
2050
  <c:val> <!-- x-coordinate values -->
2051
- ${Ry(s.range)}
2051
+ ${_y(s.range)}
2052
2052
  </c:val>
2053
2053
  </c:ser>
2054
- `)}const i="left"===e.verticalAxisPosition?"l":"r",s=e.stacked?"stacked":"clustered",r=e.stacked?100:-20;return KC`
2054
+ `)}const i="left"===e.verticalAxisPosition?"l":"r",s=e.stacked?"stacked":"clustered",r=e.stacked?100:-20;return sE`
2055
2055
  <c:barChart>
2056
2056
  <c:barDir val="col"/>
2057
2057
  <c:grouping val="${s}"/>
@@ -2059,13 +2059,13 @@
2059
2059
  <c:gapWidth val="70"/>
2060
2060
  <!-- each data marker in the series does not have a different color -->
2061
2061
  <c:varyColors val="0"/>
2062
- ${XC(o)}
2063
- <c:axId val="${fy}" />
2064
- <c:axId val="${by}" />
2062
+ ${iE(o)}
2063
+ <c:axId val="${wy}" />
2064
+ <c:axId val="${yy}" />
2065
2065
  </c:barChart>
2066
- ${xy("b","c:catAx",fy,by,{fontColor:e.fontColor})}
2067
- ${xy(i,"c:valAx",by,fy,{fontColor:e.fontColor})}
2068
- `}(e.data);break;case"line":n=function(e){const t=new Fg,o=[];for(const[i,s]of Object.entries(e.dataSets)){const r=Sy({line:{width:2.5,style:"solid",color:Cg(t.next())}});o.push(KC`
2066
+ ${Ny("b","c:catAx",wy,yy,{fontColor:e.fontColor})}
2067
+ ${Ny(i,"c:valAx",yy,wy,{fontColor:e.fontColor})}
2068
+ `}(e.data);break;case"line":n=function(e){const t=new Vg,o=[];for(const[i,s]of Object.entries(e.dataSets)){const r=Iy({line:{width:2.5,style:"solid",color:Rg(t.next())}});o.push(sE`
2069
2069
  <c:ser>
2070
2070
  <c:idx val="${i}"/>
2071
2071
  <c:order val="${i}"/>
@@ -2074,50 +2074,50 @@
2074
2074
  <c:symbol val="circle" />
2075
2075
  <c:size val="5"/>
2076
2076
  </c:marker>
2077
- ${s.label?KC`<c:tx>${Iy(s.label)}</c:tx>`:""}
2077
+ ${s.label?sE`<c:tx>${My(s.label)}</c:tx>`:""}
2078
2078
  ${r}
2079
- ${e.labelRange?KC`<c:cat>${Iy(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2079
+ ${e.labelRange?sE`<c:cat>${My(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2080
2080
  <c:val> <!-- x-coordinate values -->
2081
- ${Ry(s.range)}
2081
+ ${_y(s.range)}
2082
2082
  </c:val>
2083
2083
  </c:ser>
2084
- `)}const i="left"===e.verticalAxisPosition?"l":"r",s=e.stacked?"stacked":"standard";return KC`
2084
+ `)}const i="left"===e.verticalAxisPosition?"l":"r",s=e.stacked?"stacked":"standard";return sE`
2085
2085
  <c:lineChart>
2086
2086
  <c:grouping val="${s}"/>
2087
2087
  <!-- each data marker in the series does not have a different color -->
2088
2088
  <c:varyColors val="0"/>
2089
- ${XC(o)}
2090
- <c:axId val="${fy}" />
2091
- <c:axId val="${by}" />
2089
+ ${iE(o)}
2090
+ <c:axId val="${wy}" />
2091
+ <c:axId val="${yy}" />
2092
2092
  </c:lineChart>
2093
- ${xy("b","c:catAx",fy,by,{fontColor:e.fontColor})}
2094
- ${xy(i,"c:valAx",by,fy,{fontColor:e.fontColor})}
2095
- `}(e.data);break;case"pie":n=function(e,t,o,{holeSize:i}={holeSize:50}){const s=new Fg,r=Math.max(...e.dataSets.map((e=>EC(e.range,t,o)))),n=Oe(0,r).map((()=>Cg(s.next()))),a=[];for(const[i,s]of Object.entries(e.dataSets).reverse()){const r=EC(s.range,t,o),l=[];for(const e of Oe(0,r)){const t=Sy({backgroundColor:n[e],line:{color:"FFFFFF",width:1.5}});l.push(KC`
2093
+ ${Ny("b","c:catAx",wy,yy,{fontColor:e.fontColor})}
2094
+ ${Ny(i,"c:valAx",yy,wy,{fontColor:e.fontColor})}
2095
+ `}(e.data);break;case"pie":n=function(e,t,o,{holeSize:i}={holeSize:50}){const s=new Vg,r=Math.max(...e.dataSets.map((e=>AC(e.range,t,o)))),n=Oe(0,r).map((()=>Rg(s.next()))),a=[];for(const[i,s]of Object.entries(e.dataSets).reverse()){const r=AC(s.range,t,o),l=[];for(const e of Oe(0,r)){const t=Iy({backgroundColor:n[e],line:{color:"FFFFFF",width:1.5}});l.push(sE`
2096
2096
  <c:dPt>
2097
2097
  <c:idx val="${e}"/>
2098
2098
  ${t}
2099
2099
  </c:dPt>
2100
- `)}a.push(KC`
2100
+ `)}a.push(sE`
2101
2101
  <c:ser>
2102
2102
  <c:idx val="${i}"/>
2103
2103
  <c:order val="${i}"/>
2104
- ${s.label?KC`<c:tx>${Iy(s.label)}</c:tx>`:""}
2105
- ${XC(l)}
2106
- ${yy({showLeaderLines:!0})}
2107
- ${e.labelRange?KC`<c:cat>${Iy(e.labelRange)}</c:cat>`:""}
2104
+ ${s.label?sE`<c:tx>${My(s.label)}</c:tx>`:""}
2105
+ ${iE(l)}
2106
+ ${Oy({showLeaderLines:!0})}
2107
+ ${e.labelRange?sE`<c:cat>${My(e.labelRange)}</c:cat>`:""}
2108
2108
  <c:val>
2109
- ${Ry(s.range)}
2109
+ ${_y(s.range)}
2110
2110
  </c:val>
2111
2111
  </c:ser>
2112
- `)}return KC`
2112
+ `)}return sE`
2113
2113
  <c:doughnutChart>
2114
2114
  <c:varyColors val="1" />
2115
2115
  <c:holeSize val="${i}" />
2116
- ${yy()}
2117
- ${XC(a)}
2116
+ ${Oy()}
2117
+ ${iE(a)}
2118
2118
  </c:doughnutChart>
2119
- `}(e.data,t,o,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=KC`
2120
- <c:chartSpace ${ZC(i)}>
2119
+ `}(e.data,t,o,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=sE`
2120
+ <c:chartSpace ${eE(i)}>
2121
2121
  <c:roundedCorners val="0" />
2122
2122
  <!-- <manualLayout/> to manually position the chart in the figure container -->
2123
2123
  ${s}
@@ -2128,32 +2128,32 @@
2128
2128
  <!-- how the chart element is placed on the chart -->
2129
2129
  <c:layout />
2130
2130
  ${n}
2131
- ${Sy({backgroundColor:e.data.backgroundColor})}
2131
+ ${Iy({backgroundColor:e.data.backgroundColor})}
2132
2132
  </c:plotArea>
2133
- ${function(e,t){return KC`
2133
+ ${function(e,t){return sE`
2134
2134
  <c:legend>
2135
2135
  <c:legendPos val="${e}"/>
2136
2136
  <c:overlay val="0"/>
2137
- ${wy(10,t)}
2137
+ ${Ay(10,t)}
2138
2138
  </c:legend>
2139
2139
  `}(a,l)}
2140
2140
  </c:chart>
2141
2141
  </c:chartSpace>
2142
- `;return jC(c)}function Sy(e){return KC`
2142
+ `;return tE(c)}function Iy(e){return sE`
2143
2143
  <c:spPr>
2144
- ${e.backgroundColor?Cy(e.backgroundColor):""}
2145
- ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",CC(e.width)]);const o=e.style?KC`<a:prstDash val="${e.style}"/>`:"";return KC`
2146
- <a:ln ${ZC(t)}>
2147
- ${Cy(e.color)}
2144
+ ${e.backgroundColor?Ry(e.backgroundColor):""}
2145
+ ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",TC(e.width)]);const o=e.style?sE`<a:prstDash val="${e.style}"/>`:"";return sE`
2146
+ <a:ln ${eE(t)}>
2147
+ ${Ry(e.color)}
2148
2148
  ${o}
2149
2149
  </a:ln>
2150
2150
  `}(e.line):""}
2151
2151
  </c:spPr>
2152
- `}function Cy(e){return KC`
2152
+ `}function Ry(e){return sE`
2153
2153
  <a:solidFill>
2154
2154
  <a:srgbClr val="${e}"/>
2155
2155
  </a:solidFill>
2156
- `}function Ey(e,t="000000",o=22){return KC`
2156
+ `}function Ty(e,t="000000",o=22){return sE`
2157
2157
  <c:tx>
2158
2158
  <c:rich>
2159
2159
  <a:bodyPr />
@@ -2161,7 +2161,7 @@
2161
2161
  <a:p>
2162
2162
  <a:pPr lvl="0">
2163
2163
  <a:defRPr b="0">
2164
- ${Cy(t)}
2164
+ ${Ry(t)}
2165
2165
  <a:latin typeface="+mn-lt"/>
2166
2166
  </a:defRPr>
2167
2167
  </a:pPr>
@@ -2172,20 +2172,20 @@
2172
2172
  </a:p>
2173
2173
  </c:rich>
2174
2174
  </c:tx>
2175
- `}function wy(e=12,t="000000",o=!1,i=!1){return KC`
2175
+ `}function Ay(e=12,t="000000",o=!1,i=!1){return sE`
2176
2176
  <c:txPr>
2177
2177
  <a:bodyPr/>
2178
2178
  <a:lstStyle/>
2179
2179
  <a:p>
2180
2180
  <a:pPr lvl="0">
2181
- <a:defRPr ${ZC([["b",o?"1":"0"],["i",i?"1":"0"],["sz",100*e]])}>
2182
- ${Cy(t)}
2181
+ <a:defRPr ${eE([["b",o?"1":"0"],["i",i?"1":"0"],["sz",100*e]])}>
2182
+ ${Ry(t)}
2183
2183
  <a:latin typeface="+mn-lt"/>
2184
2184
  </a:defRPr>
2185
2185
  </a:pPr>
2186
2186
  </a:p>
2187
2187
  </c:txPr>
2188
- `}function yy({showLeaderLines:e}={showLeaderLines:!1}){return KC`
2188
+ `}function Oy({showLeaderLines:e}={showLeaderLines:!1}){return sE`
2189
2189
  <dLbls>
2190
2190
  <c:showLegendKey val="0"/>
2191
2191
  <c:showVal val="0"/>
@@ -2195,7 +2195,7 @@
2195
2195
  <c:showBubbleSize val="0"/>
2196
2196
  <c:showLeaderLines val="${e?"1":"0"}"/>
2197
2197
  </dLbls>
2198
- `}function xy(e,t,o,i,{fontColor:s}){return KC`
2198
+ `}function Ny(e,t,o,i,{fontColor:s}){return sE`
2199
2199
  <${t}>
2200
2200
  <c:axId val="${o}"/>
2201
2201
  <c:crossAx val="${i}"/> <!-- reference to the other axe of the chart -->
@@ -2204,62 +2204,62 @@
2204
2204
  <c:orientation val="minMax" />
2205
2205
  </c:scaling>
2206
2206
  <c:axPos val="${e}" />
2207
- ${function(e="B7B7B7"){return KC`
2207
+ ${function(e="B7B7B7"){return sE`
2208
2208
  <c:majorGridlines>
2209
- ${Sy({line:{color:e}})}
2209
+ ${Iy({line:{color:e}})}
2210
2210
  </c:majorGridlines>
2211
2211
  `}()}
2212
2212
  <c:majorTickMark val="out" />
2213
2213
  <c:minorTickMark val="none" />
2214
2214
  <c:numFmt formatCode="General" sourceLinked="1" />
2215
2215
  <c:title>
2216
- ${Ey("")}
2216
+ ${Ty("")}
2217
2217
  </c:title>
2218
- ${wy(10,s)}
2218
+ ${Ay(10,s)}
2219
2219
  </${t}>
2220
2220
  <!-- <tickLblPos/> omitted -->
2221
- `}function Iy(e){return KC`
2221
+ `}function My(e){return sE`
2222
2222
  <c:strRef>
2223
2223
  <c:f>${e}</c:f>
2224
2224
  </c:strRef>
2225
- `}function Ry(e){return KC`
2225
+ `}function _y(e){return sE`
2226
2226
  <c:numRef>
2227
2227
  <c:f>${e}</c:f>
2228
2228
  <c:numCache />
2229
2229
  </c:numRef>
2230
- `}function Ty(e){const t=[];let o=KC``,i=KC``;const s=Oy(e.content);return e.value===a.CircularDependency&&(t.push(["t","str"]),i=KC`<v>${e.value}</v>`),o=KC`
2230
+ `}function Fy(e){const t=[];let o=sE``,i=sE``;const s=Ly(e.content);return e.value===a.CircularDependency&&(t.push(["t","str"]),i=sE`<v>${e.value}</v>`),o=sE`
2231
2231
  <f>
2232
2232
  ${s}
2233
2233
  </f>
2234
2234
  ${i}
2235
- `,{attrs:t,node:o}}function Ay(e,t,o=!1){let i=e;const s=[],r=i.trim().toUpperCase();if(!o&&["TRUE","FALSE"].includes(r))i="TRUE"===r?"1":"0",s.push(["t","b"]);else if(o||!ro(i,oo)){const{id:o}=mC(e,t);i=o.toString(),s.push(["t","s"])}return{attrs:s,node:KC`<v>${i}</v>`}}function Oy(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Ou(e)}catch(t){return e}return t=Mu(t,"STRING",Ny),t=Mu(t,"FUNCALL",(e=>e=function(e){const t=e.value.toUpperCase(),o=e.args,i=SS[t];if(i){const s=Jd.content[t].args.filter((e=>!e.optional)),r=s.length-e.args.length;if(r)for(let t=e.args.length;t<s.length;t++){const e=i[t-r];o.push({type:e.type,value:e.value})}}return{...e,args:o}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:CS.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})))),t?_u(t):e}function Ny(e){const t=e.value.replace(new RegExp('"',"g"),""),o=zt(t,oo);if(o){let i=[];return(Dt.test(t)||Lt.test(t))&&i.push("yyyy-mm-dd"),Ut.test(t)&&i.push("hh:mm:ss"),{...e,value:vo(o.value,{format:i.join(" "),locale:oo})}}return{...e,value:e.value.replace(/\\"/g,'""')}}function My(e,t){const o=[];for(const i of t)switch(i.rule.type){case"CellIsRule":o.push(_y(i,i.rule,e));break;case"ColorScaleRule":o.push(Fy(i,i.rule));break;case"IconSetRule":o.push(Dy(i,i.rule));break;default:console.warn(`Conditional formatting ${i.rule.type} not implemented`)}return o}function _y(e,t,o){const i=Ly(e),s=lC(t.operator);i.push(...function(e){const t=lC(e.operator);switch(e.operator){case"ContainsText":case"NotContains":case"BeginsWith":case"EndsWith":return[["type",t],["text",e.values[0]]];case"IsEmpty":case"IsNotEmpty":return[["type",t]];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":case"Between":case"NotBetween":return[["type","cellIs"]]}}(t),["operator",s]);const r=function(e,t){const o=e[0].split(":")[0],i=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${i[0]}",${o})))`];case"NotContains":return[`ISERROR(SEARCH("${i[0]}",${o}))`];case"BeginsWith":return[`LEFT(${o},LEN("${i[0]}"))="${i[0]}"`];case"EndsWith":return[`RIGHT(${o},LEN("${i[0]}"))="${i[0]}"`];case"IsEmpty":return[`LEN(TRIM(${o}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${o}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[i[0]];case"Between":case"NotBetween":return[i[0],i[1]]}}(e.ranges,t).map((e=>KC`<formula>${e}</formula>`)),n={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};t.style.fillColor&&(n.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=mC(n,o);return i.push(["dxfId",a]),KC`
2235
+ `,{attrs:t,node:o}}function Dy(e,t,o=!1){let i=e;const s=[],r=i.trim().toUpperCase();if(!o&&["TRUE","FALSE"].includes(r))i="TRUE"===r?"1":"0",s.push(["t","b"]);else if(o||!ro(i,oo)){const{id:o}=wC(e,t);i=o.toString(),s.push(["t","s"])}return{attrs:s,node:sE`<v>${i}</v>`}}function Ly(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Nu(e)}catch(t){return e}return t=_u(t,"STRING",Py),t=_u(t,"FUNCALL",(e=>e=function(e){const t=e.value.toUpperCase(),o=e.args,i=IS[t];if(i){const s=tu.content[t].args.filter((e=>!e.optional)),r=s.length-e.args.length;if(r)for(let t=e.args.length;t<s.length;t++){const e=i[t-r];o.push({type:e.type,value:e.value})}}return{...e,args:o}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:RS.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})))),t?Pu(t):e}function Py(e){const t=e.value.replace(new RegExp('"',"g"),""),o=zt(t,oo);if(o){let i=[];return(Dt.test(t)||Lt.test(t))&&i.push("yyyy-mm-dd"),Ut.test(t)&&i.push("hh:mm:ss"),{...e,value:vo(o.value,{format:i.join(" "),locale:oo})}}return{...e,value:e.value.replace(/\\"/g,'""')}}function ky(e,t){const o=[];for(const i of t)switch(i.rule.type){case"CellIsRule":o.push(Uy(i,i.rule,e));break;case"ColorScaleRule":o.push(Vy(i,i.rule));break;case"IconSetRule":o.push(zy(i,i.rule));break;default:console.warn(`Conditional formatting ${i.rule.type} not implemented`)}return o}function Uy(e,t,o){const i=By(e),s=mC(t.operator);i.push(...function(e){const t=mC(e.operator);switch(e.operator){case"ContainsText":case"NotContains":case"BeginsWith":case"EndsWith":return[["type",t],["text",e.values[0]]];case"IsEmpty":case"IsNotEmpty":return[["type",t]];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":case"Between":case"NotBetween":return[["type","cellIs"]]}}(t),["operator",s]);const r=function(e,t){const o=e[0].split(":")[0],i=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${i[0]}",${o})))`];case"NotContains":return[`ISERROR(SEARCH("${i[0]}",${o}))`];case"BeginsWith":return[`LEFT(${o},LEN("${i[0]}"))="${i[0]}"`];case"EndsWith":return[`RIGHT(${o},LEN("${i[0]}"))="${i[0]}"`];case"IsEmpty":return[`LEN(TRIM(${o}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${o}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[i[0]];case"Between":case"NotBetween":return[i[0],i[1]]}}(e.ranges,t).map((e=>sE`<formula>${e}</formula>`)),n={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};t.style.fillColor&&(n.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=wC(n,o);return i.push(["dxfId",a]),sE`
2236
2236
  <conditionalFormatting sqref="${e.ranges.join(" ")}">
2237
- <cfRule ${ZC(i)}>
2238
- ${XC(r)}
2237
+ <cfRule ${eE(i)}>
2238
+ ${iE(r)}
2239
2239
  </cfRule>
2240
2240
  </conditionalFormatting>
2241
- `}function Fy(e,t){const o=Ly(e);o.push(["type","colorScale"]);const i=[];for(const s of e.ranges){const e=[],r=[];let n=!0;for(let o of["minimum","midpoint","maximum"]){const i=t[o];i&&("formula"!==i.type?(e.push(ky(i,o)),r.push([["rgb",Cg(ct(i.color))]])):n=!1)}if(!n){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>KC`<cfvo ${ZC(e)}/>`)),l=r.map((e=>KC`<color ${ZC(e)}/>`));i.push(KC`
2241
+ `}function Vy(e,t){const o=By(e);o.push(["type","colorScale"]);const i=[];for(const s of e.ranges){const e=[],r=[];let n=!0;for(let o of["minimum","midpoint","maximum"]){const i=t[o];i&&("formula"!==i.type?(e.push($y(i,o)),r.push([["rgb",Rg(ct(i.color))]])):n=!1)}if(!n){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>sE`<cfvo ${eE(e)}/>`)),l=r.map((e=>sE`<color ${eE(e)}/>`));i.push(sE`
2242
2242
  <conditionalFormatting sqref="${s}">
2243
- <cfRule ${ZC(o)}>
2243
+ <cfRule ${eE(o)}>
2244
2244
  <colorScale>
2245
- ${XC(a)}
2246
- ${XC(l)}
2245
+ ${iE(a)}
2246
+ ${iE(l)}
2247
2247
  </colorScale>
2248
2248
  </cfRule>
2249
2249
  </conditionalFormatting>
2250
- `)}return XC(i)}function Dy(e,t){const o=Ly(e);o.push(["type","iconSet"]);const i=[];for(const s of e.ranges){const e=[[["type","percent"],["val",0]]];let r=!0;for(let o of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[o].type){r=!1;continue}const i=t[o];e.push([...ky(i,o),["gte","ge"===i.operator?"1":"0"]])}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const n=e.map((e=>KC`<cfvo ${ZC(e)} />`));i.push(KC`
2250
+ `)}return iE(i)}function zy(e,t){const o=By(e);o.push(["type","iconSet"]);const i=[];for(const s of e.ranges){const e=[[["type","percent"],["val",0]]];let r=!0;for(let o of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[o].type){r=!1;continue}const i=t[o];e.push([...$y(i,o),["gte","ge"===i.operator?"1":"0"]])}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const n=e.map((e=>sE`<cfvo ${eE(e)} />`));i.push(sE`
2251
2251
  <conditionalFormatting sqref="${s}">
2252
- <cfRule ${ZC(o)}>
2253
- <iconSet iconSet="${Py(t.icons)}">
2254
- ${XC(n)}
2252
+ <cfRule ${eE(o)}>
2253
+ <iconSet iconSet="${Hy(t.icons)}">
2254
+ ${iE(n)}
2255
2255
  </iconSet>
2256
2256
  </cfRule>
2257
2257
  </conditionalFormatting>
2258
- `)}return XC(i)}function Ly(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function Py(e){return rS[Object.keys(rS).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function ky(e,t){const o=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),i=[["type",o]];if("min"!==o&&"max"!==o){let t=e.value;if("formula"===o)try{t=Oy(e.value)}catch(o){t=e.value}i.push(["val",t])}return i}function Uy(e,t,o){const i=[["xmlns:xdr",nS.drawing],["xmlns:r",dS],["xmlns:a",aS],["xmlns:c",lS]],s=[];for(const[i,r]of Object.entries(o))switch(r?.tag){case"chart":s.push(By(r,t,e[i]));break;case"image":s.push(Hy(r,t,e[i]))}return jC(KC`
2259
- <xdr:wsDr ${ZC(i)}>
2260
- ${XC(s)}
2258
+ `)}return iE(i)}function By(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function Hy(e){return dS[Object.keys(dS).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function $y(e,t){const o=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),i=[["type",o]];if("min"!==o&&"max"!==o){let t=e.value;if("formula"===o)try{t=Ly(e.value)}catch(o){t=e.value}i.push(["val",t])}return i}function Wy(e,t,o){const i=[["xmlns:xdr",uS.drawing],["xmlns:r",bS],["xmlns:a",gS],["xmlns:c",pS]],s=[];for(const[i,r]of Object.entries(o))switch(r?.tag){case"chart":s.push(Zy(r,t,e[i]));break;case"image":s.push(jy(r,t,e[i]))}return tE(sE`
2259
+ <xdr:wsDr ${eE(i)}>
2260
+ ${iE(s)}
2261
2261
  </xdr:wsDr>
2262
- `)}function Vy(e,t){const{x:o,y:i,height:s,width:r}=e,n=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=zy(n,o),{index:h,offset:d}=zy(n,o+r),{index:u,offset:g}=zy(a,i),{index:p,offset:m}=zy(a,i+s);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function zy(e,t){let o=0;for(const[i,s]of Object.entries(e)){if(o<=t&&t<o+s.size)return{index:parseInt(i),offset:CC(t-o+ee)};o+=s.size}return{index:e.length-1,offset:CC(t-o+ee)}}function By(e,t,o){const{from:i,to:s}=Vy(e,t),r=bC(e.id),n=[["id",r],["name",`Chart ${r}`],["title","Chart"]];return KC`
2262
+ `)}function Gy(e,t){const{x:o,y:i,height:s,width:r}=e,n=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=qy(n,o),{index:h,offset:d}=qy(n,o+r),{index:u,offset:g}=qy(a,i),{index:p,offset:m}=qy(a,i+s);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function qy(e,t){let o=0;for(const[i,s]of Object.entries(e)){if(o<=t&&t<o+s.size)return{index:parseInt(i),offset:TC(t-o+ee)};o+=s.size}return{index:e.length-1,offset:TC(t-o+ee)}}function Zy(e,t,o){const{from:i,to:s}=Gy(e,t),r=xC(e.id),n=[["id",r],["name",`Chart ${r}`],["title","Chart"]];return sE`
2263
2263
  <xdr:twoCellAnchor>
2264
2264
  <xdr:from>
2265
2265
  <xdr:col>${i.col}</xdr:col>
@@ -2275,7 +2275,7 @@
2275
2275
  </xdr:to>
2276
2276
  <xdr:graphicFrame>
2277
2277
  <xdr:nvGraphicFramePr>
2278
- <xdr:cNvPr ${ZC(n)} />
2278
+ <xdr:cNvPr ${eE(n)} />
2279
2279
  <xdr:cNvGraphicFramePr />
2280
2280
  </xdr:nvGraphicFramePr>
2281
2281
  <xdr:xfrm>
@@ -2283,14 +2283,14 @@
2283
2283
  <a:ext cx="0" cy="0"/>
2284
2284
  </xdr:xfrm>
2285
2285
  <a:graphic>
2286
- <a:graphicData uri="${lS}">
2286
+ <a:graphicData uri="${pS}">
2287
2287
  <c:chart r:id="${o}" />
2288
2288
  </a:graphicData>
2289
2289
  </a:graphic>
2290
2290
  </xdr:graphicFrame>
2291
2291
  <xdr:clientData fLocksWithSheet="0"/>
2292
2292
  </xdr:twoCellAnchor>
2293
- `}function Hy(e,t,o){const{from:i,to:s}=Vy(e,t),r=SC(e.id),n=[["id",r],["name",`Image ${r}`],["title","Image"]];return KC`
2293
+ `}function jy(e,t,o){const{from:i,to:s}=Gy(e,t),r=RC(e.id),n=[["id",r],["name",`Image ${r}`],["title","Image"]],a=TC(e.width),l=TC(e.height);return sE`
2294
2294
  <xdr:twoCellAnchor editAs="oneCell">
2295
2295
  <xdr:from>
2296
2296
  <xdr:col>${i.col}</xdr:col>
@@ -2306,7 +2306,7 @@
2306
2306
  </xdr:to>
2307
2307
  <xdr:pic>
2308
2308
  <xdr:nvPicPr>
2309
- <xdr:cNvPr ${ZC(n)}/>
2309
+ <xdr:cNvPr ${eE(n)}/>
2310
2310
  <xdr:cNvPicPr preferRelativeResize="0"/>
2311
2311
  </xdr:nvPicPr>
2312
2312
  <xdr:blipFill>
@@ -2316,6 +2316,9 @@
2316
2316
  </a:stretch>
2317
2317
  </xdr:blipFill>
2318
2318
  <xdr:spPr>
2319
+ <a:xfrm>
2320
+ <a:ext cx="${a}" cy="${l}" />
2321
+ </a:xfrm>
2319
2322
  <a:prstGeom prst="rect">
2320
2323
  <a:avLst/>
2321
2324
  </a:prstGeom>
@@ -2324,71 +2327,71 @@
2324
2327
  </xdr:pic>
2325
2328
  <xdr:clientData fLocksWithSheet="0"/>
2326
2329
  </xdr:twoCellAnchor>
2327
- `}function $y(e){return $e(e)?KC``:KC`
2330
+ `}function Yy(e){return $e(e)?sE``:sE`
2328
2331
  <font>
2329
- ${e.bold?KC`<b />`:""}
2330
- ${e.italic?KC`<i />`:""}
2331
- ${e.underline?KC`<u />`:""}
2332
- ${e.strike?KC`<strike />`:""}
2333
- ${e.size?KC`<sz val="${e.size}" />`:""}
2334
- ${e.color&&e.color.rgb?KC`<color rgb="${Cg(e.color.rgb)}" />`:""}
2335
- ${e.name?KC`<name val="${e.name}" />`:""}
2332
+ ${e.bold?sE`<b />`:""}
2333
+ ${e.italic?sE`<i />`:""}
2334
+ ${e.underline?sE`<u />`:""}
2335
+ ${e.strike?sE`<strike />`:""}
2336
+ ${e.size?sE`<sz val="${e.size}" />`:""}
2337
+ ${e.color&&e.color.rgb?sE`<color rgb="${Rg(e.color.rgb)}" />`:""}
2338
+ ${e.name?sE`<name val="${e.name}" />`:""}
2336
2339
  </font>
2337
- `}function Wy(e){return e?ZC([["style",e.style]]):KC``}function Gy(e){return e?KC`
2338
- <color ${ZC([["rgb",Cg(e.color.rgb)]])}/>
2339
- `:KC``}const qy=KC`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function Zy(e,t,o){const i=KC`
2340
- <table ${ZC([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",nS.table],["xmlns:xr",nS.revision],["xmlns:xr3",nS.revision3],["xmlns:mc",nS.markupCompatibility]])}>
2341
- ${function(e){const t=[["ref",e.range]];return KC`
2342
- <autoFilter ${ZC(t)}>
2343
- ${XC(function(e){const t=[];for(const o of e.filters){const e=KC`
2344
- <filterColumn ${ZC([["colId",o.colId]])}>
2345
- ${jy(o)}
2340
+ `}function Xy(e){return e?eE([["style",e.style]]):sE``}function Ky(e){return e?sE`
2341
+ <color ${eE([["rgb",Rg(e.color.rgb)]])}/>
2342
+ `:sE``}const Qy=sE`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function Jy(e,t,o){const i=sE`
2343
+ <table ${eE([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",uS.table],["xmlns:xr",uS.revision],["xmlns:xr3",uS.revision3],["xmlns:mc",uS.markupCompatibility]])}>
2344
+ ${function(e){const t=[["ref",e.range]];return sE`
2345
+ <autoFilter ${eE(t)}>
2346
+ ${iE(function(e){const t=[];for(const o of e.filters){const e=sE`
2347
+ <filterColumn ${eE([["colId",o.colId]])}>
2348
+ ${ex(o)}
2346
2349
  </filterColumn>
2347
2350
  `;t.push(e)}return t}(e))}
2348
2351
  </autoFilter>
2349
2352
  `}(e)}
2350
- ${function(e,t){const o=Jo(e.range),i=[];for(const e of Oe(0,pi(o).numberOfCols)){const s=Tt(o.left+e,o.top),r=[["id",e+1],["name",t.cells[s]?.content||`col${e}`]];i.push(KC`<tableColumn ${ZC(r)}/>`)}return KC`
2351
- <tableColumns ${ZC([["count",i.length]])}>
2352
- ${XC(i)}
2353
+ ${function(e,t){const o=Jo(e.range),i=[];for(const e of Oe(0,pi(o).numberOfCols)){const s=Tt(o.left+e,o.top),r=[["id",e+1],["name",t.cells[s]?.content||`col${e}`]];i.push(sE`<tableColumn ${eE(r)}/>`)}return sE`
2354
+ <tableColumns ${eE([["count",i.length]])}>
2355
+ ${iE(i)}
2353
2356
  </tableColumns>
2354
2357
  `}(e,o)}
2355
- ${qy}
2358
+ ${Qy}
2356
2359
  </table>
2357
- `;return jC(i)}function jy(e){const t=e.displayedValues.map((e=>KC`<filter ${ZC([["val",e]])}/>`));return KC`
2358
- <filters ${ZC(e.displayBlanks?[["blank",1]]:[])}>
2359
- ${XC(t)}
2360
+ `;return tE(i)}function ex(e){const t=e.displayedValues.map((e=>sE`<filter ${eE([["val",e]])}/>`));return sE`
2361
+ <filters ${eE(e.displayBlanks?[["blank",1]]:[])}>
2362
+ ${iE(t)}
2360
2363
  </filters>
2361
- `}function Yy(e){if(!Object.values(e).length)return KC``;const t=[];for(let[o,i]of Object.entries(e)){const e=[["min",parseInt(o)+1],["max",parseInt(o)+1],["width",hC(i.size||D)],["customWidth",1],["hidden",i.isHidden?1:0]];t.push(KC`
2362
- <col ${ZC(e)}/>
2363
- `)}return KC`
2364
+ `}function tx(e){if(!Object.values(e).length)return sE``;const t=[];for(let[o,i]of Object.entries(e)){const e=[["min",parseInt(o)+1],["max",parseInt(o)+1],["width",bC(i.size||D)],["customWidth",1],["hidden",i.isHidden?1:0]];t.push(sE`
2365
+ <col ${eE(e)}/>
2366
+ `)}return sE`
2364
2367
  <cols>
2365
- ${XC(t)}
2368
+ ${iE(t)}
2366
2369
  </cols>
2367
- `}function Xy(e,t,o){const i=[];for(let s=0;s<o.rowNumber;s++){const r=[["r",s+1]],n=o.rows[s]||{};r.push(["ht",cC(n.size||L)],["customHeight",1],["hidden",n.isHidden?1:0]);const a=[];for(let i=0;i<o.colNumber;i++){const r=Tt(i,s),n=o.cells[r];if(n){const l=[["r",r]],c=gC(e,uC(n,t));l.push(["s",c]);let h=[],d=KC``;if(n.isFormula)({attrs:h,node:d}=Ty(n));else if(n.content&&De(n.content)){const{label:t}=ke(n.content);({attrs:h,node:d}=Ay(t,e.sharedStrings))}else if(n.content&&""!==n.content){const t=Ky(i,s,o);({attrs:h,node:d}=Ay(n.content,e.sharedStrings,t))}l.push(...h),a.push(KC`
2368
- <c ${ZC(l)}>
2370
+ `}function ox(e,t,o){const i=[];for(let s=0;s<o.rowNumber;s++){const r=[["r",s+1]],n=o.rows[s]||{};r.push(["ht",fC(n.size||L)],["customHeight",1],["hidden",n.isHidden?1:0]);const a=[];for(let i=0;i<o.colNumber;i++){const r=Tt(i,s),n=o.cells[r];if(n){const l=[["r",r]],c=CC(e,SC(n,t));l.push(["s",c]);let h=[],d=sE``;if(n.isFormula)({attrs:h,node:d}=Fy(n));else if(n.content&&De(n.content)){const{label:t}=ke(n.content);({attrs:h,node:d}=Dy(t,e.sharedStrings))}else if(n.content&&""!==n.content){const t=ix(i,s,o);({attrs:h,node:d}=Dy(n.content,e.sharedStrings,t))}l.push(...h),a.push(sE`
2371
+ <c ${eE(l)}>
2369
2372
  ${d}
2370
2373
  </c>
2371
- `)}}(a.length||n.size!==L||n.isHidden)&&i.push(KC`
2372
- <row ${ZC(r)}>
2373
- ${XC(a)}
2374
+ `)}}(a.length||n.size!==L||n.isHidden)&&i.push(sE`
2375
+ <row ${eE(r)}>
2376
+ ${iE(a)}
2374
2377
  </row>
2375
- `)}return KC`
2378
+ `)}return sE`
2376
2379
  <sheetData>
2377
- ${XC(i)}
2380
+ ${iE(i)}
2378
2381
  </sheetData>
2379
- `}function Ky(e,t,o){return o.filterTables.some((o=>{const i=Jo(o.range),s={...i,bottom:i.top};return hi(e,t,s)}))}function Qy(e,t,o){const i=t.sheets[o].cells,s=[];for(const r in i){const n=i[r]?.content;if(n&&De(n)){const{label:i,url:a}=ke(n);if(Ve(a)){const e=Be(a),o=t.sheets.find((t=>t.id===e)),n=[["display",i],["location",o?`${o.name}!A1`:Q],["ref",r]];s.push(KC`
2380
- <hyperlink ${ZC(n)}/>
2381
- `)}else{const t=[["r:id",pC(e.relsFiles,`xl/worksheets/_rels/sheet${o}.xml.rels`,{target:Wi(a),type:hS.hyperlink,targetMode:"External"})],["ref",r]];s.push(KC`
2382
- <hyperlink ${ZC(t)}/>
2383
- `)}}}return s.length?KC`
2382
+ `}function ix(e,t,o){return o.filterTables.some((o=>{const i=Jo(o.range),s={...i,bottom:i.top};return hi(e,t,s)}))}function sx(e,t,o){const i=t.sheets[o].cells,s=[];for(const r in i){const n=i[r]?.content;if(n&&De(n)){const{label:i,url:a}=ke(n);if(Ve(a)){const e=Be(a),o=t.sheets.find((t=>t.id===e)),n=[["display",i],["location",o?`${o.name}!A1`:Q],["ref",r]];s.push(sE`
2383
+ <hyperlink ${eE(n)}/>
2384
+ `)}else{const t=[["r:id",EC(e.relsFiles,`xl/worksheets/_rels/sheet${o}.xml.rels`,{target:Wi(a),type:fS.hyperlink,targetMode:"External"})],["ref",r]];s.push(sE`
2385
+ <hyperlink ${eE(t)}/>
2386
+ `)}}}return s.length?sE`
2384
2387
  <hyperlinks>
2385
- ${XC(s)}
2388
+ ${iE(s)}
2386
2389
  </hyperlinks>
2387
- `:KC``}function Jy(e){if(e.length){const t=e.map((e=>KC`<mergeCell ref="${e}" />`));return KC`
2390
+ `:sE``}function rx(e){if(e.length){const t=e.map((e=>sE`<mergeCell ref="${e}" />`));return sE`
2388
2391
  <mergeCells count="${e.length}">
2389
- ${XC(t)}
2392
+ ${iE(t)}
2390
2393
  </mergeCells>
2391
- `}return KC``}function ex(e){const t=e.panes;let o=KC``;if(t&&(t.xSplit||t.ySplit)){const e=Tt(t.xSplit,t.ySplit),i=t.xSplit?KC`xSplit="${t.xSplit}"`:"",s=t.ySplit?KC`ySplit="${t.ySplit}"`:"",r=t.xSplit?KC`<selection pane="topRight"/>`:"",n=t.ySplit?KC`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?KC`<selection pane="bottomRight"/>`:"";o=KC`
2394
+ `}return sE``}function nx(e){const t=e.panes;let o=sE``;if(t&&(t.xSplit||t.ySplit)){const e=Tt(t.xSplit,t.ySplit),i=t.xSplit?sE`xSplit="${t.xSplit}"`:"",s=t.ySplit?sE`ySplit="${t.ySplit}"`:"",r=t.xSplit?sE`<selection pane="topRight"/>`:"",n=t.ySplit?sE`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?sE`<selection pane="bottomRight"/>`:"";o=sE`
2392
2395
  <pane
2393
2396
  ${i}
2394
2397
  ${s}
@@ -2398,132 +2401,132 @@
2398
2401
  ${r}
2399
2402
  ${n}
2400
2403
  ${a}
2401
- `}return KC`
2404
+ `}return sE`
2402
2405
  <sheetViews>
2403
- <sheetView ${ZC([["showGridLines",e.areGridLinesVisible?1:0],["workbookViewId",0]])}>
2406
+ <sheetView ${eE([["showGridLines",e.areGridLinesVisible?1:0],["workbookViewId",0]])}>
2404
2407
  ${o}
2405
2408
  </sheetView>
2406
2409
  </sheetViews>
2407
- `}function tx(e){const t=[],o={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"bottom"}}],fonts:[{size:q,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const o=[["xmlns",nS.workbook],["xmlns:r",dS]],i=[];for(const[o,s]of Object.entries(e.sheets)){const e=[["state",s.isVisible?"visible":"hidden"],["name",s.name],["sheetId",parseInt(o)+1],["r:id",`rId${parseInt(o)+1}`]];i.push(KC`
2408
- <sheet ${ZC(e)} />
2409
- `),pC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:hS.sheet,target:`worksheets/sheet${o}.xml`})}return GC(jC(KC`
2410
- <workbook ${ZC(o)}>
2410
+ `}function ax(e){const t=[],o={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"bottom"}}],fonts:[{size:q,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const o=[["xmlns",uS.workbook],["xmlns:r",bS]],i=[];for(const[o,s]of Object.entries(e.sheets)){const e=[["state",s.isVisible?"visible":"hidden"],["name",s.name],["sheetId",parseInt(o)+1],["r:id",`rId${parseInt(o)+1}`]];i.push(sE`
2411
+ <sheet ${eE(e)} />
2412
+ `),EC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:fS.sheet,target:`worksheets/sheet${o}.xml`})}return QC(tE(sE`
2413
+ <workbook ${eE(o)}>
2411
2414
  <sheets>
2412
- ${XC(i)}
2415
+ ${iE(i)}
2413
2416
  </sheets>
2414
2417
  </workbook>
2415
- `),"xl/workbook.xml","workbook")}(e,o)),t.push(...function(e,t){const o=[];let i=1;for(const[s,r]of Object.entries(e.sheets)){const n=[["xmlns",nS.worksheet],["xmlns:r",dS]],a=[["defaultRowHeight",cC(L)],["defaultColWidth",hC(D)]],l=ox(r,s,i,t,o);i+=r.filterTables.length;let c=KC``;const h=[];for(const i of r.charts){const r=bC(i.id),n=pC(t.relsFiles,`xl/drawings/_rels/drawing${s}.xml.rels`,{target:`../charts/chart${r}.xml`,type:hS.chart});h.push(n),o.push(GC(vy(i,s,e),`xl/charts/chart${r}.xml`,"chart"))}for(const e of r.images){const i=e.data.mimetype;if(void 0===i)continue;const r=WS[i];if(void 0===r)continue;let n=`image${SC(e.id)}.${r}`;const a=pC(t.relsFiles,`xl/drawings/_rels/drawing${s}.xml.rels`,{target:`../media/${n}`,type:hS.image});h.push(a),o.push({path:`xl/media/${n}`,imageSrc:e.data.path})}const d=[...r.charts,...r.images];if(d.length){const e=pC(t.relsFiles,`xl/worksheets/_rels/sheet${s}.xml.rels`,{target:`../drawings/drawing${s}.xml`,type:hS.drawing});o.push(GC(Uy(h,r,d),`xl/drawings/drawing${s}.xml`,"drawing")),c=KC`<drawing r:id="${e}" />`}const u=KC`
2416
- <worksheet ${ZC(n)}>
2417
- ${ex(r)}
2418
- <sheetFormatPr ${ZC(a)} />
2419
- ${Yy(r.cols)}
2420
- ${Xy(t,e,r)}
2421
- ${Jy(r.merges)}
2422
- ${XC(My(t.dxfs,r.conditionalFormats))}
2423
- ${Qy(t,e,s)}
2418
+ `),"xl/workbook.xml","workbook")}(e,o)),t.push(...function(e,t){const o=[];let i=1;for(const[s,r]of Object.entries(e.sheets)){const n=[["xmlns",uS.worksheet],["xmlns:r",bS]],a=[["defaultRowHeight",fC(L)],["defaultColWidth",bC(D)]],l=lx(r,s,i,t,o);i+=r.filterTables.length;let c=sE``;const h=[];for(const i of r.charts){const r=xC(i.id),n=EC(t.relsFiles,`xl/drawings/_rels/drawing${s}.xml.rels`,{target:`../charts/chart${r}.xml`,type:fS.chart});h.push(n),o.push(QC(xy(i,s,e),`xl/charts/chart${r}.xml`,"chart"))}for(const e of r.images){const i=e.data.mimetype;if(void 0===i)continue;const r=XS[i];if(void 0===r)continue;let n=`image${RC(e.id)}.${r}`;const a=EC(t.relsFiles,`xl/drawings/_rels/drawing${s}.xml.rels`,{target:`../media/${n}`,type:fS.image});h.push(a),o.push({path:`xl/media/${n}`,imageSrc:e.data.path})}const d=[...r.charts,...r.images];if(d.length){const e=EC(t.relsFiles,`xl/worksheets/_rels/sheet${s}.xml.rels`,{target:`../drawings/drawing${s}.xml`,type:fS.drawing});o.push(QC(Wy(h,r,d),`xl/drawings/drawing${s}.xml`,"drawing")),c=sE`<drawing r:id="${e}" />`}const u=sE`
2419
+ <worksheet ${eE(n)}>
2420
+ ${nx(r)}
2421
+ <sheetFormatPr ${eE(a)} />
2422
+ ${tx(r.cols)}
2423
+ ${ox(t,e,r)}
2424
+ ${rx(r.merges)}
2425
+ ${iE(ky(t.dxfs,r.conditionalFormats))}
2426
+ ${sx(t,e,s)}
2424
2427
  ${c}
2425
2428
  ${l}
2426
2429
  </worksheet>
2427
- `;o.push(GC(jC(u),`xl/worksheets/sheet${s}.xml`,"sheet"))}return pC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:hS.sharedStrings,target:"sharedStrings.xml"}),pC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:hS.styles,target:"styles.xml"}),o}(e,o)),t.push(function(e){const t=KC`
2428
- <styleSheet ${ZC([["xmlns",nS.styleSheet],["xmlns:r",dS]])}>
2429
- ${function(e){const t=[];for(let[o,i]of Object.entries(e)){const e=[["numFmtId",parseInt(o)+vS],["formatCode",i.format]];t.push(KC`
2430
- <numFmt ${ZC(e)}/>
2431
- `)}return KC`
2430
+ `;o.push(QC(tE(u),`xl/worksheets/sheet${s}.xml`,"sheet"))}return EC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:fS.sharedStrings,target:"sharedStrings.xml"}),EC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:fS.styles,target:"styles.xml"}),o}(e,o)),t.push(function(e){const t=sE`
2431
+ <styleSheet ${eE([["xmlns",uS.styleSheet],["xmlns:r",bS]])}>
2432
+ ${function(e){const t=[];for(let[o,i]of Object.entries(e)){const e=[["numFmtId",parseInt(o)+xS],["formatCode",i.format]];t.push(sE`
2433
+ <numFmt ${eE(e)}/>
2434
+ `)}return sE`
2432
2435
  <numFmts count="${e.length}">
2433
- ${XC(t)}
2436
+ ${iE(t)}
2434
2437
  </numFmts>
2435
2438
  `}(e.numFmts)}
2436
- ${o=e.fonts,KC`
2439
+ ${o=e.fonts,sE`
2437
2440
  <fonts count="${o.length}">
2438
- ${XC(Object.values(o).map($y))}
2441
+ ${iE(Object.values(o).map(Yy))}
2439
2442
  </fonts>
2440
2443
  `}
2441
- ${function(e){const t=[];for(let o of Object.values(e))void 0!==o.reservedAttribute?t.push(KC`
2444
+ ${function(e){const t=[];for(let o of Object.values(e))void 0!==o.reservedAttribute?t.push(sE`
2442
2445
  <fill>
2443
2446
  <patternFill patternType="${o.reservedAttribute}" />
2444
2447
  </fill>
2445
- `):t.push(KC`
2448
+ `):t.push(sE`
2446
2449
  <fill>
2447
2450
  <patternFill patternType="solid">
2448
- <fgColor rgb="${Cg(o.fgColor.rgb)}" />
2451
+ <fgColor rgb="${Rg(o.fgColor.rgb)}" />
2449
2452
  <bgColor indexed="64" />
2450
2453
  </patternFill>
2451
2454
  </fill>
2452
- `);return KC`
2455
+ `);return sE`
2453
2456
  <fills count="${e.length}">
2454
- ${XC(t)}
2457
+ ${iE(t)}
2455
2458
  </fills>
2456
2459
  `}(e.fills)}
2457
- ${function(e){const t=[];for(let o of Object.values(e))t.push(KC`
2460
+ ${function(e){const t=[];for(let o of Object.values(e))t.push(sE`
2458
2461
  <border>
2459
- <left ${Wy(o.left)}>
2460
- ${Gy(o.left)}
2462
+ <left ${Xy(o.left)}>
2463
+ ${Ky(o.left)}
2461
2464
  </left>
2462
- <right ${Wy(o.right)}>
2463
- ${Gy(o.right)}
2465
+ <right ${Xy(o.right)}>
2466
+ ${Ky(o.right)}
2464
2467
  </right>
2465
- <top ${Wy(o.top)}>
2466
- ${Gy(o.top)}
2468
+ <top ${Xy(o.top)}>
2469
+ ${Ky(o.top)}
2467
2470
  </top>
2468
- <bottom ${Wy(o.bottom)}>
2469
- ${Gy(o.bottom)}
2471
+ <bottom ${Xy(o.bottom)}>
2472
+ ${Ky(o.bottom)}
2470
2473
  </bottom>
2471
- <diagonal ${Wy(o.diagonal)}>
2472
- ${Gy(o.diagonal)}
2474
+ <diagonal ${Xy(o.diagonal)}>
2475
+ ${Ky(o.diagonal)}
2473
2476
  </diagonal>
2474
2477
  </border>
2475
- `);return KC`
2478
+ `);return sE`
2476
2479
  <borders count="${e.length}">
2477
- ${XC(t)}
2480
+ ${iE(t)}
2478
2481
  </borders>
2479
2482
  `}(e.borders)}
2480
- ${function(e){const t=[];for(let o of e){const e=[["numFmtId",o.numFmtId],["fillId",o.fillId],["fontId",o.fontId],["borderId",o.borderId]],i=[];o.alignment&&o.alignment.vertical&&i.push(["vertical",o.alignment.vertical]),o.alignment&&o.alignment.horizontal&&i.push(["horizontal",o.alignment.horizontal]),o.alignment&&o.alignment.wrapText&&i.push(["wrapText","1"]),i.length>0?(e.push(["applyAlignment","1"]),t.push(KC`<xf ${ZC(e)}>${KC`<alignment ${ZC(i)} />`}</xf> `)):t.push(KC`<xf ${ZC(e)} />`)}return KC`
2483
+ ${function(e){const t=[];for(let o of e){const e=[["numFmtId",o.numFmtId],["fillId",o.fillId],["fontId",o.fontId],["borderId",o.borderId]],i=[];o.alignment&&o.alignment.vertical&&i.push(["vertical",o.alignment.vertical]),o.alignment&&o.alignment.horizontal&&i.push(["horizontal",o.alignment.horizontal]),o.alignment&&o.alignment.wrapText&&i.push(["wrapText","1"]),i.length>0?(e.push(["applyAlignment","1"]),t.push(sE`<xf ${eE(e)}>${sE`<alignment ${eE(i)} />`}</xf> `)):t.push(sE`<xf ${eE(e)} />`)}return sE`
2481
2484
  <cellXfs count="${e.length}">
2482
- ${XC(t)}
2485
+ ${iE(t)}
2483
2486
  </cellXfs>
2484
2487
  `}(e.styles)}
2485
- ${function(e){const t=[];for(const o of e){let e=KC``;o.font&&(e=$y(o.font));let i=KC``;o.fill&&(i=KC`
2488
+ ${function(e){const t=[];for(const o of e){let e=sE``;o.font&&(e=Yy(o.font));let i=sE``;o.fill&&(i=sE`
2486
2489
  <fill>
2487
2490
  <patternFill>
2488
- <bgColor rgb="${Cg(o.fill.fgColor.rgb)}" />
2491
+ <bgColor rgb="${Rg(o.fill.fgColor.rgb)}" />
2489
2492
  </patternFill>
2490
2493
  </fill>
2491
- `),t.push(KC`
2494
+ `),t.push(sE`
2492
2495
  <dxf>
2493
2496
  ${e}
2494
2497
  ${i}
2495
2498
  </dxf>
2496
- `)}return KC`
2499
+ `)}return sE`
2497
2500
  <dxfs count="${e.length}">
2498
- ${XC(t)}
2501
+ ${iE(t)}
2499
2502
  </dxfs>
2500
2503
  `}(e.dxfs)}
2501
2504
  </styleSheet>
2502
- `;var o;return GC(jC(t),"xl/styles.xml","styles")}(o)),t.push(function(e){const t=[["xmlns",nS.sst],["count",e.length],["uniqueCount",e.length]],o=e.map((e=>KC`<si><t>${e}</t></si>`));return GC(jC(KC`
2503
- <sst ${ZC(t)}>
2504
- ${XC(o)}
2505
+ `;var o;return QC(tE(t),"xl/styles.xml","styles")}(o)),t.push(function(e){const t=[["xmlns",uS.sst],["count",e.length],["uniqueCount",e.length]],o=e.map((e=>sE`<si><t>${e}</t></si>`));return QC(tE(sE`
2506
+ <sst ${eE(t)}>
2507
+ ${iE(o)}
2505
2508
  </sst>
2506
- `),"xl/sharedStrings.xml","sharedStrings")}(o.sharedStrings)),t.push(...function(e){const t=[];for(const o of e){const e=[];for(const t of o.rels){const o=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&o.push(["TargetMode",t.targetMode]),e.push(KC`
2507
- <Relationship ${ZC(o)} />
2508
- `)}const i=KC`
2509
- <Relationships xmlns="${nS.Relationships}">
2510
- ${XC(e)}
2509
+ `),"xl/sharedStrings.xml","sharedStrings")}(o.sharedStrings)),t.push(...function(e){const t=[];for(const o of e){const e=[];for(const t of o.rels){const o=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&o.push(["TargetMode",t.targetMode]),e.push(sE`
2510
+ <Relationship ${eE(o)} />
2511
+ `)}const i=sE`
2512
+ <Relationships xmlns="${uS.Relationships}">
2513
+ ${iE(e)}
2511
2514
  </Relationships>
2512
- `;t.push(GC(jC(i),o.path))}return t}(o.relsFiles)),t.push(function(e){const t=[],o=Object.entries(WS).map((([e,t])=>function(e,t){return KC`
2515
+ `;t.push(QC(tE(i),o.path))}return t}(o.relsFiles)),t.push(function(e){const t=[],o=Object.entries(XS).map((([e,t])=>function(e,t){return sE`
2513
2516
  <Default Extension="${e}" ContentType="${t}" />
2514
- `}(t,e)));for(const o of e)"contentType"in o&&o.contentType&&t.push(YC("/"+o.path,cS[o.contentType]));const i=[["Extension","rels"],["ContentType","application/vnd.openxmlformats-package.relationships+xml"]],s=[["Extension","xml"],["ContentType","application/xml"]];return GC(jC(KC`
2515
- <Types xmlns="${nS.Types}">
2516
- ${XC(Object.values(o))}
2517
- <Default ${ZC(i)} />
2518
- <Default ${ZC(s)} />
2519
- ${XC(t)}
2517
+ `}(t,e)));for(const o of e)"contentType"in o&&o.contentType&&t.push(oE("/"+o.path,mS[o.contentType]));const i=[["Extension","rels"],["ContentType","application/vnd.openxmlformats-package.relationships+xml"]],s=[["Extension","xml"],["ContentType","application/xml"]];return QC(tE(sE`
2518
+ <Types xmlns="${uS.Types}">
2519
+ ${iE(Object.values(o))}
2520
+ <Default ${eE(i)} />
2521
+ <Default ${eE(s)} />
2522
+ ${iE(t)}
2520
2523
  </Types>
2521
- `),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",hS.document],["Target","xl/workbook.xml"]];return GC(jC(KC`
2522
- <Relationships xmlns="${nS.Relationships}">
2523
- <Relationship ${ZC(e)} />
2524
+ `),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",fS.document],["Target","xl/workbook.xml"]];return QC(tE(sE`
2525
+ <Relationships xmlns="${uS.Relationships}">
2526
+ <Relationship ${eE(e)} />
2524
2527
  </Relationships>
2525
- `),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function ox(e,t,o,i,s){let r=o;if(!e.filterTables.length)return new oS("");const n=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const o=pC(i.relsFiles,n,{target:`../tables/table${r}.xml`,type:hS.table});s.push(GC(Zy(t,r,e),`xl/tables/table${r}.xml`,"table")),a.push(KC`<tablePart r:id="${o}" />`),r++}return KC`
2528
+ `),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function lx(e,t,o,i,s){let r=o;if(!e.filterTables.length)return new lS("");const n=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const o=EC(i.relsFiles,n,{target:`../tables/table${r}.xml`,type:fS.table});s.push(QC(Jy(t,r,e),`xl/tables/table${r}.xml`,"table")),a.push(sE`<tablePart r:id="${o}" />`),r++}return sE`
2526
2529
  <tableParts count="${e.filterTables.length}">
2527
- ${XC(a)}
2530
+ ${iE(a)}
2528
2531
  </tableParts>
2529
- `}var ix;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(ix||(ix={}));function sx(e,t={}){const o=Se(t);return o.type=e,o}const rx={},nx={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:_,HEADER_WIDTH:F,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:D,DEFAULT_CELL_HEIGHT:L,SCROLLBAR_WIDTH:P},ax={autofillModifiersRegistry:Js,autofillRulesRegistry:er,cellMenuRegistry:tf,colMenuRegistry:Eb,linkMenuRegistry:fg,functionRegistry:Jd,featurePluginRegistry:Nw,statefulUIPluginRegistry:Mw,coreViewsPluginRegistry:_w,corePluginRegistry:Ow,rowMenuRegistry:xb,sidePanelRegistry:rv,figureRegistry:Op,chartSidePanelComponentRegistry:qb,chartComponentRegistry:xp,chartRegistry:yp,topbarMenuRegistry:Ib,topbarComponentRegistry:nv,clickableCellRegistry:Fw,otRegistry:Rb,inverseCommandRegistry:Fp,urlRegistry:Gi,cellPopoverRegistry:Sg,numberFormatMenuRegistry:wb,repeatLocalCommandTransformRegistry:uw,repeatCommandTransformRegistry:dw},lx={arg:Nr,toBoolean:ys,toJsDate:xs,toNumber:ms,toString:Cs,toXC:Tt,toZone:Jo,toCartesian:Rt,numberToLetters:Et,UuidGenerator:Ni,formatValue:vo,computeTextWidth:xe,createEmptyWorkbookData:wE,createEmptySheet:EE,createEmptyExcelSheet:yE,getDefaultChartJsRuntime:Kg,chartFontColor:Dg,ChartColors:Fg,EvaluationError:c,CellErrorLevel:l,getFillingMode:tp,rgbaToHex:mt,colorToRGBA:ft,positionToZone:Ei,isDefined:He,lazy:qe,genericRepeat:gw},cx={isMarkdownLink:De,parseMarkdownLink:ke,markdownLink:Pe,openLink:Xi,urlRepresentation:Yi},hx={ChartPanel:Zb,ChartFigure:Rp,ChartJsComponent:Mi,Grid:tS,GridOverlay:Vv,ScorecardChart:zi,LineConfigPanel:$b,LineBarPieDesignPanel:zb,BarConfigPanel:Fb,LineBarPieConfigPanel:_b,GaugeChartConfigPanel:Bb,GaugeChartDesignPanel:Hb,ScorecardChartConfigPanel:Wb,ScorecardChartDesignPanel:Gb,FigureComponent:av};const dx={DEFAULT_LOCALE:oo};e.AbstractChart=Eg,e.CorePlugin=IE,e.DispatchResult=ns,e.EvaluationError=c,e.Model=class extends qE{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},i=[],s=new Ni,r=!0){super(),i=SE(e,i);const n=bE(e,r);this.state=new my,this.uuidGenerator=s,this.config=this.setupConfig(o),this.session=this.setupSession(n.revisionId),this.coreGetters={},this.range=new _E(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new py(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Ow.getAll())this.setupCorePlugin(e,n);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(i);for(let e of _w.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of Mw.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of Nw.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new tw(dy({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},o=e.transportService||new oy;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(to));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session}}checkDispatchAllowed(e){return rs(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e)}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),new ns(t.flat())}checkDispatchAllowedLocalCommand(e){const t=this.uiHandlers.map((t=>t.allowDispatch(e)));return new ns(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(sx(e,t));dispatch=(e,t)=>{const o=sx(e,t);let i=this.status;if(this.getters.isReadonly()&&(s=o,!is.has(s.type)))return new ns(68);var s;if(!this.session.canApplyOptimisticUpdate())return new ns(65);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:s}=this.state.recordChanges((()=>{rs(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,s,i),this.status=0,this.trigger("update");break;case 1:if(rs(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(rs(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return ns.Success};dispatchFromCorePlugin=(e,t)=>{const o=sx(e,t),i=this.status;this.status=2;const s=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(s,o),this.status=i,ns.Success};dispatchToHandlers(e,t){for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=wE();for(let t of this.handlers)t instanceof IE&&t.export(e);return e.revisionId=this.session.getRevisionId()||J,e=Se(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...wE(),sheets:[yE(fE,"Sheet1")]};for(let t of this.handlers)t instanceof xE&&t.exportForExcel(e);return e=Se(e),tx(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=$i,e.Revision=JE,e.SPREADSHEET_DIMENSIONS=nx,e.Spreadsheet=ty,e.UIPlugin=FE,e.__info__=rx,e.addFunction=function(e,t){Jd.add(e,t)},e.astToFormula=_u,e.compile=Gu,e.components=hx,e.constants=dx,e.convertAstNodes=Mu,e.coreTypes=ss,e.findCellInNewZone=Si,e.functionCache=Wu,e.helpers=lx,e.invalidateCFEvaluationCommands=os,e.invalidateDependenciesCommands=ts,e.invalidateEvaluationCommands=es,e.links=cx,e.load=bE,e.parse=Ou,e.readonlyAllowedCommands=is,e.registries=ax,e.setDefaultSheetViewSize=function(e){ue=e},e.setTranslationMethod=function(e){o=e},e.tokenize=au,Object.defineProperty(e,"__esModule",{value:!0}),rx.version="16.4.0-alpha.6",rx.date="2023-06-28T11:40:12.377Z",rx.hash="7d15d3c"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2532
+ `}var cx;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(cx||(cx={}));function hx(e,t={}){const o=Se(t);return o.type=e,o}const dx={},ux={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:_,HEADER_WIDTH:F,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:D,DEFAULT_CELL_HEIGHT:L,SCROLLBAR_WIDTH:P},gx={autofillModifiersRegistry:Js,autofillRulesRegistry:er,cellMenuRegistry:lf,colMenuRegistry:Tb,linkMenuRegistry:wg,functionRegistry:tu,featurePluginRegistry:Pw,statefulUIPluginRegistry:kw,coreViewsPluginRegistry:Uw,corePluginRegistry:Lw,rowMenuRegistry:Nb,sidePanelRegistry:dv,figureRegistry:Lp,chartSidePanelComponentRegistry:Qb,chartComponentRegistry:Np,chartRegistry:Op,topbarMenuRegistry:Mb,topbarComponentRegistry:uv,clickableCellRegistry:Vw,otRegistry:_b,inverseCommandRegistry:Vp,urlRegistry:Gi,cellPopoverRegistry:Ig,numberFormatMenuRegistry:Ab,repeatLocalCommandTransformRegistry:vw,repeatCommandTransformRegistry:bw},px={arg:Nr,toBoolean:ys,toJsDate:xs,toNumber:ms,toString:Cs,toXC:Tt,toZone:Jo,toCartesian:Rt,numberToLetters:Et,UuidGenerator:Ni,formatValue:vo,computeTextWidth:xe,createEmptyWorkbookData:OE,createEmptySheet:AE,createEmptyExcelSheet:NE,getDefaultChartJsRuntime:ip,chartFontColor:zg,ChartColors:Vg,EvaluationError:c,CellErrorLevel:l,getFillingMode:ap,rgbaToHex:mt,colorToRGBA:ft,positionToZone:Ei,isDefined:He,lazy:qe,genericRepeat:Sw},mx={isMarkdownLink:De,parseMarkdownLink:ke,markdownLink:Pe,openLink:Xi,urlRepresentation:Yi},fx={ChartPanel:Jb,ChartFigure:_p,ChartJsComponent:Mi,Grid:aS,GridOverlay:Gv,ScorecardChart:zi,LineConfigPanel:Yb,LineBarPieDesignPanel:qb,BarConfigPanel:Vb,LineBarPieConfigPanel:Ub,GaugeChartConfigPanel:Zb,GaugeChartDesignPanel:jb,ScorecardChartConfigPanel:Xb,ScorecardChartDesignPanel:Kb,FigureComponent:gv};const bx={DEFAULT_LOCALE:oo};e.AbstractChart=Tg,e.CorePlugin=_E,e.DispatchResult=ns,e.EvaluationError=c,e.Model=class extends QE{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},i=[],s=new Ni,r=!0){super(),i=RE(e,i);const n=xE(e,r);this.state=new Ey,this.uuidGenerator=s,this.config=this.setupConfig(o),this.session=this.setupSession(n.revisionId),this.coreGetters={},this.range=new VE(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new Cy(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Lw.getAll())this.setupCorePlugin(e,n);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(i);for(let e of Uw.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of kw.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of Pw.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new aw(by({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},o=e.transportService||new ly;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(to));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session}}checkDispatchAllowed(e){return rs(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e)}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),new ns(t.flat())}checkDispatchAllowedLocalCommand(e){const t=this.uiHandlers.map((t=>t.allowDispatch(e)));return new ns(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(hx(e,t));dispatch=(e,t)=>{const o=hx(e,t);let i=this.status;if(this.getters.isReadonly()&&(s=o,!is.has(s.type)))return new ns(68);var s;if(!this.session.canApplyOptimisticUpdate())return new ns(65);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:s}=this.state.recordChanges((()=>{rs(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,s,i),this.status=0,this.trigger("update");break;case 1:if(rs(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(rs(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return ns.Success};dispatchFromCorePlugin=(e,t)=>{const o=hx(e,t),i=this.status;this.status=2;const s=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(s,o),this.status=i,ns.Success};dispatchToHandlers(e,t){for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=OE();for(let t of this.handlers)t instanceof _E&&t.export(e);return e.revisionId=this.session.getRevisionId()||J,e=Se(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...OE(),sheets:[NE(yE,"Sheet1")]};for(let t of this.handlers)t instanceof ME&&t.exportForExcel(e);return e=Se(e),ax(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=$i,e.Revision=rw,e.SPREADSHEET_DIMENSIONS=ux,e.Spreadsheet=ay,e.UIPlugin=zE,e.__info__=dx,e.addFunction=function(e,t){tu.add(e,t)},e.astToFormula=Pu,e.compile=Yu,e.components=fx,e.constants=bx,e.convertAstNodes=_u,e.coreTypes=ss,e.findCellInNewZone=Si,e.functionCache=ju,e.helpers=px,e.invalidateCFEvaluationCommands=os,e.invalidateDependenciesCommands=ts,e.invalidateEvaluationCommands=es,e.iterateAstNodes=Fu,e.links=mx,e.load=xE,e.parse=Nu,e.readonlyAllowedCommands=is,e.registries=gx,e.setDefaultSheetViewSize=function(e){ue=e},e.setTranslationMethod=function(e){o=e},e.tokenize=lu,Object.defineProperty(e,"__esModule",{value:!0}),dx.version="16.4.0-alpha.7",dx.date="2023-07-04T13:46:24.130Z",dx.hash="b04cf78"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);