@odoo/o-spreadsheet 16.0.53 → 16.0.55

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.
@@ -824,7 +824,7 @@
824
824
  }
825
825
  }
826
826
  }
827
- `;class Ss extends t.Component{constructor(){super(...arguments),this.icons=fs,this.cellIsOperators=Ko,this.iconSets=vs,this.getTextDecoration=wn,this.colorNumberString=gt}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return Xo.Errors[e]||Xo.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type){return`font-weight:${e.style.bold?"bold":"normal"};\n text-decoration:${wn(e.style)};\n font-style:${e.style.italic?"italic":"normal"};\n color:${e.style.textColor||"none"};\n background-color:${e.style.fillColor||"none"};`}if("ColorScaleRule"===e.type){const t=gt(e.minimum.color),i=e.midpoint?gt(e.midpoint.color):null,n=gt(e.maximum.color),o="background-image: linear-gradient(to right, ";return i?o+t+", "+i+", "+n+")":o+t+", "+n+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Ko[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?o("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Xo.ColorScale;case"IconSetRule":return Xo.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Nt))))return void(this.state.errors=[25]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});t.isSuccessful?this.switchToList():this.state.errors=t.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(51))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(52))}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(58)||this.state.errors.includes(50)||this.state.errors.includes(47)||this.state.errors.includes(53);case"midpoint":return this.state.errors.includes(59)||this.state.errors.includes(54)||this.state.errors.includes(49);case"maximum":return this.state.errors.includes(60)||this.state.errors.includes(55);default:return!1}}setColorScaleColor(e,t){const i=this.state.rules.colorScale[e];i&&(i.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,i=gt(t.minimum.color),n=gt((null===(e=t.midpoint)||void 0===e?void 0:e.color)||x),o=gt(t.maximum.color),r="background-image: linear-gradient(to right, ";return void 0===t.midpoint?r+i+", "+o+")":r+i+", "+n+", "+o+")"}getThresholdColor(e){return gt(e?e.color:x)}onMidpointChange(e){const t=e.target.value,i=this.state.rules.colorScale;i.midpoint="none"===t?void 0:{color:x,value:"",...i.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(57)||this.state.errors.includes(62)||this.state.errors.includes(48);case"upperInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(48);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}Ss.template="o-spreadsheet-ConditionalFormattingPanel",Ss.components={SelectionInput:sr,IconPicker:bs,ColorPicker:os},En`
827
+ `;class Ss extends t.Component{constructor(){super(...arguments),this.icons=fs,this.cellIsOperators=Ko,this.iconSets=vs,this.getTextDecoration=wn,this.colorNumberString=gt}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return Xo.Errors[e]||Xo.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type){return`font-weight:${e.style.bold?"bold":"normal"};\n text-decoration:${wn(e.style)};\n font-style:${e.style.italic?"italic":"normal"};\n color:${e.style.textColor||"none"};\n background-color:${e.style.fillColor||"none"};`}if("ColorScaleRule"===e.type){const t=gt(e.minimum.color),i=e.midpoint?gt(e.midpoint.color):null,n=gt(e.maximum.color),o="background-image: linear-gradient(to right, ";return i?o+t+", "+i+", "+n+")":o+t+", "+n+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Ko[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?o("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Xo.ColorScale;case"IconSetRule":return Xo.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Nt))))return void(this.state.errors=[25]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});t.isSuccessful?this.switchToList():this.state.errors=t.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(51))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(52))}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(58)||this.state.errors.includes(50)||this.state.errors.includes(47)||this.state.errors.includes(53);case"midpoint":return this.state.errors.includes(59)||this.state.errors.includes(54)||this.state.errors.includes(49);case"maximum":return this.state.errors.includes(60)||this.state.errors.includes(55);default:return!1}}setColorScaleColor(e,t){if(!ft(t))return;const i=this.state.rules.colorScale[e];i&&(i.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,i=gt(t.minimum.color),n=gt((null===(e=t.midpoint)||void 0===e?void 0:e.color)||x),o=gt(t.maximum.color),r="background-image: linear-gradient(to right, ";return void 0===t.midpoint?r+i+", "+o+")":r+i+", "+n+", "+o+")"}getThresholdColor(e){return gt(e?e.color:x)}onMidpointChange(e){const t=e.target.value,i=this.state.rules.colorScale;i.midpoint="none"===t?void 0:{color:x,value:"",...i.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(57)||this.state.errors.includes(62)||this.state.errors.includes(48);case"upperInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(48);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}Ss.template="o-spreadsheet-ConditionalFormattingPanel",Ss.components={SelectionInput:sr,IconPicker:bs,ColorPicker:os},En`
828
828
  .o-custom-currency {
829
829
  .o-format-proposals {
830
830
  color: black;
@@ -980,7 +980,7 @@
980
980
  opacity: 0;
981
981
  pointer-events: none;
982
982
  }
983
- `;class Fs 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":""}`}}Fs.template="o-spreadsheet-ClientTag";const Ds=/(.*?)\((.*?)\)(.*)/,ks=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function $s(e){let t=e.split("\n");const i=[];for(let e of t)e=e.trim(),e&&i.push(Ls(e));return i}function Ls(e){let t,i=e.match(Ds),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=ks.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 Ps(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 Us=["number","string","boolean","undefined"];function Vs(e,t){if(!e())throw new Error(t)}const zs=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Bs(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(zs(e));default:return 0}}function Hs(e){if(""===e)throw new Error(zs(e));return Bs(e)}function Ws(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const Gs=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 qs(e){return"string"==typeof e?Gs(e):e}const Zs=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function js(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(Zs(e))}return!1;case"number":return!!e;default:return!1}}function Ys(e){return Se(Bs(e))}function Xs(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 Ks(e,t){Xs(e,t,t)}function Qs(e,t){Xs(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Hs(e))}))}function Js(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 ea(e,t,i){return Js(e,t,t,i)}function ta(e,t,i){return Js(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,Hs(i))),i)}function ia(e,t,i){return Js(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Bs(i):0):e),((e,i)=>t(e,Bs(i))),i)}function na(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(Zs(e));return js(e)}(e))))}function oa(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=Bs(n):"TRUE"!==n&&"FALSE"!==n||(n=js(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 ra(e="",t){const{operator:i,operand:n}=t;if(void 0===n)return!1;if("number"==typeof n&&"="===i)return"string"==typeof e&&(Ci(e)||Ve(e))?Bs(e)===n:e===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 sa(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=Ws(e[t+1]);a.push(oa(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=ra(e[t][i][o],a[t/2]),!r)break}r&&t(i,o)}}function aa(e,t){return qs(e[0][t])}function la(e,t){return qs(e[t][0])}function ca(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 ha(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&&da(t,c)>=0||da(t,c)>=0&&da(c,a)>0)&&(a=c,l=o):"nextGreater"===i&&(!a&&da(t,c)<=0||da(t,c)<=0&&da(c,a)<0)&&(a=c,l=o)}return r?n-l-1:l}function da(e,t){let i=Us.indexOf(typeof e)-Us.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 ua={description:r("Apply a large number format"),args:$s(`\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(Bs(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 Bs(e)}};var ga=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:ua});const pa={description:r("Absolute value of a number."),args:$s(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Bs(e))},isExported:!0},ma={description:r("Inverse cosine of a value, in radians."),args:$s(`\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=Bs(e);return Vs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},fa={description:r("Inverse hyperbolic cosine of a number."),args:$s(`\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=Bs(e);return Vs((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},va={description:r("Inverse cotangent of a value."),args:$s(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},ba={description:r("Inverse hyperbolic cotangent of a value."),args:$s(`\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=Bs(e);return Vs((()=>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},Sa={description:r("Inverse sine of a value, in radians."),args:$s(`\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=Bs(e);return Vs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ca={description:r("Inverse hyperbolic sine of a number."),args:$s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Bs(e))},isExported:!0},Ea={description:r("Inverse tangent of a value, in radians."),args:$s(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Bs(e))},isExported:!0},wa={description:r("Angle from the X axis to a point (x,y), in radians."),args:$s(`\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=Bs(e),n=Bs(t);return Vs((()=>0!==i||0!==n),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(n,i)},isExported:!0},ya={description:r("Inverse hyperbolic tangent of a number."),args:$s(`\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=Bs(e);return Vs((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},xa={description:r("Rounds number up to nearest multiple of factor."),args:$s(`\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=Bs(e),n=Bs(t);return Vs((()=>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},Ra={description:r("Rounds number up to nearest multiple of factor."),args:$s(`\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=Bs(t);if(0===n)return 0;const o=Bs(e);if(n=Math.abs(n),o>=0)return Math.ceil(o/n)*n;return 0===Bs(i)?-Math.floor(Math.abs(o)/n)*n:-Math.ceil(Math.abs(o)/n)*n},isExported:!0},Ia={description:r("Rounds number up to nearest multiple of factor."),args:$s(`\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 Ra.compute(e,t,0)},isExported:!0},Ta={description:r("Cosine of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Bs(e))},isExported:!0},Aa={description:r("Hyperbolic cosine of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Bs(e))},isExported:!0},Oa={description:r("Cotangent of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Na={description:r("Hyperbolic cotangent of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Ma={description:r("Number of empty values."),args:$s(`\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 ea(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},_a={description:r("A conditional count across a range."),args:$s(`\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 sa(e,((e,i)=>{t+=1})),t},isExported:!0},Fa={description:r("Count values depending on multiple criteria."),args:$s(`\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 sa(e,((e,i)=>{t+=1})),t},isExported:!0};function Da(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const ka={description:r("Counts number of unique values in a range."),args:$s(`\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 ea(e,((e,t)=>Da(t)?e.add(t):e),new Set).size}},$a={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:$s(`\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 sa(t,((t,n)=>{const o=e[t][n];Da(o)&&i.add(o)})),i.size}},La={description:r("Cosecant of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Pa={description:r("Hyperbolic cosecant of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Ua={description:r("Converts from another base to decimal."),args:$s(`\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=Bs(t);i=Math.floor(i),Vs((()=>2<=i&&i<=36),r("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const n=Ws(e);if(""===n)return 0;Vs((()=>!!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 Vs((()=>!isNaN(o)),r("The value (%s) must be a valid base %s representation.",n,i.toString())),o},isExported:!0},Va={description:r("Converts an angle value in radians to degrees."),args:$s(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Bs(e)/Math.PI},isExported:!0},za={description:r("Euler's number, e (~2.718) raised to a power."),args:$s(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Bs(e))},isExported:!0},Ba={description:r("Rounds number down to nearest multiple of factor."),args:$s(`\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=Bs(e),n=Bs(t);return Vs((()=>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},Ha={description:r("Rounds number down to nearest multiple of factor."),args:$s(`\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=Bs(t);if(0===n)return 0;const o=Bs(e);if(n=Math.abs(n),o>=0)return Math.floor(o/n)*n;return 0===Bs(i)?-Math.ceil(Math.abs(o)/n)*n:-Math.floor(Math.abs(o)/n)*n},isExported:!0},Wa={description:r("Rounds number down to nearest multiple of factor."),args:$s(`\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 Ha.compute(e,t,0)},isExported:!0},Ga={description:r("Whether the provided value is even."),args:$s(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Hs(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},qa={description:r("Rounds number up to nearest multiple of factor."),args:$s(`\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 Ra.compute(e,t,0)},isExported:!0},Za={description:r("Whether the provided value is even."),args:$s(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Hs(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},ja={description:r("The logarithm of a number, base e (euler's number)."),args:$s(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ya={description:r("Modulo (remainder) operator."),args:$s(`\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=Bs(t);Vs((()=>0!==i),r("The divisor must be different from 0."));const n=Bs(e)%i;return n>0&&i<0||n<0&&i>0?n+i:n},isExported:!0},Xa={description:r("Rounds a number up to the nearest odd integer."),args:$s(`\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=Bs(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},Ka={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Qa={description:r("A number raised to a power."),args:$s(`\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=Bs(e),n=Bs(t);return Vs((()=>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},Ja={description:r("Result of multiplying a series of numbers together."),args:$s(`\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*=Hs(n),t+=1);return 0===t?0:i},isExported:!0},el={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},tl={description:r("Random integer between two values, inclusive."),args:$s(`\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=Bs(e);Number.isInteger(i)||(i=Math.ceil(i));let n=Bs(t);return Number.isInteger(n)||(n=Math.floor(n)),Vs((()=>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},il={description:r("Rounds a number according to standard rules."),args:$s(`\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=Bs(e);let n=Bs(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},nl={description:r("Rounds down a number."),args:$s(`\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=Bs(e);let n=Bs(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},ol={description:r("Rounds up a number."),args:$s(`\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=Bs(e);let n=Bs(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},rl={description:r("Secant of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Bs(e))},isExported:!0},sl={description:r("Hyperbolic secant of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Bs(e))},isExported:!0},al={description:r("Sine of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Bs(e))},isExported:!0},ll={description:r("Hyperbolic sine of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Bs(e))},isExported:!0},cl={description:r("Positive square root of a positive number."),args:$s(`\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=Bs(e);return Vs((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},hl={description:r("Sum of a series of numbers and/or cells."),args:$s(`\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 ta(e,((e,t)=>e+t),0)},isExported:!0},dl={description:r("A conditional sum across a range."),args:$s(`\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 sa([e,t],((e,t)=>{const o=i[e][t];"number"==typeof o&&(n+=o)})),n},isExported:!0},ul={description:r("Sums a range depending on multiple criteria."),args:$s(`\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 sa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i+=o)})),i},isExported:!0},gl={description:r("Tangent of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Bs(e))},isExported:!0},pl={description:r("Hyperbolic tangent of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Bs(e))},isExported:!0},ml={description:r("Truncates a number."),args:$s(`\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=Bs(e);let n=Bs(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 fl=Object.freeze({__proto__:null,ABS:pa,ACOS:ma,ACOSH:fa,ACOT:va,ACOTH:ba,ASIN:Sa,ASINH:Ca,ATAN:Ea,ATAN2:wa,ATANH:ya,CEILING:xa,CEILING_MATH:Ra,CEILING_PRECISE:Ia,COS:Ta,COSH:Aa,COT:Oa,COTH:Na,COUNTBLANK:Ma,COUNTIF:_a,COUNTIFS:Fa,COUNTUNIQUE:ka,COUNTUNIQUEIFS:$a,CSC:La,CSCH:Pa,DECIMAL:Ua,DEGREES:Va,EXP:za,FLOOR:Ba,FLOOR_MATH:Ha,FLOOR_PRECISE:Wa,ISEVEN:Ga,ISO_CEILING:qa,ISODD:Za,LN:ja,MOD:Ya,ODD:Xa,PI:Ka,POWER:Qa,PRODUCT:Ja,RAND:el,RANDBETWEEN:tl,ROUND:il,ROUNDDOWN:nl,ROUNDUP:ol,SEC:rl,SECH:sl,SIN:al,SINH:ll,SQRT:cl,SUM:hl,SUMIF:dl,SUMIFS:ul,TAN:gl,TANH:pl,TRUNC:ml});function vl(e,t,i){let n=[],o=[],s=0,a=0;Ks([e],(e=>{n.push(e),s+=1})),Ks([t],(e=>{o.push(e),a+=1})),Vs((()=>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)}Vs((()=>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 bl(e,t,i){let n=0,o=0;const s=i?ia:ta;o=s(e,((e,t)=>(n+=1,e+t)),0),Vs((()=>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 Sl(e,t,i){const n=Bs(t);Vs((()=>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 Ks(e,(e=>{"number"==typeof e&&(o=ca(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(o+1,0,e),a++)})),Vs((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),i||Vs((()=>1/(a+1)<=n&&n<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),yi(s,n,i)}const Cl={description:r("Average magnitude of deviations from mean."),args:$s(`\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=ta(e,((e,i)=>(t+=1,e+i)),0);Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const n=i/t;return ta(e,((e,t)=>e+Math.abs(n-t)),0)/t},isExported:!0},El={description:r("Numerical average value in a dataset, ignoring text."),args:$s(`\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=ta(e,((e,i)=>(t+=1,e+i)),0);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},wl=r("[[FUNCTION_NAME]] has mismatched range sizes."),yl=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),xl={description:r("Weighted average."),args:$s(`\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;Vs((()=>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)){Vs((()=>Array.isArray(i)),wl);let e=t.length,s=t[0].length;Vs((()=>e===i.length&&s===i[0].length),wl);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;Vs((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(Vs((()=>l>=0),yl),n+=s*l,o+=l)}}else i=Bs(i),t=Bs(t),Vs((()=>i>=0),yl),n+=t*i,o+=i;return Vs((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o}},Rl={description:r("Numerical average value in a dataset."),args:$s(`\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=ia(e,((e,i)=>(t+=1,e+i)),0);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Il={description:r("Average of values depending on criteria."),args:$s(`\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 sa([e,t],((t,r)=>{const s=(i||e)[t][r];"number"==typeof s&&(n+=1,o+=s)})),Vs((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n},isExported:!0},Tl={description:r("Average of values depending on multiple criteria."),args:$s(`\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 sa(t,((t,o)=>{const r=e[t][o];"number"==typeof r&&(i+=1,n+=r)})),Vs((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i},isExported:!0},Al={description:r("The number of numeric values in dataset."),args:$s(`\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},Ol={description:r("The number of values in a dataset."),args:$s(`\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 ea(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Nl={description:r("The covariance of a dataset."),args:$s(`\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 vl(e,t,!1)},isExported:!0},Ml={description:r("The covariance of a dataset."),args:$s(`\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 vl(e,t,!1)},isExported:!0},_l={description:r("The sample covariance of a dataset."),args:$s(`\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 vl(e,t,!0)},isExported:!0},Fl={description:r("Nth largest element from a data set."),args:$s(`\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(Bs(t));let n,o=[],s=0;Ks([e],(e=>{"number"==typeof e&&(n=ca(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 Vs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Vs((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Dl={description:r("Maximum value in a numeric dataset."),args:$s(`\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=ta(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},kl={description:r("Maximum numeric value in a dataset."),args:$s(`\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=ia(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},$l={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:$s(`\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 sa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i<o?o:i)})),i===-1/0?0:i},isExported:!0},Ll={description:r("Median value in a numeric dataset."),args:$s(`\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 Qs(e,(e=>{t.push(e)})),Sl(t,.5,!0)},isExported:!0},Pl={description:r("Minimum value in a numeric dataset."),args:$s(`\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=ta(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Ul={description:r("Minimum numeric value in a dataset."),args:$s(`\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=ia(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Vl={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:$s(`\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 sa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i>o?o:i)})),i===1/0?0:i},isExported:!0},zl={description:r("Value at a given percentile of a dataset."),args:$s(`\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 Hl.compute(e,t)},isExported:!0},Bl={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:$s(`\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 Sl([e],t,!1)},isExported:!0},Hl={description:r("Value at a given percentile of a dataset."),args:$s(`\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 Sl([e],t,!0)},isExported:!0},Wl={description:r("Value nearest to a specific quartile of a dataset."),args:$s(`\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 ql.compute(e,t)},isExported:!0},Gl={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:$s(`\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 Sl([e],.25*Math.trunc(Bs(t)),!1)},isExported:!0},ql={description:r("Value nearest to a specific quartile of a dataset."),args:$s(`\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 Sl([e],.25*Math.trunc(Bs(t)),!0)},isExported:!0},Zl={description:r("Nth smallest element in a data set."),args:$s(`\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(Bs(t));let n,o=[],s=0;Ks([e],(e=>{"number"==typeof e&&(n=ca(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 Vs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Vs((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},jl={description:r("Standard deviation."),args:$s(`\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 entire population."),args:$s(`\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(tc.compute(...e))},isExported:!0},Xl={description:r("Standard deviation."),args:$s(`\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(ic.compute(...e))},isExported:!0},Kl={description:r("Standard deviation of sample (text as 0)."),args:$s(`\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(nc.compute(...e))},isExported:!0},Ql={description:r("Standard deviation of entire population."),args:$s(`\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(oc.compute(...e))},isExported:!0},Jl={description:r("Standard deviation of entire population (text as 0)."),args:$s(`\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(rc.compute(...e))},isExported:!0},ec={description:r("Variance."),args:$s(`\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 bl(e,!0,!1)},isExported:!0},tc={description:r("Variance of entire population."),args:$s(`\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 bl(e,!1,!1)},isExported:!0},ic={description:r("Variance."),args:$s(`\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 bl(e,!0,!1)},isExported:!0},nc={description:r("Variance of sample (text as 0)."),args:$s(`\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 bl(e,!0,!0)},isExported:!0},oc={description:r("Variance of entire population."),args:$s(`\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 bl(e,!1,!1)},isExported:!0},rc={description:r("Variance of entire population (text as 0)."),args:$s(`\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 bl(e,!1,!0)},isExported:!0};var sc=Object.freeze({__proto__:null,AVEDEV:Cl,AVERAGE:El,AVERAGE_WEIGHTED:xl,AVERAGEA:Rl,AVERAGEIF:Il,AVERAGEIFS:Tl,COUNT:Al,COUNTA:Ol,COVAR:Nl,COVARIANCE_P:Ml,COVARIANCE_S:_l,LARGE:Fl,MAX:Dl,MAXA:kl,MAXIFS:$l,MEDIAN:Ll,MIN:Pl,MINA:Ul,MINIFS:Vl,PERCENTILE:zl,PERCENTILE_EXC:Bl,PERCENTILE_INC:Hl,QUARTILE:Wl,QUARTILE_EXC:Gl,QUARTILE_INC:ql,SMALL:Zl,STDEV:jl,STDEV_P:Yl,STDEV_S:Xl,STDEVA:Kl,STDEVP:Ql,STDEVPA:Jl,VAR:ec,VAR_P:tc,VAR_S:ic,VARA:nc,VARP:oc,VARPA:rc});function ac(e,t,i){var n;const o=new Map,s=e.length;for(let t=s-1;t>=0;t--)o.set(Ws(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=Ws(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.",Ws(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=Ws(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}sa(n,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const lc=$s(`\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`),cc={description:r("Average of a set of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return El.compute([n])},isExported:!0},hc={description:r("Counts values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Al.compute([n])},isExported:!0},dc={description:r("Counts values and text from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Ol.compute([n])},isExported:!0},uc={description:r("Single value from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Vs((()=>1===n.length),r("More than one match found in DGET evaluation.")),n[0]},isExported:!0},gc={description:r("Maximum of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Dl.compute([n])},isExported:!0},pc={description:r("Minimum of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Pl.compute([n])},isExported:!0},mc={description:r("Product of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Ja.compute([n])},isExported:!0},fc={description:r("Standard deviation of population sample from table."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return jl.compute([n])},isExported:!0},vc={description:r("Standard deviation of entire population from table."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Ql.compute([n])},isExported:!0},bc={description:r("Sum of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return hl.compute([n])},isExported:!0},Sc={description:r("Variance of population sample from table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return ec.compute([n])},isExported:!0},Cc={description:r("Variance of a population from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return oc.compute([n])},isExported:!0};var Ec=Object.freeze({__proto__:null,DAVERAGE:cc,DCOUNT:hc,DCOUNTA:dc,DGET:uc,DMAX:gc,DMIN:pc,DPRODUCT:mc,DSTDEV:fc,DSTDEVP:vc,DSUM:bc,DVAR:Sc,DVARP:Cc});const wc={description:r("Converts year/month/day into a date."),args:$s(`\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(Bs(e));const o=Math.trunc(Bs(t)),s=Math.trunc(Bs(i));Vs((()=>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 Vs((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},yc={description:r("Converts a date string to a date value."),args:$s(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ws(e),i=ve(t);return Vs((()=>null!==i),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},xc={description:r("Day of the month that a specific date falls on."),args:$s(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getDate()},isExported:!0},Rc={description:r("Number of days between two dates."),args:$s(`\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=Ys(e),n=Ys(t),o=i.getTime()-n.getTime();return Math.round(o/ce)},isExported:!0},Ic={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:$s(`\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=Bs(e),o=Bs(t),r=js(i)?4:0,s=qc.compute(e,t,r);return Math.sign(o-n)*Math.round(360*s)},isExported:!0},Tc={description:r("Date a number of months before/after another date."),args:$s(`\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(Ys(e),Math.trunc(Bs(t)),!1))},isExported:!0},Ac={description:r("Last day of a month before or after a date."),args:$s(`\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=Ys(e),n=Math.trunc(Bs(t)),o=i.getFullYear(),r=i.getMonth();return Ce(new ae(o,r+n+1,0))},isExported:!0},Oc={description:r("Hour component of a specific time."),args:$s(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getHours()},isExported:!0},Nc={description:r("ISO week number of the year."),args:$s(`\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=Ys(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},Mc={description:r("Minute component of a specific time."),args:$s(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getMinutes()},isExported:!0},_c={description:r("Month of the year a specific date falls in"),args:$s(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getMonth()+1},isExported:!0},Fc={description:r("Net working days between two provided days."),args:$s(`\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 kc.compute(e,t,1,i)},isExported:!0};function Dc(e){if("string"==typeof e){Vs((()=>{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 Vs((()=>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 kc={description:r("Net working days between two dates (specifying weekends)."),args:$s(`\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=Ys(e),r=Ys(t),s=Dc(i);let a=new Set;void 0!==n&&Ks([n],(e=>{const t=Ys(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},$c={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},Lc={description:r("Minute component of a specific time."),args:$s(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getSeconds()},isExported:!0},Pc={description:r("Converts hour/minute/second into a time."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t)),s=Math.trunc(Bs(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,Vs((()=>n>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),n/24+o/1440+s/86400},isExported:!0},Uc={description:r("Converts a time string into its serial number representation."),args:$s(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ws(e),i=ve(t);Vs((()=>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},Vc={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},zc={description:r("Day of the week of the date provided (as number)."),args:$s(`\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=Ys(e),n=Math.round(Bs(t)),o=i.getDay();return Vs((()=>[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},Bc={description:r("Week number of the year."),args:$s(`\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=Ys(e),n=Math.round(Bs(t));if(Vs((()=>1===n||2===n||11<=n&&n<=17||21===n),r("The type (%s) is out of range.",n.toString())),21===n)return Nc.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},Hc={description:r("Date after a number of workdays."),args:$s(`\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 Wc.compute(e,t,1,i)},isExported:!0},Wc={description:r("Date after a number of workdays (specifying weekends)."),args:$s(`\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=Ys(e),s=Math.trunc(Bs(t));"string"==typeof i&&Vs((()=>"1111111"!==i),r("The weekend (%s) must be different from '1111111'.",i));const a=Dc(i);let l=new Set;void 0!==n&&Ks([n],(e=>{const t=Ys(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},Gc={description:r("Year specified by a given date."),args:$s(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getFullYear()},isExported:!0},qc={description:r("Exact number of years between two dates."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t));const s=Math.trunc(Bs(i));return Vs((()=>n>=0),r("The start_date (%s) must be positive or null.",n.toString())),Vs((()=>o>=0),r("The end_date (%s) must be positive or null.",o.toString())),Vs((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),Re(n,o,s)}},Zc={description:r("First day of the month preceding a date."),args:$s(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Ys(e),i=t.getFullYear(),n=t.getMonth();return Ce(new ae(i,n,1))}},jc={description:r("Last day of the month following a date."),args:$s(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return Ac.compute(e,0)}},Yc={description:r("Quarter of the year a specific date falls in"),args:$s(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Ys(e).getMonth()+1)/3)}},Xc={description:r("First day of the quarter of the year a specific date falls in."),args:$s(`\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=Yc.compute(e),i=Gc.compute(e);return Ce(new ae(i,3*(t-1),1))}},Kc={description:r("Last day of the quarter of the year a specific date falls in."),args:$s(`\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=Yc.compute(e),i=Gc.compute(e);return Ce(new ae(i,3*t,0))}},Qc={description:r("First day of the year a specific date falls in."),args:$s(`\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=Gc.compute(e);return Ce(new ae(t,0,1))}},Jc={description:r("Last day of the year a specific date falls in."),args:$s(`\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=Gc.compute(e);return Ce(new ae(t+1,0,0))}};var eh=Object.freeze({__proto__:null,DATE:wc,DATEVALUE:yc,DAY:xc,DAYS:Rc,DAYS360:Ic,EDATE:Tc,EOMONTH:Ac,HOUR:Oc,ISOWEEKNUM:Nc,MINUTE:Mc,MONTH:_c,NETWORKDAYS:Fc,NETWORKDAYS_INTL:kc,NOW:$c,SECOND:Lc,TIME:Pc,TIMEVALUE:Uc,TODAY:Vc,WEEKDAY:zc,WEEKNUM:Bc,WORKDAY:Hc,WORKDAY_INTL:Wc,YEAR:Gc,YEARFRAC:qc,MONTH_START:Zc,MONTH_END:jc,QUARTER:Yc,QUARTER_START:Xc,QUARTER_END:Kc,YEAR_START:Qc,YEAR_END:Jc});const th={description:r("Compare two numeric values, returning 1 if they're equal."),args:$s(`\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 Bs(e)===Bs(t)?1:0},isExported:!0};var ih=Object.freeze({__proto__:null,DELTA:th});function nh(e,t){Vs((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function oh(e,t){Vs((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function rh(e){Vs((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function sh(e){Vs((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function ah(e){Vs((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function lh(e){Vs((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function ch(e){Vs((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function hh(e){Vs((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function dh(e){Vs((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function uh(e){Vs((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function gh(e){Vs((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function ph(e){Vs((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function mh(e){Vs((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function fh(e,t){Vs((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function vh(e){Vs((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function bh(e){Vs((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function Sh(e){Vs((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function Ch(e){Vs((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Eh(e,t){const i=Ys(e),n=Ys(t),o=Ys(e);o.setFullYear(i.getFullYear()+1),Vs((()=>n.getTime()<=o.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function wh(e,t,i){ch(i),Vs((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),Vs((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),Vs((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Vs((()=>t<=i),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function yh(e){Vs((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function xh(e,t){Vs((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Rh(e){Vs((()=>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 Ih=$s(`\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 Th(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)?(Vs((()=>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,Vs((()=>g<n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Ah={description:r("Accrued interest of security paying at maturity."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(n),l=Bs(i),c=Math.trunc(Bs(o));oh(s,r),sh(c),ah(a),hh(l);return a*l*qc.compute(r,s,o)},isExported:!0},Oh={description:r("Depreciation for an accounting period."),args:$s(`\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=Bs(e),c=Math.trunc(Bs(t)),h=Math.trunc(Bs(i)),d=Bs(n),u=Bs(o),g=Bs(s),p=Math.trunc(Bs(a));!function(e){Vs((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),ph(d),function(e,t){Vs((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Vs((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),hh(g),sh(p),Vs((()=>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=qc.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},Nh={description:r("Days in coupon period containing settlement date."),args:Ih,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));if(nh(o,r),rh(s),sh(a),1===a){const o=kh.compute(e,t,i,n);return Fh.compute(e,t,i,n)-o}return(3===a?365:360)/s},isExported:!0},Mh={description:r("Days from settlement until next coupon."),args:Ih,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);const l=kh.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=Ys(o),h=Ys(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},_h={description:r("Days from settlement until next coupon."),args:Ih,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);const l=Fh.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=Mh.compute(e,t,i,a);return Nh.compute(e,t,i,a)-c},isExported:!0},Fh={description:r("Next coupon date after the settlement date."),args:Ih,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);const l=12/s,c=Dh.compute(e,t,i,n);return Ce(ye(Ys(r),-(c-1)*l,!0))},isExported:!0},Dh={description:r("Number of coupons between settlement and maturity."),args:Ih,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);let l=1,c=r;const h=12/s;for(;c>o;)c=Ce(ye(Ys(c),-h,!1)),l++;return l-1},isExported:!0},kh={description:r("Last coupon date prior to or on the settlement date."),args:Ih,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);const l=12/s,c=Dh.compute(e,t,i,n);return Ce(ye(Ys(r),-c*l,!0))},isExported:!0},$h={description:r("Cumulative interest paid over a set of periods."),args:$s(`\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=Bs(n),a=Bs(o),l=Bs(e),c=Bs(i),h=Bs(t);wh(s,a,h),hh(l),mh(c);let d=0;for(let t=s;t<=a;t++){d+=jh.compute(e,t,h,i,0,r)}return d},isExported:!0},Lh={description:r("Cumulative principal paid over a set of periods."),args:$s(`\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=Bs(n),a=Bs(o),l=Bs(e),c=Bs(i),h=Bs(t);wh(s,a,h),hh(l),mh(c);let d=0;for(let t=s;t<=a;t++){d+=od.compute(e,t,h,i,0,r)}return d},isExported:!0},Ph={description:r("Depreciation via declining balance method."),args:$s(`\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=Bs(e),a=Bs(t),l=Bs(i),c=Math.trunc(Bs(n)),h=o.length?Math.trunc(Bs(o[0])):12,d=l+(12===h?0:1);uh(s),ph(a),gh(c),dh(l),Vs((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Vs((()=>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},Uh={description:r("Depreciation via double-declining balance method."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n),c=Bs(o);if(uh(r),ph(s),gh(l),dh(a),fh(l,a),Ch(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},Vh={description:r("Discount rate of a security based on price."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(i),l=Bs(n),c=Math.trunc(Bs(o));nh(r,s),sh(c),lh(a),ah(l);return(l-a)/l/qc.compute(r,s,c)},isExported:!0},zh={description:r("Convert a decimal fraction to decimal value."),args:$s(`\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=Bs(e),n=Math.trunc(Bs(t));Vs((()=>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},Bh={description:r("Convert a decimal value to decimal fraction."),args:$s(`\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=Bs(e),n=Math.trunc(Bs(t));Vs((()=>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},Hh={description:r("Number of periods for an investment to reach a value."),args:$s(`\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(Bs(e)),l=Math.trunc(Bs(t)),c=Bs(i),h=Bs(n),d=Math.trunc(Bs(o)),u=Math.trunc(Bs(s));nh(a,l),rh(d),sh(u),Vs((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),Vs((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=qc.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},Wh={description:r("Annual effective interest rate."),args:$s(`\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=Bs(e),n=Math.trunc(Bs(t));return Vs((()=>i>0),r("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Vs((()=>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},Gh={description:r("Future value of an annuity investment."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n),c=js(o)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},qh={description:r("Future value of principal from series of rates."),args:$s(`\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 ea([t],((e,t)=>e*(1+Bs(t))),Bs(e))},isExported:!0},Zh={description:r("Calculates effective interest rate."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(n),l=Bs(i);nh(r,s),vh(l),ah(a);return(a-l)/l/qc.compute(r,s,o)},isExported:!0},jh={description:r("Payment on the principal of an investment."),args:$s(`\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 nd.compute(e,i,n,o,r)-od.compute(e,t,i,n,o,r)},isExported:!0},Yh={description:r("Internal rate of return given periodic cashflows."),args:$s(`\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=Bs(t);yh(i);let n=!1,o=!1,s=[];Qs([e],(e=>{e>0&&(n=!0),e<0&&(o=!0),s.push(e)})),Vs((()=>n&&o),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return Th((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},Xh={description:r("Returns the interest paid at a particular period of an investment."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n);Vs((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*o},isExported:!0},Kh={description:r("Modified Macaulay duration."),args:$s(`\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 Hh.compute(e,t,i,n,o,r)/(1+Bs(n)/Math.trunc(Bs(o)))},isExported:!0},Qh={description:r("Modified internal rate of return."),args:$s(`\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=Bs(t),o=Bs(i),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Xe).map(Bs);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}Vs((()=>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},Jh={description:r("Annual nominal interest rate."),args:$s(`\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=Bs(e),n=Math.trunc(Bs(t));return Vs((()=>i>0),r("The effective rate (%s) must must strictly greater than 0.",i.toString())),Vs((()=>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},ed={description:r("Number of payment periods for an investment."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n),c=js(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 td={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:$s(`\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=Bs(e);return Vs((()=>-1!==i),r("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let n=0;return ta(i,((t,i)=>(n++,t+i/(1+e)**n)),t)}(i,0,t)},isExported:!0},id={description:r("Computes the number of periods needed for an investment to reach a value."),args:$s(`\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=Bs(e),o=Bs(t),s=Bs(i);return hh(n),Vs((()=>o>0),r("The present_value (%s) must be strictly positive.",o.toString())),Vs((()=>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},nd={description:r("Periodic payment for an annuity investment."),args:$s(`\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=Bs(t),s=Bs(e),a=js(o)?1:0;let l=Bs(n),c=Bs(i);if(ch(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},od={description:r("Payment on the principal of an investment."),args:$s(`\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=Bs(i),l=Bs(e),c=Bs(t),h=js(s)?1:0,d=Bs(o),u=Bs(n);ch(a),Vs((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=nd.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-Gh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},rd={description:r("Present value of an annuity investment."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n),c=js(o)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},sd={description:r("Price of a security paying periodic interest."),args:$s(`\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(Bs(e)),c=Math.trunc(Bs(t)),h=Bs(i),d=Bs(n),u=Bs(o),g=Math.trunc(Bs(s)),p=Math.trunc(Bs(a));nh(l,c),rh(g),sh(p),Vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Vs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),ah(u);const m=qc.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},ad={description:r("Price of a discount security."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(i),l=Bs(n),c=Math.trunc(Bs(o));nh(r,s),sh(c),bh(a),ah(l);return l-a*l*qc.compute(r,s,c)},isExported:!0},ld={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:$s(`\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(Bs(e)),l=Math.trunc(Bs(t)),c=Math.trunc(Bs(i)),h=Bs(n),d=Bs(o),u=Math.trunc(Bs(s));oh(a,c),nh(a,l),sh(u),Vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Vs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=qc.compute(a,l,u),p=qc.compute(a,c,u);return(100+qc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},cd=.1,hd={description:r("Interest rate of an annuity investment."),args:$s(`\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||cd;const a=Bs(e),l=Bs(t),c=js(o)?1:0,h=Bs(s);let d=Bs(n),u=Bs(i);ch(a),Vs((()=>[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())),yh(h),d-=l*c,u+=l*c;return Th((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},dd={description:r("Amount received at maturity for a security."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(i),l=Bs(n),c=Math.trunc(Bs(o));nh(r,s),sh(c),vh(a),bh(l);return a/(1-l*qc.compute(r,s,c))},isExported:!0},ud={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:$s(`\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=Bs(e),o=Bs(t),r=Bs(i);return ch(n),(r/o)**(1/n)-1},isExported:!0},gd={description:r("Depreciation of an asset using the straight-line method."),args:$s(`\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(Bs(e)-Bs(t))/Bs(i)},isExported:!0},pd={description:r("Depreciation via sum of years digit method."),args:$s(`\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=Bs(e),r=Bs(t),s=Bs(i),a=Bs(n);gh(a),dh(s),fh(a,s);return(s-a+1)/(s*(s+1)/2)*(o-r)},isExported:!0},md={description:r("Price of a US Treasury bill."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t)),r=Bs(i);nh(n,o),Eh(n,o),bh(r),Sh(r);return 100*(1-r*qc.compute(n,o,2))},isExported:!0},fd={description:r("Equivalent rate of return for a US Treasury bill."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t)),r=Bs(i);nh(n,o),Eh(n,o),bh(r),Sh(r);const s=Rc.compute(o,n);if(s<=182)return 365*r/(360-r*s);const a=md.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},vd={description:r("The yield of a US Treasury bill based on price."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t)),r=Bs(i);nh(n,o),Eh(n,o),lh(r);return(100-r)/r*(1/qc.compute(n,o,2))},isExported:!0},bd={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:$s(`\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=Bs(e),c=Bs(t),h=Bs(i),d=Math.trunc(Bs(n)),u=Math.trunc(Bs(o)),g=Bs(s),p=js(a);if(uh(l),ph(c),function(e,t,i){dh(i),Vs((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),Vs((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),Vs((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Vs((()=>t<=i),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),Ch(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},Sd={description:r("Internal rate of return given non-periodic cash flows."),args:$s(`\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=Bs(i=i||0),o=e.flat().map(Bs),s=t.flat().map(Bs);var a;xh(e,t),a=o,Vs((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),Rh(s),yh(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 Th((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},Cd={description:r("Net present value given to non-periodic cash flows.."),args:$s(`\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=Bs(e),o=Array.isArray(t)?t.flat().map(Hs):[Hs(t)],s=Array.isArray(i)?i.flat().map(Hs):[Hs(i)];if(Array.isArray(i)&&Array.isArray(t)?xh(t,i):Vs((()=>o.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Rh(s),hh(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},Ed={description:r("Annual yield of a security paying periodic interest."),args:$s(`\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(Bs(e)),c=Math.trunc(Bs(t)),h=Bs(i),d=Bs(n),u=Bs(o),g=Math.trunc(Bs(s)),p=Math.trunc(Bs(a));nh(l,c),rh(g),sh(p),Vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),lh(d),ah(u);const m=qc.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=Th((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},wd={description:r("Annual yield of a discount security."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(i),l=Bs(n),c=Math.trunc(Bs(o));nh(r,s),sh(c),lh(a),ah(l);return(l/a-1)/qc.compute(e,t,o)},isExported:!0},yd={description:r("Annual yield of a security paying interest at maturity."),args:$s(`\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(Bs(e)),l=Math.trunc(Bs(t)),c=Math.trunc(Bs(i)),h=Bs(n),d=Bs(o),u=Math.trunc(Bs(s));nh(a,l),sh(u),Vs((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),lh(d);const g=qc.compute(c,l,u),p=qc.compute(c,a,u),m=qc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var xd=Object.freeze({__proto__:null,ACCRINTM:Ah,AMORLINC:Oh,COUPDAYS:Nh,COUPDAYBS:Mh,COUPDAYSNC:_h,COUPNCD:Fh,COUPNUM:Dh,COUPPCD:kh,CUMIPMT:$h,CUMPRINC:Lh,DB:Ph,DDB:Uh,DISC:Vh,DOLLARDE:zh,DOLLARFR:Bh,DURATION:Hh,EFFECT:Wh,FV:Gh,FVSCHEDULE:qh,INTRATE:Zh,IPMT:jh,IRR:Yh,ISPMT:Xh,MDURATION:Kh,MIRR:Qh,NOMINAL:Jh,NPER:ed,NPV:td,PDURATION:id,PMT:nd,PPMT:od,PV:rd,PRICE:sd,PRICEDISC:ad,PRICEMAT:ld,RATE:hd,RECEIVED:dd,RRI:ud,SLN:gd,SYD:pd,TBILLPRICE:md,TBILLEQ:fd,TBILLYIELD:vd,VDB:bd,XIRR:Sd,XNPV:Cd,YIELD:Ed,YIELDDISC:wd,YIELDMAT:yd});const Rd={description:r("Whether a value is an error other than #N/A."),args:$s(`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},Id={description:r("Whether a value is an error."),args:$s(`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},Td={description:r("Whether a value is `true` or `false`."),args:$s(`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},Ad={description:r("Whether a value is the error #N/A."),args:$s(`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},Od={description:r("Whether a value is non-textual."),args:$s(`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},Nd={description:r("Whether a value is a number."),args:$s(`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},Md={description:r("Whether a value is text."),args:$s(`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},_d={description:r("Whether the referenced cell is empty"),args:$s(`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},Fd={description:r("Returns the error value #N/A."),args:$s(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Dd=Object.freeze({__proto__:null,ISERR:Rd,ISERROR:Id,ISLOGICAL:Td,ISNA:Ad,ISNONTEXT:Od,ISNUMBER:Nd,ISTEXT:Md,ISBLANK:_d,NA:Fd});const kd={description:r("Logical `and` operator."),args:$s(`\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 na(e,(e=>(t=!0,i=i&&e,i))),Vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},$d={description:r("Returns value depending on logical expression."),args:$s(`\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=js(e)?t():i();return null==n?"":n},isExported:!0},Ld={description:r("Value if it is not an error, otherwise 2nd argument."),args:$s(`\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},Pd={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:$s(`\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},Ud={description:r("Returns a value depending on multiple logical expressions."),args:$s(`\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){Vs((()=>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(js(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(r("No match."))},isExported:!0},Vd={description:r("Returns opposite of provided logical value."),args:$s(`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!js(e)},isExported:!0},zd={description:r("Logical `or` operator."),args:$s(`\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 na(e,(e=>(t=!0,i=i||e,!i))),Vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Bd={description:r("Logical `xor` operator."),args:$s(`\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 na(e,(e=>(t=!0,i=i?!e:e,!0))),Vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Hd=Object.freeze({__proto__:null,AND:kd,IF:$d,IFERROR:Ld,IFNA:Pd,IFS:Ud,NOT:Vd,OR:zd,XOR:Bd});const Wd={description:r("Column number of a specified cell."),args:$s(`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));Vs((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Ni(i).left+1},isExported:!0},Gd={description:r("Number of columns in a specified array or range."),args:$s(`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},qd={description:r("Horizontal lookup"),args:$s(`\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(Bs(i)),s=qs(e);Vs((()=>1<=o&&o<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=js(n);let l;return l=a?ca(t,s,"nextSmaller","asc",t.length,la):ha(t,s,"strict",t.length,la),Vs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),t[l][o-1]},isExported:!0},Zd={description:r("Returns the content of a cell, specified by row and column offset."),args:$s(`\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=Bs(t.value);return null===(n=e[Bs(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=Bs(t),a=Bs(i);return Vs((()=>a>=0&&a-1<n.length&&s>=0&&s-1<n[0].length),r("Index out of range.")),Vs((()=>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},jd={description:r("Look up a value."),args:$s(`\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=qs(e),a=o>=n,l=ca(t,s,"nextSmaller","asc",a?o:n,a?aa:la);return Vs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),void 0===i?a?t[n-1][l]:t[l][o-1]:(n=i.length,o=i[0].length,Vs((()=>1===n||1===o),r("The result_range must be a single row or a single column.")),n>1?(Vs((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Vs((()=>l<=o-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Yd={description:r("Position of item in range that matches value."),args:$s(`\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=Bs(i);const o=qs(e),s=t.length,a=t[0].length;Vs((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?aa:la,h=1===s?t[0].length:t.length;switch(n=Math.sign(n),n){case 1:l=ca(t,o,"nextSmaller","asc",h,c);break;case 0:l=ha(t,o,"strict",h,c);break;case-1:l=ca(t,o,"nextGreater","desc",h,c)}return Vs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),l+1},isExported:!0},Xd={description:r("Row number of a specified cell."),args:$s(`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)),Vs((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Ni(e).top+1},isExported:!0},Kd={description:r("Number of rows in a specified array or range."),args:$s(`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},Qd={description:r("Vertical lookup."),args:$s(`\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(Bs(i)),s=qs(e);Vs((()=>1<=o&&o<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=js(n);let l;return l=a?ca(t,s,"nextSmaller","asc",t[0].length,aa):ha(t,s,"strict",t[0].length,aa),Vs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),t[o-1][l]},isExported:!0},Jd={description:r("Search a range for a match and return the corresponding item from a second range."),args:$s(`\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(Bs(o)),l=Math.trunc(Bs(s)),c=qs(e);Vs((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),Vs((()=>1===i.length||1===i[0].length),r("return_range should be either a single row or single column.")),Vs((()=>i.length===t.length&&i[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),Vs((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),Vs((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?aa:la,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=ca(t,c,u,2===l?"asc":"desc",d,h)}else p=ha(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 Vs((()=>!!m),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),m},isExported:!0};var eu=Object.freeze({__proto__:null,COLUMN:Wd,COLUMNS:Gd,HLOOKUP:qd,INDEX:Zd,LOOKUP:jd,MATCH:Yd,ROW:Xd,ROWS:Kd,VLOOKUP:Qd,XLOOKUP:Jd});const tu={description:r("Sum of two numbers."),args:$s(`\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 Bs(e)+Bs(t)}},iu={description:r("Concatenation of two values."),args:$s(`\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 Ws(e)+Ws(t)},isExported:!0},nu={description:r("One number divided by another."),args:$s(`\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=Bs(t);return Vs((()=>0!==i),r("The divisor must be different from zero.")),Bs(e)/i}};function ou(e){return null==e}const ru={number:0,string:"",boolean:!1},su={description:r("Equal."),args:$s(`\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=ou(e)?ru[typeof t]:e,t=ou(t)?ru[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function au(e,t,i){e=ou(e)?ru[typeof t]:e,t=ou(t)?ru[typeof e]:t,"number"!=typeof e&&(e=Ws(e).toUpperCase()),"number"!=typeof t&&(t=Ws(t).toUpperCase());const n=typeof e,o=typeof t;return"string"===n&&"number"===o||("string"!==o||"number"!==n)&&i(e,t)}const lu={description:r("Strictly greater than."),args:$s(`\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 au(e,t,((e,t)=>e>t))}},cu={description:r("Greater than or equal to."),args:$s(`\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 au(e,t,((e,t)=>e>=t))}},hu={description:r("Less than."),args:$s(`\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!cu.compute(e,t)}},du={description:r("Less than or equal to."),args:$s(`\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!lu.compute(e,t)}},uu={description:r("Difference of two numbers."),args:$s(`\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 Bs(e)-Bs(t)}},gu={description:r("Product of two numbers"),args:$s(`\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 Bs(e)*Bs(t)}},pu={description:r("Not equal."),args:$s(`\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!su.compute(e,t)}},mu={description:r("A number raised to a power."),args:$s(`\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 Qa.compute(e,t)}},fu={description:r("A number with the sign reversed."),args:$s(`\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-Bs(e)}},vu={description:r("Value interpreted as a percentage."),args:$s(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Bs(e)/100}},bu={description:r("A specified number, unchanged."),args:$s(`\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 Su=Object.freeze({__proto__:null,ADD:tu,CONCAT:iu,DIVIDE:nu,EQ:su,GT:lu,GTE:cu,LT:hu,LTE:du,MINUS:uu,MULTIPLY:gu,NE:pu,POW:mu,UMINUS:fu,UNARY_PERCENT:vu,UPLUS:bu});const Cu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Eu={description:r("Gets character associated with number."),args:$s(`\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(Bs(e));return Vs((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},wu={description:r("Remove non-printable characters from a piece of text."),args:$s(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Ws(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},yu={description:r("Appends strings to one another."),args:$s(`\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 ea(e,((e,t)=>e+Ws(t)),"")},isExported:!0},xu={description:r("Tests whether two strings are identical."),args:$s(`\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 Ws(e)===Ws(t)},isExported:!0},Ru={description:r("First position of string found in text, case-sensitive."),args:$s(`\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=Ws(e),o=Ws(t),s=Bs(i);Vs((()=>""!==o),r("The text_to_search must be non-empty.")),Vs((()=>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 Vs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n.toString(),o)),a+1},isExported:!0},Iu={description:r("Concatenates elements of arrays with delimiter."),args:$s(`\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=Ws(e);return ea(t,((e,t)=>(e?e+i:"")+Ws(t)),"")}},Tu={description:r("Substring from beginning of specified string."),args:$s(`\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?Bs(t[0]):1;return Vs((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString())),Ws(e).substring(0,i)},isExported:!0},Au={description:r("Length of a string."),args:$s(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Ws(e).length},isExported:!0},Ou={description:r("Converts a specified string to lowercase."),args:$s(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Ws(e).toLowerCase()},isExported:!0},Nu={description:r("A segment of a string."),args:$s(`\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=Ws(e),o=Bs(t),s=Bs(i);return Vs((()=>o>=1),r("The starting_at argument (%s) must be positive greater than one.",o.toString())),Vs((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),n.slice(o-1,o+s-1)},isExported:!0},Mu={description:r("Capitalizes each word in a specified string."),args:$s(`\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 Ws(e).replace(Cu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},_u={description:r("Replaces part of a text string with different text."),args:$s(`\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=Bs(t);Vs((()=>o>=1),r("The position (%s) must be greater than or equal to 1.",o.toString()));const s=Ws(e),a=Bs(i),l=Ws(n);return s.substring(0,o-1)+l+s.substring(o-1+a)},isExported:!0},Fu={description:r("A substring from the end of a specified string."),args:$s(`\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?Bs(t[0]):1;Vs((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString()));const n=Ws(e),o=n.length;return n.substring(o-i,o)},isExported:!0},Du={description:r("First position of string found in text, ignoring case."),args:$s(`\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=Ws(e).toLowerCase(),o=Ws(t).toLowerCase(),s=Bs(i);Vs((()=>""!==o),r("The text_to_search must be non-empty.")),Vs((()=>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 Vs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n,o)),a+1},isExported:!0},ku={description:r("Replaces existing text with new text in a string."),args:$s(`\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=Bs(n);Vs((()=>o>=0),r("The occurrenceNumber (%s) must be positive or null.",o.toString()));const s=Ws(e),a=Ws(t);if(""===a)return s;const l=Ws(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},$u={description:r("Combines text from multiple strings and/or arrays."),args:$s(`\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=Ws(e),o=js(t);let r=0;return ea(i,((e,t)=>o&&""===Ws(t)?e:(r++?e+n:"")+Ws(t)),"")},isExported:!0},Lu={description:r("Removes space characters."),args:$s(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Ws(e).trim()},isExported:!0},Pu={description:r("Converts a specified string to uppercase."),args:$s(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Ws(e).toUpperCase()},isExported:!0},Uu={description:r("Converts a number to text according to a specified format."),args:$s(`\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(Bs(e),Ws(t))},isExported:!0};const Vu={database:Ec,date:eh,financial:xd,info:Dd,lookup:eu,logical:Hd,math:fl,misc:ga,operators:Su,statistical:sc,text:Object.freeze({__proto__:null,CHAR:Eu,CLEAN:wu,CONCATENATE:yu,EXACT:xu,FIND:Ru,JOIN:Iu,LEFT:Tu,LEN:Au,LOWER:Ou,MID:Nu,PROPER:Mu,REPLACE:_u,RIGHT:Fu,SEARCH:Du,SUBSTITUTE:ku,TEXTJOIN:$u,TRIM:Lu,UPPER:Pu,TEXT:Uu}),engineering:ih},zu=/^[A-Z0-9\_\.]+$/;function Bu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Hu(e()):Hu(e)}))}function Hu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Wu=new class extends tn{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(zu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=Ps(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(...Bu(e)),format:n(...e)}},super.add(e,i),this}};for(let e in Vu){const t=Vu[e];for(let i in t){const n=t[i];n.category=e,i=i.replace(/_/g,"."),Wu.add(i,{isExported:!1,...n})}}const Gu=Wu.content,qu=["%"],Zu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(qu);function ju(e){const t=e.split(""),i=[];for(;t.length;){let e=rg(t)||Ku(t)||Ju(t)||tg(t)||Yu(t)||sg(t)||eg(t)||ng(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Yu(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Xu={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Ku(e){if(e[0]in Xu){const t=e.shift();return{type:Xu[t],value:t}}return null}function Qu(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Ju(e){for(let t of Zu)if(Qu(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function eg(e){const t=et(e).match(pi);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function tg(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 ig=/\w|\.|!|\$/;function ng(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(ig);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Gu)return{type:"FUNCTION",value:e};return e.match(Nt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const og=/\s/;function rg(e){let t=0;for(;e[0]&&e[0].match(og);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function sg(e){return Qu(e,X)?(e.splice(0,X.length),{type:"INVALID_REFERENCE",value:X}):null}var ag;!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"}(ag||(ag={}));const lg=(e,t=(()=>!0))=>[{goTo:e,guard:t}],cg=(e,t=(()=>!0))=>({goTo:e,guard:t}),hg={[ag.LeftRef]:{REFERENCE:lg(ag.Separator),NUMBER:lg(ag.FullRowSeparator),SYMBOL:[cg(ag.FullColumnSeparator,(e=>Mt(e.value))),cg(ag.FullRowSeparator,(e=>_t(e.value)))]},[ag.FullColumnSeparator]:{SPACE:lg(ag.FullColumnSeparator),OPERATOR:lg(ag.RightColumnRef,(e=>":"===e.value))},[ag.FullRowSeparator]:{SPACE:lg(ag.FullRowSeparator),OPERATOR:lg(ag.RightRowRef,(e=>":"===e.value))},[ag.Separator]:{SPACE:lg(ag.Separator),OPERATOR:lg(ag.RightRef,(e=>":"===e.value))},[ag.RightRef]:{SPACE:lg(ag.RightRef),NUMBER:lg(ag.Found),REFERENCE:lg(ag.Found,(e=>kt(e.value))),SYMBOL:lg(ag.Found,(e=>Ft(e.value)||Dt(e.value)))},[ag.RightColumnRef]:{SPACE:lg(ag.RightColumnRef),SYMBOL:lg(ag.Found,(e=>Ft(e.value))),REFERENCE:lg(ag.Found,(e=>kt(e.value)))},[ag.RightRowRef]:{SPACE:lg(ag.RightRowRef),NUMBER:lg(ag.Found),REFERENCE:lg(ag.Found,(e=>kt(e.value))),SYMBOL:lg(ag.Found,(e=>Dt(e.value)))},[ag.Found]:{}};function dg(e){var t;let i=0,n=hg[ag.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 ag.Found:return o+=r.value,e.splice(0,i),{type:"REFERENCE",value:o};default:n=hg[a],o+=r.value}}return null}function ug(e){const t=ju(e),i=[];for(;t.length;)i.push(dg(t)||t.shift());return i}const gg=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,pg=["-","+"],mg=["%"],fg=["*","+","&"],vg={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},bg=6;function Sg(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 vg[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function Cg(e,t,i){if("OPERATOR"===t.type){const n=Sg(t);if(mg.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const o=Eg(i,n);return{type:"BIN_OPERATION",value:t.value,left:e,right:o}}}throw new Error(ne)}function Eg(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=Eg(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(Eg(t,bg));"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(Eg(t,bg))}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(gg.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=Eg(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&&pg.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:Eg(t,vg[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(i,e);for(;e[0]&&Sg(e[0])>t;)n=Cg(n,e.shift(),e);return n}function wg(e){return yg(ug(e))}function yg(e){(e=e.filter((e=>"SPACE"!==e.type)))[0]&&"OPERATOR"===e[0].type&&"="===e[0].value&&e.splice(0,1);const t=Eg(e,0);if(e.length)throw new Error(ne);return t}function xg(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>xg(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:xg(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:xg(e.right,t,i),left:xg(e.left,t,i)};default:return e}}function Rg(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>Rg(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?Ig(e)+e.value:e.value+Tg(e);case"BIN_OPERATION":return Ig(e)+e.value+Tg(e)}}function Ig(e){const t=e.value,i="left"in e?e.left:e.operand,n=i.value;return"BIN_OPERATION"===i.type&&vg[n]<vg[t]?`(${Rg(i)})`:Rg(i)}function Tg(e){const t=e.value,i="right"in e?e.right:e.operand,n=vg[i.value],o=vg[t];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:n<o?r=!0:n!==o||fg.includes(t)||(r=!0),r?`(${Rg(i)})`:Rg(i)}const Ag=Wu.content,Og={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Ng={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function Mg(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const _g={};function Fg(e){const t=ug(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(!_g[o]){const s=yg([...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=Mg([`// ${o}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=Ag[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||Og["="]}", ${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=Ng[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=Og[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${Mg(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}_g[o]={execute:h}}return{execute:_g[o].execute,dependencies:i,constantValues:n,tokens:t}}function Dg(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}))}(ug(e))))}function kg(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=$t(e.value),[n,o]=t.split(":"),r=i?`${Ne(i)}!`:"",s=$g(n),a=o?`:${$g(o)}`:"";return{...e,value:r+s+a}}function $g(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=Lg(e,"colrow");break;case"colrow":e=Lg(e,"row");break;case"row":e=Lg(e,"col");break;case"col":e=Lg(e,"none")}return e}function Lg(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 Pg{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)}}Pg.getters=[];class Ug extends Pg{constructor(e,t,i,n,o){super(t,i,n),this.getters=e,this.ui=n,this.selection=o}drawGrid(e,t){}}Ug.layers=[];const Vg=r("The cell you are trying to edit has been deleted.");class zg extends Ug{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:Vg}));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(kg).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:Vg});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:Vg});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("=")?Dg(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)||qu.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))}}zg.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const Bg=Wu.content,Hg=new tn;Hg.add("functions",(()=>Object.keys(Bg).map((e=>({text:e,description:Bg[e].description}))))),En`
983
+ `;class Fs 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":""}`}}Fs.template="o-spreadsheet-ClientTag";const Ds=/(.*?)\((.*?)\)(.*)/,ks=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function $s(e){let t=e.split("\n");const i=[];for(let e of t)e=e.trim(),e&&i.push(Ls(e));return i}function Ls(e){let t,i=e.match(Ds),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=ks.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 Ps(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 Us=["number","string","boolean","undefined"];function Vs(e,t){if(!e())throw new Error(t)}const zs=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Bs(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(zs(e));default:return 0}}function Hs(e){if(""===e)throw new Error(zs(e));return Bs(e)}function Ws(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const Gs=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 qs(e){return"string"==typeof e?Gs(e):e}const Zs=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function js(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(Zs(e))}return!1;case"number":return!!e;default:return!1}}function Ys(e){return Se(Bs(e))}function Xs(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 Ks(e,t){Xs(e,t,t)}function Qs(e,t){Xs(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Hs(e))}))}function Js(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 ea(e,t,i){return Js(e,t,t,i)}function ta(e,t,i){return Js(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,Hs(i))),i)}function ia(e,t,i){return Js(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Bs(i):0):e),((e,i)=>t(e,Bs(i))),i)}function na(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(Zs(e));return js(e)}(e))))}function oa(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=Bs(n):"TRUE"!==n&&"FALSE"!==n||(n=js(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 ra(e="",t){const{operator:i,operand:n}=t;if(void 0===n)return!1;if("number"==typeof n&&"="===i)return"string"==typeof e&&(Ci(e)||Ve(e))?Bs(e)===n:e===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 sa(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=Ws(e[t+1]);a.push(oa(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=ra(e[t][i][o],a[t/2]),!r)break}r&&t(i,o)}}function aa(e,t){return qs(e[0][t])}function la(e,t){return qs(e[t][0])}function ca(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 ha(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&&da(t,c)>=0||da(t,c)>=0&&da(c,a)>0)&&(a=c,l=o):"nextGreater"===i&&(!a&&da(t,c)<=0||da(t,c)<=0&&da(c,a)<0)&&(a=c,l=o)}return r?n-l-1:l}function da(e,t){let i=Us.indexOf(typeof e)-Us.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 ua={description:r("Apply a large number format"),args:$s(`\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(Bs(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 Bs(e)}};var ga=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:ua});const pa={description:r("Absolute value of a number."),args:$s(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Bs(e))},isExported:!0},ma={description:r("Inverse cosine of a value, in radians."),args:$s(`\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=Bs(e);return Vs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},fa={description:r("Inverse hyperbolic cosine of a number."),args:$s(`\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=Bs(e);return Vs((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},va={description:r("Inverse cotangent of a value."),args:$s(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},ba={description:r("Inverse hyperbolic cotangent of a value."),args:$s(`\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=Bs(e);return Vs((()=>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},Sa={description:r("Inverse sine of a value, in radians."),args:$s(`\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=Bs(e);return Vs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ca={description:r("Inverse hyperbolic sine of a number."),args:$s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Bs(e))},isExported:!0},Ea={description:r("Inverse tangent of a value, in radians."),args:$s(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Bs(e))},isExported:!0},wa={description:r("Angle from the X axis to a point (x,y), in radians."),args:$s(`\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=Bs(e),n=Bs(t);return Vs((()=>0!==i||0!==n),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(n,i)},isExported:!0},ya={description:r("Inverse hyperbolic tangent of a number."),args:$s(`\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=Bs(e);return Vs((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},xa={description:r("Rounds number up to nearest multiple of factor."),args:$s(`\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=Bs(e),n=Bs(t);return Vs((()=>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},Ra={description:r("Rounds number up to nearest multiple of factor."),args:$s(`\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=Bs(t);if(0===n)return 0;const o=Bs(e);if(n=Math.abs(n),o>=0)return Math.ceil(o/n)*n;return 0===Bs(i)?-Math.floor(Math.abs(o)/n)*n:-Math.ceil(Math.abs(o)/n)*n},isExported:!0},Ia={description:r("Rounds number up to nearest multiple of factor."),args:$s(`\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 Ra.compute(e,t,0)},isExported:!0},Ta={description:r("Cosine of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Bs(e))},isExported:!0},Aa={description:r("Hyperbolic cosine of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Bs(e))},isExported:!0},Oa={description:r("Cotangent of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Na={description:r("Hyperbolic cotangent of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Ma={description:r("Number of empty values."),args:$s(`\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 ea(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},_a={description:r("A conditional count across a range."),args:$s(`\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 sa(e,((e,i)=>{t+=1})),t},isExported:!0},Fa={description:r("Count values depending on multiple criteria."),args:$s(`\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 sa(e,((e,i)=>{t+=1})),t},isExported:!0};function Da(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const ka={description:r("Counts number of unique values in a range."),args:$s(`\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 ea(e,((e,t)=>Da(t)?e.add(t):e),new Set).size}},$a={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:$s(`\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 sa(t,((t,n)=>{const o=e[t][n];Da(o)&&i.add(o)})),i.size}},La={description:r("Cosecant of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Pa={description:r("Hyperbolic cosecant of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Ua={description:r("Converts from another base to decimal."),args:$s(`\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=Bs(t);i=Math.floor(i),Vs((()=>2<=i&&i<=36),r("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const n=Ws(e);if(""===n)return 0;Vs((()=>!!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 Vs((()=>!isNaN(o)),r("The value (%s) must be a valid base %s representation.",n,i.toString())),o},isExported:!0},Va={description:r("Converts an angle value in radians to degrees."),args:$s(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Bs(e)/Math.PI},isExported:!0},za={description:r("Euler's number, e (~2.718) raised to a power."),args:$s(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Bs(e))},isExported:!0},Ba={description:r("Rounds number down to nearest multiple of factor."),args:$s(`\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=Bs(e),n=Bs(t);return Vs((()=>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},Ha={description:r("Rounds number down to nearest multiple of factor."),args:$s(`\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=Bs(t);if(0===n)return 0;const o=Bs(e);if(n=Math.abs(n),o>=0)return Math.floor(o/n)*n;return 0===Bs(i)?-Math.ceil(Math.abs(o)/n)*n:-Math.floor(Math.abs(o)/n)*n},isExported:!0},Wa={description:r("Rounds number down to nearest multiple of factor."),args:$s(`\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 Ha.compute(e,t,0)},isExported:!0},Ga={description:r("Whether the provided value is even."),args:$s(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Hs(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},qa={description:r("Rounds number up to nearest multiple of factor."),args:$s(`\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 Ra.compute(e,t,0)},isExported:!0},Za={description:r("Whether the provided value is even."),args:$s(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Hs(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},ja={description:r("The logarithm of a number, base e (euler's number)."),args:$s(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Bs(e);return Vs((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ya={description:r("Modulo (remainder) operator."),args:$s(`\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=Bs(t);Vs((()=>0!==i),r("The divisor must be different from 0."));const n=Bs(e)%i;return n>0&&i<0||n<0&&i>0?n+i:n},isExported:!0},Xa={description:r("Rounds a number up to the nearest odd integer."),args:$s(`\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=Bs(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},Ka={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Qa={description:r("A number raised to a power."),args:$s(`\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=Bs(e),n=Bs(t);return Vs((()=>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},Ja={description:r("Result of multiplying a series of numbers together."),args:$s(`\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*=Hs(n),t+=1);return 0===t?0:i},isExported:!0},el={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},tl={description:r("Random integer between two values, inclusive."),args:$s(`\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=Bs(e);Number.isInteger(i)||(i=Math.ceil(i));let n=Bs(t);return Number.isInteger(n)||(n=Math.floor(n)),Vs((()=>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},il={description:r("Rounds a number according to standard rules."),args:$s(`\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=Bs(e);let n=Bs(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},nl={description:r("Rounds down a number."),args:$s(`\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=Bs(e);let n=Bs(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},ol={description:r("Rounds up a number."),args:$s(`\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=Bs(e);let n=Bs(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},rl={description:r("Secant of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Bs(e))},isExported:!0},sl={description:r("Hyperbolic secant of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Bs(e))},isExported:!0},al={description:r("Sine of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Bs(e))},isExported:!0},ll={description:r("Hyperbolic sine of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Bs(e))},isExported:!0},cl={description:r("Positive square root of a positive number."),args:$s(`\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=Bs(e);return Vs((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},hl={description:r("Sum of a series of numbers and/or cells."),args:$s(`\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 ta(e,((e,t)=>e+t),0)},isExported:!0},dl={description:r("A conditional sum across a range."),args:$s(`\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 sa([e,t],((e,t)=>{const o=i[e][t];"number"==typeof o&&(n+=o)})),n},isExported:!0},ul={description:r("Sums a range depending on multiple criteria."),args:$s(`\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 sa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i+=o)})),i},isExported:!0},gl={description:r("Tangent of an angle provided in radians."),args:$s(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Bs(e))},isExported:!0},pl={description:r("Hyperbolic tangent of any real number."),args:$s(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Bs(e))},isExported:!0},ml={description:r("Truncates a number."),args:$s(`\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=Bs(e);let n=Bs(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 fl=Object.freeze({__proto__:null,ABS:pa,ACOS:ma,ACOSH:fa,ACOT:va,ACOTH:ba,ASIN:Sa,ASINH:Ca,ATAN:Ea,ATAN2:wa,ATANH:ya,CEILING:xa,CEILING_MATH:Ra,CEILING_PRECISE:Ia,COS:Ta,COSH:Aa,COT:Oa,COTH:Na,COUNTBLANK:Ma,COUNTIF:_a,COUNTIFS:Fa,COUNTUNIQUE:ka,COUNTUNIQUEIFS:$a,CSC:La,CSCH:Pa,DECIMAL:Ua,DEGREES:Va,EXP:za,FLOOR:Ba,FLOOR_MATH:Ha,FLOOR_PRECISE:Wa,ISEVEN:Ga,ISO_CEILING:qa,ISODD:Za,LN:ja,MOD:Ya,ODD:Xa,PI:Ka,POWER:Qa,PRODUCT:Ja,RAND:el,RANDBETWEEN:tl,ROUND:il,ROUNDDOWN:nl,ROUNDUP:ol,SEC:rl,SECH:sl,SIN:al,SINH:ll,SQRT:cl,SUM:hl,SUMIF:dl,SUMIFS:ul,TAN:gl,TANH:pl,TRUNC:ml});function vl(e,t,i){let n=[],o=[],s=0,a=0;Ks([e],(e=>{n.push(e),s+=1})),Ks([t],(e=>{o.push(e),a+=1})),Vs((()=>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)}Vs((()=>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 bl(e,t,i){let n=0,o=0;const s=i?ia:ta;o=s(e,((e,t)=>(n+=1,e+t)),0),Vs((()=>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 Sl(e,t,i){const n=Bs(t);Vs((()=>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 Ks(e,(e=>{"number"==typeof e&&(o=ca(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(o+1,0,e),a++)})),Vs((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),i||Vs((()=>1/(a+1)<=n&&n<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),yi(s,n,i)}const Cl={description:r("Average magnitude of deviations from mean."),args:$s(`\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=ta(e,((e,i)=>(t+=1,e+i)),0);Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const n=i/t;return ta(e,((e,t)=>e+Math.abs(n-t)),0)/t},isExported:!0},El={description:r("Numerical average value in a dataset, ignoring text."),args:$s(`\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=ta(e,((e,i)=>(t+=1,e+i)),0);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},wl=r("[[FUNCTION_NAME]] has mismatched range sizes."),yl=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),xl={description:r("Weighted average."),args:$s(`\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;Vs((()=>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)){Vs((()=>Array.isArray(i)),wl);let e=t.length,s=t[0].length;Vs((()=>e===i.length&&s===i[0].length),wl);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;Vs((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(Vs((()=>l>=0),yl),n+=s*l,o+=l)}}else i=Bs(i),t=Bs(t),Vs((()=>i>=0),yl),n+=t*i,o+=i;return Vs((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o}},Rl={description:r("Numerical average value in a dataset."),args:$s(`\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=ia(e,((e,i)=>(t+=1,e+i)),0);return Vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Il={description:r("Average of values depending on criteria."),args:$s(`\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 sa([e,t],((t,r)=>{const s=(i||e)[t][r];"number"==typeof s&&(n+=1,o+=s)})),Vs((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n},isExported:!0},Tl={description:r("Average of values depending on multiple criteria."),args:$s(`\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 sa(t,((t,o)=>{const r=e[t][o];"number"==typeof r&&(i+=1,n+=r)})),Vs((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i},isExported:!0},Al={description:r("The number of numeric values in dataset."),args:$s(`\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},Ol={description:r("The number of values in a dataset."),args:$s(`\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 ea(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Nl={description:r("The covariance of a dataset."),args:$s(`\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 vl(e,t,!1)},isExported:!0},Ml={description:r("The covariance of a dataset."),args:$s(`\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 vl(e,t,!1)},isExported:!0},_l={description:r("The sample covariance of a dataset."),args:$s(`\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 vl(e,t,!0)},isExported:!0},Fl={description:r("Nth largest element from a data set."),args:$s(`\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(Bs(t));let n,o=[],s=0;Ks([e],(e=>{"number"==typeof e&&(n=ca(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 Vs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Vs((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Dl={description:r("Maximum value in a numeric dataset."),args:$s(`\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=ta(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},kl={description:r("Maximum numeric value in a dataset."),args:$s(`\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=ia(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},$l={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:$s(`\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 sa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i<o?o:i)})),i===-1/0?0:i},isExported:!0},Ll={description:r("Median value in a numeric dataset."),args:$s(`\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 Qs(e,(e=>{t.push(e)})),Sl(t,.5,!0)},isExported:!0},Pl={description:r("Minimum value in a numeric dataset."),args:$s(`\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=ta(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Ul={description:r("Minimum numeric value in a dataset."),args:$s(`\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=ia(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Vl={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:$s(`\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 sa(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i>o?o:i)})),i===1/0?0:i},isExported:!0},zl={description:r("Value at a given percentile of a dataset."),args:$s(`\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 Hl.compute(e,t)},isExported:!0},Bl={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:$s(`\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 Sl([e],t,!1)},isExported:!0},Hl={description:r("Value at a given percentile of a dataset."),args:$s(`\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 Sl([e],t,!0)},isExported:!0},Wl={description:r("Value nearest to a specific quartile of a dataset."),args:$s(`\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 ql.compute(e,t)},isExported:!0},Gl={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:$s(`\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 Sl([e],.25*Math.trunc(Bs(t)),!1)},isExported:!0},ql={description:r("Value nearest to a specific quartile of a dataset."),args:$s(`\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 Sl([e],.25*Math.trunc(Bs(t)),!0)},isExported:!0},Zl={description:r("Nth smallest element in a data set."),args:$s(`\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(Bs(t));let n,o=[],s=0;Ks([e],(e=>{"number"==typeof e&&(n=ca(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 Vs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Vs((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},jl={description:r("Standard deviation."),args:$s(`\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 entire population."),args:$s(`\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(tc.compute(...e))},isExported:!0},Xl={description:r("Standard deviation."),args:$s(`\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(ic.compute(...e))},isExported:!0},Kl={description:r("Standard deviation of sample (text as 0)."),args:$s(`\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(nc.compute(...e))},isExported:!0},Ql={description:r("Standard deviation of entire population."),args:$s(`\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(oc.compute(...e))},isExported:!0},Jl={description:r("Standard deviation of entire population (text as 0)."),args:$s(`\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(rc.compute(...e))},isExported:!0},ec={description:r("Variance."),args:$s(`\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 bl(e,!0,!1)},isExported:!0},tc={description:r("Variance of entire population."),args:$s(`\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 bl(e,!1,!1)},isExported:!0},ic={description:r("Variance."),args:$s(`\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 bl(e,!0,!1)},isExported:!0},nc={description:r("Variance of sample (text as 0)."),args:$s(`\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 bl(e,!0,!0)},isExported:!0},oc={description:r("Variance of entire population."),args:$s(`\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 bl(e,!1,!1)},isExported:!0},rc={description:r("Variance of entire population (text as 0)."),args:$s(`\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 bl(e,!1,!0)},isExported:!0};var sc=Object.freeze({__proto__:null,AVEDEV:Cl,AVERAGE:El,AVERAGE_WEIGHTED:xl,AVERAGEA:Rl,AVERAGEIF:Il,AVERAGEIFS:Tl,COUNT:Al,COUNTA:Ol,COVAR:Nl,COVARIANCE_P:Ml,COVARIANCE_S:_l,LARGE:Fl,MAX:Dl,MAXA:kl,MAXIFS:$l,MEDIAN:Ll,MIN:Pl,MINA:Ul,MINIFS:Vl,PERCENTILE:zl,PERCENTILE_EXC:Bl,PERCENTILE_INC:Hl,QUARTILE:Wl,QUARTILE_EXC:Gl,QUARTILE_INC:ql,SMALL:Zl,STDEV:jl,STDEV_P:Yl,STDEV_S:Xl,STDEVA:Kl,STDEVP:Ql,STDEVPA:Jl,VAR:ec,VAR_P:tc,VAR_S:ic,VARA:nc,VARP:oc,VARPA:rc});function ac(e,t,i){var n;const o=new Map,s=e.length;for(let t=s-1;t>=0;t--)o.set(Ws(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=Ws(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.",Ws(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=Ws(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}sa(n,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const lc=$s(`\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`),cc={description:r("Average of a set of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return El.compute([n])},isExported:!0},hc={description:r("Counts values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Al.compute([n])},isExported:!0},dc={description:r("Counts values and text from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Ol.compute([n])},isExported:!0},uc={description:r("Single value from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Vs((()=>1===n.length),r("More than one match found in DGET evaluation.")),n[0]},isExported:!0},gc={description:r("Maximum of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Dl.compute([n])},isExported:!0},pc={description:r("Minimum of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Pl.compute([n])},isExported:!0},mc={description:r("Product of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Ja.compute([n])},isExported:!0},fc={description:r("Standard deviation of population sample from table."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return jl.compute([n])},isExported:!0},vc={description:r("Standard deviation of entire population from table."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return Ql.compute([n])},isExported:!0},bc={description:r("Sum of values from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return hl.compute([n])},isExported:!0},Sc={description:r("Variance of population sample from table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return ec.compute([n])},isExported:!0},Cc={description:r("Variance of a population from a table-like range."),args:lc,returns:["NUMBER"],compute:function(e,t,i){const n=ac(e,t,i);return oc.compute([n])},isExported:!0};var Ec=Object.freeze({__proto__:null,DAVERAGE:cc,DCOUNT:hc,DCOUNTA:dc,DGET:uc,DMAX:gc,DMIN:pc,DPRODUCT:mc,DSTDEV:fc,DSTDEVP:vc,DSUM:bc,DVAR:Sc,DVARP:Cc});const wc={description:r("Converts year/month/day into a date."),args:$s(`\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(Bs(e));const o=Math.trunc(Bs(t)),s=Math.trunc(Bs(i));Vs((()=>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 Vs((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},yc={description:r("Converts a date string to a date value."),args:$s(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ws(e),i=ve(t);return Vs((()=>null!==i),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},xc={description:r("Day of the month that a specific date falls on."),args:$s(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getDate()},isExported:!0},Rc={description:r("Number of days between two dates."),args:$s(`\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=Ys(e),n=Ys(t),o=i.getTime()-n.getTime();return Math.round(o/ce)},isExported:!0},Ic={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:$s(`\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=Bs(e),o=Bs(t),r=js(i)?4:0,s=qc.compute(e,t,r);return Math.sign(o-n)*Math.round(360*s)},isExported:!0},Tc={description:r("Date a number of months before/after another date."),args:$s(`\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(Ys(e),Math.trunc(Bs(t)),!1))},isExported:!0},Ac={description:r("Last day of a month before or after a date."),args:$s(`\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=Ys(e),n=Math.trunc(Bs(t)),o=i.getFullYear(),r=i.getMonth();return Ce(new ae(o,r+n+1,0))},isExported:!0},Oc={description:r("Hour component of a specific time."),args:$s(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getHours()},isExported:!0},Nc={description:r("ISO week number of the year."),args:$s(`\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=Ys(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},Mc={description:r("Minute component of a specific time."),args:$s(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getMinutes()},isExported:!0},_c={description:r("Month of the year a specific date falls in"),args:$s(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getMonth()+1},isExported:!0},Fc={description:r("Net working days between two provided days."),args:$s(`\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 kc.compute(e,t,1,i)},isExported:!0};function Dc(e){if("string"==typeof e){Vs((()=>{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 Vs((()=>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 kc={description:r("Net working days between two dates (specifying weekends)."),args:$s(`\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=Ys(e),r=Ys(t),s=Dc(i);let a=new Set;void 0!==n&&Ks([n],(e=>{const t=Ys(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},$c={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},Lc={description:r("Minute component of a specific time."),args:$s(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getSeconds()},isExported:!0},Pc={description:r("Converts hour/minute/second into a time."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t)),s=Math.trunc(Bs(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,Vs((()=>n>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),n/24+o/1440+s/86400},isExported:!0},Uc={description:r("Converts a time string into its serial number representation."),args:$s(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ws(e),i=ve(t);Vs((()=>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},Vc={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},zc={description:r("Day of the week of the date provided (as number)."),args:$s(`\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=Ys(e),n=Math.round(Bs(t)),o=i.getDay();return Vs((()=>[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},Bc={description:r("Week number of the year."),args:$s(`\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=Ys(e),n=Math.round(Bs(t));if(Vs((()=>1===n||2===n||11<=n&&n<=17||21===n),r("The type (%s) is out of range.",n.toString())),21===n)return Nc.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},Hc={description:r("Date after a number of workdays."),args:$s(`\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 Wc.compute(e,t,1,i)},isExported:!0},Wc={description:r("Date after a number of workdays (specifying weekends)."),args:$s(`\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=Ys(e),s=Math.trunc(Bs(t));"string"==typeof i&&Vs((()=>"1111111"!==i),r("The weekend (%s) must be different from '1111111'.",i));const a=Dc(i);let l=new Set;void 0!==n&&Ks([n],(e=>{const t=Ys(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},Gc={description:r("Year specified by a given date."),args:$s(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Ys(e).getFullYear()},isExported:!0},qc={description:r("Exact number of years between two dates."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t));const s=Math.trunc(Bs(i));return Vs((()=>n>=0),r("The start_date (%s) must be positive or null.",n.toString())),Vs((()=>o>=0),r("The end_date (%s) must be positive or null.",o.toString())),Vs((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),Re(n,o,s)}},Zc={description:r("First day of the month preceding a date."),args:$s(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Ys(e),i=t.getFullYear(),n=t.getMonth();return Ce(new ae(i,n,1))}},jc={description:r("Last day of the month following a date."),args:$s(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return Ac.compute(e,0)}},Yc={description:r("Quarter of the year a specific date falls in"),args:$s(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Ys(e).getMonth()+1)/3)}},Xc={description:r("First day of the quarter of the year a specific date falls in."),args:$s(`\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=Yc.compute(e),i=Gc.compute(e);return Ce(new ae(i,3*(t-1),1))}},Kc={description:r("Last day of the quarter of the year a specific date falls in."),args:$s(`\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=Yc.compute(e),i=Gc.compute(e);return Ce(new ae(i,3*t,0))}},Qc={description:r("First day of the year a specific date falls in."),args:$s(`\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=Gc.compute(e);return Ce(new ae(t,0,1))}},Jc={description:r("Last day of the year a specific date falls in."),args:$s(`\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=Gc.compute(e);return Ce(new ae(t+1,0,0))}};var eh=Object.freeze({__proto__:null,DATE:wc,DATEVALUE:yc,DAY:xc,DAYS:Rc,DAYS360:Ic,EDATE:Tc,EOMONTH:Ac,HOUR:Oc,ISOWEEKNUM:Nc,MINUTE:Mc,MONTH:_c,NETWORKDAYS:Fc,NETWORKDAYS_INTL:kc,NOW:$c,SECOND:Lc,TIME:Pc,TIMEVALUE:Uc,TODAY:Vc,WEEKDAY:zc,WEEKNUM:Bc,WORKDAY:Hc,WORKDAY_INTL:Wc,YEAR:Gc,YEARFRAC:qc,MONTH_START:Zc,MONTH_END:jc,QUARTER:Yc,QUARTER_START:Xc,QUARTER_END:Kc,YEAR_START:Qc,YEAR_END:Jc});const th={description:r("Compare two numeric values, returning 1 if they're equal."),args:$s(`\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 Bs(e)===Bs(t)?1:0},isExported:!0};var ih=Object.freeze({__proto__:null,DELTA:th});function nh(e,t){Vs((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function oh(e,t){Vs((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function rh(e){Vs((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function sh(e){Vs((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function ah(e){Vs((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function lh(e){Vs((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function ch(e){Vs((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function hh(e){Vs((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function dh(e){Vs((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function uh(e){Vs((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function gh(e){Vs((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function ph(e){Vs((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function mh(e){Vs((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function fh(e,t){Vs((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function vh(e){Vs((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function bh(e){Vs((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function Sh(e){Vs((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function Ch(e){Vs((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Eh(e,t){const i=Ys(e),n=Ys(t),o=Ys(e);o.setFullYear(i.getFullYear()+1),Vs((()=>n.getTime()<=o.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function wh(e,t,i){ch(i),Vs((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),Vs((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),Vs((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Vs((()=>t<=i),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function yh(e){Vs((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function xh(e,t){Vs((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Rh(e){Vs((()=>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 Ih=$s(`\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 Th(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)?(Vs((()=>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,Vs((()=>g<n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Ah={description:r("Accrued interest of security paying at maturity."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(n),l=Bs(i),c=Math.trunc(Bs(o));oh(s,r),sh(c),ah(a),hh(l);return a*l*qc.compute(r,s,o)},isExported:!0},Oh={description:r("Depreciation for an accounting period."),args:$s(`\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=Bs(e),c=Math.trunc(Bs(t)),h=Math.trunc(Bs(i)),d=Bs(n),u=Bs(o),g=Bs(s),p=Math.trunc(Bs(a));!function(e){Vs((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),ph(d),function(e,t){Vs((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Vs((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),hh(g),sh(p),Vs((()=>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=qc.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},Nh={description:r("Days in coupon period containing settlement date."),args:Ih,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));if(nh(o,r),rh(s),sh(a),1===a){const o=kh.compute(e,t,i,n);return Fh.compute(e,t,i,n)-o}return(3===a?365:360)/s},isExported:!0},Mh={description:r("Days from settlement until next coupon."),args:Ih,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);const l=kh.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=Ys(o),h=Ys(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},_h={description:r("Days from settlement until next coupon."),args:Ih,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);const l=Fh.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=Mh.compute(e,t,i,a);return Nh.compute(e,t,i,a)-c},isExported:!0},Fh={description:r("Next coupon date after the settlement date."),args:Ih,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);const l=12/s,c=Dh.compute(e,t,i,n);return Ce(ye(Ys(r),-(c-1)*l,!0))},isExported:!0},Dh={description:r("Number of coupons between settlement and maturity."),args:Ih,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);let l=1,c=r;const h=12/s;for(;c>o;)c=Ce(ye(Ys(c),-h,!1)),l++;return l-1},isExported:!0},kh={description:r("Last coupon date prior to or on the settlement date."),args:Ih,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Bs(e)),r=Math.trunc(Bs(t)),s=Math.trunc(Bs(i)),a=Math.trunc(Bs(n));nh(o,r),rh(s),sh(a);const l=12/s,c=Dh.compute(e,t,i,n);return Ce(ye(Ys(r),-c*l,!0))},isExported:!0},$h={description:r("Cumulative interest paid over a set of periods."),args:$s(`\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=Bs(n),a=Bs(o),l=Bs(e),c=Bs(i),h=Bs(t);wh(s,a,h),hh(l),mh(c);let d=0;for(let t=s;t<=a;t++){d+=jh.compute(e,t,h,i,0,r)}return d},isExported:!0},Lh={description:r("Cumulative principal paid over a set of periods."),args:$s(`\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=Bs(n),a=Bs(o),l=Bs(e),c=Bs(i),h=Bs(t);wh(s,a,h),hh(l),mh(c);let d=0;for(let t=s;t<=a;t++){d+=od.compute(e,t,h,i,0,r)}return d},isExported:!0},Ph={description:r("Depreciation via declining balance method."),args:$s(`\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=Bs(e),a=Bs(t),l=Bs(i),c=Math.trunc(Bs(n)),h=o.length?Math.trunc(Bs(o[0])):12,d=l+(12===h?0:1);uh(s),ph(a),gh(c),dh(l),Vs((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Vs((()=>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},Uh={description:r("Depreciation via double-declining balance method."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n),c=Bs(o);if(uh(r),ph(s),gh(l),dh(a),fh(l,a),Ch(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},Vh={description:r("Discount rate of a security based on price."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(i),l=Bs(n),c=Math.trunc(Bs(o));nh(r,s),sh(c),lh(a),ah(l);return(l-a)/l/qc.compute(r,s,c)},isExported:!0},zh={description:r("Convert a decimal fraction to decimal value."),args:$s(`\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=Bs(e),n=Math.trunc(Bs(t));Vs((()=>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},Bh={description:r("Convert a decimal value to decimal fraction."),args:$s(`\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=Bs(e),n=Math.trunc(Bs(t));Vs((()=>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},Hh={description:r("Number of periods for an investment to reach a value."),args:$s(`\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(Bs(e)),l=Math.trunc(Bs(t)),c=Bs(i),h=Bs(n),d=Math.trunc(Bs(o)),u=Math.trunc(Bs(s));nh(a,l),rh(d),sh(u),Vs((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),Vs((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=qc.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},Wh={description:r("Annual effective interest rate."),args:$s(`\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=Bs(e),n=Math.trunc(Bs(t));return Vs((()=>i>0),r("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Vs((()=>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},Gh={description:r("Future value of an annuity investment."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n),c=js(o)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},qh={description:r("Future value of principal from series of rates."),args:$s(`\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 ea([t],((e,t)=>e*(1+Bs(t))),Bs(e))},isExported:!0},Zh={description:r("Calculates effective interest rate."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(n),l=Bs(i);nh(r,s),vh(l),ah(a);return(a-l)/l/qc.compute(r,s,o)},isExported:!0},jh={description:r("Payment on the principal of an investment."),args:$s(`\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 nd.compute(e,i,n,o,r)-od.compute(e,t,i,n,o,r)},isExported:!0},Yh={description:r("Internal rate of return given periodic cashflows."),args:$s(`\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=Bs(t);yh(i);let n=!1,o=!1,s=[];Qs([e],(e=>{e>0&&(n=!0),e<0&&(o=!0),s.push(e)})),Vs((()=>n&&o),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return Th((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},Xh={description:r("Returns the interest paid at a particular period of an investment."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n);Vs((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*o},isExported:!0},Kh={description:r("Modified Macaulay duration."),args:$s(`\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 Hh.compute(e,t,i,n,o,r)/(1+Bs(n)/Math.trunc(Bs(o)))},isExported:!0},Qh={description:r("Modified internal rate of return."),args:$s(`\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=Bs(t),o=Bs(i),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Xe).map(Bs);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}Vs((()=>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},Jh={description:r("Annual nominal interest rate."),args:$s(`\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=Bs(e),n=Math.trunc(Bs(t));return Vs((()=>i>0),r("The effective rate (%s) must must strictly greater than 0.",i.toString())),Vs((()=>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},ed={description:r("Number of payment periods for an investment."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n),c=js(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 td={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:$s(`\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=Bs(e);return Vs((()=>-1!==i),r("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let n=0;return ta(i,((t,i)=>(n++,t+i/(1+e)**n)),t)}(i,0,t)},isExported:!0},id={description:r("Computes the number of periods needed for an investment to reach a value."),args:$s(`\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=Bs(e),o=Bs(t),s=Bs(i);return hh(n),Vs((()=>o>0),r("The present_value (%s) must be strictly positive.",o.toString())),Vs((()=>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},nd={description:r("Periodic payment for an annuity investment."),args:$s(`\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=Bs(t),s=Bs(e),a=js(o)?1:0;let l=Bs(n),c=Bs(i);if(ch(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},od={description:r("Payment on the principal of an investment."),args:$s(`\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=Bs(i),l=Bs(e),c=Bs(t),h=js(s)?1:0,d=Bs(o),u=Bs(n);ch(a),Vs((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=nd.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-Gh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},rd={description:r("Present value of an annuity investment."),args:$s(`\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=Bs(e),s=Bs(t),a=Bs(i),l=Bs(n),c=js(o)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},sd={description:r("Price of a security paying periodic interest."),args:$s(`\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(Bs(e)),c=Math.trunc(Bs(t)),h=Bs(i),d=Bs(n),u=Bs(o),g=Math.trunc(Bs(s)),p=Math.trunc(Bs(a));nh(l,c),rh(g),sh(p),Vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Vs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),ah(u);const m=qc.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},ad={description:r("Price of a discount security."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(i),l=Bs(n),c=Math.trunc(Bs(o));nh(r,s),sh(c),bh(a),ah(l);return l-a*l*qc.compute(r,s,c)},isExported:!0},ld={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:$s(`\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(Bs(e)),l=Math.trunc(Bs(t)),c=Math.trunc(Bs(i)),h=Bs(n),d=Bs(o),u=Math.trunc(Bs(s));oh(a,c),nh(a,l),sh(u),Vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Vs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=qc.compute(a,l,u),p=qc.compute(a,c,u);return(100+qc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},cd=.1,hd={description:r("Interest rate of an annuity investment."),args:$s(`\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||cd;const a=Bs(e),l=Bs(t),c=js(o)?1:0,h=Bs(s);let d=Bs(n),u=Bs(i);ch(a),Vs((()=>[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())),yh(h),d-=l*c,u+=l*c;return Th((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},dd={description:r("Amount received at maturity for a security."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(i),l=Bs(n),c=Math.trunc(Bs(o));nh(r,s),sh(c),vh(a),bh(l);return a/(1-l*qc.compute(r,s,c))},isExported:!0},ud={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:$s(`\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=Bs(e),o=Bs(t),r=Bs(i);return ch(n),(r/o)**(1/n)-1},isExported:!0},gd={description:r("Depreciation of an asset using the straight-line method."),args:$s(`\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(Bs(e)-Bs(t))/Bs(i)},isExported:!0},pd={description:r("Depreciation via sum of years digit method."),args:$s(`\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=Bs(e),r=Bs(t),s=Bs(i),a=Bs(n);gh(a),dh(s),fh(a,s);return(s-a+1)/(s*(s+1)/2)*(o-r)},isExported:!0},md={description:r("Price of a US Treasury bill."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t)),r=Bs(i);nh(n,o),Eh(n,o),bh(r),Sh(r);return 100*(1-r*qc.compute(n,o,2))},isExported:!0},fd={description:r("Equivalent rate of return for a US Treasury bill."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t)),r=Bs(i);nh(n,o),Eh(n,o),bh(r),Sh(r);const s=Rc.compute(o,n);if(s<=182)return 365*r/(360-r*s);const a=md.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},vd={description:r("The yield of a US Treasury bill based on price."),args:$s(`\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(Bs(e)),o=Math.trunc(Bs(t)),r=Bs(i);nh(n,o),Eh(n,o),lh(r);return(100-r)/r*(1/qc.compute(n,o,2))},isExported:!0},bd={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:$s(`\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=Bs(e),c=Bs(t),h=Bs(i),d=Math.trunc(Bs(n)),u=Math.trunc(Bs(o)),g=Bs(s),p=js(a);if(uh(l),ph(c),function(e,t,i){dh(i),Vs((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),Vs((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),Vs((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Vs((()=>t<=i),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),Ch(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},Sd={description:r("Internal rate of return given non-periodic cash flows."),args:$s(`\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=Bs(i=i||0),o=e.flat().map(Bs),s=t.flat().map(Bs);var a;xh(e,t),a=o,Vs((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),Rh(s),yh(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 Th((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},Cd={description:r("Net present value given to non-periodic cash flows.."),args:$s(`\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=Bs(e),o=Array.isArray(t)?t.flat().map(Hs):[Hs(t)],s=Array.isArray(i)?i.flat().map(Hs):[Hs(i)];if(Array.isArray(i)&&Array.isArray(t)?xh(t,i):Vs((()=>o.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Rh(s),hh(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},Ed={description:r("Annual yield of a security paying periodic interest."),args:$s(`\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(Bs(e)),c=Math.trunc(Bs(t)),h=Bs(i),d=Bs(n),u=Bs(o),g=Math.trunc(Bs(s)),p=Math.trunc(Bs(a));nh(l,c),rh(g),sh(p),Vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),lh(d),ah(u);const m=qc.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=Th((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},wd={description:r("Annual yield of a discount security."),args:$s(`\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(Bs(e)),s=Math.trunc(Bs(t)),a=Bs(i),l=Bs(n),c=Math.trunc(Bs(o));nh(r,s),sh(c),lh(a),ah(l);return(l/a-1)/qc.compute(e,t,o)},isExported:!0},yd={description:r("Annual yield of a security paying interest at maturity."),args:$s(`\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(Bs(e)),l=Math.trunc(Bs(t)),c=Math.trunc(Bs(i)),h=Bs(n),d=Bs(o),u=Math.trunc(Bs(s));nh(a,l),sh(u),Vs((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),lh(d);const g=qc.compute(c,l,u),p=qc.compute(c,a,u),m=qc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var xd=Object.freeze({__proto__:null,ACCRINTM:Ah,AMORLINC:Oh,COUPDAYS:Nh,COUPDAYBS:Mh,COUPDAYSNC:_h,COUPNCD:Fh,COUPNUM:Dh,COUPPCD:kh,CUMIPMT:$h,CUMPRINC:Lh,DB:Ph,DDB:Uh,DISC:Vh,DOLLARDE:zh,DOLLARFR:Bh,DURATION:Hh,EFFECT:Wh,FV:Gh,FVSCHEDULE:qh,INTRATE:Zh,IPMT:jh,IRR:Yh,ISPMT:Xh,MDURATION:Kh,MIRR:Qh,NOMINAL:Jh,NPER:ed,NPV:td,PDURATION:id,PMT:nd,PPMT:od,PV:rd,PRICE:sd,PRICEDISC:ad,PRICEMAT:ld,RATE:hd,RECEIVED:dd,RRI:ud,SLN:gd,SYD:pd,TBILLPRICE:md,TBILLEQ:fd,TBILLYIELD:vd,VDB:bd,XIRR:Sd,XNPV:Cd,YIELD:Ed,YIELDDISC:wd,YIELDMAT:yd});const Rd={description:r("Whether a value is an error other than #N/A."),args:$s(`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},Id={description:r("Whether a value is an error."),args:$s(`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},Td={description:r("Whether a value is `true` or `false`."),args:$s(`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},Ad={description:r("Whether a value is the error #N/A."),args:$s(`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},Od={description:r("Whether a value is non-textual."),args:$s(`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},Nd={description:r("Whether a value is a number."),args:$s(`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},Md={description:r("Whether a value is text."),args:$s(`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},_d={description:r("Whether the referenced cell is empty"),args:$s(`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},Fd={description:r("Returns the error value #N/A."),args:$s(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Dd=Object.freeze({__proto__:null,ISERR:Rd,ISERROR:Id,ISLOGICAL:Td,ISNA:Ad,ISNONTEXT:Od,ISNUMBER:Nd,ISTEXT:Md,ISBLANK:_d,NA:Fd});const kd={description:r("Logical `and` operator."),args:$s(`\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 na(e,(e=>(t=!0,i=i&&e,i))),Vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},$d={description:r("Returns value depending on logical expression."),args:$s(`\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=js(e)?t():i();return null==n?"":n},isExported:!0},Ld={description:r("Value if it is not an error, otherwise 2nd argument."),args:$s(`\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},Pd={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:$s(`\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},Ud={description:r("Returns a value depending on multiple logical expressions."),args:$s(`\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){Vs((()=>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(js(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(r("No match."))},isExported:!0},Vd={description:r("Returns opposite of provided logical value."),args:$s(`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!js(e)},isExported:!0},zd={description:r("Logical `or` operator."),args:$s(`\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 na(e,(e=>(t=!0,i=i||e,!i))),Vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Bd={description:r("Logical `xor` operator."),args:$s(`\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 na(e,(e=>(t=!0,i=i?!e:e,!0))),Vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Hd=Object.freeze({__proto__:null,AND:kd,IF:$d,IFERROR:Ld,IFNA:Pd,IFS:Ud,NOT:Vd,OR:zd,XOR:Bd});const Wd={description:r("Column number of a specified cell."),args:$s(`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));Vs((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Ni(i).left+1},isExported:!0},Gd={description:r("Number of columns in a specified array or range."),args:$s(`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},qd={description:r("Horizontal lookup"),args:$s(`\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(Bs(i)),s=qs(e);Vs((()=>1<=o&&o<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=js(n);let l;return l=a?ca(t,s,"nextSmaller","asc",t.length,la):ha(t,s,"strict",t.length,la),Vs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),t[l][o-1]},isExported:!0},Zd={description:r("Returns the content of a cell, specified by row and column offset."),args:$s(`\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=Bs(t.value);return null===(n=e[Bs(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=Bs(t),a=Bs(i);return Vs((()=>a>=0&&a-1<n.length&&s>=0&&s-1<n[0].length),r("Index out of range.")),Vs((()=>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},jd={description:r("Look up a value."),args:$s(`\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=qs(e),a=o>=n,l=ca(t,s,"nextSmaller","asc",a?o:n,a?aa:la);return Vs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),void 0===i?a?t[n-1][l]:t[l][o-1]:(n=i.length,o=i[0].length,Vs((()=>1===n||1===o),r("The result_range must be a single row or a single column.")),n>1?(Vs((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Vs((()=>l<=o-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Yd={description:r("Position of item in range that matches value."),args:$s(`\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=Bs(i);const o=qs(e),s=t.length,a=t[0].length;Vs((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?aa:la,h=1===s?t[0].length:t.length;switch(n=Math.sign(n),n){case 1:l=ca(t,o,"nextSmaller","asc",h,c);break;case 0:l=ha(t,o,"strict",h,c);break;case-1:l=ca(t,o,"nextGreater","desc",h,c)}return Vs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),l+1},isExported:!0},Xd={description:r("Row number of a specified cell."),args:$s(`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)),Vs((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Ni(e).top+1},isExported:!0},Kd={description:r("Number of rows in a specified array or range."),args:$s(`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},Qd={description:r("Vertical lookup."),args:$s(`\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(Bs(i)),s=qs(e);Vs((()=>1<=o&&o<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=js(n);let l;return l=a?ca(t,s,"nextSmaller","asc",t[0].length,aa):ha(t,s,"strict",t[0].length,aa),Vs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),t[o-1][l]},isExported:!0},Jd={description:r("Search a range for a match and return the corresponding item from a second range."),args:$s(`\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(Bs(o)),l=Math.trunc(Bs(s)),c=qs(e);Vs((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),Vs((()=>1===i.length||1===i[0].length),r("return_range should be either a single row or single column.")),Vs((()=>i.length===t.length&&i[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),Vs((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),Vs((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?aa:la,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=ca(t,c,u,2===l?"asc":"desc",d,h)}else p=ha(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 Vs((()=>!!m),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ws(e))),m},isExported:!0};var eu=Object.freeze({__proto__:null,COLUMN:Wd,COLUMNS:Gd,HLOOKUP:qd,INDEX:Zd,LOOKUP:jd,MATCH:Yd,ROW:Xd,ROWS:Kd,VLOOKUP:Qd,XLOOKUP:Jd});const tu={description:r("Sum of two numbers."),args:$s(`\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 Bs(e)+Bs(t)}},iu={description:r("Concatenation of two values."),args:$s(`\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 Ws(e)+Ws(t)},isExported:!0},nu={description:r("One number divided by another."),args:$s(`\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=Bs(t);return Vs((()=>0!==i),r("The divisor must be different from zero.")),Bs(e)/i}};function ou(e){return null==e}const ru={number:0,string:"",boolean:!1},su={description:r("Equal."),args:$s(`\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=ou(e)?ru[typeof t]:e,t=ou(t)?ru[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function au(e,t,i){e=ou(e)?ru[typeof t]:e,t=ou(t)?ru[typeof e]:t,"number"!=typeof e&&(e=Ws(e).toUpperCase()),"number"!=typeof t&&(t=Ws(t).toUpperCase());const n=typeof e,o=typeof t;return"string"===n&&"number"===o||("string"!==o||"number"!==n)&&i(e,t)}const lu={description:r("Strictly greater than."),args:$s(`\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 au(e,t,((e,t)=>e>t))}},cu={description:r("Greater than or equal to."),args:$s(`\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 au(e,t,((e,t)=>e>=t))}},hu={description:r("Less than."),args:$s(`\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!cu.compute(e,t)}},du={description:r("Less than or equal to."),args:$s(`\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!lu.compute(e,t)}},uu={description:r("Difference of two numbers."),args:$s(`\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 Bs(e)-Bs(t)}},gu={description:r("Product of two numbers"),args:$s(`\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 Bs(e)*Bs(t)}},pu={description:r("Not equal."),args:$s(`\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!su.compute(e,t)}},mu={description:r("A number raised to a power."),args:$s(`\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 Qa.compute(e,t)}},fu={description:r("A number with the sign reversed."),args:$s(`\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-Bs(e)}},vu={description:r("Value interpreted as a percentage."),args:$s(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Bs(e)/100}},bu={description:r("A specified number, unchanged."),args:$s(`\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 Su=Object.freeze({__proto__:null,ADD:tu,CONCAT:iu,DIVIDE:nu,EQ:su,GT:lu,GTE:cu,LT:hu,LTE:du,MINUS:uu,MULTIPLY:gu,NE:pu,POW:mu,UMINUS:fu,UNARY_PERCENT:vu,UPLUS:bu});const Cu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Eu={description:r("Gets character associated with number."),args:$s(`\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(Bs(e));return Vs((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},wu={description:r("Remove non-printable characters from a piece of text."),args:$s(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Ws(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},yu={description:r("Appends strings to one another."),args:$s(`\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 ea(e,((e,t)=>e+Ws(t)),"")},isExported:!0},xu={description:r("Tests whether two strings are identical."),args:$s(`\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 Ws(e)===Ws(t)},isExported:!0},Ru={description:r("First position of string found in text, case-sensitive."),args:$s(`\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=Ws(e),o=Ws(t),s=Bs(i);Vs((()=>""!==o),r("The text_to_search must be non-empty.")),Vs((()=>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 Vs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n.toString(),o)),a+1},isExported:!0},Iu={description:r("Concatenates elements of arrays with delimiter."),args:$s(`\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=Ws(e);return ea(t,((e,t)=>(e?e+i:"")+Ws(t)),"")}},Tu={description:r("Substring from beginning of specified string."),args:$s(`\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?Bs(t[0]):1;return Vs((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString())),Ws(e).substring(0,i)},isExported:!0},Au={description:r("Length of a string."),args:$s(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Ws(e).length},isExported:!0},Ou={description:r("Converts a specified string to lowercase."),args:$s(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Ws(e).toLowerCase()},isExported:!0},Nu={description:r("A segment of a string."),args:$s(`\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=Ws(e),o=Bs(t),s=Bs(i);return Vs((()=>o>=1),r("The starting_at argument (%s) must be positive greater than one.",o.toString())),Vs((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),n.slice(o-1,o+s-1)},isExported:!0},Mu={description:r("Capitalizes each word in a specified string."),args:$s(`\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 Ws(e).replace(Cu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},_u={description:r("Replaces part of a text string with different text."),args:$s(`\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=Bs(t);Vs((()=>o>=1),r("The position (%s) must be greater than or equal to 1.",o.toString()));const s=Ws(e),a=Bs(i),l=Ws(n);return s.substring(0,o-1)+l+s.substring(o-1+a)},isExported:!0},Fu={description:r("A substring from the end of a specified string."),args:$s(`\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?Bs(t[0]):1;Vs((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString()));const n=Ws(e),o=n.length;return n.substring(o-i,o)},isExported:!0},Du={description:r("First position of string found in text, ignoring case."),args:$s(`\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=Ws(e).toLowerCase(),o=Ws(t).toLowerCase(),s=Bs(i);Vs((()=>""!==o),r("The text_to_search must be non-empty.")),Vs((()=>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 Vs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n,o)),a+1},isExported:!0},ku={description:r("Replaces existing text with new text in a string."),args:$s(`\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=Bs(n);Vs((()=>o>=0),r("The occurrenceNumber (%s) must be positive or null.",o.toString()));const s=Ws(e),a=Ws(t);if(""===a)return s;const l=Ws(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},$u={description:r("Combines text from multiple strings and/or arrays."),args:$s(`\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=Ws(e),o=js(t);let r=0;return ea(i,((e,t)=>o&&""===Ws(t)?e:(r++?e+n:"")+Ws(t)),"")},isExported:!0},Lu={description:r("Removes space characters."),args:$s(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Ws(e).trim()},isExported:!0},Pu={description:r("Converts a specified string to uppercase."),args:$s(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Ws(e).toUpperCase()},isExported:!0},Uu={description:r("Converts a number to text according to a specified format."),args:$s(`\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(Bs(e),Ws(t))},isExported:!0};const Vu={database:Ec,date:eh,financial:xd,info:Dd,lookup:eu,logical:Hd,math:fl,misc:ga,operators:Su,statistical:sc,text:Object.freeze({__proto__:null,CHAR:Eu,CLEAN:wu,CONCATENATE:yu,EXACT:xu,FIND:Ru,JOIN:Iu,LEFT:Tu,LEN:Au,LOWER:Ou,MID:Nu,PROPER:Mu,REPLACE:_u,RIGHT:Fu,SEARCH:Du,SUBSTITUTE:ku,TEXTJOIN:$u,TRIM:Lu,UPPER:Pu,TEXT:Uu}),engineering:ih},zu=/^[A-Z0-9\_\.]+$/;function Bu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Hu(e()):Hu(e)}))}function Hu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Wu=new class extends tn{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(zu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=Ps(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(...Bu(e)),format:n(...e)}},super.add(e,i),this}};for(let e in Vu){const t=Vu[e];for(let i in t){const n=t[i];n.category=e,i=i.replace(/_/g,"."),Wu.add(i,{isExported:!1,...n})}}const Gu=Wu.content,qu=["%"],Zu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(qu);function ju(e){const t=e.split(""),i=[];for(;t.length;){let e=rg(t)||Ku(t)||Ju(t)||tg(t)||Yu(t)||sg(t)||eg(t)||ng(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Yu(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Xu={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Ku(e){if(e[0]in Xu){const t=e.shift();return{type:Xu[t],value:t}}return null}function Qu(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Ju(e){for(let t of Zu)if(Qu(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function eg(e){const t=et(e).match(pi);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function tg(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 ig=/\w|\.|!|\$/;function ng(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(ig);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Gu)return{type:"FUNCTION",value:e};return e.match(Nt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const og=/\s/;function rg(e){let t=0;for(;e[0]&&e[0].match(og);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function sg(e){return Qu(e,X)?(e.splice(0,X.length),{type:"INVALID_REFERENCE",value:X}):null}var ag;!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"}(ag||(ag={}));const lg=(e,t=(()=>!0))=>[{goTo:e,guard:t}],cg=(e,t=(()=>!0))=>({goTo:e,guard:t}),hg={[ag.LeftRef]:{REFERENCE:lg(ag.Separator),NUMBER:lg(ag.FullRowSeparator),SYMBOL:[cg(ag.FullColumnSeparator,(e=>Mt(e.value))),cg(ag.FullRowSeparator,(e=>_t(e.value)))]},[ag.FullColumnSeparator]:{SPACE:lg(ag.FullColumnSeparator),OPERATOR:lg(ag.RightColumnRef,(e=>":"===e.value))},[ag.FullRowSeparator]:{SPACE:lg(ag.FullRowSeparator),OPERATOR:lg(ag.RightRowRef,(e=>":"===e.value))},[ag.Separator]:{SPACE:lg(ag.Separator),OPERATOR:lg(ag.RightRef,(e=>":"===e.value))},[ag.RightRef]:{SPACE:lg(ag.RightRef),NUMBER:lg(ag.Found),REFERENCE:lg(ag.Found,(e=>kt(e.value))),SYMBOL:lg(ag.Found,(e=>Ft(e.value)||Dt(e.value)))},[ag.RightColumnRef]:{SPACE:lg(ag.RightColumnRef),SYMBOL:lg(ag.Found,(e=>Ft(e.value))),REFERENCE:lg(ag.Found,(e=>kt(e.value)))},[ag.RightRowRef]:{SPACE:lg(ag.RightRowRef),NUMBER:lg(ag.Found),REFERENCE:lg(ag.Found,(e=>kt(e.value))),SYMBOL:lg(ag.Found,(e=>Dt(e.value)))},[ag.Found]:{}};function dg(e){var t;let i=0,n=hg[ag.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 ag.Found:return o+=r.value,e.splice(0,i),{type:"REFERENCE",value:o};default:n=hg[a],o+=r.value}}return null}function ug(e){const t=ju(e),i=[];for(;t.length;)i.push(dg(t)||t.shift());return i}const gg=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,pg=["-","+"],mg=["%"],fg=["*","+","&"],vg={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},bg=6;function Sg(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 vg[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function Cg(e,t,i){if("OPERATOR"===t.type){const n=Sg(t);if(mg.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const o=Eg(i,n);return{type:"BIN_OPERATION",value:t.value,left:e,right:o}}}throw new Error(ne)}function Eg(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 l=Eg(t,1e3);return l.debug=!0,l;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(Eg(t,bg));"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(Eg(t,bg))}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":return{type:"REFERENCE",value:a.InvalidReference};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(gg.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 c=Eg(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),c;default:if("OPERATOR"===e.type&&pg.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:Eg(t,vg[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(i,e);for(;e[0]&&Sg(e[0])>t;)n=Cg(n,e.shift(),e);return n}function wg(e){return yg(ug(e))}function yg(e){(e=e.filter((e=>"SPACE"!==e.type)))[0]&&"OPERATOR"===e[0].type&&"="===e[0].value&&e.splice(0,1);const t=Eg(e,0);if(e.length)throw new Error(ne);return t}function xg(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>xg(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:xg(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:xg(e.right,t,i),left:xg(e.left,t,i)};default:return e}}function Rg(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>Rg(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?Ig(e)+e.value:e.value+Tg(e);case"BIN_OPERATION":return Ig(e)+e.value+Tg(e)}}function Ig(e){const t=e.value,i="left"in e?e.left:e.operand,n=i.value;return"BIN_OPERATION"===i.type&&vg[n]<vg[t]?`(${Rg(i)})`:Rg(i)}function Tg(e){const t=e.value,i="right"in e?e.right:e.operand,n=vg[i.value],o=vg[t];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:n<o?r=!0:n!==o||fg.includes(t)||(r=!0),r?`(${Rg(i)})`:Rg(i)}const Ag=Wu.content,Og={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Ng={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function Mg(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const _g={};function Fg(e){const t=ug(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(!_g[o]){const s=yg([...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=Mg([`// ${o}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=Ag[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||Og["="]}", ${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=Ng[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=Og[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${Mg(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}_g[o]={execute:h}}return{execute:_g[o].execute,dependencies:i,constantValues:n,tokens:t}}function Dg(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}))}(ug(e))))}function kg(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=$t(e.value),[n,o]=t.split(":"),r=i?`${Ne(i)}!`:"",s=$g(n),a=o?`:${$g(o)}`:"";return{...e,value:r+s+a}}function $g(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=Lg(e,"colrow");break;case"colrow":e=Lg(e,"row");break;case"row":e=Lg(e,"col");break;case"col":e=Lg(e,"none")}return e}function Lg(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 Pg{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)}}Pg.getters=[];class Ug extends Pg{constructor(e,t,i,n,o){super(t,i,n),this.getters=e,this.ui=n,this.selection=o}drawGrid(e,t){}}Ug.layers=[];const Vg=r("The cell you are trying to edit has been deleted.");class zg extends Ug{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:Vg}));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(kg).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:Vg});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:Vg});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("=")?Dg(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)||qu.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))}}zg.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const Bg=Wu.content,Hg=new tn;Hg.add("functions",(()=>Object.keys(Bg).map((e=>({text:e,description:Bg[e].description}))))),En`
984
984
  .o-autocomplete-dropdown {
985
985
  pointer-events: auto;
986
986
  background-color: #fff;
@@ -2185,12 +2185,12 @@
2185
2185
  <c:f>${e}</c:f>
2186
2186
  <c:numCache />
2187
2187
  </c:numRef>
2188
- `}function Zb(e){const t=e.content,i=Wu.content,n=[];let o=Af``;const r=ju(t).filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported)),s=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(e.value);if(r){return o=Af`
2188
+ `}function Zb(e){const t=e.content,i=Wu.content,n=[];let o=Af``;const r=ju(t).filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported)),s=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(e.value),l=(c=e.value)===a.InvalidReference?"#REF!":c;var c;if(r){return o=Af`
2189
2189
  <f>
2190
2190
  ${Yb(t)}
2191
2191
  </f>
2192
- ${Af`<v>${e.value}</v>`}
2193
- `,n.push(["t",s]),{attrs:n,node:o}}if(""!==e.value)return n.push(["t",s]),o=Af`<v>${e.value}</v>`,{attrs:n,node:o}}function jb(e,t,i=!1){let n=e;const o=[];return!i&&["TRUE","FALSE"].includes(n.trim())?(n="TRUE"===n?"1":"0",o.push(["t","b"])):!i&&Ci(n)||(n=Zm(e,t),o.push(["t","s"])),{attrs:o,node:Af`<v>${n}</v>`}}function Yb(e){let t;"="===e[0]&&(e=e.slice(1));try{t=wg(e)}catch(t){return e}return t=xg(t,"STRING",Xb),t=xg(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),i=e.args,n=tm[t];if(n){const o=Wu.content[t].args.filter((e=>!e.optional)),r=o.length-e.args.length;if(r)for(let t=e.args.length;t<o.length;t++){const e=n[t-r];i.push({type:e.type,value:e.value})}}return{...e,args:i}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:im.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?Rg(t):e}function Xb(e){const t=e.value.replace(new RegExp('"',"g"),""),i=ve(t);if(i){let n=[];return(t.match(ge)||t.match(pe))&&n.push("yyyy-mm-dd"),t.match(me)&&n.push("hh:mm:ss"),{...e,value:Qt(i.value,n.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function Kb(e,t){const i=[];for(const n of t)switch(n.rule.type){case"CellIsRule":i.push(Qb(n,n.rule,e));break;case"ColorScaleRule":i.push(Jb(n,n.rule));break;case"IconSetRule":i.push(eS(n,n.rule));break;default:console.warn(`Conditional formatting ${n.rule.type} not implemented`)}return i}function Qb(e,t,i){const n=tS(e),o=zm(t.operator);n.push(...function(e){const t=zm(e.operator);switch(e.operator){case"ContainsText":case"NotContains":case"BeginsWith":case"EndsWith":return[["type",t],["text",e.values[0]]];case"IsEmpty":case"IsNotEmpty":return[["type",t]];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":case"Between":case"NotBetween":return[["type","cellIs"]]}}(t),["operator",o]);const r=function(e,t){const i=e[0].split(":")[0],n=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${n[0]}",${i})))`];case"NotContains":return[`ISERROR(SEARCH("${n[0]}",${i}))`];case"BeginsWith":return[`LEFT(${i},LEN("${n[0]}"))="${n[0]}"`];case"EndsWith":return[`RIGHT(${i},LEN("${n[0]}"))="${n[0]}"`];case"IsEmpty":return[`LEN(TRIM(${i}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${i}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[n[0]];case"Between":case"NotBetween":return[n[0],n[1]]}}(e.ranges,t).map((e=>Af`<formula>${e}</formula>`)),s={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};return t.style.fillColor&&(s.fill={fgColor:{rgb:t.style.fillColor}}),n.push(["dxfId",Zm(s,i)]),Af`
2192
+ ${Af`<v>${l}</v>`}
2193
+ `,n.push(["t",s]),{attrs:n,node:o}}if(""!==l)return n.push(["t",s]),o=Af`<v>${l}</v>`,{attrs:n,node:o}}function jb(e,t,i=!1){let n=e;const o=[];return!i&&["TRUE","FALSE"].includes(n.trim())?(n="TRUE"===n?"1":"0",o.push(["t","b"])):!i&&Ci(n)||(n=Zm(e,t),o.push(["t","s"])),{attrs:o,node:Af`<v>${n}</v>`}}function Yb(e){let t;"="===e[0]&&(e=e.slice(1));try{t=wg(e)}catch(t){return e}return t=xg(t,"STRING",Xb),t=xg(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),i=e.args,n=tm[t];if(n){const o=Wu.content[t].args.filter((e=>!e.optional)),r=o.length-e.args.length;if(r)for(let t=e.args.length;t<o.length;t++){const e=n[t-r];i.push({type:e.type,value:e.value})}}return{...e,args:i}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:im.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t=xg(t,"REFERENCE",(e=>e.value===a.InvalidReference?{...e,value:"#REF!"}:e)),t?Rg(t):e}function Xb(e){const t=e.value.replace(new RegExp('"',"g"),""),i=ve(t);if(i){let n=[];return(t.match(ge)||t.match(pe))&&n.push("yyyy-mm-dd"),t.match(me)&&n.push("hh:mm:ss"),{...e,value:Qt(i.value,n.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function Kb(e,t){const i=[];for(const n of t)switch(n.rule.type){case"CellIsRule":i.push(Qb(n,n.rule,e));break;case"ColorScaleRule":i.push(Jb(n,n.rule));break;case"IconSetRule":i.push(eS(n,n.rule));break;default:console.warn(`Conditional formatting ${n.rule.type} not implemented`)}return i}function Qb(e,t,i){const n=tS(e),o=zm(t.operator);n.push(...function(e){const t=zm(e.operator);switch(e.operator){case"ContainsText":case"NotContains":case"BeginsWith":case"EndsWith":return[["type",t],["text",e.values[0]]];case"IsEmpty":case"IsNotEmpty":return[["type",t]];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":case"Between":case"NotBetween":return[["type","cellIs"]]}}(t),["operator",o]);const r=function(e,t){const i=e[0].split(":")[0],n=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${n[0]}",${i})))`];case"NotContains":return[`ISERROR(SEARCH("${n[0]}",${i}))`];case"BeginsWith":return[`LEFT(${i},LEN("${n[0]}"))="${n[0]}"`];case"EndsWith":return[`RIGHT(${i},LEN("${n[0]}"))="${n[0]}"`];case"IsEmpty":return[`LEN(TRIM(${i}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${i}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[n[0]];case"Between":case"NotBetween":return[n[0],n[1]]}}(e.ranges,t).map((e=>Af`<formula>${e}</formula>`)),s={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};return t.style.fillColor&&(s.fill={fgColor:{rgb:t.style.fillColor}}),n.push(["dxfId",Zm(s,i)]),Af`
2194
2194
  <conditionalFormatting sqref="${e.ranges.join(" ")}">
2195
2195
  <cfRule ${yf(n)}>
2196
2196
  ${Tf(r)}
@@ -2437,4 +2437,4 @@
2437
2437
  <tableParts count="${e.filterTables.length}">
2438
2438
  ${Tf(a)}
2439
2439
  </tableParts>
2440
- `}var CS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(CS||(CS={}));const ES={},wS={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},yS={autofillModifiersRegistry:sn,autofillRulesRegistry:bn,cellMenuRegistry:Go,colMenuRegistry:qo,linkMenuRegistry:Yn,functionRegistry:Wu,uiPluginRegistry:cb,corePluginRegistry:lb,rowMenuRegistry:Zo,sidePanelRegistry:ws,figureRegistry:to,sheetMenuRegistry:Yo,chartSidePanelComponentRegistry:gs,chartComponentRegistry:on,chartRegistry:nn,topbarMenuRegistry:nr,topbarComponentRegistry:ys,clickableCellRegistry:hb,otRegistry:or,inverseCommandRegistry:io,cellRegistry:Jn,cellPopoverRegistry:Qn},xS={LinkCell:_p},RS={args:$s,toBoolean:js,toJsDate:Ys,toNumber:Bs,toString:Ws,toXC:Vt,toZone:Ni,toCartesian:Ut,numberToLetters:Lt,createFullMenuItem:qn,UuidGenerator:Ai,formatValue:Qt,computeTextWidth:_e,isMarkdownLink:He,parseMarkdownLink:Ge,markdownLink:We,createEmptyWorkbookData:Jf,createEmptySheet:Qf,createEmptyExcelSheet:ev,getDefaultChartJsRuntime:Mr,chartFontColor:wr,getMenuChildren:Nn,ChartColors:Er,EvaluationError:c,CellErrorLevel:l,getFillingMode:Dr,rgbaToHex:Ct,colorToRGBA:Et,positionToZone:Ki,deepEquals:ot},IS={ChartPanel:ps,ChartFigure:As,ChartJsComponent:rn,Grid:Rp,GridOverlay:cp,ScorecardChart:Rs,LineConfigPanel:cs,LineBarPieDesignPanel:rs,BarConfigPanel:lr,LineBarPieConfigPanel:ar,GaugeChartConfigPanel:as,GaugeChartDesignPanel:ls,ScorecardChartConfigPanel:ds,ScorecardChartDesignPanel:us};e.AbstractChart=cr,e.CorePlugin=tv,e.DATETIME_FORMAT=Y,e.DispatchResult=gn,e.EvaluationError=c,e.Model=class extends Gv{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=Xf(e,n);const s=jf(e,r);this.state=new kb,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 Mb(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new _b(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 Db(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of lb.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of cb.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.isLoading=!0,this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this),this.isLoading=!1,this.finalize()}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 eb(Ob(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 Cb;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(){if(!this.isLoading){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=Jf();for(let t of this.handlers)t instanceof tv&&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={...Jf(),sheets:[ev(Zf,"Sheet1")]};for(let t of this.handlers)t instanceof Pg&&t.exportForExcel(e);return e=Ae(e),bS(e)}},e.Registry=tn,e.Revision=Qv,e.SPREADSHEET_DIMENSIONS=wS,e.Spreadsheet=Sb,e.UIPlugin=Ug,e.__info__=ES,e.addFunction=function(e,t){Wu.add(e,t)},e.astToFormula=Rg,e.cellTypes=xS,e.compile=Fg,e.components=IS,e.convertAstNodes=xg,e.coreTypes=dn,e.findCellInNewZone=Yi,e.functionCache=_g,e.helpers=RS,e.invalidateEvaluationCommands=ln,e.load=jf,e.parse=wg,e.readonlyAllowedCommands=hn,e.registries=yS,e.setTranslationMethod=function(e){i=e},e.tokenize=ju,Object.defineProperty(e,"__esModule",{value:!0}),ES.version="16.0.53",ES.date="2024-10-14T07:50:02.583Z",ES.hash="a9ad6d8"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2440
+ `}var CS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(CS||(CS={}));const ES={},wS={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},yS={autofillModifiersRegistry:sn,autofillRulesRegistry:bn,cellMenuRegistry:Go,colMenuRegistry:qo,linkMenuRegistry:Yn,functionRegistry:Wu,uiPluginRegistry:cb,corePluginRegistry:lb,rowMenuRegistry:Zo,sidePanelRegistry:ws,figureRegistry:to,sheetMenuRegistry:Yo,chartSidePanelComponentRegistry:gs,chartComponentRegistry:on,chartRegistry:nn,topbarMenuRegistry:nr,topbarComponentRegistry:ys,clickableCellRegistry:hb,otRegistry:or,inverseCommandRegistry:io,cellRegistry:Jn,cellPopoverRegistry:Qn},xS={LinkCell:_p},RS={args:$s,toBoolean:js,toJsDate:Ys,toNumber:Bs,toString:Ws,toXC:Vt,toZone:Ni,toCartesian:Ut,numberToLetters:Lt,createFullMenuItem:qn,UuidGenerator:Ai,formatValue:Qt,computeTextWidth:_e,isMarkdownLink:He,parseMarkdownLink:Ge,markdownLink:We,createEmptyWorkbookData:Jf,createEmptySheet:Qf,createEmptyExcelSheet:ev,getDefaultChartJsRuntime:Mr,chartFontColor:wr,getMenuChildren:Nn,ChartColors:Er,EvaluationError:c,CellErrorLevel:l,getFillingMode:Dr,rgbaToHex:Ct,colorToRGBA:Et,positionToZone:Ki,deepEquals:ot},IS={ChartPanel:ps,ChartFigure:As,ChartJsComponent:rn,Grid:Rp,GridOverlay:cp,ScorecardChart:Rs,LineConfigPanel:cs,LineBarPieDesignPanel:rs,BarConfigPanel:lr,LineBarPieConfigPanel:ar,GaugeChartConfigPanel:as,GaugeChartDesignPanel:ls,ScorecardChartConfigPanel:ds,ScorecardChartDesignPanel:us};e.AbstractChart=cr,e.CorePlugin=tv,e.DATETIME_FORMAT=Y,e.DispatchResult=gn,e.EvaluationError=c,e.Model=class extends Gv{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=Xf(e,n);const s=jf(e,r);this.state=new kb,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 Mb(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new _b(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 Db(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of lb.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of cb.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.isLoading=!0,this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this),this.isLoading=!1,this.finalize()}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 eb(Ob(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 Cb;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(){if(!this.isLoading){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=Jf();for(let t of this.handlers)t instanceof tv&&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={...Jf(),sheets:[ev(Zf,"Sheet1")]};for(let t of this.handlers)t instanceof Pg&&t.exportForExcel(e);return e=Ae(e),bS(e)}},e.Registry=tn,e.Revision=Qv,e.SPREADSHEET_DIMENSIONS=wS,e.Spreadsheet=Sb,e.UIPlugin=Ug,e.__info__=ES,e.addFunction=function(e,t){Wu.add(e,t)},e.astToFormula=Rg,e.cellTypes=xS,e.compile=Fg,e.components=IS,e.convertAstNodes=xg,e.coreTypes=dn,e.findCellInNewZone=Yi,e.functionCache=_g,e.helpers=RS,e.invalidateEvaluationCommands=ln,e.load=jf,e.parse=wg,e.readonlyAllowedCommands=hn,e.registries=yS,e.setTranslationMethod=function(e){i=e},e.tokenize=ju,Object.defineProperty(e,"__esModule",{value:!0}),ES.version="16.0.55",ES.date="2024-11-13T15:02:56.109Z",ES.hash="6984990"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);