@odoo/o-spreadsheet 16.0.47 → 16.0.48

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.
@@ -11375,7 +11375,7 @@ function getPredicate(descr, isQuery) {
11375
11375
  operand = descr;
11376
11376
  }
11377
11377
  }
11378
- if (isNumber(operand)) {
11378
+ if (isNumber(operand) || isDateTime(operand)) {
11379
11379
  operand = toNumber(operand);
11380
11380
  }
11381
11381
  else if (operand === "TRUE" || operand === "FALSE") {
@@ -21622,10 +21622,13 @@ function useCellHovered(env, gridRef, callback) {
21622
21622
  row: undefined,
21623
21623
  };
21624
21624
  const { Date } = window;
21625
- let x = 0;
21626
- let y = 0;
21625
+ let x = undefined;
21626
+ let y = undefined;
21627
21627
  let lastMoved = 0;
21628
21628
  function getPosition() {
21629
+ if (x === undefined || y === undefined) {
21630
+ return { col: -1, row: -1 };
21631
+ }
21629
21632
  const col = env.model.getters.getColIndex(x);
21630
21633
  const row = env.model.getters.getRowIndex(y);
21631
21634
  return { col, row };
@@ -43436,6 +43439,6 @@ exports.setTranslationMethod = setTranslationMethod;
43436
43439
  exports.tokenize = tokenize;
43437
43440
 
43438
43441
 
43439
- __info__.version = '16.0.47';
43440
- __info__.date = '2024-07-08T05:37:37.541Z';
43441
- __info__.hash = 'f52ca6f';
43442
+ __info__.version = '16.0.48';
43443
+ __info__.date = '2024-07-18T14:12:39.369Z';
43444
+ __info__.hash = 'a1be508';
@@ -11371,7 +11371,7 @@ function getPredicate(descr, isQuery) {
11371
11371
  operand = descr;
11372
11372
  }
11373
11373
  }
11374
- if (isNumber(operand)) {
11374
+ if (isNumber(operand) || isDateTime(operand)) {
11375
11375
  operand = toNumber(operand);
11376
11376
  }
11377
11377
  else if (operand === "TRUE" || operand === "FALSE") {
@@ -21618,10 +21618,13 @@ function useCellHovered(env, gridRef, callback) {
21618
21618
  row: undefined,
21619
21619
  };
21620
21620
  const { Date } = window;
21621
- let x = 0;
21622
- let y = 0;
21621
+ let x = undefined;
21622
+ let y = undefined;
21623
21623
  let lastMoved = 0;
21624
21624
  function getPosition() {
21625
+ if (x === undefined || y === undefined) {
21626
+ return { col: -1, row: -1 };
21627
+ }
21625
21628
  const col = env.model.getters.getColIndex(x);
21626
21629
  const row = env.model.getters.getRowIndex(y);
21627
21630
  return { col, row };
@@ -43404,6 +43407,6 @@ function addFunction(functionName, functionDescription) {
43404
43407
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43405
43408
 
43406
43409
 
43407
- __info__.version = '16.0.47';
43408
- __info__.date = '2024-07-08T05:37:37.541Z';
43409
- __info__.hash = 'f52ca6f';
43410
+ __info__.version = '16.0.48';
43411
+ __info__.date = '2024-07-18T14:12:39.369Z';
43412
+ __info__.hash = 'a1be508';
@@ -11372,7 +11372,7 @@
11372
11372
  operand = descr;
11373
11373
  }
11374
11374
  }
11375
- if (isNumber(operand)) {
11375
+ if (isNumber(operand) || isDateTime(operand)) {
11376
11376
  operand = toNumber(operand);
11377
11377
  }
11378
11378
  else if (operand === "TRUE" || operand === "FALSE") {
@@ -21619,10 +21619,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21619
21619
  row: undefined,
21620
21620
  };
21621
21621
  const { Date } = window;
21622
- let x = 0;
21623
- let y = 0;
21622
+ let x = undefined;
21623
+ let y = undefined;
21624
21624
  let lastMoved = 0;
21625
21625
  function getPosition() {
21626
+ if (x === undefined || y === undefined) {
21627
+ return { col: -1, row: -1 };
21628
+ }
21626
21629
  const col = env.model.getters.getColIndex(x);
21627
21630
  const row = env.model.getters.getRowIndex(y);
21628
21631
  return { col, row };
@@ -43435,9 +43438,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43435
43438
  Object.defineProperty(exports, '__esModule', { value: true });
43436
43439
 
43437
43440
 
43438
- __info__.version = '16.0.47';
43439
- __info__.date = '2024-07-08T05:37:37.541Z';
43440
- __info__.hash = 'f52ca6f';
43441
+ __info__.version = '16.0.48';
43442
+ __info__.date = '2024-07-18T14:12:39.369Z';
43443
+ __info__.hash = 'a1be508';
43441
43444
 
43442
43445
 
43443
43446
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -980,7 +980,7 @@
980
980
  opacity: 0;
981
981
  pointer-events: none;
982
982
  }
983
- `;class Ms extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:n}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:o,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return`bottom: ${n-r+15}px;left: ${o-1}px;border: 1px solid ${i};background-color: ${i};${this.props.active?"opacity:1 !important":""}`}}Ms.template="o-spreadsheet-ClientTag";const _s=/(.*?)\((.*?)\)(.*)/,Fs=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function Ds(e){let t=e.split("\n");const i=[];for(let e of t)e=e.trim(),e&&i.push(ks(e));return i}function ks(e){let t,i=e.match(_s),n=i[1].trim(),o=[],r=!1,s=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let n=Fs.find((e=>i===e));n?o.push(n):"RANGE<ANY>"===i?o.push("RANGE"):"OPTIONAL"===i?r=!0:"REPEATING"===i?s=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:n,description:i[3].trim(),type:o};return r&&(l.optional=!0),s&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function $s(e){let t=0,i=0,n=0;for(let o of e.args)t++,o.optional||o.repeating||o.default||i++,o.repeating&&n++;const o=e;return o.minArgRequired=i,o.maxArgPossible=n?1/0:t,o.nbrArgRepeating=n,o.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,n),o}const Ls=["number","string","boolean","undefined"];function Ps(e,t){if(!e())throw new Error(t)}const Us=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Vs(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(Ci(e)||""===e)return wi(e);const t=ve(e);if(t)return t.value;throw new Error(Us(e));default:return 0}}function zs(e){if(""===e)throw new Error(Us(e));return Vs(e)}function Bs(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const Hs=function(e){const t=new Map,i=e.name?e.name+" (memoized)":"memoized";return{[i]:(...i)=>(t.has(i[0])||t.set(i[0],e(...i)),t.get(i[0]))}[i]}((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}));function Ws(e){return"string"==typeof e?Hs(e):e}const Gs=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function qs(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(Gs(e))}return!1;case"number":return!!e;default:return!1}}function Zs(e){return Se(Vs(e))}function js(e,t,i){for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let o=0;o<i;o++)for(let i=0;i<e;i++)t(n[i][o])}else i(n)}function Ys(e,t){js(e,t,t)}function Xs(e,t){js(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(zs(e))}))}function Ks(e,t,i,n){let o=n;for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let r=0;r<i;r++)for(let i=0;i<e;i++)o=t(o,n[i][r])}else o=i(o,n);return o}function Qs(e,t,i){return Ks(e,t,t,i)}function Js(e,t,i){return Ks(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,zs(i))),i)}function ea(e,t,i){return Ks(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Vs(i):0):e),((e,i)=>t(e,Vs(i))),i)}function ta(e,t){return function(e,t,i){for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let o=0;o<i;o++)for(let i=0;i<e;i++)if(!t(n[i][o]))return}else if(!i(n))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(Gs(e));return qs(e)}(e))))}function ia(e,t){let i,n,o=e.substring(0,2);"<="===o||">="===o||"<>"===o?(i=o,n=e.substring(2)):(o=e.substring(0,1),"<"===o||">"===o||"="===o?(i=o,n=e.substring(1)):(i="=",n=e)),Ci(n)?n=Vs(n):"TRUE"!==n&&"FALSE"!==n||(n=qs(n));const r={operator:i,operand:n};return"string"==typeof n&&(t&&(n+="*"),r.regexp=function(e){if("*"===e)return/.+/;let t="",i="";for(let n of e)"?"===n&&"~"!==i?t+=".":"*"===n&&"~"!==i?t+=".*":("*"!==n&&"?"!==n||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(n)&&(t+="\\"),t+=n),i=n;return new RegExp("^"+t+"$","i")}(n)),r}function na(e="",t){const{operator:i,operand:n}=t;if(void 0===n)return!1;if("number"==typeof n&&"="===i)return Bs(e)===Bs(n);if("<>"===i||"="===i){let o;return o=typeof e==typeof n&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===n),"="===i?o:!o}if(typeof e==typeof n)switch(i){case"<":return e<n;case">":return e>n;case"<=":return e<=n;case">=":return e>=n}return!1}function oa(e,t,i=!1){const n=e.length;if(n%2==1)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const o=e[0].length,s=e[0][0].length;let a=[];for(let t=0;t<n-1;t+=2){const n=e[t];if(!Array.isArray(n)||n.length!==o||n[0].length!==s)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Bs(e[t+1]);a.push(ia(l,i))}for(let i=0;i<o;i++)for(let o=0;o<s;o++){let r=!0;for(let t=0;t<n-1;t+=2){if(r=na(e[t][i][o],a[t/2]),!r)break}r&&t(i,o)}}function ra(e,t){return Ws(e[0][t])}function sa(e,t){return Ws(e[t][0])}function aa(e,t,i,n,o,r){if(null==t)return-1;const s=typeof t;let a,l,c,h,d,u,g=0,p=o-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=r(e,h),u=typeof d;g<h&&s!==u;)h--,d=r(e,h),u=typeof d;u===s&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h),"asc"===n&&d>t||"desc"===n&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function la(e,t,i,n,o,r=!1){if(null==t)return-1;const s=r?(e,t)=>o(e,n-t-1):o;let a,l=-1;for(let o=0;o<n;o++){const c=s(e,o);if(c===t)return r?n-o-1:o;"nextSmaller"===i?(!a&&ca(t,c)>=0||ca(t,c)>=0&&ca(c,a)>0)&&(a=c,l=o):"nextGreater"===i&&(!a&&ca(t,c)<=0||ca(t,c)<=0&&ca(c,a)<0)&&(a=c,l=o)}return r?n-l-1:l}function ca(e,t){let i=Ls.indexOf(typeof e)-Ls.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}const ha={description:r("Apply a large number format"),args:Ds(`\n value (number) ${r("The number.")}\n unit (string, optional) ${r("The formatting unit. Use 'k', 'm', or 'b' to force the unit")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Vs(e.value)),n=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return li(n,1e3,"k");case"m":return li(n,1e6,"m");case"b":return li(n,1e9,"b");default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?li(n,0,""):i<1e8?li(n,1e3,"k"):i<1e11?li(n,1e6,"m"):li(n,1e9,"b")},compute:function(e){return Vs(e)}};var da=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:ha});const ua={description:r("Absolute value of a number."),args:Ds(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Vs(e))},isExported:!0},ga={description:r("Inverse cosine of a value, in radians."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},pa={description:r("Inverse hyperbolic cosine of a number."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},ma={description:r("Inverse cotangent of a value."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},fa={description:r("Inverse hyperbolic cotangent of a value."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>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},va={description:r("Inverse sine of a value, in radians."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},ba={description:r("Inverse hyperbolic sine of a number."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Vs(e))},isExported:!0},Sa={description:r("Inverse tangent of a value, in radians."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Vs(e))},isExported:!0},Ca={description:r("Angle from the X axis to a point (x,y), in radians."),args:Ds(`\n x (number) ${r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Vs(t);return Ps((()=>0!==i||0!==n),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(n,i)},isExported:!0},Ea={description:r("Inverse hyperbolic tangent of a number."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},wa={description:r("Rounds number up to nearest multiple of factor."),args:Ds(`\n value (number) ${r("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Vs(e),n=Vs(t);return Ps((()=>n>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),i.toString())),n?Math.ceil(i/n)*n:0},isExported:!0},ya={description:r("Rounds number up to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n 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.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let n=Vs(t);if(0===n)return 0;const o=Vs(e);if(n=Math.abs(n),o>=0)return Math.ceil(o/n)*n;return 0===Vs(i)?-Math.floor(Math.abs(o)/n)*n:-Math.ceil(Math.abs(o)/n)*n},isExported:!0},xa={description:r("Rounds number up to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return ya.compute(e,t,0)},isExported:!0},Ra={description:r("Cosine of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Vs(e))},isExported:!0},Ia={description:r("Hyperbolic cosine of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Vs(e))},isExported:!0},Ta={description:r("Cotangent of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Aa={description:r("Hyperbolic cotangent of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Oa={description:r("Number of empty values."),args:Ds(`\n value1 (any, range) ${r("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${r("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return Qs(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Na={description:r("A conditional count across a range."),args:Ds(`\n range (range) ${r("The range that is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return oa(e,((e,i)=>{t+=1})),t},isExported:!0},Ma={description:r("Count values depending on multiple criteria."),args:Ds(`\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n 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.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return oa(e,((e,i)=>{t+=1})),t},isExported:!0};function _a(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Fa={description:r("Counts number of unique values in a range."),args:Ds(`\n value1 (any, range) ${r("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return Qs(e,((e,t)=>_a(t)?e.add(t):e),new Set).size}},Da={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:Ds(`\n range (range) ${r("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n 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.")}\n 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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=new Set;return oa(t,((t,n)=>{const o=e[t][n];_a(o)&&i.add(o)})),i.size}},ka={description:r("Cosecant of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},$a={description:r("Hyperbolic cosecant of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},La={description:r("Converts from another base to decimal."),args:Ds(`\n value (string) ${r("The number to convert.")},\n base (number) ${r("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let i=Vs(t);i=Math.floor(i),Ps((()=>2<=i&&i<=36),r("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const n=Bs(e);if(""===n)return 0;Ps((()=>!!n.match(/^-?[a-z0-9]+$/i)),r("The value (%s) must be a valid base %s representation.",n,i.toString()));const o=parseInt(n,i);return Ps((()=>!isNaN(o)),r("The value (%s) must be a valid base %s representation.",n,i.toString())),o},isExported:!0},Pa={description:r("Converts an angle value in radians to degrees."),args:Ds(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Vs(e)/Math.PI},isExported:!0},Ua={description:r("Euler's number, e (~2.718) raised to a power."),args:Ds(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Vs(e))},isExported:!0},Va={description:r("Rounds number down to nearest multiple of factor."),args:Ds(`\n value (number) ${r("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Vs(e),n=Vs(t);return Ps((()=>n>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),i.toString())),n?Math.floor(i/n)*n:0},isExported:!0},za={description:r("Rounds number down to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n 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.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let n=Vs(t);if(0===n)return 0;const o=Vs(e);if(n=Math.abs(n),o>=0)return Math.floor(o/n)*n;return 0===Vs(i)?-Math.ceil(Math.abs(o)/n)*n:-Math.floor(Math.abs(o)/n)*n},isExported:!0},Ba={description:r("Rounds number down to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return za.compute(e,t,0)},isExported:!0},Ha={description:r("Whether the provided value is even."),args:Ds(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=zs(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Wa={description:r("Rounds number up to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return ya.compute(e,t,0)},isExported:!0},Ga={description:r("Whether the provided value is even."),args:Ds(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=zs(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},qa={description:r("The logarithm of a number, base e (euler's number)."),args:Ds(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Za={description:r("Modulo (remainder) operator."),args:Ds(`\n dividend (number) ${r("The number to be divided to find the remainder.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Vs(t);Ps((()=>0!==i),r("The divisor must be different from 0."));const n=Vs(e)%i;return n>0&&i<0||n<0&&i>0?n+i:n},isExported:!0},ja={description:r("Rounds a number up to the nearest odd integer."),args:Ds(`\n value (number) ${r("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Vs(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},Ya={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Xa={description:r("A number raised to a power."),args:Ds(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Vs(e),n=Vs(t);return Ps((()=>i>=0||Number.isInteger(n)),r("The exponent (%s) must be an integer when the base is negative.",n.toString())),Math.pow(i,n)},isExported:!0},Ka={description:r("Result of multiplying a series of numbers together."),args:Ds(`\n factor1 (number, range<number>) ${r("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${r("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let n of e)if(Array.isArray(n))for(let e of n)for(let n of e)"number"==typeof n&&(i*=n,t+=1);else null!=n&&(i*=zs(n),t+=1);return 0===t?0:i},isExported:!0},Qa={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ja={description:r("Random integer between two values, inclusive."),args:Ds(`\n low (number) ${r("The low end of the random range.")}\n high (number) ${r("The high end of the random range.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Vs(e);Number.isInteger(i)||(i=Math.ceil(i));let n=Vs(t);return Number.isInteger(n)||(n=Math.floor(n)),Ps((()=>i<=n),r("The high (%s) must be greater than or equal to the low (%s).",n.toString(),i.toString())),i+Math.ceil((n-i+1)*Math.random())-1},isExported:!0},el={description:r("Rounds a number according to standard rules."),args:Ds(`\n value (number) ${r("The value to round to places number of places.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Vs(e);let n=Vs(t);const o=Math.abs(i);let r;return 0===n?r=Math.round(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.round(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},tl={description:r("Rounds down a number."),args:Ds(`\n value (number) ${r("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Vs(e);let n=Vs(t);const o=Math.abs(i);let r;return 0===n?r=Math.floor(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.floor(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},il={description:r("Rounds up a number."),args:Ds(`\n value (number) ${r("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Vs(e);let n=Vs(t);const o=Math.abs(i);let r;return 0===n?r=Math.ceil(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.ceil(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},nl={description:r("Secant of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Vs(e))},isExported:!0},ol={description:r("Hyperbolic secant of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Vs(e))},isExported:!0},rl={description:r("Sine of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Vs(e))},isExported:!0},sl={description:r("Hyperbolic sine of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Vs(e))},isExported:!0},al={description:r("Positive square root of a positive number."),args:Ds(`\n value (number) ${r("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Vs(e);return Ps((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},ll={description:r("Sum of a series of numbers and/or cells."),args:Ds(`\n value1 (number, range<number>) ${r("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${r("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return Js(e,((e,t)=>e+t),0)},isExported:!0},cl={description:r("A conditional sum across a range."),args:Ds(`\n criteria_range (range) ${r("The range which is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${r("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let n=0;return oa([e,t],((e,t)=>{const o=i[e][t];"number"==typeof o&&(n+=o)})),n},isExported:!0},hl={description:r("Sums a range depending on multiple criteria."),args:Ds(`\n sum_range (range) ${r("The range to sum.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges to check.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0;return oa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i+=o)})),i},isExported:!0},dl={description:r("Tangent of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Vs(e))},isExported:!0},ul={description:r("Hyperbolic tangent of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Vs(e))},isExported:!0},gl={description:r("Truncates a number."),args:Ds(`\n value (number) ${r("The value to be truncated.")}\n places (number, default=0) ${r("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Vs(e);let n=Vs(t);return 0===n?Math.trunc(i):(Number.isInteger(n)||(n=Math.trunc(n)),Math.trunc(i*Math.pow(10,n))/Math.pow(10,n))},isExported:!0};var pl=Object.freeze({__proto__:null,ABS:ua,ACOS:ga,ACOSH:pa,ACOT:ma,ACOTH:fa,ASIN:va,ASINH:ba,ATAN:Sa,ATAN2:Ca,ATANH:Ea,CEILING:wa,CEILING_MATH:ya,CEILING_PRECISE:xa,COS:Ra,COSH:Ia,COT:Ta,COTH:Aa,COUNTBLANK:Oa,COUNTIF:Na,COUNTIFS:Ma,COUNTUNIQUE:Fa,COUNTUNIQUEIFS:Da,CSC:ka,CSCH:$a,DECIMAL:La,DEGREES:Pa,EXP:Ua,FLOOR:Va,FLOOR_MATH:za,FLOOR_PRECISE:Ba,ISEVEN:Ha,ISO_CEILING:Wa,ISODD:Ga,LN:qa,MOD:Za,ODD:ja,PI:Ya,POWER:Xa,PRODUCT:Ka,RAND:Qa,RANDBETWEEN:Ja,ROUND:el,ROUNDDOWN:tl,ROUNDUP:il,SEC:nl,SECH:ol,SIN:rl,SINH:sl,SQRT:al,SUM:ll,SUMIF:cl,SUMIFS:hl,TAN:dl,TANH:ul,TRUNC:gl});function ml(e,t,i){let n=[],o=[],s=0,a=0;Ys([e],(e=>{n.push(e),s+=1})),Ys([t],(e=>{o.push(e),a+=1})),Ps((()=>s===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",s.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<s;e++){const t=n[e],i=o[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}Ps((()=>0!==l&&(!i||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<s;e++){const t=n[e],i=o[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function fl(e,t,i){let n=0,o=0;const s=i?ea:Js;o=s(e,((e,t)=>(n+=1,e+t)),0),Ps((()=>0!==n&&(!t||1!==n)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=o/n;return s(e,((e,t)=>e+Math.pow(t-a,2)),0)/(n-(t?1:0))}function vl(e,t,i){const n=Vs(t);Ps((()=>i?0<=n&&n<=1:0<n&&n<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let o,s=[],a=0;return Ys(e,(e=>{"number"==typeof e&&(o=aa(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(o+1,0,e),a++)})),Ps((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),i||Ps((()=>1/(a+1)<=n&&n<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),yi(s,n,i)}const bl={description:r("Average magnitude of deviations from mean."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const i=Js(e,((e,i)=>(t+=1,e+i)),0);Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const n=i/t;return Js(e,((e,t)=>e+Math.abs(n-t)),0)/t},isExported:!0},Sl={description:r("Numerical average value in a dataset, ignoring text."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Js(e,((e,i)=>(t+=1,e+i)),0);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Cl=r("[[FUNCTION_NAME]] has mismatched range sizes."),El=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),wl={description:r("Weighted average."),args:Ds(`\n values (number, range<number>) ${r("Values to average.")}\n weights (number, range<number>) ${r("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${r("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${r("Additional weights.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,n=0,o=0;Ps((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let s=0;s<e.length-1;s+=2)if(t=e[s],i=e[s+1],Array.isArray(t)){Ps((()=>Array.isArray(i)),Cl);let e=t.length,s=t[0].length;Ps((()=>e===i.length&&s===i[0].length),Cl);for(let a=0;a<e;a++)for(let e=0;e<s;e++){let s=t[a][e],l=i[a][e],c="number"==typeof s,h="number"==typeof l;Ps((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(Ps((()=>l>=0),El),n+=s*l,o+=l)}}else i=Vs(i),t=Vs(t),Ps((()=>i>=0),El),n+=t*i,o+=i;return Ps((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o}},yl={description:r("Numerical average value in a dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=ea(e,((e,i)=>(t+=1,e+i)),0);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},xl={description:r("Average of values depending on criteria."),args:Ds(`\n criteria_range (range) ${r("The range to check against criterion.")}\n criterion (string) ${r("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${r("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let n=0,o=0;return oa([e,t],((t,r)=>{const s=(i||e)[t][r];"number"==typeof s&&(n+=1,o+=s)})),Ps((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n},isExported:!0},Rl={description:r("Average of values depending on multiple criteria."),args:Ds(`\n average_range (range) ${r("The range to average.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0,n=0;return oa(t,((t,o)=>{const r=e[t][o];"number"==typeof r&&(i+=1,n+=r)})),Ps((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i},isExported:!0},Il={description:r("The number of numeric values in dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||Ci(i)||ve(i))&&(t+=1);return t},isExported:!0},Tl={description:r("The number of values in a dataset."),args:Ds(`\n value1 (any, range) ${r("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return Qs(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Al={description:r("The covariance of a dataset."),args:Ds(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ml(e,t,!1)},isExported:!0},Ol={description:r("The covariance of a dataset."),args:Ds(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ml(e,t,!1)},isExported:!0},Nl={description:r("The sample covariance of a dataset."),args:Ds(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ml(e,t,!0)},isExported:!0},Ml={description:r("Nth largest element from a data set."),args:Ds(`\n data (any, range) ${r("Array or range containing the dataset to consider.")}\n n (number) ${r("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Vs(t));let n,o=[],s=0;Ys([e],(e=>{"number"==typeof e&&(n=aa(o,e,"nextSmaller","asc",o.length,((e,t)=>e[t])),o.splice(n+1,0,e),s++,s>i&&(o.shift(),s--))}));const a=o.shift();return Ps((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Ps((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},_l={description:r("Maximum value in a numeric dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Js(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Fl={description:r("Maximum numeric value in a dataset."),args:Ds(`\n value1 (any, range) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=ea(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Dl={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:Ds(`\n range (range) ${r("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n 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.")}\n 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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return oa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i<o?o:i)})),i===-1/0?0:i},isExported:!0},kl={description:r("Median value in a numeric dataset."),args:Ds(`\n value1 (any, range) ${r("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return Xs(e,(e=>{t.push(e)})),vl(t,.5,!0)},isExported:!0},$l={description:r("Minimum value in a numeric dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Js(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Ll={description:r("Minimum numeric value in a dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=ea(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Pl={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:Ds(`\n range (range) ${r("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n 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.")}\n 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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=1/0;return oa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i>o?o:i)})),i===1/0?0:i},isExported:!0},Ul={description:r("Value at a given percentile of a dataset."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return zl.compute(e,t)},isExported:!0},Vl={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return vl([e],t,!1)},isExported:!0},zl={description:r("Value at a given percentile of a dataset."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return vl([e],t,!0)},isExported:!0},Bl={description:r("Value nearest to a specific quartile of a dataset."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Wl.compute(e,t)},isExported:!0},Hl={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return vl([e],.25*Math.trunc(Vs(t)),!1)},isExported:!0},Wl={description:r("Value nearest to a specific quartile of a dataset."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return vl([e],.25*Math.trunc(Vs(t)),!0)},isExported:!0},Gl={description:r("Nth smallest element in a data set."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n n (number) ${r("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Vs(t));let n,o=[],s=0;Ys([e],(e=>{"number"==typeof e&&(n=aa(o,e,"nextSmaller","asc",o.length,((e,t)=>e[t])),o.splice(n+1,0,e),s++,s>i&&(o.pop(),s--))}));const a=o.pop();return Ps((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Ps((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},ql={description:r("Standard deviation."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ql.compute(...e))},isExported:!0},Zl={description:r("Standard deviation of entire population."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Jl.compute(...e))},isExported:!0},jl={description:r("Standard deviation."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(ec.compute(...e))},isExported:!0},Yl={description:r("Standard deviation of sample (text as 0)."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(tc.compute(...e))},isExported:!0},Xl={description:r("Standard deviation of entire population."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(ic.compute(...e))},isExported:!0},Kl={description:r("Standard deviation of entire population (text as 0)."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(nc.compute(...e))},isExported:!0},Ql={description:r("Variance."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!0,!1)},isExported:!0},Jl={description:r("Variance of entire population."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!1,!1)},isExported:!0},ec={description:r("Variance."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!0,!1)},isExported:!0},tc={description:r("Variance of sample (text as 0)."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!0,!0)},isExported:!0},ic={description:r("Variance of entire population."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!1,!1)},isExported:!0},nc={description:r("Variance of entire population (text as 0)."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!1,!0)},isExported:!0};var oc=Object.freeze({__proto__:null,AVEDEV:bl,AVERAGE:Sl,AVERAGE_WEIGHTED:wl,AVERAGEA:yl,AVERAGEIF:xl,AVERAGEIFS:Rl,COUNT:Il,COUNTA:Tl,COVAR:Al,COVARIANCE_P:Ol,COVARIANCE_S:Nl,LARGE:Ml,MAX:_l,MAXA:Fl,MAXIFS:Dl,MEDIAN:kl,MIN:$l,MINA:Ll,MINIFS:Pl,PERCENTILE:Ul,PERCENTILE_EXC:Vl,PERCENTILE_INC:zl,QUARTILE:Bl,QUARTILE_EXC:Hl,QUARTILE_INC:Wl,SMALL:Gl,STDEV:ql,STDEV_P:Zl,STDEV_S:jl,STDEVA:Yl,STDEVP:Xl,STDEVPA:Kl,VAR:Ql,VAR_P:Jl,VAR_S:ec,VARA:tc,VARP:ic,VARPA:nc});function rc(e,t,i){var n;const o=new Map,s=e.length;for(let t=s-1;t>=0;t--)o.set(Bs(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||s-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(),s.toString()))}else{const e=Bs(t).toUpperCase();if(a=null!==(n=o.get(e))&&void 0!==n?n:-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Bs(t),[...o.keys()].toString()))}const l=i[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 n=[],r=!0;for(let s=0;s<i.length;s++){const a=Bs(i[s][0]).toUpperCase(),l=o.get(a),c=i[s][t];if(void 0!==c){if(void 0===l){r=!1;break}n.push([e[l].slice(1,h)]),n.push(c)}}if(r){if(!(n.length>0)){c=new Set(Array(h-1).keys());break}oa(n,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const sc=Ds(`\n 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.")}\n field (any) ${r("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${r("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),ac={description:r("Average of a set of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Sl.compute([n])},isExported:!0},lc={description:r("Counts values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Il.compute([n])},isExported:!0},cc={description:r("Counts values and text from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Tl.compute([n])},isExported:!0},hc={description:r("Single value from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Ps((()=>1===n.length),r("More than one match found in DGET evaluation.")),n[0]},isExported:!0},dc={description:r("Maximum of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return _l.compute([n])},isExported:!0},uc={description:r("Minimum of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return $l.compute([n])},isExported:!0},gc={description:r("Product of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Ka.compute([n])},isExported:!0},pc={description:r("Standard deviation of population sample from table."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return ql.compute([n])},isExported:!0},mc={description:r("Standard deviation of entire population from table."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Xl.compute([n])},isExported:!0},fc={description:r("Sum of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return ll.compute([n])},isExported:!0},vc={description:r("Variance of population sample from table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Ql.compute([n])},isExported:!0},bc={description:r("Variance of a population from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return ic.compute([n])},isExported:!0};var Sc=Object.freeze({__proto__:null,DAVERAGE:ac,DCOUNT:lc,DCOUNTA:cc,DGET:hc,DMAX:dc,DMIN:uc,DPRODUCT:gc,DSTDEV:pc,DSTDEVP:mc,DSUM:fc,DVAR:vc,DVARP:bc});const Cc={description:r("Converts year/month/day into a date."),args:Ds(`\n year (number) ${r("The year component of the date.")}\n month (number) ${r("The month component of the date.")}\n day (number) ${r("The day component of the date.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let n=Math.trunc(Vs(e));const o=Math.trunc(Vs(t)),s=Math.trunc(Vs(i));Ps((()=>0<=n&&n<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",n.toString())),n<1900&&(n+=1900);const a=Ce(new ae(n,o-1,s));return Ps((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Ec={description:r("Converts a date string to a date value."),args:Ds(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e),i=ve(t);return Ps((()=>null!==i),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},wc={description:r("Day of the month that a specific date falls on."),args:Ds(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getDate()},isExported:!0},yc={description:r("Number of days between two dates."),args:Ds(`\n end_date (date) ${r("The end of the date range.")}\n start_date (date) ${r("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Zs(e),n=Zs(t),o=i.getTime()-n.getTime();return Math.round(o/ce)},isExported:!0},xc={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:Ds(`\n start_date (date) ${r("The start date to consider in the calculation.")}\n end_date (date) ${r("The end date to consider in the calculation.")}\n method (number, default=0) ${r("An indicator of what day count method to use. (0) US NASD method (1) European method")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){const n=Vs(e),o=Vs(t),r=qs(i)?4:0,s=Wc.compute(e,t,r);return Math.sign(o-n)*Math.round(360*s)},isExported:!0},Rc={description:r("Date a number of months before/after another date."),args:Ds(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return Ce(ye(Zs(e),Math.trunc(Vs(t)),!1))},isExported:!0},Ic={description:r("Last day of a month before or after a date."),args:Ds(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Zs(e),n=Math.trunc(Vs(t)),o=i.getFullYear(),r=i.getMonth();return Ce(new ae(o,r+n+1,0))},isExported:!0},Tc={description:r("Hour component of a specific time."),args:Ds(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getHours()},isExported:!0},Ac={description:r("ISO week number of the year."),args:Ds(`\n 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.")}\n `),returns:["NUMBER"],compute:function(e){const t=Zs(e),i=t.getFullYear();let n=1;for(;4!==new ae(i,0,n).getDay();)n+=1;const o=new ae(i,0,n-3);let r=31;for(;4!==new ae(i,11,r).getDay();)r-=1;const s=new ae(i,11,r+3);let a,l;switch(a=o.getTime()<=t.getTime()?t.getTime()<=s.getTime()?0:1:-1,a){case 0:l=o;break;case 1:l=new ae(i,11,r+3+1);break;case-1:let e=1;for(;4!==new ae(i-1,0,e).getDay();)e+=1;l=new ae(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ce;return Math.floor(c/7)+1},isExported:!0},Oc={description:r("Minute component of a specific time."),args:Ds(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getMinutes()},isExported:!0},Nc={description:r("Month of the year a specific date falls in"),args:Ds(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getMonth()+1},isExported:!0},Mc={description:r("Net working days between two provided days."),args:Ds(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i){return Fc.compute(e,t,1,i)},isExported:!0};function _c(e){if("string"==typeof e){Ps((()=>{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 i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return Ps((()=>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 Fc={description:r("Net working days between two dates (specifying weekends)."),args:Ds(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1,n){const o=Zs(e),r=Zs(t),s=_c(i);let a=new Set;void 0!==n&&Ys([n],(e=>{const t=Zs(e);a.add(t.getTime())}));const l=o.getTime()>r.getTime(),c=ae.fromTimestamp((l?o:r).getTime());let h=ae.fromTimestamp((l?r:o).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)s.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Dc={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=ae.now();const t=e.getTime()-le.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ce)+i},isExported:!0},kc={description:r("Minute component of a specific time."),args:Ds(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getSeconds()},isExported:!0},$c={description:r("Converts hour/minute/second into a time."),args:Ds(`\n hour (number) ${r("The hour component of the time.")}\n minute (number) ${r("The minute component of the time.")}\n second (number) ${r("The second component of the time.")}\n `),returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t)),s=Math.trunc(Vs(i));return o+=Math.floor(s/60),s=s%60+(s<0?60:0),n+=Math.floor(o/60),o=o%60+(o<0?60:0),n%=24,Ps((()=>n>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),n/24+o/1440+s/86400},isExported:!0},Lc={description:r("Converts a time string into its serial number representation."),args:Ds(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e),i=ve(t);Ps((()=>null!==i),r("The time_string (%s) cannot be parsed to date/time.",t));const n=i.value-Math.trunc(i.value);return n<0?1+n:n},isExported:!0},Pc={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=ae.now();return Ce(new ae(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Uc={description:r("Day of the week of the date provided (as number)."),args:Ds(`\n 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.")}\n type (number, default=1) ${r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Zs(e),n=Math.round(Vs(t)),o=i.getDay();return Ps((()=>[1,2,3].includes(n)),r("The type (%s) must be 1, 2 or 3.",n.toString())),1===n?o+1:2===n?0===o?7:o:0===o?6:o-1},isExported:!0},Vc={description:r("Week number of the year."),args:Ds(`\n 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.")}\n type (number, default=1) ${r("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Zs(e),n=Math.round(Vs(t));if(Ps((()=>1===n||2===n||11<=n&&n<=17||21===n),r("The type (%s) is out of range.",n.toString())),21===n)return Ac.compute(e);let o;o=1===n||2===n?n-1:n-10==7?0:n-10;const s=i.getFullYear();let a=1,l=new ae(s,0,a);for(;l.getDay()!==o;)a+=1,l=new ae(s,0,a);const c=(i.getTime()-l.getTime())/ce;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},zc={description:r("Date after a number of workdays."),args:Ds(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Bc.compute(e,t,1,i)},isExported:!0},Bc={description:r("Date after a number of workdays (specifying weekends)."),args:Ds(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,n){let o=Zs(e),s=Math.trunc(Vs(t));"string"==typeof i&&Ps((()=>"1111111"!==i),r("The weekend (%s) must be different from '1111111'.",i));const a=_c(i);let l=new Set;void 0!==n&&Ys([n],(e=>{const t=Zs(e);l.add(t.getTime())}));let c=ae.fromTimestamp(o.getTime()),h=c.getTime();const d=Math.sign(s);let u=Math.abs(s);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-le.getTime();return Math.round(g/ce)},isExported:!0},Hc={description:r("Year specified by a given date."),args:Ds(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getFullYear()},isExported:!0},Wc={description:r("Exact number of years between two dates."),args:Ds(`\n 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.")}\n 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.")}\n day_count_convention (number, default=0) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){let n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t));const s=Math.trunc(Vs(i));return Ps((()=>n>=0),r("The start_date (%s) must be positive or null.",n.toString())),Ps((()=>o>=0),r("The end_date (%s) must be positive or null.",o.toString())),Ps((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),Re(n,o,s)}},Gc={description:r("First day of the month preceding a date."),args:Ds(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Zs(e),i=t.getFullYear(),n=t.getMonth();return Ce(new ae(i,n,1))}},qc={description:r("Last day of the month following a date."),args:Ds(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return Ic.compute(e,0)}},Zc={description:r("Quarter of the year a specific date falls in"),args:Ds(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Zs(e).getMonth()+1)/3)}},jc={description:r("First day of the quarter of the year a specific date falls in."),args:Ds(`\n date (date) ${r("The date from which to calculate the start of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Zc.compute(e),i=Hc.compute(e);return Ce(new ae(i,3*(t-1),1))}},Yc={description:r("Last day of the quarter of the year a specific date falls in."),args:Ds(`\n date (date) ${r("The date from which to calculate the end of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Zc.compute(e),i=Hc.compute(e);return Ce(new ae(i,3*t,0))}},Xc={description:r("First day of the year a specific date falls in."),args:Ds(`\n date (date) ${r("The date from which to calculate the start of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Hc.compute(e);return Ce(new ae(t,0,1))}},Kc={description:r("Last day of the year a specific date falls in."),args:Ds(`\n date (date) ${r("The date from which to calculate the end of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Hc.compute(e);return Ce(new ae(t+1,0,0))}};var Qc=Object.freeze({__proto__:null,DATE:Cc,DATEVALUE:Ec,DAY:wc,DAYS:yc,DAYS360:xc,EDATE:Rc,EOMONTH:Ic,HOUR:Tc,ISOWEEKNUM:Ac,MINUTE:Oc,MONTH:Nc,NETWORKDAYS:Mc,NETWORKDAYS_INTL:Fc,NOW:Dc,SECOND:kc,TIME:$c,TIMEVALUE:Lc,TODAY:Pc,WEEKDAY:Uc,WEEKNUM:Vc,WORKDAY:zc,WORKDAY_INTL:Bc,YEAR:Hc,YEARFRAC:Wc,MONTH_START:Gc,MONTH_END:qc,QUARTER:Zc,QUARTER_START:jc,QUARTER_END:Yc,YEAR_START:Xc,YEAR_END:Kc});const Jc={description:r("Compare two numeric values, returning 1 if they're equal."),args:Ds(`\n number1 (number) ${r("The first number to compare.")}\n number2 (number, default=0) ${r("The second number to compare.")}\n `),returns:["NUMBER"],compute:function(e,t=0){return Vs(e)===Vs(t)?1:0},isExported:!0};var eh=Object.freeze({__proto__:null,DELTA:Jc});function th(e,t){Ps((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function ih(e,t){Ps((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function nh(e){Ps((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function oh(e){Ps((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function rh(e){Ps((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function sh(e){Ps((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function ah(e){Ps((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function lh(e){Ps((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function ch(e){Ps((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function hh(e){Ps((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function dh(e){Ps((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function uh(e){Ps((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function gh(e){Ps((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function ph(e,t){Ps((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function mh(e){Ps((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function fh(e){Ps((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function vh(e){Ps((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function bh(e){Ps((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Sh(e,t){const i=Zs(e),n=Zs(t),o=Zs(e);o.setFullYear(i.getFullYear()+1),Ps((()=>n.getTime()<=o.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Ch(e,t,i){ah(i),Ps((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),Ps((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),Ps((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Ps((()=>t<=i),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function Eh(e){Ps((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function wh(e,t){Ps((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function yh(e){Ps((()=>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 xh=Ds(`\nsettlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\nmaturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\nfrequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\nday_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n`);function Rh(e,t,i,n,o=1e-10,s){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(Ps((()=>g<n&&void 0!==s),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=s(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<o||Math.abs(c)<o,Ps((()=>g<n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Ih={description:r("Accrued interest of security paying at maturity."),args:Ds(`\n issue (date) ${r("The date the security was initially issued.")}\n maturity (date) ${r("The maturity date of the security.")}\n rate (number) ${r("The annualized rate of interest.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(n),l=Vs(i),c=Math.trunc(Vs(o));ih(s,r),oh(c),rh(a),lh(l);return a*l*Wc.compute(r,s,o)},isExported:!0},Th={description:r("Depreciation for an accounting period."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n purchase_date (date) ${r("The date the asset was purchased.")}\n first_period_end (date) ${r("The date the first period ended.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n rate (number) ${r("The deprecation rate.")}\n day_count_convention (number, optional) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Vs(e),c=Math.trunc(Vs(t)),h=Math.trunc(Vs(i)),d=Vs(n),u=Vs(o),g=Vs(s),p=Math.trunc(Vs(a));!function(e){Ps((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),uh(d),function(e,t){Ps((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Ps((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),lh(g),oh(p),Ps((()=>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,v=Wc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},Ah={description:r("Days in coupon period containing settlement date."),args:xh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));if(th(o,r),nh(s),oh(a),1===a){const o=Fh.compute(e,t,i,n);return Mh.compute(e,t,i,n)-o}return(3===a?365:360)/s},isExported:!0},Oh={description:r("Days from settlement until next coupon."),args:xh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);const l=Fh.compute(o,r,i,n);if([1,2,3].includes(a))return o-l;if(4===a){const e=Re(l,o,a);return Math.round(360*e)}const c=Zs(o),h=Zs(l),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&&we(h)&&we(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&we(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Nh={description:r("Days from settlement until next coupon."),args:xh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);const l=Mh.compute(o,r,i,n);if([1,2,3].includes(a))return l-o;if(4===a){const e=Re(o,l,a);return Math.round(360*e)}const c=Oh.compute(e,t,i,a);return Ah.compute(e,t,i,a)-c},isExported:!0},Mh={description:r("Next coupon date after the settlement date."),args:xh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);const l=12/s,c=_h.compute(e,t,i,n);return Ce(ye(Zs(r),-(c-1)*l,!0))},isExported:!0},_h={description:r("Number of coupons between settlement and maturity."),args:xh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);let l=1,c=r;const h=12/s;for(;c>o;)c=Ce(ye(Zs(c),-h,!1)),l++;return l-1},isExported:!0},Fh={description:r("Last coupon date prior to or on the settlement date."),args:xh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);const l=12/s,c=_h.compute(e,t,i,n);return Ce(ye(Zs(r),-c*l,!0))},isExported:!0},Dh={description:r("Cumulative interest paid over a set of periods."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){const s=Vs(n),a=Vs(o),l=Vs(e),c=Vs(i),h=Vs(t);Ch(s,a,h),lh(l),gh(c);let d=0;for(let t=s;t<=a;t++){d+=qh.compute(e,t,h,i,0,r)}return d},isExported:!0},kh={description:r("Cumulative principal paid over a set of periods."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){const s=Vs(n),a=Vs(o),l=Vs(e),c=Vs(i),h=Vs(t);Ch(s,a,h),lh(l),gh(c);let d=0;for(let t=s;t<=a;t++){d+=id.compute(e,t,h,i,0,r)}return d},isExported:!0},$h={description:r("Depreciation via declining balance method."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${r("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,...o){const s=Vs(e),a=Vs(t),l=Vs(i),c=Math.trunc(Vs(n)),h=o.length?Math.trunc(Vs(o[0])):12,d=l+(12===h?0:1);hh(s),uh(a),dh(c),ch(l),Ps((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Ps((()=>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/s,1/l);g=Math.round(1e3*g)/1e3;let p=s,m=s*(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},Lh={description:r("Depreciation via double-declining balance method."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n factor (number, default=2) ${r("The factor by which depreciation decreases.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=2){o=o||0;const r=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n),c=Vs(o);if(hh(r),uh(s),dh(l),ch(a),ph(l,a),bh(c),0===r||s>=r)return 0;const h=c/a;if(h>1)return 1===n?r-s: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<s?d-s:d-u;return Math.max(g,0)},isExported:!0},Ph={description:r("Discount rate of a security based on price."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(i),l=Vs(n),c=Math.trunc(Vs(o));th(r,s),oh(c),sh(a),rh(l);return(l-a)/l/Wc.compute(r,s,c)},isExported:!0},Uh={description:r("Convert a decimal fraction to decimal value."),args:Ds(`\n fractional_price (number) ${r("The price quotation given using fractional decimal conventions.")}\n unit (number) ${r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Math.trunc(Vs(t));Ps((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const o=Math.trunc(i);return o+(i-o)*(10**Math.ceil(Math.log10(n))/n)},isExported:!0},Vh={description:r("Convert a decimal value to decimal fraction."),args:Ds(`\n decimal_price (number) ${r("The price quotation given as a decimal value.")}\n unit (number) ${r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Math.trunc(Vs(t));Ps((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const o=Math.trunc(i);return o+(i-o)*(n/10**Math.ceil(Math.log10(n)))},isExported:!0},zh={description:r("Number of periods for an investment to reach a value."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Vs(e)),l=Math.trunc(Vs(t)),c=Vs(i),h=Vs(n),d=Math.trunc(Vs(o)),u=Math.trunc(Vs(s));th(a,l),nh(d),oh(u),Ps((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),Ps((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=Wc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Bh={description:r("Annual effective interest rate."),args:Ds(`\n nominal_rate (number) ${r("The nominal interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Math.trunc(Vs(t));return Ps((()=>i>0),r("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Ps((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),Math.pow(1+i/n,n)-1},isExported:!0},Hh={description:r("Future value of an annuity investment."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n present_value (number, default=0) ${r("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n),c=qs(o)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},Wh={description:r("Future value of principal from series of rates."),args:Ds(`\n principal (number) ${r("The amount of initial capital or value to compound against.")}\n rate_schedule (number, range<number>) ${r("A series of interest rates to compound against the principal.")}\n `),returns:["NUMBER"],compute:function(e,t){return Qs([t],((e,t)=>e*(1+Vs(t))),Vs(e))},isExported:!0},Gh={description:r("Calculates effective interest rate."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested in the security.")}\n redemption (number) ${r("The amount to be received at maturity.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(n),l=Vs(i);th(r,s),mh(l),rh(a);return(a-l)/l/Wc.compute(r,s,o)},isExported:!0},qh={description:r("Payment on the principal of an investment."),args:Ds(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=0,r=0){return td.compute(e,i,n,o,r)-id.compute(e,t,i,n,o,r)},isExported:!0},Zh={description:r("Internal rate of return given periodic cashflows."),args:Ds(`\n cashflow_amounts (number, range<number>) ${r("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Vs(t);Eh(i);let n=!1,o=!1,s=[];Xs([e],(e=>{e>0&&(n=!0),e<0&&(o=!0),s.push(e)})),Ps((()=>n&&o),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return Rh((function(e){return function(e,t,i){const n=i.length;let o=0;return i.reduce(((t,i)=>(o++,t+i*e**(n-o))),t*e**n)}(e,a,s)}),(function(e){return function(e,t,i){const n=i.length;let o=0;return i.reduce(((t,i)=>(o++,t+i*(n-o)*e**(n-o-1))),t*n*e**(n-1))}(e,a,s)}),i+1,20,1e-5)-1},isExported:!0},jh={description:r("Returns the interest paid at a particular period of an investment."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n period (number) ${r("The period for which you want to view the interest payment.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n){const o=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n);Ps((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*o},isExported:!0},Yh={description:r("Modified Macaulay duration."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){return zh.compute(e,t,i,n,o,r)/(1+Vs(n)/Math.trunc(Vs(o)))},isExported:!0},Xh={description:r("Modified internal rate of return."),args:Ds(`\n cashflow_amounts (range<number>) ${r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")}\n financing_rate (number) ${r("The interest rate paid on funds invested.")}\n reinvestment_return_rate (number) ${r("The return (as a percentage) earned on reinvestment of income received from the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Vs(t),o=Vs(i),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Xe).map(Vs);var a;const l=s.length;let c=0,h=0;for(const e of $e(0,l)){const t=s[e];t>=0?c+=t*(o+1)**(l-e-1):h+=t/(n+1)**e}Ps((()=>0!==h&&0!==c),r("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},Kh={description:r("Annual nominal interest rate."),args:Ds(`\n effective_rate (number) ${r("The effective interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Math.trunc(Vs(t));return Ps((()=>i>0),r("The effective rate (%s) must must strictly greater than 0.",i.toString())),Ps((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),(Math.pow(i+1,1/n)-1)*n},isExported:!0},Qh={description:r("Number of payment periods for an investment."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n payment_amount (number) ${r("The amount of each payment made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n),c=qs(o)?1:0;if(0===r)return-(l+a)/s;const h=s*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const Jh={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:Ds(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${r("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${r("Additional future cash flows.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Vs(e);return Ps((()=>-1!==i),r("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let n=0;return Js(i,((t,i)=>(n++,t+i/(1+e)**n)),t)}(i,0,t)},isExported:!0},ed={description:r("Computes the number of periods needed for an investment to reach a value."),args:Ds(`\n rate (number) ${r("The rate at which the investment grows each period.")}\n present_value (number) ${r("The investment's current value.")}\n future_value (number) ${r("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Vs(e),o=Vs(t),s=Vs(i);return lh(n),Ps((()=>o>0),r("The present_value (%s) must be strictly positive.",o.toString())),Ps((()=>s>0),r("The future_value (%s) must be strictly positive.",s.toString())),(Math.log(s)-Math.log(o))/Math.log(1+n)},isExported:!0},td={description:r("Periodic payment for an annuity investment."),args:Ds(`\n rate (number) ${r("The annualized rate of interest.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Vs(t),s=Vs(e),a=qs(o)?1:0;let l=Vs(n),c=Vs(i);if(ah(r),0===s)return-(l+c)/r;let h=-(c*(1+s)**r+l);return h=h*s/((1+s*a)*((1+s)**r-1)),h},isExported:!0},id={description:r("Payment on the principal of an investment."),args:Ds(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=0,s=0){o=o||0,s=s||0;const a=Vs(i),l=Vs(e),c=Vs(t),h=qs(s)?1:0,d=Vs(o),u=Vs(n);ah(a),Ps((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=td.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-Hh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},nd={description:r("Present value of an annuity investment."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n),c=qs(o)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},od={description:r("Price of a security paying periodic interest."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Math.trunc(Vs(e)),c=Math.trunc(Vs(t)),h=Vs(i),d=Vs(n),u=Vs(o),g=Math.trunc(Vs(s)),p=Math.trunc(Vs(a));th(l,c),nh(g),oh(p),Ps((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Ps((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),rh(u);const m=Wc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},rd={description:r("Price of a discount security."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the security at time of purchase.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(i),l=Vs(n),c=Math.trunc(Vs(o));th(r,s),oh(c),fh(a),rh(l);return l-a*l*Wc.compute(r,s,c)},isExported:!0},sd={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Vs(e)),l=Math.trunc(Vs(t)),c=Math.trunc(Vs(i)),h=Vs(n),d=Vs(o),u=Math.trunc(Vs(s));ih(a,c),th(a,l),oh(u),Ps((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Ps((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=Wc.compute(a,l,u),p=Wc.compute(a,c,u);return(100+Wc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},ad=.1,ld={description:r("Interest rate of an annuity investment."),args:Ds(`\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_per_period (number) ${r("The amount per period to be paid.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the interest rate will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,n=0,o=0,s=.1){n=n||0,o=o||0,s=s||ad;const a=Vs(e),l=Vs(t),c=qs(o)?1:0,h=Vs(s);let d=Vs(n),u=Vs(i);ah(a),Ps((()=>[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())),Eh(h),d-=l*c,u+=l*c;return Rh((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),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},cd={description:r("Amount received at maturity for a security."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested (irrespective of face value of each security).")}\n discount (number) ${r("The discount rate of the security invested in.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(i),l=Vs(n),c=Math.trunc(Vs(o));th(r,s),oh(c),mh(a),fh(l);return a/(1-l*Wc.compute(r,s,c))},isExported:!0},hd={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:Ds(`\n number_of_periods (number) ${r("The number of periods.")}\n present_value (number) ${r("The present value of the investment.")}\n future_value (number) ${r("The future value of the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Vs(e),o=Vs(t),r=Vs(i);return ah(n),(r/o)**(1/n)-1},isExported:!0},dd={description:r("Depreciation of an asset using the straight-line method."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Vs(e)-Vs(t))/Vs(i)},isExported:!0},ud={description:r("Depreciation via sum of years digit method."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n){const o=Vs(e),r=Vs(t),s=Vs(i),a=Vs(n);dh(a),ch(s),ph(a,s);return(s-a+1)/(s*(s+1)/2)*(o-r)},isExported:!0},gd={description:r("Price of a US Treasury bill."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t)),r=Vs(i);th(n,o),Sh(n,o),fh(r),vh(r);return 100*(1-r*Wc.compute(n,o,2))},isExported:!0},pd={description:r("Equivalent rate of return for a US Treasury bill."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t)),r=Vs(i);th(n,o),Sh(n,o),fh(r),vh(r);const s=yc.compute(o,n);if(s<=182)return 365*r/(360-r*s);const a=gd.compute(n,o,r)/100,l=s/(366===s?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},md={description:r("The yield of a US Treasury bill based on price."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t)),r=Vs(i);th(n,o),Sh(n,o),sh(r);return(100-r)/r*(1/Wc.compute(n,o,2))},isExported:!0},fd={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n start (number) ${r("Starting period to calculate depreciation.")}\n end (number) ${r("Ending period to calculate depreciation.")}\n factor (number, default=2) ${r("The number of months in the first year of depreciation.")}\n no_switch (number, default=false) ${r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=2,a=false){s=s||0;const l=Vs(e),c=Vs(t),h=Vs(i),d=Math.trunc(Vs(n)),u=Math.trunc(Vs(o)),g=Vs(s),p=qs(a);if(hh(l),uh(c),function(e,t,i){ch(i),Ps((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),Ps((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),Ps((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Ps((()=>t<=i),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),bh(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,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},vd={description:r("Internal rate of return given non-periodic cash flows."),args:Ds(`\n cashflow_amounts (range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],compute:function(e,t,i=.1){const n=Vs(i=i||0),o=e.flat().map(Vs),s=t.flat().map(Vs);var a;wh(e,t),a=o,Ps((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),yh(s),Eh(n);const l=new Map;for(const e of $e(0,s.length)){const t=s[e];l.has(t)?l.set(t,l.get(t)+o[e]):l.set(t,o[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return Rh((e=>{let t=h[0];for(const i of $e(1,h.length)){const n=(c[0]-c[i])/365;t+=h[i]*(1+e)**n}return t}),(e=>{let t=0;for(const i of $e(1,h.length)){const n=(c[0]-c[i])/365;t+=n*h[i]*(1+e)**(n-1)}return t}),n,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},bd={description:r("Net present value given to non-periodic cash flows.."),args:Ds(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow_amounts (number, range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (number, range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Vs(e),o=Array.isArray(t)?t.flat().map(zs):[zs(t)],s=Array.isArray(i)?i.flat().map(zs):[zs(i)];if(Array.isArray(i)&&Array.isArray(t)?wh(t,i):Ps((()=>o.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),yh(s),lh(n),1===o.length)return o[0];const a=new Map;for(const e of $e(0,s.length)){const t=s[e];a.has(t)?a.set(t,a.get(t)+o[e]):a.set(t,o[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of $e(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+n)**t}return h},isExported:!0},Sd={description:r("Annual yield of a security paying periodic interest."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Math.trunc(Vs(e)),c=Math.trunc(Vs(t)),h=Vs(i),d=Vs(n),u=Vs(o),g=Math.trunc(Vs(s)),p=Math.trunc(Vs(a));th(l,c),nh(g),oh(p),Ps((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),sh(d),rh(u);const m=Wc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=Rh((function(e){return function(e,t,i,n,o,r){let s=r-(e+o*(1-t))*n**(i-1+t);for(let e=1;e<=i;e++)s+=o*n**(e-1);return s}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,n,o){let r=-(e+o*(1-t))*(i-1+t)*n**(i-2+t);for(let e=1;e<=i;e++)r+=o*(e-1)*n**(e-2);return r}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Cd={description:r("Annual yield of a discount security."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(i),l=Vs(n),c=Math.trunc(Vs(o));th(r,s),oh(c),sh(a),rh(l);return(l/a-1)/Wc.compute(e,t,o)},isExported:!0},Ed={description:r("Annual yield of a security paying interest at maturity."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Vs(e)),l=Math.trunc(Vs(t)),c=Math.trunc(Vs(i)),h=Vs(n),d=Vs(o),u=Math.trunc(Vs(s));th(a,l),oh(u),Ps((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Ps((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),sh(d);const g=Wc.compute(c,l,u),p=Wc.compute(c,a,u),m=Wc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var wd=Object.freeze({__proto__:null,ACCRINTM:Ih,AMORLINC:Th,COUPDAYS:Ah,COUPDAYBS:Oh,COUPDAYSNC:Nh,COUPNCD:Mh,COUPNUM:_h,COUPPCD:Fh,CUMIPMT:Dh,CUMPRINC:kh,DB:$h,DDB:Lh,DISC:Ph,DOLLARDE:Uh,DOLLARFR:Vh,DURATION:zh,EFFECT:Bh,FV:Hh,FVSCHEDULE:Wh,INTRATE:Gh,IPMT:qh,IRR:Zh,ISPMT:jh,MDURATION:Yh,MIRR:Xh,NOMINAL:Kh,NPER:Qh,NPV:Jh,PDURATION:ed,PMT:td,PPMT:id,PV:nd,PRICE:od,PRICEDISC:rd,PRICEMAT:sd,RATE:ld,RECEIVED:cd,RRI:hd,SLN:dd,SYD:ud,TBILLPRICE:gd,TBILLEQ:pd,TBILLYIELD:md,VDB:fd,XIRR:vd,XNPV:bd,YIELD:Sd,YIELDDISC:Cd,YIELDMAT:Ed});const yd={description:r("Whether a value is an error other than #N/A."),args:Ds(`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(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},xd={description:r("Whether a value is an error."),args:Ds(`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},Rd={description:r("Whether a value is `true` or `false`."),args:Ds(`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},Id={description:r("Whether a value is the error #N/A."),args:Ds(`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(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},Td={description:r("Whether a value is non-textual."),args:Ds(`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},Ad={description:r("Whether a value is a number."),args:Ds(`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},Od={description:r("Whether a value is text."),args:Ds(`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},Nd={description:r("Whether the referenced cell is empty"),args:Ds(`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},Md={description:r("Returns the error value #N/A."),args:Ds(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var _d=Object.freeze({__proto__:null,ISERR:yd,ISERROR:xd,ISLOGICAL:Rd,ISNA:Id,ISNONTEXT:Td,ISNUMBER:Ad,ISTEXT:Od,ISBLANK:Nd,NA:Md});const Fd={description:r("Logical `and` operator."),args:Ds(`\n 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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return ta(e,(e=>(t=!0,i=i&&e,i))),Ps((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Dd={description:r("Returns value depending on logical expression."),args:Ds(`\n logical_expression (boolean) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")}\n value_if_true (any, lazy) ${r("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${r("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,i=(()=>!1)){const n=qs(e)?t():i();return null==n?"":n},isExported:!0},kd={description:r("Value if it is not an error, otherwise 2nd argument."),args:Ds(`\n value (any, lazy) ${r("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an error.")}\n `),returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},$d={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:Ds(`\n value (any, lazy) ${r("The value to return if value itself is not #N/A an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an #N/A error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(n){i=n.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},Ld={description:r("Returns a value depending on multiple logical expressions."),args:Ds(`\n 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.")}\n value1 (any, lazy) ${r("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${r("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${r("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){Ps((()=>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(qs(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(r("No match."))},isExported:!0},Pd={description:r("Returns opposite of provided logical value."),args:Ds(`logical_expression (boolean) ${r("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!qs(e)},isExported:!0},Ud={description:r("Logical `or` operator."),args:Ds(`\n 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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return ta(e,(e=>(t=!0,i=i||e,!i))),Ps((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Vd={description:r("Logical `xor` operator."),args:Ds(`\n 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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return ta(e,(e=>(t=!0,i=i?!e:e,!0))),Ps((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var zd=Object.freeze({__proto__:null,AND:Fd,IF:Dd,IFERROR:kd,IFNA:$d,IFS:Ld,NOT:Pd,OR:Ud,XOR:Vd});const Bd={description:r("Column number of a specified cell."),args:Ds(`cell_reference (meta, default=${r("The cell in which the formula is entered")}) ${r("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Ps((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Ni(i).left+1},isExported:!0},Hd={description:r("Number of columns in a specified array or range."),args:Ds(`range (meta) ${r("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Ni(e);return t.right-t.left+1},isExported:!0},Wd={description:r("Horizontal lookup"),args:Ds(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n 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.")}\n index (number) ${r("The row index of the value to be returned, where the first row in range is numbered 1.")}\n 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.")}\n `),returns:["ANY"],compute:function(e,t,i,n=true){const o=Math.trunc(Vs(i)),s=Ws(e);Ps((()=>1<=o&&o<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=qs(n);let l;return l=a?aa(t,s,"nextSmaller","asc",t.length,sa):la(t,s,"strict",t.length,sa),Ps((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),t[l][o-1]},isExported:!0},Gd={description:r("Returns the content of a cell, specified by row and column offset."),args:Ds(`\n reference (any, range) ${r("The range of cells from which the value is returned.")}\n row (number) ${r("The index of the row to be returned from within the reference range of cells.")}\n column (number) ${r("The index of the column to be returned from within the reference range of cells.")}\n`),returns:["ANY"],computeFormat:(e,t,i)=>{var n;const o=Vs(t.value);return null===(n=e[Vs(i.value)-1][o-1])||void 0===n?void 0:n.format},compute:function(e,t,i){const n=(o=e,Array.isArray(o)&&Array.isArray(o[0])?e:[[e]]);var o;const s=Vs(t),a=Vs(i);return Ps((()=>a>=0&&a-1<n.length&&s>=0&&s-1<n[0].length),r("Index out of range.")),Ps((()=>0!==t&&0!==i),r("This function can only return a single cell value, not an array. Provide valid row and column indices.")),n[a-1][s-1]},isExported:!0},qd={description:r("Look up a value."),args:Ds(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n 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.")}\n 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.")}\n `),returns:["ANY"],compute:function(e,t,i){let n=t.length,o=t[0].length;const s=Ws(e),a=o>=n,l=aa(t,s,"nextSmaller","asc",a?o:n,a?ra:sa);return Ps((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),void 0===i?a?t[n-1][l]:t[l][o-1]:(n=i.length,o=i[0].length,Ps((()=>1===n||1===o),r("The result_range must be a single row or a single column.")),n>1?(Ps((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Ps((()=>l<=o-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Zd={description:r("Position of item in range that matches value."),args:Ds(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The one-dimensional array to be searched.")}\n 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.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){let n=Vs(i);const o=Ws(e),s=t.length,a=t[0].length;Ps((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?ra:sa,h=1===s?t[0].length:t.length;switch(n=Math.sign(n),n){case 1:l=aa(t,o,"nextSmaller","asc",h,c);break;case 0:l=la(t,o,"strict",h,c);break;case-1:l=aa(t,o,"nextGreater","desc",h,c)}return Ps((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),l+1},isExported:!0},jd={description:r("Row number of a specified cell."),args:Ds(`cell_reference (meta, default=${r("The cell in which the formula is entered by default")}) ${r("The cell whose row number will be returned.")}`),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),Ps((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Ni(e).top+1},isExported:!0},Yd={description:r("Number of rows in a specified array or range."),args:Ds(`range (meta) ${r("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Ni(e);return t.bottom-t.top+1},isExported:!0},Xd={description:r("Vertical lookup."),args:Ds(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n 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.")}\n index (number) ${r("The column index of the value to be returned, where the first column in range is numbered 1.")}\n 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.")}\n `),returns:["ANY"],compute:function(e,t,i,n=true){const o=Math.trunc(Vs(i)),s=Ws(e);Ps((()=>1<=o&&o<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=qs(n);let l;return l=a?aa(t,s,"nextSmaller","asc",t[0].length,ra):la(t,s,"strict",t[0].length,ra),Ps((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),t[o-1][l]},isExported:!0},Kd={description:r("Search a range for a match and return the corresponding item from a second range."),args:Ds(`\n search_key (any) ${r("The value to search for.")}\n lookup_range (any, range) ${r("The range to consider for the search. Should be a single column or a single row.")}\n return_range (any, range) ${r("The range containing the return value. Should have the same dimensions as lookup_range.")}\n if_not_found (any, lazy, optional) ${r("If a valid match is not found, return this value.")}\n 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.")}\n 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. ")}\n\n `),returns:["ANY"],compute:function(e,t,i,n,o=0,s=1){const a=Math.trunc(Vs(o)),l=Math.trunc(Vs(s)),c=Ws(e);Ps((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),Ps((()=>1===i.length||1===i[0].length),r("return_range should be either a single row or single column.")),Ps((()=>i.length===t.length&&i[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),Ps((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),Ps((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?ra:sa,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=aa(t,c,u,2===l?"asc":"desc",d,h)}else p=la(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==n?void 0:n();return Ps((()=>!!m),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),m},isExported:!0};var Qd=Object.freeze({__proto__:null,COLUMN:Bd,COLUMNS:Hd,HLOOKUP:Wd,INDEX:Gd,LOOKUP:qd,MATCH:Zd,ROW:jd,ROWS:Yd,VLOOKUP:Xd,XLOOKUP:Kd});const Jd={description:r("Sum of two numbers."),args:Ds(`\n value1 (number) ${r("The first addend.")}\n value2 (number) ${r("The second addend.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Vs(e)+Vs(t)}},eu={description:r("Concatenation of two values."),args:Ds(`\n value1 (string) ${r("The value to which value2 will be appended.")}\n value2 (string) ${r("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return Bs(e)+Bs(t)},isExported:!0},tu={description:r("One number divided by another."),args:Ds(`\n dividend (number) ${r("The number to be divided.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Vs(t);return Ps((()=>0!==i),r("The divisor must be different from zero.")),Vs(e)/i}};function iu(e){return null==e}const nu={number:0,string:"",boolean:!1},ou={description:r("Equal."),args:Ds(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=iu(e)?nu[typeof t]:e,t=iu(t)?nu[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function ru(e,t,i){e=iu(e)?nu[typeof t]:e,t=iu(t)?nu[typeof e]:t,"number"!=typeof e&&(e=Bs(e).toUpperCase()),"number"!=typeof t&&(t=Bs(t).toUpperCase());const n=typeof e,o=typeof t;return"string"===n&&"number"===o||("string"!==o||"number"!==n)&&i(e,t)}const su={description:r("Strictly greater than."),args:Ds(`\n value1 (any) ${r("The value to test as being greater than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return ru(e,t,((e,t)=>e>t))}},au={description:r("Greater than or equal to."),args:Ds(`\n value1 (any) ${r("The value to test as being greater than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return ru(e,t,((e,t)=>e>=t))}},lu={description:r("Less than."),args:Ds(`\n value1 (any) ${r("The value to test as being less than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!au.compute(e,t)}},cu={description:r("Less than or equal to."),args:Ds(`\n value1 (any) ${r("The value to test as being less than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!su.compute(e,t)}},hu={description:r("Difference of two numbers."),args:Ds(`\n value1 (number) ${r("The minuend, or number to be subtracted from.")}\n value2 (number) ${r("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Vs(e)-Vs(t)}},du={description:r("Product of two numbers"),args:Ds(`\n factor1 (number) ${r("The first multiplicand.")}\n factor2 (number) ${r("The second multiplicand.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Vs(e)*Vs(t)}},uu={description:r("Not equal."),args:Ds(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!ou.compute(e,t)}},gu={description:r("A number raised to a power."),args:Ds(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],compute:function(e,t){return Xa.compute(e,t)}},pu={description:r("A number with the sign reversed."),args:Ds(`\n value (number) ${r("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Vs(e)}},mu={description:r("Value interpreted as a percentage."),args:Ds(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Vs(e)/100}},fu={description:r("A specified number, unchanged."),args:Ds(`\n value (any) ${r("The number to return.")}\n `),returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var vu=Object.freeze({__proto__:null,ADD:Jd,CONCAT:eu,DIVIDE:tu,EQ:ou,GT:su,GTE:au,LT:lu,LTE:cu,MINUS:hu,MULTIPLY:du,NE:uu,POW:gu,UMINUS:pu,UNARY_PERCENT:mu,UPLUS:fu});const bu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Su={description:r("Gets character associated with number."),args:Ds(`\n table_number (number) ${r("The number of the character to look up from the current Unicode table in decimal format.")}\n `),returns:["STRING"],compute:function(e){const t=Math.trunc(Vs(e));return Ps((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Cu={description:r("Remove non-printable characters from a piece of text."),args:Ds(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Bs(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},Eu={description:r("Appends strings to one another."),args:Ds(`\n string1 (string, range<string>) ${r("The initial string.")}\n string2 (string, range<string>, repeating) ${r("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return Qs(e,((e,t)=>e+Bs(t)),"")},isExported:!0},wu={description:r("Tests whether two strings are identical."),args:Ds(`\n string1 (string) ${r("The first string to compare.")}\n string2 (string) ${r("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Bs(e)===Bs(t)},isExported:!0},yu={description:r("First position of string found in text, case-sensitive."),args:Ds(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const n=Bs(e),o=Bs(t),s=Vs(i);Ps((()=>""!==o),r("The text_to_search must be non-empty.")),Ps((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=o.indexOf(n,s-1);return Ps((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n.toString(),o)),a+1},isExported:!0},xu={description:r("Concatenates elements of arrays with delimiter."),args:Ds(`\n delimiter (string) ${r("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${r("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${r("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const i=Bs(e);return Qs(t,((e,t)=>(e?e+i:"")+Bs(t)),"")}},Ru={description:r("Substring from beginning of specified string."),args:Ds(`\n text (string) ${r("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Vs(t[0]):1;return Ps((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString())),Bs(e).substring(0,i)},isExported:!0},Iu={description:r("Length of a string."),args:Ds(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Bs(e).length},isExported:!0},Tu={description:r("Converts a specified string to lowercase."),args:Ds(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Bs(e).toLowerCase()},isExported:!0},Au={description:r("A segment of a string."),args:Ds(`\n text (string) ${r("The string to extract a segment from.")}\n starting_at (number) ${r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")}\n extract_length (number) ${r("The length of the segment to extract.")}\n `),returns:["STRING"],compute:function(e,t,i){const n=Bs(e),o=Vs(t),s=Vs(i);return Ps((()=>o>=1),r("The starting_at argument (%s) must be positive greater than one.",o.toString())),Ps((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),n.slice(o-1,o+s-1)},isExported:!0},Ou={description:r("Capitalizes each word in a specified string."),args:Ds(`\n 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.")}\n `),returns:["STRING"],compute:function(e){return Bs(e).replace(bu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Nu={description:r("Replaces part of a text string with different text."),args:Ds(`\n text (string) ${r("The text, a part of which will be replaced.")}\n position (number) ${r("The position where the replacement will begin (starting from 1).")}\n length (number) ${r("The number of characters in the text to be replaced.")}\n new_text (string) ${r("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,i,n){const o=Vs(t);Ps((()=>o>=1),r("The position (%s) must be greater than or equal to 1.",o.toString()));const s=Bs(e),a=Vs(i),l=Bs(n);return s.substring(0,o-1)+l+s.substring(o-1+a)},isExported:!0},Mu={description:r("A substring from the end of a specified string."),args:Ds(`\n text (string) ${r("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Vs(t[0]):1;Ps((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString()));const n=Bs(e),o=n.length;return n.substring(o-i,o)},isExported:!0},_u={description:r("First position of string found in text, ignoring case."),args:Ds(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const n=Bs(e).toLowerCase(),o=Bs(t).toLowerCase(),s=Vs(i);Ps((()=>""!==o),r("The text_to_search must be non-empty.")),Ps((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=o.indexOf(n,s-1);return Ps((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n,o)),a+1},isExported:!0},Fu={description:r("Replaces existing text with new text in a string."),args:Ds(`\n text_to_search (string) ${r("The text within which to search and replace.")}\n search_for (string) ${r("The string to search for within text_to_search.")}\n replace_with (string) ${r("The string that will replace search_for.")}\n 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.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n){const o=Vs(n);Ps((()=>o>=0),r("The occurrenceNumber (%s) must be positive or null.",o.toString()));const s=Bs(e),a=Bs(t);if(""===a)return s;const l=Bs(i),c=new RegExp(Te(a),"g");if(0===o)return s.replace(c,l);let h=0;return s.replace(c,(e=>++h===o?l:e))},isExported:!0},Du={description:r("Combines text from multiple strings and/or arrays."),args:Ds(`\n delimiter (string) ${r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${r("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${r("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...i){const n=Bs(e),o=qs(t);let r=0;return Qs(i,((e,t)=>o&&""===Bs(t)?e:(r++?e+n:"")+Bs(t)),"")},isExported:!0},ku={description:r("Removes space characters."),args:Ds(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Bs(e).trim()},isExported:!0},$u={description:r("Converts a specified string to uppercase."),args:Ds(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Bs(e).toUpperCase()},isExported:!0},Lu={description:r("Converts a number to text according to a specified format."),args:Ds(`\n number (number) ${r("The number, date or time to format.")}\n format (string) ${r("The pattern by which to format the number, enclosed in quotation marks.")}\n `),returns:["STRING"],compute:function(e,t){return Qt(Vs(e),Bs(t))},isExported:!0};const Pu={database:Sc,date:Qc,financial:wd,info:_d,lookup:Qd,logical:zd,math:pl,misc:da,operators:vu,statistical:oc,text:Object.freeze({__proto__:null,CHAR:Su,CLEAN:Cu,CONCATENATE:Eu,EXACT:wu,FIND:yu,JOIN:xu,LEFT:Ru,LEN:Iu,LOWER:Tu,MID:Au,PROPER:Ou,REPLACE:Nu,RIGHT:Mu,SEARCH:_u,SUBSTITUTE:Fu,TEXTJOIN:Du,TRIM:ku,UPPER:$u,TEXT:Lu}),engineering:eh},Uu=/^[A-Z0-9\_\.]+$/;function Vu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>zu(e()):zu(e)}))}function zu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Bu=new class extends tn{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Uu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=$s(t);return function(e){let t=!1,i=!1,n=!1;for(let o of e){if(o.type.includes("META")&&o.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&&!o.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||n,s=!(o.optional||o.repeating||o.default);if(e&&s)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=o.repeating,i=o.optional,n=o.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),n=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Vu(e)),format:n(...e)}},super.add(e,i),this}};for(let e in Pu){const t=Pu[e];for(let i in t){const n=t[i];n.category=e,i=i.replace(/_/g,"."),Bu.add(i,{isExported:!1,...n})}}const Hu=Bu.content,Wu=["%"],Gu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Wu);function qu(e){const t=e.split(""),i=[];for(;t.length;){let e=ng(t)||Yu(t)||Ku(t)||Ju(t)||Zu(t)||og(t)||Qu(t)||tg(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Zu(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const ju={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Yu(e){if(e[0]in ju){const t=e.shift();return{type:ju[t],value:t}}return null}function Xu(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Ku(e){for(let t of Gu)if(Xu(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Qu(e){const t=et(e).match(pi);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Ju(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const eg=/\w|\.|!|\$/;function tg(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(eg);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Hu)return{type:"FUNCTION",value:e};return e.match(Nt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const ig=/\s/;function ng(e){let t=0;for(;e[0]&&e[0].match(ig);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function og(e){return Xu(e,X)?(e.splice(0,X.length),{type:"INVALID_REFERENCE",value:X}):null}var rg;!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"}(rg||(rg={}));const sg=(e,t=(()=>!0))=>[{goTo:e,guard:t}],ag=(e,t=(()=>!0))=>({goTo:e,guard:t}),lg={[rg.LeftRef]:{REFERENCE:sg(rg.Separator),NUMBER:sg(rg.FullRowSeparator),SYMBOL:[ag(rg.FullColumnSeparator,(e=>Mt(e.value))),ag(rg.FullRowSeparator,(e=>_t(e.value)))]},[rg.FullColumnSeparator]:{SPACE:sg(rg.FullColumnSeparator),OPERATOR:sg(rg.RightColumnRef,(e=>":"===e.value))},[rg.FullRowSeparator]:{SPACE:sg(rg.FullRowSeparator),OPERATOR:sg(rg.RightRowRef,(e=>":"===e.value))},[rg.Separator]:{SPACE:sg(rg.Separator),OPERATOR:sg(rg.RightRef,(e=>":"===e.value))},[rg.RightRef]:{SPACE:sg(rg.RightRef),NUMBER:sg(rg.Found),REFERENCE:sg(rg.Found,(e=>kt(e.value))),SYMBOL:sg(rg.Found,(e=>Ft(e.value)||Dt(e.value)))},[rg.RightColumnRef]:{SPACE:sg(rg.RightColumnRef),SYMBOL:sg(rg.Found,(e=>Ft(e.value))),REFERENCE:sg(rg.Found,(e=>kt(e.value)))},[rg.RightRowRef]:{SPACE:sg(rg.RightRowRef),NUMBER:sg(rg.Found),REFERENCE:sg(rg.Found,(e=>kt(e.value))),SYMBOL:sg(rg.Found,(e=>Dt(e.value)))},[rg.Found]:{}};function cg(e){var t;let i=0,n=lg[rg.LeftRef],o="";for(;void 0!==n;){const r=e[i++];if(!r)return null;const s=null===(t=n[r.type])||void 0===t?void 0:t.find((e=>e.guard(r))),a=s?s.goTo:void 0;switch(a){case void 0:return null;case rg.Found:return o+=r.value,e.splice(0,i),{type:"REFERENCE",value:o};default:n=lg[a],o+=r.value}}return null}function hg(e){const t=qu(e),i=[];for(;t.length;)i.push(cg(t)||t.shift());return i}const dg=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,ug=["-","+"],gg=["%"],pg=["*","+","&"],mg={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},fg=6;function vg(e){switch(e.type){case"NUMBER":case"SYMBOL":case"REFERENCE":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return mg[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function bg(e,t,i){if("OPERATOR"===t.type){const n=vg(t);if(gg.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const o=Sg(i,n);return{type:"BIN_OPERATION",value:t.value,left:e,right:o}}}throw new Error(ne)}function Sg(e,t){const i=e.shift();if(!i)throw new Error(ne);let n=function(e,t){var i,n,o,s;switch(e.type){case"DEBUGGER":const a=Sg(t,1e3);return a.debug=!0,a;case"NUMBER":return{type:"NUMBER",value:wi(e.value)};case"STRING":return{type:"STRING",value:Ie(e.value)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(r("Wrong function call"));{const n=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?n.push({type:"UNKNOWN",value:""}):n.push(Sg(t,fg));"COMMA"===(null===(i=t[0])||void 0===i?void 0:i.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){n.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?n.push({type:"UNKNOWN",value:""}):n.push(Sg(t,fg))}const o=t.shift();if(!o||"RIGHT_PAREN"!==o.type)throw new Error(r("Wrong function call"));return{type:"FUNCALL",value:e.value,args:n}}case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(n=t[0])||void 0===n?void 0:n.value)&&"REFERENCE"===(null===(o=t[1])||void 0===o?void 0:o.type)){t.shift();const i=t.shift();return{type:"REFERENCE",value:`${e.value}:${null==i?void 0:i.value}`}}return{type:"REFERENCE",value:e.value};case"SYMBOL":if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value){if(dg.test(e.value)&&"LEFT_PAREN"===(null===(s=t[0])||void 0===s?void 0:s.type))throw new p(e.value);throw new Error(r("Invalid formula"))}return{type:"STRING",value:e.value};case"LEFT_PAREN":const l=Sg(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),l;default:if("OPERATOR"===e.type&&ug.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:Sg(t,mg[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(i,e);for(;e[0]&&vg(e[0])>t;)n=bg(n,e.shift(),e);return n}function Cg(e){return Eg(hg(e))}function Eg(e){"OPERATOR"===(e=e.filter((e=>"SPACE"!==e.type)))[0].type&&"="===e[0].value&&e.splice(0,1);const t=Sg(e,0);if(e.length)throw new Error(ne);return t}function wg(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>wg(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:wg(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:wg(e.right,t,i),left:wg(e.left,t,i)};default:return e}}function yg(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>yg(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?xg(e)+e.value:e.value+Rg(e);case"BIN_OPERATION":return xg(e)+e.value+Rg(e)}}function xg(e){const t=e.value,i="left"in e?e.left:e.operand,n=i.value;return"BIN_OPERATION"===i.type&&mg[n]<mg[t]?`(${yg(i)})`:yg(i)}function Rg(e){const t=e.value,i="right"in e?e.right:e.operand,n=mg[i.value],o=mg[t];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:n<o?r=!0:n!==o||pg.includes(t)||(r=!0),r?`(${yg(i)})`:yg(i)}const Ig=Bu.content,Tg={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Ag={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function Og(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const Ng={};function Mg(e){const t=hg(e),{dependencies:i,constantValues:n}=function(e){const t={numbers:[],strings:[]},i=[];for(const n of e)switch(n.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(n.value);break;case"STRING":const e=Ie(n.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=wi(n.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),o=function(e,t,i){return et(e.map((e=>{switch(e.type){case"STRING":const n=Ie(e.value);return`|S${i.strings.indexOf(n)}|`;case"NUMBER":return`|N${i.numbers.indexOf(wi(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,n);if(!Ng[o]){const s=Eg([...t]);let a=1;if("BIN_OPERATION"===s.type&&":"===s.value)throw new Error(r("Invalid formula"));if("UNKNOWN"===s.type)throw new Error(r("Invalid formula"));const l=u(s),c=Og([`// ${o}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=Ig[e.value.toUpperCase()],i=e.args,n=i.length;if(n<t.minArgRequired)throw new Error(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),n.toString()));if(n>t.maxArgPossible)throw new Error(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),n.toString()));const o=t.nbrArgRepeating;if(o>1){const i=t.args.length-o;if((n-i)%o!=0)throw new Error(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),o.toString()))}let s=[];for(let o=0;o<n;o++){const n=t.getArgToFocus(o+1)-1;if(0<=n&&n<t.args.length){const a=i[o],l=t.args[n],c=l.type||[],h=c.includes("META"),d=l.lazy,g=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),p=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(p&&"REFERENCE"!==a.type)throw new Error(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(o+1).toString(),a.type.toLowerCase()));const m=u(a,d,h,g,{functionName:e.value.toUpperCase(),paramIndex:o+1});s.push(m)}}return s}function u(e,t=!1,o=!1,s=!1,l={}){const c=[];let h,g,p;if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&o)throw new Error(r("Argument must be a reference to a cell or range."));switch(e.debug&&c.push("debugger;"),e.type){case"BOOLEAN":if(!t)return{id:`{ value: ${e.value} }`,code:""};h=a++,p=`{ value: ${e.value} }`;break;case"NUMBER":h=a++,p=`{ value: this.constantValues.numbers[${n.numbers.indexOf(e.value)}] }`;break;case"STRING":h=a++,p=`{ value: this.constantValues.strings[${n.strings.indexOf(e.value)}] }`;break;case"REFERENCE":const r=i.indexOf(e.value);h=a++,p=s?`range(deps[${r}])`:`ref(deps[${r}], ${o?"true":"false"}, "${l.functionName||Tg["="]}", ${l.paramIndex})`;break;case"FUNCALL":h=a++;const m=d(e);c.push(m.map((e=>e.code)).join("\n")),g=e.value.toUpperCase(),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${m.map((e=>e.id))})`;break;case"UNARY_OPERATION":{h=a++,g=Ag[e.value];const t=u(e.operand,!1,!1,!1,{functionName:g});c.push(t.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id})`;break}case"BIN_OPERATION":{h=a++,g=Tg[e.value];const t=u(e.left,!1,!1,!1,{functionName:g}),i=u(e.right,!1,!1,!1,{functionName:g});c.push(t.code),c.push(i.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id}, ${i.id})`;break}case"UNKNOWN":if(!t)return{id:"undefined",code:""};h=a++,p="undefined"}if(t){return{id:`_${h}`,code:`const _${h} = () => {\n\t${Og(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}Ng[o]={execute:h}}return{execute:Ng[o].execute,dependencies:i,constantValues:n,tokens:t}}function _g(e){return function(e){let t=[],i="";return e.map(((e,n)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,n=Object.assign({},e,{start:t,end:t+i,length:i});return t=n.end,n}))}(hg(e))))}function Fg(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=$t(e.value),[n,o]=t.split(":"),r=i?`${Ne(i)}!`:"",s=Dg(n),a=o?`:${Dg(o)}`:"";return{...e,value:r+s+a}}function Dg(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=kg(e,"colrow");break;case"colrow":e=kg(e,"row");break;case"row":e=kg(e,"col");break;case"col":e=kg(e,"none")}return e}function kg(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),-1===i||0===i?"$"+e:"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}class $g{constructor(e,t,i){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 i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const n=e.filter((e=>0!==e));if(n.length)return n}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}$g.getters=[];class Lg extends $g{constructor(e,t,i,n,o){super(t,i,n),this.getters=e,this.ui=n,this.selection=o}drawGrid(e,t){}}Lg.layers=[];const Pg=r("The cell you are trying to edit has been deleted.");class Ug extends Lg{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.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=this.getters.getActiveCell(),i=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(i.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}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":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),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:n}=$t(e.value),o=n||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==o)return!1;const s=this.getters.getRangeFromSheetXC(r,i);return Ui(this.getters.expandZone(r,s.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const n=this.getters.getRangeFromRangeData(e.range),o=this.getRangeReference(n,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(o),this.previousRef=o,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{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),n=this.getters.expandZone(e.sheetIdTo,Ki({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:n})}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:Pg}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}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((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(Fg).map((e=>e.value)).join(""),n=this.currentContent,o=e[0].start,r=e[e.length-1].end,s=n.slice(0,o)+i+n.slice(r),a=s.length-n.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:s,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}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:Pg});const{top:t,left:i}=ki({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,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:Pg});const{top:t,left:i}=ki({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Di({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=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Ki({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){var i;const n=this.getters.getActiveCell();e&&(null===(i=null==n?void 0:n.format)||void 0===i?void 0:i.includes("%"))&&Ci(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`),this.initialContent=(null==n?void 0:n.composerContent)||"",this.mode="editing";const{col:o,row:r}=this.getters.getPosition();this.col=o,this.row=r,this.sheetId=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const s=Ki({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){const e=this.getters.getActiveSheetId();this.cancelEditionAndActivateSheet();const{col:t,row:i}=this.getters.getMainCellPosition(this.sheetId,this.col,this.row);let n=this.currentContent;if(!(this.initialContent!==n))return;if(n){const o=this.getters.getCell(e,t,i);if(n.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&&(n+=et(new Array(i).fill(")")))}else(null==o?void 0:o.isLink())&&(n=We(n,o.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:t,row:i,content:n})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:t,row:i});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})}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){e=e.replace(/[\r\n]/g,"");const n=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(n||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?_g(e):[],this.currentTokens.length>100&&i&&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),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let n=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){n=`${Ne(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${n}`}return n}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){1===t.length&&Ji(e.zone)>1?t.push({...t[0]}):2===t.length&&1===Ji(e.zone)&&t.pop();const i=e.clone({parts:this.previousRange.parts});return this.getters.getSelectionRangeString(i,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),n=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:n,end:n}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const n=new Set(Object.values(i));let o=0;const r=()=>{for(;n.has(o);)o++;return n.add(o),o};for(const e of t){const t=e in i?i[e]:r();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return ut[t%ut.length]};return this.getReferencedRanges().map((i=>{const n=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(n),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}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 i=t,n=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(n.type)||Wu.includes(n.value);){if("SPACE"!==n.type||i<1)return!1;i--,n=this.currentTokens[i]}for(i=t+1,n=this.currentTokens[i];n&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(n.type);){if("SPACE"!==n.type)return!1;i++,n=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Ug.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const Vg=Bu.content,zg=new tn;zg.add("functions",(()=>Object.keys(Vg).map((e=>({text:e,description:Vg[e].description}))))),Cn`
983
+ `;class Ms extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:n}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:o,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return`bottom: ${n-r+15}px;left: ${o-1}px;border: 1px solid ${i};background-color: ${i};${this.props.active?"opacity:1 !important":""}`}}Ms.template="o-spreadsheet-ClientTag";const _s=/(.*?)\((.*?)\)(.*)/,Fs=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function Ds(e){let t=e.split("\n");const i=[];for(let e of t)e=e.trim(),e&&i.push(ks(e));return i}function ks(e){let t,i=e.match(_s),n=i[1].trim(),o=[],r=!1,s=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let n=Fs.find((e=>i===e));n?o.push(n):"RANGE<ANY>"===i?o.push("RANGE"):"OPTIONAL"===i?r=!0:"REPEATING"===i?s=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:n,description:i[3].trim(),type:o};return r&&(l.optional=!0),s&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function $s(e){let t=0,i=0,n=0;for(let o of e.args)t++,o.optional||o.repeating||o.default||i++,o.repeating&&n++;const o=e;return o.minArgRequired=i,o.maxArgPossible=n?1/0:t,o.nbrArgRepeating=n,o.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,n),o}const Ls=["number","string","boolean","undefined"];function Ps(e,t){if(!e())throw new Error(t)}const Us=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Vs(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(Ci(e)||""===e)return wi(e);const t=ve(e);if(t)return t.value;throw new Error(Us(e));default:return 0}}function zs(e){if(""===e)throw new Error(Us(e));return Vs(e)}function Bs(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const Hs=function(e){const t=new Map,i=e.name?e.name+" (memoized)":"memoized";return{[i]:(...i)=>(t.has(i[0])||t.set(i[0],e(...i)),t.get(i[0]))}[i]}((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}));function Ws(e){return"string"==typeof e?Hs(e):e}const Gs=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function qs(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(Gs(e))}return!1;case"number":return!!e;default:return!1}}function Zs(e){return Se(Vs(e))}function js(e,t,i){for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let o=0;o<i;o++)for(let i=0;i<e;i++)t(n[i][o])}else i(n)}function Ys(e,t){js(e,t,t)}function Xs(e,t){js(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(zs(e))}))}function Ks(e,t,i,n){let o=n;for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let r=0;r<i;r++)for(let i=0;i<e;i++)o=t(o,n[i][r])}else o=i(o,n);return o}function Qs(e,t,i){return Ks(e,t,t,i)}function Js(e,t,i){return Ks(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,zs(i))),i)}function ea(e,t,i){return Ks(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Vs(i):0):e),((e,i)=>t(e,Vs(i))),i)}function ta(e,t){return function(e,t,i){for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let o=0;o<i;o++)for(let i=0;i<e;i++)if(!t(n[i][o]))return}else if(!i(n))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(Gs(e));return qs(e)}(e))))}function ia(e,t){let i,n,o=e.substring(0,2);"<="===o||">="===o||"<>"===o?(i=o,n=e.substring(2)):(o=e.substring(0,1),"<"===o||">"===o||"="===o?(i=o,n=e.substring(1)):(i="=",n=e)),Ci(n)||Ve(n)?n=Vs(n):"TRUE"!==n&&"FALSE"!==n||(n=qs(n));const r={operator:i,operand:n};return"string"==typeof n&&(t&&(n+="*"),r.regexp=function(e){if("*"===e)return/.+/;let t="",i="";for(let n of e)"?"===n&&"~"!==i?t+=".":"*"===n&&"~"!==i?t+=".*":("*"!==n&&"?"!==n||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(n)&&(t+="\\"),t+=n),i=n;return new RegExp("^"+t+"$","i")}(n)),r}function na(e="",t){const{operator:i,operand:n}=t;if(void 0===n)return!1;if("number"==typeof n&&"="===i)return Bs(e)===Bs(n);if("<>"===i||"="===i){let o;return o=typeof e==typeof n&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===n),"="===i?o:!o}if(typeof e==typeof n)switch(i){case"<":return e<n;case">":return e>n;case"<=":return e<=n;case">=":return e>=n}return!1}function oa(e,t,i=!1){const n=e.length;if(n%2==1)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const o=e[0].length,s=e[0][0].length;let a=[];for(let t=0;t<n-1;t+=2){const n=e[t];if(!Array.isArray(n)||n.length!==o||n[0].length!==s)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Bs(e[t+1]);a.push(ia(l,i))}for(let i=0;i<o;i++)for(let o=0;o<s;o++){let r=!0;for(let t=0;t<n-1;t+=2){if(r=na(e[t][i][o],a[t/2]),!r)break}r&&t(i,o)}}function ra(e,t){return Ws(e[0][t])}function sa(e,t){return Ws(e[t][0])}function aa(e,t,i,n,o,r){if(null==t)return-1;const s=typeof t;let a,l,c,h,d,u,g=0,p=o-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=r(e,h),u=typeof d;g<h&&s!==u;)h--,d=r(e,h),u=typeof d;u===s&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h),"asc"===n&&d>t||"desc"===n&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function la(e,t,i,n,o,r=!1){if(null==t)return-1;const s=r?(e,t)=>o(e,n-t-1):o;let a,l=-1;for(let o=0;o<n;o++){const c=s(e,o);if(c===t)return r?n-o-1:o;"nextSmaller"===i?(!a&&ca(t,c)>=0||ca(t,c)>=0&&ca(c,a)>0)&&(a=c,l=o):"nextGreater"===i&&(!a&&ca(t,c)<=0||ca(t,c)<=0&&ca(c,a)<0)&&(a=c,l=o)}return r?n-l-1:l}function ca(e,t){let i=Ls.indexOf(typeof e)-Ls.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}const ha={description:r("Apply a large number format"),args:Ds(`\n value (number) ${r("The number.")}\n unit (string, optional) ${r("The formatting unit. Use 'k', 'm', or 'b' to force the unit")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Vs(e.value)),n=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return li(n,1e3,"k");case"m":return li(n,1e6,"m");case"b":return li(n,1e9,"b");default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?li(n,0,""):i<1e8?li(n,1e3,"k"):i<1e11?li(n,1e6,"m"):li(n,1e9,"b")},compute:function(e){return Vs(e)}};var da=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:ha});const ua={description:r("Absolute value of a number."),args:Ds(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Vs(e))},isExported:!0},ga={description:r("Inverse cosine of a value, in radians."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},pa={description:r("Inverse hyperbolic cosine of a number."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},ma={description:r("Inverse cotangent of a value."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},fa={description:r("Inverse hyperbolic cotangent of a value."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>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},va={description:r("Inverse sine of a value, in radians."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},ba={description:r("Inverse hyperbolic sine of a number."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Vs(e))},isExported:!0},Sa={description:r("Inverse tangent of a value, in radians."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Vs(e))},isExported:!0},Ca={description:r("Angle from the X axis to a point (x,y), in radians."),args:Ds(`\n x (number) ${r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Vs(t);return Ps((()=>0!==i||0!==n),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(n,i)},isExported:!0},Ea={description:r("Inverse hyperbolic tangent of a number."),args:Ds(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},wa={description:r("Rounds number up to nearest multiple of factor."),args:Ds(`\n value (number) ${r("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Vs(e),n=Vs(t);return Ps((()=>n>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),i.toString())),n?Math.ceil(i/n)*n:0},isExported:!0},ya={description:r("Rounds number up to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n 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.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let n=Vs(t);if(0===n)return 0;const o=Vs(e);if(n=Math.abs(n),o>=0)return Math.ceil(o/n)*n;return 0===Vs(i)?-Math.floor(Math.abs(o)/n)*n:-Math.ceil(Math.abs(o)/n)*n},isExported:!0},xa={description:r("Rounds number up to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return ya.compute(e,t,0)},isExported:!0},Ra={description:r("Cosine of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Vs(e))},isExported:!0},Ia={description:r("Hyperbolic cosine of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Vs(e))},isExported:!0},Ta={description:r("Cotangent of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Aa={description:r("Hyperbolic cotangent of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Oa={description:r("Number of empty values."),args:Ds(`\n value1 (any, range) ${r("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${r("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return Qs(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Na={description:r("A conditional count across a range."),args:Ds(`\n range (range) ${r("The range that is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return oa(e,((e,i)=>{t+=1})),t},isExported:!0},Ma={description:r("Count values depending on multiple criteria."),args:Ds(`\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n 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.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return oa(e,((e,i)=>{t+=1})),t},isExported:!0};function _a(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Fa={description:r("Counts number of unique values in a range."),args:Ds(`\n value1 (any, range) ${r("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return Qs(e,((e,t)=>_a(t)?e.add(t):e),new Set).size}},Da={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:Ds(`\n range (range) ${r("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n 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.")}\n 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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=new Set;return oa(t,((t,n)=>{const o=e[t][n];_a(o)&&i.add(o)})),i.size}},ka={description:r("Cosecant of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},$a={description:r("Hyperbolic cosecant of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},La={description:r("Converts from another base to decimal."),args:Ds(`\n value (string) ${r("The number to convert.")},\n base (number) ${r("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let i=Vs(t);i=Math.floor(i),Ps((()=>2<=i&&i<=36),r("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const n=Bs(e);if(""===n)return 0;Ps((()=>!!n.match(/^-?[a-z0-9]+$/i)),r("The value (%s) must be a valid base %s representation.",n,i.toString()));const o=parseInt(n,i);return Ps((()=>!isNaN(o)),r("The value (%s) must be a valid base %s representation.",n,i.toString())),o},isExported:!0},Pa={description:r("Converts an angle value in radians to degrees."),args:Ds(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Vs(e)/Math.PI},isExported:!0},Ua={description:r("Euler's number, e (~2.718) raised to a power."),args:Ds(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Vs(e))},isExported:!0},Va={description:r("Rounds number down to nearest multiple of factor."),args:Ds(`\n value (number) ${r("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Vs(e),n=Vs(t);return Ps((()=>n>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),i.toString())),n?Math.floor(i/n)*n:0},isExported:!0},za={description:r("Rounds number down to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n 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.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let n=Vs(t);if(0===n)return 0;const o=Vs(e);if(n=Math.abs(n),o>=0)return Math.floor(o/n)*n;return 0===Vs(i)?-Math.ceil(Math.abs(o)/n)*n:-Math.floor(Math.abs(o)/n)*n},isExported:!0},Ba={description:r("Rounds number down to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return za.compute(e,t,0)},isExported:!0},Ha={description:r("Whether the provided value is even."),args:Ds(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=zs(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Wa={description:r("Rounds number up to nearest multiple of factor."),args:Ds(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return ya.compute(e,t,0)},isExported:!0},Ga={description:r("Whether the provided value is even."),args:Ds(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=zs(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},qa={description:r("The logarithm of a number, base e (euler's number)."),args:Ds(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e);return Ps((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Za={description:r("Modulo (remainder) operator."),args:Ds(`\n dividend (number) ${r("The number to be divided to find the remainder.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Vs(t);Ps((()=>0!==i),r("The divisor must be different from 0."));const n=Vs(e)%i;return n>0&&i<0||n<0&&i>0?n+i:n},isExported:!0},ja={description:r("Rounds a number up to the nearest odd integer."),args:Ds(`\n value (number) ${r("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Vs(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},Ya={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Xa={description:r("A number raised to a power."),args:Ds(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Vs(e),n=Vs(t);return Ps((()=>i>=0||Number.isInteger(n)),r("The exponent (%s) must be an integer when the base is negative.",n.toString())),Math.pow(i,n)},isExported:!0},Ka={description:r("Result of multiplying a series of numbers together."),args:Ds(`\n factor1 (number, range<number>) ${r("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${r("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let n of e)if(Array.isArray(n))for(let e of n)for(let n of e)"number"==typeof n&&(i*=n,t+=1);else null!=n&&(i*=zs(n),t+=1);return 0===t?0:i},isExported:!0},Qa={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ja={description:r("Random integer between two values, inclusive."),args:Ds(`\n low (number) ${r("The low end of the random range.")}\n high (number) ${r("The high end of the random range.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Vs(e);Number.isInteger(i)||(i=Math.ceil(i));let n=Vs(t);return Number.isInteger(n)||(n=Math.floor(n)),Ps((()=>i<=n),r("The high (%s) must be greater than or equal to the low (%s).",n.toString(),i.toString())),i+Math.ceil((n-i+1)*Math.random())-1},isExported:!0},el={description:r("Rounds a number according to standard rules."),args:Ds(`\n value (number) ${r("The value to round to places number of places.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Vs(e);let n=Vs(t);const o=Math.abs(i);let r;return 0===n?r=Math.round(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.round(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},tl={description:r("Rounds down a number."),args:Ds(`\n value (number) ${r("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Vs(e);let n=Vs(t);const o=Math.abs(i);let r;return 0===n?r=Math.floor(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.floor(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},il={description:r("Rounds up a number."),args:Ds(`\n value (number) ${r("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Vs(e);let n=Vs(t);const o=Math.abs(i);let r;return 0===n?r=Math.ceil(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.ceil(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},nl={description:r("Secant of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Vs(e))},isExported:!0},ol={description:r("Hyperbolic secant of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Vs(e))},isExported:!0},rl={description:r("Sine of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Vs(e))},isExported:!0},sl={description:r("Hyperbolic sine of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Vs(e))},isExported:!0},al={description:r("Positive square root of a positive number."),args:Ds(`\n value (number) ${r("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Vs(e);return Ps((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},ll={description:r("Sum of a series of numbers and/or cells."),args:Ds(`\n value1 (number, range<number>) ${r("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${r("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return Js(e,((e,t)=>e+t),0)},isExported:!0},cl={description:r("A conditional sum across a range."),args:Ds(`\n criteria_range (range) ${r("The range which is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${r("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let n=0;return oa([e,t],((e,t)=>{const o=i[e][t];"number"==typeof o&&(n+=o)})),n},isExported:!0},hl={description:r("Sums a range depending on multiple criteria."),args:Ds(`\n sum_range (range) ${r("The range to sum.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges to check.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0;return oa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i+=o)})),i},isExported:!0},dl={description:r("Tangent of an angle provided in radians."),args:Ds(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Vs(e))},isExported:!0},ul={description:r("Hyperbolic tangent of any real number."),args:Ds(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Vs(e))},isExported:!0},gl={description:r("Truncates a number."),args:Ds(`\n value (number) ${r("The value to be truncated.")}\n places (number, default=0) ${r("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Vs(e);let n=Vs(t);return 0===n?Math.trunc(i):(Number.isInteger(n)||(n=Math.trunc(n)),Math.trunc(i*Math.pow(10,n))/Math.pow(10,n))},isExported:!0};var pl=Object.freeze({__proto__:null,ABS:ua,ACOS:ga,ACOSH:pa,ACOT:ma,ACOTH:fa,ASIN:va,ASINH:ba,ATAN:Sa,ATAN2:Ca,ATANH:Ea,CEILING:wa,CEILING_MATH:ya,CEILING_PRECISE:xa,COS:Ra,COSH:Ia,COT:Ta,COTH:Aa,COUNTBLANK:Oa,COUNTIF:Na,COUNTIFS:Ma,COUNTUNIQUE:Fa,COUNTUNIQUEIFS:Da,CSC:ka,CSCH:$a,DECIMAL:La,DEGREES:Pa,EXP:Ua,FLOOR:Va,FLOOR_MATH:za,FLOOR_PRECISE:Ba,ISEVEN:Ha,ISO_CEILING:Wa,ISODD:Ga,LN:qa,MOD:Za,ODD:ja,PI:Ya,POWER:Xa,PRODUCT:Ka,RAND:Qa,RANDBETWEEN:Ja,ROUND:el,ROUNDDOWN:tl,ROUNDUP:il,SEC:nl,SECH:ol,SIN:rl,SINH:sl,SQRT:al,SUM:ll,SUMIF:cl,SUMIFS:hl,TAN:dl,TANH:ul,TRUNC:gl});function ml(e,t,i){let n=[],o=[],s=0,a=0;Ys([e],(e=>{n.push(e),s+=1})),Ys([t],(e=>{o.push(e),a+=1})),Ps((()=>s===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",s.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<s;e++){const t=n[e],i=o[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}Ps((()=>0!==l&&(!i||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<s;e++){const t=n[e],i=o[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function fl(e,t,i){let n=0,o=0;const s=i?ea:Js;o=s(e,((e,t)=>(n+=1,e+t)),0),Ps((()=>0!==n&&(!t||1!==n)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=o/n;return s(e,((e,t)=>e+Math.pow(t-a,2)),0)/(n-(t?1:0))}function vl(e,t,i){const n=Vs(t);Ps((()=>i?0<=n&&n<=1:0<n&&n<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let o,s=[],a=0;return Ys(e,(e=>{"number"==typeof e&&(o=aa(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(o+1,0,e),a++)})),Ps((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),i||Ps((()=>1/(a+1)<=n&&n<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),yi(s,n,i)}const bl={description:r("Average magnitude of deviations from mean."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const i=Js(e,((e,i)=>(t+=1,e+i)),0);Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const n=i/t;return Js(e,((e,t)=>e+Math.abs(n-t)),0)/t},isExported:!0},Sl={description:r("Numerical average value in a dataset, ignoring text."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Js(e,((e,i)=>(t+=1,e+i)),0);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Cl=r("[[FUNCTION_NAME]] has mismatched range sizes."),El=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),wl={description:r("Weighted average."),args:Ds(`\n values (number, range<number>) ${r("Values to average.")}\n weights (number, range<number>) ${r("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${r("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${r("Additional weights.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,n=0,o=0;Ps((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let s=0;s<e.length-1;s+=2)if(t=e[s],i=e[s+1],Array.isArray(t)){Ps((()=>Array.isArray(i)),Cl);let e=t.length,s=t[0].length;Ps((()=>e===i.length&&s===i[0].length),Cl);for(let a=0;a<e;a++)for(let e=0;e<s;e++){let s=t[a][e],l=i[a][e],c="number"==typeof s,h="number"==typeof l;Ps((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(Ps((()=>l>=0),El),n+=s*l,o+=l)}}else i=Vs(i),t=Vs(t),Ps((()=>i>=0),El),n+=t*i,o+=i;return Ps((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o}},yl={description:r("Numerical average value in a dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=ea(e,((e,i)=>(t+=1,e+i)),0);return Ps((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},xl={description:r("Average of values depending on criteria."),args:Ds(`\n criteria_range (range) ${r("The range to check against criterion.")}\n criterion (string) ${r("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${r("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let n=0,o=0;return oa([e,t],((t,r)=>{const s=(i||e)[t][r];"number"==typeof s&&(n+=1,o+=s)})),Ps((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n},isExported:!0},Rl={description:r("Average of values depending on multiple criteria."),args:Ds(`\n average_range (range) ${r("The range to average.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0,n=0;return oa(t,((t,o)=>{const r=e[t][o];"number"==typeof r&&(i+=1,n+=r)})),Ps((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i},isExported:!0},Il={description:r("The number of numeric values in dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||Ci(i)||ve(i))&&(t+=1);return t},isExported:!0},Tl={description:r("The number of values in a dataset."),args:Ds(`\n value1 (any, range) ${r("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return Qs(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Al={description:r("The covariance of a dataset."),args:Ds(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ml(e,t,!1)},isExported:!0},Ol={description:r("The covariance of a dataset."),args:Ds(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ml(e,t,!1)},isExported:!0},Nl={description:r("The sample covariance of a dataset."),args:Ds(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ml(e,t,!0)},isExported:!0},Ml={description:r("Nth largest element from a data set."),args:Ds(`\n data (any, range) ${r("Array or range containing the dataset to consider.")}\n n (number) ${r("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Vs(t));let n,o=[],s=0;Ys([e],(e=>{"number"==typeof e&&(n=aa(o,e,"nextSmaller","asc",o.length,((e,t)=>e[t])),o.splice(n+1,0,e),s++,s>i&&(o.shift(),s--))}));const a=o.shift();return Ps((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Ps((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},_l={description:r("Maximum value in a numeric dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Js(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Fl={description:r("Maximum numeric value in a dataset."),args:Ds(`\n value1 (any, range) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=ea(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Dl={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:Ds(`\n range (range) ${r("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n 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.")}\n 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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return oa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i<o?o:i)})),i===-1/0?0:i},isExported:!0},kl={description:r("Median value in a numeric dataset."),args:Ds(`\n value1 (any, range) ${r("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return Xs(e,(e=>{t.push(e)})),vl(t,.5,!0)},isExported:!0},$l={description:r("Minimum value in a numeric dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Js(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Ll={description:r("Minimum numeric value in a dataset."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=ea(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Pl={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:Ds(`\n range (range) ${r("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n 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.")}\n 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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=1/0;return oa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i>o?o:i)})),i===1/0?0:i},isExported:!0},Ul={description:r("Value at a given percentile of a dataset."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return zl.compute(e,t)},isExported:!0},Vl={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return vl([e],t,!1)},isExported:!0},zl={description:r("Value at a given percentile of a dataset."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return vl([e],t,!0)},isExported:!0},Bl={description:r("Value nearest to a specific quartile of a dataset."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Wl.compute(e,t)},isExported:!0},Hl={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return vl([e],.25*Math.trunc(Vs(t)),!1)},isExported:!0},Wl={description:r("Value nearest to a specific quartile of a dataset."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return vl([e],.25*Math.trunc(Vs(t)),!0)},isExported:!0},Gl={description:r("Nth smallest element in a data set."),args:Ds(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n n (number) ${r("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Vs(t));let n,o=[],s=0;Ys([e],(e=>{"number"==typeof e&&(n=aa(o,e,"nextSmaller","asc",o.length,((e,t)=>e[t])),o.splice(n+1,0,e),s++,s>i&&(o.pop(),s--))}));const a=o.pop();return Ps((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Ps((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},ql={description:r("Standard deviation."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ql.compute(...e))},isExported:!0},Zl={description:r("Standard deviation of entire population."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Jl.compute(...e))},isExported:!0},jl={description:r("Standard deviation."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(ec.compute(...e))},isExported:!0},Yl={description:r("Standard deviation of sample (text as 0)."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(tc.compute(...e))},isExported:!0},Xl={description:r("Standard deviation of entire population."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(ic.compute(...e))},isExported:!0},Kl={description:r("Standard deviation of entire population (text as 0)."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(nc.compute(...e))},isExported:!0},Ql={description:r("Variance."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!0,!1)},isExported:!0},Jl={description:r("Variance of entire population."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!1,!1)},isExported:!0},ec={description:r("Variance."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!0,!1)},isExported:!0},tc={description:r("Variance of sample (text as 0)."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!0,!0)},isExported:!0},ic={description:r("Variance of entire population."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!1,!1)},isExported:!0},nc={description:r("Variance of entire population (text as 0)."),args:Ds(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return fl(e,!1,!0)},isExported:!0};var oc=Object.freeze({__proto__:null,AVEDEV:bl,AVERAGE:Sl,AVERAGE_WEIGHTED:wl,AVERAGEA:yl,AVERAGEIF:xl,AVERAGEIFS:Rl,COUNT:Il,COUNTA:Tl,COVAR:Al,COVARIANCE_P:Ol,COVARIANCE_S:Nl,LARGE:Ml,MAX:_l,MAXA:Fl,MAXIFS:Dl,MEDIAN:kl,MIN:$l,MINA:Ll,MINIFS:Pl,PERCENTILE:Ul,PERCENTILE_EXC:Vl,PERCENTILE_INC:zl,QUARTILE:Bl,QUARTILE_EXC:Hl,QUARTILE_INC:Wl,SMALL:Gl,STDEV:ql,STDEV_P:Zl,STDEV_S:jl,STDEVA:Yl,STDEVP:Xl,STDEVPA:Kl,VAR:Ql,VAR_P:Jl,VAR_S:ec,VARA:tc,VARP:ic,VARPA:nc});function rc(e,t,i){var n;const o=new Map,s=e.length;for(let t=s-1;t>=0;t--)o.set(Bs(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||s-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(),s.toString()))}else{const e=Bs(t).toUpperCase();if(a=null!==(n=o.get(e))&&void 0!==n?n:-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Bs(t),[...o.keys()].toString()))}const l=i[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 n=[],r=!0;for(let s=0;s<i.length;s++){const a=Bs(i[s][0]).toUpperCase(),l=o.get(a),c=i[s][t];if(void 0!==c){if(void 0===l){r=!1;break}n.push([e[l].slice(1,h)]),n.push(c)}}if(r){if(!(n.length>0)){c=new Set(Array(h-1).keys());break}oa(n,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const sc=Ds(`\n 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.")}\n field (any) ${r("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${r("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),ac={description:r("Average of a set of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Sl.compute([n])},isExported:!0},lc={description:r("Counts values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Il.compute([n])},isExported:!0},cc={description:r("Counts values and text from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Tl.compute([n])},isExported:!0},hc={description:r("Single value from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Ps((()=>1===n.length),r("More than one match found in DGET evaluation.")),n[0]},isExported:!0},dc={description:r("Maximum of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return _l.compute([n])},isExported:!0},uc={description:r("Minimum of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return $l.compute([n])},isExported:!0},gc={description:r("Product of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Ka.compute([n])},isExported:!0},pc={description:r("Standard deviation of population sample from table."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return ql.compute([n])},isExported:!0},mc={description:r("Standard deviation of entire population from table."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Xl.compute([n])},isExported:!0},fc={description:r("Sum of values from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return ll.compute([n])},isExported:!0},vc={description:r("Variance of population sample from table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return Ql.compute([n])},isExported:!0},bc={description:r("Variance of a population from a table-like range."),args:sc,returns:["NUMBER"],compute:function(e,t,i){const n=rc(e,t,i);return ic.compute([n])},isExported:!0};var Sc=Object.freeze({__proto__:null,DAVERAGE:ac,DCOUNT:lc,DCOUNTA:cc,DGET:hc,DMAX:dc,DMIN:uc,DPRODUCT:gc,DSTDEV:pc,DSTDEVP:mc,DSUM:fc,DVAR:vc,DVARP:bc});const Cc={description:r("Converts year/month/day into a date."),args:Ds(`\n year (number) ${r("The year component of the date.")}\n month (number) ${r("The month component of the date.")}\n day (number) ${r("The day component of the date.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let n=Math.trunc(Vs(e));const o=Math.trunc(Vs(t)),s=Math.trunc(Vs(i));Ps((()=>0<=n&&n<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",n.toString())),n<1900&&(n+=1900);const a=Ce(new ae(n,o-1,s));return Ps((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Ec={description:r("Converts a date string to a date value."),args:Ds(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e),i=ve(t);return Ps((()=>null!==i),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},wc={description:r("Day of the month that a specific date falls on."),args:Ds(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getDate()},isExported:!0},yc={description:r("Number of days between two dates."),args:Ds(`\n end_date (date) ${r("The end of the date range.")}\n start_date (date) ${r("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Zs(e),n=Zs(t),o=i.getTime()-n.getTime();return Math.round(o/ce)},isExported:!0},xc={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:Ds(`\n start_date (date) ${r("The start date to consider in the calculation.")}\n end_date (date) ${r("The end date to consider in the calculation.")}\n method (number, default=0) ${r("An indicator of what day count method to use. (0) US NASD method (1) European method")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){const n=Vs(e),o=Vs(t),r=qs(i)?4:0,s=Wc.compute(e,t,r);return Math.sign(o-n)*Math.round(360*s)},isExported:!0},Rc={description:r("Date a number of months before/after another date."),args:Ds(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return Ce(ye(Zs(e),Math.trunc(Vs(t)),!1))},isExported:!0},Ic={description:r("Last day of a month before or after a date."),args:Ds(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Zs(e),n=Math.trunc(Vs(t)),o=i.getFullYear(),r=i.getMonth();return Ce(new ae(o,r+n+1,0))},isExported:!0},Tc={description:r("Hour component of a specific time."),args:Ds(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getHours()},isExported:!0},Ac={description:r("ISO week number of the year."),args:Ds(`\n 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.")}\n `),returns:["NUMBER"],compute:function(e){const t=Zs(e),i=t.getFullYear();let n=1;for(;4!==new ae(i,0,n).getDay();)n+=1;const o=new ae(i,0,n-3);let r=31;for(;4!==new ae(i,11,r).getDay();)r-=1;const s=new ae(i,11,r+3);let a,l;switch(a=o.getTime()<=t.getTime()?t.getTime()<=s.getTime()?0:1:-1,a){case 0:l=o;break;case 1:l=new ae(i,11,r+3+1);break;case-1:let e=1;for(;4!==new ae(i-1,0,e).getDay();)e+=1;l=new ae(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ce;return Math.floor(c/7)+1},isExported:!0},Oc={description:r("Minute component of a specific time."),args:Ds(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getMinutes()},isExported:!0},Nc={description:r("Month of the year a specific date falls in"),args:Ds(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getMonth()+1},isExported:!0},Mc={description:r("Net working days between two provided days."),args:Ds(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i){return Fc.compute(e,t,1,i)},isExported:!0};function _c(e){if("string"==typeof e){Ps((()=>{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 i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return Ps((()=>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 Fc={description:r("Net working days between two dates (specifying weekends)."),args:Ds(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1,n){const o=Zs(e),r=Zs(t),s=_c(i);let a=new Set;void 0!==n&&Ys([n],(e=>{const t=Zs(e);a.add(t.getTime())}));const l=o.getTime()>r.getTime(),c=ae.fromTimestamp((l?o:r).getTime());let h=ae.fromTimestamp((l?r:o).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)s.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Dc={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=ae.now();const t=e.getTime()-le.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ce)+i},isExported:!0},kc={description:r("Minute component of a specific time."),args:Ds(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getSeconds()},isExported:!0},$c={description:r("Converts hour/minute/second into a time."),args:Ds(`\n hour (number) ${r("The hour component of the time.")}\n minute (number) ${r("The minute component of the time.")}\n second (number) ${r("The second component of the time.")}\n `),returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t)),s=Math.trunc(Vs(i));return o+=Math.floor(s/60),s=s%60+(s<0?60:0),n+=Math.floor(o/60),o=o%60+(o<0?60:0),n%=24,Ps((()=>n>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),n/24+o/1440+s/86400},isExported:!0},Lc={description:r("Converts a time string into its serial number representation."),args:Ds(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e),i=ve(t);Ps((()=>null!==i),r("The time_string (%s) cannot be parsed to date/time.",t));const n=i.value-Math.trunc(i.value);return n<0?1+n:n},isExported:!0},Pc={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=ae.now();return Ce(new ae(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Uc={description:r("Day of the week of the date provided (as number)."),args:Ds(`\n 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.")}\n type (number, default=1) ${r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Zs(e),n=Math.round(Vs(t)),o=i.getDay();return Ps((()=>[1,2,3].includes(n)),r("The type (%s) must be 1, 2 or 3.",n.toString())),1===n?o+1:2===n?0===o?7:o:0===o?6:o-1},isExported:!0},Vc={description:r("Week number of the year."),args:Ds(`\n 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.")}\n type (number, default=1) ${r("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Zs(e),n=Math.round(Vs(t));if(Ps((()=>1===n||2===n||11<=n&&n<=17||21===n),r("The type (%s) is out of range.",n.toString())),21===n)return Ac.compute(e);let o;o=1===n||2===n?n-1:n-10==7?0:n-10;const s=i.getFullYear();let a=1,l=new ae(s,0,a);for(;l.getDay()!==o;)a+=1,l=new ae(s,0,a);const c=(i.getTime()-l.getTime())/ce;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},zc={description:r("Date after a number of workdays."),args:Ds(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Bc.compute(e,t,1,i)},isExported:!0},Bc={description:r("Date after a number of workdays (specifying weekends)."),args:Ds(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,n){let o=Zs(e),s=Math.trunc(Vs(t));"string"==typeof i&&Ps((()=>"1111111"!==i),r("The weekend (%s) must be different from '1111111'.",i));const a=_c(i);let l=new Set;void 0!==n&&Ys([n],(e=>{const t=Zs(e);l.add(t.getTime())}));let c=ae.fromTimestamp(o.getTime()),h=c.getTime();const d=Math.sign(s);let u=Math.abs(s);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-le.getTime();return Math.round(g/ce)},isExported:!0},Hc={description:r("Year specified by a given date."),args:Ds(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Zs(e).getFullYear()},isExported:!0},Wc={description:r("Exact number of years between two dates."),args:Ds(`\n 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.")}\n 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.")}\n day_count_convention (number, default=0) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){let n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t));const s=Math.trunc(Vs(i));return Ps((()=>n>=0),r("The start_date (%s) must be positive or null.",n.toString())),Ps((()=>o>=0),r("The end_date (%s) must be positive or null.",o.toString())),Ps((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),Re(n,o,s)}},Gc={description:r("First day of the month preceding a date."),args:Ds(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Zs(e),i=t.getFullYear(),n=t.getMonth();return Ce(new ae(i,n,1))}},qc={description:r("Last day of the month following a date."),args:Ds(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return Ic.compute(e,0)}},Zc={description:r("Quarter of the year a specific date falls in"),args:Ds(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Zs(e).getMonth()+1)/3)}},jc={description:r("First day of the quarter of the year a specific date falls in."),args:Ds(`\n date (date) ${r("The date from which to calculate the start of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Zc.compute(e),i=Hc.compute(e);return Ce(new ae(i,3*(t-1),1))}},Yc={description:r("Last day of the quarter of the year a specific date falls in."),args:Ds(`\n date (date) ${r("The date from which to calculate the end of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Zc.compute(e),i=Hc.compute(e);return Ce(new ae(i,3*t,0))}},Xc={description:r("First day of the year a specific date falls in."),args:Ds(`\n date (date) ${r("The date from which to calculate the start of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Hc.compute(e);return Ce(new ae(t,0,1))}},Kc={description:r("Last day of the year a specific date falls in."),args:Ds(`\n date (date) ${r("The date from which to calculate the end of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Hc.compute(e);return Ce(new ae(t+1,0,0))}};var Qc=Object.freeze({__proto__:null,DATE:Cc,DATEVALUE:Ec,DAY:wc,DAYS:yc,DAYS360:xc,EDATE:Rc,EOMONTH:Ic,HOUR:Tc,ISOWEEKNUM:Ac,MINUTE:Oc,MONTH:Nc,NETWORKDAYS:Mc,NETWORKDAYS_INTL:Fc,NOW:Dc,SECOND:kc,TIME:$c,TIMEVALUE:Lc,TODAY:Pc,WEEKDAY:Uc,WEEKNUM:Vc,WORKDAY:zc,WORKDAY_INTL:Bc,YEAR:Hc,YEARFRAC:Wc,MONTH_START:Gc,MONTH_END:qc,QUARTER:Zc,QUARTER_START:jc,QUARTER_END:Yc,YEAR_START:Xc,YEAR_END:Kc});const Jc={description:r("Compare two numeric values, returning 1 if they're equal."),args:Ds(`\n number1 (number) ${r("The first number to compare.")}\n number2 (number, default=0) ${r("The second number to compare.")}\n `),returns:["NUMBER"],compute:function(e,t=0){return Vs(e)===Vs(t)?1:0},isExported:!0};var eh=Object.freeze({__proto__:null,DELTA:Jc});function th(e,t){Ps((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function ih(e,t){Ps((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function nh(e){Ps((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function oh(e){Ps((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function rh(e){Ps((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function sh(e){Ps((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function ah(e){Ps((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function lh(e){Ps((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function ch(e){Ps((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function hh(e){Ps((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function dh(e){Ps((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function uh(e){Ps((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function gh(e){Ps((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function ph(e,t){Ps((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function mh(e){Ps((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function fh(e){Ps((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function vh(e){Ps((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function bh(e){Ps((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Sh(e,t){const i=Zs(e),n=Zs(t),o=Zs(e);o.setFullYear(i.getFullYear()+1),Ps((()=>n.getTime()<=o.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Ch(e,t,i){ah(i),Ps((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),Ps((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),Ps((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Ps((()=>t<=i),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function Eh(e){Ps((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function wh(e,t){Ps((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function yh(e){Ps((()=>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 xh=Ds(`\nsettlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\nmaturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\nfrequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\nday_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n`);function Rh(e,t,i,n,o=1e-10,s){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(Ps((()=>g<n&&void 0!==s),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=s(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<o||Math.abs(c)<o,Ps((()=>g<n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Ih={description:r("Accrued interest of security paying at maturity."),args:Ds(`\n issue (date) ${r("The date the security was initially issued.")}\n maturity (date) ${r("The maturity date of the security.")}\n rate (number) ${r("The annualized rate of interest.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(n),l=Vs(i),c=Math.trunc(Vs(o));ih(s,r),oh(c),rh(a),lh(l);return a*l*Wc.compute(r,s,o)},isExported:!0},Th={description:r("Depreciation for an accounting period."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n purchase_date (date) ${r("The date the asset was purchased.")}\n first_period_end (date) ${r("The date the first period ended.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n rate (number) ${r("The deprecation rate.")}\n day_count_convention (number, optional) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Vs(e),c=Math.trunc(Vs(t)),h=Math.trunc(Vs(i)),d=Vs(n),u=Vs(o),g=Vs(s),p=Math.trunc(Vs(a));!function(e){Ps((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),uh(d),function(e,t){Ps((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Ps((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),lh(g),oh(p),Ps((()=>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,v=Wc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},Ah={description:r("Days in coupon period containing settlement date."),args:xh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));if(th(o,r),nh(s),oh(a),1===a){const o=Fh.compute(e,t,i,n);return Mh.compute(e,t,i,n)-o}return(3===a?365:360)/s},isExported:!0},Oh={description:r("Days from settlement until next coupon."),args:xh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);const l=Fh.compute(o,r,i,n);if([1,2,3].includes(a))return o-l;if(4===a){const e=Re(l,o,a);return Math.round(360*e)}const c=Zs(o),h=Zs(l),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&&we(h)&&we(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&we(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Nh={description:r("Days from settlement until next coupon."),args:xh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);const l=Mh.compute(o,r,i,n);if([1,2,3].includes(a))return l-o;if(4===a){const e=Re(o,l,a);return Math.round(360*e)}const c=Oh.compute(e,t,i,a);return Ah.compute(e,t,i,a)-c},isExported:!0},Mh={description:r("Next coupon date after the settlement date."),args:xh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);const l=12/s,c=_h.compute(e,t,i,n);return Ce(ye(Zs(r),-(c-1)*l,!0))},isExported:!0},_h={description:r("Number of coupons between settlement and maturity."),args:xh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);let l=1,c=r;const h=12/s;for(;c>o;)c=Ce(ye(Zs(c),-h,!1)),l++;return l-1},isExported:!0},Fh={description:r("Last coupon date prior to or on the settlement date."),args:xh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Vs(e)),r=Math.trunc(Vs(t)),s=Math.trunc(Vs(i)),a=Math.trunc(Vs(n));th(o,r),nh(s),oh(a);const l=12/s,c=_h.compute(e,t,i,n);return Ce(ye(Zs(r),-c*l,!0))},isExported:!0},Dh={description:r("Cumulative interest paid over a set of periods."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){const s=Vs(n),a=Vs(o),l=Vs(e),c=Vs(i),h=Vs(t);Ch(s,a,h),lh(l),gh(c);let d=0;for(let t=s;t<=a;t++){d+=qh.compute(e,t,h,i,0,r)}return d},isExported:!0},kh={description:r("Cumulative principal paid over a set of periods."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){const s=Vs(n),a=Vs(o),l=Vs(e),c=Vs(i),h=Vs(t);Ch(s,a,h),lh(l),gh(c);let d=0;for(let t=s;t<=a;t++){d+=id.compute(e,t,h,i,0,r)}return d},isExported:!0},$h={description:r("Depreciation via declining balance method."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${r("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,...o){const s=Vs(e),a=Vs(t),l=Vs(i),c=Math.trunc(Vs(n)),h=o.length?Math.trunc(Vs(o[0])):12,d=l+(12===h?0:1);hh(s),uh(a),dh(c),ch(l),Ps((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Ps((()=>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/s,1/l);g=Math.round(1e3*g)/1e3;let p=s,m=s*(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},Lh={description:r("Depreciation via double-declining balance method."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n factor (number, default=2) ${r("The factor by which depreciation decreases.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=2){o=o||0;const r=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n),c=Vs(o);if(hh(r),uh(s),dh(l),ch(a),ph(l,a),bh(c),0===r||s>=r)return 0;const h=c/a;if(h>1)return 1===n?r-s: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<s?d-s:d-u;return Math.max(g,0)},isExported:!0},Ph={description:r("Discount rate of a security based on price."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(i),l=Vs(n),c=Math.trunc(Vs(o));th(r,s),oh(c),sh(a),rh(l);return(l-a)/l/Wc.compute(r,s,c)},isExported:!0},Uh={description:r("Convert a decimal fraction to decimal value."),args:Ds(`\n fractional_price (number) ${r("The price quotation given using fractional decimal conventions.")}\n unit (number) ${r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Math.trunc(Vs(t));Ps((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const o=Math.trunc(i);return o+(i-o)*(10**Math.ceil(Math.log10(n))/n)},isExported:!0},Vh={description:r("Convert a decimal value to decimal fraction."),args:Ds(`\n decimal_price (number) ${r("The price quotation given as a decimal value.")}\n unit (number) ${r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Math.trunc(Vs(t));Ps((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const o=Math.trunc(i);return o+(i-o)*(n/10**Math.ceil(Math.log10(n)))},isExported:!0},zh={description:r("Number of periods for an investment to reach a value."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Vs(e)),l=Math.trunc(Vs(t)),c=Vs(i),h=Vs(n),d=Math.trunc(Vs(o)),u=Math.trunc(Vs(s));th(a,l),nh(d),oh(u),Ps((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),Ps((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=Wc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Bh={description:r("Annual effective interest rate."),args:Ds(`\n nominal_rate (number) ${r("The nominal interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Math.trunc(Vs(t));return Ps((()=>i>0),r("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Ps((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),Math.pow(1+i/n,n)-1},isExported:!0},Hh={description:r("Future value of an annuity investment."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n present_value (number, default=0) ${r("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n),c=qs(o)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},Wh={description:r("Future value of principal from series of rates."),args:Ds(`\n principal (number) ${r("The amount of initial capital or value to compound against.")}\n rate_schedule (number, range<number>) ${r("A series of interest rates to compound against the principal.")}\n `),returns:["NUMBER"],compute:function(e,t){return Qs([t],((e,t)=>e*(1+Vs(t))),Vs(e))},isExported:!0},Gh={description:r("Calculates effective interest rate."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested in the security.")}\n redemption (number) ${r("The amount to be received at maturity.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(n),l=Vs(i);th(r,s),mh(l),rh(a);return(a-l)/l/Wc.compute(r,s,o)},isExported:!0},qh={description:r("Payment on the principal of an investment."),args:Ds(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=0,r=0){return td.compute(e,i,n,o,r)-id.compute(e,t,i,n,o,r)},isExported:!0},Zh={description:r("Internal rate of return given periodic cashflows."),args:Ds(`\n cashflow_amounts (number, range<number>) ${r("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Vs(t);Eh(i);let n=!1,o=!1,s=[];Xs([e],(e=>{e>0&&(n=!0),e<0&&(o=!0),s.push(e)})),Ps((()=>n&&o),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return Rh((function(e){return function(e,t,i){const n=i.length;let o=0;return i.reduce(((t,i)=>(o++,t+i*e**(n-o))),t*e**n)}(e,a,s)}),(function(e){return function(e,t,i){const n=i.length;let o=0;return i.reduce(((t,i)=>(o++,t+i*(n-o)*e**(n-o-1))),t*n*e**(n-1))}(e,a,s)}),i+1,20,1e-5)-1},isExported:!0},jh={description:r("Returns the interest paid at a particular period of an investment."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n period (number) ${r("The period for which you want to view the interest payment.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n){const o=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n);Ps((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*o},isExported:!0},Yh={description:r("Modified Macaulay duration."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){return zh.compute(e,t,i,n,o,r)/(1+Vs(n)/Math.trunc(Vs(o)))},isExported:!0},Xh={description:r("Modified internal rate of return."),args:Ds(`\n cashflow_amounts (range<number>) ${r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")}\n financing_rate (number) ${r("The interest rate paid on funds invested.")}\n reinvestment_return_rate (number) ${r("The return (as a percentage) earned on reinvestment of income received from the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Vs(t),o=Vs(i),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Xe).map(Vs);var a;const l=s.length;let c=0,h=0;for(const e of $e(0,l)){const t=s[e];t>=0?c+=t*(o+1)**(l-e-1):h+=t/(n+1)**e}Ps((()=>0!==h&&0!==c),r("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},Kh={description:r("Annual nominal interest rate."),args:Ds(`\n effective_rate (number) ${r("The effective interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Vs(e),n=Math.trunc(Vs(t));return Ps((()=>i>0),r("The effective rate (%s) must must strictly greater than 0.",i.toString())),Ps((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),(Math.pow(i+1,1/n)-1)*n},isExported:!0},Qh={description:r("Number of payment periods for an investment."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n payment_amount (number) ${r("The amount of each payment made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n),c=qs(o)?1:0;if(0===r)return-(l+a)/s;const h=s*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const Jh={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:Ds(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${r("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${r("Additional future cash flows.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Vs(e);return Ps((()=>-1!==i),r("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let n=0;return Js(i,((t,i)=>(n++,t+i/(1+e)**n)),t)}(i,0,t)},isExported:!0},ed={description:r("Computes the number of periods needed for an investment to reach a value."),args:Ds(`\n rate (number) ${r("The rate at which the investment grows each period.")}\n present_value (number) ${r("The investment's current value.")}\n future_value (number) ${r("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Vs(e),o=Vs(t),s=Vs(i);return lh(n),Ps((()=>o>0),r("The present_value (%s) must be strictly positive.",o.toString())),Ps((()=>s>0),r("The future_value (%s) must be strictly positive.",s.toString())),(Math.log(s)-Math.log(o))/Math.log(1+n)},isExported:!0},td={description:r("Periodic payment for an annuity investment."),args:Ds(`\n rate (number) ${r("The annualized rate of interest.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Vs(t),s=Vs(e),a=qs(o)?1:0;let l=Vs(n),c=Vs(i);if(ah(r),0===s)return-(l+c)/r;let h=-(c*(1+s)**r+l);return h=h*s/((1+s*a)*((1+s)**r-1)),h},isExported:!0},id={description:r("Payment on the principal of an investment."),args:Ds(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=0,s=0){o=o||0,s=s||0;const a=Vs(i),l=Vs(e),c=Vs(t),h=qs(s)?1:0,d=Vs(o),u=Vs(n);ah(a),Ps((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=td.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-Hh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},nd={description:r("Present value of an annuity investment."),args:Ds(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Vs(e),s=Vs(t),a=Vs(i),l=Vs(n),c=qs(o)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},od={description:r("Price of a security paying periodic interest."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Math.trunc(Vs(e)),c=Math.trunc(Vs(t)),h=Vs(i),d=Vs(n),u=Vs(o),g=Math.trunc(Vs(s)),p=Math.trunc(Vs(a));th(l,c),nh(g),oh(p),Ps((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Ps((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),rh(u);const m=Wc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},rd={description:r("Price of a discount security."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the security at time of purchase.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(i),l=Vs(n),c=Math.trunc(Vs(o));th(r,s),oh(c),fh(a),rh(l);return l-a*l*Wc.compute(r,s,c)},isExported:!0},sd={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Vs(e)),l=Math.trunc(Vs(t)),c=Math.trunc(Vs(i)),h=Vs(n),d=Vs(o),u=Math.trunc(Vs(s));ih(a,c),th(a,l),oh(u),Ps((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Ps((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=Wc.compute(a,l,u),p=Wc.compute(a,c,u);return(100+Wc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},ad=.1,ld={description:r("Interest rate of an annuity investment."),args:Ds(`\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_per_period (number) ${r("The amount per period to be paid.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the interest rate will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,n=0,o=0,s=.1){n=n||0,o=o||0,s=s||ad;const a=Vs(e),l=Vs(t),c=qs(o)?1:0,h=Vs(s);let d=Vs(n),u=Vs(i);ah(a),Ps((()=>[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())),Eh(h),d-=l*c,u+=l*c;return Rh((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),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},cd={description:r("Amount received at maturity for a security."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested (irrespective of face value of each security).")}\n discount (number) ${r("The discount rate of the security invested in.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(i),l=Vs(n),c=Math.trunc(Vs(o));th(r,s),oh(c),mh(a),fh(l);return a/(1-l*Wc.compute(r,s,c))},isExported:!0},hd={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:Ds(`\n number_of_periods (number) ${r("The number of periods.")}\n present_value (number) ${r("The present value of the investment.")}\n future_value (number) ${r("The future value of the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Vs(e),o=Vs(t),r=Vs(i);return ah(n),(r/o)**(1/n)-1},isExported:!0},dd={description:r("Depreciation of an asset using the straight-line method."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Vs(e)-Vs(t))/Vs(i)},isExported:!0},ud={description:r("Depreciation via sum of years digit method."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n){const o=Vs(e),r=Vs(t),s=Vs(i),a=Vs(n);dh(a),ch(s),ph(a,s);return(s-a+1)/(s*(s+1)/2)*(o-r)},isExported:!0},gd={description:r("Price of a US Treasury bill."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t)),r=Vs(i);th(n,o),Sh(n,o),fh(r),vh(r);return 100*(1-r*Wc.compute(n,o,2))},isExported:!0},pd={description:r("Equivalent rate of return for a US Treasury bill."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t)),r=Vs(i);th(n,o),Sh(n,o),fh(r),vh(r);const s=yc.compute(o,n);if(s<=182)return 365*r/(360-r*s);const a=gd.compute(n,o,r)/100,l=s/(366===s?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},md={description:r("The yield of a US Treasury bill based on price."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Vs(e)),o=Math.trunc(Vs(t)),r=Vs(i);th(n,o),Sh(n,o),sh(r);return(100-r)/r*(1/Wc.compute(n,o,2))},isExported:!0},fd={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:Ds(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n start (number) ${r("Starting period to calculate depreciation.")}\n end (number) ${r("Ending period to calculate depreciation.")}\n factor (number, default=2) ${r("The number of months in the first year of depreciation.")}\n no_switch (number, default=false) ${r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=2,a=false){s=s||0;const l=Vs(e),c=Vs(t),h=Vs(i),d=Math.trunc(Vs(n)),u=Math.trunc(Vs(o)),g=Vs(s),p=qs(a);if(hh(l),uh(c),function(e,t,i){ch(i),Ps((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),Ps((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),Ps((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Ps((()=>t<=i),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),bh(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,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},vd={description:r("Internal rate of return given non-periodic cash flows."),args:Ds(`\n cashflow_amounts (range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],compute:function(e,t,i=.1){const n=Vs(i=i||0),o=e.flat().map(Vs),s=t.flat().map(Vs);var a;wh(e,t),a=o,Ps((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),yh(s),Eh(n);const l=new Map;for(const e of $e(0,s.length)){const t=s[e];l.has(t)?l.set(t,l.get(t)+o[e]):l.set(t,o[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return Rh((e=>{let t=h[0];for(const i of $e(1,h.length)){const n=(c[0]-c[i])/365;t+=h[i]*(1+e)**n}return t}),(e=>{let t=0;for(const i of $e(1,h.length)){const n=(c[0]-c[i])/365;t+=n*h[i]*(1+e)**(n-1)}return t}),n,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},bd={description:r("Net present value given to non-periodic cash flows.."),args:Ds(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow_amounts (number, range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (number, range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Vs(e),o=Array.isArray(t)?t.flat().map(zs):[zs(t)],s=Array.isArray(i)?i.flat().map(zs):[zs(i)];if(Array.isArray(i)&&Array.isArray(t)?wh(t,i):Ps((()=>o.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),yh(s),lh(n),1===o.length)return o[0];const a=new Map;for(const e of $e(0,s.length)){const t=s[e];a.has(t)?a.set(t,a.get(t)+o[e]):a.set(t,o[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of $e(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+n)**t}return h},isExported:!0},Sd={description:r("Annual yield of a security paying periodic interest."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Math.trunc(Vs(e)),c=Math.trunc(Vs(t)),h=Vs(i),d=Vs(n),u=Vs(o),g=Math.trunc(Vs(s)),p=Math.trunc(Vs(a));th(l,c),nh(g),oh(p),Ps((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),sh(d),rh(u);const m=Wc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=Rh((function(e){return function(e,t,i,n,o,r){let s=r-(e+o*(1-t))*n**(i-1+t);for(let e=1;e<=i;e++)s+=o*n**(e-1);return s}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,n,o){let r=-(e+o*(1-t))*(i-1+t)*n**(i-2+t);for(let e=1;e<=i;e++)r+=o*(e-1)*n**(e-2);return r}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Cd={description:r("Annual yield of a discount security."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Vs(e)),s=Math.trunc(Vs(t)),a=Vs(i),l=Vs(n),c=Math.trunc(Vs(o));th(r,s),oh(c),sh(a),rh(l);return(l/a-1)/Wc.compute(e,t,o)},isExported:!0},Ed={description:r("Annual yield of a security paying interest at maturity."),args:Ds(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Vs(e)),l=Math.trunc(Vs(t)),c=Math.trunc(Vs(i)),h=Vs(n),d=Vs(o),u=Math.trunc(Vs(s));th(a,l),oh(u),Ps((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Ps((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),sh(d);const g=Wc.compute(c,l,u),p=Wc.compute(c,a,u),m=Wc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var wd=Object.freeze({__proto__:null,ACCRINTM:Ih,AMORLINC:Th,COUPDAYS:Ah,COUPDAYBS:Oh,COUPDAYSNC:Nh,COUPNCD:Mh,COUPNUM:_h,COUPPCD:Fh,CUMIPMT:Dh,CUMPRINC:kh,DB:$h,DDB:Lh,DISC:Ph,DOLLARDE:Uh,DOLLARFR:Vh,DURATION:zh,EFFECT:Bh,FV:Hh,FVSCHEDULE:Wh,INTRATE:Gh,IPMT:qh,IRR:Zh,ISPMT:jh,MDURATION:Yh,MIRR:Xh,NOMINAL:Kh,NPER:Qh,NPV:Jh,PDURATION:ed,PMT:td,PPMT:id,PV:nd,PRICE:od,PRICEDISC:rd,PRICEMAT:sd,RATE:ld,RECEIVED:cd,RRI:hd,SLN:dd,SYD:ud,TBILLPRICE:gd,TBILLEQ:pd,TBILLYIELD:md,VDB:fd,XIRR:vd,XNPV:bd,YIELD:Sd,YIELDDISC:Cd,YIELDMAT:Ed});const yd={description:r("Whether a value is an error other than #N/A."),args:Ds(`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(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},xd={description:r("Whether a value is an error."),args:Ds(`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},Rd={description:r("Whether a value is `true` or `false`."),args:Ds(`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},Id={description:r("Whether a value is the error #N/A."),args:Ds(`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(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},Td={description:r("Whether a value is non-textual."),args:Ds(`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},Ad={description:r("Whether a value is a number."),args:Ds(`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},Od={description:r("Whether a value is text."),args:Ds(`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},Nd={description:r("Whether the referenced cell is empty"),args:Ds(`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},Md={description:r("Returns the error value #N/A."),args:Ds(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var _d=Object.freeze({__proto__:null,ISERR:yd,ISERROR:xd,ISLOGICAL:Rd,ISNA:Id,ISNONTEXT:Td,ISNUMBER:Ad,ISTEXT:Od,ISBLANK:Nd,NA:Md});const Fd={description:r("Logical `and` operator."),args:Ds(`\n 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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return ta(e,(e=>(t=!0,i=i&&e,i))),Ps((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Dd={description:r("Returns value depending on logical expression."),args:Ds(`\n logical_expression (boolean) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")}\n value_if_true (any, lazy) ${r("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${r("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,i=(()=>!1)){const n=qs(e)?t():i();return null==n?"":n},isExported:!0},kd={description:r("Value if it is not an error, otherwise 2nd argument."),args:Ds(`\n value (any, lazy) ${r("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an error.")}\n `),returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},$d={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:Ds(`\n value (any, lazy) ${r("The value to return if value itself is not #N/A an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an #N/A error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(n){i=n.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},Ld={description:r("Returns a value depending on multiple logical expressions."),args:Ds(`\n 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.")}\n value1 (any, lazy) ${r("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${r("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${r("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){Ps((()=>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(qs(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(r("No match."))},isExported:!0},Pd={description:r("Returns opposite of provided logical value."),args:Ds(`logical_expression (boolean) ${r("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!qs(e)},isExported:!0},Ud={description:r("Logical `or` operator."),args:Ds(`\n 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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return ta(e,(e=>(t=!0,i=i||e,!i))),Ps((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Vd={description:r("Logical `xor` operator."),args:Ds(`\n 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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return ta(e,(e=>(t=!0,i=i?!e:e,!0))),Ps((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var zd=Object.freeze({__proto__:null,AND:Fd,IF:Dd,IFERROR:kd,IFNA:$d,IFS:Ld,NOT:Pd,OR:Ud,XOR:Vd});const Bd={description:r("Column number of a specified cell."),args:Ds(`cell_reference (meta, default=${r("The cell in which the formula is entered")}) ${r("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Ps((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Ni(i).left+1},isExported:!0},Hd={description:r("Number of columns in a specified array or range."),args:Ds(`range (meta) ${r("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Ni(e);return t.right-t.left+1},isExported:!0},Wd={description:r("Horizontal lookup"),args:Ds(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n 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.")}\n index (number) ${r("The row index of the value to be returned, where the first row in range is numbered 1.")}\n 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.")}\n `),returns:["ANY"],compute:function(e,t,i,n=true){const o=Math.trunc(Vs(i)),s=Ws(e);Ps((()=>1<=o&&o<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=qs(n);let l;return l=a?aa(t,s,"nextSmaller","asc",t.length,sa):la(t,s,"strict",t.length,sa),Ps((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),t[l][o-1]},isExported:!0},Gd={description:r("Returns the content of a cell, specified by row and column offset."),args:Ds(`\n reference (any, range) ${r("The range of cells from which the value is returned.")}\n row (number) ${r("The index of the row to be returned from within the reference range of cells.")}\n column (number) ${r("The index of the column to be returned from within the reference range of cells.")}\n`),returns:["ANY"],computeFormat:(e,t,i)=>{var n;const o=Vs(t.value);return null===(n=e[Vs(i.value)-1][o-1])||void 0===n?void 0:n.format},compute:function(e,t,i){const n=(o=e,Array.isArray(o)&&Array.isArray(o[0])?e:[[e]]);var o;const s=Vs(t),a=Vs(i);return Ps((()=>a>=0&&a-1<n.length&&s>=0&&s-1<n[0].length),r("Index out of range.")),Ps((()=>0!==t&&0!==i),r("This function can only return a single cell value, not an array. Provide valid row and column indices.")),n[a-1][s-1]},isExported:!0},qd={description:r("Look up a value."),args:Ds(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n 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.")}\n 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.")}\n `),returns:["ANY"],compute:function(e,t,i){let n=t.length,o=t[0].length;const s=Ws(e),a=o>=n,l=aa(t,s,"nextSmaller","asc",a?o:n,a?ra:sa);return Ps((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),void 0===i?a?t[n-1][l]:t[l][o-1]:(n=i.length,o=i[0].length,Ps((()=>1===n||1===o),r("The result_range must be a single row or a single column.")),n>1?(Ps((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Ps((()=>l<=o-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Zd={description:r("Position of item in range that matches value."),args:Ds(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The one-dimensional array to be searched.")}\n 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.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){let n=Vs(i);const o=Ws(e),s=t.length,a=t[0].length;Ps((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?ra:sa,h=1===s?t[0].length:t.length;switch(n=Math.sign(n),n){case 1:l=aa(t,o,"nextSmaller","asc",h,c);break;case 0:l=la(t,o,"strict",h,c);break;case-1:l=aa(t,o,"nextGreater","desc",h,c)}return Ps((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),l+1},isExported:!0},jd={description:r("Row number of a specified cell."),args:Ds(`cell_reference (meta, default=${r("The cell in which the formula is entered by default")}) ${r("The cell whose row number will be returned.")}`),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),Ps((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Ni(e).top+1},isExported:!0},Yd={description:r("Number of rows in a specified array or range."),args:Ds(`range (meta) ${r("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Ni(e);return t.bottom-t.top+1},isExported:!0},Xd={description:r("Vertical lookup."),args:Ds(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n 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.")}\n index (number) ${r("The column index of the value to be returned, where the first column in range is numbered 1.")}\n 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.")}\n `),returns:["ANY"],compute:function(e,t,i,n=true){const o=Math.trunc(Vs(i)),s=Ws(e);Ps((()=>1<=o&&o<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=qs(n);let l;return l=a?aa(t,s,"nextSmaller","asc",t[0].length,ra):la(t,s,"strict",t[0].length,ra),Ps((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),t[o-1][l]},isExported:!0},Kd={description:r("Search a range for a match and return the corresponding item from a second range."),args:Ds(`\n search_key (any) ${r("The value to search for.")}\n lookup_range (any, range) ${r("The range to consider for the search. Should be a single column or a single row.")}\n return_range (any, range) ${r("The range containing the return value. Should have the same dimensions as lookup_range.")}\n if_not_found (any, lazy, optional) ${r("If a valid match is not found, return this value.")}\n 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.")}\n 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. ")}\n\n `),returns:["ANY"],compute:function(e,t,i,n,o=0,s=1){const a=Math.trunc(Vs(o)),l=Math.trunc(Vs(s)),c=Ws(e);Ps((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),Ps((()=>1===i.length||1===i[0].length),r("return_range should be either a single row or single column.")),Ps((()=>i.length===t.length&&i[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),Ps((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),Ps((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?ra:sa,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=aa(t,c,u,2===l?"asc":"desc",d,h)}else p=la(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==n?void 0:n();return Ps((()=>!!m),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Bs(e))),m},isExported:!0};var Qd=Object.freeze({__proto__:null,COLUMN:Bd,COLUMNS:Hd,HLOOKUP:Wd,INDEX:Gd,LOOKUP:qd,MATCH:Zd,ROW:jd,ROWS:Yd,VLOOKUP:Xd,XLOOKUP:Kd});const Jd={description:r("Sum of two numbers."),args:Ds(`\n value1 (number) ${r("The first addend.")}\n value2 (number) ${r("The second addend.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Vs(e)+Vs(t)}},eu={description:r("Concatenation of two values."),args:Ds(`\n value1 (string) ${r("The value to which value2 will be appended.")}\n value2 (string) ${r("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return Bs(e)+Bs(t)},isExported:!0},tu={description:r("One number divided by another."),args:Ds(`\n dividend (number) ${r("The number to be divided.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Vs(t);return Ps((()=>0!==i),r("The divisor must be different from zero.")),Vs(e)/i}};function iu(e){return null==e}const nu={number:0,string:"",boolean:!1},ou={description:r("Equal."),args:Ds(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=iu(e)?nu[typeof t]:e,t=iu(t)?nu[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function ru(e,t,i){e=iu(e)?nu[typeof t]:e,t=iu(t)?nu[typeof e]:t,"number"!=typeof e&&(e=Bs(e).toUpperCase()),"number"!=typeof t&&(t=Bs(t).toUpperCase());const n=typeof e,o=typeof t;return"string"===n&&"number"===o||("string"!==o||"number"!==n)&&i(e,t)}const su={description:r("Strictly greater than."),args:Ds(`\n value1 (any) ${r("The value to test as being greater than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return ru(e,t,((e,t)=>e>t))}},au={description:r("Greater than or equal to."),args:Ds(`\n value1 (any) ${r("The value to test as being greater than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return ru(e,t,((e,t)=>e>=t))}},lu={description:r("Less than."),args:Ds(`\n value1 (any) ${r("The value to test as being less than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!au.compute(e,t)}},cu={description:r("Less than or equal to."),args:Ds(`\n value1 (any) ${r("The value to test as being less than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!su.compute(e,t)}},hu={description:r("Difference of two numbers."),args:Ds(`\n value1 (number) ${r("The minuend, or number to be subtracted from.")}\n value2 (number) ${r("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Vs(e)-Vs(t)}},du={description:r("Product of two numbers"),args:Ds(`\n factor1 (number) ${r("The first multiplicand.")}\n factor2 (number) ${r("The second multiplicand.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Vs(e)*Vs(t)}},uu={description:r("Not equal."),args:Ds(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!ou.compute(e,t)}},gu={description:r("A number raised to a power."),args:Ds(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],compute:function(e,t){return Xa.compute(e,t)}},pu={description:r("A number with the sign reversed."),args:Ds(`\n value (number) ${r("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Vs(e)}},mu={description:r("Value interpreted as a percentage."),args:Ds(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Vs(e)/100}},fu={description:r("A specified number, unchanged."),args:Ds(`\n value (any) ${r("The number to return.")}\n `),returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var vu=Object.freeze({__proto__:null,ADD:Jd,CONCAT:eu,DIVIDE:tu,EQ:ou,GT:su,GTE:au,LT:lu,LTE:cu,MINUS:hu,MULTIPLY:du,NE:uu,POW:gu,UMINUS:pu,UNARY_PERCENT:mu,UPLUS:fu});const bu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Su={description:r("Gets character associated with number."),args:Ds(`\n table_number (number) ${r("The number of the character to look up from the current Unicode table in decimal format.")}\n `),returns:["STRING"],compute:function(e){const t=Math.trunc(Vs(e));return Ps((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Cu={description:r("Remove non-printable characters from a piece of text."),args:Ds(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Bs(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},Eu={description:r("Appends strings to one another."),args:Ds(`\n string1 (string, range<string>) ${r("The initial string.")}\n string2 (string, range<string>, repeating) ${r("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return Qs(e,((e,t)=>e+Bs(t)),"")},isExported:!0},wu={description:r("Tests whether two strings are identical."),args:Ds(`\n string1 (string) ${r("The first string to compare.")}\n string2 (string) ${r("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Bs(e)===Bs(t)},isExported:!0},yu={description:r("First position of string found in text, case-sensitive."),args:Ds(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const n=Bs(e),o=Bs(t),s=Vs(i);Ps((()=>""!==o),r("The text_to_search must be non-empty.")),Ps((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=o.indexOf(n,s-1);return Ps((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n.toString(),o)),a+1},isExported:!0},xu={description:r("Concatenates elements of arrays with delimiter."),args:Ds(`\n delimiter (string) ${r("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${r("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${r("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const i=Bs(e);return Qs(t,((e,t)=>(e?e+i:"")+Bs(t)),"")}},Ru={description:r("Substring from beginning of specified string."),args:Ds(`\n text (string) ${r("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Vs(t[0]):1;return Ps((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString())),Bs(e).substring(0,i)},isExported:!0},Iu={description:r("Length of a string."),args:Ds(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Bs(e).length},isExported:!0},Tu={description:r("Converts a specified string to lowercase."),args:Ds(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Bs(e).toLowerCase()},isExported:!0},Au={description:r("A segment of a string."),args:Ds(`\n text (string) ${r("The string to extract a segment from.")}\n starting_at (number) ${r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")}\n extract_length (number) ${r("The length of the segment to extract.")}\n `),returns:["STRING"],compute:function(e,t,i){const n=Bs(e),o=Vs(t),s=Vs(i);return Ps((()=>o>=1),r("The starting_at argument (%s) must be positive greater than one.",o.toString())),Ps((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),n.slice(o-1,o+s-1)},isExported:!0},Ou={description:r("Capitalizes each word in a specified string."),args:Ds(`\n 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.")}\n `),returns:["STRING"],compute:function(e){return Bs(e).replace(bu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Nu={description:r("Replaces part of a text string with different text."),args:Ds(`\n text (string) ${r("The text, a part of which will be replaced.")}\n position (number) ${r("The position where the replacement will begin (starting from 1).")}\n length (number) ${r("The number of characters in the text to be replaced.")}\n new_text (string) ${r("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,i,n){const o=Vs(t);Ps((()=>o>=1),r("The position (%s) must be greater than or equal to 1.",o.toString()));const s=Bs(e),a=Vs(i),l=Bs(n);return s.substring(0,o-1)+l+s.substring(o-1+a)},isExported:!0},Mu={description:r("A substring from the end of a specified string."),args:Ds(`\n text (string) ${r("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Vs(t[0]):1;Ps((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString()));const n=Bs(e),o=n.length;return n.substring(o-i,o)},isExported:!0},_u={description:r("First position of string found in text, ignoring case."),args:Ds(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const n=Bs(e).toLowerCase(),o=Bs(t).toLowerCase(),s=Vs(i);Ps((()=>""!==o),r("The text_to_search must be non-empty.")),Ps((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=o.indexOf(n,s-1);return Ps((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n,o)),a+1},isExported:!0},Fu={description:r("Replaces existing text with new text in a string."),args:Ds(`\n text_to_search (string) ${r("The text within which to search and replace.")}\n search_for (string) ${r("The string to search for within text_to_search.")}\n replace_with (string) ${r("The string that will replace search_for.")}\n 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.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n){const o=Vs(n);Ps((()=>o>=0),r("The occurrenceNumber (%s) must be positive or null.",o.toString()));const s=Bs(e),a=Bs(t);if(""===a)return s;const l=Bs(i),c=new RegExp(Te(a),"g");if(0===o)return s.replace(c,l);let h=0;return s.replace(c,(e=>++h===o?l:e))},isExported:!0},Du={description:r("Combines text from multiple strings and/or arrays."),args:Ds(`\n delimiter (string) ${r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${r("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${r("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...i){const n=Bs(e),o=qs(t);let r=0;return Qs(i,((e,t)=>o&&""===Bs(t)?e:(r++?e+n:"")+Bs(t)),"")},isExported:!0},ku={description:r("Removes space characters."),args:Ds(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Bs(e).trim()},isExported:!0},$u={description:r("Converts a specified string to uppercase."),args:Ds(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Bs(e).toUpperCase()},isExported:!0},Lu={description:r("Converts a number to text according to a specified format."),args:Ds(`\n number (number) ${r("The number, date or time to format.")}\n format (string) ${r("The pattern by which to format the number, enclosed in quotation marks.")}\n `),returns:["STRING"],compute:function(e,t){return Qt(Vs(e),Bs(t))},isExported:!0};const Pu={database:Sc,date:Qc,financial:wd,info:_d,lookup:Qd,logical:zd,math:pl,misc:da,operators:vu,statistical:oc,text:Object.freeze({__proto__:null,CHAR:Su,CLEAN:Cu,CONCATENATE:Eu,EXACT:wu,FIND:yu,JOIN:xu,LEFT:Ru,LEN:Iu,LOWER:Tu,MID:Au,PROPER:Ou,REPLACE:Nu,RIGHT:Mu,SEARCH:_u,SUBSTITUTE:Fu,TEXTJOIN:Du,TRIM:ku,UPPER:$u,TEXT:Lu}),engineering:eh},Uu=/^[A-Z0-9\_\.]+$/;function Vu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>zu(e()):zu(e)}))}function zu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Bu=new class extends tn{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Uu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=$s(t);return function(e){let t=!1,i=!1,n=!1;for(let o of e){if(o.type.includes("META")&&o.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&&!o.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||n,s=!(o.optional||o.repeating||o.default);if(e&&s)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=o.repeating,i=o.optional,n=o.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),n=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Vu(e)),format:n(...e)}},super.add(e,i),this}};for(let e in Pu){const t=Pu[e];for(let i in t){const n=t[i];n.category=e,i=i.replace(/_/g,"."),Bu.add(i,{isExported:!1,...n})}}const Hu=Bu.content,Wu=["%"],Gu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Wu);function qu(e){const t=e.split(""),i=[];for(;t.length;){let e=ng(t)||Yu(t)||Ku(t)||Ju(t)||Zu(t)||og(t)||Qu(t)||tg(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Zu(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const ju={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Yu(e){if(e[0]in ju){const t=e.shift();return{type:ju[t],value:t}}return null}function Xu(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Ku(e){for(let t of Gu)if(Xu(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Qu(e){const t=et(e).match(pi);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Ju(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const eg=/\w|\.|!|\$/;function tg(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(eg);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Hu)return{type:"FUNCTION",value:e};return e.match(Nt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const ig=/\s/;function ng(e){let t=0;for(;e[0]&&e[0].match(ig);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function og(e){return Xu(e,X)?(e.splice(0,X.length),{type:"INVALID_REFERENCE",value:X}):null}var rg;!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"}(rg||(rg={}));const sg=(e,t=(()=>!0))=>[{goTo:e,guard:t}],ag=(e,t=(()=>!0))=>({goTo:e,guard:t}),lg={[rg.LeftRef]:{REFERENCE:sg(rg.Separator),NUMBER:sg(rg.FullRowSeparator),SYMBOL:[ag(rg.FullColumnSeparator,(e=>Mt(e.value))),ag(rg.FullRowSeparator,(e=>_t(e.value)))]},[rg.FullColumnSeparator]:{SPACE:sg(rg.FullColumnSeparator),OPERATOR:sg(rg.RightColumnRef,(e=>":"===e.value))},[rg.FullRowSeparator]:{SPACE:sg(rg.FullRowSeparator),OPERATOR:sg(rg.RightRowRef,(e=>":"===e.value))},[rg.Separator]:{SPACE:sg(rg.Separator),OPERATOR:sg(rg.RightRef,(e=>":"===e.value))},[rg.RightRef]:{SPACE:sg(rg.RightRef),NUMBER:sg(rg.Found),REFERENCE:sg(rg.Found,(e=>kt(e.value))),SYMBOL:sg(rg.Found,(e=>Ft(e.value)||Dt(e.value)))},[rg.RightColumnRef]:{SPACE:sg(rg.RightColumnRef),SYMBOL:sg(rg.Found,(e=>Ft(e.value))),REFERENCE:sg(rg.Found,(e=>kt(e.value)))},[rg.RightRowRef]:{SPACE:sg(rg.RightRowRef),NUMBER:sg(rg.Found),REFERENCE:sg(rg.Found,(e=>kt(e.value))),SYMBOL:sg(rg.Found,(e=>Dt(e.value)))},[rg.Found]:{}};function cg(e){var t;let i=0,n=lg[rg.LeftRef],o="";for(;void 0!==n;){const r=e[i++];if(!r)return null;const s=null===(t=n[r.type])||void 0===t?void 0:t.find((e=>e.guard(r))),a=s?s.goTo:void 0;switch(a){case void 0:return null;case rg.Found:return o+=r.value,e.splice(0,i),{type:"REFERENCE",value:o};default:n=lg[a],o+=r.value}}return null}function hg(e){const t=qu(e),i=[];for(;t.length;)i.push(cg(t)||t.shift());return i}const dg=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,ug=["-","+"],gg=["%"],pg=["*","+","&"],mg={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},fg=6;function vg(e){switch(e.type){case"NUMBER":case"SYMBOL":case"REFERENCE":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return mg[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function bg(e,t,i){if("OPERATOR"===t.type){const n=vg(t);if(gg.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const o=Sg(i,n);return{type:"BIN_OPERATION",value:t.value,left:e,right:o}}}throw new Error(ne)}function Sg(e,t){const i=e.shift();if(!i)throw new Error(ne);let n=function(e,t){var i,n,o,s;switch(e.type){case"DEBUGGER":const a=Sg(t,1e3);return a.debug=!0,a;case"NUMBER":return{type:"NUMBER",value:wi(e.value)};case"STRING":return{type:"STRING",value:Ie(e.value)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(r("Wrong function call"));{const n=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?n.push({type:"UNKNOWN",value:""}):n.push(Sg(t,fg));"COMMA"===(null===(i=t[0])||void 0===i?void 0:i.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){n.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?n.push({type:"UNKNOWN",value:""}):n.push(Sg(t,fg))}const o=t.shift();if(!o||"RIGHT_PAREN"!==o.type)throw new Error(r("Wrong function call"));return{type:"FUNCALL",value:e.value,args:n}}case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(n=t[0])||void 0===n?void 0:n.value)&&"REFERENCE"===(null===(o=t[1])||void 0===o?void 0:o.type)){t.shift();const i=t.shift();return{type:"REFERENCE",value:`${e.value}:${null==i?void 0:i.value}`}}return{type:"REFERENCE",value:e.value};case"SYMBOL":if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value){if(dg.test(e.value)&&"LEFT_PAREN"===(null===(s=t[0])||void 0===s?void 0:s.type))throw new p(e.value);throw new Error(r("Invalid formula"))}return{type:"STRING",value:e.value};case"LEFT_PAREN":const l=Sg(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),l;default:if("OPERATOR"===e.type&&ug.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:Sg(t,mg[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(i,e);for(;e[0]&&vg(e[0])>t;)n=bg(n,e.shift(),e);return n}function Cg(e){return Eg(hg(e))}function Eg(e){"OPERATOR"===(e=e.filter((e=>"SPACE"!==e.type)))[0].type&&"="===e[0].value&&e.splice(0,1);const t=Sg(e,0);if(e.length)throw new Error(ne);return t}function wg(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>wg(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:wg(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:wg(e.right,t,i),left:wg(e.left,t,i)};default:return e}}function yg(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>yg(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?xg(e)+e.value:e.value+Rg(e);case"BIN_OPERATION":return xg(e)+e.value+Rg(e)}}function xg(e){const t=e.value,i="left"in e?e.left:e.operand,n=i.value;return"BIN_OPERATION"===i.type&&mg[n]<mg[t]?`(${yg(i)})`:yg(i)}function Rg(e){const t=e.value,i="right"in e?e.right:e.operand,n=mg[i.value],o=mg[t];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:n<o?r=!0:n!==o||pg.includes(t)||(r=!0),r?`(${yg(i)})`:yg(i)}const Ig=Bu.content,Tg={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Ag={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function Og(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const Ng={};function Mg(e){const t=hg(e),{dependencies:i,constantValues:n}=function(e){const t={numbers:[],strings:[]},i=[];for(const n of e)switch(n.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(n.value);break;case"STRING":const e=Ie(n.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=wi(n.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),o=function(e,t,i){return et(e.map((e=>{switch(e.type){case"STRING":const n=Ie(e.value);return`|S${i.strings.indexOf(n)}|`;case"NUMBER":return`|N${i.numbers.indexOf(wi(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,n);if(!Ng[o]){const s=Eg([...t]);let a=1;if("BIN_OPERATION"===s.type&&":"===s.value)throw new Error(r("Invalid formula"));if("UNKNOWN"===s.type)throw new Error(r("Invalid formula"));const l=u(s),c=Og([`// ${o}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=Ig[e.value.toUpperCase()],i=e.args,n=i.length;if(n<t.minArgRequired)throw new Error(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),n.toString()));if(n>t.maxArgPossible)throw new Error(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),n.toString()));const o=t.nbrArgRepeating;if(o>1){const i=t.args.length-o;if((n-i)%o!=0)throw new Error(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),o.toString()))}let s=[];for(let o=0;o<n;o++){const n=t.getArgToFocus(o+1)-1;if(0<=n&&n<t.args.length){const a=i[o],l=t.args[n],c=l.type||[],h=c.includes("META"),d=l.lazy,g=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),p=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(p&&"REFERENCE"!==a.type)throw new Error(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(o+1).toString(),a.type.toLowerCase()));const m=u(a,d,h,g,{functionName:e.value.toUpperCase(),paramIndex:o+1});s.push(m)}}return s}function u(e,t=!1,o=!1,s=!1,l={}){const c=[];let h,g,p;if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&o)throw new Error(r("Argument must be a reference to a cell or range."));switch(e.debug&&c.push("debugger;"),e.type){case"BOOLEAN":if(!t)return{id:`{ value: ${e.value} }`,code:""};h=a++,p=`{ value: ${e.value} }`;break;case"NUMBER":h=a++,p=`{ value: this.constantValues.numbers[${n.numbers.indexOf(e.value)}] }`;break;case"STRING":h=a++,p=`{ value: this.constantValues.strings[${n.strings.indexOf(e.value)}] }`;break;case"REFERENCE":const r=i.indexOf(e.value);h=a++,p=s?`range(deps[${r}])`:`ref(deps[${r}], ${o?"true":"false"}, "${l.functionName||Tg["="]}", ${l.paramIndex})`;break;case"FUNCALL":h=a++;const m=d(e);c.push(m.map((e=>e.code)).join("\n")),g=e.value.toUpperCase(),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${m.map((e=>e.id))})`;break;case"UNARY_OPERATION":{h=a++,g=Ag[e.value];const t=u(e.operand,!1,!1,!1,{functionName:g});c.push(t.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id})`;break}case"BIN_OPERATION":{h=a++,g=Tg[e.value];const t=u(e.left,!1,!1,!1,{functionName:g}),i=u(e.right,!1,!1,!1,{functionName:g});c.push(t.code),c.push(i.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id}, ${i.id})`;break}case"UNKNOWN":if(!t)return{id:"undefined",code:""};h=a++,p="undefined"}if(t){return{id:`_${h}`,code:`const _${h} = () => {\n\t${Og(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}Ng[o]={execute:h}}return{execute:Ng[o].execute,dependencies:i,constantValues:n,tokens:t}}function _g(e){return function(e){let t=[],i="";return e.map(((e,n)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,n=Object.assign({},e,{start:t,end:t+i,length:i});return t=n.end,n}))}(hg(e))))}function Fg(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=$t(e.value),[n,o]=t.split(":"),r=i?`${Ne(i)}!`:"",s=Dg(n),a=o?`:${Dg(o)}`:"";return{...e,value:r+s+a}}function Dg(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=kg(e,"colrow");break;case"colrow":e=kg(e,"row");break;case"row":e=kg(e,"col");break;case"col":e=kg(e,"none")}return e}function kg(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),-1===i||0===i?"$"+e:"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}class $g{constructor(e,t,i){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 i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const n=e.filter((e=>0!==e));if(n.length)return n}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}$g.getters=[];class Lg extends $g{constructor(e,t,i,n,o){super(t,i,n),this.getters=e,this.ui=n,this.selection=o}drawGrid(e,t){}}Lg.layers=[];const Pg=r("The cell you are trying to edit has been deleted.");class Ug extends Lg{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.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=this.getters.getActiveCell(),i=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(i.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}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":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),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:n}=$t(e.value),o=n||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==o)return!1;const s=this.getters.getRangeFromSheetXC(r,i);return Ui(this.getters.expandZone(r,s.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const n=this.getters.getRangeFromRangeData(e.range),o=this.getRangeReference(n,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(o),this.previousRef=o,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{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),n=this.getters.expandZone(e.sheetIdTo,Ki({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:n})}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:Pg}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}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((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(Fg).map((e=>e.value)).join(""),n=this.currentContent,o=e[0].start,r=e[e.length-1].end,s=n.slice(0,o)+i+n.slice(r),a=s.length-n.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:s,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}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:Pg});const{top:t,left:i}=ki({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,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:Pg});const{top:t,left:i}=ki({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Di({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=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Ki({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){var i;const n=this.getters.getActiveCell();e&&(null===(i=null==n?void 0:n.format)||void 0===i?void 0:i.includes("%"))&&Ci(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`),this.initialContent=(null==n?void 0:n.composerContent)||"",this.mode="editing";const{col:o,row:r}=this.getters.getPosition();this.col=o,this.row=r,this.sheetId=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const s=Ki({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){const e=this.getters.getActiveSheetId();this.cancelEditionAndActivateSheet();const{col:t,row:i}=this.getters.getMainCellPosition(this.sheetId,this.col,this.row);let n=this.currentContent;if(!(this.initialContent!==n))return;if(n){const o=this.getters.getCell(e,t,i);if(n.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&&(n+=et(new Array(i).fill(")")))}else(null==o?void 0:o.isLink())&&(n=We(n,o.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:t,row:i,content:n})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:t,row:i});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})}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){e=e.replace(/[\r\n]/g,"");const n=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(n||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?_g(e):[],this.currentTokens.length>100&&i&&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),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let n=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){n=`${Ne(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${n}`}return n}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){1===t.length&&Ji(e.zone)>1?t.push({...t[0]}):2===t.length&&1===Ji(e.zone)&&t.pop();const i=e.clone({parts:this.previousRange.parts});return this.getters.getSelectionRangeString(i,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),n=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:n,end:n}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const n=new Set(Object.values(i));let o=0;const r=()=>{for(;n.has(o);)o++;return n.add(o),o};for(const e of t){const t=e in i?i[e]:r();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return ut[t%ut.length]};return this.getReferencedRanges().map((i=>{const n=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(n),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}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 i=t,n=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(n.type)||Wu.includes(n.value);){if("SPACE"!==n.type||i<1)return!1;i--,n=this.currentTokens[i]}for(i=t+1,n=this.currentTokens[i];n&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(n.type);){if("SPACE"!==n.type)return!1;i++,n=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Ug.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const Vg=Bu.content,zg=new tn;zg.add("functions",(()=>Object.keys(Vg).map((e=>({text:e,description:Vg[e].description}))))),Cn`
984
984
  .o-autocomplete-dropdown {
985
985
  pointer-events: auto;
986
986
  background-color: #fff;
@@ -1179,7 +1179,7 @@
1179
1179
  }
1180
1180
  }
1181
1181
  }
1182
- `;class op extends t.Component{constructor(){super(...arguments),this.figureRegistry=Jn,this.figureRef=t.useRef("figure")}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:1}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:i,height:n}=this.props.figure;return wn({left:`${e}px`,top:`${t}px`,width:`${i}px`,height:`${n}px`,"z-index":String(oe.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);",t}setup(){t.useEffect(((e,t,i)=>{e===t&&(null==i||i.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el])),t.onWillUnmount((()=>{this.props.onFigureDeleted()}))}clickAnchor(e,t,i){this.props.onClickAnchor(e,t,i)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure,i=function(e,t="key"){let i="";_n.includes(e.key)||(Ln(e)&&(i+="Ctrl+"),e.altKey&&(i+="Alt+"),e.shiftKey&&(i+="Shift+"));const n="key"===t?e.key:e.code;return i+=kn.test(n)?n.toUpperCase():n,i}(e);switch(i){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.preventDefault(),e.stopPropagation();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const n={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+n[0],y:t.y+n[1]}),e.preventDefault(),e.stopPropagation();break;case"Ctrl+A":e.preventDefault(),e.stopPropagation();break;case"Ctrl+Y":case"Ctrl+Z":"Ctrl+Y"===i?this.env.model.dispatch("REQUEST_REDO"):"Ctrl+Z"===i&&this.env.model.dispatch("REQUEST_UNDO"),e.preventDefault(),e.stopPropagation()}}}op.template="o-spreadsheet-FigureComponent",op.components={},op.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},op.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};class rp extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const i of["topLeft","topRight","bottomLeft","bottomRight"]){const n=e.filter((e=>this.getFigureContainer(e)===i));n.length>0&&t.push({type:i,figures:n,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:i}=this.env.model.getters.getSheetViewDimension(),{x:n,y:o}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?n:0,s=t-r,a=["bottomRight","bottomLeft"].includes(e)?o:0;return wn({left:`${r}px`,top:`${a}px`,width:`${s}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:n,y:o}=this.env.model.getters.getMainViewportCoordinates();return wn({left:`${["bottomRight","topRight"].includes(e)?-(n+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(o+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"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 i=this.env.model.getters.getActiveSheetId(),n=t.clientX,o=t.clientY,{x:r,y:s}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=s,this.dnd.width=e.width,this.dnd.height=e.height;Ts((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-n;this.dnd.x=Math.max(r+u,h);let g=t.clientY-o;this.dnd.y=Math.max(s+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:n,y:o}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:n,y:o})}))}startResize(e,t,i,n){n.stopPropagation();const o=n.clientX,r=n.clientY,{scrollX:s,scrollY:a}=this.env.model.getters.getActiveSheetScrollInfo(),{x:l,y:c}=this.internalToScreenCoordinates(e);let h;this.dnd.x=l,this.dnd.y=c,this.dnd.width=e.width,this.dnd.height=e.height,h=n=>{this.dnd.figId=e.id;const h=Math.max(t*(n.clientX-o),80-e.width),d=Math.max(i*(n.clientY-r),80-e.height);this.dnd.width=e.width+h,this.dnd.height=e.height+d,t<0&&(this.dnd.x=l-h),i<0&&(this.dnd.y=c-d),this.dnd.x+s<=0&&(this.dnd.width=this.dnd.width+this.dnd.x+s,this.dnd.x=-s),this.dnd.y+a<=0&&(this.dnd.height=this.dnd.height+this.dnd.y+a,this.dnd.y=-a)};Ts(h,(n=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:o,y:r}=this.screenCoordinatesToInternal(this.dnd);const s={x:o,y:r};t&&(s.width=this.dnd.width),i&&(s.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...s})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":wn({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:n}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:o,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-o,y:t=t<n?t:t-r}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:n}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:o,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+o,y:t=n&&t<n?t:t+r}}}function sp(e,i,n){let o={col:void 0,row:void 0};const{Date:r}=window;let s=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(s),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let n;const{setInterval:o,clearInterval:r}=window;return t.useEffect((()=>(n=o(e,i),()=>r(n))),(()=>[i])),{pause:()=>{r(n),n=void 0},resume:()=>{void 0===n&&(n=o(e,i))}}}((function(){const{col:e,row:t}=c(),i=r.now()-l;i>300&&(e!==o.col||t!==o.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){i.el===e.target&&(s=e.offsetX,a=e.offsetY,l=r.now())}function g(){const{col:e,row:t}=c();e===o.col&&t===o.row||p(void 0,void 0)}function p(e,t){e===o.col&&t===o.row||(o.col=e,o.row=t,n({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),o}rp.template="o-spreadsheet-FiguresContainer",rp.components={FigureComponent:op},Jn.add("chart",{Component:Is,SidePanelComponent:"ChartPanel"});class ap extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),sp(this.env,this.gridOverlay,this.props.onCellHovered),t.useEffect((()=>this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})),(()=>[this.gridOverlayEl.clientHeight,this.gridOverlayEl.clientWidth])),function(e,i,n){let o=null,r=null;function s(e){1===e.touches.length&&(o=e.touches[0].clientX,r=e.touches[0].clientY)}function a(){o=null,r=null}function l(e){if(1!==e.touches.length)return;n()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,s=e.touches[0].clientY;i(o-t,r-s),o=t,r=s}t.onMounted((()=>{e.el.addEventListener("touchstart",s),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",s),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(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,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{expandZone:e.shiftKey,addZone:Ln(e)})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}ap.template="o-spreadsheet-GridOverlay",ap.components={FiguresContainer:rp},ap.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{},sidePanelIsOpen:!1};class lp extends t.Component{constructor(){super(...arguments),this.zIndex=oe.GridPopover}get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.coordinates;return{...e,coordinates:{x:t.x+this.props.gridPosition.x,y:t.y+this.props.gridPosition.y}}}}lp.template="o-spreadsheet-GridPopover",lp.components={Popover:Un};class cp extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.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,position:"before"})}_computeHandleDisplay(e){const t=this._getEvOffset(e),i=this._getElementIndex(t);if(i<0)return;const n=this._getDimensionsInViewport(i);t-n.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=n.start,this.state.activeElement=this._getPreviousVisibleElement(i)):n.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=n.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),n=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();i.has(n)&&n<=t&&t<=o?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),i=this.state.draggerLinePosition,n=this._getElementSize(this.state.activeElement),o=i-n+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();Ts((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<o&&(this.state.draggerLinePosition=o,this.state.delta=this.MIN_ELEMENT_SIZE-n),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-i)}),(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.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),n=t.start;this.state.draggerLinePosition=n,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=n,this.state.draggerShadowThickness=i.end-t.start;As(this.env,((e,i)=>{let n="COL"===this._getType()?e:i;if(n>=0){const e=this._getDimensionsInViewport(n);n<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=n,this.state.position="before"):this._getSelectedZoneEnd()<n?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=n,this.state.position="after"):(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,Ln(e)),this.lastSelectedElementIndex=t;As(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(Ln(e)?"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 i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}Cn`
1182
+ `;class op extends t.Component{constructor(){super(...arguments),this.figureRegistry=Jn,this.figureRef=t.useRef("figure")}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:1}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:i,height:n}=this.props.figure;return wn({left:`${e}px`,top:`${t}px`,width:`${i}px`,height:`${n}px`,"z-index":String(oe.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);",t}setup(){t.useEffect(((e,t,i)=>{e===t&&(null==i||i.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el])),t.onWillUnmount((()=>{this.props.onFigureDeleted()}))}clickAnchor(e,t,i){this.props.onClickAnchor(e,t,i)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure,i=function(e,t="key"){let i="";_n.includes(e.key)||(Ln(e)&&(i+="Ctrl+"),e.altKey&&(i+="Alt+"),e.shiftKey&&(i+="Shift+"));const n="key"===t?e.key:e.code;return i+=kn.test(n)?n.toUpperCase():n,i}(e);switch(i){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.preventDefault(),e.stopPropagation();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const n={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+n[0],y:t.y+n[1]}),e.preventDefault(),e.stopPropagation();break;case"Ctrl+A":e.preventDefault(),e.stopPropagation();break;case"Ctrl+Y":case"Ctrl+Z":"Ctrl+Y"===i?this.env.model.dispatch("REQUEST_REDO"):"Ctrl+Z"===i&&this.env.model.dispatch("REQUEST_UNDO"),e.preventDefault(),e.stopPropagation()}}}op.template="o-spreadsheet-FigureComponent",op.components={},op.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},op.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};class rp extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const i of["topLeft","topRight","bottomLeft","bottomRight"]){const n=e.filter((e=>this.getFigureContainer(e)===i));n.length>0&&t.push({type:i,figures:n,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:i}=this.env.model.getters.getSheetViewDimension(),{x:n,y:o}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?n:0,s=t-r,a=["bottomRight","bottomLeft"].includes(e)?o:0;return wn({left:`${r}px`,top:`${a}px`,width:`${s}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:n,y:o}=this.env.model.getters.getMainViewportCoordinates();return wn({left:`${["bottomRight","topRight"].includes(e)?-(n+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(o+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"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 i=this.env.model.getters.getActiveSheetId(),n=t.clientX,o=t.clientY,{x:r,y:s}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=s,this.dnd.width=e.width,this.dnd.height=e.height;Ts((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-n;this.dnd.x=Math.max(r+u,h);let g=t.clientY-o;this.dnd.y=Math.max(s+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:n,y:o}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:n,y:o})}))}startResize(e,t,i,n){n.stopPropagation();const o=n.clientX,r=n.clientY,{scrollX:s,scrollY:a}=this.env.model.getters.getActiveSheetScrollInfo(),{x:l,y:c}=this.internalToScreenCoordinates(e);let h;this.dnd.x=l,this.dnd.y=c,this.dnd.width=e.width,this.dnd.height=e.height,h=n=>{this.dnd.figId=e.id;const h=Math.max(t*(n.clientX-o),80-e.width),d=Math.max(i*(n.clientY-r),80-e.height);this.dnd.width=e.width+h,this.dnd.height=e.height+d,t<0&&(this.dnd.x=l-h),i<0&&(this.dnd.y=c-d),this.dnd.x+s<=0&&(this.dnd.width=this.dnd.width+this.dnd.x+s,this.dnd.x=-s),this.dnd.y+a<=0&&(this.dnd.height=this.dnd.height+this.dnd.y+a,this.dnd.y=-a)};Ts(h,(n=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:o,y:r}=this.screenCoordinatesToInternal(this.dnd);const s={x:o,y:r};t&&(s.width=this.dnd.width),i&&(s.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...s})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":wn({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:n}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:o,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-o,y:t=t<n?t:t-r}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:n}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:o,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+o,y:t=n&&t<n?t:t+r}}}function sp(e,i,n){let o={col:void 0,row:void 0};const{Date:r}=window;let s,a,l=0;function c(){if(void 0===s||void 0===a)return{col:-1,row:-1};return{col:e.model.getters.getColIndex(s),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let n;const{setInterval:o,clearInterval:r}=window;return t.useEffect((()=>(n=o(e,i),()=>r(n))),(()=>[i])),{pause:()=>{r(n),n=void 0},resume:()=>{void 0===n&&(n=o(e,i))}}}((function(){const{col:e,row:t}=c(),i=r.now()-l;i>300&&(e!==o.col||t!==o.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){i.el===e.target&&(s=e.offsetX,a=e.offsetY,l=r.now())}function g(){const{col:e,row:t}=c();e===o.col&&t===o.row||p(void 0,void 0)}function p(e,t){e===o.col&&t===o.row||(o.col=e,o.row=t,n({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),o}rp.template="o-spreadsheet-FiguresContainer",rp.components={FigureComponent:op},Jn.add("chart",{Component:Is,SidePanelComponent:"ChartPanel"});class ap extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),sp(this.env,this.gridOverlay,this.props.onCellHovered),t.useEffect((()=>this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})),(()=>[this.gridOverlayEl.clientHeight,this.gridOverlayEl.clientWidth])),function(e,i,n){let o=null,r=null;function s(e){1===e.touches.length&&(o=e.touches[0].clientX,r=e.touches[0].clientY)}function a(){o=null,r=null}function l(e){if(1!==e.touches.length)return;n()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,s=e.touches[0].clientY;i(o-t,r-s),o=t,r=s}t.onMounted((()=>{e.el.addEventListener("touchstart",s),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",s),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(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,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{expandZone:e.shiftKey,addZone:Ln(e)})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}ap.template="o-spreadsheet-GridOverlay",ap.components={FiguresContainer:rp},ap.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{},sidePanelIsOpen:!1};class lp extends t.Component{constructor(){super(...arguments),this.zIndex=oe.GridPopover}get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.coordinates;return{...e,coordinates:{x:t.x+this.props.gridPosition.x,y:t.y+this.props.gridPosition.y}}}}lp.template="o-spreadsheet-GridPopover",lp.components={Popover:Un};class cp extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.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,position:"before"})}_computeHandleDisplay(e){const t=this._getEvOffset(e),i=this._getElementIndex(t);if(i<0)return;const n=this._getDimensionsInViewport(i);t-n.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=n.start,this.state.activeElement=this._getPreviousVisibleElement(i)):n.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=n.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),n=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();i.has(n)&&n<=t&&t<=o?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),i=this.state.draggerLinePosition,n=this._getElementSize(this.state.activeElement),o=i-n+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();Ts((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<o&&(this.state.draggerLinePosition=o,this.state.delta=this.MIN_ELEMENT_SIZE-n),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-i)}),(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.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),n=t.start;this.state.draggerLinePosition=n,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=n,this.state.draggerShadowThickness=i.end-t.start;As(this.env,((e,i)=>{let n="COL"===this._getType()?e:i;if(n>=0){const e=this._getDimensionsInViewport(n);n<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=n,this.state.position="before"):this._getSelectedZoneEnd()<n?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=n,this.state.position="after"):(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,Ln(e)),this.lastSelectedElementIndex=t;As(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(Ln(e)?"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 i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}Cn`
1183
1183
  .o-col-resizer {
1184
1184
  position: absolute;
1185
1185
  top: 0;
@@ -2432,4 +2432,4 @@
2432
2432
  <tableParts count="${e.filterTables.length}">
2433
2433
  ${Rf(a)}
2434
2434
  </tableParts>
2435
- `}var bS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(bS||(bS={}));const SS={},CS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:N,HEADER_WIDTH:M,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},ES={autofillModifiersRegistry:sn,autofillRulesRegistry:vn,cellMenuRegistry:Ho,colMenuRegistry:Wo,linkMenuRegistry:Zn,functionRegistry:Bu,uiPluginRegistry:ab,corePluginRegistry:sb,rowMenuRegistry:Go,sidePanelRegistry:Cs,figureRegistry:Jn,sheetMenuRegistry:Zo,chartSidePanelComponentRegistry:ds,chartComponentRegistry:on,chartRegistry:nn,topbarMenuRegistry:tr,topbarComponentRegistry:Es,clickableCellRegistry:lb,otRegistry:ir,inverseCommandRegistry:eo,cellRegistry:Kn,cellPopoverRegistry:Xn},wS={LinkCell:Np},yS={args:Ds,toBoolean:qs,toJsDate:Zs,toNumber:Vs,toString:Bs,toXC:Vt,toZone:Ni,toCartesian:Ut,numberToLetters:Lt,createFullMenuItem:Wn,UuidGenerator:Ai,formatValue:Qt,computeTextWidth:_e,isMarkdownLink:He,parseMarkdownLink:Ge,markdownLink:We,createEmptyWorkbookData:Kf,createEmptySheet:Xf,createEmptyExcelSheet:Qf,getDefaultChartJsRuntime:Or,chartFontColor:Cr,getMenuChildren:On,ChartColors:Sr,EvaluationError:c,CellErrorLevel:l,getFillingMode:_r,rgbaToHex:Ct,colorToRGBA:Et,positionToZone:Ki,deepEquals:ot},xS={ChartPanel:us,ChartFigure:Is,ChartJsComponent:rn,Grid:yp,GridOverlay:ap,ScorecardChart:ys,LineConfigPanel:as,LineBarPieDesignPanel:ns,BarConfigPanel:sr,LineBarPieConfigPanel:rr,GaugeChartConfigPanel:rs,GaugeChartDesignPanel:ss,ScorecardChartConfigPanel:cs,ScorecardChartDesignPanel:hs};e.AbstractChart=ar,e.CorePlugin=Jf,e.DATETIME_FORMAT=Y,e.DispatchResult=gn,e.EvaluationError=c,e.Model=class extends Hv{constructor(e={},i={},n=[],o=new Ai,r=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={type:e,...t};let n=this.status;if(this.getters.isReadonly()&&(o=i,!hn.has(o.type)))return new gn(67);var o;if(!this.session.canApplyOptimisticUpdate())return new gn(64);switch(n){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:n,commands:o}=this.state.recordChanges((()=>{un(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(o,n),this.status=0,this.trigger("update");break;case 1:if(un(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i)}else this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(un(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return gn.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={type:e,...t},n=this.status;this.status=2;const o=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(o,i),this.status=n,gn.Success},n=jf(e,n);const s=qf(e,r);this.state=new Fb,this.uuidGenerator=o,this.config=this.setupConfig(i),this.session=this.setupSession(s.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new Ob(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Nb(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.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new _b(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of sb.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of ab.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}this.uiPlugins.push(t),this.handlers.push(t);const i=e.layers.map((e=>[t,e]));this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const i=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Qv(Tb(e,this.state.recordChanges.bind(this.state),(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-redone",this,this.finalize),this.session.on("revision-undone",this,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()},i=e.transportService||new bb;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new gn(t.flat()):gn.Success}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ae(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Kf();for(let t of this.handlers)t instanceof Jf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Ae(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={...Kf(),sheets:[Qf(Gf,"Sheet1")]};for(let t of this.handlers)t instanceof $g&&t.exportForExcel(e);return e=Ae(e),fS(e)}},e.Registry=tn,e.Revision=Xv,e.SPREADSHEET_DIMENSIONS=CS,e.Spreadsheet=vb,e.UIPlugin=Lg,e.__info__=SS,e.addFunction=function(e,t){Bu.add(e,t)},e.astToFormula=yg,e.cellTypes=wS,e.compile=Mg,e.components=xS,e.convertAstNodes=wg,e.coreTypes=dn,e.findCellInNewZone=Yi,e.functionCache=Ng,e.helpers=yS,e.invalidateEvaluationCommands=ln,e.load=qf,e.parse=Cg,e.readonlyAllowedCommands=hn,e.registries=ES,e.setTranslationMethod=function(e){i=e},e.tokenize=qu,Object.defineProperty(e,"__esModule",{value:!0}),SS.version="16.0.47",SS.date="2024-07-08T05:37:37.541Z",SS.hash="f52ca6f"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2435
+ `}var bS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(bS||(bS={}));const SS={},CS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:N,HEADER_WIDTH:M,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},ES={autofillModifiersRegistry:sn,autofillRulesRegistry:vn,cellMenuRegistry:Ho,colMenuRegistry:Wo,linkMenuRegistry:Zn,functionRegistry:Bu,uiPluginRegistry:ab,corePluginRegistry:sb,rowMenuRegistry:Go,sidePanelRegistry:Cs,figureRegistry:Jn,sheetMenuRegistry:Zo,chartSidePanelComponentRegistry:ds,chartComponentRegistry:on,chartRegistry:nn,topbarMenuRegistry:tr,topbarComponentRegistry:Es,clickableCellRegistry:lb,otRegistry:ir,inverseCommandRegistry:eo,cellRegistry:Kn,cellPopoverRegistry:Xn},wS={LinkCell:Np},yS={args:Ds,toBoolean:qs,toJsDate:Zs,toNumber:Vs,toString:Bs,toXC:Vt,toZone:Ni,toCartesian:Ut,numberToLetters:Lt,createFullMenuItem:Wn,UuidGenerator:Ai,formatValue:Qt,computeTextWidth:_e,isMarkdownLink:He,parseMarkdownLink:Ge,markdownLink:We,createEmptyWorkbookData:Kf,createEmptySheet:Xf,createEmptyExcelSheet:Qf,getDefaultChartJsRuntime:Or,chartFontColor:Cr,getMenuChildren:On,ChartColors:Sr,EvaluationError:c,CellErrorLevel:l,getFillingMode:_r,rgbaToHex:Ct,colorToRGBA:Et,positionToZone:Ki,deepEquals:ot},xS={ChartPanel:us,ChartFigure:Is,ChartJsComponent:rn,Grid:yp,GridOverlay:ap,ScorecardChart:ys,LineConfigPanel:as,LineBarPieDesignPanel:ns,BarConfigPanel:sr,LineBarPieConfigPanel:rr,GaugeChartConfigPanel:rs,GaugeChartDesignPanel:ss,ScorecardChartConfigPanel:cs,ScorecardChartDesignPanel:hs};e.AbstractChart=ar,e.CorePlugin=Jf,e.DATETIME_FORMAT=Y,e.DispatchResult=gn,e.EvaluationError=c,e.Model=class extends Hv{constructor(e={},i={},n=[],o=new Ai,r=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={type:e,...t};let n=this.status;if(this.getters.isReadonly()&&(o=i,!hn.has(o.type)))return new gn(67);var o;if(!this.session.canApplyOptimisticUpdate())return new gn(64);switch(n){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:n,commands:o}=this.state.recordChanges((()=>{un(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(o,n),this.status=0,this.trigger("update");break;case 1:if(un(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i)}else this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(un(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return gn.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={type:e,...t},n=this.status;this.status=2;const o=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(o,i),this.status=n,gn.Success},n=jf(e,n);const s=qf(e,r);this.state=new Fb,this.uuidGenerator=o,this.config=this.setupConfig(i),this.session=this.setupSession(s.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new Ob(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Nb(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.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new _b(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of sb.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of ab.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}this.uiPlugins.push(t),this.handlers.push(t);const i=e.layers.map((e=>[t,e]));this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const i=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Qv(Tb(e,this.state.recordChanges.bind(this.state),(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-redone",this,this.finalize),this.session.on("revision-undone",this,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()},i=e.transportService||new bb;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new gn(t.flat()):gn.Success}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ae(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Kf();for(let t of this.handlers)t instanceof Jf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Ae(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={...Kf(),sheets:[Qf(Gf,"Sheet1")]};for(let t of this.handlers)t instanceof $g&&t.exportForExcel(e);return e=Ae(e),fS(e)}},e.Registry=tn,e.Revision=Xv,e.SPREADSHEET_DIMENSIONS=CS,e.Spreadsheet=vb,e.UIPlugin=Lg,e.__info__=SS,e.addFunction=function(e,t){Bu.add(e,t)},e.astToFormula=yg,e.cellTypes=wS,e.compile=Mg,e.components=xS,e.convertAstNodes=wg,e.coreTypes=dn,e.findCellInNewZone=Yi,e.functionCache=Ng,e.helpers=yS,e.invalidateEvaluationCommands=ln,e.load=qf,e.parse=Cg,e.readonlyAllowedCommands=hn,e.registries=ES,e.setTranslationMethod=function(e){i=e},e.tokenize=qu,Object.defineProperty(e,"__esModule",{value:!0}),SS.version="16.0.48",SS.date="2024-07-18T14:12:39.369Z",SS.hash="a1be508"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
@@ -3239,7 +3239,7 @@ https://fontawesome.com/license -->
3239
3239
  </t>
3240
3240
  </odoo>
3241
3241
  <!--
3242
- __info__.version = '16.0.47';
3243
- __info__.date = '2024-07-08T05:37:59.279Z';
3244
- __info__.hash = 'f52ca6f';
3242
+ __info__.version = '16.0.48';
3243
+ __info__.date = '2024-07-18T14:13:02.116Z';
3244
+ __info__.hash = 'a1be508';
3245
3245
  -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "16.0.47",
3
+ "version": "16.0.48",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",