@odoo/o-spreadsheet 15.0.26 → 15.0.28

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.
@@ -1,4 +1,4 @@
1
- !function(e,t){"use strict";function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var i=s(t);let o=e=>e;function n(e,...t){if(1===t.length&&"object"==typeof t[0]){const s=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>s[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const r=function(e,...t){return n(o(e),...t)},a=function(e,...t){return{toString:function(){return n(o(e),...t)}}},l="#f5f5f5",c="#F8F9FA",h="#E8EAED",d="#595959",u="#666666",p="#3266ca",g="#FFFFFF",f=26,m=48,v=63,E=96,S=23,b=15,C=14,I=4,y=200,w=1,T="400",x=10,R="'Roboto', arial",L=["thin","#000"],M="#00f",A=/[ymd:]/,_="#REF",O="START_REVISION",N=a("Invalid expression"),k=/'|\*|\?|\/|\\|\[|\]/,F=void 0,$="|";class D{constructor(e,t,s,i=0,o=0,n=0){this.jsDate=new Date(Date.UTC(e,t,s,i,o,n,0))}static fromTimestamp(e){const t=new Date(e);return new D(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new D(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())}toString(){return this.jsDate.toString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}setDate(e){this.jsDate.setUTCDate(e)}setHours(e){this.jsDate.setUTCHours(e)}setMinutes(e){this.jsDate.setUTCMinutes(e)}setSeconds(e){this.jsDate.setUTCSeconds(e)}}const U=2e3,P=D.now().getFullYear(),B=new D(1899,11,30),V=D.fromTimestamp(0).getTime()-B.getTime(),H=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,z=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Z=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function G(e){let t;const s=(e=e.trim()).match(Z);if(s){if(t=function(e){if(e=e.trim(),Z.test(e)){const t=/AM/i.test(e),s=/PM/i.test(e),i=(t||s?e.substring(0,e.length-2).trim():e).split(/:/),o=i.length>=2,n=3===i.length;let r=Number(i[0]),a=o?Number(i[1]):0,l=n?Number(i[2]):0,c=n?"hh:mm:ss":"hh:mm";if(t||s)c+=" a";else if(!o)return null;r>=12&&t?r-=12:r<12&&s&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new D(1899,11,30,r,a,l)}}return null}(s[0]),null===t)return null;e=e.replace(s[0],"").trim()}let i;const o=e.match(H),n=e.match(z);if(o||n){let t;if(o?(t=o[0],i=W(t,"mdy")):(t=n[0],i=W(t,"ymd")),null===i)return null;e=e.replace(t,"").trim()}return""!==e||!i&&!t?null:i&&t?{value:i.value+t.value,format:i.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new D(i.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,i.jsDate.getMonth()+t.jsDate.getMonth()-11,i.jsDate.getDate()+t.jsDate.getDate()-30,i.jsDate.getHours()+t.jsDate.getHours(),i.jsDate.getMinutes()+t.jsDate.getMinutes(),i.jsDate.getSeconds()+t.jsDate.getSeconds())}:i||t}function W(e,t){const s="mdy"===t;if(s||"ymd"===t){const t=e.split(/\/|-|\s/),i=s?0:1,o=s?1:2,n=s?2:0,r=Number(t[i]),a=Number(t[o]),l=2===t[i].length&&r<10||2===t[o].length&&a<10,c=t[n]?function(e){const t=Number(e);switch(e.length){case 1:return U+t;case 2:return U+(U+t>P+10?-100:0)+t;case 3:case 4:return t}return 0}(t[n]):P,h=new D(c,r-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==r-1||h.getDate()!==a)return null;const u=h.getTime()-B.getTime();let p=l?`mm${d}dd`:`m${d}d`;return t[n]&&(p=s?p+d+"yyyy":"yyyy"+d+p),{value:Math.round(u/864e5),format:p,jsDate:h}}return null}function q(e){const t=Math.trunc(e);let s=D.fromTimestamp(86400*t*1e3-V),i=e-t;i=i<0?1+i:i;const o=Math.round(24*i),n=Math.round(24*(i-o/24)*60),r=Math.round(24*(i-o/24-n/24/60)*60*60);return s.setHours(o),s.setMinutes(n),s.setSeconds(r),s}function j(e){const t=e.format,s=e.jsDate||q(e.value),i=t.indexOf("h");let o="",n="";return i>0?(o=Y(s,t.substring(0,i-1)),n=X(s,t.substring(i))):0===i?n=X(s,t):i<0&&(o=Y(s,t)),o+(o&&n?" ":"")+n}function Y(e,t){const s=t.match(/\/|-|\s/)[0];return t.split(s).map((s=>{switch(s){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(s)}function X(e,t){let s=t.split(/:|\s/);const i=e.getHours(),o="a"===s[s.length-1];let n=i,r="";return o&&(n=0===n?12:n>12?n-12:n,r=i>=12?" PM":" AM",s.pop()),s.map((s=>{switch(s){case"hhhh":return Math.floor((e.getTime()-B.getTime())/36e5).toString();case"hh":return n.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}const K=/(^-?\d+(\.?\d*(e\d+)?)?(\s*%)?|^-?\.\d+(\s*%)?)(?!\w|!)/,Q=/^-?\d+(,\d+)*(\.?\d*(e\d+)?)?(\s*%)?$|^-?\.\d+(\s*%)?$/;function J(e){return Q.test(e.trim())}const ee=/,/g;function te(e){let t=Number(e.replace(ee,""));return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}const se=new Intl.NumberFormat("en-US",{useGrouping:!1,maximumFractionDigits:10});function ie(e){return Number.isInteger(e)?e.toString():se.format(e)}let oe=[];const ne=20;function re(e,t,s=""){if(e<0)return"-"+re(-e,t);const i=t>=ne?ne:t;let o=oe[i];o||(o=new Intl.NumberFormat("en-US",{minimumFractionDigits:i,maximumFractionDigits:i,useGrouping:!1}),oe[i]=o);let n=o.format(e);if(s){let e=n.indexOf(".");n=n.replace(/\d(?=(?:\d{3})+(?:\.|$))/g,((t,i)=>e<0||i<e?`${t}${s}`:t))}return n}function ae(e,t){const s=t.split("."),i=1===s.length?0:s[1].match(/0/g).length,o=s[0].includes(",")?",":"",n=t.includes("%");n&&(e*=100);const r=re(e,i,o);return n?r+"%":r}function le(e,t){if(!e())throw new Error(t)}const ce=e=>a("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function he(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(J(e)||""===e)return te(e);const t=G(e);if(t)return t.value;throw new Error(ce(e));default:return 0}}function de(e){if(""===e)throw new Error(ce(e));return he(e)}function ue(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const pe=e=>a("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function ge(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(pe(e))}return!1;case"number":return!!e;default:return!1}}function fe(e){return q(he(e))}function me(e,t,s){for(let i of e)if(Array.isArray(i)){const e=i.length,s=i[0].length;for(let o=0;o<s;o++)for(let s=0;s<e;s++)t(i[s][o])}else s(i)}function ve(e,t){me(e,t,t)}function Ee(e,t){me(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(de(e))}))}function Se(e,t,s,i){let o=i;for(let i of e)if(Array.isArray(i)){const e=i.length,s=i[0].length;for(let n=0;n<s;n++)for(let s=0;s<e;s++)o=t(o,i[s][n])}else o=s(o,i);return o}function be(e,t,s){return Se(e,t,t,s)}function Ce(e,t,s){return Se(e,((e,s)=>"number"==typeof s?t(e,s):e),((e,s)=>t(e,de(s))),s)}function Ie(e,t,s){return Se(e,((e,s)=>null!=s?t(e,"number"==typeof s?s:"boolean"==typeof s?he(s):0):e),((e,s)=>t(e,he(s))),s)}function ye(e,t){return function(e,t,s){for(let i of e)if(Array.isArray(i)){const e=i.length,s=i[0].length;for(let o=0;o<s;o++)for(let s=0;s<e;s++)if(!t(i[s][o]))return}else if(!s(i))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(pe(e));return ge(e)}(e))))}function we(e,t){let s,i,o=e.substring(0,2);"<="===o||">="===o||"<>"===o?(s=o,i=e.substring(2)):(o=e.substring(0,1),"<"===o||">"===o||"="===o?(s=o,i=e.substring(1)):(s="=",i=e)),J(i)?i=he(i):"TRUE"!==i&&"FALSE"!==i||(i=ge(i));const n={operator:s,operand:i};return"string"==typeof i&&(t&&(i+="*"),n.regexp=function(e){if("*"===e)return/.+/;let t="",s="";for(let i of e)"?"===i&&"~"!==s?t+=".":"*"===i&&"~"!==s?t+=".*":("*"!==i&&"?"!==i||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(i)&&(t+="\\"),t+=i),s=i;return new RegExp("^"+t+"$","i")}(i)),n}function Te(e="",t){const{operator:s,operand:i}=t;if(void 0===i)return!1;if("number"==typeof i&&"="===s)return ue(e)===ue(i);if("<>"===s||"="===s){let o;return o=typeof e==typeof i&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===i),"="===s?o:!o}if(typeof e==typeof i)switch(s){case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i}return!1}function xe(e,t,s=!1){const i=e.length;if(i%2==1)throw new Error(a("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const o=e[0].length,n=e[0][0].length;let r=[];for(let t=0;t<i-1;t+=2){const i=e[t];if(!Array.isArray(i)||i.length!==o||i[0].length!==n)throw new Error(a("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=ue(e[t+1]);r.push(we(l,s))}for(let s=0;s<o;s++)for(let o=0;o<n;o++){let n=!0;for(let t=0;t<i-1;t+=2){if(n=Te(e[t][s][o],r[t/2]),!n)break}n&&t(s,o)}}function Re(e,t){if(void 0===t)return-1;const s=typeof t;let i,o,n,r,a,l,c=0,h=e.length-1;if(typeof e[c]===s&&t<e[c])return-1;if(typeof e[h]===s&&e[h]<=t)return h;for(;h-c>=0;){for(n=Math.ceil((c+h)/2),r=n,a=e[r],l=typeof a;c<=r&&s!==l;)r--,a=e[r],l=typeof a;l===s&&a<=t&&(void 0===i||i<a||i===a&&o<r)&&(i=a,o=r),l===s&&a>t?h=r-1:c=n+1}return void 0!==o?o:-1}class Le{constructor(){this.content={}}add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}remove(e){delete this.content[e]}}const Me=/(.*?)\((.*?)\)(.*)/,Ae=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function _e(e){let t=e.split("\n");const s=[];for(let e of t)e=e.trim(),e&&s.push(Oe(e));return s}function Oe(e){let t,s=e.match(Me),i=s[1].trim(),o=[],n=!1,r=!1,a=!1;for(let e of s[2].split(",")){const s=e.trim().toUpperCase();let i=Ae.find((e=>s===e));i?o.push(i):"RANGE<ANY>"===s?o.push("RANGE"):"OPTIONAL"===s?n=!0:"REPEATING"===s?r=!0:"LAZY"===s?a=!0:s.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:i,description:s[3].trim(),type:o};return n&&(l.optional=!0),r&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function Ne(e){let t=0,s=0,i=0;for(let o of e.args)t++,o.optional||o.repeating||o.default||s++,o.repeating&&i++;const o=e;return o.minArgRequired=s,o.maxArgPossible=i?1/0:t,o.nbrArgRepeating=i,o.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const s=e-t;return e=>{if(e<=s)return e;return s+((e-s)%t||t)}}(t,i),o}var ke;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(ke||(ke={}));const Fe=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),$e=new Set(["START","ACTIVATE_SHEET","COPY","START_SELECTION","SET_SELECTION","ALTER_SELECTION","START_SELECTION_EXPANSION","PREPARE_SELECTION_EXPANSION","STOP_SELECTION","RESIZE_VIEWPORT","SET_VIEWPORT_OFFSET","SELECT_ALL","SELECT_CELL","SELECT_COLUMN","SELECT_ROW","MOVE_POSITION","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY"]),De=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART"]);function Ue(e){return De.has(e.type)}class Pe{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return Be}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const Be=new Pe;var Ve,He,ze,Ze;e.CommandResult=void 0,(Ve=e.CommandResult||(e.CommandResult={}))[Ve.Success=0]="Success",Ve[Ve.CancelledForUnknownReason=1]="CancelledForUnknownReason",Ve[Ve.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",Ve[Ve.MergeIsDestructive=3]="MergeIsDestructive",Ve[Ve.CellIsMerged=4]="CellIsMerged",Ve[Ve.InvalidTarget=5]="InvalidTarget",Ve[Ve.EmptyUndoStack=6]="EmptyUndoStack",Ve[Ve.EmptyRedoStack=7]="EmptyRedoStack",Ve[Ve.NotEnoughElements=8]="NotEnoughElements",Ve[Ve.NotEnoughSheets=9]="NotEnoughSheets",Ve[Ve.MissingSheetName=10]="MissingSheetName",Ve[Ve.DuplicatedSheetName=11]="DuplicatedSheetName",Ve[Ve.DuplicatedSheetId=12]="DuplicatedSheetId",Ve[Ve.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",Ve[Ve.WrongSheetMove=14]="WrongSheetMove",Ve[Ve.WrongSheetPosition=15]="WrongSheetPosition",Ve[Ve.InvalidAnchorZone=16]="InvalidAnchorZone",Ve[Ve.SelectionOutOfBound=17]="SelectionOutOfBound",Ve[Ve.TargetOutOfSheet=18]="TargetOutOfSheet",Ve[Ve.WrongPasteSelection=19]="WrongPasteSelection",Ve[Ve.EmptyClipboard=20]="EmptyClipboard",Ve[Ve.EmptyRange=21]="EmptyRange",Ve[Ve.InvalidRange=22]="InvalidRange",Ve[Ve.InvalidSheetId=23]="InvalidSheetId",Ve[Ve.InputAlreadyFocused=24]="InputAlreadyFocused",Ve[Ve.MaximumRangesReached=25]="MaximumRangesReached",Ve[Ve.InvalidChartDefinition=26]="InvalidChartDefinition",Ve[Ve.EmptyDataSet=27]="EmptyDataSet",Ve[Ve.InvalidDataSet=28]="InvalidDataSet",Ve[Ve.InvalidLabelRange=29]="InvalidLabelRange",Ve[Ve.InvalidAutofillSelection=30]="InvalidAutofillSelection",Ve[Ve.WrongComposerSelection=31]="WrongComposerSelection",Ve[Ve.MinBiggerThanMax=32]="MinBiggerThanMax",Ve[Ve.LowerBiggerThanUpper=33]="LowerBiggerThanUpper",Ve[Ve.MidBiggerThanMax=34]="MidBiggerThanMax",Ve[Ve.MinBiggerThanMid=35]="MinBiggerThanMid",Ve[Ve.FirstArgMissing=36]="FirstArgMissing",Ve[Ve.SecondArgMissing=37]="SecondArgMissing",Ve[Ve.MinNaN=38]="MinNaN",Ve[Ve.MidNaN=39]="MidNaN",Ve[Ve.MaxNaN=40]="MaxNaN",Ve[Ve.ValueUpperInflectionNaN=41]="ValueUpperInflectionNaN",Ve[Ve.ValueLowerInflectionNaN=42]="ValueLowerInflectionNaN",Ve[Ve.MinInvalidFormula=43]="MinInvalidFormula",Ve[Ve.MidInvalidFormula=44]="MidInvalidFormula",Ve[Ve.MaxInvalidFormula=45]="MaxInvalidFormula",Ve[Ve.ValueUpperInvalidFormula=46]="ValueUpperInvalidFormula",Ve[Ve.ValueLowerInvalidFormula=47]="ValueLowerInvalidFormula",Ve[Ve.InvalidSortZone=48]="InvalidSortZone",Ve[Ve.WaitingSessionConfirmation=49]="WaitingSessionConfirmation",Ve[Ve.MergeOverlap=50]="MergeOverlap",Ve[Ve.TooManyHiddenElements=51]="TooManyHiddenElements",Ve[Ve.Readonly=52]="Readonly",Ve[Ve.InvalidOffset=53]="InvalidOffset",Ve[Ve.InvalidViewportSize=54]="InvalidViewportSize",Ve[Ve.FigureDoesNotExist=55]="FigureDoesNotExist",Ve[Ve.DuplicatedFigureId=56]="DuplicatedFigureId",Ve[Ve.DuplicatedChartId=57]="DuplicatedChartId",Ve[Ve.ChartDoesNotExist=58]="ChartDoesNotExist",function(e){e.FormatFromArgument="FormatFromArgument"}(He||(He={})),function(e){e[e.UP=0]="UP",e[e.DOWN=1]="DOWN",e[e.LEFT=2]="LEFT",e[e.RIGHT=3]="RIGHT"}(ze||(ze={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Selection=5]="Selection",e[e.Autofill=6]="Autofill",e[e.Headers=7]="Headers"}(Ze||(Ze={}));const Ge={description:a("Absolute value of a number."),args:_e(`\n value (number) ${a("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(he(e))},isExported:!0},We={description:a("Inverse cosine of a value, in radians."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>Math.abs(t)<=1),a("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},qe={description:a("Inverse hyperbolic cosine of a number."),args:_e(`\n value (number) ${a("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=he(e);return le((()=>t>=1),a("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},je={description:a("Inverse cotangent of a value."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Ye={description:a("Inverse hyperbolic cotangent of a value."),args:_e(`\n value (number) ${a("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=he(e);return le((()=>Math.abs(t)>1),a("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Xe={description:a("Inverse sine of a value, in radians."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>Math.abs(t)<=1),a("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ke={description:a("Inverse hyperbolic sine of a number."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(he(e))},isExported:!0},Qe={description:a("Inverse tangent of a value, in radians."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(he(e))},isExported:!0},Je={description:a("Angle from the X axis to a point (x,y), in radians."),args:_e(`\n x (number) ${a("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${a("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 s=he(e),i=he(t);return le((()=>0!==s||0!==i),a("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(i,s)},isExported:!0},et={description:a("Inverse hyperbolic tangent of a number."),args:_e(`\n value (number) ${a("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=he(e);return le((()=>Math.abs(t)<1),a("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},tt={description:a("Rounds number up to nearest multiple of factor."),args:_e(`\n value (number) ${a("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${a("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=1){const s=he(e),i=he(t);return le((()=>i>=0||s<=0),a("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),s.toString())),i?Math.ceil(s/i)*i:0},isExported:!0},st={description:a("Rounds number up to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${a("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"],returnFormat:He.FormatFromArgument,compute:function(e,t=1,s=0){let i=he(t);if(0===i)return 0;const o=he(e);if(i=Math.abs(i),o>=0)return Math.ceil(o/i)*i;return 0===he(s)?-Math.floor(Math.abs(o)/i)*i:-Math.ceil(Math.abs(o)/i)*i},isExported:!0},it={description:a("Rounds number up to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return st.compute(e,t,0)},isExported:!0},ot={description:a("Cosine of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(he(e))},isExported:!0},nt={description:a("Hyperbolic cosine of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(he(e))},isExported:!0},rt={description:a("Cotangent of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},at={description:a("Hyperbolic cotangent of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},lt={description:a("Number of empty values."),args:_e(`\n value1 (any, range) ${a("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${a("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return be(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},ct={description:a("A conditional count across a range."),args:_e(`\n range (range) ${a("The range that is tested against criterion.")}\n criterion (string) ${a("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return xe(e,((e,s)=>{t+=1})),t},isExported:!0},ht={description:a("Count values depending on multiple criteria."),args:_e(`\n criteria_range1 (range) ${a("The range to check against criterion1.")}\n criterion1 (string) ${a("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${a("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) ${a("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return xe(e,((e,s)=>{t+=1})),t},isExported:!0};function dt(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const ut={description:a("Counts number of unique values in a range."),args:_e(`\n value1 (any, range) ${a("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${a("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return be(e,((e,t)=>dt(t)?e.add(t):e),new Set).size}},pt={description:a("Counts number of unique values in a range, filtered by a set of criteria."),args:_e(`\n range (range) ${a("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${a("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${a("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) ${a("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) ${a("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=new Set;return xe(t,((t,i)=>{const o=e[t][i];dt(o)&&s.add(o)})),s.size}},gt={description:a("Cosecant of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},ft={description:a("Hyperbolic cosecant of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},mt={description:a("Converts from another base to decimal."),args:_e(`\n value (string) ${a("The number to convert.")},\n base (number) ${a("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let s=he(t);s=Math.floor(s),le((()=>2<=s&&s<=36),a("The base (%s) must be between 2 and 36 inclusive.",s.toString()));const i=ue(e);if(""===i)return 0;le((()=>!!i.match(/^-?[a-z0-9]+$/i)),a("The value (%s) must be a valid base %s representation.",i,s.toString()));const o=parseInt(i,s);return le((()=>!isNaN(o)),a("The value (%s) must be a valid base %s representation.",i,s.toString())),o},isExported:!0},vt={description:a("Converts an angle value in radians to degrees."),args:_e(`\n angle (number) ${a("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*he(e)/Math.PI},isExported:!0},Et={description:a("Euler's number, e (~2.718) raised to a power."),args:_e(`\n value (number) ${a("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(he(e))},isExported:!0},St={description:a("Rounds number down to nearest multiple of factor."),args:_e(`\n value (number) ${a("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${a("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=1){const s=he(e),i=he(t);return le((()=>i>=0||s<=0),a("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),s.toString())),i?Math.floor(s/i)*i:0},isExported:!0},bt={description:a("Rounds number down to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${a("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"],returnFormat:He.FormatFromArgument,compute:function(e,t=1,s=0){let i=he(t);if(0===i)return 0;const o=he(e);if(i=Math.abs(i),o>=0)return Math.floor(o/i)*i;return 0===he(s)?-Math.ceil(Math.abs(o)/i)*i:-Math.floor(Math.abs(o)/i)*i},isExported:!0},Ct={description:a("Rounds number down to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=1){return bt.compute(e,t,0)},isExported:!0},It={description:a("Whether the provided value is even."),args:_e(`\n value (number) ${a("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=de(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},yt={description:a("Rounds number up to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=1){return st.compute(e,t,0)},isExported:!0},wt={description:a("Whether the provided value is even."),args:_e(`\n value (number) ${a("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=de(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Tt={description:a("The logarithm of a number, base e (euler's number)."),args:_e(`\n value (number) ${a("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>t>0),a("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},xt={description:a("Modulo (remainder) operator."),args:_e(`\n dividend (number) ${a("The number to be divided to find the remainder.")}\n divisor (number) ${a("The number to divide by.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=he(t);le((()=>0!==s),a("The divisor must be different from 0."));const i=he(e)%s;return i>0&&s<0||i<0&&s>0?i+s:i},isExported:!0},Rt={description:a("Rounds a number up to the nearest odd integer."),args:_e(`\n value (number) ${a("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e){const t=he(e);let s=Math.ceil(Math.abs(t));return s=1&s?s:s+1,t<0?-s:s},isExported:!0},Lt={description:a("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Mt={description:a("A number raised to a power."),args:_e(`\n base (number) ${a("The number to raise to the exponent power.")}\n exponent (number) ${a("The exponent to raise base to.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=he(e),i=he(t);return le((()=>s>=0||Number.isInteger(i)),a("The exponent (%s) must be an integer when the base is negative.",i.toString())),Math.pow(s,i)},isExported:!0},At={description:a("Result of multiplying a series of numbers together."),args:_e(`\n factor1 (number, range<number>) ${a("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${a("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t=0,s=1;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(s*=i,t+=1);else null!=i&&(s*=de(i),t+=1);return 0===t?0:s},isExported:!0},_t={description:a("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ot={description:a("Random integer between two values, inclusive."),args:_e(`\n low (number) ${a("The low end of the random range.")}\n high (number) ${a("The high end of the random range.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){let s=he(e);Number.isInteger(s)||(s=Math.ceil(s));let i=he(t);return Number.isInteger(i)||(i=Math.floor(i)),le((()=>s<=i),a("The high (%s) must be greater than or equal to the low (%s).",i.toString(),s.toString())),s+Math.ceil((i-s+1)*Math.random())-1},isExported:!0},Nt={description:a("Rounds a number according to standard rules."),args:_e(`\n value (number) ${a("The value to round to places number of places.")}\n places (number, default=0) ${a("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=0){const s=he(e);let i=he(t);const o=Math.abs(s);let n;return 0===i?n=Math.round(o):(Number.isInteger(i)||(i=Math.trunc(i)),n=Math.round(o*Math.pow(10,i))/Math.pow(10,i)),s>=0?n:-n},isExported:!0},kt={description:a("Rounds down a number."),args:_e(`\n value (number) ${a("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${a("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=0){const s=he(e);let i=he(t);const o=Math.abs(s);let n;return 0===i?n=Math.floor(o):(Number.isInteger(i)||(i=Math.trunc(i)),n=Math.floor(o*Math.pow(10,i))/Math.pow(10,i)),s>=0?n:-n},isExported:!0},Ft={description:a("Rounds up a number."),args:_e(`\n value (number) ${a("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${a("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=0){const s=he(e);let i=he(t);const o=Math.abs(s);let n;return 0===i?n=Math.ceil(o):(Number.isInteger(i)||(i=Math.trunc(i)),n=Math.ceil(o*Math.pow(10,i))/Math.pow(10,i)),s>=0?n:-n},isExported:!0},$t={description:a("Secant of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(he(e))},isExported:!0},Dt={description:a("Hyperbolic secant of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(he(e))},isExported:!0},Ut={description:a("Sine of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(he(e))},isExported:!0},Pt={description:a("Hyperbolic sine of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(he(e))},isExported:!0},Bt={description:a("Positive square root of a positive number."),args:_e(`\n value (number) ${a("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e){const t=he(e);return le((()=>t>=0),a("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},Vt={description:a("Sum of a series of numbers and/or cells."),args:_e(`\n value1 (number, range<number>) ${a("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${a("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){return Ce(e,((e,t)=>e+t),0)},isExported:!0},Ht={description:a("A conditional sum across a range."),args:_e(`\n criteria_range (range) ${a("The range which is tested against criterion.")}\n criterion (string) ${a("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${a("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,s){void 0===s&&(s=e);let i=0;return xe([e,t],((e,t)=>{const o=s[e][t];"number"==typeof o&&(i+=o)})),i},isExported:!0},zt={description:a("Sums a range depending on multiple criteria."),args:_e(`\n sum_range (range) ${a("The range to sum.")}\n criteria_range1 (range) ${a("The range to check against criterion1.")}\n criterion1 (string) ${a("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${a("Additional ranges to check.")}\n criterion2 (string, repeating) ${a("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=0;return xe(t,((t,i)=>{const o=e[t][i];"number"==typeof o&&(s+=o)})),s},isExported:!0},Zt={description:a("Tangent of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(he(e))},isExported:!0},Gt={description:a("Hyperbolic tangent of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(he(e))},isExported:!0},Wt={description:a("Truncates a number."),args:_e(`\n value (number) ${a("The value to be truncated.")}\n places (number, default=0) ${a("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=0){const s=he(e);let i=he(t);return 0===i?Math.trunc(s):(Number.isInteger(i)||(i=Math.trunc(i)),Math.trunc(s*Math.pow(10,i))/Math.pow(10,i))},isExported:!0};var qt=Object.freeze({__proto__:null,ABS:Ge,ACOS:We,ACOSH:qe,ACOT:je,ACOTH:Ye,ASIN:Xe,ASINH:Ke,ATAN:Qe,ATAN2:Je,ATANH:et,CEILING:tt,CEILING_MATH:st,CEILING_PRECISE:it,COS:ot,COSH:nt,COT:rt,COTH:at,COUNTBLANK:lt,COUNTIF:ct,COUNTIFS:ht,COUNTUNIQUE:ut,COUNTUNIQUEIFS:pt,CSC:gt,CSCH:ft,DECIMAL:mt,DEGREES:vt,EXP:Et,FLOOR:St,FLOOR_MATH:bt,FLOOR_PRECISE:Ct,ISEVEN:It,ISO_CEILING:yt,ISODD:wt,LN:Tt,MOD:xt,ODD:Rt,PI:Lt,POWER:Mt,PRODUCT:At,RAND:_t,RANDBETWEEN:Ot,ROUND:Nt,ROUNDDOWN:kt,ROUNDUP:Ft,SEC:$t,SECH:Dt,SIN:Ut,SINH:Pt,SQRT:Bt,SUM:Vt,SUMIF:Ht,SUMIFS:zt,TAN:Zt,TANH:Gt,TRUNC:Wt});const jt=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function Yt(e){return e.toString(16).padStart(6,"0")}let Xt=0;function Kt(){return Xt=++Xt%jt.length,jt[Xt]}function Qt(e){return e.includes("rgb")?function(e){return e.slice(4,-1).split(",").map((e=>parseInt(e,10).toString(16).padStart(2,"0"))).join("").toUpperCase()}(e):(3===(e=e.replace("#","").toUpperCase()).length&&(e=e.split("").reduce(((e,t)=>e+t+t),"")),e)}const Jt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),es=new RegExp(/^\s*(.*!)?\$?[A-Z]{1,3}\$?[0-9]{1,7}\s*(\s*:\s*\$?[A-Z]{1,3}\$?[0-9]{1,7}\s*)?$/,"i");function ts(e){const t=e.split("!"),s=t.pop();return{sheetName:t.join("!")||void 0,xc:s}}function ss(e){return e<26?String.fromCharCode(65+e):ss(Math.floor(e/26)-1)+ss(e%26)}function is(e){e=e.toUpperCase().trim();const[t,s,i]=e.match(Jt);if(t!==e)throw new Error(`Invalid cell description: ${e}`);const o=function(e){let t=0;const s=e.length;for(let i=0;i<s;i++)t+=(e.charCodeAt(i)-65+(i<s-1?1:0))*26**(s-i-1);return t}(s);return[o,parseInt(i,10)-1]}function os(e,t,s={colFixed:!1,rowFixed:!1}){return(s.colFixed?"$":"")+ss(e)+(s.rowFixed?"$":"")+String(t+1)}const ns=140,rs=20,as=.035;function ls(e){return rs+(ns-rs)*Math.exp(-as*(e-1))}const cs=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48}],hs={};for(let e of cs)hs[e.pt]=e.px;function ds(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function us(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(!(function(e){return"object"==typeof e&&(null==e?void 0:e.constructor)===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const s in e)t[s]=us(e[s]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function ps(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function gs(e,t,s){return e<t?t:e>s?s:e}function fs(e,t,s){const i=s.italic?"italic ":"",o=s.bold?"bold":T,n=s.fontSize||x,r=hs[n];return e.font=`${i}${o} ${r}px ${R}`,e.measureText(t).width}function ms(e,t,s=1){if(t<=e&&s>0)return[];if(0===s)throw new Error("range() step must not be zero");const i=Math.ceil(Math.abs((t-e)/s)),o=Array(i);for(let t=0;t<i;t++)o[t]=e+t*s;return o}function vs(e){return e.reduce(((e,t,s,i)=>{if(1===Math.abs(t-i[s-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Es(e,t){t.next();for(const s of e){const e=t.next();yield{...s,next:e.done?void 0:e.value}}}function Ss(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}function bs(e){return null!==G(e)}const Cs=/^\[(.+)\]\((.+)\)$/,Is=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function ys(e){return Cs.test(e)}function ws(e,t){return`[${e}](${t})`}function Ts(e){const t=e.match(Cs)||[],s=t[1],i=t[2];if(!s||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:s,url:i}}const xs="o-spreadsheet://";function Rs(e){if(!ys(e))return!1;const{url:t}=Ts(e);return t.startsWith(xs)}function Ls(e){if(e.startsWith(xs))return e.substr(xs.length);throw new Error(`${e} is not a valid sheet link`)}function Ms(e){return void 0!==e}const As={};function _s(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return!1;const s=new Set;Object.keys(e).forEach((e=>s.add(e))),Object.keys(t).forEach((e=>s.add(e)));for(let i of s){if(typeof e[i]!=typeof e[i])return!1;if("object"==typeof e[i]){if(!_s(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function Os(e){let t=e.length;if(t<1e5)return Math.max(...e);let s=-1/0;for(;t--;)s=e[t]>s?e[t]:s;return s}function Ns(e){let t=e.length;if(t<1e5)return Math.min(...e);let s=1/0;for(;t--;)s=e[t]<s?e[t]:s;return s}function ks(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":");let s,i,o,n,r=is(t[0].trim());if(o=n=r[0],s=i=r[1],2===t.length){let e=is(t[1].trim());n=e[0],i=e[1]}return{top:s,bottom:i,left:o,right:n}}function Fs(e){let{top:t,bottom:s,left:i,right:o}=ks(e);return o<i&&([o,i]=[i,o]),s<t&&([s,t]=[t,s]),{top:t,bottom:s,left:i,right:o}}function $s(e){return!(isNaN(e.bottom)||isNaN(e.top)||isNaN(e.left)||isNaN(e.right))&&(!(e.top<0||e.left<0||e.right<0||e.bottom<0)&&(e.bottom>=e.top&&e.right>=e.left))}function Ds(e){const{top:t,bottom:s,left:i,right:o}=e;return t===s&&i===o?os(i,t):`${os(i,t)}:${os(o,s)}`}function Us(e,t,s,i,o){const n="left"===t?"columns":"rows",r="before"===i?s-1:s,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?Xs(e,n,"RESIZE",o):r<e[t]?Xs(e,n,"MOVE",o):{...e}}function Ps(e,t,s){const i="left"===t?"right":"bottom";let o=e[t],n=e[i];for(let r of s.sort(((e,t)=>t-e)))e[t]>r&&(o--,n--),e[t]<r&&e[i]>=r&&n--;return{...e,[t]:o,[i]:n}}function Bs(e,t){return{top:Math.min(e.top,t.top),left:Math.min(e.left,t.left),bottom:Math.max(e.bottom,t.bottom),right:Math.max(e.right,t.right)}}function Vs(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Hs(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function zs(e,t,s){const{left:i,right:o,top:n,bottom:r}=s;return e>=i&&e<=o&&t>=n&&t<=r}function Zs(e,t){const s={};for(let t of e)if(t){const e=Fs(t);for(let t=e.left;t<=e.right;t++)void 0===s[t]&&(s[t]=[]),s[t].push({top:e.top,bottom:e.bottom,remove:!1})}for(let e of t){const t=Fs(e);for(let e=t.left;e<=t.right;e++)void 0===s[e]&&(s[e]=[]),s[e].push({top:t.top,bottom:t.bottom,remove:!0})}const i=[];for(let[e,t]of Object.entries(s))i.push({col:parseInt(e),ranges:Gs(t)});return function(e){const t=e.sort(((e,t)=>e.col-t.col)),s=[];let i=[],o=0;for(let e=0;e<=t.length-1;e++){let n=[];if(o+1===t[e].col)for(let s of t[e].ranges){let o=!1;for(let e of i)s.top==e.top&&s.bottom==e.bottom&&(n.push(e),o=!0);o||n.push({top:s.top,bottom:s.bottom,startCol:t[e].col})}else n=t[e].ranges.map((s=>({top:s.top,bottom:s.bottom,startCol:t[e].col})));const r=i.filter((e=>!n.includes(e)));for(let e of r)s.push({top:e.top,bottom:e.bottom,left:e.startCol,right:o});o=t[e].col,i=n}for(let e of i)s.push({top:e.top,bottom:e.bottom,left:e.startCol,right:o});return s}(i).map(Ds)}function Gs(e){const t=new Set,s=new Set;for(let i of e)for(let e=i.top;e<=i.bottom;e++)i.remove?s.add(e):t.add(e);const i=[...t].filter((e=>!s.has(e))).sort(((e,t)=>e-t)),o=[];let n;for(let e of i)n?e===n.bottom+1?n.bottom=e:(o.push({top:n.top,bottom:n.bottom}),n={top:e,bottom:e}):n={top:e,bottom:e};return n&&o.push({top:n.top,bottom:n.bottom}),o}function Ws(e,t,s,i,o=1,n=1){var r;const{top:a,bottom:l,left:c,right:h}=e,d=new Array(Math.floor((h-c+1)/o));for(let e=c;e<=h;e+=o){let o=new Array(Math.floor((l-a+1)/n));d[e-c]=o;for(let c=a;c<=l;c+=n){let l=null===(r=t.rows[c])||void 0===r?void 0:r.cells[e];o[(c-a)/n]=l?s(l):i}}return d}function qs(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function js(e){const{width:t,height:s}=qs(e);return 1===t||1===s}function Ys(e){const t=[],[s,i]=[e.right,e.left].sort(((e,t)=>e-t)),[o,n]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ms(s,i+1))for(const s of ms(o,n+1))t.push([e,s]);return t}function Xs(e,t,s,i){const o="columns"===t?"right":"bottom",n={...e};return"MOVE"===s&&(n["columns"===t?"left":"top"]+=i),n[o]+=i,n}function Ks(e){return e.reverse().filter(((e,t,s)=>t===s.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}function Qs(e){return{top:Math.min(e.top,e.bottom),bottom:Math.max(e.top,e.bottom),left:Math.min(e.left,e.right),right:Math.max(e.left,e.right)}}function Js(e){const t=[];let s=0;for(let i=0;i<e;i++){const e={start:s,end:s+E,size:E,name:ss(i)};t.push(e),s=e.end}return t}function ei(e){const t=[];let s=0;for(let i=0;i<e;i++){const e={start:s,end:s+S,size:S,name:String(i+1),cells:{}};t.push(e),s=e.end}return t}function ti(e,t){var s;const i=[];let o=0;for(let n=0;n<t;n++){const t=e[n]&&e[n].size||E,r=(null===(s=e[n])||void 0===s?void 0:s.isHidden)||!1,a={start:o,end:r?o:o+t,size:t,name:ss(n)};r&&(a.isHidden=r),i.push(a),o=a.end}return i}function si(e,t){var s;const i=[];let o=0;for(let n=0;n<t;n++){const t=e[n]&&e[n].size||S,r=(null===(s=e[n])||void 0===s?void 0:s.isHidden)||!1,a={start:o,end:r?o:o+t,size:t,name:String(n+1),cells:{}};r&&(a.isHidden=r),i.push(a),o=a.end}return i}function ii(e,t=!1){const s={};for(let i in e){const o=e[i];(o.size!==E||t)&&(s[i]={size:o.size}),o.isHidden&&(s[i]=s[i]||{},s[i].isHidden=o.isHidden)}return s}function oi(e,t=!1){const s={};for(let i in e){const o=e[i];(o.size!==S||t)&&(s[i]={size:o.size}),o.isHidden&&(s[i]=s[i]||{},s[i].isHidden=o.isHidden)}return s}class ni{constructor(e=!1){this.isFastIdStrategy=!1,this.fastIdStart=0,this.setIsFastStrategy(e)}setIsFastStrategy(e){this.isFastIdStrategy=e}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto&&window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))):"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}}function ri(e,t,s){return[ai(e,"cols",ms(t,e.cols.length)),ai(e,"rows",ms(s,e.rows.length))]}function ai(e,t,s){const i=e[t];return s.find((e=>!i[e].isHidden))}function li(e,t){let s=e[t].length-1;for(;s>=0&&!0===e[t][s].isHidden;)s--;return e[t][s]}function ci(e,t,s){let i=[],o=[],n=0,r=0;ve([e],(e=>{i.push(e),n+=1})),ve([t],(e=>{o.push(e),r+=1})),le((()=>n===r),a("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",n.toString(),r.toString()));let l=0,c=0,h=0;for(let e=0;e<n;e++){const t=i[e],s=o[e];"number"==typeof t&&"number"==typeof s&&(l+=1,c+=t,h+=s)}le((()=>0!==l&&(!s||1!==l)),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let p=0;for(let e=0;e<n;e++){const t=i[e],s=o[e];"number"==typeof t&&"number"==typeof s&&(p+=(t-d)*(s-u))}return p/(l-(s?1:0))}function hi(e,t,s){let i=0,o=0;const n=s?Ie:Ce;o=n(e,((e,t)=>(i+=1,e+t)),0),le((()=>0!==i&&(!t||1!==i)),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const r=o/i;return n(e,((e,t)=>e+Math.pow(t-r,2)),0)/(i-(t?1:0))}function di(e,t,s){const i=he(t);le((()=>s?0<=i&&i<=1:0<i&&i<1),a("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let o,n=[],r=0;ve(e,(e=>{"number"==typeof e&&(o=Re(n,e),n.splice(o+1,0,e),r++)})),le((()=>0!==r),a("[[FUNCTION_NAME]] has no valid input data."));let l=(r+(s?-1:1))*i;if(s||(le((()=>1<=l&&l<=r),a("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),l--),Number.isInteger(l))return n[l];const c=Math.ceil(l),h=Math.floor(l);return n[c]*(l-h)+n[h]*(c-l)}const ui={description:a("Average magnitude of deviations from mean."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const s=Ce(e,((e,s)=>(t+=1,e+s)),0);le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const i=s/t;return Ce(e,((e,t)=>e+Math.abs(i-t)),0)/t},isExported:!0},pi={description:a("Numerical average value in a dataset, ignoring text."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t=0;const s=Ce(e,((e,s)=>(t+=1,e+s)),0);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),s/t},isExported:!0},gi=a("[[FUNCTION_NAME]] has mismatched range sizes."),fi=a("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),mi={description:a("Weighted average."),args:_e(`\n values (number, range<number>) ${a("Values to average.")}\n weights (number, range<number>) ${a("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${a("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${a("Additional weights.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t,s,i=0,o=0;le((()=>e.length%2==0),a("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let n=0;n<e.length-1;n+=2)if(t=e[n],s=e[n+1],Array.isArray(t)){le((()=>Array.isArray(s)),gi);let e=t.length,n=t[0].length;le((()=>e===s.length&&n===s[0].length),gi);for(let r=0;r<e;r++)for(let e=0;e<n;e++){let n=t[r][e],l=s[r][e],c="number"==typeof n,h="number"==typeof l;le((()=>c===h),a("[[FUNCTION_NAME]] expects number values.")),h&&(le((()=>l>=0),fi),i+=n*l,o+=l)}}else s=he(s),t=he(t),le((()=>s>=0),fi),i+=t*s,o+=s;return le((()=>0!==o),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/o}},vi={description:a("Numerical average value in a dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t=0;const s=Ie(e,((e,s)=>(t+=1,e+s)),0);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),s/t},isExported:!0},Ei={description:a("Average of values depending on criteria."),args:_e(`\n criteria_range (range) ${a("The range to check against criterion.")}\n criterion (string) ${a("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${a("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,s){null==s&&(s=e);let i=0,o=0;return xe([e,t],((t,n)=>{const r=(s||e)[t][n];"number"==typeof r&&(i+=1,o+=r)})),le((()=>0!==i),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},Si={description:a("Average of values depending on multiple criteria."),args:_e(`\n average_range (range) ${a("The range to average.")}\n criteria_range1 (range) ${a("The range to check against criterion1.")}\n criterion1 (string) ${a("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${a("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${a("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=0,i=0;return xe(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(s+=1,i+=n)})),le((()=>0!==s),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/s},isExported:!0},bi={description:a("The number of numeric values in dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let s of e)if(Array.isArray(s))for(let e of s)for(let s of e)"number"==typeof s&&(t+=1);else("string"!=typeof s||J(s)||G(s))&&(t+=1);return t},isExported:!0},Ci={description:a("The number of values in a dataset."),args:_e(`\n value1 (any, range) ${a("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${a("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return be(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Ii={description:a("The covariance of a dataset."),args:_e(`\n data_y (any, range) ${a("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${a("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ci(e,t,!1)},isExported:!0},yi={description:a("The covariance of a dataset."),args:_e(`\n data_y (any, range) ${a("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${a("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ci(e,t,!1)},isExported:!0},wi={description:a("The sample covariance of a dataset."),args:_e(`\n data_y (any, range) ${a("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${a("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ci(e,t,!0)},isExported:!0},Ti={description:a("Nth largest element from a data set."),args:_e(`\n data (any, range) ${a("Array or range containing the dataset to consider.")}\n n (number) ${a("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=Math.trunc(he(t));let i,o=[],n=0;ve([e],(e=>{"number"==typeof e&&(i=Re(o,e),o.splice(i+1,0,e),n++,n>s&&(o.shift(),n--))}));const r=o.shift();return le((()=>void 0!==r),a("[[FUNCTION_NAME]] has no valid input data.")),le((()=>n>=s),a("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",s.toString())),r},isExported:!0},xi={description:a("Maximum value in a numeric dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){const t=Ce(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Ri={description:a("Maximum numeric value in a dataset."),args:_e(`\n value1 (any, range) ${a("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${a("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){const t=Ie(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Li={description:a("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:_e(`\n range (range) ${a("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${a("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${a("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) ${a("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) ${a("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=-1/0;return xe(t,((t,i)=>{const o=e[t][i];"number"==typeof o&&(s=s<o?o:s)})),s===-1/0?0:s},isExported:!0},Mi={description:a("Median value in a numeric dataset."),args:_e(`\n value1 (any, range) ${a("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${a("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t=[];return Ee(e,(e=>{t.push(e)})),di(t,.5,!0)},isExported:!0},Ai={description:a("Minimum value in a numeric dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){const t=Ce(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},_i={description:a("Minimum numeric value in a dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){const t=Ie(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Oi={description:a("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:_e(`\n range (range) ${a("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${a("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${a("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) ${a("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) ${a("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=1/0;return xe(t,((t,i)=>{const o=e[t][i];"number"==typeof o&&(s=s>o?o:s)})),s===1/0?0:s},isExported:!0},Ni={description:a("Value at a given percentile of a dataset."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n percentile (number) ${a("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return Fi.compute(e,t)},isExported:!0},ki={description:a("Value at a given percentile of a dataset exclusive of 0 and 1."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n percentile (number) ${a("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return di([e],t,!1)},isExported:!0},Fi={description:a("Value at a given percentile of a dataset."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n percentile (number) ${a("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return di([e],t,!0)},isExported:!0},$i={description:a("Value nearest to a specific quartile of a dataset."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n quartile_number (number) ${a("Which quartile value to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return Ui.compute(e,t)},isExported:!0},Di={description:a("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n quartile_number (number) ${a("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return di([e],.25*Math.trunc(he(t)),!1)},isExported:!0},Ui={description:a("Value nearest to a specific quartile of a dataset."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n quartile_number (number) ${a("Which quartile value to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return di([e],.25*Math.trunc(he(t)),!0)},isExported:!0},Pi={description:a("Nth smallest element in a data set."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n n (number) ${a("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=Math.trunc(he(t));let i,o=[],n=0;ve([e],(e=>{"number"==typeof e&&(i=Re(o,e),o.splice(i+1,0,e),n++,n>s&&(o.pop(),n--))}));const r=o.pop();return le((()=>void 0!==r),a("[[FUNCTION_NAME]] has no valid input data.")),le((()=>n>=s),a("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",s.toString())),r},isExported:!0},Bi={description:a("Standard deviation."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Wi.compute(...e))},isExported:!0},Vi={description:a("Standard deviation of entire population."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(qi.compute(...e))},isExported:!0},Hi={description:a("Standard deviation."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(ji.compute(...e))},isExported:!0},zi={description:a("Standard deviation of sample (text as 0)."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Yi.compute(...e))},isExported:!0},Zi={description:a("Standard deviation of entire population."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Xi.compute(...e))},isExported:!0},Gi={description:a("Standard deviation of entire population (text as 0)."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ki.compute(...e))},isExported:!0},Wi={description:a("Variance."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!0,!1)},isExported:!0},qi={description:a("Variance of entire population."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!1,!1)},isExported:!0},ji={description:a("Variance."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!0,!1)},isExported:!0},Yi={description:a("Variance of sample (text as 0)."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!0,!0)},isExported:!0},Xi={description:a("Variance of entire population."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!1,!1)},isExported:!0},Ki={description:a("Variance of entire population (text as 0)."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!1,!0)},isExported:!0};var Qi=Object.freeze({__proto__:null,AVEDEV:ui,AVERAGE:pi,AVERAGE_WEIGHTED:mi,AVERAGEA:vi,AVERAGEIF:Ei,AVERAGEIFS:Si,COUNT:bi,COUNTA:Ci,COVAR:Ii,COVARIANCE_P:yi,COVARIANCE_S:wi,LARGE:Ti,MAX:xi,MAXA:Ri,MAXIFS:Li,MEDIAN:Mi,MIN:Ai,MINA:_i,MINIFS:Oi,PERCENTILE:Ni,PERCENTILE_EXC:ki,PERCENTILE_INC:Fi,QUARTILE:$i,QUARTILE_EXC:Di,QUARTILE_INC:Ui,SMALL:Pi,STDEV:Bi,STDEV_P:Vi,STDEV_S:Hi,STDEVA:zi,STDEVP:Zi,STDEVPA:Gi,VAR:Wi,VAR_P:qi,VAR_S:ji,VARA:Yi,VARP:Xi,VARPA:Ki});function Ji(e,t,s){var i;const o=new Map,n=e.length;for(let t=n-1;t>=0;t--)o.set(ue(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(a("The field must be a number or a string"));let r;if("number"==typeof t){if(r=Math.trunc(t)-1,r<0||n-1<r)throw new Error(a("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),n.toString()))}else{const e=ue(t).toUpperCase();if(r=null!==(i=o.get(e))&&void 0!==i?i:-1,-1===r)throw new Error(a("The field (%s) must be one of %s.",ue(t),[...o.keys()].toString()))}const l=s[0].length;if(l<2)throw new Error(a("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 i=[],n=!0;for(let r=0;r<s.length;r++){const a=ue(s[r][0]).toUpperCase(),l=o.get(a),c=s[r][t];if(void 0!==c){if(void 0===l){n=!1;break}i.push([e[l].slice(1,h)]),i.push(c)}}if(n){if(!(i.length>0)){c=new Set(Array(h-1).keys());break}xe(i,((e,t)=>{c.add(t)}),!0)}}const d=e[r];return[...c].map((e=>d[e+1]))}const eo=_e(`\n database (range) ${a("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) ${a("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${a("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),to={description:a("Average of a set of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return pi.compute([i])},isExported:!0},so={description:a("Counts values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return bi.compute([i])},isExported:!0},io={description:a("Counts values and text from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Ci.compute([i])},isExported:!0},oo={description:a("Single value from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return le((()=>1===i.length),a("More than one match found in DGET evaluation.")),i[0]},isExported:!0},no={description:a("Maximum of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return xi.compute([i])},isExported:!0},ro={description:a("Minimum of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Ai.compute([i])},isExported:!0},ao={description:a("Product of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return At.compute([i])},isExported:!0},lo={description:a("Standard deviation of population sample from table."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Bi.compute([i])},isExported:!0},co={description:a("Standard deviation of entire population from table."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Zi.compute([i])},isExported:!0},ho={description:a("Sum of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Vt.compute([i])},isExported:!0},uo={description:a("Variance of population sample from table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Wi.compute([i])},isExported:!0},po={description:a("Variance of a population from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Xi.compute([i])},isExported:!0};var go=Object.freeze({__proto__:null,DAVERAGE:to,DCOUNT:so,DCOUNTA:io,DGET:oo,DMAX:no,DMIN:ro,DPRODUCT:ao,DSTDEV:lo,DSTDEVP:co,DSUM:ho,DVAR:uo,DVARP:po});const fo=new D(1899,11,30);function mo(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}const vo={description:a("Converts year/month/day into a date."),args:_e(`\n year (number) ${a("The year component of the date.")}\n month (number) ${a("The month component of the date.")}\n day (number) ${a("The day component of the date.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t,s){let i=Math.trunc(he(e));const o=Math.trunc(he(t)),n=Math.trunc(he(s));le((()=>0<=i&&i<=9999),a("The year (%s) must be between 0 and 9999 inclusive.",i.toString())),i<1900&&(i+=1900);const r=new D(i,o-1,n).getTime()-fo.getTime();return le((()=>r>=0),a("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),Math.round(r/864e5)},isExported:!0},Eo={description:a("Converts a date string to a date value."),args:_e(`\n date_string (string) ${a("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=ue(e),s=G(t);return le((()=>null!==s),a("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(s.value)},isExported:!0},So={description:a("Day of the month that a specific date falls on."),args:_e(`\n date (string) ${a("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getDate()},isExported:!0},bo={description:a("Number of days between two dates."),args:_e(`\n end_date (date) ${a("The end of the date range.")}\n start_date (date) ${a("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const s=fe(e),i=fe(t),o=s.getTime()-i.getTime();return Math.round(o/864e5)},isExported:!0},Co={description:a("Date a number of months before/after another date."),args:_e(`\n start_date (date) ${a("The date from which to calculate the result.")}\n months (number) ${a("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t){const s=fe(e),i=Math.trunc(he(t)),o=s.getFullYear(),n=s.getMonth(),r=s.getDate(),a=new D(o,n+i,r).getTime()-fo.getTime();return Math.round(a/864e5)},isExported:!0},Io={description:a("Last day of a month before or after a date."),args:_e(`\n start_date (date) ${a("The date from which to calculate the result.")}\n months (number) ${a("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t){const s=fe(e),i=Math.trunc(he(t)),o=s.getFullYear(),n=s.getMonth(),r=new D(o,n+i+1,0).getTime()-fo.getTime();return Math.round(r/864e5)},isExported:!0},yo={description:a("Hour component of a specific time."),args:_e(`\n time (date) ${a("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getHours()},isExported:!0},wo={description:a("ISO week number of the year."),args:_e(`\n date (date) ${a("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=fe(e),s=t.getFullYear();let i=1;for(;4!==new D(s,0,i).getDay();)i+=1;const o=new D(s,0,i-3);let n=31;for(;4!==new D(s,11,n).getDay();)n-=1;const r=new D(s,11,n+3);let a,l;switch(a=o.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=o;break;case 1:l=new D(s,11,n+3+1);break;case-1:let e=1;for(;4!==new D(s-1,0,e).getDay();)e+=1;l=new D(s-1,0,e-3)}const c=(t.getTime()-l.getTime())/864e5;return Math.floor(c/7)+1},isExported:!0},To={description:a("Minute component of a specific time."),args:_e(`\n time (date) ${a("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getMinutes()},isExported:!0},xo={description:a("Month of the year a specific date falls in"),args:_e(`\n date (date) ${a("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getMonth()+1},isExported:!0},Ro={description:a("Net working days between two provided days."),args:_e(`\n start_date (date) ${a("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${a("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${a("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,s){return Mo.compute(e,t,1,s)},isExported:!0};function Lo(e){if("string"==typeof e){le((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),a('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let s=0;s<7;s++)"1"===e[s]&&t.push((s+1)%7);return t}if("number"==typeof e)return le((()=>1<=e&&e<=7||11<=e&&e<=17),a("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(a("The weekend (%s) must be a number or a string.",e.toString()))}const Mo={description:a("Net working days between two dates (specifying weekends)."),args:_e(`\n start_date (date) ${a("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${a("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${a("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${a("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,s=1,i){const o=fe(e),n=fe(t),r=Lo(s);let a=new Set;void 0!==i&&ve([i],(e=>{const t=fe(e);a.add(t.getTime())}));const l=o.getTime()>n.getTime(),c=D.fromTimestamp((l?o:n).getTime());let h=D.fromTimestamp((l?n:o).getTime());const d=c.getTime();let u=h.getTime(),p=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(p+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-p:p},isExported:!0},Ao={description:a("Current date and time as a date value."),args:[],returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy hh:mm:ss"},compute:function(){let e=D.now();const t=e.getTime()-fo.getTime(),s=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/864e5)+s},isExported:!0},_o={description:a("Minute component of a specific time."),args:_e(`\n time (date) ${a("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getSeconds()},isExported:!0},Oo={description:a("Converts hour/minute/second into a time."),args:_e(`\n hour (number) ${a("The hour component of the time.")}\n minute (number) ${a("The minute component of the time.")}\n second (number) ${a("The second component of the time.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"hh:mm:ss a"},compute:function(e,t,s){let i=Math.trunc(he(e)),o=Math.trunc(he(t)),n=Math.trunc(he(s));return o+=Math.floor(n/60),n=n%60+(n<0?60:0),i+=Math.floor(o/60),o=o%60+(o<0?60:0),i%=24,le((()=>i>=0),a("The function [[FUNCTION_NAME]] result cannot be negative")),i/24+o/1440+n/86400},isExported:!0},No={description:a("Converts a time string into its serial number representation."),args:_e(`\n time_string (string) ${a("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=ue(e),s=G(t);le((()=>null!==s),a("The time_string (%s) cannot be parsed to date/time.",t));const i=s.value-Math.trunc(s.value);return i<0?1+i:i},isExported:!0},ko={description:a("Current date as a date value."),args:[],returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(){const e=D.now(),t=new D(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-fo.getTime();return Math.round(t/864e5)},isExported:!0},Fo={description:a("Day of the week of the date provided (as number)."),args:_e(`\n date (date) ${a("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) ${a("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 s=fe(e),i=Math.round(he(t)),o=s.getDay();return le((()=>[1,2,3].includes(i)),a("The type (%s) must be 1, 2 or 3.",i.toString())),1===i?o+1:2===i?0===o?7:o:0===o?6:o-1},isExported:!0},$o={description:a("Week number of the year."),args:_e(`\n date (date) ${a("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) ${a("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const s=fe(e),i=Math.round(he(t));if(le((()=>1===i||2===i||11<=i&&i<=17||21===i),a("The type (%s) is out of range.",i.toString())),21===i)return wo.compute(e);let o;o=1===i||2===i?i-1:i-10==7?0:i-10;const n=s.getFullYear();let r=1,l=new D(n,0,r);for(;l.getDay()!==o;)r+=1,l=new D(n,0,r);const c=(s.getTime()-l.getTime())/864e5;return c<0?1:Math.floor(c/7)+(1===r?1:2)},isExported:!0},Do={description:a("Number of working days from start date."),args:_e(`\n start_date (date) ${a("The date from which to begin counting.")}\n num_days (number) ${a("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${a("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t,s){return Uo.compute(e,t,1,s)},isExported:!0},Uo={description:a("Net working days between two dates (specifying weekends)."),args:_e(`\n start_date (date) ${a("The date from which to begin counting.")}\n num_days (number) ${a("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${a("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${a("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t,s=1,i){let o=fe(e),n=Math.trunc(he(t));"string"==typeof s&&le((()=>"1111111"!==s),a("The weekend (%s) must be different from '1111111'.",s));const r=Lo(s);let l=new Set;void 0!==i&&ve([i],(e=>{const t=fe(e);l.add(t.getTime())}));let c=D.fromTimestamp(o.getTime()),h=c.getTime();const d=Math.sign(n);let u=Math.abs(n);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),r.includes(c.getDay())||l.has(h)||(u-=1);const p=h-fo.getTime();return Math.round(p/864e5)},isExported:!0},Po={description:a("Year specified by a given date."),args:_e(`\n date (date) ${a("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getFullYear()},isExported:!0},Bo={description:a("Exact number of years between two dates."),args:_e(`\n start_date (date) ${a("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) ${a("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) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s=0){let i=Math.trunc(he(e)),o=Math.trunc(he(t));const n=Math.trunc(he(s));if(le((()=>i>=0),a("The start_date (%s) must be positive or null.",i.toString())),le((()=>o>=0),a("The end_date (%s) must be positive or null.",o.toString())),le((()=>0<=n&&n<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),i===o)return 0;if(i>o){const e=o;o=i,i=e}const r=fe(i),l=fe(o);let c=r.getDate(),h=l.getDate();const d=r.getMonth(),u=l.getMonth(),p=r.getFullYear(),g=l.getFullYear();let f=0,m=0;switch(n){case 0:31===c&&(c=30),30===c&&31===h&&(h=30),1===d&&c===(mo(p)?29:28)&&(c=30,1===u&&h===(mo(g)?29:28)&&(h=30)),f=p+(30*d+c)/360,m=g+(30*u+h)/360;break;case 1:let e=365;const t=p===g;if(!t&&!(p+1===g)||!t&&d<u||!t&&d===u&&c<h){let t=0,s=0;for(let e=p;e<=g;e++)t++,s+=mo(e)?366:365;e=s/t}else t?mo(p)&&(e=366):(mo(p)&&d<2&&(e=366),mo(g)&&(u>1||1===u&&29===h)&&(e=366));f=i/e,m=o/e;break;case 2:f=i/360,m=o/360;break;case 3:f=i/365,m=o/365;break;case 4:31===c&&(c=30),31===h&&(h=30),f=p+(30*d+c)/360,m=g+(30*u+h)/360}return m-f}};var Vo=Object.freeze({__proto__:null,DATE:vo,DATEVALUE:Eo,DAY:So,DAYS:bo,EDATE:Co,EOMONTH:Io,HOUR:yo,ISOWEEKNUM:wo,MINUTE:To,MONTH:xo,NETWORKDAYS:Ro,NETWORKDAYS_INTL:Mo,NOW:Ao,SECOND:_o,TIME:Oo,TIMEVALUE:No,TODAY:ko,WEEKDAY:Fo,WEEKNUM:$o,WORKDAY:Do,WORKDAY_INTL:Uo,YEAR:Po,YEARFRAC:Bo});function Ho(e,t,s,i,o=1e-10){let n,r,l,c=s,h=!1,d=0;do{l=e(c),n=c-l/t(c),r=Math.abs(n-c),c=n,h=r<o||Math.abs(l)<o,le((()=>d<i),a("Function [[FUNCTION_NAME]] didn't find any result")),d++}while(!h);return c}const zo={description:a("Depreciation via declining balance method."),args:_e(`\n cost (number) ${a("The initial cost of the asset.")}\n salvage (number) ${a("The value of the asset at the end of depreciation.")}\n life (number) ${a("The number of periods over which the asset is depreciated.")}\n period (number) ${a("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${a("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"#,##0.00"},compute:function(e,t,s,i,...o){const n=he(e),r=he(t),l=he(s),c=Math.trunc(he(i)),h=o.length?Math.trunc(he(o[0])):12,d=l+(12===h?0:1);le((()=>n>0),a("The cost (%s) must be strictly positive.",n.toString())),le((()=>r>=0),a("The salvage (%s) must be positive or null.",r.toString())),le((()=>l>0),a("The life (%s) must be strictly positive.",l.toString())),le((()=>c>0),a("The period (%s) must be strictly positive.",c.toString())),le((()=>1<=h&&h<=12),a("The month (%s) must be between 1 and 12 inclusive.",h.toString())),le((()=>c<=d),a("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let p=1-Math.pow(r/n,1/l);p=Math.round(1e3*p)/1e3;let g=n,f=n*(1-p*u);for(let e=1;e<c;e++)g=f,f=g*(1-p),e===l&&(f=g*(1-p*(1-u)));return g-f}},Zo={description:a("Number of periods for an investment to reach a value."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${a("The annualized rate of interest.")}\n yield (number) ${a("The expected annual yield of the security.")}\n frequency (number) ${a("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n=0){n=n||0;const r=Math.trunc(he(e)),l=Math.trunc(he(t)),c=he(s),h=he(i),d=Math.trunc(he(o)),u=Math.trunc(he(n));le((()=>r<l),a("The maturity (%s) must be strictly greater than the settlement (%s).",l.toString(),r.toString())),le((()=>c>=0),a("The rate (%s) must be positive or null.",c.toString())),le((()=>h>=0),a("The yield (%s) must be positive or null.",h.toString())),le((()=>[1,2,4].includes(d)),a("The frequency (%s) must be one of %s",d.toString(),[1,2,4].toString())),le((()=>0<=u&&u<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",u.toString()));const p=Bo.compute(r,l,u),g=p-Math.trunc(p)||1/d,f=Math.ceil(p*d),m=c/d,v=h/d;let E=0,S=0;for(let e=1;e<=f;e++){const t=(m+(e===f?1:0))/(1+v)**e;S+=(g+(e-1)/d)*t,E+=t}return 0===E?0:S/E}},Go={description:a("Future value of an annuity investment."),args:_e(`\n rate (number) ${a("The interest rate.")}\n number_of_periods (number) ${a("The number of payments to be made.")}\n payment_amount (number) ${a("The amount per period to be paid.")}\n present_value (number, default=0) ${a("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${a("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"#,##0.00"},compute:function(e,t,s,i=0,o=0){i=i||0,o=o||0;const n=he(e),r=he(t),a=he(s),l=he(i),c=ge(o)?1:0;return n?-l*(1+n)**r-a*(1+n*c)*((1+n)**r-1)/n:-(l+a*r)}},Wo={description:a("Internal rate of return given periodic cashflows."),args:_e(`\n cashflow_amounts (number, range<number>) ${a("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${a("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"0%"},compute:function(e,t=.1){const s=he(t);le((()=>s>-1),a("The rate_guess (%s) must be strictly greater than -1.",s.toString()));let i=!1,o=!1,n=[];Ee([e],(e=>{e>0&&(i=!0),e<0&&(o=!0),n.push(e)})),le((()=>i&&o),a("The cashflow_amounts must include negative and positive values."));const r=n.shift();return Ho((function(e){return function(e,t,s){const i=s.length;let o=0;return s.reduce(((t,s)=>(o++,t+s*e**(i-o))),t*e**i)}(e,r,n)}),(function(e){return function(e,t,s){const i=s.length;let o=0;return s.reduce(((t,s)=>(o++,t+s*(i-o)*e**(i-o-1))),t*i*e**(i-1))}(e,r,n)}),s+1,20,1e-5)-1}},qo={description:a("Modified Macaulay duration."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${a("The annualized rate of interest.")}\n yield (number) ${a("The expected annual yield of the security.")}\n frequency (number) ${a("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n=0){return Zo.compute(e,t,s,i,o,n)/(1+he(i)/Math.trunc(he(o)))}};const jo={description:a("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:_e(`\n discount (number) ${a("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${a("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${a("Additional future cash flows.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"#,##0.00"},compute:function(e,...t){const s=he(e);return le((()=>-1!==s),a("The discount (%s) must be different from -1.",s.toString())),function(e,t,s){let i=0;return Ce(s,((t,s)=>(i++,t+s/(1+e)**i)),t)}(s,0,t)}},Yo={description:a("Computes the number of periods needed for an investment to reach a value."),args:_e(`\n rate (number) ${a("The rate at which the investment grows each period.")}\n present_value (number) ${a("The investment's current value.")}\n future_value (number) ${a("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,s){const i=he(e),o=he(t),n=he(s);return le((()=>i>0),a("The rate (%s) must be strictly positive.",i.toString())),le((()=>o>0),a("The present_value (%s) must be strictly positive.",o.toString())),le((()=>n>0),a("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(o))/Math.log(1+i)}},Xo={description:a("Present value of an annuity investment."),args:_e(`\n rate (number) ${a("The interest rate.")}\n number_of_periods (number) ${a("The number of payments to be made.")}\n payment_amount (number) ${a("The amount per period to be paid.")}\n future_value (number, default=0) ${a("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${a("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"#,##0.00"},compute:function(e,t,s,i=0,o=0){i=i||0,o=o||0;const n=he(e),r=he(t),a=he(s),l=he(i),c=ge(o)?1:0;return n?-(a*(1+n*c)*((1+n)**r-1)/n+l)/(1+n)**r:-(l+a*r)}},Ko={description:a("Price of a security paying periodic interest."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${a("The annualized rate of interest.")}\n yield (number) ${a("The expected annual yield of the security.")}\n redemption (number) ${a("The redemption amount per 100 face value, or par.")}\n frequency (number) ${a("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n,r=0){r=r||0;const l=Math.trunc(he(e)),c=Math.trunc(he(t)),h=he(s),d=he(i),u=he(o),p=Math.trunc(he(n)),g=Math.trunc(he(r));le((()=>c>l),a("The maturity (%s) must be strictly greater than the settlement (%s).",c.toString(),l.toString())),le((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),le((()=>d>=0),a("The yield (%s) must be positive or null.",d.toString())),le((()=>u>0),a("The redemption (%s) must be strictly positive.",u.toString())),le((()=>[1,2,4].includes(p)),a("The frequency (%s) must be one of %s.",p.toString(),[1,2,4].toString())),le((()=>0<=g&&g<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",g.toString()));const f=Bo.compute(l,c,g)*p,m=Math.ceil(f),v=f-Math.floor(f)||1,E=1+d/p,S=100*h/p;if(1===m)return(S+u)/(v*d/p+1)-S*(1-v);let b=0;for(let e=1;e<=m;e++)b+=S/E**(e-1+v);return u/E**(m-1+v)+b-S*(1-v)}},Qo={description:a("Annual yield of a security paying periodic interest."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${a("The annualized rate of interest.")}\n price (number) ${a("The price at which the security is bought per 100 face value.")}\n redemption (number) ${a("The redemption amount per 100 face value, or par.")}\n frequency (number) ${a("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n,r=0){r=r||0;const l=Math.trunc(he(e)),c=Math.trunc(he(t)),h=he(s),d=he(i),u=he(o),p=Math.trunc(he(n)),g=Math.trunc(he(r));le((()=>c>l),a("The maturity (%s) must be strictly greater than the settlement (%s).",c.toString(),l.toString())),le((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),le((()=>d>0),a("The price (%s) must be strictly positive.",d.toString())),le((()=>u>0),a("The redemption (%s) must be strictly positive.",u.toString())),le((()=>[1,2,4].includes(p)),a("The frequency (%s) must be one of %s.",p.toString(),[1,2,4].toString())),le((()=>0<=g&&g<=4),a("The day_count_convention (%s) must between 0 and 4 inclusive.",g.toString()));const f=Bo.compute(l,c,g)*p,m=Math.ceil(f),v=f-Math.floor(f)||1,E=100*h/p;if(1===m){const e=d+E*(1-v);return(u+E-e)*p*(1/v)/e}const S=Ho((function(e){return function(e,t,s,i,o,n){let r=n-(e+o*(1-t))*i**(s-1+t);for(let e=1;e<=s;e++)r+=o*i**(e-1);return r}(d,v,m,e,E,u)}),(function(e){return function(e,t,s,i,o){let n=-(e+o*(1-t))*(s-1+t)*i**(s-2+t);for(let e=1;e<=s;e++)n+=o*(e-1)*i**(e-2);return n}(d,v,m,e,E)}),1+(h+1)/p,100,1e-5);return(S-1)*p}},Jo={description:a("Annual yield of a security paying interest at maturity."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${a("The date the security was initially issued.")}\n rate (number) ${a("The annualized rate of interest.")}\n price (number) ${a("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n=0){n=n||0;const r=Math.trunc(he(e)),l=Math.trunc(he(t)),c=Math.trunc(he(s)),h=he(i),d=he(o),u=Math.trunc(he(n));le((()=>r>=c),a("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),c.toString())),le((()=>l>r),a("The maturity (%s) must be strictly greater than the settlement (%s).",l.toString(),r.toString())),le((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),le((()=>d>0),a("The price (%s) must be strictly positive.",d.toString())),le((()=>0<=u&&u<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",u.toString()));const p=Bo.compute(c,l,u),g=Bo.compute(c,r,u),f=Bo.compute(r,l,u);return(100*(1+h*p)/(d+100*h*g)-1)/f}};var en=Object.freeze({__proto__:null,DB:zo,DURATION:Zo,FV:Go,IRR:Wo,MDURATION:qo,NPV:jo,PDURATION:Yo,PV:Xo,PRICE:Ko,YIELD:Qo,YIELDMAT:Jo});const tn={description:a("Whether a value is an error."),args:_e(`value (any, lazy) ${a("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},sn={description:a("Whether a value is `true` or `false`."),args:_e(`value (any) ${a("The value to be verified as a logical TRUE or FALSE.")}`),returns:["BOOLEAN"],compute:function(e){return"boolean"==typeof e},isExported:!0},on={description:a("Whether a value is non-textual."),args:_e(`value (any) ${a("The value to be checked.")}`),returns:["BOOLEAN"],compute:function(e){return"string"!=typeof e},isExported:!0},nn={description:a("Whether a value is a number."),args:_e(`value (any) ${a("The value to be verified as a number.")}`),returns:["BOOLEAN"],compute:function(e){return"number"==typeof e},isExported:!0},rn={description:a("Whether a value is text."),args:_e(`value (any) ${a("The value to be verified as text.")}`),returns:["BOOLEAN"],compute:function(e){return"string"==typeof e},isExported:!0};var an=Object.freeze({__proto__:null,ISERROR:tn,ISLOGICAL:sn,ISNONTEXT:on,ISNUMBER:nn,ISTEXT:rn});const ln={description:a("Logical `and` operator."),args:_e(`\n logical_expression1 (boolean, range<boolean>) ${a("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) ${a("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,s=!0;return ye(e,(e=>(t=!0,s=s&&e,s))),le((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),s},isExported:!0},cn={description:a("Returns value depending on logical expression."),args:_e(`\n logical_expression (boolean) ${a("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) ${a("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${a("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,s=(()=>!1)){const i=ge(e)?t():s();return null==i?"":i},isExported:!0},hn={description:a("Value if it is not an error, otherwise 2nd argument."),args:_e(`\n value (any, lazy) ${a("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${a("An empty value")}) ${a("The value the function returns if value is an error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let s;try{s=e()}catch(e){s=t()}return null==s?"":s},isExported:!0},dn={description:a("Returns a value depending on multiple logical expressions."),args:_e(`\n condition1 (boolean, lazy) ${a("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) ${a("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${a("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${a("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){le((()=>e.length%2==0),a("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(ge(e[t]()))return e[t+1]();throw new Error(a("No match."))},isExported:!0},un={description:a("Returns opposite of provided logical value."),args:_e(`logical_expression (boolean) ${a("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!ge(e)},isExported:!0},pn={description:a("Logical `or` operator."),args:_e(`\n logical_expression1 (boolean, range<boolean>) ${a("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) ${a("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,s=!1;return ye(e,(e=>(t=!0,s=s||e,!s))),le((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),s},isExported:!0},gn={description:a("Logical `xor` operator."),args:_e(`\n logical_expression1 (boolean, range<boolean>) ${a("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) ${a("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,s=!1;return ye(e,(e=>(t=!0,s=s?!e:e,!0))),le((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),s},isExported:!0};var fn=Object.freeze({__proto__:null,AND:ln,IF:cn,IFERROR:hn,IFS:dn,NOT:un,OR:pn,XOR:gn});function mn(e,t){for(let s=0;s<e.length;s++)if(e[s]===t)return s;return-1}const vn={description:a("Column number of a specified cell."),args:_e(`cell_reference (meta, default=${a("The cell in which the formula is entered")}) ${a("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),le((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Fs(e).left+1},isExported:!0},En={description:a("Number of columns in a specified array or range."),args:_e(`range (meta) ${a("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Fs(e);return t.right-t.left+1},isExported:!0},Sn={description:a("Horizontal lookup"),args:_e(`\n search_key (any) ${a("The value to search for. For example, 42, 'Cats', or I24.")}\n range (range) ${a("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) ${a("The row index of the value to be returned, where the first row in range is numbered 1.")}\n is_sorted (boolean, default=true) ${a("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,s,i=true){const o=Math.trunc(he(s));le((()=>1<=o&&o<=t[0].length),a("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const n=ge(i),r=t.map((e=>e[0]));let l;return l=n?Re(r,e):mn(r,e),le((()=>l>-1),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),t[l][o-1]},isExported:!0},bn={description:a("Look up a value."),args:_e(`\n search_key (any) ${a("The value to search for. For example, 42, 'Cats', or I24.")}\n search_array (range) ${a("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) ${a("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,s){let i=t.length,o=t[0].length;const n=o>=i,r=Re(n?t[0]:t.map((e=>e[0])),e);return le((()=>r>=0),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),void 0===s?n?t[i-1][r]:t[r][o-1]:(i=s.length,o=s[0].length,le((()=>1===i||1===o),a("The result_range must be a single row or a single column.")),i>1?(le((()=>r<=i-1),a("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(r+1).toString())),s[r][0]):(le((()=>r<=o-1),a("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(r+1).toString())),s[0][r]))},isExported:!0},Cn={description:a("Position of item in range that matches value."),args:_e(`\n search_key (any) ${a("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${a("The one-dimensional array to be searched.")}\n search_type (number, default=1) ${a("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,s=1){let i=he(s);const o=t.length,n=t[0].length;le((()=>1===o||1===n),a("The range must be a single row or a single column."));let r=-1;const l=t.flat();switch(i=Math.sign(i),i){case 1:r=Re(l,e);break;case 0:r=mn(l,e);break;case-1:r=function(e,t){const s=typeof t;let i,o,n,r,a,l,c=0,h=e.length-1;if(typeof e[c]===s&&t>e[c])return-1;if(typeof e[h]===s&&e[h]>t)return h;for(;h-c>=0;){for(n=Math.ceil((c+h)/2),r=n,a=e[r],l=typeof a;c<=r&&s!==l;)r--,a=e[r],l=typeof a;l===s&&a>=t&&(void 0===i||i>a||i===a&&o>r)&&(i=a,o=r),l===s&&a<=t?h=r-1:c=n+1}return void 0!==o?o:-1}(l,e)}return le((()=>r>=0),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),r+1},isExported:!0},In={description:a("Row number of a specified cell."),args:_e(`cell_reference (meta, default=${a("The cell in which the formula is entered by default")}) ${a("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)),le((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Fs(e).top+1},isExported:!0},yn={description:a("Number of rows in a specified array or range."),args:_e(`range (meta) ${a("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Fs(e);return t.bottom-t.top+1},isExported:!0},wn={description:a("Vertical lookup."),args:_e(`\n search_key (any) ${a("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${a("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) ${a("The column index of the value to be returned, where the first column in range is numbered 1.")}\n is_sorted (boolean, default=true) ${a("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,s,i=true){const o=Math.trunc(he(s));le((()=>1<=o&&o<=t.length),a("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const n=ge(i),r=t[0];let l;return l=n?Re(r,e):mn(r,e),le((()=>l>-1),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),t[o-1][l]},isExported:!0};var Tn=Object.freeze({__proto__:null,COLUMN:vn,COLUMNS:En,HLOOKUP:Sn,LOOKUP:bn,MATCH:Cn,ROW:In,ROWS:yn,VLOOKUP:wn});const xn={description:a("Sum of two numbers."),args:_e(`\n value1 (number) ${a("The first addend.")}\n value2 (number) ${a("The second addend.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return he(e)+he(t)}},Rn={description:a("Concatenation of two values."),args:_e(`\n value1 (string) ${a("The value to which value2 will be appended.")}\n value2 (string) ${a("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return ue(e)+ue(t)},isExported:!0},Ln={description:a("One number divided by another."),args:_e(`\n dividend (number) ${a("The number to be divided.")}\n divisor (number) ${a("The number to divide by.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=he(t);return le((()=>0!==s),a("The divisor must be different from zero.")),he(e)/s}};function Mn(e){return null==e}const An={number:0,string:"",boolean:!1},_n={description:a("Equal."),args:_e(`\n value1 (any) ${a("The first value.")}\n value2 (any) ${a("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=Mn(e)?An[typeof t]:e,t=Mn(t)?An[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function On(e,t,s){e=Mn(e)?An[typeof t]:e,t=Mn(t)?An[typeof e]:t,"number"!=typeof e&&(e=ue(e).toUpperCase()),"number"!=typeof t&&(t=ue(t).toUpperCase());const i=typeof e,o=typeof t;return"string"===i&&"number"===o||("string"!==o||"number"!==i)&&s(e,t)}const Nn={description:a("Strictly greater than."),args:_e(`\n value1 (any) ${a("The value to test as being greater than value2.")}\n value2 (any) ${a("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return On(e,t,((e,t)=>e>t))}},kn={description:a("Greater than or equal to."),args:_e(`\n value1 (any) ${a("The value to test as being greater than or equal to value2.")}\n value2 (any) ${a("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return On(e,t,((e,t)=>e>=t))}},Fn={description:a("Less than."),args:_e(`\n value1 (any) ${a("The value to test as being less than value2.")}\n value2 (any) ${a("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!kn.compute(e,t)}},$n={description:a("Less than or equal to."),args:_e(`\n value1 (any) ${a("The value to test as being less than or equal to value2.")}\n value2 (any) ${a("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Nn.compute(e,t)}},Dn={description:a("Difference of two numbers."),args:_e(`\n value1 (number) ${a("The minuend, or number to be subtracted from.")}\n value2 (number) ${a("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return he(e)-he(t)}},Un={description:a("Product of two numbers"),args:_e(`\n factor1 (number) ${a("The first multiplicand.")}\n factor2 (number) ${a("The second multiplicand.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return he(e)*he(t)}},Pn={description:a("Not equal."),args:_e(`\n value1 (any) ${a("The first value.")}\n value2 (any) ${a("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!_n.compute(e,t)}},Bn={description:a("A number raised to a power."),args:_e(`\n base (number) ${a("The number to raise to the exponent power.")}\n exponent (number) ${a("The exponent to raise base to.")}\n `),returns:["NUMBER"],compute:function(e,t){return Mt.compute(e,t)}},Vn={description:a("A number with the sign reversed."),args:_e(`\n value (number) ${a("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),returnFormat:He.FormatFromArgument,returns:["NUMBER"],compute:function(e){return-he(e)}},Hn={description:a("Value interpreted as a percentage."),args:_e(`\n percentage (number) ${a("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return he(e)/100}},zn={description:a("A specified number, unchanged."),args:_e(`\n value (any) ${a("The number to return.")}\n `),returnFormat:He.FormatFromArgument,returns:["ANY"],compute:function(e){return e}};var Zn=Object.freeze({__proto__:null,ADD:xn,CONCAT:Rn,DIVIDE:Ln,EQ:_n,GT:Nn,GTE:kn,LT:Fn,LTE:$n,MINUS:Dn,MULTIPLY:Un,NE:Pn,POW:Bn,UMINUS:Vn,UNARY_PERCENT:Hn,UPLUS:zn});const Gn={description:a("Gets character associated with number."),args:_e(`\n table_number (number) ${a("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(he(e));return le((()=>t>=1),a("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Wn={description:a("Appends strings to one another."),args:_e(`\n string1 (string, range<string>) ${a("The initial string.")}\n string2 (string, range<string>, repeating) ${a("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return be(e,((e,t)=>e+ue(t)),"")},isExported:!0},qn={description:a("Tests whether two strings are identical."),args:_e(`\n string1 (string) ${a("The first string to compare.")}\n string2 (string) ${a("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return ue(e)===ue(t)},isExported:!0},jn={description:a("First position of string found in text, case-sensitive."),args:_e(`\n search_for (string) ${a("The string to look for within text_to_search.")}\n text_to_search (string) ${a("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${a("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,s=1){const i=ue(e),o=ue(t),n=he(s);le((()=>""!==o),a("The text_to_search must be non-empty.")),le((()=>n>=1),a("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=o.indexOf(i,n-1);return le((()=>r>=0),a("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i.toString(),o)),r+1},isExported:!0},Yn={description:a("Concatenates elements of arrays with delimiter."),args:_e(`\n delimiter (string) ${a("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${a("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${a("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const s=ue(e);return be(t,((e,t)=>(e?e+s:"")+ue(t)),"")}},Xn={description:a("Substring from beginning of specified string."),args:_e(`\n text (string) ${a("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${a("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const s=t.length?he(t[0]):1;return le((()=>s>=0),a("The number_of_characters (%s) must be positive or null.",s.toString())),ue(e).substring(0,s)},isExported:!0},Kn={description:a("Length of a string."),args:_e(`\n text (string) ${a("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return ue(e).length},isExported:!0},Qn={description:a("Converts a specified string to lowercase."),args:_e(`\n text (string) ${a("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return ue(e).toLowerCase()},isExported:!0},Jn={description:a("Replaces part of a text string with different text."),args:_e(`\n text (string) ${a("The text, a part of which will be replaced.")}\n position (number) ${a("The position where the replacement will begin (starting from 1).")}\n length (number) ${a("The number of characters in the text to be replaced.")}\n new_text (string) ${a("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,s,i){const o=he(t);le((()=>o>=1),a("The position (%s) must be greater than or equal to 1.",o.toString()));const n=ue(e),r=he(s),l=ue(i);return n.substring(0,o-1)+l+n.substring(o-1+r)},isExported:!0},er={description:a("A substring from the end of a specified string."),args:_e(`\n text (string) ${a("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${a("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const s=t.length?he(t[0]):1;le((()=>s>=0),a("The number_of_characters (%s) must be positive or null.",s.toString()));const i=ue(e),o=i.length;return i.substring(o-s,o)},isExported:!0},tr={description:a("First position of string found in text, ignoring case."),args:_e(`\n search_for (string) ${a("The string to look for within text_to_search.")}\n text_to_search (string) ${a("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${a("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,s=1){const i=ue(e).toLowerCase(),o=ue(t).toLowerCase(),n=he(s);le((()=>""!==o),a("The text_to_search must be non-empty.")),le((()=>n>=1),a("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=o.indexOf(i,n-1);return le((()=>r>=0),a("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i,o)),r+1},isExported:!0},sr={description:a("Replaces existing text with new text in a string."),args:_e(`\n text_to_search (string) ${a("The text within which to search and replace.")}\n search_for (string) ${a("The string to search for within text_to_search.")}\n replace_with (string) ${a("The string that will replace search_for.")}\n occurrence_number (number, optional) ${a("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,s,i){const o=he(i);le((()=>o>=0),a("The occurrenceNumber (%s) must be positive or null.",o.toString()));const n=ue(e),r=ue(t);if(""===r)return n;const l=ue(s),c=new RegExp(ds(r),"g");if(0===o)return n.replace(c,l);let h=0;return n.replace(c,(e=>++h===o?l:e))},isExported:!0},ir={description:a("Combines text from multiple strings and/or arrays."),args:_e(`\n delimiter (string) ${a(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${a("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${a("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${a("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...s){const i=ue(e),o=ge(t);let n=0;return be(s,((e,t)=>o&&""===ue(t)?e:(n++?e+i:"")+ue(t)),"")},isExported:!0},or={description:a("Removes space characters."),args:_e(`\n text (string) ${a("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return ue(e).trim()},isExported:!0},nr={description:a("Converts a specified string to uppercase."),args:_e(`\n text (string) ${a("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return ue(e).toUpperCase()},isExported:!0};const rr={database:go,date:Vo,financial:en,info:an,lookup:Tn,logical:fn,math:qt,operators:Zn,statistical:Qi,text:Object.freeze({__proto__:null,CHAR:Gn,CONCATENATE:Wn,EXACT:qn,FIND:jn,JOIN:Yn,LEFT:Xn,LEN:Kn,LOWER:Qn,REPLACE:Jn,RIGHT:er,SEARCH:tr,SUBSTITUTE:sr,TEXTJOIN:ir,TRIM:or,UPPER:nr})};const ar=new class extends Le{constructor(){super(...arguments),this.mapping={}}add(e,t){e=e.toUpperCase().replace("_",".");const s=Ne(t);return function(e){let t=!1,s=!1,i=!1;for(let o of e){if(o.type.includes("META")&&o.type.length>1)throw new Error(a("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(a("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=s||t||i,n=!(o.optional||o.repeating||o.default);if(e&&n)throw new Error(a("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=o.repeating,s=o.optional,i=o.default}}(s.args),this.mapping[e]=s.compute,super.add(e,s),this}};for(let e in rr){const t=rr[e];for(let s in t){const i=t[s];i.category=e,ar.add(s,{isExported:!1,...i})}}const lr=/^[S|N]?\d+/,cr=ar.content,hr="+,-,*,/,:,=,<>,>=,>,<=,<,%,^,&".split(",");function dr(e){const t=e.split(""),s=[];for(;t.length;){let e=yr(t)||fr(t)||vr(t)||Sr(t)||pr(t)||ur(t)||wr(t)||Er(t)||Cr(t);e||(e={type:"UNKNOWN",value:t.shift()}),s.push(e)}return s}function ur(e){if(e[0]===$){e.shift();const t=e.join("").match(lr);if(!t)return null;e.splice(0,t[0].length),e[0]===$&&e.shift();const s=t[0];switch(s[0]){case"S":return{type:"NORMALIZED_STRING",value:s.substring(1)};case"N":return{type:"NORMALIZED_NUMBER",value:s.substring(1)};default:return{type:"REFERENCE",value:s}}}return null}function pr(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const gr={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function fr(e){if(e[0]in gr){const t=e.shift();return{type:gr[t],value:t}}return null}function mr(e,t){for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function vr(e){for(let t of hr)if(mr(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Er(e){const t=e.join("").match(K);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Sr(e){if('"'===e[0]){const t=e.shift(),s=[t];for(;e[0]&&(e[0]!==t||"\\"===s[s.length-1]);)s.push(e.shift());return'"'===e[0]&&s.push(e.shift()),{type:"STRING",value:s.join("")}}return null}const br=/\w|\.|!|\$/;function Cr(e){const t=[];if("'"===e[0]){let s=e.shift();for(t.push(s);e[0];)if(s=e.shift(),t.push(s),"'"===s){if(!e[0]||"'"!==e[0])break;s=e.shift(),t.push(s)}if("'"!==s)return{type:"UNKNOWN",value:t.join("")}}for(;e[0]&&e[0].match(br);)t.push(e.shift());if(t.length){const e=t.join("");return{type:e.toUpperCase()in cr?"FUNCTION":"SYMBOL",value:e}}return null}const Ir=/\s/;function yr(e){let t=0;for(;e[0]&&e[0].match(Ir);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function wr(e){return mr(e,_)?(e.splice(0,_.length),{type:"INVALID_REFERENCE",value:_}):null}const Tr=["-","+"],xr=["*","+","&"],Rr={"^":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},Lr=6;function Mr(e){switch(e.type){case"NUMBER":case"SYMBOL":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return Rr[e.value]||15}throw new Error(a("Unknown token: %s",e.value))}function Ar(e,t,s){if("OPERATOR"===t.type){const i=_r(s,Mr(t));return{type:"BIN_OPERATION",value:t.value,left:e,right:i}}throw new Error(N)}function _r(e,t){const s=e.shift();if(!s)throw new Error(N);let i=function(e,t){var s;switch(e.type){case"DEBUGGER":const i=_r(t,1e3);return i.debug=!0,i;case"NUMBER":return{type:"NUMBER",value:te(e.value)};case"NORMALIZED_NUMBER":return{type:"NORMALIZED_NUMBER",value:parseInt(e.value,10)};case"STRING":return{type:"STRING",value:e.value};case"NORMALIZED_STRING":return{type:"NORMALIZED_STRING",value:parseInt(e.value,10)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(a("Wrong function call"));{const i=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?i.push({type:"UNKNOWN",value:""}):i.push(_r(t,Lr));"COMMA"===(null===(s=t[0])||void 0===s?void 0:s.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){i.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?i.push({type:"UNKNOWN",value:""}):i.push(_r(t,Lr))}const o=t.shift();if(!o||"RIGHT_PAREN"!==o.type)throw new Error(a("Wrong function call"));return{type:"FUNCALL",value:e.value,args:i}}case"REFERENCE":return{type:"NORMALIZED_REFERENCE",value:parseInt(e.value,10)};case"INVALID_REFERENCE":throw new Error(a("Invalid reference"));case"SYMBOL":if(Jt.test(e.value))return{type:"REFERENCE",value:e.value};if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value)throw new Error(a("Invalid formula"));return{type:"STRING",value:e.value};case"LEFT_PAREN":const o=_r(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(a("Unmatched left parenthesis"));return t.shift(),o;default:if("OPERATOR"===e.type&&Tr.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,right:_r(t,Rr[e.value])};throw new Error(a("Unexpected token: %s",e.value))}}(s,e);for(;e[0]&&Mr(e[0])>t;)i=Ar(i,e.shift(),e);return i}function Or(e){const t=dr(e).filter((e=>"SPACE"!==e.type));"OPERATOR"===t[0].type&&"="===t[0].value&&t.splice(0,1);const s=_r(t,0);if(t.length)throw new Error(N);return s}function Nr(e,t,s){switch(t===e.type&&(e=s(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>Nr(e,t,s)))};case"UNARY_OPERATION":return{...e,right:Nr(e.right,t,s)};case"BIN_OPERATION":return{...e,right:Nr(e.right,t,s),left:Nr(e.left,t,s)};default:return e}}function kr(e,t={references:[],numbers:[],strings:[]}){switch(e.type){case"FUNCALL":const s=e.args.map((e=>kr(e,t)));return`${e.value}(${s.join(",")})`;case"NUMBER":return e.value.toString();case"NORMALIZED_STRING":return`"${t.strings[e.value]}"`;case"NORMALIZED_NUMBER":return t.numbers[e.value].toString();case"NORMALIZED_REFERENCE":return t.references[e.value].toString();case"REFERENCE":case"STRING":default:return e.value;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.value+Fr(e,t);case"BIN_OPERATION":return function(e,t){const s=e.value,i=e.left,o=i.value;return"BIN_OPERATION"===i.type&&Rr[o]<Rr[s]?`(${kr(i,t)})`:kr(i,t)}(e,t)+e.value+Fr(e,t)}}function Fr(e,t){const s=e.value,i=e.right,o=Rr[i.value],n=Rr[s];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:o<n?r=!0:o!==n||xr.includes(s)||(r=!0),r?`(${kr(i,t)})`:kr(i,t)}const $r=ar.content,Dr={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Ur={"-":"UMINUS","+":"UPLUS"};function Pr(e){return e.map((e=>e.split("\n"))).flat().filter((e=>""!==e.trim()))}const Br={};function Vr(e){if(!Br[e.text]){const t=Or(e.text);let s=1;if("BIN_OPERATION"===t.type&&":"===t.value)throw new Error(a("Invalid formula"));if("UNKNOWN"===t.type)throw new Error(a("Invalid formula"));const i=l(t),o=Pr([`// ${e.text}`,i.code,`return ${i.id};`]).join("\n");let n=new Function("deps","sheetId","ref","range","ctx",o);function r(e){const t=$r[e.value.toUpperCase()],s=e.args,i=s.length;if(i<t.minArgRequired)throw new Error(a("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),i.toString()));if(i>t.maxArgPossible)throw new Error(a("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),i.toString()));const o=t.nbrArgRepeating;if(o>1){const s=t.args.length-o;if((i-s)%o!=0)throw new Error(a("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(),s.toString(),o.toString()))}let n=[];for(let o=0;o<i;o++){const i=t.getArgToFocus(o+1)-1;if(0<=i&&i<t.args.length){const r=s[o],c=t.args[i],h=c.type||[],d=h.includes("META"),u=c.lazy,p=h.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),g=h.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(g&&"NORMALIZED_REFERENCE"!==r.type)throw new Error(a("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(o+1).toString(),r.type.toLowerCase().replace("normalized_","")));const f=l(r,u,d,p,{functionName:e.value.toUpperCase(),paramIndex:o+1});n.push(f)}}return n}function l(t,i=!1,o=!1,n=!1,c={}){const h=[];let d,u,p;if("NORMALIZED_REFERENCE"!==t.type&&("BIN_OPERATION"!==t.type||":"!==t.value)&&o)throw new Error(a("Argument must be a reference to a cell or range."));switch(t.debug&&h.push("debugger;"),t.type){case"BOOLEAN":case"NUMBER":case"STRING":if(!i)return{id:t.value,code:""};d=s++,p=`${t.value}`;break;case"NORMALIZED_NUMBER":d=s++,p=`deps.numbers[${t.value}]`;break;case"NORMALIZED_STRING":d=s++,p=`deps.strings[${t.value}]`;break;case"REFERENCE":throw new Error(`Only normalized references can be compiled: ${t.value}`);case"NORMALIZED_REFERENCE":if(!e.dependencies.references[t.value]){d=s++,p="null";break}d=s++,p=n?`range(${t.value}, deps.references, sheetId)`:`ref(${t.value}, deps.references, sheetId, ${o?"true":"false"}, "${c.functionName||Dr["="]}", ${c.paramIndex})`;break;case"FUNCALL":d=s++;const a=r(t);h.push(Pr(a.map((e=>e.code))).join("\n")),u=t.value.toUpperCase(),h.push(`ctx.__lastFnCalled = '${u}';`),p=`ctx['${u}'](${a.map((e=>e.id))})`;break;case"UNARY_OPERATION":{d=s++,u=Ur[t.value];const e=l(t.right,!1,!1,!1,{functionName:u});h.push(e.code),h.push(`ctx.__lastFnCalled = '${u}';`),p=`ctx['${u}']( ${e.id})`;break}case"BIN_OPERATION":{d=s++,u=Dr[t.value];const e=l(t.left,!1,!1,!1,{functionName:u}),i=l(t.right,!1,!1,!1,{functionName:u});h.push(e.code),h.push(i.code),h.push(`ctx.__lastFnCalled = '${u}';`),p=`ctx['${u}'](${e.id}, ${i.id})`;break}case"UNKNOWN":if(!i)return{id:"undefined",code:""};d=s++,p="undefined"}if(i){return{id:`_${d}`,code:`const _${d} = () => {\n\t${Pr(h).join("\n\t")}\n\treturn ${p};\n}`}}return h.push(`let _${d} = ${p};`),{id:`_${d}`,code:Pr(h).join("\n")}}function c(t){let s;switch(t.type){case"NORMALIZED_REFERENCE":if(e.dependencies.references[t.value])return[t.value];break;case"FUNCALL":if(s=$r[t.value.toUpperCase()],s.returnFormat){if("FormatFromArgument"!==s.returnFormat)return[s.returnFormat.specificFormat];if(t.args.length>0){const e=0;if(!s.args[e].type.includes("META"))return c(t.args[e])}}break;case"UNARY_OPERATION":return c(t.right);case"BIN_OPERATION":if(s=$r[Dr[t.value]],s.returnFormat){if("FormatFromArgument"===s.returnFormat){const e=c(t.left);if("string"==typeof e[e.length-1])return e;const s=c(t.right);return e.concat(s)}return[s.returnFormat.specificFormat]}}return[]}Br[e.text]=n,Br[e.text].dependenciesFormat=c(t)}return Br[e.text]}function Hr(e,t=!1){let s,i,o,n;const r=()=>{n=void 0,i=void 0,s=void 0,o=void 0};for(let a=0;a<e.length;a++){const l=e[a];if(n)if(i){if("SPACE"===l.type)continue;if("OPERATOR"===l.type&&":"===l.value)s=a;else if(s&&"SYMBOL"===l.type)o=a;else if(n&&i&&s&&o){const s={type:"SYMBOL",value:e.slice(n,a).filter((e=>!t||"SPACE"!==e.type)).map((e=>e.value)).join("")};e.splice(n,a-n,s),a=n+1,r()}else"SYMBOL"===l.type?(n=a,i=a,s=void 0):r()}else"SYMBOL"===l.type?(i=a,s=o=void 0):r();else["SPACE","SYMBOL"].includes(l.type)?(n=a,i="SYMBOL"===l.type?a:void 0,s=o=void 0):r()}const a=e.length-1;if(n&&i&&s&&o){const s={type:"SYMBOL",value:e.slice(n,a+1).filter((e=>!t||"SPACE"!==e.type)).map((e=>e.value)).join("")};e.splice(n,a-n+1,s)}return e}function zr(e){return Hr(dr(e),!0)}function Zr(e){return function(e){let t=[],s="";return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(s=""),e.type){case"FUNCTION":s=e.value;break;case"LEFT_PAREN":t.push({parent:s,argPosition:0}),s="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const s=t[t.length-1];s.parent&&(e.functionContext=Object.assign({},s))}return e}))}(function(e){let t=1;const s=[];return e.map((e=>("LEFT_PAREN"===e.type?(s.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=s.pop()),e)))}(function(e){let t=0;return e.map((e=>{const s=e.value.toString().length,i=Object.assign({},e,{start:t,end:t+s,length:s});return t=i.end,i}))}(Hr(dr(e)))))}function Gr(e){const t=zr(e);let s={numbers:[],strings:[],references:[]};return{text:"".concat(...t.map((e=>{if("SYMBOL"===e.type&&Jt.test(e.value)){const t=e.value.trim();s.references.includes(t)||s.references.push(t);return Wr(s.references.indexOf(t).toString())}if("STRING"===e.type){const t=e.value.slice(1).slice(0,e.value.length-2);s.strings.includes(t)||s.strings.push(t);const i=s.strings.indexOf(t);return Wr(`${e.type[0]}${i}`)}if("NUMBER"===e.type){const t=te(e.value);s.numbers.includes(t)||s.numbers.push(t);const i=s.numbers.indexOf(t);return Wr(`${e.type[0]}${i}`)}return e.value}))),dependencies:s}}function Wr(e){return`${$}${e}${$}`}const qr=new Le;function jr(e,t){switch(typeof e){case"string":return e.includes('\\"')?e.replace(/\\"/g,'"'):e;case"boolean":return e?"TRUE":"FALSE";case"number":return(null==t?void 0:t.match(A))?j({value:e,format:t}):t?function(e,t){const s=t.split(";"),i=s.length;return e<0?i>1?ae(-e,s[1]):"-"+ae(-e,s[0]):ae(e,s[3===i&&0===e?2:0])}(e,t):ie(e);case"object":return"0"}}function Yr(e){return""===e?"":J(e)?te(e):Ss(e)?"TRUE"===e.toUpperCase():bs(e)?G(e).value:e}class Xr{constructor(e,t,s){this.id=e,this.evaluated=t,this.style=s.style,this.format=s.format}isFormula(){return!1}isLink(){return!1}isEmpty(){return!1}get formattedValue(){return jr(this.evaluated.value,this.format)}get composerContent(){return this.content}get defaultAlign(){switch(this.evaluated.type){case ke.number:return"right";case ke.boolean:case ke.error:return"center";case ke.text:case ke.empty:return"left"}}get isAutoSummable(){var e;switch(this.evaluated.type){case ke.empty:case ke.text:return!0;case ke.number:return!(null===(e=this.format)||void 0===e?void 0:e.match(A));case ke.error:case ke.boolean:return!1}}}class Kr extends Xr{constructor(e,t={}){super(e,{value:"",type:ke.empty},t),this.content=""}isEmpty(){return!0}}class Qr extends Xr{constructor(e,t,s={}){super(e,{value:t,type:ke.number},s),this.content=ie(this.evaluated.value)}}class Jr extends Xr{constructor(e,t,s={}){super(e,{value:t,type:ke.boolean},s),this.content=this.evaluated.value?"TRUE":"FALSE"}}class ea extends Xr{constructor(e,t,s={}){super(e,{value:t,type:ke.text},s),this.content=this.evaluated.value}}class ta extends Qr{constructor(e,t,s){super(e,t,s),this.format=s.format}get composerContent(){return jr(this.evaluated.value,this.format)}}class sa extends Xr{constructor(e,t,s={}){const i=Ts(t);super(e,{value:i.label,type:ke.text},s),this.link=i,this.content=t}isLink(){return!0}get composerContent(){return this.link.label}}class ia extends sa{constructor(e,t,s={}){super(e,t,s),this.link.url=this.withHttp(this.link.url),this.link.isExternal=!0,this.content=ws(this.link.label,this.link.url),this.urlRepresentation=this.link.url,this.isUrlEditable=!0}action(e){window.open(this.link.url,"_blank")}withHttp(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}}class oa extends sa{constructor(e,t,s={},i){super(e,t,s),this.sheetName=i,this.sheetId=Ls(this.link.url),this.isUrlEditable=!1}action(e){e.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}get urlRepresentation(){return this.sheetName(this.sheetId)||a("Invalid sheet")}}class na extends Xr{constructor(e,t,s,i,o,n){super(t,{value:"Loading...",type:ke.text},n),this.buildFormulaString=e,this.normalizedText=s,this.compiledFormula=i,this.dependencies=o}get content(){return this.buildFormulaString(this.normalizedText,this.dependencies)}isFormula(){return!0}assignValue(e){switch(typeof e){case"number":this.evaluated={value:e,type:ke.number};break;case"boolean":this.evaluated={value:e,type:ke.boolean};break;case"string":this.evaluated={value:e,type:ke.text};break;case"object":case"undefined":this.evaluated={value:e,type:ke.empty}}}assignError(e,t){this.evaluated={value:e,error:t,type:ke.error}}}class ra extends Xr{constructor(e,t,s,i){super(e,{value:"#BAD_EXPR",type:ke.error,error:s},i),this.content=t}}function aa(e){const t=zr(e);let s=[];return{text:"".concat(...t.map((e=>{if("SYMBOL"===e.type&&Jt.test(e.value)){const t=e.value.trim();return s.includes(t)||s.push(t),`${$}${s.indexOf(t)}${$}`}return e.value}))),dependencies:s}}qr.add("Formula",{sequence:10,match:e=>e.startsWith("="),createCell:(e,t,s,i,o)=>{const n=Gr(t),r=n.text,a=Vr(n),l=n.dependencies.references.map((e=>o.getRangeFromSheetXC(i,e))),c=s.format||function(e,t,s){var i;const o=t.dependenciesFormat;for(let t of o)switch(typeof t){case"string":return t;case"number":const o=s[t],n=e[o.sheetId];if(n){const e=null===(i=n.rows[o.zone.top])||void 0===i?void 0:i.cells[o.zone.left];if(e&&e.format)return e.format}}return F}(o.getEvaluationSheets(),a,l);return new na(((e,t)=>o.buildFormulaContent(i,e,t)),e,r,a,{...n.dependencies,references:l},{...s,format:c})}}).add("Empty",{sequence:20,match:e=>""===e,createCell:(e,t,s)=>new Kr(e,s)}).add("Number",{sequence:30,match:e=>J(e),createCell:(e,t,s)=>(!s.format&&t.includes("%")&&(s.format=t.includes(".")?"0.00%":"0%"),new Qr(e,te(t),s))}).add("Boolean",{sequence:40,match:e=>Ss(e),createCell:(e,t,s)=>new Jr(e,"TRUE"===t.toUpperCase(),s)}).add("DateTime",{sequence:50,match:e=>bs(e),createCell:(e,t,s)=>{const i=G(t),o=s.format||i.format;return new ta(e,i.value,{...s,format:o})}}).add("MarkdownSheetLink",{sequence:60,match:e=>Rs(e),createCell:(e,t,s,i,o)=>new oa(e,t,s,(e=>o.tryGetSheetName(e)))}).add("MarkdownLink",{sequence:70,match:e=>ys(e),createCell:(e,t,s)=>new ia(e,t,s)}).add("WebLink",{sequence:80,match:e=>{return t=e,Is.test(t);var t},createCell:(e,t,s)=>new ia(e,ws(t,t),s)});const la=10,ca="Sheet1";function ha(e){return e?("version"in(e=JSON.parse(JSON.stringify(e)))&&e.version<la&&(e=function(e){for(let t=da.findIndex((t=>t.from===e.version));t<da.length;t++)e=da[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,s=new ni;for(const i of e.sheets||[])for(const e of i.figures||[])t.has(e.id)&&(e.id+=s.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(fa(),e,{version:la}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(ga(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(ga(ca,"Sheet1"));return e}(e),e}(e),e):fa()}const da=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const s=t.cells[e];s.content&&s.content.startsWith("=")&&(s.formula=aa(s.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:s,...i}=t.figures[e].data,o=[];for(let e of s)if(e.labelCell){const t=Fs(e.dataRange),s=e.labelCell+":"+os(t.right,t.bottom);o.push(s)}else o.push(e.dataRange);i.dataSetsHaveTitle=Boolean(s[0].labelCell),i.dataSets=o,t.figures[e].data=i}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const s=[],i=new RegExp(k,"g");for(let o of e.sheets||[]){if(!o.name)continue;const e=o.name,n=e.replace(i,"_");let r=1,a=n;for(;s.includes(a);)a=`${n}${r}`,r++;o.name=a,s.push(a);const l=t=>{if(void 0===t)return t;let s=t.replace(e,a),i=t;for(;i!==s;)i=s,s=i.replace(e,a);return i};for(let e in o.cells){const t=o.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of o.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),s=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:s}}for(let e of o.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const s of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[s])||void 0===t?void 0:t.type)&&(e.rule[s].value=l(e.rule[s].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=g,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stackedBar=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const s=t.cells[e];if(s.formula){let{text:e,dependencies:t}=s.formula;for(let[s,i]of Object.entries(t)){const t=`\\${$}${s}\\${$}`;e=e.replace(new RegExp(t,"g"),i)}s.content=e,delete s.formula}}return e}}];function ua(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const s=[],i=[],o=e=>{if("CREATE_SHEET"===e.type)s.push(e.sheetId);else if("sheetId"in e&&!s.includes(e.sheetId))return{...e,sheetId:ca};return e};for(const e of t)"REMOTE_REVISION"===e.type?i.push({...e,commands:e.commands.map(o)}):i.push(e);return i}(e,t),t=pa(t,"SORT_CELLS"),t=pa(t,"SET_DECIMAL")}function pa(e,t){const s=[];for(const i of e)"REMOTE_REVISION"===i.type?s.push({...i,commands:i.commands.filter((e=>e.type!==t))}):s.push(i);return s}function ga(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[]}}function fa(e="Sheet1"){return{version:la,sheets:[ga(ca,e)],entities:{},styles:{},borders:{},revisionId:O,uniqueFigureIds:!0}}class ma{constructor(e,t,s){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t,this.currentMode=s.mode}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 s of e){let e=s.call(this,t);Array.isArray(e)||(e=[e]);const i=e.filter((e=>0!==e));if(i.length)return i}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}ma.getters=[],ma.modes=["headless","normal"];class va extends ma{constructor(e,t,s,i,o,n){super(t,i,o),this.dispatch=i,this.range=s,s.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}exportForExcel(e){}adaptRanges(e,t){}}class Ea extends va{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":if(!e.interactive)for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const s=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,s)}break;case"DELETE_SHEET":const s={...this.borders};delete s[e.sheetId],this.history.update("borders",s);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=this.getters.getSheet(e.sheetId),s=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(t,s,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":e.elements.sort(((e,t)=>t-e));for(const t of vs(e.elements))"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t[t.length-1]+1,-t.length):this.shiftBordersVertically(e.sheetId,t[t.length-1]+1,-t.length);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){const t=this.getters.getSheet(e.sheetId);let s,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),s=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),s=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(t,s,i)}handleAddRows(e){const t=this.getters.getSheet(e.sheetId);let s,i;"before"===e.position?(this.shiftBordersVertically(t.id,e.base,e.quantity,{moveFirstTopBorder:!0}),s=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(t.id,e.base+1,e.quantity,{moveFirstTopBorder:!1}),s=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(t,s,i)}getCellBorder(e,t,s){var i,o,n,r,a,l,c,h,d,u,p,g;const f={top:null===(n=null===(o=null===(i=this.borders[e])||void 0===i?void 0:i[t])||void 0===o?void 0:o[s])||void 0===n?void 0:n.horizontal,bottom:null===(l=null===(a=null===(r=this.borders[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[s+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[s])||void 0===d?void 0:d.vertical,right:null===(g=null===(p=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===p?void 0:p[s])||void 0===g?void 0:g.vertical};return f.bottom||f.left||f.right||f.top?f:null}ensureColumnBorderContinuity(e,t,s){const i=ms(t+1,s);for(let o=0;o<e.rows.length;o++){const n=this.getCellBorder(e.id,t,o),r=this.getCellBorder(e.id,s,o);if(n&&r){const t=this.getCommonSides(n,r);for(let s of i)this.addBorder(e.id,s,o,t)}}}ensureRowBorderContinuity(e,t,s){const i=ms(t+1,s);for(let o=0;o<e.cols.length;o++){const n=this.getCellBorder(e.id,o,t),r=this.getCellBorder(e.id,o,s);if(n&&r){const t=this.getCommonSides(n,r);for(let s of i)this.addBorder(e.id,o,s,t)}}}getCommonSides(e,t){const s={};for(let i of["top","bottom","left","right"])e[i]&&e[i]===t[i]&&(s[i]=e[i]);return s}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsWithBorders(e){var t;const s=null===(t=this.borders[e])||void 0===t?void 0:t.filter(Ms);if(!s)return[];const i=new Set;for(const e of s)for(const t in e)i.add(parseInt(t,10));return Array.from(i)}getRowsRange(e){if(!this.borders[e])return[];return ms(0,this.getters.getSheet(e).rows.length+1)}shiftBordersHorizontally(e,t,s,{moveFirstLeftBorder:i}={}){this.borders[e]&&(s<0&&this.moveBordersOfColumn(e,t,s,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>s<0?e-t:t-e)).forEach((o=>{(o===t&&i||o!==t)&&this.moveBordersOfColumn(e,o,s,"vertical"),this.moveBordersOfColumn(e,o,s,"horizontal")})))}shiftBordersVertically(e,t,s,{moveFirstTopBorder:i}={}){this.borders[e]&&(s<0&&this.moveBordersOfRow(e,t,s,"horizontal",{destructive:!1}),this.getRowsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>s<0?e-t:t-e)).forEach((o=>{(o===t&&i||o!==t)&&this.moveBordersOfRow(e,o,s,"horizontal"),this.moveBordersOfRow(e,o,s,"vertical")})))}moveBordersOfRow(e,t,s,i,{destructive:o}={destructive:!0}){const n=this.borders[e];n&&this.getColumnsWithBorders(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=n[r])||void 0===a?void 0:a[t+s])||void 0===l?void 0:l[i],u=null===(h=null===(c=n[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[i];this.history.update("borders",e,r,t+s,i,o?u:u||d),this.history.update("borders",e,r,t,i,void 0)}))}moveBordersOfColumn(e,t,s,i,{destructive:o}={destructive:!0}){const n=this.borders[e];n&&this.getRowsRange(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=n[t+s])||void 0===a?void 0:a[r])||void 0===l?void 0:l[i],u=null===(h=null===(c=n[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[i];this.history.update("borders",e,t+s,r,i,o?u:u||d),this.history.update("borders",e,t,r,i,void 0)}))}setBorder(e,t,s,i){this.history.update("borders",e,t,s,{vertical:null==i?void 0:i.left,horizontal:null==i?void 0:i.top}),this.history.update("borders",e,t+1,s,"vertical",null==i?void 0:i.right),this.history.update("borders",e,t,s+1,"horizontal",null==i?void 0:i.bottom)}clearBorders(e,t){for(let s of t){for(let t=s.top;t<=s.bottom;t++){this.history.update("borders",e,s.right+1,t,"vertical",void 0);for(let i=s.left;i<=s.right;i++)this.history.update("borders",e,i,t,void 0)}for(let t=s.left;t<=s.right;t++)this.history.update("borders",e,t,s.bottom+1,"horizontal",void 0)}}addBorder(e,t,s,i){this.setBorder(e,t,s,{...this.getCellBorder(e,t,s),...i})}setBorders(e,t,s){const i=e.id;if("clear"===s)return this.clearBorders(i,t);for(let e of t){if("h"===s||"hv"===s||"all"===s)for(let t=e.top+1;t<=e.bottom;t++)for(let s=e.left;s<=e.right;s++)this.addBorder(i,s,t,{top:L});if("v"===s||"hv"===s||"all"===s)for(let t=e.top;t<=e.bottom;t++)for(let s=e.left+1;s<=e.right;s++)this.addBorder(i,s,t,{left:L});if("left"===s||"all"===s||"external"===s)for(let t=e.top;t<=e.bottom;t++)this.addBorder(i,e.left,t,{left:L});if("right"===s||"all"===s||"external"===s)for(let t=e.top;t<=e.bottom;t++)this.addBorder(i,e.right+1,t,{left:L});if("top"===s||"all"===s||"external"===s)for(let t=e.left;t<=e.right;t++)this.addBorder(i,t,e.top,{top:L});if("bottom"===s||"all"===s||"external"===s)for(let t=e.left;t<=e.right;t++)this.addBorder(i,t,e.bottom+1,{top:L})}}addBordersToMerge(e,t){const s=this.getters.getSheet(e),{left:i,right:o,top:n,bottom:r}=t,a=this.getCellBorder(s.id,i,n),l=this.getCellBorder(s.id,o,r);this.clearBorders(e,[t]),(null==a?void 0:a.top)&&this.setBorders(s,[{...t,bottom:n}],"top"),(null==a?void 0:a.left)&&this.setBorders(s,[{...t,right:i}],"left"),((null==l?void 0:l.bottom)||(null==a?void 0:a.bottom))&&this.setBorders(s,[{...t,top:r}],"bottom"),((null==l?void 0:l.right)||(null==a?void 0:a.right))&&this.setBorders(s,[{...t,left:o}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[s,i]of Object.entries(t.cells))if(null==i?void 0:i.border){const o=e.borders[i.border],[n,r]=is(s);this.setBorder(t.id,n,r,o)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,Fs(e))}export(e){let t=0;const s={};function i(e){for(let[t,i]of Object.entries(s))if(_s(i,e))return parseInt(t,10);return s[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let s=0;s<t.rowNumber;s++){const o=this.getCellBorder(t.id,e,s);if(o){const n=os(e,s),r=t.cells[n],a=i(o);r?r.border=a:t.cells[n]={border:a}}}e.borders=s}exportForExcel(e){this.export(e)}}Ea.getters=["getCellBorder"];const Sa=new RegExp(String.fromCharCode(160),"g"),ba={textColor:M,underline:!0};class Ca extends va{constructor(){super(...arguments),this.cells={},this.cellUuidGenerator=new ni(!0),this.createCell=function(e){const t=qr.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(s,i,o,n){const r=t.find((e=>e.match(i)));if(!r)return new ea(s,i,o);try{return r.createCell(s,i,o,n,e)}catch(e){return new ra(s,i,e.message||N,o)}}}(this.getters)}adaptRanges(e,t){for(const s of Object.keys(this.cells))for(const i of Object.values(this.cells[s]||{}))if(i.isFormula())for(const o of i.dependencies.references)if(!t||o.sheetId===t){const t=e(o);"NONE"!==t.changeType&&this.history.update("cells",s,i.id,"dependencies","references",i.dependencies.references.indexOf(o),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearStyles(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(this.getters.getSheet(e.sheetId),e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,s){for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let o=i.left;o<=i.right;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,format:s})}clearStyles(e,t){for(let s of t)for(let t=s.left;t<=s.right;t++)for(let i=s.top;i<=s.bottom;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:null})}handleAddColumnsRows(e,t){const s=this.getters.getSheet(e.sheetId);let i,o;"before"===e.position?(i=ms(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=ms(e.base+1,e.base+e.quantity+1),o=e.base),t(s,o,i)}import(e){for(let t of e.sheets){const s=this.getters.getSheet(t.id);for(let i in t.cells){const o=t.cells[i],[n,r]=is(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(s,o,e.styles);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cell:i,cellId:i.id,col:n,row:r,sheetId:t.id})}}}}export(e){let t=0;const s={};function i(e){for(let[t,i]of Object.entries(s))if(_s(i,e))return parseInt(t,10);return s[++t]=e,t}for(let t of e.sheets){const e={},s=Object.keys(this.cells[t.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const{col:o,row:n}of s){const s=this.getters.getCell(t.id,o,n);e[os(o,n)]={style:s.style&&i(s.style),format:s.format,content:s.content}}t.cells=e}e.styles=s}importCell(e,t,s){const i=t.style&&s[t.style]||void 0,o=this.cellUuidGenerator.uuidv4(),n={format:null==t?void 0:t.format,style:i};return this.createCell(o,(null==t?void 0:t.content)||"",n,e.id)}exportForExcel(e){this.export(e);for(let t of e.sheets)for(const e in t.cells){const[s,i]=is(e),o=this.getters.getCell(t.id,s,i),n=t.cells[e];n.value=o.evaluated.value,n.isFormula=o.isFormula()}}getCells(e){return this.cells[e]||{}}getCellById(e){const t=this.getters.getCellPosition(e);return this.cells[t.sheetId][e]}buildFormulaContent(e,t,s){let i=t;for(let[t,o]of Object.entries(s.references)){const s=this.getters.getRangeString(o,e),n=`\\${$}${t}\\${$}`;i=i.replace(new RegExp(n,"g"),s)}for(let[e,t]of Object.entries(s.strings)){const s=`\\${$}S${e}\\${$}`;i=i.replace(new RegExp(s,"g"),`"${t}"`)}for(let[e,t]of Object.entries(s.numbers)){const s=`\\${$}N${e}\\${$}`;i=i.replace(new RegExp(s,"g"),t.toString())}return i}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t.normalizedText,t.dependencies)}getCellStyle(e){return{...e.isLink()?ba:{},...e.style}}zoneToXC(e,t,s=[{colFixed:!1,rowFixed:!1}]){const i=os((t=this.getters.expandZone(e,t)).left,t.top,s[0]),o=os(t.right,t.bottom,s.length>1?s[1]:s[0]),n=this.getters.getMainCell(e,t.left,t.top),r=this.getters.getMainCell(e,t.right,t.bottom),a=n[0]==r[0]&&n[1]==r[1];return i==o||a?i:i+":"+o}setStyle(e,t,s){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){const i=this.getters.getCell(e,t,o);this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:s?{...null==i?void 0:i.style,...s}:void 0})}}copyColumnStyle(e,t,s){for(let i=0;i<e.rows.length;i++){const o=this.getFormat(e.id,t,i);if(o.style||o.format)for(let t of s)this.dispatch("UPDATE_CELL",{sheetId:e.id,col:t,row:i,...o})}}copyRowStyle(e,t,s){for(let i=0;i<e.cols.length;i++){const o=this.getFormat(e.id,i,t);if(o.style||o.format)for(let t of s)this.dispatch("UPDATE_CELL",{sheetId:e.id,col:i,row:t,...o})}}getFormat(e,t,s){const i={},[o,n]=this.getters.getMainCell(e,t,s),r=this.getters.getCell(e,o,n);return r&&(r.style&&(i.style=r.style),r.format&&(i.format=r.format)),i}updateCell(e,t,s,i){var o;const n=e.rows[s].cells[t],r="content"in i||"formula"in i,a=r?(null===(o=i.content)||void 0===o?void 0:o.replace(Sa,""))||"":(null==n?void 0:n.content)||"";let l;l=void 0!==i.style?i.style||void 0:n?n.style:void 0;let c=("format"in i?i.format:n&&n.format)||F;if((r&&!a&&!i.formula||!r&&(!n||n.isEmpty()))&&!l&&!c)return void(n&&(this.history.update("cells",e.id,n.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:n.id,col:t,row:s,sheetId:e.id,cell:void 0})));const h=(null==n?void 0:n.id)||this.cellUuidGenerator.uuidv4(),d=r,u={format:c,style:l},p=this.createCell(h,a,u,e.id);n&&!d&&p.isFormula()&&(p.assignValue(n.evaluated.value),n.evaluated.type===ke.error&&p.assignError(n.evaluated.value,n.evaluated.error)),this.history.update("cells",e.id,p.id,p),this.dispatch("UPDATE_CELL_POSITION",{cell:p,cellId:p.id,col:t,row:s,sheetId:e.id})}checkCellOutOfSheet(e,t,s){const i=this.getters.tryGetSheet(e);if(!i)return 23;return zs(t,s,{top:0,left:0,bottom:i.rows.length-1,right:i.cols.length-1})?0:18}}Ca.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Ia extends va{constructor(){super(...arguments),this.chartFigures={}}adaptRanges(e){for(let[t,s]of Object.entries(this.chartFigures))s&&(this.adaptDataSetRanges(s,t,e),this.adaptLabelRanges(s,t,e))}adaptDataSetRanges(e,t,s){for(let i of e.dataSets){if(i.labelCell){const o=s(i.labelCell);switch(o.changeType){case"REMOVE":this.history.update("chartFigures",t,"dataSets",e.dataSets.indexOf(i),"labelCell",void 0);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("chartFigures",t,"dataSets",e.dataSets.indexOf(i),"labelCell",o.range)}}const o=s(i.dataRange);switch(o.changeType){case"REMOVE":const s=e.dataSets.filter((e=>e!==i));this.history.update("chartFigures",t,"dataSets",s);break;case"RESIZE":case"MOVE":case"CHANGE":if(this.getters.getRangeString(o.range,o.range.sheetId)!==_)this.history.update("chartFigures",t,"dataSets",e.dataSets.indexOf(i),"dataRange",o.range);else{const s=e.dataSets.filter((e=>e!==i));this.history.update("chartFigures",t,"dataSets",s)}}}}adaptLabelRanges(e,t,s){if(e.labelRange){const i=s(e.labelRange);switch(i.changeType){case"REMOVE":this.history.update("chartFigures",t,"labelRange",void 0);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("chartFigures",t,"labelRange",i.range)}}}allowDispatch(e){switch(e.type){case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.checkEmptyDataset,this.checkDataset,this.checkChartExists),this.checkLabelRange);case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.checkEmptyDataset,this.checkDataset,this.checkChartDuplicate),this.checkLabelRange);default:return 0}}handle(e){var t,s;switch(e.type){case"CREATE_CHART":const i=e.position?e.position.x:0,o=e.position?e.position.y:0;this.addChartFigure(e.sheetId,this.createChartDefinition(e.definition,e.sheetId),{id:e.id,x:i,y:o,height:335,width:536,tag:"chart"});break;case"UPDATE_CHART":this.updateChartDefinition(e.id,e.definition);break;case"DUPLICATE_SHEET":{const s=this.getters.getFigures(e.sheetId);for(const i of s)if("chart"===i.tag){const s=i.id.split("??").pop(),o=`${e.sheetIdTo}??${s}`,n={...us(this.chartFigures[i.id]),id:o};n.sheetId=e.sheetIdTo,n.dataSets.forEach((t=>{var s;t.dataRange.sheetId===e.sheetId&&(t.dataRange.sheetId=e.sheetIdTo),(null===(s=t.labelCell)||void 0===s?void 0:s.sheetId)===e.sheetId&&(t.labelCell.sheetId=e.sheetIdTo)})),(null===(t=n.labelRange)||void 0===t?void 0:t.sheetId)===e.sheetId&&(n.labelRange.sheetId=e.sheetIdTo);const r={id:o,x:i.x,y:i.y,height:i.height,width:i.width,tag:"chart"};this.addChartFigure(e.sheetIdTo,n,r)}break}case"DELETE_FIGURE":this.history.update("chartFigures",e.id,void 0);break;case"DELETE_SHEET":for(let t of Object.keys(this.chartFigures))(null===(s=this.chartFigures[t])||void 0===s?void 0:s.sheetId)===e.sheetId&&this.history.update("chartFigures",t,void 0)}}getChartDefinition(e){return this.chartFigures[e]}getChartsIdBySheet(e){return Object.entries(this.chartFigures).filter((t=>t[1].sheetId===e)).map((e=>e[0]))}getChartDefinitionUI(e,t){const s=this.chartFigures[t];if(!s)return;const i=s.dataSets.map((t=>t?this.getters.getRangeString(t.dataRange,e):"")).filter((e=>""!==e));return{title:s&&s.title?s.title:"",dataSets:i,labelRange:s.labelRange?this.getters.getRangeString(s.labelRange,e):void 0,type:s?s.type:"bar",dataSetsHaveTitle:!(!s||0===i.length)&&Boolean(s.dataSets[0].labelCell),background:s.background,verticalAxisPosition:s.verticalAxisPosition,legendPosition:s.legendPosition,stackedBar:s.stackedBar}}getChartDefinitionExcel(e,t){const s=this.chartFigures[t],i=this.getChartDefinitionUI("forceSheetReference",t);if(!s||!i)return;const o=s.dataSets.map((e=>this.toExcelDataset(e))).filter((e=>""!==e.range));return{...i,backgroundColor:s.background,dataSets:o}}toExcelDataset(e){var t;const s=null===(t=e.labelCell)||void 0===t?void 0:t.zone;let i=e.dataRange.zone;if(s){const{height:e,width:t}=qs(i);1===e?i={...i,left:i.left+1}:1===t&&(i={...i,top:i.top+1})}const o={...e.dataRange,zone:i};return{label:e.labelCell?this.getters.getRangeString(e.labelCell,"forceSheetReference"):void 0,range:this.getters.getRangeString(o,"forceSheetReference")}}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)if("chart"===e.tag){const s={...e.data};this.chartFigures[e.id]=this.createChartDefinition(s,t.id),delete e.data}}export(e){if(e.sheets)for(let t of e.sheets){const e=this.getters.getFigures(t.id),s=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=this.getChartDefinitionUI(t.id,e.id);i&&(e.data=i,s.push(e))}else s.push(e)}t.figures=s}}exportForExcel(e){for(let t of e.sheets){const e=this.getters.getFigures(t.id),s=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=this.getChartDefinitionExcel(t.id,e.id);i&&(e.data=i,s.push(e))}else s.push(e)}t.charts=s}}createChartDefinition(e,t){return{...e,dataSets:this.createDataSets(e.dataSets,t,e.dataSetsHaveTitle),labelRange:e.labelRange?this.getters.getRangeFromSheetXC(t,e.labelRange):void 0,sheetId:t}}updateChartDefinition(e,t){const s=this.chartFigures[e];if(!s)throw new Error(`There is no chart with the given id: ${e}`);if(void 0!==t.title&&this.history.update("chartFigures",e,"title",t.title),t.type&&this.history.update("chartFigures",e,"type",t.type),t.dataSets){const i=!!t.dataSetsHaveTitle,o=this.createDataSets(t.dataSets,s.sheetId,i);this.history.update("chartFigures",e,"dataSets",o)}if(void 0!==t.labelRange){const i=t.labelRange?this.getters.getRangeFromSheetXC(s.sheetId,t.labelRange):void 0;this.history.update("chartFigures",e,"labelRange",i)}t.background&&this.history.update("chartFigures",e,"background",t.background),t.verticalAxisPosition&&this.history.update("chartFigures",e,"verticalAxisPosition",t.verticalAxisPosition),t.legendPosition&&this.history.update("chartFigures",e,"legendPosition",t.legendPosition),void 0!==t.stackedBar&&this.history.update("chartFigures",e,"stackedBar",t.stackedBar)}createDataSets(e,t,s){const i=[];for(const o of e){const e=this.getters.getRangeFromSheetXC(t,o),{zone:n,sheetId:r,invalidSheetName:a}=e;if(!a)if(n.left!==n.right&&n.top!==n.bottom)for(let e=n.left;e<=n.right;e++){const t={left:e,right:e,top:n.top,bottom:n.bottom};i.push(this.createDataSet(r,t,s?{top:t.top,bottom:t.top,left:t.left,right:t.left}:void 0))}else n.left===n.right&&n.top===n.bottom?s||i.push(this.createDataSet(r,n,void 0)):i.push(this.createDataSet(r,n,s?{top:n.top,bottom:n.top,left:n.left,right:n.left}:void 0))}return i}addChartFigure(e,t,s){this.dispatch("CREATE_FIGURE",{sheetId:e,figure:s}),this.history.update("chartFigures",s.id,t)}createDataSet(e,t,s){if(t.left!==t.right&&t.top!==t.bottom)throw new Error(`Zone should be a single column or row: ${Ds(t)}`);if(s){const i=Ds(t),o=Ds(s);return{labelCell:this.getters.getRangeFromSheetXC(e,o),dataRange:this.getters.getRangeFromSheetXC(e,i)}}return{labelCell:void 0,dataRange:this.getters.getRangeFromSheetXC(e,Ds(t))}}checkEmptyDataset(e){return e.definition.dataSets&&0===e.definition.dataSets.length?27:0}checkDataset(e){if(!e.definition.dataSets)return 0;const t=void 0!==e.definition.dataSets.find((e=>!es.test(e)));return t?28:0}checkLabelRange(e){if(!e.definition.labelRange)return 0;return!es.test(e.definition.labelRange||"")?29:0}checkChartDuplicate(e){for(const t of this.getters.getSheets())if(this.getters.getFigure(t.id,e.id))return 57;return 0}checkChartExists(e){return this.getters.getFigure(e.sheetId,e.id)?0:58}}function ya(e){return""===e?NaN:Number(e)}Ia.getters=["getChartDefinition","getChartDefinitionUI","getChartsIdBySheet"];class wa extends va{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const s of this.cfRules[e])for(const i of s.ranges){const o=t(i);switch(o.changeType){case"REMOVE":let t=s.ranges.slice();t.splice(s.ranges.indexOf(i),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(s),"ranges",t):this.removeConditionalFormatting(s.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(s),"ranges",s.ranges.indexOf(i),o.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){return"ADD_CONDITIONAL_FORMAT"===e.type?this.checkValidations(e,this.checkCFRule,this.checkEmptyRange):0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const s={...e.cf,ranges:e.target.map(Ds)};this.addConditionalFormatting(s,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){return this.cfRules[e].map((t=>this.mapToConditionalFormat(e,t)))||[]}getRulesSelection(e,t){const s=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{s.add(e)}))})),Array.from(s)}getRulesByZone(e,t){const s=new Set;for(let i=t.top;i<=t.bottom;i++)for(let o=t.left;o<=t.right;o++){this.getRulesByCell(e,o,i).forEach((e=>{s.add(e.id)}))}return s}getRulesByCell(e,t,s){const i=[];for(let o of this.cfRules[e])for(let e of o.ranges)zs(t,s,e.zone)&&i.push(o);return new Set(i.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const s={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return s}addConditionalFormatting(e,t){const s=this.cfRules[t].slice(),i=s.findIndex((t=>t.id===e.id)),o=this.mapToConditionalFormatInternal(t,e);i>-1?s.splice(i,1,o):s.push(o),this.history.update("cfRules",t,s)}checkEmptyRange(e){return e.target.length?0:21}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return s=>{if(t.includes(s.operator)){const t=[],i=e=>void 0===e||""===e;return e>=1&&i(s.values[0])&&t.push(36),e>=2&&i(s.values[1])&&t.push(37),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 38;case"max":return 40;case"mid":return 39;case"upperInflectionPoint":return 41;case"lowerInflectionPoint":return 42}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{Vr(Gr(e.value||""))}catch(e){switch(t){case"min":return 43;case"max":return 45;case"mid":return 44;case"upperInflectionPoint":return 46;case"lowerInflectionPoint":return 47}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,s=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(s)?33:0}checkMinBiggerThanMax(e){const t=e.minimum.value,s=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&ya(t)>=ya(s)?32:0}checkMidBiggerThanMax(e){var t;const s=null===(t=e.midpoint)||void 0===t?void 0:t.value,i=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&ya(s)>=ya(i)?34:0}checkMinBiggerThanMid(e){var t;const s=e.minimum.value,i=null===(t=e.midpoint)||void 0===t?void 0:t.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&ya(s)>=ya(i)?35:0}removeConditionalFormatting(e,t){const s=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==s){const e=this.cfRules[t].slice();e.splice(s,1),this.history.update("cfRules",t,e)}}}wa.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Ta extends va{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.getters.getFigures(e.sheetId).forEach((t=>{this.dispatch("DELETE_FIGURE",{id:t.id,sheetId:e.sheetId})})),this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:s,...i}=e,o=i;this.updateFigure(s,o);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[s,i]of Object.entries(t))switch(s){case"x":case"y":void 0!==i&&this.history.update("figures",e,t.id,s,Math.max(i,0));break;case"width":case"height":void 0!==i&&this.history.update("figures",e,t.id,s,i)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var s;return void 0===(null===(s=this.figures[e])||void 0===s?void 0:s[t])?55:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?56:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(Ms)}getFigure(e,t){var s;return null===(s=this.figures[e])||void 0===s?void 0:s[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var s;return void 0!==(null===(s=this.figures[t])||void 0===s?void 0:s[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const s=void 0;t.figures.push({...e,data:s})}}exportForExcel(e){this.export(e)}}Ta.getters=["getFigures","getFigure","getFigureSheetId"];class xa extends va{constructor(){super(...arguments),this.nextId=1,this.pending=null,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?0:this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}beforeHandle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.exportAndRemoveMerges(e.sheetId,(t=>function(e,t){let{left:s,right:i,top:o,bottom:n}=Fs(e);t=t.slice().sort(((e,t)=>t-e));for(let e of t)s>e&&(s-=1),(s>=e||i>=e)&&(i-=1);return s>i?null:os(s,o)+":"+os(i,n)}(t,e.elements)),!0):this.exportAndRemoveMerges(e.sheetId,(t=>function(e,t){let{left:s,right:i,top:o,bottom:n}=Fs(e);t=t.slice().sort(((e,t)=>t-e));for(let e of t)o>e&&(o-=1),(o>=e||n>=e)&&(n-=1);return o>n?null:os(s,o)+":"+os(i,n)}(t,e.elements)),!1);break;case"ADD_COLUMNS_ROWS":const t="before"===e.position?e.base:e.base+1;"COL"===e.dimension?this.exportAndRemoveMerges(e.sheetId,(s=>function(e,t,s){let{left:i,right:o,top:n,bottom:r}=Fs(e);return i>=t&&(i+=s),(i>=t||o>=t)&&(o+=s),i>o?null:os(i,n)+":"+os(o,r)}(s,t,e.quantity)),!0):this.exportAndRemoveMerges(e.sheetId,(s=>function(e,t,s){let{left:i,right:o,top:n,bottom:r}=Fs(e);return n>=t&&(n+=s),(n>=t||r>=t)&&(r+=s),n>r?null:os(i,n)+":"+os(o,r)}(s,t,e.quantity)),!1)}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":this.history.update("merges",e.sheetIdTo,Object.assign({},this.merges[e.sheetId])),this.history.update("mergeCellMap",e.sheetIdTo,Object.assign({},this.mergeCellMap[e.sheetId]));break;case"ADD_MERGE":if(!e.interactive)for(const t of e.target)this.addMerge(this.getters.getSheet(e.sheetId),t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t);break;case"ADD_COLUMNS_ROWS":case"REMOVE_COLUMNS_ROWS":this.pending&&(this.importMerges(this.pending.sheet,this.pending.merges),this.pending=null)}}getMerges(e){return Object.values(this.merges[e]||{}).filter(Ms)}getMerge(e,t,s){var i;const o=this.mergeCellMap[e],n=o?t in o&&(null===(i=o[t])||void 0===i?void 0:i[s]):void 0;return n?this.getMergeById(e,n):void 0}doesIntersectMerge(e,t){const{left:s,right:i,top:o,bottom:n}=t;for(let t=o;t<=n;t++)for(let o=s;o<=i;o++)if(this.getMerge(e,o,t))return!0;return!1}doesColumnsHaveCommonMerges(e,t,s){const i=this.getters.getSheet(e);for(let e=0;e<i.rows.length;e++)if(this.isInSameMerge(i.id,t,e,s,e))return!0;return!1}doesRowsHaveCommonMerges(e,t,s){const i=this.getters.getSheet(e);for(let e=0;e<=i.cols.length;e++)if(this.isInSameMerge(i.id,e,t,e,s))return!0;return!1}expandZone(e,t){let{left:s,right:i,top:o,bottom:n}=t,r={left:s,right:i,top:o,bottom:n};for(let t in this.merges[e]){const s=this.getMergeById(e,parseInt(t));s&&Hs(s,r)&&(r=Bs(s,r))}return Vs(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,s,i,o){return!(!this.isInMerge(e,t,s)||!this.isInMerge(e,i,o))&&this.getMerge(e,t,s)===this.getMerge(e,i,o)}isInMerge(e,t,s){var i;const o=this.mergeCellMap[e];return!!o&&(t in o&&Boolean(null===(i=o[t])||void 0===i?void 0:i[s]))}getMainCell(e,t,s){if(!this.isInMerge(e,t,s))return[t,s];const i=this.getMerge(e,t,s).topLeft;return[i.col,i.row]}getBottomLeftCell(e,t,s){if(!this.isInMerge(e,t,s))return[t,s];const{bottom:i,left:o}=this.getMerge(e,t,s);return[o,i]}isMergeHidden(e,t){const s=this.getters.getHiddenColsGroups(e),i=this.getters.getHiddenRowsGroups(e);for(let e of s)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of i)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const s=this.getMerge(e,t.left,t.top);if(s)return Vs(t,s);const{width:i,height:o}=qs(t);return 1===i&&1===o}isMergeDestructive(e,t){let{left:s,right:i,top:o,bottom:n}=t;i=gs(i,0,e.cols.length-1),n=gs(n,0,e.rows.length-1);for(let t=o;t<=n;t++){const n=this.getters.getRow(e.id,t);for(let e=s;e<=i;e++)if(e!==s||t!==o){const t=n.cells[e];if(t&&!t.isEmpty())return!0}}return!1}getMergeById(e,t){const s=this.merges[e];return void 0!==s?s[t]:void 0}checkDestructiveMerge({sheetId:e,target:t}){const s=this.getters.tryGetSheet(e);if(!s)return 0;return t.some((e=>this.isMergeDestructive(s,e)))?3:0}checkOverlap({target:e}){for(const t of e)for(const s of e)if(t!==s&&Hs(t,s))return 50;return 0}checkMergedContentUpdate(e){const{col:t,row:s,sheetId:i,content:o}=e;if(void 0===o)return 0;const[n,r]=this.getMainCell(i,t,s);return n===t&&r===s?0:4}checkMergeExists(e){const{sheetId:t,target:s}=e;for(const e of s){const{left:s,top:i}=e,o=this.getMerge(t,s,i);if(void 0===o||!Vs(e,o))return 5}return 0}addMerge(e,t){let{left:s,right:i,top:o,bottom:n}=t;i=gs(i,0,e.cols.length-1),n=gs(n,0,e.rows.length-1);if(os(s,o)===os(i,n))return;const r=this.getters.getCell(e.id,s,o);let a=this.nextId++;this.history.update("merges",e.id,a,{id:a,left:s,top:o,right:i,bottom:n,topLeft:{col:s,row:o}});let l=new Set;for(let t=o;t<=n;t++)for(let n=s;n<=i;n++){n===s&&t===o||this.dispatch("UPDATE_CELL",{sheetId:e.id,col:n,row:t,style:r?r.style:null,content:void 0});const i=this.getMerge(e.id,n,t);i&&l.add(i.id),this.history.update("mergeCellMap",e.id,n,t,a)}for(let t of l){const{top:s,bottom:i,left:o,right:n}=this.getMergeById(e.id,t);for(let t=s;t<=i;t++)for(let s=o;s<=n;s++){const i=this.getMerge(e.id,s,t);i&&i.id===a||(this.history.update("mergeCellMap",e.id,s,t,void 0),this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:t}))}this.history.update("merges",e.id,t,void 0)}}removeMerge(e,t){const{left:s,top:i,bottom:o,right:n}=t,r=this.getMerge(e,s,i);if(void 0!==r&&Vs(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=i;t<=o;t++)for(let i=s;i<=n;i++)this.history.update("mergeCellMap",e,i,t,void 0)}}removeAllMerges(e){for(let t in this.merges[e])this.history.update("merges",e,parseInt(t),void 0);for(let t in this.mergeCellMap[e])this.history.update("mergeCellMap",e,parseInt(t),void 0)}exportAndRemoveMerges(e,t,s){const i=this.merges[e];if(!i)return;const o=Ra(i),n=[];for(let e of o){const s=t(e);if(s){const[e,t]=s.split(":");e!==t&&n.push(s)}}this.removeAllMerges(e),this.pending={sheet:e,merges:n}}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){const s=this.getters.getSheet(e);for(let e of t)this.addMerge(s,Fs(e))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Ra(e))}}exportForExcel(e){this.export(e)}}function Ra(e){return Object.values(e).filter(Ms).map((e=>os(e.left,e.top)+":"+os(e.right,e.bottom)))}xa.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCell","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","isSingleCellOrMerge"];class La extends va{constructor(){super(...arguments),this.sheetIds={},this.visibleSheets=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":const t=this.visibleSheets.findIndex((t=>t===e.sheetId));return"left"===e.direction&&0===t||"right"===e.direction&&t===this.visibleSheets.length-1?14:0;case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.visibleSheets.length>1?0:9;case"REMOVE_COLUMNS_ROWS":const s=this.getSheet(e.sheetId);return("COL"===e.dimension?s.cols.length:s.rows.length)>e.elements.length?0:8;case"HIDE_COLUMNS_ROWS":{const t=this.sheets[e.sheetId],s="COL"===e.dimension?t.hiddenColsGroups:t.hiddenRowsGroups,i="COL"===e.dimension?t.cols:t.rows;return(s||[]).flat().concat(e.elements).length<i.length?0:51}default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIds",t.name,t.id);break;case"RESIZE_COLUMNS_ROWS":const s="COL"===e.dimension?"cols":"rows";for(let t of e.elements)this.setHeaderSize(this.getSheet(e.sheetId),s,t,e.size);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.direction);break;case"RENAME_SHEET":e.interactive||this.renameSheet(this.sheets[e.sheetId],e.name);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],e.elements):this.removeRows(this.sheets[e.sheetId],e.elements);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"HIDE_COLUMNS_ROWS":"COL"===e.dimension?this.setElementsVisibility(this.sheets[e.sheetId],e.elements,"cols","hide"):this.setElementsVisibility(this.sheets[e.sheetId],e.elements,"rows","hide");break;case"UNHIDE_COLUMNS_ROWS":"COL"===e.dimension?this.setElementsVisibility(this.sheets[e.sheetId],e.elements,"cols","show"):this.setElementsVisibility(this.sheets[e.sheetId],e.elements,"rows","show");break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e)}}import(e){for(let t of e.sheets)this.sheetIds[t.name]=t.id;for(let t of e.sheets){const e=t.name||r("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:i}=this.getImportedSheetSize(t),o={id:t.id,name:e,cols:ti(t.cols||{},s),rows:si(t.rows||{},i),hiddenColsGroups:[],hiddenRowsGroups:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible};this.visibleSheets.push(o.id),this.sheets[o.id]=o,this.updateHiddenElementsGroups(o.id,"cols"),this.updateHiddenElementsGroups(o.id,"rows")}}exportSheets(e,t=!1){e.sheets=this.visibleSheets.filter(Ms).map((e=>{const s=this.sheets[e];return{id:s.id,name:s.name,colNumber:s.cols.length,rowNumber:s.rows.length,rows:oi(s.rows,t),cols:ii(s.cols,t),merges:[],cells:{},conditionalFormats:[],figures:[],areGridLinesVisible:void 0===s.areGridLinesVisible||s.areGridLinesVisible}}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e,!0)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const s=((t=e).startsWith("'")&&(t=t.slice(1,-1).replace(/''/g,"'")),t);for(const e in this.sheetIds)if(e.toUpperCase()===s.toUpperCase())return this.sheetIds[e]}var t}getSheets(){const{visibleSheets:e,sheets:t}=this;return e.map((e=>t[e])).filter(Ms)}getVisibleSheets(){return this.visibleSheets}getEvaluationSheets(){return this.sheets}getCol(e,t){var s;return null===(s=this.sheets[e])||void 0===s?void 0:s.cols[t]}getRow(e,t){var s;return null===(s=this.sheets[e])||void 0===s?void 0:s.rows[t]}getCell(e,t,s){const i=this.tryGetSheet(e);return i&&i.rows[s]&&i.rows[s].cells[t]||void 0}getColCells(e,t){return this.getSheet(e).rows.reduce(((e,s)=>{const i=s.cells[t];return void 0!==i?e.concat(i):e}),[])}getColsZone(e,t,s){return{top:0,bottom:this.getSheet(e).rows.length-1,left:t,right:s}}getRowsZone(e,t,s){return{top:t,bottom:s,left:0,right:this.getSheet(e).cols.length-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getHiddenColsGroups(e){var t;return(null===(t=this.sheets[e])||void 0===t?void 0:t.hiddenColsGroups)||[]}getHiddenRowsGroups(e){var t;return(null===(t=this.sheets[e])||void 0===t?void 0:t.hiddenRowsGroups)||[]}getNumberCols(e){return this.getSheet(e).cols.length}getNumberRows(e){return this.getSheet(e).rows.length}getNextSheetName(e="Sheet"){let t=1;const s=this.getSheets().map((e=>e.name));let i=`${e}${t}`;for(;s.includes(i);)i=`${e}${t}`,t++;return i}isEmpty(e,t){return Ws(t,this.getSheet(e),(e=>e),void 0).flat().every((e=>!e||e.isEmpty()))}setHeaderSize(e,t,s,i){let o,n;const r=e[t],a=r[s],l=i-a.size;this.history.update("sheets",e.id,t,s,"size",i),a.isHidden||this.history.update("sheets",e.id,t,s,"end",a.end+l),o=a.end;for(let i=s+1;i<r.length;i++){const s=r[i];n=s.isHidden?o:o+s.size,this.history.update("sheets",e.id,t,i,"start",o),this.history.update("sheets",e.id,t,i,"end",n),o=n}}updateCellPosition(e){if(e.cell){const t=this.cellPosition[e.cellId];t&&this.history.update("sheets",e.sheetId,"rows",t.row,"cells",t.col,void 0),this.history.update("cellPosition",e.cell.id,{row:e.row,col:e.col,sheetId:e.sheetId}),this.history.update("sheets",e.sheetId,"rows",e.row,"cells",e.col,e.cell)}else this.history.update("cellPosition",e.cellId,void 0),this.history.update("sheets",e.sheetId,"rows",e.row,"cells",e.col,void 0)}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let s of t)for(let t=s.left;t<=s.right;t++)for(let i=s.top;i<=s.bottom;i++){this.sheets[e].rows[i].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:i})}}createSheet(e,t,s,i,o){const n={id:e,name:t,cols:Js(s),rows:ei(i),hiddenColsGroups:[],hiddenRowsGroups:[],areGridLinesVisible:!0},r=this.visibleSheets.slice();r.splice(o,0,n.id);const a=this.sheets;return this.history.update("visibleSheets",r),this.history.update("sheets",Object.assign({},a,{[n.id]:n})),n}moveSheet(e,t){const s=this.visibleSheets.slice(),i=s.findIndex((t=>t===e)),o=s.splice(i,1);s.splice(i+("left"===t?-1:1),0,o[0]),this.history.update("visibleSheets",s)}checkSheetName(e){const{visibleSheets:t,sheets:s}=this,i=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=s[e])||void 0===t?void 0:t.name.toLowerCase())===i}))?11:k.test(i)?13:0}checkSheetPosition(e){const{visibleSheets:t}=this;return e.position>t.length||e.position<0?15:0}isRenameAllowed(e){if(e.interactive)return 0;return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const s=e.name;this.history.update("sheets",e.id,"name",t.trim());const i=Object.assign({},this.sheetIds);i[t]=e.id,delete i[s],this.history.update("sheetIds",i)}duplicateSheet(e,t){const s=this.getSheet(e),i=this.getDuplicateSheetName(s.name),o=JSON.parse(JSON.stringify(s));o.id=t,o.name=i;for(let e=0;e<=o.cols.length;e++)for(let t=0;t<=o.rows.length;t++)o.rows[t]&&(o.rows[t].cells[e]=void 0);const n=this.visibleSheets.slice(),r=n.findIndex((t=>t===e));n.splice(r+1,0,o.id),this.history.update("visibleSheets",n),this.history.update("sheets",Object.assign({},this.sheets,{[o.id]:o}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:s}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:o.id,col:e,row:s,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIds);a[o.name]=o.id,this.history.update("sheetIds",a)}getDuplicateSheetName(e){let t=1;const s=this.getters.getSheets().map((e=>e.name)),i=a("Copy of %s",e);let o=i.toString();for(;s.includes(o);)o=`${i} (${t})`,t++;return o}deleteSheet(e){const t=e.name,s=Object.assign({},this.sheets);delete s[e.id],this.history.update("sheets",s);const i=this.visibleSheets.slice(),o=i.findIndex((t=>t===e.id));i.splice(o,1),this.history.update("visibleSheets",i);const n=Object.assign({},this.sheetIds);delete n[t],this.history.update("sheetIds",n)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let s of t)this.moveCellOnColumnsDeletion(e,s);this.updateColumnsStructureOnDeletion(e,t)}removeRows(e,t){t.sort(((e,t)=>t-e));for(let s of vs(t))this.moveCellOnRowsDeletion(e,s[s.length-1],s[0]),s.map((t=>this.updateRowsStructureOnDeletion(t,e)))}addColumns(e,t,s,i){this.moveCellsOnAddition(e,"before"===s?t:t+1,i,"columns"),this.updateColumnsStructureOnAddition(e,t,i)}addRows(e,t,s,i){this.addEmptyRows(e,i),this.moveCellsOnAddition(e,"before"===s?t:t+1,i,"rows"),this.updateRowsStructureOnAddition(e,t,i)}moveCellOnColumnsDeletion(e,t){for(let[s,i]of Object.entries(e.rows)){const o=parseInt(s,10);for(let s in i.cells){const n=parseInt(s,10),r=i.cells[s];r&&(n===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:n,row:o}),n>t&&this.updateCellPosition({sheetId:e.id,cellId:r.id,cell:r,col:n-1,row:o}))}}}moveCellsOnAddition(e,t,s,i){const o=[];for(const[n,r]of Object.entries(e.rows)){const a=parseInt(n,10);if("rows"!==i||a>=t)for(let n in r.cells){const l=parseInt(n,10),c=r.cells[n];c&&("rows"===i||l>=t)&&o.push({sheetId:e.id,cellId:c.id,cell:c,col:l+("columns"===i?s:0),row:a+("rows"===i?s:0)})}}for(let e of o.reverse())this.updateCellPosition(e)}moveCellOnRowsDeletion(e,t,s){const i=s-t+1;for(let[o,n]of Object.entries(e.rows)){const r=parseInt(o,10);if(r>=t&&r<=s)for(let t in n.cells){const s=parseInt(t,10);n.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:r})}if(r>s)for(let t in n.cells){const s=parseInt(t,10),o=n.cells[t];o&&this.updateCellPosition({sheetId:e.id,cellId:o.id,cell:o,col:s,row:r-i})}}}updateColumnsStructureOnDeletion(e,t){const s=[];let i=0,o=0;for(let n in e.cols){if(t.includes(parseInt(n,10)))continue;const{size:r,isHidden:a}=e.cols[n],l=a?i:i+r;s.push({name:ss(o),size:r,start:i,end:l,isHidden:a}),i=l,o++}this.history.update("sheets",e.id,"cols",s),this.updateHiddenElementsGroups(e.id,"cols")}updateColumnsStructureOnAddition(e,t,s){const i=[];let o=0,n=0;for(let r in e.cols){if(parseInt(r,10)===t){const{size:t}=e.cols[n];for(let e=0;e<s;e++)i.push({name:ss(n),size:t,start:o,end:o+t}),o+=t,n++}const{size:a,isHidden:l}=e.cols[r],c=l?o:o+a;i.push({name:ss(n),size:a,start:o,end:c,isHidden:l}),o=c,n++}this.history.update("sheets",e.id,"cols",i),this.updateHiddenElementsGroups(e.id,"cols")}updateRowsStructureOnDeletion(e,t){const s=[];let i=0,o=0;const n=t.rows.map((e=>e.cells));for(let r in t.rows){const a=t.rows[r],{size:l,isHidden:c}=a,h=c?i:i+l;parseInt(r,10)!==e&&(o++,s.push({start:i,end:h,size:l,cells:n.shift(),name:String(o),isHidden:c}),i=h)}this.history.update("sheets",t.id,"rows",s),this.updateHiddenElementsGroups(t.id,"rows")}updateRowsStructureOnAddition(e,t,s){const i=[];let o=0,n=0,r=0;const a=e.rows.map((e=>e.cells));for(let l in e.rows){const{size:c,isHidden:h}=e.rows[r],d=h?o:o+c;(parseInt(l,10)<t||parseInt(l,10)>=t+s)&&r++,n++,i.push({start:o,end:d,size:c,cells:a.shift(),name:String(n),isHidden:h}),o=d}this.history.update("sheets",e.id,"rows",i),this.updateHiddenElementsGroups(e.id,"rows")}addEmptyRows(e,t){const s=e.rows[e.rows.length-1].end,i=e.rows.slice();for(let e=0;e<t;e++)i.push({start:s,end:s,size:0,name:(i.length+1).toString(),cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(is);return{rowNumber:Math.max(e.rowNumber,Os(t.map((([e,t])=>t+1)))),colNumber:Math.max(e.colNumber,Os(t.map((([e,t])=>e+1))))}}setElementsVisibility(e,t,s,i){let o=0;const n="hide"===i;for(let i=0;i<e[s].length;i++){const{size:r,isHidden:a}=e[s][i],l=t.includes(i)?n:a||!1,c=l?o:o+r;this.history.update("sheets",e.id,s,i,"start",o),this.history.update("sheets",e.id,s,i,"end",c),this.history.update("sheets",e.id,s,i,"isHidden",l),o=c}this.updateHiddenElementsGroups(e.id,s)}updateHiddenElementsGroups(e,t){var s;const i="cols"===t?"hiddenColsGroups":"hiddenRowsGroups",o=((null===(s=this.sheets[e])||void 0===s?void 0:s[t])||[]).reduce(((e,t,s)=>{if(!t.isHidden)return e;const i=e[e.length-1];return i&&i[i.length-1]==s-1||e.push([]),e[e.length-1].push(s),e}),[]);this.history.update("sheets",e,i,o)}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?23:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?12:0}checkZones(e){const t=[];if("zone"in e&&t.push(e.zone),"target"in e&&Array.isArray(e.target)&&t.push(...e.target),!t.every($s))return 22;if(t.length&&"sheetId"in e){const s=this.getSheet(e.sheetId),i={top:0,left:0,bottom:s.rows.length-1,right:s.cols.length-1};return t.every((e=>{return Vs(Bs(t=i,e),t);var t}))?0:18}return 0}}La.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheets","getVisibleSheets","getEvaluationSheets","getCol","getRow","getCell","getCellPosition","getColCells","getColsZone","getRowsZone","getNumberCols","getNumberRows","getHiddenColsGroups","getHiddenRowsGroups","getGridLinesVisibility","getNextSheetName","isEmpty"];const Ma=new Le;Ma.add("INCREMENT_MODIFIER",{apply:(e,t)=>{var s;e.current+=e.increment;const i=e.current.toString(),o=jr(e.current,null===(s=t.cell)||void 0===s?void 0:s.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i},tooltip:i?{props:{content:o}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,s)=>{var i,o;const n=(null===(i=t.cell)||void 0===i?void 0:i.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:n},tooltip:n?{props:{content:null===(o=t.cell)||void 0===o?void 0:o.formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,s,i)=>{e.current+=e.increment;let o=0,n=0;switch(i){case 0:o=0,n=-e.current;break;case 1:o=0,n=e.current;break;case 2:o=-e.current,n=0;break;case 3:o=e.current,n=0}if(!t.cell||!t.cell.isFormula())return{cellData:{}};const r=t.sheetId,a=s.createAdaptedRanges(t.cell.dependencies.references,o,n,r),l=s.buildFormulaContent(r,t.cell.normalizedText,{...t.cell.dependencies,references:a});return{cellData:{border:t.border,style:t.cell.style,format:t.cell.format,content:l},tooltip:l?{props:{content:l}}:void 0}}});const Aa=new Le;Aa.add("simple_value_copy",{condition:(e,t)=>{var s;return 1===t.length&&!e.isFormula()&&!(null===(s=e.format)||void 0===s?void 0:s.match(A))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("copy_text",{condition:e=>!e.isFormula()&&e.evaluated.type===ke.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula(),generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_number",{condition:e=>e.evaluated.type===ke.number,generateRule:(e,t)=>{const s=function(e,t){let s=[],i=!1;for(let o of t)if(o===e&&(i=!0),(null==o?void 0:o.evaluated.type)===ke.number)s.push(o.evaluated.value);else{if(i)return s;s=[]}return s}(e,t);let i=1;return 2==s.length?i=2*(s[1]-s[0]):s.length>2&&(i=function(e){const t=[];let s=e[0];for(let i=1;i<e.length;i++){const o=e[i];t.push(o-s),s=o}return t.reduce(((e,t)=>e+t),0)/t.length}(s)*s.length),{type:"INCREMENT_MODIFIER",increment:i,current:e.evaluated.type===ke.number?e.evaluated.value:0}},sequence:40});const _a=new Le,Oa=(new Le).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let s=e.base;"after"===e.position&&s++;for(let i=0;i<e.quantity;i++)t.push(i+s);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],s=[...e.elements].sort(((e,t)=>e-t));for(let i of vs(s)){const s=0===i[0]?0:i[0]-1,o=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:s,sheetId:e.sheetId,position:o})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of De.values())Oa.contains(e)||Oa.add(e,Na);function Na(e){return[e]}const ka=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,shortCut:"",action:!1,children:[],separator:!1,icon:!1,id:e});function Fa(e,t){return Object.assign({},ka(e),t)}class $a extends Le{add(e,t){return this.content[e]=Fa(e,t),this}addChild(e,t,s){const i=t.splice(0,1)[0];let o=this.content[i];if(!o)throw new Error(`Path ${i+":"+t.join(":")} not found`);for(let e of t)if(o="function"==typeof o.children?void 0:o.children.find((t=>t.id===e)),!o)throw new Error(`Path ${i+":"+t.join(":")} not found`);return o.children.push(Fa(e,s)),this}getChildren(e,t){return"function"==typeof e.children?e.children(t).sort(((e,t)=>e.sequence-t.sequence)):e.children.sort(((e,t)=>e.sequence-t.sequence))}getName(e,t){return"function"==typeof e.name?e.name(t):e.name}getShortCut(e){return e.shortCut?e.shortCut:""}getAll(){return super.getAll().sort(((e,t)=>e.sequence-t.sequence))}}function Da(e){const t=e.getters.getActiveCols();if(t.size)return t.size;{const t=e.getters.getSelectedZones()[0];return t.right-t.left+1}}function Ua(e){const t=e.getters.getActiveRows();if(t.size)return t.size;{const t=e.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function Pa(e,t){e.dispatch("SET_FORMATTING",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones(),format:t})}function Ba(e,t){e.dispatch("SET_FORMATTING",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones(),style:t})}const Va=async e=>{e.dispatch("COPY",{target:e.getters.getSelectedZones()}),await e.clipboard.writeText(e.getters.getClipboardContent())},Ha=async e=>{e.dispatch("CUT",{target:e.getters.getSelectedZones()}),await e.clipboard.writeText(e.getters.getClipboardContent())},za=async e=>{const t=e.getters.getClipboardContent();let s;try{s=await e.clipboard.readText()}catch(e){console.warn("The OS clipboard could not be read."),console.error(e)}const i=e.getters.getSelectedZones();s&&s!==t?e.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:i,text:s}):e.dispatch("PASTE",{target:i,interactive:!0})},Za=e=>e.dispatch("PASTE",{target:e.getters.getSelectedZones(),pasteOption:"onlyValue"}),Ga=e=>e.dispatch("PASTE",{target:e.getters.getSelectedZones(),pasteOption:"onlyFormat"}),Wa=e=>e.dispatch("DELETE_CONTENT",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones()}),qa=e=>{let t,s;const i=e.getters.getActiveRows();if(0!==i.size)t=Ns([...i]),s=Os([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.top,s=i.bottom}return t===s?a("Delete row %s",(t+1).toString()):a("Delete rows %s - %s",(t+1).toString(),(s+1).toString())},ja=e=>{let t=[...e.getters.getActiveRows()];if(!t.length){const s=e.getters.getSelectedZones()[0];for(let e=s.top;e<=s.bottom;e++)t.push(e)}e.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Ya=e=>{let t,s;const i=e.getters.getActiveCols();if(0!==i.size)t=Ns([...i]),s=Os([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.left,s=i.right}return t===s?a("Delete column %s",ss(t)):a("Delete columns %s - %s",ss(t),ss(s))},Xa=e=>{let t=[...e.getters.getActiveCols()];if(!t.length){const s=e.getters.getSelectedZones()[0];for(let e=s.left;e<=s.right;e++)t.push(e)}e.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"COL",elements:t})},Ka=e=>{const t=e.getters.getSelectedZone();e.dispatch("INSERT_CELL",{shiftDimension:"ROW",zone:t,interactive:!0})},Qa=e=>{const t=e.getters.getSelectedZone();e.dispatch("INSERT_CELL",{shiftDimension:"COL",zone:t,interactive:!0})},Ja=e=>{const t=e.getters.getSelectedZone();e.dispatch("DELETE_CELL",{shiftDimension:"ROW",zone:t,interactive:!0})},el=e=>{const t=e.getters.getSelectedZone();e.dispatch("DELETE_CELL",{shiftDimension:"COL",zone:t,interactive:!0})},tl=e=>{const t=e.getters.getActiveRows();let s,i;if(t.size)s=Ns([...t]),i=t.size;else{const t=e.getters.getSelectedZones()[0];s=t.top,i=t.bottom-t.top+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"before",base:s,quantity:i,dimension:"ROW"})},sl=e=>{const t=e.getters.getActiveRows();let s,i;if(t.size)s=Os([...t]),i=t.size;else{const t=e.getters.getSelectedZones()[0];s=t.bottom,i=t.bottom-t.top+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"after",base:s,quantity:i,dimension:"ROW"})},il=e=>{const t=e.getters.getActiveCols();let s,i;if(t.size)s=Ns([...t]),i=t.size;else{const t=e.getters.getSelectedZones()[0];s=t.left,i=t.right-t.left+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"before",dimension:"COL",base:s,quantity:i})},ol=e=>{const t=e.getters.getActiveCols();let s,i;if(t.size)s=Os([...t]),i=t.size;else{const t=e.getters.getSelectedZones()[0];s=t.right,i=t.right-t.left+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"after",dimension:"COL",base:s,quantity:i})},nl=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.getters.getSelectedZones()})},rl=e=>{e.openLinkEditor()},al=e=>{const{anchor:t,zones:s}=e.getters.getSelection();e.dispatch("SORT_CELLS",{interactive:!0,sheetId:e.getters.getActiveSheetId(),anchor:t,zone:s[0],sortDirection:"ascending"})},ll=e=>{const{anchor:t,zones:s}=e.getters.getSelection();e.dispatch("SORT_CELLS",{interactive:!0,sheetId:e.getters.getActiveSheetId(),anchor:t,zone:s[0],sortDirection:"descending"})},cl=e=>1===e.getters.getSelectedZones().length,hl=new $a;hl.add("cut",{name:a("Cut"),shortCut:"Ctrl+X",sequence:10,action:Ha}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Va}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:za,isVisible:cl}).add("paste_special",{name:a("Paste special"),sequence:40,separator:!0,isVisible:cl}).addChild("paste_value_only",["paste_special"],{name:a("Paste values only"),sequence:10,action:Za}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Ga}).add("sort_range",{name:a("Sort range"),sequence:50,isVisible:cl,separator:!0}).addChild("sort_ascending",["sort_range"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:al}).addChild("sort_descending",["sort_range"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ll}).add("add_row_before",{name:e=>{const t=Ua(e);return 1===t?a("Insert row"):a("Insert %s rows",t.toString())},sequence:70,action:tl,isVisible:cl}).add("add_column_before",{name:e=>{const t=Da(e);return 1===t?a("Insert column"):a("Insert %s columns",t.toString())},sequence:90,action:il,isVisible:cl}).add("insert_cell",{name:a("Insert cells"),sequence:100,isVisible:cl,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:a("Shift down"),sequence:10,action:Ka}).addChild("insert_cell_right",["insert_cell"],{name:a("Shift right"),sequence:20,action:Qa}).add("delete_row",{name:qa,sequence:110,action:ja,isVisible:cl}).add("delete_column",{name:Ya,sequence:120,action:Xa,isVisible:cl}).add("delete_cell",{name:a("Delete cells"),sequence:130,isVisible:cl}).addChild("delete_cell_up",["delete_cell"],{name:a("Shift up"),sequence:10,action:Ja}).addChild("delete_cell_down",["delete_cell"],{name:a("Shift left"),sequence:20,action:el}).add("clear_cell",{name:a("Clear cells"),sequence:140,action:Wa,isEnabled:e=>{const t=e.getters.getActiveCell();return Boolean(t)},separator:!0}).add("insert_link",{name:a("Insert link"),separator:!0,sequence:150,action:rl}).add("conditional_formatting",{name:a("Conditional formatting"),sequence:160,action:nl,separator:!0});const dl=new $a;dl.add("cut",{name:a("Cut"),shortCut:"Ctrl+X",sequence:10,action:Ha}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Va}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:za}).add("paste_special",{name:a("Paste special"),sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{name:a("Paste value only"),sequence:10,action:Za}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Ga}).add("sort_columns",{name:e=>e.getters.getActiveCols().size>1?a("Sort columns"):a("Sort column"),sequence:50,isVisible:cl,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:al}).addChild("sort_descending",["sort_columns"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ll}).add("add_column_before",{name:e=>{const t=Da(e);return 1===t?a("Insert column left"):a("Insert %s columns left",t.toString())},sequence:70,action:il}).add("add_column_after",{name:e=>{const t=Da(e);return 1===t?a("Insert column right"):a("Insert %s columns right",t.toString())},sequence:80,action:ol}).add("delete_column",{name:Ya,sequence:90,action:Xa}).add("clear_column",{name:e=>{let t,s;const i=e.getters.getActiveCols();if(0!==i.size)t=Ns([...i]),s=Os([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.left,s=i.right}return t===s?a("Clear column %s",ss(t)):a("Clear columns %s - %s",ss(t),ss(s))},sequence:100,action:e=>{const t=e.getters.getActiveSheetId(),s=[...e.getters.getActiveCols()].map((s=>e.getters.getColsZone(t,s,s)));e.dispatch("DELETE_CONTENT",{target:s,sheetId:e.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.getters.getElementsFromSelection("COL");let s=t[0],i=t[t.length-1];return 1===t.length?a("Hide column %s",ss(s).toString()):i-s+1===t.length?a("Hide columns %s - %s",ss(s).toString(),ss(i).toString()):a("Hide columns")},sequence:85,action:e=>{const t=e.getters.getElementsFromSelection("COL");e.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.getters.getActiveSheet(),s=e.getters.getHiddenColsGroups(t.id).flat();return t.cols.length>s.length+e.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:"Unhide columns",sequence:86,action:e=>{const t=e.getters.getElementsFromSelection("COL");e.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.getters.getHiddenColsGroups(e.getters.getActiveSheetId()).flat();return e.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:a("Conditional formatting"),sequence:110,action:nl});const ul=new $a;ul.add("sheet",{name:a("Link sheet"),sequence:10,children:e=>e.getters.getSheets().map(((e,t)=>Fa(e.id,{name:e.name,sequence:t,action:()=>{return{link:{label:e.name,url:(t=e.id,`${xs}${t}`)},urlRepresentation:e.name,isUrlEditable:!1};var t}})))});const pl=new $a;pl.add("cut",{name:a("Cut"),sequence:10,shortCut:"Ctrl+X",action:Ha}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Va}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:za}).add("paste_special",{name:a("Paste special"),sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{name:a("Paste value only"),sequence:10,action:Za}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Ga}).add("add_row_before",{name:e=>{const t=Ua(e);return 1===t?a("Insert row above"):a("Insert %s rows above",t.toString())},sequence:50,action:tl}).add("add_row_after",{name:e=>{const t=Ua(e);return 1===t?a("Insert row below"):a("Insert %s rows below",t.toString())},sequence:60,action:sl}).add("delete_row",{name:qa,sequence:70,action:ja}).add("clear_row",{name:e=>{let t,s;const i=e.getters.getActiveRows();if(0!==i.size)t=Ns([...i]),s=Os([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.top,s=i.bottom}return t===s?a("Clear row %s",(t+1).toString()):a("Clear rows %s - %s",(t+1).toString(),(s+1).toString())},sequence:80,action:e=>{const t=e.getters.getActiveSheetId(),s=[...e.getters.getActiveRows()].map((s=>e.getters.getRowsZone(t,s,s)));e.dispatch("DELETE_CONTENT",{target:s,sheetId:e.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.getters.getElementsFromSelection("ROW");let s=t[0],i=t[t.length-1];return 1===t.length?a("Hide row %s",(s+1).toString()):i-s+1===t.length?a("Hide rows %s - %s",(s+1).toString(),(i+1).toString()):a("Hide rows")},sequence:85,action:e=>{const t=e.getters.getElementsFromSelection("ROW");e.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.getters.getActiveSheet(),s=e.getters.getHiddenRowsGroups(t.id).flat();return t.rows.length>s.length+e.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:"Unhide rows",sequence:86,action:e=>{const t=e.getters.getElementsFromSelection("ROW");e.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.getters.getHiddenRowsGroups(e.getters.getActiveSheetId()).flat();return e.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:a("Conditional formatting"),sequence:90,action:nl});const gl=new $a;gl.add("delete",{name:a("Delete"),sequence:10,isVisible:e=>e.getters.getSheets().length>1,action:e=>e.dispatch("DELETE_SHEET_CONFIRMATION",{sheetId:e.getters.getActiveSheetId()})}).add("duplicate",{name:a("Duplicate"),sequence:20,action:e=>{const t=e.getters.getActiveSheetId(),s=e.uuidGenerator.uuidv4();e.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:s}),e.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:s})}}).add("rename",{name:a("Rename"),sequence:30,action:e=>e.dispatch("RENAME_SHEET",{interactive:!0,sheetId:e.getters.getActiveSheetId()})}).add("move_right",{name:a("Move right"),sequence:40,isVisible:e=>{const t=e.getters.getActiveSheetId(),s=e.getters.getSheets();return s.findIndex((e=>e.id===t))!==s.length-1},action:e=>e.dispatch("MOVE_SHEET",{sheetId:e.getters.getActiveSheetId(),direction:"right"})}).add("move_left",{name:a("Move left"),sequence:50,isVisible:e=>{const t=e.getters.getActiveSheetId();return 0!==e.getters.getSheets().findIndex((e=>e.id===t))},action:e=>e.dispatch("MOVE_SHEET",{sheetId:e.getters.getActiveSheetId(),direction:"left"})});const fl=new $a;fl.add("file",{name:a("File"),sequence:10}).add("edit",{name:a("Edit"),sequence:20}).add("view",{name:a("View"),sequence:30}).add("insert",{name:a("Insert"),sequence:40}).add("format",{name:a("Format"),sequence:50}).add("data",{name:a("Data"),sequence:60}).addChild("save",["file"],{name:a("Save"),shortCut:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:a("Undo"),shortCut:"Ctrl+Z",sequence:10,action:e=>e.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:a("Redo"),shortCut:"Ctrl+Y",sequence:20,action:e=>e.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:a("Copy"),shortCut:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:Va}).addChild("cut",["edit"],{name:a("Cut"),shortCut:"Ctrl+X",sequence:40,action:Ha}).addChild("paste",["edit"],{name:a("Paste"),shortCut:"Ctrl+V",sequence:50,action:za}).addChild("paste_special",["edit"],{name:a("Paste special"),sequence:60,separator:!0}).addChild("paste_special_value",["edit","paste_special"],{name:a("Paste value only"),sequence:10,action:Za}).addChild("paste_special_format",["edit","paste_special"],{name:a("Paste format only"),sequence:20,action:Ga}).addChild("sort_range",["edit"],{name:a("Sort range"),sequence:62,isVisible:cl,separator:!0}).addChild("sort_ascending",["edit","sort_range"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:al}).addChild("sort_descending",["edit","sort_range"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ll}).addChild("find_and_replace",["edit"],{name:a("Find and replace"),shortCut:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:a("Delete values"),sequence:70,action:Wa}).addChild("edit_delete_row",["edit"],{name:qa,sequence:80,action:ja}).addChild("edit_delete_column",["edit"],{name:Ya,sequence:90,action:Xa}).addChild("edit_delete_cell_shift_up",["edit"],{name:a("Delete cell and shift up"),sequence:93,action:Ja}).addChild("edit_delete_cell_shift_left",["edit"],{name:a("Delete cell and shift left"),sequence:97,action:el}).addChild("edit_unhide_columns",["edit"],{name:a("Unhide all columns"),sequence:100,action:e=>{const t=e.getters.getActiveSheet();e.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t.id,dimension:"COL",elements:Array.from(Array(t.cols.length).keys())})},isVisible:e=>e.getters.getHiddenColsGroups(e.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:a("Unhide all rows"),sequence:100,action:e=>{const t=e.getters.getActiveSheet();e.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t.id,dimension:"ROW",elements:Array.from(Array(t.rows.length).keys())})},isVisible:e=>e.getters.getHiddenRowsGroups(e.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=Ua(e);return 1===t?a("Row above"):a("%s Rows above",t.toString())},sequence:10,action:tl,isVisible:e=>0===e.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Ua(e);return 1===t?a("Row below"):a("%s Rows below",t.toString())},sequence:20,action:sl,isVisible:e=>0===e.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Da(e);return 1===t?a("Column left"):a("%s Columns left",t.toString())},sequence:30,action:il,isVisible:e=>0===e.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Da(e);return 1===t?a("Column right"):a("%s Columns right",t.toString())},sequence:40,action:ol,isVisible:e=>0===e.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:a("Insert cells and shift down"),sequence:43,action:Ka}).addChild("insert_insert_cell_shift_right",["insert"],{name:a("Insert cells and shift right"),sequence:47,action:Qa,separator:!0}).addChild("insert_chart",["insert"],{name:a("Chart"),sequence:50,action:e=>{var t,s;const i=e.getters.getSelectedZone();let o=i;const n=e.uuidGenerator.uuidv4();let r;i.left!==i.right&&(o={...i,left:i.left+1});const a=[Ds(o)],l=e.getters.getActiveSheetId(),c={x:(null===(t=e.getters.getCol(l,i.right+1))||void 0===t?void 0:t.start)||0,y:(null===(s=e.getters.getRow(l,i.top))||void 0===s?void 0:s.start)||0};let h=!1;for(let t=o.left;t<=o.right;t++){const s=e.getters.getCell(l,t,i.top);if(s&&s.evaluated.type!==ke.number){h=!0;break}}i.left!==i.right&&(r=Ds({...i,right:i.left,top:h?i.top+1:i.top})),e.dispatch("CREATE_CHART",{sheetId:l,id:n,position:c,definition:{title:"",dataSets:a,labelRange:r,type:"bar",stackedBar:!1,dataSetsHaveTitle:h,background:g,verticalAxisPosition:"left",legendPosition:"top"}});const d=e.getters.getFigure(l,n);e.openSidePanel("ChartPanel",{figure:d})}}).addChild("insert_link",["insert"],{name:a("Link"),separator:!0,sequence:60,action:rl}).addChild("insert_sheet",["insert"],{name:a("New sheet"),sequence:70,action:e=>{const t=e.getters.getActiveSheetId(),s=e.getters.getVisibleSheets().findIndex((e=>e===t))+1,i=e.uuidGenerator.uuidv4();e.dispatch("CREATE_SHEET",{sheetId:i,position:s}),e.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},separator:!0}).addChild("view_gridlines",["view"],{name:e=>e.getters.getGridLinesVisibility(e.getters.getActiveSheetId())?a("Hide gridlines"):a("Show gridlines"),action:e=>{const t=e.getters.getActiveSheetId();e.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.getters.getGridLinesVisibility(t)})},sequence:5,separator:!0}).addChild("view_formulas",["view"],{name:e=>e.getters.shouldShowFormulas()?a("Hide formulas"):a("Show formulas"),action:e=>e.dispatch("SET_FORMULA_VISIBILITY",{show:!e.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:10}).addChild("format_number",["format"],{name:a("Numbers"),sequence:10,separator:!0}).addChild("format_number_general",["format","format_number"],{name:a("General"),sequence:10,separator:!0,action:e=>Pa(e,"")}).addChild("format_number_number",["format","format_number"],{name:a("Number (1,000.12)"),sequence:20,action:e=>Pa(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:a("Percent (10.12%)"),sequence:30,separator:!0,action:e=>Pa(e,"0.00%")}).addChild("format_number_date",["format","format_number"],{name:a("Date (9/26/2008)"),sequence:40,action:e=>Pa(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:a("Time (10:43:00 PM)"),sequence:50,action:e=>Pa(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:a("Date time (9/26/2008 22:43:00)"),sequence:60,action:e=>Pa(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:a("Duration (27:51:38)"),sequence:70,separator:!0,action:e=>Pa(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:a("Bold"),sequence:20,shortCut:"Ctrl+B",action:e=>Ba(e,{bold:!e.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:a("Italic"),sequence:30,shortCut:"Ctrl+I",action:e=>Ba(e,{italic:!e.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:a("Underline"),shortCut:"Ctrl+U",sequence:40,action:e=>Ba(e,{underline:!e.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:a("Strikethrough"),sequence:50,action:e=>Ba(e,{strikethrough:!e.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:a("Font size"),sequence:60,separator:!0}).addChild("format_cf",["format"],{name:a("Conditional formatting"),sequence:70,action:nl,separator:!0});for(let e of cs)fl.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>Ba(t,{fontSize:e.pt})});const ml=new class extends Le{addTransformation(e,t,s){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,s);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},{css:vl,xml:El}=t.tags,Sl=[["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff"],["#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff"],["#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc"],["#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd"],["#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0"],["#a61c00","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79"],["#85200c","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#0b5394","#351c75","#741b47"],["#5b0f00","#660000","#783f04","#7f6000","#274e13","#0c343d","#1c4587","#073763","#20124d","#4c1130"]],bl=24*Math.max(...Sl.map((e=>e.length)))+12;class Cl extends t.Component{constructor(){super(...arguments),this.COLORS=Sl}onColorClick(e){const t=e.target.dataset.color;t&&this.trigger("color-picked",{color:t})}}Cl.template=El`
1
+ !function(e,t){"use strict";function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var i=s(t);let o=e=>e;function n(e,...t){if(1===t.length&&"object"==typeof t[0]){const s=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>s[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const r=function(e,...t){return n(o(e),...t)},a=function(e,...t){return{toString:function(){return n(o(e),...t)}}},l="#f5f5f5",c="#F8F9FA",h="#E8EAED",d="#595959",u="#666666",p="#3266ca",g="#FFFFFF",f=26,m=48,v=63,E=96,S=23,b=15,C=14,I=4,y=200,w=1,T="400",x=10,R="'Roboto', arial",L=["thin","#000"],M="#00f",A=/[ymd:]/,_="#REF",O="START_REVISION",N=a("Invalid expression"),k=/'|\*|\?|\/|\\|\[|\]/,F=void 0,$="|";class D{constructor(e,t,s,i=0,o=0,n=0){this.jsDate=new Date(Date.UTC(e,t,s,i,o,n,0))}static fromTimestamp(e){const t=new Date(e);return new D(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new D(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())}toString(){return this.jsDate.toString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}setDate(e){this.jsDate.setUTCDate(e)}setHours(e){this.jsDate.setUTCHours(e)}setMinutes(e){this.jsDate.setUTCMinutes(e)}setSeconds(e){this.jsDate.setUTCSeconds(e)}}const U=2e3,P=D.now().getFullYear(),B=new D(1899,11,30),V=D.fromTimestamp(0).getTime()-B.getTime(),H=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,z=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Z=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function G(e){let t;const s=(e=e.trim()).match(Z);if(s){if(t=function(e){if(e=e.trim(),Z.test(e)){const t=/AM/i.test(e),s=/PM/i.test(e),i=(t||s?e.substring(0,e.length-2).trim():e).split(/:/),o=i.length>=2,n=3===i.length;let r=Number(i[0]),a=o?Number(i[1]):0,l=n?Number(i[2]):0,c=n?"hh:mm:ss":"hh:mm";if(t||s)c+=" a";else if(!o)return null;r>=12&&t?r-=12:r<12&&s&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new D(1899,11,30,r,a,l)}}return null}(s[0]),null===t)return null;e=e.replace(s[0],"").trim()}let i;const o=e.match(H),n=e.match(z);if(o||n){let t;if(o?(t=o[0],i=W(t,"mdy")):(t=n[0],i=W(t,"ymd")),null===i)return null;e=e.replace(t,"").trim()}return""!==e||!i&&!t?null:i&&t?{value:i.value+t.value,format:i.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new D(i.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,i.jsDate.getMonth()+t.jsDate.getMonth()-11,i.jsDate.getDate()+t.jsDate.getDate()-30,i.jsDate.getHours()+t.jsDate.getHours(),i.jsDate.getMinutes()+t.jsDate.getMinutes(),i.jsDate.getSeconds()+t.jsDate.getSeconds())}:i||t}function W(e,t){const s="mdy"===t;if(s||"ymd"===t){const t=e.split(/\/|-|\s/),i=s?0:1,o=s?1:2,n=s?2:0,r=Number(t[i]),a=Number(t[o]),l=2===t[i].length&&r<10||2===t[o].length&&a<10,c=t[n]?function(e){const t=Number(e);switch(e.length){case 1:return U+t;case 2:return U+(U+t>P+10?-100:0)+t;case 3:case 4:return t}return 0}(t[n]):P,h=new D(c,r-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==r-1||h.getDate()!==a)return null;const u=h.getTime()-B.getTime();let p=l?`mm${d}dd`:`m${d}d`;return t[n]&&(p=s?p+d+"yyyy":"yyyy"+d+p),{value:Math.round(u/864e5),format:p,jsDate:h}}return null}function q(e){const t=Math.trunc(e);let s=D.fromTimestamp(86400*t*1e3-V),i=e-t;i=i<0?1+i:i;const o=Math.round(24*i),n=Math.round(24*(i-o/24)*60),r=Math.round(24*(i-o/24-n/24/60)*60*60);return s.setHours(o),s.setMinutes(n),s.setSeconds(r),s}function j(e){const t=e.format,s=e.jsDate||q(e.value),i=t.indexOf("h");let o="",n="";return i>0?(o=Y(s,t.substring(0,i-1)),n=X(s,t.substring(i))):0===i?n=X(s,t):i<0&&(o=Y(s,t)),o+(o&&n?" ":"")+n}function Y(e,t){const s=t.match(/\/|-|\s/)[0];return t.split(s).map((s=>{switch(s){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(s)}function X(e,t){let s=t.split(/:|\s/);const i=e.getHours(),o="a"===s[s.length-1];let n=i,r="";return o&&(n=0===n?12:n>12?n-12:n,r=i>=12?" PM":" AM",s.pop()),s.map((s=>{switch(s){case"hhhh":return Math.floor((e.getTime()-B.getTime())/36e5).toString();case"hh":return n.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}const K=/(^-?\d+(\.?\d*(e\d+)?)?(\s*%)?|^-?\.\d+(\s*%)?)(?!\w|!)/,Q=/^-?\d+(,\d+)*(\.?\d*(e\d+)?)?(\s*%)?$|^-?\.\d+(\s*%)?$/;function J(e){return Q.test(e.trim())}const ee=/,/g;function te(e){let t=Number(e.replace(ee,""));return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}const se=new Intl.NumberFormat("en-US",{useGrouping:!1,maximumFractionDigits:10});function ie(e){return Number.isInteger(e)?e.toString():se.format(e)}let oe=[];const ne=20;function re(e,t,s=""){if(e<0)return"-"+re(-e,t);const i=t>=ne?ne:t;let o=oe[i];o||(o=new Intl.NumberFormat("en-US",{minimumFractionDigits:i,maximumFractionDigits:i,useGrouping:!1}),oe[i]=o);let n=o.format(e);if(s){let e=n.indexOf(".");n=n.replace(/\d(?=(?:\d{3})+(?:\.|$))/g,((t,i)=>e<0||i<e?`${t}${s}`:t))}return n}function ae(e,t){const s=t.split("."),i=1===s.length?0:s[1].match(/0/g).length,o=s[0].includes(",")?",":"",n=t.includes("%");n&&(e*=100);const r=re(e,i,o);return n?r+"%":r}function le(e,t){if(!e())throw new Error(t)}const ce=e=>a("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function he(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(J(e)||""===e)return te(e);const t=G(e);if(t)return t.value;throw new Error(ce(e));default:return 0}}function de(e){if(""===e)throw new Error(ce(e));return he(e)}function ue(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const pe=e=>a("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function ge(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(pe(e))}return!1;case"number":return!!e;default:return!1}}function fe(e){return q(he(e))}function me(e,t,s){for(let i of e)if(Array.isArray(i)){const e=i.length,s=i[0].length;for(let o=0;o<s;o++)for(let s=0;s<e;s++)t(i[s][o])}else s(i)}function ve(e,t){me(e,t,t)}function Ee(e,t){me(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(de(e))}))}function Se(e,t,s,i){let o=i;for(let i of e)if(Array.isArray(i)){const e=i.length,s=i[0].length;for(let n=0;n<s;n++)for(let s=0;s<e;s++)o=t(o,i[s][n])}else o=s(o,i);return o}function be(e,t,s){return Se(e,t,t,s)}function Ce(e,t,s){return Se(e,((e,s)=>"number"==typeof s?t(e,s):e),((e,s)=>t(e,de(s))),s)}function Ie(e,t,s){return Se(e,((e,s)=>null!=s?t(e,"number"==typeof s?s:"boolean"==typeof s?he(s):0):e),((e,s)=>t(e,he(s))),s)}function ye(e,t){return function(e,t,s){for(let i of e)if(Array.isArray(i)){const e=i.length,s=i[0].length;for(let o=0;o<s;o++)for(let s=0;s<e;s++)if(!t(i[s][o]))return}else if(!s(i))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(pe(e));return ge(e)}(e))))}function we(e,t){let s,i,o=e.substring(0,2);"<="===o||">="===o||"<>"===o?(s=o,i=e.substring(2)):(o=e.substring(0,1),"<"===o||">"===o||"="===o?(s=o,i=e.substring(1)):(s="=",i=e)),J(i)?i=he(i):"TRUE"!==i&&"FALSE"!==i||(i=ge(i));const n={operator:s,operand:i};return"string"==typeof i&&(t&&(i+="*"),n.regexp=function(e){if("*"===e)return/.+/;let t="",s="";for(let i of e)"?"===i&&"~"!==s?t+=".":"*"===i&&"~"!==s?t+=".*":("*"!==i&&"?"!==i||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(i)&&(t+="\\"),t+=i),s=i;return new RegExp("^"+t+"$","i")}(i)),n}function Te(e="",t){const{operator:s,operand:i}=t;if(void 0===i)return!1;if("number"==typeof i&&"="===s)return ue(e)===ue(i);if("<>"===s||"="===s){let o;return o=typeof e==typeof i&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===i),"="===s?o:!o}if(typeof e==typeof i)switch(s){case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i}return!1}function xe(e,t,s=!1){const i=e.length;if(i%2==1)throw new Error(a("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const o=e[0].length,n=e[0][0].length;let r=[];for(let t=0;t<i-1;t+=2){const i=e[t];if(!Array.isArray(i)||i.length!==o||i[0].length!==n)throw new Error(a("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=ue(e[t+1]);r.push(we(l,s))}for(let s=0;s<o;s++)for(let o=0;o<n;o++){let n=!0;for(let t=0;t<i-1;t+=2){if(n=Te(e[t][s][o],r[t/2]),!n)break}n&&t(s,o)}}function Re(e,t){if(void 0===t)return-1;const s=typeof t;let i,o,n,r,a,l,c=0,h=e.length-1;if(typeof e[c]===s&&t<e[c])return-1;if(typeof e[h]===s&&e[h]<=t)return h;for(;h-c>=0;){for(n=Math.ceil((c+h)/2),r=n,a=e[r],l=typeof a;c<=r&&s!==l;)r--,a=e[r],l=typeof a;l===s&&a<=t&&(void 0===i||i<a||i===a&&o<r)&&(i=a,o=r),l===s&&a>t?h=r-1:c=n+1}return void 0!==o?o:-1}class Le{constructor(){this.content={}}add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}remove(e){delete this.content[e]}}const Me=/(.*?)\((.*?)\)(.*)/,Ae=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function _e(e){let t=e.split("\n");const s=[];for(let e of t)e=e.trim(),e&&s.push(Oe(e));return s}function Oe(e){let t,s=e.match(Me),i=s[1].trim(),o=[],n=!1,r=!1,a=!1;for(let e of s[2].split(",")){const s=e.trim().toUpperCase();let i=Ae.find((e=>s===e));i?o.push(i):"RANGE<ANY>"===s?o.push("RANGE"):"OPTIONAL"===s?n=!0:"REPEATING"===s?r=!0:"LAZY"===s?a=!0:s.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:i,description:s[3].trim(),type:o};return n&&(l.optional=!0),r&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function Ne(e){let t=0,s=0,i=0;for(let o of e.args)t++,o.optional||o.repeating||o.default||s++,o.repeating&&i++;const o=e;return o.minArgRequired=s,o.maxArgPossible=i?1/0:t,o.nbrArgRepeating=i,o.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const s=e-t;return e=>{if(e<=s)return e;return s+((e-s)%t||t)}}(t,i),o}var ke;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(ke||(ke={}));const Fe=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),$e=new Set(["START","ACTIVATE_SHEET","COPY","START_SELECTION","SET_SELECTION","ALTER_SELECTION","START_SELECTION_EXPANSION","PREPARE_SELECTION_EXPANSION","STOP_SELECTION","RESIZE_VIEWPORT","SET_VIEWPORT_OFFSET","SELECT_ALL","SELECT_CELL","SELECT_COLUMN","SELECT_ROW","MOVE_POSITION","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY"]),De=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART"]);function Ue(e){return De.has(e.type)}class Pe{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return Be}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const Be=new Pe;var Ve,He,ze,Ze;e.CommandResult=void 0,(Ve=e.CommandResult||(e.CommandResult={}))[Ve.Success=0]="Success",Ve[Ve.CancelledForUnknownReason=1]="CancelledForUnknownReason",Ve[Ve.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",Ve[Ve.MergeIsDestructive=3]="MergeIsDestructive",Ve[Ve.CellIsMerged=4]="CellIsMerged",Ve[Ve.InvalidTarget=5]="InvalidTarget",Ve[Ve.EmptyUndoStack=6]="EmptyUndoStack",Ve[Ve.EmptyRedoStack=7]="EmptyRedoStack",Ve[Ve.NotEnoughElements=8]="NotEnoughElements",Ve[Ve.NotEnoughSheets=9]="NotEnoughSheets",Ve[Ve.MissingSheetName=10]="MissingSheetName",Ve[Ve.DuplicatedSheetName=11]="DuplicatedSheetName",Ve[Ve.DuplicatedSheetId=12]="DuplicatedSheetId",Ve[Ve.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",Ve[Ve.WrongSheetMove=14]="WrongSheetMove",Ve[Ve.WrongSheetPosition=15]="WrongSheetPosition",Ve[Ve.InvalidAnchorZone=16]="InvalidAnchorZone",Ve[Ve.SelectionOutOfBound=17]="SelectionOutOfBound",Ve[Ve.TargetOutOfSheet=18]="TargetOutOfSheet",Ve[Ve.WrongPasteSelection=19]="WrongPasteSelection",Ve[Ve.EmptyClipboard=20]="EmptyClipboard",Ve[Ve.EmptyRange=21]="EmptyRange",Ve[Ve.InvalidRange=22]="InvalidRange",Ve[Ve.InvalidSheetId=23]="InvalidSheetId",Ve[Ve.InputAlreadyFocused=24]="InputAlreadyFocused",Ve[Ve.MaximumRangesReached=25]="MaximumRangesReached",Ve[Ve.InvalidChartDefinition=26]="InvalidChartDefinition",Ve[Ve.EmptyDataSet=27]="EmptyDataSet",Ve[Ve.InvalidDataSet=28]="InvalidDataSet",Ve[Ve.InvalidLabelRange=29]="InvalidLabelRange",Ve[Ve.InvalidAutofillSelection=30]="InvalidAutofillSelection",Ve[Ve.WrongComposerSelection=31]="WrongComposerSelection",Ve[Ve.MinBiggerThanMax=32]="MinBiggerThanMax",Ve[Ve.LowerBiggerThanUpper=33]="LowerBiggerThanUpper",Ve[Ve.MidBiggerThanMax=34]="MidBiggerThanMax",Ve[Ve.MinBiggerThanMid=35]="MinBiggerThanMid",Ve[Ve.FirstArgMissing=36]="FirstArgMissing",Ve[Ve.SecondArgMissing=37]="SecondArgMissing",Ve[Ve.MinNaN=38]="MinNaN",Ve[Ve.MidNaN=39]="MidNaN",Ve[Ve.MaxNaN=40]="MaxNaN",Ve[Ve.ValueUpperInflectionNaN=41]="ValueUpperInflectionNaN",Ve[Ve.ValueLowerInflectionNaN=42]="ValueLowerInflectionNaN",Ve[Ve.MinInvalidFormula=43]="MinInvalidFormula",Ve[Ve.MidInvalidFormula=44]="MidInvalidFormula",Ve[Ve.MaxInvalidFormula=45]="MaxInvalidFormula",Ve[Ve.ValueUpperInvalidFormula=46]="ValueUpperInvalidFormula",Ve[Ve.ValueLowerInvalidFormula=47]="ValueLowerInvalidFormula",Ve[Ve.InvalidSortZone=48]="InvalidSortZone",Ve[Ve.WaitingSessionConfirmation=49]="WaitingSessionConfirmation",Ve[Ve.MergeOverlap=50]="MergeOverlap",Ve[Ve.TooManyHiddenElements=51]="TooManyHiddenElements",Ve[Ve.Readonly=52]="Readonly",Ve[Ve.InvalidOffset=53]="InvalidOffset",Ve[Ve.InvalidViewportSize=54]="InvalidViewportSize",Ve[Ve.FigureDoesNotExist=55]="FigureDoesNotExist",Ve[Ve.DuplicatedFigureId=56]="DuplicatedFigureId",Ve[Ve.DuplicatedChartId=57]="DuplicatedChartId",Ve[Ve.ChartDoesNotExist=58]="ChartDoesNotExist",function(e){e.FormatFromArgument="FormatFromArgument"}(He||(He={})),function(e){e[e.UP=0]="UP",e[e.DOWN=1]="DOWN",e[e.LEFT=2]="LEFT",e[e.RIGHT=3]="RIGHT"}(ze||(ze={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Selection=5]="Selection",e[e.Autofill=6]="Autofill",e[e.Headers=7]="Headers"}(Ze||(Ze={}));const Ge={description:a("Absolute value of a number."),args:_e(`\n value (number) ${a("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(he(e))},isExported:!0},We={description:a("Inverse cosine of a value, in radians."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>Math.abs(t)<=1),a("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},qe={description:a("Inverse hyperbolic cosine of a number."),args:_e(`\n value (number) ${a("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=he(e);return le((()=>t>=1),a("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},je={description:a("Inverse cotangent of a value."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Ye={description:a("Inverse hyperbolic cotangent of a value."),args:_e(`\n value (number) ${a("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=he(e);return le((()=>Math.abs(t)>1),a("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Xe={description:a("Inverse sine of a value, in radians."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>Math.abs(t)<=1),a("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ke={description:a("Inverse hyperbolic sine of a number."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(he(e))},isExported:!0},Qe={description:a("Inverse tangent of a value, in radians."),args:_e(`\n value (number) ${a("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(he(e))},isExported:!0},Je={description:a("Angle from the X axis to a point (x,y), in radians."),args:_e(`\n x (number) ${a("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${a("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 s=he(e),i=he(t);return le((()=>0!==s||0!==i),a("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(i,s)},isExported:!0},et={description:a("Inverse hyperbolic tangent of a number."),args:_e(`\n value (number) ${a("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=he(e);return le((()=>Math.abs(t)<1),a("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},tt={description:a("Rounds number up to nearest multiple of factor."),args:_e(`\n value (number) ${a("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${a("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=1){const s=he(e),i=he(t);return le((()=>i>=0||s<=0),a("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),s.toString())),i?Math.ceil(s/i)*i:0},isExported:!0},st={description:a("Rounds number up to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${a("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"],returnFormat:He.FormatFromArgument,compute:function(e,t=1,s=0){let i=he(t);if(0===i)return 0;const o=he(e);if(i=Math.abs(i),o>=0)return Math.ceil(o/i)*i;return 0===he(s)?-Math.floor(Math.abs(o)/i)*i:-Math.ceil(Math.abs(o)/i)*i},isExported:!0},it={description:a("Rounds number up to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return st.compute(e,t,0)},isExported:!0},ot={description:a("Cosine of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(he(e))},isExported:!0},nt={description:a("Hyperbolic cosine of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(he(e))},isExported:!0},rt={description:a("Cotangent of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},at={description:a("Hyperbolic cotangent of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},lt={description:a("Number of empty values."),args:_e(`\n value1 (any, range) ${a("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${a("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return be(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},ct={description:a("A conditional count across a range."),args:_e(`\n range (range) ${a("The range that is tested against criterion.")}\n criterion (string) ${a("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return xe(e,((e,s)=>{t+=1})),t},isExported:!0},ht={description:a("Count values depending on multiple criteria."),args:_e(`\n criteria_range1 (range) ${a("The range to check against criterion1.")}\n criterion1 (string) ${a("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${a("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) ${a("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return xe(e,((e,s)=>{t+=1})),t},isExported:!0};function dt(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const ut={description:a("Counts number of unique values in a range."),args:_e(`\n value1 (any, range) ${a("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${a("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return be(e,((e,t)=>dt(t)?e.add(t):e),new Set).size}},pt={description:a("Counts number of unique values in a range, filtered by a set of criteria."),args:_e(`\n range (range) ${a("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${a("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${a("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) ${a("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) ${a("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=new Set;return xe(t,((t,i)=>{const o=e[t][i];dt(o)&&s.add(o)})),s.size}},gt={description:a("Cosecant of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},ft={description:a("Hyperbolic cosecant of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},mt={description:a("Converts from another base to decimal."),args:_e(`\n value (string) ${a("The number to convert.")},\n base (number) ${a("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let s=he(t);s=Math.floor(s),le((()=>2<=s&&s<=36),a("The base (%s) must be between 2 and 36 inclusive.",s.toString()));const i=ue(e);if(""===i)return 0;le((()=>!!i.match(/^-?[a-z0-9]+$/i)),a("The value (%s) must be a valid base %s representation.",i,s.toString()));const o=parseInt(i,s);return le((()=>!isNaN(o)),a("The value (%s) must be a valid base %s representation.",i,s.toString())),o},isExported:!0},vt={description:a("Converts an angle value in radians to degrees."),args:_e(`\n angle (number) ${a("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*he(e)/Math.PI},isExported:!0},Et={description:a("Euler's number, e (~2.718) raised to a power."),args:_e(`\n value (number) ${a("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(he(e))},isExported:!0},St={description:a("Rounds number down to nearest multiple of factor."),args:_e(`\n value (number) ${a("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${a("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=1){const s=he(e),i=he(t);return le((()=>i>=0||s<=0),a("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),s.toString())),i?Math.floor(s/i)*i:0},isExported:!0},bt={description:a("Rounds number down to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${a("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"],returnFormat:He.FormatFromArgument,compute:function(e,t=1,s=0){let i=he(t);if(0===i)return 0;const o=he(e);if(i=Math.abs(i),o>=0)return Math.floor(o/i)*i;return 0===he(s)?-Math.ceil(Math.abs(o)/i)*i:-Math.floor(Math.abs(o)/i)*i},isExported:!0},Ct={description:a("Rounds number down to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=1){return bt.compute(e,t,0)},isExported:!0},It={description:a("Whether the provided value is even."),args:_e(`\n value (number) ${a("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=de(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},yt={description:a("Rounds number up to nearest multiple of factor."),args:_e(`\n number (number) ${a("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${a("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=1){return st.compute(e,t,0)},isExported:!0},wt={description:a("Whether the provided value is even."),args:_e(`\n value (number) ${a("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=de(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Tt={description:a("The logarithm of a number, base e (euler's number)."),args:_e(`\n value (number) ${a("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=he(e);return le((()=>t>0),a("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},xt={description:a("Modulo (remainder) operator."),args:_e(`\n dividend (number) ${a("The number to be divided to find the remainder.")}\n divisor (number) ${a("The number to divide by.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=he(t);le((()=>0!==s),a("The divisor must be different from 0."));const i=he(e)%s;return i>0&&s<0||i<0&&s>0?i+s:i},isExported:!0},Rt={description:a("Rounds a number up to the nearest odd integer."),args:_e(`\n value (number) ${a("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e){const t=he(e);let s=Math.ceil(Math.abs(t));return s=1&s?s:s+1,t<0?-s:s},isExported:!0},Lt={description:a("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Mt={description:a("A number raised to a power."),args:_e(`\n base (number) ${a("The number to raise to the exponent power.")}\n exponent (number) ${a("The exponent to raise base to.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=he(e),i=he(t);return le((()=>s>=0||Number.isInteger(i)),a("The exponent (%s) must be an integer when the base is negative.",i.toString())),Math.pow(s,i)},isExported:!0},At={description:a("Result of multiplying a series of numbers together."),args:_e(`\n factor1 (number, range<number>) ${a("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${a("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t=0,s=1;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(s*=i,t+=1);else null!=i&&(s*=de(i),t+=1);return 0===t?0:s},isExported:!0},_t={description:a("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ot={description:a("Random integer between two values, inclusive."),args:_e(`\n low (number) ${a("The low end of the random range.")}\n high (number) ${a("The high end of the random range.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){let s=he(e);Number.isInteger(s)||(s=Math.ceil(s));let i=he(t);return Number.isInteger(i)||(i=Math.floor(i)),le((()=>s<=i),a("The high (%s) must be greater than or equal to the low (%s).",i.toString(),s.toString())),s+Math.ceil((i-s+1)*Math.random())-1},isExported:!0},Nt={description:a("Rounds a number according to standard rules."),args:_e(`\n value (number) ${a("The value to round to places number of places.")}\n places (number, default=0) ${a("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=0){const s=he(e);let i=he(t);const o=Math.abs(s);let n;return 0===i?n=Math.round(o):(Number.isInteger(i)||(i=Math.trunc(i)),n=Math.round(o*Math.pow(10,i))/Math.pow(10,i)),s>=0?n:-n},isExported:!0},kt={description:a("Rounds down a number."),args:_e(`\n value (number) ${a("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${a("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=0){const s=he(e);let i=he(t);const o=Math.abs(s);let n;return 0===i?n=Math.floor(o):(Number.isInteger(i)||(i=Math.trunc(i)),n=Math.floor(o*Math.pow(10,i))/Math.pow(10,i)),s>=0?n:-n},isExported:!0},Ft={description:a("Rounds up a number."),args:_e(`\n value (number) ${a("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${a("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=0){const s=he(e);let i=he(t);const o=Math.abs(s);let n;return 0===i?n=Math.ceil(o):(Number.isInteger(i)||(i=Math.trunc(i)),n=Math.ceil(o*Math.pow(10,i))/Math.pow(10,i)),s>=0?n:-n},isExported:!0},$t={description:a("Secant of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(he(e))},isExported:!0},Dt={description:a("Hyperbolic secant of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(he(e))},isExported:!0},Ut={description:a("Sine of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(he(e))},isExported:!0},Pt={description:a("Hyperbolic sine of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(he(e))},isExported:!0},Bt={description:a("Positive square root of a positive number."),args:_e(`\n value (number) ${a("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e){const t=he(e);return le((()=>t>=0),a("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},Vt={description:a("Sum of a series of numbers and/or cells."),args:_e(`\n value1 (number, range<number>) ${a("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${a("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){return Ce(e,((e,t)=>e+t),0)},isExported:!0},Ht={description:a("A conditional sum across a range."),args:_e(`\n criteria_range (range) ${a("The range which is tested against criterion.")}\n criterion (string) ${a("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${a("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,s){void 0===s&&(s=e);let i=0;return xe([e,t],((e,t)=>{const o=s[e][t];"number"==typeof o&&(i+=o)})),i},isExported:!0},zt={description:a("Sums a range depending on multiple criteria."),args:_e(`\n sum_range (range) ${a("The range to sum.")}\n criteria_range1 (range) ${a("The range to check against criterion1.")}\n criterion1 (string) ${a("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${a("Additional ranges to check.")}\n criterion2 (string, repeating) ${a("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=0;return xe(t,((t,i)=>{const o=e[t][i];"number"==typeof o&&(s+=o)})),s},isExported:!0},Zt={description:a("Tangent of an angle provided in radians."),args:_e(`\n angle (number) ${a("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(he(e))},isExported:!0},Gt={description:a("Hyperbolic tangent of any real number."),args:_e(`\n value (number) ${a("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(he(e))},isExported:!0},Wt={description:a("Truncates a number."),args:_e(`\n value (number) ${a("The value to be truncated.")}\n places (number, default=0) ${a("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t=0){const s=he(e);let i=he(t);return 0===i?Math.trunc(s):(Number.isInteger(i)||(i=Math.trunc(i)),Math.trunc(s*Math.pow(10,i))/Math.pow(10,i))},isExported:!0};var qt=Object.freeze({__proto__:null,ABS:Ge,ACOS:We,ACOSH:qe,ACOT:je,ACOTH:Ye,ASIN:Xe,ASINH:Ke,ATAN:Qe,ATAN2:Je,ATANH:et,CEILING:tt,CEILING_MATH:st,CEILING_PRECISE:it,COS:ot,COSH:nt,COT:rt,COTH:at,COUNTBLANK:lt,COUNTIF:ct,COUNTIFS:ht,COUNTUNIQUE:ut,COUNTUNIQUEIFS:pt,CSC:gt,CSCH:ft,DECIMAL:mt,DEGREES:vt,EXP:Et,FLOOR:St,FLOOR_MATH:bt,FLOOR_PRECISE:Ct,ISEVEN:It,ISO_CEILING:yt,ISODD:wt,LN:Tt,MOD:xt,ODD:Rt,PI:Lt,POWER:Mt,PRODUCT:At,RAND:_t,RANDBETWEEN:Ot,ROUND:Nt,ROUNDDOWN:kt,ROUNDUP:Ft,SEC:$t,SECH:Dt,SIN:Ut,SINH:Pt,SQRT:Bt,SUM:Vt,SUMIF:Ht,SUMIFS:zt,TAN:Zt,TANH:Gt,TRUNC:Wt});const jt=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function Yt(e){return e.toString(16).padStart(6,"0")}let Xt=0;function Kt(){return Xt=++Xt%jt.length,jt[Xt]}function Qt(e){return e.includes("rgb")?function(e){return e.slice(4,-1).split(",").map((e=>parseInt(e,10).toString(16).padStart(2,"0"))).join("").toUpperCase()}(e):(3===(e=e.replace("#","").toUpperCase()).length&&(e=e.split("").reduce(((e,t)=>e+t+t),"")),e)}const Jt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),es=new RegExp(/^\s*(.*!)?\$?[A-Z]{1,3}\$?[0-9]{1,7}\s*(\s*:\s*\$?[A-Z]{1,3}\$?[0-9]{1,7}\s*)?$/,"i");function ts(e){const t=e.split("!"),s=t.pop();return{sheetName:t.join("!")||void 0,xc:s}}function ss(e){return e<26?String.fromCharCode(65+e):ss(Math.floor(e/26)-1)+ss(e%26)}function is(e){e=e.toUpperCase().trim();const[t,s,i]=e.match(Jt);if(t!==e)throw new Error(`Invalid cell description: ${e}`);const o=function(e){let t=0;const s=e.length;for(let i=0;i<s;i++)t+=(e.charCodeAt(i)-65+(i<s-1?1:0))*26**(s-i-1);return t}(s);return[o,parseInt(i,10)-1]}function os(e,t,s={colFixed:!1,rowFixed:!1}){return(s.colFixed?"$":"")+ss(e)+(s.rowFixed?"$":"")+String(t+1)}const ns=140,rs=20,as=.035;function ls(e){return rs+(ns-rs)*Math.exp(-as*(e-1))}const cs=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48}],hs={};for(let e of cs)hs[e.pt]=e.px;function ds(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function us(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(!(function(e){return"object"==typeof e&&(null==e?void 0:e.constructor)===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const s in e)t[s]=us(e[s]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function ps(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function gs(e,t,s){return e<t?t:e>s?s:e}function fs(e,t,s){const i=s.italic?"italic ":"",o=s.bold?"bold":T,n=s.fontSize||x,r=hs[n];return e.font=`${i}${o} ${r}px ${R}`,e.measureText(t).width}function ms(e,t,s=1){if(t<=e&&s>0)return[];if(0===s)throw new Error("range() step must not be zero");const i=Math.ceil(Math.abs((t-e)/s)),o=Array(i);for(let t=0;t<i;t++)o[t]=e+t*s;return o}function vs(e){return e.reduce(((e,t,s,i)=>{if(1===Math.abs(t-i[s-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Es(e,t){t.next();for(const s of e){const e=t.next();yield{...s,next:e.done?void 0:e.value}}}function Ss(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}function bs(e){return null!==G(e)}const Cs=/^\[(.+)\]\((.+)\)$/,Is=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function ys(e){return Cs.test(e)}function ws(e,t){return`[${e}](${t})`}function Ts(e){const t=e.match(Cs)||[],s=t[1],i=t[2];if(!s||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:s,url:i}}const xs="o-spreadsheet://";function Rs(e){if(!ys(e))return!1;const{url:t}=Ts(e);return t.startsWith(xs)}function Ls(e){if(e.startsWith(xs))return e.substr(xs.length);throw new Error(`${e} is not a valid sheet link`)}function Ms(e){return void 0!==e}const As={};function _s(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return!1;const s=new Set;Object.keys(e).forEach((e=>s.add(e))),Object.keys(t).forEach((e=>s.add(e)));for(let i of s){if(typeof e[i]!=typeof e[i])return!1;if("object"==typeof e[i]){if(!_s(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function Os(e){let t=e.length;if(t<1e5)return Math.max(...e);let s=-1/0;for(;t--;)s=e[t]>s?e[t]:s;return s}function Ns(e){let t=e.length;if(t<1e5)return Math.min(...e);let s=1/0;for(;t--;)s=e[t]<s?e[t]:s;return s}function ks(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":");let s,i,o,n,r=is(t[0].trim());if(o=n=r[0],s=i=r[1],2===t.length){let e=is(t[1].trim());n=e[0],i=e[1]}return{top:s,bottom:i,left:o,right:n}}function Fs(e){let{top:t,bottom:s,left:i,right:o}=ks(e);return o<i&&([o,i]=[i,o]),s<t&&([s,t]=[t,s]),{top:t,bottom:s,left:i,right:o}}function $s(e){return!(isNaN(e.bottom)||isNaN(e.top)||isNaN(e.left)||isNaN(e.right))&&(!(e.top<0||e.left<0||e.right<0||e.bottom<0)&&(e.bottom>=e.top&&e.right>=e.left))}function Ds(e){const{top:t,bottom:s,left:i,right:o}=e;return t===s&&i===o?os(i,t):`${os(i,t)}:${os(o,s)}`}function Us(e,t,s,i,o){const n="left"===t?"columns":"rows",r="before"===i?s-1:s,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?Xs(e,n,"RESIZE",o):r<e[t]?Xs(e,n,"MOVE",o):{...e}}function Ps(e,t,s){const i="left"===t?"right":"bottom";let o=e[t],n=e[i];for(let r of s.sort(((e,t)=>t-e)))e[t]>r&&(o--,n--),e[t]<r&&e[i]>=r&&n--;return{...e,[t]:o,[i]:n}}function Bs(e,t){return{top:Math.min(e.top,t.top),left:Math.min(e.left,t.left),bottom:Math.max(e.bottom,t.bottom),right:Math.max(e.right,t.right)}}function Vs(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Hs(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function zs(e,t,s){const{left:i,right:o,top:n,bottom:r}=s;return e>=i&&e<=o&&t>=n&&t<=r}function Zs(e,t){const s={};for(let t of e)if(t){const e=Fs(t);for(let t=e.left;t<=e.right;t++)void 0===s[t]&&(s[t]=[]),s[t].push({top:e.top,bottom:e.bottom,remove:!1})}for(let e of t){const t=Fs(e);for(let e=t.left;e<=t.right;e++)void 0===s[e]&&(s[e]=[]),s[e].push({top:t.top,bottom:t.bottom,remove:!0})}const i=[];for(let[e,t]of Object.entries(s))i.push({col:parseInt(e),ranges:Gs(t)});return function(e){const t=e.sort(((e,t)=>e.col-t.col)),s=[];let i=[],o=0;for(let e=0;e<=t.length-1;e++){let n=[];if(o+1===t[e].col)for(let s of t[e].ranges){let o=!1;for(let e of i)s.top==e.top&&s.bottom==e.bottom&&(n.push(e),o=!0);o||n.push({top:s.top,bottom:s.bottom,startCol:t[e].col})}else n=t[e].ranges.map((s=>({top:s.top,bottom:s.bottom,startCol:t[e].col})));const r=i.filter((e=>!n.includes(e)));for(let e of r)s.push({top:e.top,bottom:e.bottom,left:e.startCol,right:o});o=t[e].col,i=n}for(let e of i)s.push({top:e.top,bottom:e.bottom,left:e.startCol,right:o});return s}(i).map(Ds)}function Gs(e){const t=new Set,s=new Set;for(let i of e)for(let e=i.top;e<=i.bottom;e++)i.remove?s.add(e):t.add(e);const i=[...t].filter((e=>!s.has(e))).sort(((e,t)=>e-t)),o=[];let n;for(let e of i)n?e===n.bottom+1?n.bottom=e:(o.push({top:n.top,bottom:n.bottom}),n={top:e,bottom:e}):n={top:e,bottom:e};return n&&o.push({top:n.top,bottom:n.bottom}),o}function Ws(e,t,s,i,o=1,n=1){var r;const{top:a,bottom:l,left:c,right:h}=e,d=new Array(Math.floor((h-c+1)/o));for(let e=c;e<=h;e+=o){let o=new Array(Math.floor((l-a+1)/n));d[e-c]=o;for(let c=a;c<=l;c+=n){let l=null===(r=t.rows[c])||void 0===r?void 0:r.cells[e];o[(c-a)/n]=l?s(l):i}}return d}function qs(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function js(e){const{width:t,height:s}=qs(e);return 1===t||1===s}function Ys(e){const t=[],[s,i]=[e.right,e.left].sort(((e,t)=>e-t)),[o,n]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ms(s,i+1))for(const s of ms(o,n+1))t.push([e,s]);return t}function Xs(e,t,s,i){const o="columns"===t?"right":"bottom",n={...e};return"MOVE"===s&&(n["columns"===t?"left":"top"]+=i),n[o]+=i,n}function Ks(e){return e.reverse().filter(((e,t,s)=>t===s.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}function Qs(e){return{top:Math.min(e.top,e.bottom),bottom:Math.max(e.top,e.bottom),left:Math.min(e.left,e.right),right:Math.max(e.left,e.right)}}function Js(e){const t=[];let s=0;for(let i=0;i<e;i++){const e={start:s,end:s+E,size:E,name:ss(i)};t.push(e),s=e.end}return t}function ei(e){const t=[];let s=0;for(let i=0;i<e;i++){const e={start:s,end:s+S,size:S,name:String(i+1),cells:{}};t.push(e),s=e.end}return t}function ti(e,t){var s;const i=[];let o=0;for(let n=0;n<t;n++){const t=e[n]&&e[n].size||E,r=(null===(s=e[n])||void 0===s?void 0:s.isHidden)||!1,a={start:o,end:r?o:o+t,size:t,name:ss(n)};r&&(a.isHidden=r),i.push(a),o=a.end}return i}function si(e,t){var s;const i=[];let o=0;for(let n=0;n<t;n++){const t=e[n]&&e[n].size||S,r=(null===(s=e[n])||void 0===s?void 0:s.isHidden)||!1,a={start:o,end:r?o:o+t,size:t,name:String(n+1),cells:{}};r&&(a.isHidden=r),i.push(a),o=a.end}return i}function ii(e,t=!1){const s={};for(let i in e){const o=e[i];(o.size!==E||t)&&(s[i]={size:o.size}),o.isHidden&&(s[i]=s[i]||{},s[i].isHidden=o.isHidden)}return s}function oi(e,t=!1){const s={};for(let i in e){const o=e[i];(o.size!==S||t)&&(s[i]={size:o.size}),o.isHidden&&(s[i]=s[i]||{},s[i].isHidden=o.isHidden)}return s}class ni{constructor(e=!1){this.isFastIdStrategy=!1,this.fastIdStart=0,this.setIsFastStrategy(e)}setIsFastStrategy(e){this.isFastIdStrategy=e}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto&&window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))):"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}}function ri(e,t,s){return[ai(e,"cols",ms(t,e.cols.length)),ai(e,"rows",ms(s,e.rows.length))]}function ai(e,t,s){const i=e[t];return s.find((e=>!i[e].isHidden))}function li(e,t){let s=e[t].length-1;for(;s>=0&&!0===e[t][s].isHidden;)s--;return e[t][s]}function ci(e,t,s){let i=[],o=[],n=0,r=0;ve([e],(e=>{i.push(e),n+=1})),ve([t],(e=>{o.push(e),r+=1})),le((()=>n===r),a("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",n.toString(),r.toString()));let l=0,c=0,h=0;for(let e=0;e<n;e++){const t=i[e],s=o[e];"number"==typeof t&&"number"==typeof s&&(l+=1,c+=t,h+=s)}le((()=>0!==l&&(!s||1!==l)),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let p=0;for(let e=0;e<n;e++){const t=i[e],s=o[e];"number"==typeof t&&"number"==typeof s&&(p+=(t-d)*(s-u))}return p/(l-(s?1:0))}function hi(e,t,s){let i=0,o=0;const n=s?Ie:Ce;o=n(e,((e,t)=>(i+=1,e+t)),0),le((()=>0!==i&&(!t||1!==i)),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const r=o/i;return n(e,((e,t)=>e+Math.pow(t-r,2)),0)/(i-(t?1:0))}function di(e,t,s){const i=he(t);le((()=>s?0<=i&&i<=1:0<i&&i<1),a("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let o,n=[],r=0;ve(e,(e=>{"number"==typeof e&&(o=Re(n,e),n.splice(o+1,0,e),r++)})),le((()=>0!==r),a("[[FUNCTION_NAME]] has no valid input data."));let l=(r+(s?-1:1))*i;if(s||(le((()=>1<=l&&l<=r),a("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),l--),Number.isInteger(l))return n[l];const c=Math.ceil(l),h=Math.floor(l);return n[c]*(l-h)+n[h]*(c-l)}const ui={description:a("Average magnitude of deviations from mean."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const s=Ce(e,((e,s)=>(t+=1,e+s)),0);le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const i=s/t;return Ce(e,((e,t)=>e+Math.abs(i-t)),0)/t},isExported:!0},pi={description:a("Numerical average value in a dataset, ignoring text."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t=0;const s=Ce(e,((e,s)=>(t+=1,e+s)),0);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),s/t},isExported:!0},gi=a("[[FUNCTION_NAME]] has mismatched range sizes."),fi=a("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),mi={description:a("Weighted average."),args:_e(`\n values (number, range<number>) ${a("Values to average.")}\n weights (number, range<number>) ${a("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${a("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${a("Additional weights.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t,s,i=0,o=0;le((()=>e.length%2==0),a("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let n=0;n<e.length-1;n+=2)if(t=e[n],s=e[n+1],Array.isArray(t)){le((()=>Array.isArray(s)),gi);let e=t.length,n=t[0].length;le((()=>e===s.length&&n===s[0].length),gi);for(let r=0;r<e;r++)for(let e=0;e<n;e++){let n=t[r][e],l=s[r][e],c="number"==typeof n,h="number"==typeof l;le((()=>c===h),a("[[FUNCTION_NAME]] expects number values.")),h&&(le((()=>l>=0),fi),i+=n*l,o+=l)}}else s=he(s),t=he(t),le((()=>s>=0),fi),i+=t*s,o+=s;return le((()=>0!==o),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/o}},vi={description:a("Numerical average value in a dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t=0;const s=Ie(e,((e,s)=>(t+=1,e+s)),0);return le((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),s/t},isExported:!0},Ei={description:a("Average of values depending on criteria."),args:_e(`\n criteria_range (range) ${a("The range to check against criterion.")}\n criterion (string) ${a("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${a("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,s){null==s&&(s=e);let i=0,o=0;return xe([e,t],((t,n)=>{const r=(s||e)[t][n];"number"==typeof r&&(i+=1,o+=r)})),le((()=>0!==i),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},Si={description:a("Average of values depending on multiple criteria."),args:_e(`\n average_range (range) ${a("The range to average.")}\n criteria_range1 (range) ${a("The range to check against criterion1.")}\n criterion1 (string) ${a("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${a("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${a("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=0,i=0;return xe(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(s+=1,i+=n)})),le((()=>0!==s),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/s},isExported:!0},bi={description:a("The number of numeric values in dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let s of e)if(Array.isArray(s))for(let e of s)for(let s of e)"number"==typeof s&&(t+=1);else("string"!=typeof s||J(s)||G(s))&&(t+=1);return t},isExported:!0},Ci={description:a("The number of values in a dataset."),args:_e(`\n value1 (any, range) ${a("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${a("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return be(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Ii={description:a("The covariance of a dataset."),args:_e(`\n data_y (any, range) ${a("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${a("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ci(e,t,!1)},isExported:!0},yi={description:a("The covariance of a dataset."),args:_e(`\n data_y (any, range) ${a("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${a("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ci(e,t,!1)},isExported:!0},wi={description:a("The sample covariance of a dataset."),args:_e(`\n data_y (any, range) ${a("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${a("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ci(e,t,!0)},isExported:!0},Ti={description:a("Nth largest element from a data set."),args:_e(`\n data (any, range) ${a("Array or range containing the dataset to consider.")}\n n (number) ${a("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=Math.trunc(he(t));let i,o=[],n=0;ve([e],(e=>{"number"==typeof e&&(i=Re(o,e),o.splice(i+1,0,e),n++,n>s&&(o.shift(),n--))}));const r=o.shift();return le((()=>void 0!==r),a("[[FUNCTION_NAME]] has no valid input data.")),le((()=>n>=s),a("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",s.toString())),r},isExported:!0},xi={description:a("Maximum value in a numeric dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){const t=Ce(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Ri={description:a("Maximum numeric value in a dataset."),args:_e(`\n value1 (any, range) ${a("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${a("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){const t=Ie(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Li={description:a("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:_e(`\n range (range) ${a("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${a("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${a("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) ${a("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) ${a("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=-1/0;return xe(t,((t,i)=>{const o=e[t][i];"number"==typeof o&&(s=s<o?o:s)})),s===-1/0?0:s},isExported:!0},Mi={description:a("Median value in a numeric dataset."),args:_e(`\n value1 (any, range) ${a("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${a("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){let t=[];return Ee(e,(e=>{t.push(e)})),di(t,.5,!0)},isExported:!0},Ai={description:a("Minimum value in a numeric dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){const t=Ce(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},_i={description:a("Minimum numeric value in a dataset."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(...e){const t=Ie(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Oi={description:a("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:_e(`\n range (range) ${a("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${a("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${a("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) ${a("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) ${a("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let s=1/0;return xe(t,((t,i)=>{const o=e[t][i];"number"==typeof o&&(s=s>o?o:s)})),s===1/0?0:s},isExported:!0},Ni={description:a("Value at a given percentile of a dataset."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n percentile (number) ${a("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return Fi.compute(e,t)},isExported:!0},ki={description:a("Value at a given percentile of a dataset exclusive of 0 and 1."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n percentile (number) ${a("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return di([e],t,!1)},isExported:!0},Fi={description:a("Value at a given percentile of a dataset."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n percentile (number) ${a("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return di([e],t,!0)},isExported:!0},$i={description:a("Value nearest to a specific quartile of a dataset."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n quartile_number (number) ${a("Which quartile value to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return Ui.compute(e,t)},isExported:!0},Di={description:a("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n quartile_number (number) ${a("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return di([e],.25*Math.trunc(he(t)),!1)},isExported:!0},Ui={description:a("Value nearest to a specific quartile of a dataset."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n quartile_number (number) ${a("Which quartile value to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return di([e],.25*Math.trunc(he(t)),!0)},isExported:!0},Pi={description:a("Nth smallest element in a data set."),args:_e(`\n data (any, range) ${a("The array or range containing the dataset to consider.")}\n n (number) ${a("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=Math.trunc(he(t));let i,o=[],n=0;ve([e],(e=>{"number"==typeof e&&(i=Re(o,e),o.splice(i+1,0,e),n++,n>s&&(o.pop(),n--))}));const r=o.pop();return le((()=>void 0!==r),a("[[FUNCTION_NAME]] has no valid input data.")),le((()=>n>=s),a("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",s.toString())),r},isExported:!0},Bi={description:a("Standard deviation."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Wi.compute(...e))},isExported:!0},Vi={description:a("Standard deviation of entire population."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(qi.compute(...e))},isExported:!0},Hi={description:a("Standard deviation."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(ji.compute(...e))},isExported:!0},zi={description:a("Standard deviation of sample (text as 0)."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Yi.compute(...e))},isExported:!0},Zi={description:a("Standard deviation of entire population."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Xi.compute(...e))},isExported:!0},Gi={description:a("Standard deviation of entire population (text as 0)."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ki.compute(...e))},isExported:!0},Wi={description:a("Variance."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!0,!1)},isExported:!0},qi={description:a("Variance of entire population."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!1,!1)},isExported:!0},ji={description:a("Variance."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!0,!1)},isExported:!0},Yi={description:a("Variance of sample (text as 0)."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!0,!0)},isExported:!0},Xi={description:a("Variance of entire population."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!1,!1)},isExported:!0},Ki={description:a("Variance of entire population (text as 0)."),args:_e(`\n value1 (number, range<number>) ${a("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${a("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return hi(e,!1,!0)},isExported:!0};var Qi=Object.freeze({__proto__:null,AVEDEV:ui,AVERAGE:pi,AVERAGE_WEIGHTED:mi,AVERAGEA:vi,AVERAGEIF:Ei,AVERAGEIFS:Si,COUNT:bi,COUNTA:Ci,COVAR:Ii,COVARIANCE_P:yi,COVARIANCE_S:wi,LARGE:Ti,MAX:xi,MAXA:Ri,MAXIFS:Li,MEDIAN:Mi,MIN:Ai,MINA:_i,MINIFS:Oi,PERCENTILE:Ni,PERCENTILE_EXC:ki,PERCENTILE_INC:Fi,QUARTILE:$i,QUARTILE_EXC:Di,QUARTILE_INC:Ui,SMALL:Pi,STDEV:Bi,STDEV_P:Vi,STDEV_S:Hi,STDEVA:zi,STDEVP:Zi,STDEVPA:Gi,VAR:Wi,VAR_P:qi,VAR_S:ji,VARA:Yi,VARP:Xi,VARPA:Ki});function Ji(e,t,s){var i;const o=new Map,n=e.length;for(let t=n-1;t>=0;t--)o.set(ue(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(a("The field must be a number or a string"));let r;if("number"==typeof t){if(r=Math.trunc(t)-1,r<0||n-1<r)throw new Error(a("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),n.toString()))}else{const e=ue(t).toUpperCase();if(r=null!==(i=o.get(e))&&void 0!==i?i:-1,-1===r)throw new Error(a("The field (%s) must be one of %s.",ue(t),[...o.keys()].toString()))}const l=s[0].length;if(l<2)throw new Error(a("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 i=[],n=!0;for(let r=0;r<s.length;r++){const a=ue(s[r][0]).toUpperCase(),l=o.get(a),c=s[r][t];if(void 0!==c){if(void 0===l){n=!1;break}i.push([e[l].slice(1,h)]),i.push(c)}}if(n){if(!(i.length>0)){c=new Set(Array(h-1).keys());break}xe(i,((e,t)=>{c.add(t)}),!0)}}const d=e[r];return[...c].map((e=>d[e+1]))}const eo=_e(`\n database (range) ${a("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) ${a("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${a("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),to={description:a("Average of a set of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return pi.compute([i])},isExported:!0},so={description:a("Counts values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return bi.compute([i])},isExported:!0},io={description:a("Counts values and text from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Ci.compute([i])},isExported:!0},oo={description:a("Single value from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return le((()=>1===i.length),a("More than one match found in DGET evaluation.")),i[0]},isExported:!0},no={description:a("Maximum of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return xi.compute([i])},isExported:!0},ro={description:a("Minimum of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Ai.compute([i])},isExported:!0},ao={description:a("Product of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return At.compute([i])},isExported:!0},lo={description:a("Standard deviation of population sample from table."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Bi.compute([i])},isExported:!0},co={description:a("Standard deviation of entire population from table."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Zi.compute([i])},isExported:!0},ho={description:a("Sum of values from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Vt.compute([i])},isExported:!0},uo={description:a("Variance of population sample from table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Wi.compute([i])},isExported:!0},po={description:a("Variance of a population from a table-like range."),args:eo,returns:["NUMBER"],compute:function(e,t,s){const i=Ji(e,t,s);return Xi.compute([i])},isExported:!0};var go=Object.freeze({__proto__:null,DAVERAGE:to,DCOUNT:so,DCOUNTA:io,DGET:oo,DMAX:no,DMIN:ro,DPRODUCT:ao,DSTDEV:lo,DSTDEVP:co,DSUM:ho,DVAR:uo,DVARP:po});const fo=new D(1899,11,30);function mo(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}const vo={description:a("Converts year/month/day into a date."),args:_e(`\n year (number) ${a("The year component of the date.")}\n month (number) ${a("The month component of the date.")}\n day (number) ${a("The day component of the date.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t,s){let i=Math.trunc(he(e));const o=Math.trunc(he(t)),n=Math.trunc(he(s));le((()=>0<=i&&i<=9999),a("The year (%s) must be between 0 and 9999 inclusive.",i.toString())),i<1900&&(i+=1900);const r=new D(i,o-1,n).getTime()-fo.getTime();return le((()=>r>=0),a("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),Math.round(r/864e5)},isExported:!0},Eo={description:a("Converts a date string to a date value."),args:_e(`\n date_string (string) ${a("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=ue(e),s=G(t);return le((()=>null!==s),a("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(s.value)},isExported:!0},So={description:a("Day of the month that a specific date falls on."),args:_e(`\n date (string) ${a("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getDate()},isExported:!0},bo={description:a("Number of days between two dates."),args:_e(`\n end_date (date) ${a("The end of the date range.")}\n start_date (date) ${a("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const s=fe(e),i=fe(t),o=s.getTime()-i.getTime();return Math.round(o/864e5)},isExported:!0},Co={description:a("Date a number of months before/after another date."),args:_e(`\n start_date (date) ${a("The date from which to calculate the result.")}\n months (number) ${a("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t){const s=fe(e),i=Math.trunc(he(t)),o=s.getFullYear(),n=s.getMonth(),r=s.getDate(),a=new D(o,n+i,r).getTime()-fo.getTime();return Math.round(a/864e5)},isExported:!0},Io={description:a("Last day of a month before or after a date."),args:_e(`\n start_date (date) ${a("The date from which to calculate the result.")}\n months (number) ${a("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t){const s=fe(e),i=Math.trunc(he(t)),o=s.getFullYear(),n=s.getMonth(),r=new D(o,n+i+1,0).getTime()-fo.getTime();return Math.round(r/864e5)},isExported:!0},yo={description:a("Hour component of a specific time."),args:_e(`\n time (date) ${a("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getHours()},isExported:!0},wo={description:a("ISO week number of the year."),args:_e(`\n date (date) ${a("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=fe(e),s=t.getFullYear();let i=1;for(;4!==new D(s,0,i).getDay();)i+=1;const o=new D(s,0,i-3);let n=31;for(;4!==new D(s,11,n).getDay();)n-=1;const r=new D(s,11,n+3);let a,l;switch(a=o.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=o;break;case 1:l=new D(s,11,n+3+1);break;case-1:let e=1;for(;4!==new D(s-1,0,e).getDay();)e+=1;l=new D(s-1,0,e-3)}const c=(t.getTime()-l.getTime())/864e5;return Math.floor(c/7)+1},isExported:!0},To={description:a("Minute component of a specific time."),args:_e(`\n time (date) ${a("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getMinutes()},isExported:!0},xo={description:a("Month of the year a specific date falls in"),args:_e(`\n date (date) ${a("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getMonth()+1},isExported:!0},Ro={description:a("Net working days between two provided days."),args:_e(`\n start_date (date) ${a("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${a("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${a("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,s){return Mo.compute(e,t,1,s)},isExported:!0};function Lo(e){if("string"==typeof e){le((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),a('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let s=0;s<7;s++)"1"===e[s]&&t.push((s+1)%7);return t}if("number"==typeof e)return le((()=>1<=e&&e<=7||11<=e&&e<=17),a("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(a("The weekend (%s) must be a number or a string.",e.toString()))}const Mo={description:a("Net working days between two dates (specifying weekends)."),args:_e(`\n start_date (date) ${a("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${a("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${a("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${a("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,s=1,i){const o=fe(e),n=fe(t),r=Lo(s);let a=new Set;void 0!==i&&ve([i],(e=>{const t=fe(e);a.add(t.getTime())}));const l=o.getTime()>n.getTime(),c=D.fromTimestamp((l?o:n).getTime());let h=D.fromTimestamp((l?n:o).getTime());const d=c.getTime();let u=h.getTime(),p=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(p+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-p:p},isExported:!0},Ao={description:a("Current date and time as a date value."),args:[],returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy hh:mm:ss"},compute:function(){let e=D.now();const t=e.getTime()-fo.getTime(),s=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/864e5)+s},isExported:!0},_o={description:a("Minute component of a specific time."),args:_e(`\n time (date) ${a("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getSeconds()},isExported:!0},Oo={description:a("Converts hour/minute/second into a time."),args:_e(`\n hour (number) ${a("The hour component of the time.")}\n minute (number) ${a("The minute component of the time.")}\n second (number) ${a("The second component of the time.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"hh:mm:ss a"},compute:function(e,t,s){let i=Math.trunc(he(e)),o=Math.trunc(he(t)),n=Math.trunc(he(s));return o+=Math.floor(n/60),n=n%60+(n<0?60:0),i+=Math.floor(o/60),o=o%60+(o<0?60:0),i%=24,le((()=>i>=0),a("The function [[FUNCTION_NAME]] result cannot be negative")),i/24+o/1440+n/86400},isExported:!0},No={description:a("Converts a time string into its serial number representation."),args:_e(`\n time_string (string) ${a("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=ue(e),s=G(t);le((()=>null!==s),a("The time_string (%s) cannot be parsed to date/time.",t));const i=s.value-Math.trunc(s.value);return i<0?1+i:i},isExported:!0},ko={description:a("Current date as a date value."),args:[],returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(){const e=D.now(),t=new D(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-fo.getTime();return Math.round(t/864e5)},isExported:!0},Fo={description:a("Day of the week of the date provided (as number)."),args:_e(`\n date (date) ${a("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) ${a("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 s=fe(e),i=Math.round(he(t)),o=s.getDay();return le((()=>[1,2,3].includes(i)),a("The type (%s) must be 1, 2 or 3.",i.toString())),1===i?o+1:2===i?0===o?7:o:0===o?6:o-1},isExported:!0},$o={description:a("Week number of the year."),args:_e(`\n date (date) ${a("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) ${a("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const s=fe(e),i=Math.round(he(t));if(le((()=>1===i||2===i||11<=i&&i<=17||21===i),a("The type (%s) is out of range.",i.toString())),21===i)return wo.compute(e);let o;o=1===i||2===i?i-1:i-10==7?0:i-10;const n=s.getFullYear();let r=1,l=new D(n,0,r);for(;l.getDay()!==o;)r+=1,l=new D(n,0,r);const c=(s.getTime()-l.getTime())/864e5;return c<0?1:Math.floor(c/7)+(1===r?1:2)},isExported:!0},Do={description:a("Number of working days from start date."),args:_e(`\n start_date (date) ${a("The date from which to begin counting.")}\n num_days (number) ${a("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${a("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t,s){return Uo.compute(e,t,1,s)},isExported:!0},Uo={description:a("Net working days between two dates (specifying weekends)."),args:_e(`\n start_date (date) ${a("The date from which to begin counting.")}\n num_days (number) ${a("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${a("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${a("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],returnFormat:{specificFormat:"m/d/yyyy"},compute:function(e,t,s=1,i){let o=fe(e),n=Math.trunc(he(t));"string"==typeof s&&le((()=>"1111111"!==s),a("The weekend (%s) must be different from '1111111'.",s));const r=Lo(s);let l=new Set;void 0!==i&&ve([i],(e=>{const t=fe(e);l.add(t.getTime())}));let c=D.fromTimestamp(o.getTime()),h=c.getTime();const d=Math.sign(n);let u=Math.abs(n);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),r.includes(c.getDay())||l.has(h)||(u-=1);const p=h-fo.getTime();return Math.round(p/864e5)},isExported:!0},Po={description:a("Year specified by a given date."),args:_e(`\n date (date) ${a("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return fe(e).getFullYear()},isExported:!0},Bo={description:a("Exact number of years between two dates."),args:_e(`\n start_date (date) ${a("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) ${a("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) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s=0){let i=Math.trunc(he(e)),o=Math.trunc(he(t));const n=Math.trunc(he(s));if(le((()=>i>=0),a("The start_date (%s) must be positive or null.",i.toString())),le((()=>o>=0),a("The end_date (%s) must be positive or null.",o.toString())),le((()=>0<=n&&n<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),i===o)return 0;if(i>o){const e=o;o=i,i=e}const r=fe(i),l=fe(o);let c=r.getDate(),h=l.getDate();const d=r.getMonth(),u=l.getMonth(),p=r.getFullYear(),g=l.getFullYear();let f=0,m=0;switch(n){case 0:31===c&&(c=30),30===c&&31===h&&(h=30),1===d&&c===(mo(p)?29:28)&&(c=30,1===u&&h===(mo(g)?29:28)&&(h=30)),f=p+(30*d+c)/360,m=g+(30*u+h)/360;break;case 1:let e=365;const t=p===g;if(!t&&!(p+1===g)||!t&&d<u||!t&&d===u&&c<h){let t=0,s=0;for(let e=p;e<=g;e++)t++,s+=mo(e)?366:365;e=s/t}else t?mo(p)&&(e=366):(mo(p)&&d<2&&(e=366),mo(g)&&(u>1||1===u&&29===h)&&(e=366));f=i/e,m=o/e;break;case 2:f=i/360,m=o/360;break;case 3:f=i/365,m=o/365;break;case 4:31===c&&(c=30),31===h&&(h=30),f=p+(30*d+c)/360,m=g+(30*u+h)/360}return m-f}};var Vo=Object.freeze({__proto__:null,DATE:vo,DATEVALUE:Eo,DAY:So,DAYS:bo,EDATE:Co,EOMONTH:Io,HOUR:yo,ISOWEEKNUM:wo,MINUTE:To,MONTH:xo,NETWORKDAYS:Ro,NETWORKDAYS_INTL:Mo,NOW:Ao,SECOND:_o,TIME:Oo,TIMEVALUE:No,TODAY:ko,WEEKDAY:Fo,WEEKNUM:$o,WORKDAY:Do,WORKDAY_INTL:Uo,YEAR:Po,YEARFRAC:Bo});function Ho(e,t,s,i,o=1e-10){let n,r,l,c=s,h=!1,d=0;do{l=e(c),n=c-l/t(c),r=Math.abs(n-c),c=n,h=r<o||Math.abs(l)<o,le((()=>d<i),a("Function [[FUNCTION_NAME]] didn't find any result")),d++}while(!h);return c}const zo={description:a("Depreciation via declining balance method."),args:_e(`\n cost (number) ${a("The initial cost of the asset.")}\n salvage (number) ${a("The value of the asset at the end of depreciation.")}\n life (number) ${a("The number of periods over which the asset is depreciated.")}\n period (number) ${a("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${a("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"#,##0.00"},compute:function(e,t,s,i,...o){const n=he(e),r=he(t),l=he(s),c=Math.trunc(he(i)),h=o.length?Math.trunc(he(o[0])):12,d=l+(12===h?0:1);le((()=>n>0),a("The cost (%s) must be strictly positive.",n.toString())),le((()=>r>=0),a("The salvage (%s) must be positive or null.",r.toString())),le((()=>l>0),a("The life (%s) must be strictly positive.",l.toString())),le((()=>c>0),a("The period (%s) must be strictly positive.",c.toString())),le((()=>1<=h&&h<=12),a("The month (%s) must be between 1 and 12 inclusive.",h.toString())),le((()=>c<=d),a("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let p=1-Math.pow(r/n,1/l);p=Math.round(1e3*p)/1e3;let g=n,f=n*(1-p*u);for(let e=1;e<c;e++)g=f,f=g*(1-p),e===l&&(f=g*(1-p*(1-u)));return g-f}},Zo={description:a("Number of periods for an investment to reach a value."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${a("The annualized rate of interest.")}\n yield (number) ${a("The expected annual yield of the security.")}\n frequency (number) ${a("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n=0){n=n||0;const r=Math.trunc(he(e)),l=Math.trunc(he(t)),c=he(s),h=he(i),d=Math.trunc(he(o)),u=Math.trunc(he(n));le((()=>r<l),a("The maturity (%s) must be strictly greater than the settlement (%s).",l.toString(),r.toString())),le((()=>c>=0),a("The rate (%s) must be positive or null.",c.toString())),le((()=>h>=0),a("The yield (%s) must be positive or null.",h.toString())),le((()=>[1,2,4].includes(d)),a("The frequency (%s) must be one of %s",d.toString(),[1,2,4].toString())),le((()=>0<=u&&u<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",u.toString()));const p=Bo.compute(r,l,u),g=p-Math.trunc(p)||1/d,f=Math.ceil(p*d),m=c/d,v=h/d;let E=0,S=0;for(let e=1;e<=f;e++){const t=(m+(e===f?1:0))/(1+v)**e;S+=(g+(e-1)/d)*t,E+=t}return 0===E?0:S/E}},Go={description:a("Future value of an annuity investment."),args:_e(`\n rate (number) ${a("The interest rate.")}\n number_of_periods (number) ${a("The number of payments to be made.")}\n payment_amount (number) ${a("The amount per period to be paid.")}\n present_value (number, default=0) ${a("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${a("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"#,##0.00"},compute:function(e,t,s,i=0,o=0){i=i||0,o=o||0;const n=he(e),r=he(t),a=he(s),l=he(i),c=ge(o)?1:0;return n?-l*(1+n)**r-a*(1+n*c)*((1+n)**r-1)/n:-(l+a*r)}},Wo={description:a("Internal rate of return given periodic cashflows."),args:_e(`\n cashflow_amounts (number, range<number>) ${a("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${a("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"0%"},compute:function(e,t=.1){const s=he(t);le((()=>s>-1),a("The rate_guess (%s) must be strictly greater than -1.",s.toString()));let i=!1,o=!1,n=[];Ee([e],(e=>{e>0&&(i=!0),e<0&&(o=!0),n.push(e)})),le((()=>i&&o),a("The cashflow_amounts must include negative and positive values."));const r=n.shift();return Ho((function(e){return function(e,t,s){const i=s.length;let o=0;return s.reduce(((t,s)=>(o++,t+s*e**(i-o))),t*e**i)}(e,r,n)}),(function(e){return function(e,t,s){const i=s.length;let o=0;return s.reduce(((t,s)=>(o++,t+s*(i-o)*e**(i-o-1))),t*i*e**(i-1))}(e,r,n)}),s+1,20,1e-5)-1}},qo={description:a("Modified Macaulay duration."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${a("The annualized rate of interest.")}\n yield (number) ${a("The expected annual yield of the security.")}\n frequency (number) ${a("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n=0){return Zo.compute(e,t,s,i,o,n)/(1+he(i)/Math.trunc(he(o)))}};const jo={description:a("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:_e(`\n discount (number) ${a("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${a("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${a("Additional future cash flows.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"#,##0.00"},compute:function(e,...t){const s=he(e);return le((()=>-1!==s),a("The discount (%s) must be different from -1.",s.toString())),function(e,t,s){let i=0;return Ce(s,((t,s)=>(i++,t+s/(1+e)**i)),t)}(s,0,t)}},Yo={description:a("Computes the number of periods needed for an investment to reach a value."),args:_e(`\n rate (number) ${a("The rate at which the investment grows each period.")}\n present_value (number) ${a("The investment's current value.")}\n future_value (number) ${a("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,s){const i=he(e),o=he(t),n=he(s);return le((()=>i>0),a("The rate (%s) must be strictly positive.",i.toString())),le((()=>o>0),a("The present_value (%s) must be strictly positive.",o.toString())),le((()=>n>0),a("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(o))/Math.log(1+i)}},Xo={description:a("Present value of an annuity investment."),args:_e(`\n rate (number) ${a("The interest rate.")}\n number_of_periods (number) ${a("The number of payments to be made.")}\n payment_amount (number) ${a("The amount per period to be paid.")}\n future_value (number, default=0) ${a("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${a("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],returnFormat:{specificFormat:"#,##0.00"},compute:function(e,t,s,i=0,o=0){i=i||0,o=o||0;const n=he(e),r=he(t),a=he(s),l=he(i),c=ge(o)?1:0;return n?-(a*(1+n*c)*((1+n)**r-1)/n+l)/(1+n)**r:-(l+a*r)}},Ko={description:a("Price of a security paying periodic interest."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${a("The annualized rate of interest.")}\n yield (number) ${a("The expected annual yield of the security.")}\n redemption (number) ${a("The redemption amount per 100 face value, or par.")}\n frequency (number) ${a("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n,r=0){r=r||0;const l=Math.trunc(he(e)),c=Math.trunc(he(t)),h=he(s),d=he(i),u=he(o),p=Math.trunc(he(n)),g=Math.trunc(he(r));le((()=>c>l),a("The maturity (%s) must be strictly greater than the settlement (%s).",c.toString(),l.toString())),le((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),le((()=>d>=0),a("The yield (%s) must be positive or null.",d.toString())),le((()=>u>0),a("The redemption (%s) must be strictly positive.",u.toString())),le((()=>[1,2,4].includes(p)),a("The frequency (%s) must be one of %s.",p.toString(),[1,2,4].toString())),le((()=>0<=g&&g<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",g.toString()));const f=Bo.compute(l,c,g)*p,m=Math.ceil(f),v=f-Math.floor(f)||1,E=1+d/p,S=100*h/p;if(1===m)return(S+u)/(v*d/p+1)-S*(1-v);let b=0;for(let e=1;e<=m;e++)b+=S/E**(e-1+v);return u/E**(m-1+v)+b-S*(1-v)}},Qo={description:a("Annual yield of a security paying periodic interest."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${a("The annualized rate of interest.")}\n price (number) ${a("The price at which the security is bought per 100 face value.")}\n redemption (number) ${a("The redemption amount per 100 face value, or par.")}\n frequency (number) ${a("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n,r=0){r=r||0;const l=Math.trunc(he(e)),c=Math.trunc(he(t)),h=he(s),d=he(i),u=he(o),p=Math.trunc(he(n)),g=Math.trunc(he(r));le((()=>c>l),a("The maturity (%s) must be strictly greater than the settlement (%s).",c.toString(),l.toString())),le((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),le((()=>d>0),a("The price (%s) must be strictly positive.",d.toString())),le((()=>u>0),a("The redemption (%s) must be strictly positive.",u.toString())),le((()=>[1,2,4].includes(p)),a("The frequency (%s) must be one of %s.",p.toString(),[1,2,4].toString())),le((()=>0<=g&&g<=4),a("The day_count_convention (%s) must between 0 and 4 inclusive.",g.toString()));const f=Bo.compute(l,c,g)*p,m=Math.ceil(f),v=f-Math.floor(f)||1,E=100*h/p;if(1===m){const e=d+E*(1-v);return(u+E-e)*p*(1/v)/e}const S=Ho((function(e){return function(e,t,s,i,o,n){let r=n-(e+o*(1-t))*i**(s-1+t);for(let e=1;e<=s;e++)r+=o*i**(e-1);return r}(d,v,m,e,E,u)}),(function(e){return function(e,t,s,i,o){let n=-(e+o*(1-t))*(s-1+t)*i**(s-2+t);for(let e=1;e<=s;e++)n+=o*(e-1)*i**(e-2);return n}(d,v,m,e,E)}),1+(h+1)/p,100,1e-5);return(S-1)*p}},Jo={description:a("Annual yield of a security paying interest at maturity."),args:_e(`\n settlement (date) ${a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${a("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${a("The date the security was initially issued.")}\n rate (number) ${a("The annualized rate of interest.")}\n price (number) ${a("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${a("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,s,i,o,n=0){n=n||0;const r=Math.trunc(he(e)),l=Math.trunc(he(t)),c=Math.trunc(he(s)),h=he(i),d=he(o),u=Math.trunc(he(n));le((()=>r>=c),a("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),c.toString())),le((()=>l>r),a("The maturity (%s) must be strictly greater than the settlement (%s).",l.toString(),r.toString())),le((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),le((()=>d>0),a("The price (%s) must be strictly positive.",d.toString())),le((()=>0<=u&&u<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",u.toString()));const p=Bo.compute(c,l,u),g=Bo.compute(c,r,u),f=Bo.compute(r,l,u);return(100*(1+h*p)/(d+100*h*g)-1)/f}};var en=Object.freeze({__proto__:null,DB:zo,DURATION:Zo,FV:Go,IRR:Wo,MDURATION:qo,NPV:jo,PDURATION:Yo,PV:Xo,PRICE:Ko,YIELD:Qo,YIELDMAT:Jo});const tn={description:a("Whether a value is an error."),args:_e(`value (any, lazy) ${a("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},sn={description:a("Whether a value is `true` or `false`."),args:_e(`value (any) ${a("The value to be verified as a logical TRUE or FALSE.")}`),returns:["BOOLEAN"],compute:function(e){return"boolean"==typeof e},isExported:!0},on={description:a("Whether a value is non-textual."),args:_e(`value (any) ${a("The value to be checked.")}`),returns:["BOOLEAN"],compute:function(e){return"string"!=typeof e},isExported:!0},nn={description:a("Whether a value is a number."),args:_e(`value (any) ${a("The value to be verified as a number.")}`),returns:["BOOLEAN"],compute:function(e){return"number"==typeof e},isExported:!0},rn={description:a("Whether a value is text."),args:_e(`value (any) ${a("The value to be verified as text.")}`),returns:["BOOLEAN"],compute:function(e){return"string"==typeof e},isExported:!0};var an=Object.freeze({__proto__:null,ISERROR:tn,ISLOGICAL:sn,ISNONTEXT:on,ISNUMBER:nn,ISTEXT:rn});const ln={description:a("Logical `and` operator."),args:_e(`\n logical_expression1 (boolean, range<boolean>) ${a("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) ${a("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,s=!0;return ye(e,(e=>(t=!0,s=s&&e,s))),le((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),s},isExported:!0},cn={description:a("Returns value depending on logical expression."),args:_e(`\n logical_expression (boolean) ${a("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) ${a("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${a("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,s=(()=>!1)){const i=ge(e)?t():s();return null==i?"":i},isExported:!0},hn={description:a("Value if it is not an error, otherwise 2nd argument."),args:_e(`\n value (any, lazy) ${a("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${a("An empty value")}) ${a("The value the function returns if value is an error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let s;try{s=e()}catch(e){s=t()}return null==s?"":s},isExported:!0},dn={description:a("Returns a value depending on multiple logical expressions."),args:_e(`\n condition1 (boolean, lazy) ${a("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) ${a("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${a("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${a("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){le((()=>e.length%2==0),a("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(ge(e[t]()))return e[t+1]();throw new Error(a("No match."))},isExported:!0},un={description:a("Returns opposite of provided logical value."),args:_e(`logical_expression (boolean) ${a("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!ge(e)},isExported:!0},pn={description:a("Logical `or` operator."),args:_e(`\n logical_expression1 (boolean, range<boolean>) ${a("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) ${a("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,s=!1;return ye(e,(e=>(t=!0,s=s||e,!s))),le((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),s},isExported:!0},gn={description:a("Logical `xor` operator."),args:_e(`\n logical_expression1 (boolean, range<boolean>) ${a("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) ${a("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,s=!1;return ye(e,(e=>(t=!0,s=s?!e:e,!0))),le((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),s},isExported:!0};var fn=Object.freeze({__proto__:null,AND:ln,IF:cn,IFERROR:hn,IFS:dn,NOT:un,OR:pn,XOR:gn});function mn(e,t){for(let s=0;s<e.length;s++)if(e[s]===t)return s;return-1}const vn={description:a("Column number of a specified cell."),args:_e(`cell_reference (meta, default=${a("The cell in which the formula is entered")}) ${a("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),le((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Fs(e).left+1},isExported:!0},En={description:a("Number of columns in a specified array or range."),args:_e(`range (meta) ${a("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Fs(e);return t.right-t.left+1},isExported:!0},Sn={description:a("Horizontal lookup"),args:_e(`\n search_key (any) ${a("The value to search for. For example, 42, 'Cats', or I24.")}\n range (range) ${a("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) ${a("The row index of the value to be returned, where the first row in range is numbered 1.")}\n is_sorted (boolean, default=true) ${a("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,s,i=true){const o=Math.trunc(he(s));le((()=>1<=o&&o<=t[0].length),a("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const n=ge(i),r=t.map((e=>e[0]));let l;return l=n?Re(r,e):mn(r,e),le((()=>l>-1),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),t[l][o-1]},isExported:!0},bn={description:a("Look up a value."),args:_e(`\n search_key (any) ${a("The value to search for. For example, 42, 'Cats', or I24.")}\n search_array (range) ${a("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) ${a("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,s){let i=t.length,o=t[0].length;const n=o>=i,r=Re(n?t[0]:t.map((e=>e[0])),e);return le((()=>r>=0),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),void 0===s?n?t[i-1][r]:t[r][o-1]:(i=s.length,o=s[0].length,le((()=>1===i||1===o),a("The result_range must be a single row or a single column.")),i>1?(le((()=>r<=i-1),a("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(r+1).toString())),s[r][0]):(le((()=>r<=o-1),a("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(r+1).toString())),s[0][r]))},isExported:!0},Cn={description:a("Position of item in range that matches value."),args:_e(`\n search_key (any) ${a("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${a("The one-dimensional array to be searched.")}\n search_type (number, default=1) ${a("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,s=1){let i=he(s);const o=t.length,n=t[0].length;le((()=>1===o||1===n),a("The range must be a single row or a single column."));let r=-1;const l=t.flat();switch(i=Math.sign(i),i){case 1:r=Re(l,e);break;case 0:r=mn(l,e);break;case-1:r=function(e,t){const s=typeof t;let i,o,n,r,a,l,c=0,h=e.length-1;if(typeof e[c]===s&&t>e[c])return-1;if(typeof e[h]===s&&e[h]>t)return h;for(;h-c>=0;){for(n=Math.ceil((c+h)/2),r=n,a=e[r],l=typeof a;c<=r&&s!==l;)r--,a=e[r],l=typeof a;l===s&&a>=t&&(void 0===i||i>a||i===a&&o>r)&&(i=a,o=r),l===s&&a<=t?h=r-1:c=n+1}return void 0!==o?o:-1}(l,e)}return le((()=>r>=0),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),r+1},isExported:!0},In={description:a("Row number of a specified cell."),args:_e(`cell_reference (meta, default=${a("The cell in which the formula is entered by default")}) ${a("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)),le((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Fs(e).top+1},isExported:!0},yn={description:a("Number of rows in a specified array or range."),args:_e(`range (meta) ${a("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Fs(e);return t.bottom-t.top+1},isExported:!0},wn={description:a("Vertical lookup."),args:_e(`\n search_key (any) ${a("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${a("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) ${a("The column index of the value to be returned, where the first column in range is numbered 1.")}\n is_sorted (boolean, default=true) ${a("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,s,i=true){const o=Math.trunc(he(s));le((()=>1<=o&&o<=t.length),a("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const n=ge(i),r=t[0];let l;return l=n?Re(r,e):mn(r,e),le((()=>l>-1),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),t[o-1][l]},isExported:!0};var Tn=Object.freeze({__proto__:null,COLUMN:vn,COLUMNS:En,HLOOKUP:Sn,LOOKUP:bn,MATCH:Cn,ROW:In,ROWS:yn,VLOOKUP:wn});const xn={description:a("Sum of two numbers."),args:_e(`\n value1 (number) ${a("The first addend.")}\n value2 (number) ${a("The second addend.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return he(e)+he(t)}},Rn={description:a("Concatenation of two values."),args:_e(`\n value1 (string) ${a("The value to which value2 will be appended.")}\n value2 (string) ${a("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return ue(e)+ue(t)},isExported:!0},Ln={description:a("One number divided by another."),args:_e(`\n dividend (number) ${a("The number to be divided.")}\n divisor (number) ${a("The number to divide by.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){const s=he(t);return le((()=>0!==s),a("The divisor must be different from zero.")),he(e)/s}};function Mn(e){return null==e}const An={number:0,string:"",boolean:!1},_n={description:a("Equal."),args:_e(`\n value1 (any) ${a("The first value.")}\n value2 (any) ${a("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=Mn(e)?An[typeof t]:e,t=Mn(t)?An[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function On(e,t,s){e=Mn(e)?An[typeof t]:e,t=Mn(t)?An[typeof e]:t,"number"!=typeof e&&(e=ue(e).toUpperCase()),"number"!=typeof t&&(t=ue(t).toUpperCase());const i=typeof e,o=typeof t;return"string"===i&&"number"===o||("string"!==o||"number"!==i)&&s(e,t)}const Nn={description:a("Strictly greater than."),args:_e(`\n value1 (any) ${a("The value to test as being greater than value2.")}\n value2 (any) ${a("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return On(e,t,((e,t)=>e>t))}},kn={description:a("Greater than or equal to."),args:_e(`\n value1 (any) ${a("The value to test as being greater than or equal to value2.")}\n value2 (any) ${a("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return On(e,t,((e,t)=>e>=t))}},Fn={description:a("Less than."),args:_e(`\n value1 (any) ${a("The value to test as being less than value2.")}\n value2 (any) ${a("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!kn.compute(e,t)}},$n={description:a("Less than or equal to."),args:_e(`\n value1 (any) ${a("The value to test as being less than or equal to value2.")}\n value2 (any) ${a("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Nn.compute(e,t)}},Dn={description:a("Difference of two numbers."),args:_e(`\n value1 (number) ${a("The minuend, or number to be subtracted from.")}\n value2 (number) ${a("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return he(e)-he(t)}},Un={description:a("Product of two numbers"),args:_e(`\n factor1 (number) ${a("The first multiplicand.")}\n factor2 (number) ${a("The second multiplicand.")}\n `),returns:["NUMBER"],returnFormat:He.FormatFromArgument,compute:function(e,t){return he(e)*he(t)}},Pn={description:a("Not equal."),args:_e(`\n value1 (any) ${a("The first value.")}\n value2 (any) ${a("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!_n.compute(e,t)}},Bn={description:a("A number raised to a power."),args:_e(`\n base (number) ${a("The number to raise to the exponent power.")}\n exponent (number) ${a("The exponent to raise base to.")}\n `),returns:["NUMBER"],compute:function(e,t){return Mt.compute(e,t)}},Vn={description:a("A number with the sign reversed."),args:_e(`\n value (number) ${a("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),returnFormat:He.FormatFromArgument,returns:["NUMBER"],compute:function(e){return-he(e)}},Hn={description:a("Value interpreted as a percentage."),args:_e(`\n percentage (number) ${a("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return he(e)/100}},zn={description:a("A specified number, unchanged."),args:_e(`\n value (any) ${a("The number to return.")}\n `),returnFormat:He.FormatFromArgument,returns:["ANY"],compute:function(e){return e}};var Zn=Object.freeze({__proto__:null,ADD:xn,CONCAT:Rn,DIVIDE:Ln,EQ:_n,GT:Nn,GTE:kn,LT:Fn,LTE:$n,MINUS:Dn,MULTIPLY:Un,NE:Pn,POW:Bn,UMINUS:Vn,UNARY_PERCENT:Hn,UPLUS:zn});const Gn={description:a("Gets character associated with number."),args:_e(`\n table_number (number) ${a("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(he(e));return le((()=>t>=1),a("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Wn={description:a("Appends strings to one another."),args:_e(`\n string1 (string, range<string>) ${a("The initial string.")}\n string2 (string, range<string>, repeating) ${a("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return be(e,((e,t)=>e+ue(t)),"")},isExported:!0},qn={description:a("Tests whether two strings are identical."),args:_e(`\n string1 (string) ${a("The first string to compare.")}\n string2 (string) ${a("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return ue(e)===ue(t)},isExported:!0},jn={description:a("First position of string found in text, case-sensitive."),args:_e(`\n search_for (string) ${a("The string to look for within text_to_search.")}\n text_to_search (string) ${a("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${a("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,s=1){const i=ue(e),o=ue(t),n=he(s);le((()=>""!==o),a("The text_to_search must be non-empty.")),le((()=>n>=1),a("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=o.indexOf(i,n-1);return le((()=>r>=0),a("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i.toString(),o)),r+1},isExported:!0},Yn={description:a("Concatenates elements of arrays with delimiter."),args:_e(`\n delimiter (string) ${a("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${a("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${a("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const s=ue(e);return be(t,((e,t)=>(e?e+s:"")+ue(t)),"")}},Xn={description:a("Substring from beginning of specified string."),args:_e(`\n text (string) ${a("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${a("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const s=t.length?he(t[0]):1;return le((()=>s>=0),a("The number_of_characters (%s) must be positive or null.",s.toString())),ue(e).substring(0,s)},isExported:!0},Kn={description:a("Length of a string."),args:_e(`\n text (string) ${a("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return ue(e).length},isExported:!0},Qn={description:a("Converts a specified string to lowercase."),args:_e(`\n text (string) ${a("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return ue(e).toLowerCase()},isExported:!0},Jn={description:a("Replaces part of a text string with different text."),args:_e(`\n text (string) ${a("The text, a part of which will be replaced.")}\n position (number) ${a("The position where the replacement will begin (starting from 1).")}\n length (number) ${a("The number of characters in the text to be replaced.")}\n new_text (string) ${a("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,s,i){const o=he(t);le((()=>o>=1),a("The position (%s) must be greater than or equal to 1.",o.toString()));const n=ue(e),r=he(s),l=ue(i);return n.substring(0,o-1)+l+n.substring(o-1+r)},isExported:!0},er={description:a("A substring from the end of a specified string."),args:_e(`\n text (string) ${a("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${a("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const s=t.length?he(t[0]):1;le((()=>s>=0),a("The number_of_characters (%s) must be positive or null.",s.toString()));const i=ue(e),o=i.length;return i.substring(o-s,o)},isExported:!0},tr={description:a("First position of string found in text, ignoring case."),args:_e(`\n search_for (string) ${a("The string to look for within text_to_search.")}\n text_to_search (string) ${a("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${a("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,s=1){const i=ue(e).toLowerCase(),o=ue(t).toLowerCase(),n=he(s);le((()=>""!==o),a("The text_to_search must be non-empty.")),le((()=>n>=1),a("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=o.indexOf(i,n-1);return le((()=>r>=0),a("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i,o)),r+1},isExported:!0},sr={description:a("Replaces existing text with new text in a string."),args:_e(`\n text_to_search (string) ${a("The text within which to search and replace.")}\n search_for (string) ${a("The string to search for within text_to_search.")}\n replace_with (string) ${a("The string that will replace search_for.")}\n occurrence_number (number, optional) ${a("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,s,i){const o=he(i);le((()=>o>=0),a("The occurrenceNumber (%s) must be positive or null.",o.toString()));const n=ue(e),r=ue(t);if(""===r)return n;const l=ue(s),c=new RegExp(ds(r),"g");if(0===o)return n.replace(c,l);let h=0;return n.replace(c,(e=>++h===o?l:e))},isExported:!0},ir={description:a("Combines text from multiple strings and/or arrays."),args:_e(`\n delimiter (string) ${a(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${a("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${a("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${a("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...s){const i=ue(e),o=ge(t);let n=0;return be(s,((e,t)=>o&&""===ue(t)?e:(n++?e+i:"")+ue(t)),"")},isExported:!0},or={description:a("Removes space characters."),args:_e(`\n text (string) ${a("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return ue(e).trim()},isExported:!0},nr={description:a("Converts a specified string to uppercase."),args:_e(`\n text (string) ${a("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return ue(e).toUpperCase()},isExported:!0};const rr={database:go,date:Vo,financial:en,info:an,lookup:Tn,logical:fn,math:qt,operators:Zn,statistical:Qi,text:Object.freeze({__proto__:null,CHAR:Gn,CONCATENATE:Wn,EXACT:qn,FIND:jn,JOIN:Yn,LEFT:Xn,LEN:Kn,LOWER:Qn,REPLACE:Jn,RIGHT:er,SEARCH:tr,SUBSTITUTE:sr,TEXTJOIN:ir,TRIM:or,UPPER:nr})};const ar=new class extends Le{constructor(){super(...arguments),this.mapping={}}add(e,t){e=e.toUpperCase().replace("_",".");const s=Ne(t);return function(e){let t=!1,s=!1,i=!1;for(let o of e){if(o.type.includes("META")&&o.type.length>1)throw new Error(a("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(a("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=s||t||i,n=!(o.optional||o.repeating||o.default);if(e&&n)throw new Error(a("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=o.repeating,s=o.optional,i=o.default}}(s.args),this.mapping[e]=s.compute,super.add(e,s),this}};for(let e in rr){const t=rr[e];for(let s in t){const i=t[s];i.category=e,ar.add(s,{isExported:!1,...i})}}const lr=/^[S|N]?\d+/,cr=ar.content,hr="+,-,*,/,:,=,<>,>=,>,<=,<,%,^,&".split(",");function dr(e){const t=e.split(""),s=[];for(;t.length;){let e=yr(t)||fr(t)||vr(t)||Sr(t)||pr(t)||ur(t)||wr(t)||Er(t)||Cr(t);e||(e={type:"UNKNOWN",value:t.shift()}),s.push(e)}return s}function ur(e){if(e[0]===$){e.shift();const t=e.join("").match(lr);if(!t)return null;e.splice(0,t[0].length),e[0]===$&&e.shift();const s=t[0];switch(s[0]){case"S":return{type:"NORMALIZED_STRING",value:s.substring(1)};case"N":return{type:"NORMALIZED_NUMBER",value:s.substring(1)};default:return{type:"REFERENCE",value:s}}}return null}function pr(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const gr={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function fr(e){if(e[0]in gr){const t=e.shift();return{type:gr[t],value:t}}return null}function mr(e,t){for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function vr(e){for(let t of hr)if(mr(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Er(e){const t=e.join("").match(K);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Sr(e){if('"'===e[0]){const t=e.shift(),s=[t];for(;e[0]&&(e[0]!==t||"\\"===s[s.length-1]);)s.push(e.shift());return'"'===e[0]&&s.push(e.shift()),{type:"STRING",value:s.join("")}}return null}const br=/\w|\.|!|\$/;function Cr(e){const t=[];if("'"===e[0]){let s=e.shift();for(t.push(s);e[0];)if(s=e.shift(),t.push(s),"'"===s){if(!e[0]||"'"!==e[0])break;s=e.shift(),t.push(s)}if("'"!==s)return{type:"UNKNOWN",value:t.join("")}}for(;e[0]&&e[0].match(br);)t.push(e.shift());if(t.length){const e=t.join("");return{type:e.toUpperCase()in cr?"FUNCTION":"SYMBOL",value:e}}return null}const Ir=/\s/;function yr(e){let t=0;for(;e[0]&&e[0].match(Ir);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function wr(e){return mr(e,_)?(e.splice(0,_.length),{type:"INVALID_REFERENCE",value:_}):null}const Tr=["-","+"],xr=["*","+","&"],Rr={"^":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},Lr=6;function Mr(e){switch(e.type){case"NUMBER":case"SYMBOL":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return Rr[e.value]||15}throw new Error(a("Unknown token: %s",e.value))}function Ar(e,t,s){if("OPERATOR"===t.type){const i=_r(s,Mr(t));return{type:"BIN_OPERATION",value:t.value,left:e,right:i}}throw new Error(N)}function _r(e,t){const s=e.shift();if(!s)throw new Error(N);let i=function(e,t){var s;switch(e.type){case"DEBUGGER":const i=_r(t,1e3);return i.debug=!0,i;case"NUMBER":return{type:"NUMBER",value:te(e.value)};case"NORMALIZED_NUMBER":return{type:"NORMALIZED_NUMBER",value:parseInt(e.value,10)};case"STRING":return{type:"STRING",value:e.value};case"NORMALIZED_STRING":return{type:"NORMALIZED_STRING",value:parseInt(e.value,10)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(a("Wrong function call"));{const i=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?i.push({type:"UNKNOWN",value:""}):i.push(_r(t,Lr));"COMMA"===(null===(s=t[0])||void 0===s?void 0:s.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){i.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?i.push({type:"UNKNOWN",value:""}):i.push(_r(t,Lr))}const o=t.shift();if(!o||"RIGHT_PAREN"!==o.type)throw new Error(a("Wrong function call"));return{type:"FUNCALL",value:e.value,args:i}}case"REFERENCE":return{type:"NORMALIZED_REFERENCE",value:parseInt(e.value,10)};case"INVALID_REFERENCE":throw new Error(a("Invalid reference"));case"SYMBOL":if(Jt.test(e.value))return{type:"REFERENCE",value:e.value};if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value)throw new Error(a("Invalid formula"));return{type:"STRING",value:e.value};case"LEFT_PAREN":const o=_r(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(a("Unmatched left parenthesis"));return t.shift(),o;default:if("OPERATOR"===e.type&&Tr.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,right:_r(t,Rr[e.value])};throw new Error(a("Unexpected token: %s",e.value))}}(s,e);for(;e[0]&&Mr(e[0])>t;)i=Ar(i,e.shift(),e);return i}function Or(e){const t=dr(e).filter((e=>"SPACE"!==e.type));t[0]&&"OPERATOR"===t[0].type&&"="===t[0].value&&t.splice(0,1);const s=_r(t,0);if(t.length)throw new Error(N);return s}function Nr(e,t,s){switch(t===e.type&&(e=s(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>Nr(e,t,s)))};case"UNARY_OPERATION":return{...e,right:Nr(e.right,t,s)};case"BIN_OPERATION":return{...e,right:Nr(e.right,t,s),left:Nr(e.left,t,s)};default:return e}}function kr(e,t={references:[],numbers:[],strings:[]}){switch(e.type){case"FUNCALL":const s=e.args.map((e=>kr(e,t)));return`${e.value}(${s.join(",")})`;case"NUMBER":return e.value.toString();case"NORMALIZED_STRING":return`"${t.strings[e.value]}"`;case"NORMALIZED_NUMBER":return t.numbers[e.value].toString();case"NORMALIZED_REFERENCE":return t.references[e.value].toString();case"REFERENCE":case"STRING":default:return e.value;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.value+Fr(e,t);case"BIN_OPERATION":return function(e,t){const s=e.value,i=e.left,o=i.value;return"BIN_OPERATION"===i.type&&Rr[o]<Rr[s]?`(${kr(i,t)})`:kr(i,t)}(e,t)+e.value+Fr(e,t)}}function Fr(e,t){const s=e.value,i=e.right,o=Rr[i.value],n=Rr[s];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:o<n?r=!0:o!==n||xr.includes(s)||(r=!0),r?`(${kr(i,t)})`:kr(i,t)}const $r=ar.content,Dr={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Ur={"-":"UMINUS","+":"UPLUS"};function Pr(e){return e.map((e=>e.split("\n"))).flat().filter((e=>""!==e.trim()))}const Br={};function Vr(e){if(!Br[e.text]){const t=Or(e.text);let s=1;if("BIN_OPERATION"===t.type&&":"===t.value)throw new Error(a("Invalid formula"));if("UNKNOWN"===t.type)throw new Error(a("Invalid formula"));const i=l(t),o=Pr([`// ${e.text}`,i.code,`return ${i.id};`]).join("\n");let n=new Function("deps","sheetId","ref","range","ctx",o);function r(e){const t=$r[e.value.toUpperCase()],s=e.args,i=s.length;if(i<t.minArgRequired)throw new Error(a("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),i.toString()));if(i>t.maxArgPossible)throw new Error(a("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),i.toString()));const o=t.nbrArgRepeating;if(o>1){const s=t.args.length-o;if((i-s)%o!=0)throw new Error(a("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(),s.toString(),o.toString()))}let n=[];for(let o=0;o<i;o++){const i=t.getArgToFocus(o+1)-1;if(0<=i&&i<t.args.length){const r=s[o],c=t.args[i],h=c.type||[],d=h.includes("META"),u=c.lazy,p=h.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),g=h.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(g&&"NORMALIZED_REFERENCE"!==r.type)throw new Error(a("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(o+1).toString(),r.type.toLowerCase().replace("normalized_","")));const f=l(r,u,d,p,{functionName:e.value.toUpperCase(),paramIndex:o+1});n.push(f)}}return n}function l(t,i=!1,o=!1,n=!1,c={}){const h=[];let d,u,p;if("NORMALIZED_REFERENCE"!==t.type&&("BIN_OPERATION"!==t.type||":"!==t.value)&&o)throw new Error(a("Argument must be a reference to a cell or range."));switch(t.debug&&h.push("debugger;"),t.type){case"BOOLEAN":case"NUMBER":case"STRING":if(!i)return{id:t.value,code:""};d=s++,p=`${t.value}`;break;case"NORMALIZED_NUMBER":d=s++,p=`deps.numbers[${t.value}]`;break;case"NORMALIZED_STRING":d=s++,p=`deps.strings[${t.value}]`;break;case"REFERENCE":throw new Error(`Only normalized references can be compiled: ${t.value}`);case"NORMALIZED_REFERENCE":if(!e.dependencies.references[t.value]){d=s++,p="null";break}d=s++,p=n?`range(${t.value}, deps.references, sheetId)`:`ref(${t.value}, deps.references, sheetId, ${o?"true":"false"}, "${c.functionName||Dr["="]}", ${c.paramIndex})`;break;case"FUNCALL":d=s++;const a=r(t);h.push(Pr(a.map((e=>e.code))).join("\n")),u=t.value.toUpperCase(),h.push(`ctx.__lastFnCalled = '${u}';`),p=`ctx['${u}'](${a.map((e=>e.id))})`;break;case"UNARY_OPERATION":{d=s++,u=Ur[t.value];const e=l(t.right,!1,!1,!1,{functionName:u});h.push(e.code),h.push(`ctx.__lastFnCalled = '${u}';`),p=`ctx['${u}']( ${e.id})`;break}case"BIN_OPERATION":{d=s++,u=Dr[t.value];const e=l(t.left,!1,!1,!1,{functionName:u}),i=l(t.right,!1,!1,!1,{functionName:u});h.push(e.code),h.push(i.code),h.push(`ctx.__lastFnCalled = '${u}';`),p=`ctx['${u}'](${e.id}, ${i.id})`;break}case"UNKNOWN":if(!i)return{id:"undefined",code:""};d=s++,p="undefined"}if(i){return{id:`_${d}`,code:`const _${d} = () => {\n\t${Pr(h).join("\n\t")}\n\treturn ${p};\n}`}}return h.push(`let _${d} = ${p};`),{id:`_${d}`,code:Pr(h).join("\n")}}function c(t){let s;switch(t.type){case"NORMALIZED_REFERENCE":if(e.dependencies.references[t.value])return[t.value];break;case"FUNCALL":if(s=$r[t.value.toUpperCase()],s.returnFormat){if("FormatFromArgument"!==s.returnFormat)return[s.returnFormat.specificFormat];if(t.args.length>0){const e=0;if(!s.args[e].type.includes("META"))return c(t.args[e])}}break;case"UNARY_OPERATION":return c(t.right);case"BIN_OPERATION":if(s=$r[Dr[t.value]],s.returnFormat){if("FormatFromArgument"===s.returnFormat){const e=c(t.left);if("string"==typeof e[e.length-1])return e;const s=c(t.right);return e.concat(s)}return[s.returnFormat.specificFormat]}}return[]}Br[e.text]=n,Br[e.text].dependenciesFormat=c(t)}return Br[e.text]}function Hr(e,t=!1){let s,i,o,n;const r=()=>{n=void 0,i=void 0,s=void 0,o=void 0};for(let a=0;a<e.length;a++){const l=e[a];if(n)if(i){if("SPACE"===l.type)continue;if("OPERATOR"===l.type&&":"===l.value)s=a;else if(s&&"SYMBOL"===l.type)o=a;else if(n&&i&&s&&o){const s={type:"SYMBOL",value:e.slice(n,a).filter((e=>!t||"SPACE"!==e.type)).map((e=>e.value)).join("")};e.splice(n,a-n,s),a=n+1,r()}else"SYMBOL"===l.type?(n=a,i=a,s=void 0):r()}else"SYMBOL"===l.type?(i=a,s=o=void 0):r();else["SPACE","SYMBOL"].includes(l.type)?(n=a,i="SYMBOL"===l.type?a:void 0,s=o=void 0):r()}const a=e.length-1;if(n&&i&&s&&o){const s={type:"SYMBOL",value:e.slice(n,a+1).filter((e=>!t||"SPACE"!==e.type)).map((e=>e.value)).join("")};e.splice(n,a-n+1,s)}return e}function zr(e){return Hr(dr(e),!0)}function Zr(e){return function(e){let t=[],s="";return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(s=""),e.type){case"FUNCTION":s=e.value;break;case"LEFT_PAREN":t.push({parent:s,argPosition:0}),s="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const s=t[t.length-1];s.parent&&(e.functionContext=Object.assign({},s))}return e}))}(function(e){let t=1;const s=[];return e.map((e=>("LEFT_PAREN"===e.type?(s.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=s.pop()),e)))}(function(e){let t=0;return e.map((e=>{const s=e.value.toString().length,i=Object.assign({},e,{start:t,end:t+s,length:s});return t=i.end,i}))}(Hr(dr(e)))))}function Gr(e){const t=zr(e);let s={numbers:[],strings:[],references:[]};return{text:"".concat(...t.map((e=>{if("SYMBOL"===e.type&&Jt.test(e.value)){const t=e.value.trim();s.references.includes(t)||s.references.push(t);return Wr(s.references.indexOf(t).toString())}if("STRING"===e.type){const t=e.value.slice(1).slice(0,e.value.length-2);s.strings.includes(t)||s.strings.push(t);const i=s.strings.indexOf(t);return Wr(`${e.type[0]}${i}`)}if("NUMBER"===e.type){const t=te(e.value);s.numbers.includes(t)||s.numbers.push(t);const i=s.numbers.indexOf(t);return Wr(`${e.type[0]}${i}`)}return e.value}))),dependencies:s}}function Wr(e){return`${$}${e}${$}`}const qr=new Le;function jr(e,t){switch(typeof e){case"string":return e.includes('\\"')?e.replace(/\\"/g,'"'):e;case"boolean":return e?"TRUE":"FALSE";case"number":return(null==t?void 0:t.match(A))?j({value:e,format:t}):t?function(e,t){const s=t.split(";"),i=s.length;return e<0?i>1?ae(-e,s[1]):"-"+ae(-e,s[0]):ae(e,s[3===i&&0===e?2:0])}(e,t):ie(e);case"object":return"0"}}function Yr(e){return""===e?"":J(e)?te(e):Ss(e)?"TRUE"===e.toUpperCase():bs(e)?G(e).value:e}class Xr{constructor(e,t,s){this.id=e,this.evaluated=t,this.style=s.style,this.format=s.format}isFormula(){return!1}isLink(){return!1}isEmpty(){return!1}get formattedValue(){return jr(this.evaluated.value,this.format)}get composerContent(){return this.content}get defaultAlign(){switch(this.evaluated.type){case ke.number:return"right";case ke.boolean:case ke.error:return"center";case ke.text:case ke.empty:return"left"}}get isAutoSummable(){var e;switch(this.evaluated.type){case ke.empty:case ke.text:return!0;case ke.number:return!(null===(e=this.format)||void 0===e?void 0:e.match(A));case ke.error:case ke.boolean:return!1}}}class Kr extends Xr{constructor(e,t={}){super(e,{value:"",type:ke.empty},t),this.content=""}isEmpty(){return!0}}class Qr extends Xr{constructor(e,t,s={}){super(e,{value:t,type:ke.number},s),this.content=ie(this.evaluated.value)}}class Jr extends Xr{constructor(e,t,s={}){super(e,{value:t,type:ke.boolean},s),this.content=this.evaluated.value?"TRUE":"FALSE"}}class ea extends Xr{constructor(e,t,s={}){super(e,{value:t,type:ke.text},s),this.content=this.evaluated.value}}class ta extends Qr{constructor(e,t,s){super(e,t,s),this.format=s.format}get composerContent(){return jr(this.evaluated.value,this.format)}}class sa extends Xr{constructor(e,t,s={}){const i=Ts(t);super(e,{value:i.label,type:ke.text},s),this.link=i,this.content=t}isLink(){return!0}get composerContent(){return this.link.label}}class ia extends sa{constructor(e,t,s={}){super(e,t,s),this.link.url=this.withHttp(this.link.url),this.link.isExternal=!0,this.content=ws(this.link.label,this.link.url),this.urlRepresentation=this.link.url,this.isUrlEditable=!0}action(e){window.open(this.link.url,"_blank")}withHttp(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}}class oa extends sa{constructor(e,t,s={},i){super(e,t,s),this.sheetName=i,this.sheetId=Ls(this.link.url),this.isUrlEditable=!1}action(e){e.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}get urlRepresentation(){return this.sheetName(this.sheetId)||a("Invalid sheet")}}class na extends Xr{constructor(e,t,s,i,o,n){super(t,{value:"Loading...",type:ke.text},n),this.buildFormulaString=e,this.normalizedText=s,this.compiledFormula=i,this.dependencies=o}get content(){return this.buildFormulaString(this.normalizedText,this.dependencies)}isFormula(){return!0}assignValue(e){switch(typeof e){case"number":this.evaluated={value:e,type:ke.number};break;case"boolean":this.evaluated={value:e,type:ke.boolean};break;case"string":this.evaluated={value:e,type:ke.text};break;case"object":case"undefined":this.evaluated={value:e,type:ke.empty}}}assignError(e,t){this.evaluated={value:e,error:t,type:ke.error}}}class ra extends Xr{constructor(e,t,s,i){super(e,{value:"#BAD_EXPR",type:ke.error,error:s},i),this.content=t}}function aa(e){const t=zr(e);let s=[];return{text:"".concat(...t.map((e=>{if("SYMBOL"===e.type&&Jt.test(e.value)){const t=e.value.trim();return s.includes(t)||s.push(t),`${$}${s.indexOf(t)}${$}`}return e.value}))),dependencies:s}}qr.add("Formula",{sequence:10,match:e=>e.startsWith("="),createCell:(e,t,s,i,o)=>{const n=Gr(t),r=n.text,a=Vr(n),l=n.dependencies.references.map((e=>o.getRangeFromSheetXC(i,e))),c=s.format||function(e,t,s){var i;const o=t.dependenciesFormat;for(let t of o)switch(typeof t){case"string":return t;case"number":const o=s[t],n=e[o.sheetId];if(n){const e=null===(i=n.rows[o.zone.top])||void 0===i?void 0:i.cells[o.zone.left];if(e&&e.format)return e.format}}return F}(o.getEvaluationSheets(),a,l);return new na(((e,t)=>o.buildFormulaContent(i,e,t)),e,r,a,{...n.dependencies,references:l},{...s,format:c})}}).add("Empty",{sequence:20,match:e=>""===e,createCell:(e,t,s)=>new Kr(e,s)}).add("Number",{sequence:30,match:e=>J(e),createCell:(e,t,s)=>(!s.format&&t.includes("%")&&(s.format=t.includes(".")?"0.00%":"0%"),new Qr(e,te(t),s))}).add("Boolean",{sequence:40,match:e=>Ss(e),createCell:(e,t,s)=>new Jr(e,"TRUE"===t.toUpperCase(),s)}).add("DateTime",{sequence:50,match:e=>bs(e),createCell:(e,t,s)=>{const i=G(t),o=s.format||i.format;return new ta(e,i.value,{...s,format:o})}}).add("MarkdownSheetLink",{sequence:60,match:e=>Rs(e),createCell:(e,t,s,i,o)=>new oa(e,t,s,(e=>o.tryGetSheetName(e)))}).add("MarkdownLink",{sequence:70,match:e=>ys(e),createCell:(e,t,s)=>new ia(e,t,s)}).add("WebLink",{sequence:80,match:e=>{return t=e,Is.test(t);var t},createCell:(e,t,s)=>new ia(e,ws(t,t),s)});const la=10,ca="Sheet1";function ha(e){return e?("version"in(e=JSON.parse(JSON.stringify(e)))&&e.version<la&&(e=function(e){for(let t=da.findIndex((t=>t.from===e.version));t<da.length;t++)e=da[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,s=new ni;for(const i of e.sheets||[])for(const e of i.figures||[])t.has(e.id)&&(e.id+=s.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(fa(),e,{version:la}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(ga(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(ga(ca,"Sheet1"));return e}(e),e}(e),e):fa()}const da=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const s=t.cells[e];s.content&&s.content.startsWith("=")&&(s.formula=aa(s.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:s,...i}=t.figures[e].data,o=[];for(let e of s)if(e.labelCell){const t=Fs(e.dataRange),s=e.labelCell+":"+os(t.right,t.bottom);o.push(s)}else o.push(e.dataRange);i.dataSetsHaveTitle=Boolean(s[0].labelCell),i.dataSets=o,t.figures[e].data=i}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const s=[],i=new RegExp(k,"g");for(let o of e.sheets||[]){if(!o.name)continue;const e=o.name,n=e.replace(i,"_");let r=1,a=n;for(;s.includes(a);)a=`${n}${r}`,r++;o.name=a,s.push(a);const l=t=>{if(void 0===t)return t;let s=t.replace(e,a),i=t;for(;i!==s;)i=s,s=i.replace(e,a);return i};for(let e in o.cells){const t=o.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of o.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),s=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:s}}for(let e of o.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const s of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[s])||void 0===t?void 0:t.type)&&(e.rule[s].value=l(e.rule[s].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=g,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stackedBar=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const s=t.cells[e];if(s.formula){let{text:e,dependencies:t}=s.formula;for(let[s,i]of Object.entries(t)){const t=`\\${$}${s}\\${$}`;e=e.replace(new RegExp(t,"g"),i)}s.content=e,delete s.formula}}return e}}];function ua(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const s=[],i=[],o=e=>{if("CREATE_SHEET"===e.type)s.push(e.sheetId);else if("sheetId"in e&&!s.includes(e.sheetId))return{...e,sheetId:ca};return e};for(const e of t)"REMOTE_REVISION"===e.type?i.push({...e,commands:e.commands.map(o)}):i.push(e);return i}(e,t),t=pa(t,"SORT_CELLS"),t=pa(t,"SET_DECIMAL")}function pa(e,t){const s=[];for(const i of e)"REMOTE_REVISION"===i.type?s.push({...i,commands:i.commands.filter((e=>e.type!==t))}):s.push(i);return s}function ga(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[]}}function fa(e="Sheet1"){return{version:la,sheets:[ga(ca,e)],entities:{},styles:{},borders:{},revisionId:O,uniqueFigureIds:!0}}class ma{constructor(e,t,s){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t,this.currentMode=s.mode}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 s of e){let e=s.call(this,t);Array.isArray(e)||(e=[e]);const i=e.filter((e=>0!==e));if(i.length)return i}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}ma.getters=[],ma.modes=["headless","normal"];class va extends ma{constructor(e,t,s,i,o,n){super(t,i,o),this.dispatch=i,this.range=s,s.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}exportForExcel(e){}adaptRanges(e,t){}}class Ea extends va{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":if(!e.interactive)for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const s=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,s)}break;case"DELETE_SHEET":const s={...this.borders};delete s[e.sheetId],this.history.update("borders",s);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=this.getters.getSheet(e.sheetId),s=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(t,s,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":e.elements.sort(((e,t)=>t-e));for(const t of vs(e.elements))"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t[t.length-1]+1,-t.length):this.shiftBordersVertically(e.sheetId,t[t.length-1]+1,-t.length);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){const t=this.getters.getSheet(e.sheetId);let s,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),s=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),s=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(t,s,i)}handleAddRows(e){const t=this.getters.getSheet(e.sheetId);let s,i;"before"===e.position?(this.shiftBordersVertically(t.id,e.base,e.quantity,{moveFirstTopBorder:!0}),s=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(t.id,e.base+1,e.quantity,{moveFirstTopBorder:!1}),s=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(t,s,i)}getCellBorder(e,t,s){var i,o,n,r,a,l,c,h,d,u,p,g;const f={top:null===(n=null===(o=null===(i=this.borders[e])||void 0===i?void 0:i[t])||void 0===o?void 0:o[s])||void 0===n?void 0:n.horizontal,bottom:null===(l=null===(a=null===(r=this.borders[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[s+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[s])||void 0===d?void 0:d.vertical,right:null===(g=null===(p=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===p?void 0:p[s])||void 0===g?void 0:g.vertical};return f.bottom||f.left||f.right||f.top?f:null}ensureColumnBorderContinuity(e,t,s){const i=ms(t+1,s);for(let o=0;o<e.rows.length;o++){const n=this.getCellBorder(e.id,t,o),r=this.getCellBorder(e.id,s,o);if(n&&r){const t=this.getCommonSides(n,r);for(let s of i)this.addBorder(e.id,s,o,t)}}}ensureRowBorderContinuity(e,t,s){const i=ms(t+1,s);for(let o=0;o<e.cols.length;o++){const n=this.getCellBorder(e.id,o,t),r=this.getCellBorder(e.id,o,s);if(n&&r){const t=this.getCommonSides(n,r);for(let s of i)this.addBorder(e.id,o,s,t)}}}getCommonSides(e,t){const s={};for(let i of["top","bottom","left","right"])e[i]&&e[i]===t[i]&&(s[i]=e[i]);return s}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsWithBorders(e){var t;const s=null===(t=this.borders[e])||void 0===t?void 0:t.filter(Ms);if(!s)return[];const i=new Set;for(const e of s)for(const t in e)i.add(parseInt(t,10));return Array.from(i)}getRowsRange(e){if(!this.borders[e])return[];return ms(0,this.getters.getSheet(e).rows.length+1)}shiftBordersHorizontally(e,t,s,{moveFirstLeftBorder:i}={}){this.borders[e]&&(s<0&&this.moveBordersOfColumn(e,t,s,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>s<0?e-t:t-e)).forEach((o=>{(o===t&&i||o!==t)&&this.moveBordersOfColumn(e,o,s,"vertical"),this.moveBordersOfColumn(e,o,s,"horizontal")})))}shiftBordersVertically(e,t,s,{moveFirstTopBorder:i}={}){this.borders[e]&&(s<0&&this.moveBordersOfRow(e,t,s,"horizontal",{destructive:!1}),this.getRowsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>s<0?e-t:t-e)).forEach((o=>{(o===t&&i||o!==t)&&this.moveBordersOfRow(e,o,s,"horizontal"),this.moveBordersOfRow(e,o,s,"vertical")})))}moveBordersOfRow(e,t,s,i,{destructive:o}={destructive:!0}){const n=this.borders[e];n&&this.getColumnsWithBorders(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=n[r])||void 0===a?void 0:a[t+s])||void 0===l?void 0:l[i],u=null===(h=null===(c=n[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[i];this.history.update("borders",e,r,t+s,i,o?u:u||d),this.history.update("borders",e,r,t,i,void 0)}))}moveBordersOfColumn(e,t,s,i,{destructive:o}={destructive:!0}){const n=this.borders[e];n&&this.getRowsRange(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=n[t+s])||void 0===a?void 0:a[r])||void 0===l?void 0:l[i],u=null===(h=null===(c=n[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[i];this.history.update("borders",e,t+s,r,i,o?u:u||d),this.history.update("borders",e,t,r,i,void 0)}))}setBorder(e,t,s,i){this.history.update("borders",e,t,s,{vertical:null==i?void 0:i.left,horizontal:null==i?void 0:i.top}),this.history.update("borders",e,t+1,s,"vertical",null==i?void 0:i.right),this.history.update("borders",e,t,s+1,"horizontal",null==i?void 0:i.bottom)}clearBorders(e,t){for(let s of t){for(let t=s.top;t<=s.bottom;t++){this.history.update("borders",e,s.right+1,t,"vertical",void 0);for(let i=s.left;i<=s.right;i++)this.history.update("borders",e,i,t,void 0)}for(let t=s.left;t<=s.right;t++)this.history.update("borders",e,t,s.bottom+1,"horizontal",void 0)}}addBorder(e,t,s,i){this.setBorder(e,t,s,{...this.getCellBorder(e,t,s),...i})}setBorders(e,t,s){const i=e.id;if("clear"===s)return this.clearBorders(i,t);for(let e of t){if("h"===s||"hv"===s||"all"===s)for(let t=e.top+1;t<=e.bottom;t++)for(let s=e.left;s<=e.right;s++)this.addBorder(i,s,t,{top:L});if("v"===s||"hv"===s||"all"===s)for(let t=e.top;t<=e.bottom;t++)for(let s=e.left+1;s<=e.right;s++)this.addBorder(i,s,t,{left:L});if("left"===s||"all"===s||"external"===s)for(let t=e.top;t<=e.bottom;t++)this.addBorder(i,e.left,t,{left:L});if("right"===s||"all"===s||"external"===s)for(let t=e.top;t<=e.bottom;t++)this.addBorder(i,e.right+1,t,{left:L});if("top"===s||"all"===s||"external"===s)for(let t=e.left;t<=e.right;t++)this.addBorder(i,t,e.top,{top:L});if("bottom"===s||"all"===s||"external"===s)for(let t=e.left;t<=e.right;t++)this.addBorder(i,t,e.bottom+1,{top:L})}}addBordersToMerge(e,t){const s=this.getters.getSheet(e),{left:i,right:o,top:n,bottom:r}=t,a=this.getCellBorder(s.id,i,n),l=this.getCellBorder(s.id,o,r);this.clearBorders(e,[t]),(null==a?void 0:a.top)&&this.setBorders(s,[{...t,bottom:n}],"top"),(null==a?void 0:a.left)&&this.setBorders(s,[{...t,right:i}],"left"),((null==l?void 0:l.bottom)||(null==a?void 0:a.bottom))&&this.setBorders(s,[{...t,top:r}],"bottom"),((null==l?void 0:l.right)||(null==a?void 0:a.right))&&this.setBorders(s,[{...t,left:o}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[s,i]of Object.entries(t.cells))if(null==i?void 0:i.border){const o=e.borders[i.border],[n,r]=is(s);this.setBorder(t.id,n,r,o)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,Fs(e))}export(e){let t=0;const s={};function i(e){for(let[t,i]of Object.entries(s))if(_s(i,e))return parseInt(t,10);return s[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let s=0;s<t.rowNumber;s++){const o=this.getCellBorder(t.id,e,s);if(o){const n=os(e,s),r=t.cells[n],a=i(o);r?r.border=a:t.cells[n]={border:a}}}e.borders=s}exportForExcel(e){this.export(e)}}Ea.getters=["getCellBorder"];const Sa=new RegExp(String.fromCharCode(160),"g"),ba={textColor:M,underline:!0};class Ca extends va{constructor(){super(...arguments),this.cells={},this.cellUuidGenerator=new ni(!0),this.createCell=function(e){const t=qr.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(s,i,o,n){const r=t.find((e=>e.match(i)));if(!r)return new ea(s,i,o);try{return r.createCell(s,i,o,n,e)}catch(e){return new ra(s,i,e.message||N,o)}}}(this.getters)}adaptRanges(e,t){for(const s of Object.keys(this.cells))for(const i of Object.values(this.cells[s]||{}))if(i.isFormula())for(const o of i.dependencies.references)if(!t||o.sheetId===t){const t=e(o);"NONE"!==t.changeType&&this.history.update("cells",s,i.id,"dependencies","references",i.dependencies.references.indexOf(o),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearStyles(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(this.getters.getSheet(e.sheetId),e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,s){for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let o=i.left;o<=i.right;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,format:s})}clearStyles(e,t){for(let s of t)for(let t=s.left;t<=s.right;t++)for(let i=s.top;i<=s.bottom;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:null})}handleAddColumnsRows(e,t){const s=this.getters.getSheet(e.sheetId);let i,o;"before"===e.position?(i=ms(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=ms(e.base+1,e.base+e.quantity+1),o=e.base),t(s,o,i)}import(e){for(let t of e.sheets){const s=this.getters.getSheet(t.id);for(let i in t.cells){const o=t.cells[i],[n,r]=is(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(s,o,e.styles);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cell:i,cellId:i.id,col:n,row:r,sheetId:t.id})}}}}export(e){let t=0;const s={};function i(e){for(let[t,i]of Object.entries(s))if(_s(i,e))return parseInt(t,10);return s[++t]=e,t}for(let t of e.sheets){const e={},s=Object.keys(this.cells[t.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const{col:o,row:n}of s){const s=this.getters.getCell(t.id,o,n);e[os(o,n)]={style:s.style&&i(s.style),format:s.format,content:s.content}}t.cells=e}e.styles=s}importCell(e,t,s){const i=t.style&&s[t.style]||void 0,o=this.cellUuidGenerator.uuidv4(),n={format:null==t?void 0:t.format,style:i};return this.createCell(o,(null==t?void 0:t.content)||"",n,e.id)}exportForExcel(e){this.export(e);for(let t of e.sheets)for(const e in t.cells){const[s,i]=is(e),o=this.getters.getCell(t.id,s,i),n=t.cells[e];n.value=o.evaluated.value,n.isFormula=o.isFormula()}}getCells(e){return this.cells[e]||{}}getCellById(e){const t=this.getters.getCellPosition(e);return this.cells[t.sheetId][e]}buildFormulaContent(e,t,s){let i=t;for(let[t,o]of Object.entries(s.references)){const s=this.getters.getRangeString(o,e),n=`\\${$}${t}\\${$}`;i=i.replace(new RegExp(n,"g"),s)}for(let[e,t]of Object.entries(s.strings)){const s=`\\${$}S${e}\\${$}`;i=i.replace(new RegExp(s,"g"),`"${t}"`)}for(let[e,t]of Object.entries(s.numbers)){const s=`\\${$}N${e}\\${$}`;i=i.replace(new RegExp(s,"g"),t.toString())}return i}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t.normalizedText,t.dependencies)}getCellStyle(e){return{...e.isLink()?ba:{},...e.style}}zoneToXC(e,t,s=[{colFixed:!1,rowFixed:!1}]){const i=os((t=this.getters.expandZone(e,t)).left,t.top,s[0]),o=os(t.right,t.bottom,s.length>1?s[1]:s[0]),n=this.getters.getMainCell(e,t.left,t.top),r=this.getters.getMainCell(e,t.right,t.bottom),a=n[0]==r[0]&&n[1]==r[1];return i==o||a?i:i+":"+o}setStyle(e,t,s){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){const i=this.getters.getCell(e,t,o);this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:s?{...null==i?void 0:i.style,...s}:void 0})}}copyColumnStyle(e,t,s){for(let i=0;i<e.rows.length;i++){const o=this.getFormat(e.id,t,i);if(o.style||o.format)for(let t of s)this.dispatch("UPDATE_CELL",{sheetId:e.id,col:t,row:i,...o})}}copyRowStyle(e,t,s){for(let i=0;i<e.cols.length;i++){const o=this.getFormat(e.id,i,t);if(o.style||o.format)for(let t of s)this.dispatch("UPDATE_CELL",{sheetId:e.id,col:i,row:t,...o})}}getFormat(e,t,s){const i={},[o,n]=this.getters.getMainCell(e,t,s),r=this.getters.getCell(e,o,n);return r&&(r.style&&(i.style=r.style),r.format&&(i.format=r.format)),i}updateCell(e,t,s,i){var o;const n=e.rows[s].cells[t],r="content"in i||"formula"in i,a=r?(null===(o=i.content)||void 0===o?void 0:o.replace(Sa,""))||"":(null==n?void 0:n.content)||"";let l;l=void 0!==i.style?i.style||void 0:n?n.style:void 0;let c=("format"in i?i.format:n&&n.format)||F;if((r&&!a&&!i.formula||!r&&(!n||n.isEmpty()))&&!l&&!c)return void(n&&(this.history.update("cells",e.id,n.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:n.id,col:t,row:s,sheetId:e.id,cell:void 0})));const h=(null==n?void 0:n.id)||this.cellUuidGenerator.uuidv4(),d=r,u={format:c,style:l},p=this.createCell(h,a,u,e.id);n&&!d&&p.isFormula()&&(p.assignValue(n.evaluated.value),n.evaluated.type===ke.error&&p.assignError(n.evaluated.value,n.evaluated.error)),this.history.update("cells",e.id,p.id,p),this.dispatch("UPDATE_CELL_POSITION",{cell:p,cellId:p.id,col:t,row:s,sheetId:e.id})}checkCellOutOfSheet(e,t,s){const i=this.getters.tryGetSheet(e);if(!i)return 23;return zs(t,s,{top:0,left:0,bottom:i.rows.length-1,right:i.cols.length-1})?0:18}}Ca.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Ia extends va{constructor(){super(...arguments),this.chartFigures={}}adaptRanges(e){for(let[t,s]of Object.entries(this.chartFigures))s&&(this.adaptDataSetRanges(s,t,e),this.adaptLabelRanges(s,t,e))}adaptDataSetRanges(e,t,s){for(let i of e.dataSets){if(i.labelCell){const o=s(i.labelCell);switch(o.changeType){case"REMOVE":this.history.update("chartFigures",t,"dataSets",e.dataSets.indexOf(i),"labelCell",void 0);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("chartFigures",t,"dataSets",e.dataSets.indexOf(i),"labelCell",o.range)}}const o=s(i.dataRange);switch(o.changeType){case"REMOVE":const s=e.dataSets.filter((e=>e!==i));this.history.update("chartFigures",t,"dataSets",s);break;case"RESIZE":case"MOVE":case"CHANGE":if(this.getters.getRangeString(o.range,o.range.sheetId)!==_)this.history.update("chartFigures",t,"dataSets",e.dataSets.indexOf(i),"dataRange",o.range);else{const s=e.dataSets.filter((e=>e!==i));this.history.update("chartFigures",t,"dataSets",s)}}}}adaptLabelRanges(e,t,s){if(e.labelRange){const i=s(e.labelRange);switch(i.changeType){case"REMOVE":this.history.update("chartFigures",t,"labelRange",void 0);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("chartFigures",t,"labelRange",i.range)}}}allowDispatch(e){switch(e.type){case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.checkEmptyDataset,this.checkDataset,this.checkChartExists),this.checkLabelRange);case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.checkEmptyDataset,this.checkDataset,this.checkChartDuplicate),this.checkLabelRange);default:return 0}}handle(e){var t,s;switch(e.type){case"CREATE_CHART":const i=e.position?e.position.x:0,o=e.position?e.position.y:0;this.addChartFigure(e.sheetId,this.createChartDefinition(e.definition,e.sheetId),{id:e.id,x:i,y:o,height:335,width:536,tag:"chart"});break;case"UPDATE_CHART":this.updateChartDefinition(e.id,e.definition);break;case"DUPLICATE_SHEET":{const s=this.getters.getFigures(e.sheetId);for(const i of s)if("chart"===i.tag){const s=i.id.split("??").pop(),o=`${e.sheetIdTo}??${s}`,n={...us(this.chartFigures[i.id]),id:o};n.sheetId=e.sheetIdTo,n.dataSets.forEach((t=>{var s;t.dataRange.sheetId===e.sheetId&&(t.dataRange.sheetId=e.sheetIdTo),(null===(s=t.labelCell)||void 0===s?void 0:s.sheetId)===e.sheetId&&(t.labelCell.sheetId=e.sheetIdTo)})),(null===(t=n.labelRange)||void 0===t?void 0:t.sheetId)===e.sheetId&&(n.labelRange.sheetId=e.sheetIdTo);const r={id:o,x:i.x,y:i.y,height:i.height,width:i.width,tag:"chart"};this.addChartFigure(e.sheetIdTo,n,r)}break}case"DELETE_FIGURE":this.history.update("chartFigures",e.id,void 0);break;case"DELETE_SHEET":for(let t of Object.keys(this.chartFigures))(null===(s=this.chartFigures[t])||void 0===s?void 0:s.sheetId)===e.sheetId&&this.history.update("chartFigures",t,void 0)}}getChartDefinition(e){return this.chartFigures[e]}getChartsIdBySheet(e){return Object.entries(this.chartFigures).filter((t=>t[1].sheetId===e)).map((e=>e[0]))}getChartDefinitionUI(e,t){const s=this.chartFigures[t];if(!s)return;const i=s.dataSets.map((t=>t?this.getters.getRangeString(t.dataRange,e):"")).filter((e=>""!==e));return{title:s&&s.title?s.title:"",dataSets:i,labelRange:s.labelRange?this.getters.getRangeString(s.labelRange,e):void 0,type:s?s.type:"bar",dataSetsHaveTitle:!(!s||0===i.length)&&Boolean(s.dataSets[0].labelCell),background:s.background,verticalAxisPosition:s.verticalAxisPosition,legendPosition:s.legendPosition,stackedBar:s.stackedBar}}getChartDefinitionExcel(e,t){const s=this.chartFigures[t],i=this.getChartDefinitionUI("forceSheetReference",t);if(!s||!i)return;const o=s.dataSets.map((e=>this.toExcelDataset(e))).filter((e=>""!==e.range));return{...i,backgroundColor:s.background,dataSets:o}}toExcelDataset(e){var t;const s=null===(t=e.labelCell)||void 0===t?void 0:t.zone;let i=e.dataRange.zone;if(s){const{height:e,width:t}=qs(i);1===e?i={...i,left:i.left+1}:1===t&&(i={...i,top:i.top+1})}const o={...e.dataRange,zone:i};return{label:e.labelCell?this.getters.getRangeString(e.labelCell,"forceSheetReference"):void 0,range:this.getters.getRangeString(o,"forceSheetReference")}}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)if("chart"===e.tag){const s={...e.data};this.chartFigures[e.id]=this.createChartDefinition(s,t.id),delete e.data}}export(e){if(e.sheets)for(let t of e.sheets){const e=this.getters.getFigures(t.id),s=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=this.getChartDefinitionUI(t.id,e.id);i&&(e.data=i,s.push(e))}else s.push(e)}t.figures=s}}exportForExcel(e){for(let t of e.sheets){const e=this.getters.getFigures(t.id),s=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=this.getChartDefinitionExcel(t.id,e.id);i&&(e.data=i,s.push(e))}else s.push(e)}t.charts=s}}createChartDefinition(e,t){return{...e,dataSets:this.createDataSets(e.dataSets,t,e.dataSetsHaveTitle),labelRange:e.labelRange?this.getters.getRangeFromSheetXC(t,e.labelRange):void 0,sheetId:t}}updateChartDefinition(e,t){const s=this.chartFigures[e];if(!s)throw new Error(`There is no chart with the given id: ${e}`);if(void 0!==t.title&&this.history.update("chartFigures",e,"title",t.title),t.type&&this.history.update("chartFigures",e,"type",t.type),t.dataSets){const i=!!t.dataSetsHaveTitle,o=this.createDataSets(t.dataSets,s.sheetId,i);this.history.update("chartFigures",e,"dataSets",o)}if(void 0!==t.labelRange){const i=t.labelRange?this.getters.getRangeFromSheetXC(s.sheetId,t.labelRange):void 0;this.history.update("chartFigures",e,"labelRange",i)}t.background&&this.history.update("chartFigures",e,"background",t.background),t.verticalAxisPosition&&this.history.update("chartFigures",e,"verticalAxisPosition",t.verticalAxisPosition),t.legendPosition&&this.history.update("chartFigures",e,"legendPosition",t.legendPosition),void 0!==t.stackedBar&&this.history.update("chartFigures",e,"stackedBar",t.stackedBar)}createDataSets(e,t,s){const i=[];for(const o of e){const e=this.getters.getRangeFromSheetXC(t,o),{zone:n,sheetId:r,invalidSheetName:a}=e;if(!a)if(n.left!==n.right&&n.top!==n.bottom)for(let e=n.left;e<=n.right;e++){const t={left:e,right:e,top:n.top,bottom:n.bottom};i.push(this.createDataSet(r,t,s?{top:t.top,bottom:t.top,left:t.left,right:t.left}:void 0))}else n.left===n.right&&n.top===n.bottom?s||i.push(this.createDataSet(r,n,void 0)):i.push(this.createDataSet(r,n,s?{top:n.top,bottom:n.top,left:n.left,right:n.left}:void 0))}return i}addChartFigure(e,t,s){this.dispatch("CREATE_FIGURE",{sheetId:e,figure:s}),this.history.update("chartFigures",s.id,t)}createDataSet(e,t,s){if(t.left!==t.right&&t.top!==t.bottom)throw new Error(`Zone should be a single column or row: ${Ds(t)}`);if(s){const i=Ds(t),o=Ds(s);return{labelCell:this.getters.getRangeFromSheetXC(e,o),dataRange:this.getters.getRangeFromSheetXC(e,i)}}return{labelCell:void 0,dataRange:this.getters.getRangeFromSheetXC(e,Ds(t))}}checkEmptyDataset(e){return e.definition.dataSets&&0===e.definition.dataSets.length?27:0}checkDataset(e){if(!e.definition.dataSets)return 0;const t=void 0!==e.definition.dataSets.find((e=>!es.test(e)));return t?28:0}checkLabelRange(e){if(!e.definition.labelRange)return 0;return!es.test(e.definition.labelRange||"")?29:0}checkChartDuplicate(e){for(const t of this.getters.getSheets())if(this.getters.getFigure(t.id,e.id))return 57;return 0}checkChartExists(e){return this.getters.getFigure(e.sheetId,e.id)?0:58}}function ya(e){return""===e?NaN:Number(e)}Ia.getters=["getChartDefinition","getChartDefinitionUI","getChartsIdBySheet"];class wa extends va{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const s of this.cfRules[e])for(const i of s.ranges){const o=t(i);switch(o.changeType){case"REMOVE":let t=s.ranges.slice();t.splice(s.ranges.indexOf(i),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(s),"ranges",t):this.removeConditionalFormatting(s.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(s),"ranges",s.ranges.indexOf(i),o.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){return"ADD_CONDITIONAL_FORMAT"===e.type?this.checkValidations(e,this.checkCFRule,this.checkEmptyRange):0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const s={...e.cf,ranges:e.target.map(Ds)};this.addConditionalFormatting(s,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){return this.cfRules[e].map((t=>this.mapToConditionalFormat(e,t)))||[]}getRulesSelection(e,t){const s=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{s.add(e)}))})),Array.from(s)}getRulesByZone(e,t){const s=new Set;for(let i=t.top;i<=t.bottom;i++)for(let o=t.left;o<=t.right;o++){this.getRulesByCell(e,o,i).forEach((e=>{s.add(e.id)}))}return s}getRulesByCell(e,t,s){const i=[];for(let o of this.cfRules[e])for(let e of o.ranges)zs(t,s,e.zone)&&i.push(o);return new Set(i.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const s={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return s}addConditionalFormatting(e,t){const s=this.cfRules[t].slice(),i=s.findIndex((t=>t.id===e.id)),o=this.mapToConditionalFormatInternal(t,e);i>-1?s.splice(i,1,o):s.push(o),this.history.update("cfRules",t,s)}checkEmptyRange(e){return e.target.length?0:21}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return s=>{if(t.includes(s.operator)){const t=[],i=e=>void 0===e||""===e;return e>=1&&i(s.values[0])&&t.push(36),e>=2&&i(s.values[1])&&t.push(37),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 38;case"max":return 40;case"mid":return 39;case"upperInflectionPoint":return 41;case"lowerInflectionPoint":return 42}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{Vr(Gr(e.value||""))}catch(e){switch(t){case"min":return 43;case"max":return 45;case"mid":return 44;case"upperInflectionPoint":return 46;case"lowerInflectionPoint":return 47}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,s=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(s)?33:0}checkMinBiggerThanMax(e){const t=e.minimum.value,s=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&ya(t)>=ya(s)?32:0}checkMidBiggerThanMax(e){var t;const s=null===(t=e.midpoint)||void 0===t?void 0:t.value,i=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&ya(s)>=ya(i)?34:0}checkMinBiggerThanMid(e){var t;const s=e.minimum.value,i=null===(t=e.midpoint)||void 0===t?void 0:t.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&ya(s)>=ya(i)?35:0}removeConditionalFormatting(e,t){const s=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==s){const e=this.cfRules[t].slice();e.splice(s,1),this.history.update("cfRules",t,e)}}}wa.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Ta extends va{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.getters.getFigures(e.sheetId).forEach((t=>{this.dispatch("DELETE_FIGURE",{id:t.id,sheetId:e.sheetId})})),this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:s,...i}=e,o=i;this.updateFigure(s,o);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[s,i]of Object.entries(t))switch(s){case"x":case"y":void 0!==i&&this.history.update("figures",e,t.id,s,Math.max(i,0));break;case"width":case"height":void 0!==i&&this.history.update("figures",e,t.id,s,i)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var s;return void 0===(null===(s=this.figures[e])||void 0===s?void 0:s[t])?55:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?56:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(Ms)}getFigure(e,t){var s;return null===(s=this.figures[e])||void 0===s?void 0:s[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var s;return void 0!==(null===(s=this.figures[t])||void 0===s?void 0:s[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const s=void 0;t.figures.push({...e,data:s})}}exportForExcel(e){this.export(e)}}Ta.getters=["getFigures","getFigure","getFigureSheetId"];class xa extends va{constructor(){super(...arguments),this.nextId=1,this.pending=null,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?0:this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}beforeHandle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.exportAndRemoveMerges(e.sheetId,(t=>function(e,t){let{left:s,right:i,top:o,bottom:n}=Fs(e);t=t.slice().sort(((e,t)=>t-e));for(let e of t)s>e&&(s-=1),(s>=e||i>=e)&&(i-=1);return s>i?null:os(s,o)+":"+os(i,n)}(t,e.elements)),!0):this.exportAndRemoveMerges(e.sheetId,(t=>function(e,t){let{left:s,right:i,top:o,bottom:n}=Fs(e);t=t.slice().sort(((e,t)=>t-e));for(let e of t)o>e&&(o-=1),(o>=e||n>=e)&&(n-=1);return o>n?null:os(s,o)+":"+os(i,n)}(t,e.elements)),!1);break;case"ADD_COLUMNS_ROWS":const t="before"===e.position?e.base:e.base+1;"COL"===e.dimension?this.exportAndRemoveMerges(e.sheetId,(s=>function(e,t,s){let{left:i,right:o,top:n,bottom:r}=Fs(e);return i>=t&&(i+=s),(i>=t||o>=t)&&(o+=s),i>o?null:os(i,n)+":"+os(o,r)}(s,t,e.quantity)),!0):this.exportAndRemoveMerges(e.sheetId,(s=>function(e,t,s){let{left:i,right:o,top:n,bottom:r}=Fs(e);return n>=t&&(n+=s),(n>=t||r>=t)&&(r+=s),n>r?null:os(i,n)+":"+os(o,r)}(s,t,e.quantity)),!1)}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":this.history.update("merges",e.sheetIdTo,Object.assign({},this.merges[e.sheetId])),this.history.update("mergeCellMap",e.sheetIdTo,Object.assign({},this.mergeCellMap[e.sheetId]));break;case"ADD_MERGE":if(!e.interactive)for(const t of e.target)this.addMerge(this.getters.getSheet(e.sheetId),t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t);break;case"ADD_COLUMNS_ROWS":case"REMOVE_COLUMNS_ROWS":this.pending&&(this.importMerges(this.pending.sheet,this.pending.merges),this.pending=null)}}getMerges(e){return Object.values(this.merges[e]||{}).filter(Ms)}getMerge(e,t,s){var i;const o=this.mergeCellMap[e],n=o?t in o&&(null===(i=o[t])||void 0===i?void 0:i[s]):void 0;return n?this.getMergeById(e,n):void 0}doesIntersectMerge(e,t){const{left:s,right:i,top:o,bottom:n}=t;for(let t=o;t<=n;t++)for(let o=s;o<=i;o++)if(this.getMerge(e,o,t))return!0;return!1}doesColumnsHaveCommonMerges(e,t,s){const i=this.getters.getSheet(e);for(let e=0;e<i.rows.length;e++)if(this.isInSameMerge(i.id,t,e,s,e))return!0;return!1}doesRowsHaveCommonMerges(e,t,s){const i=this.getters.getSheet(e);for(let e=0;e<=i.cols.length;e++)if(this.isInSameMerge(i.id,e,t,e,s))return!0;return!1}expandZone(e,t){let{left:s,right:i,top:o,bottom:n}=t,r={left:s,right:i,top:o,bottom:n};for(let t in this.merges[e]){const s=this.getMergeById(e,parseInt(t));s&&Hs(s,r)&&(r=Bs(s,r))}return Vs(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,s,i,o){return!(!this.isInMerge(e,t,s)||!this.isInMerge(e,i,o))&&this.getMerge(e,t,s)===this.getMerge(e,i,o)}isInMerge(e,t,s){var i;const o=this.mergeCellMap[e];return!!o&&(t in o&&Boolean(null===(i=o[t])||void 0===i?void 0:i[s]))}getMainCell(e,t,s){if(!this.isInMerge(e,t,s))return[t,s];const i=this.getMerge(e,t,s).topLeft;return[i.col,i.row]}getBottomLeftCell(e,t,s){if(!this.isInMerge(e,t,s))return[t,s];const{bottom:i,left:o}=this.getMerge(e,t,s);return[o,i]}isMergeHidden(e,t){const s=this.getters.getHiddenColsGroups(e),i=this.getters.getHiddenRowsGroups(e);for(let e of s)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of i)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const s=this.getMerge(e,t.left,t.top);if(s)return Vs(t,s);const{width:i,height:o}=qs(t);return 1===i&&1===o}isMergeDestructive(e,t){let{left:s,right:i,top:o,bottom:n}=t;i=gs(i,0,e.cols.length-1),n=gs(n,0,e.rows.length-1);for(let t=o;t<=n;t++){const n=this.getters.getRow(e.id,t);for(let e=s;e<=i;e++)if(e!==s||t!==o){const t=n.cells[e];if(t&&!t.isEmpty())return!0}}return!1}getMergeById(e,t){const s=this.merges[e];return void 0!==s?s[t]:void 0}checkDestructiveMerge({sheetId:e,target:t}){const s=this.getters.tryGetSheet(e);if(!s)return 0;return t.some((e=>this.isMergeDestructive(s,e)))?3:0}checkOverlap({target:e}){for(const t of e)for(const s of e)if(t!==s&&Hs(t,s))return 50;return 0}checkMergedContentUpdate(e){const{col:t,row:s,sheetId:i,content:o}=e;if(void 0===o)return 0;const[n,r]=this.getMainCell(i,t,s);return n===t&&r===s?0:4}checkMergeExists(e){const{sheetId:t,target:s}=e;for(const e of s){const{left:s,top:i}=e,o=this.getMerge(t,s,i);if(void 0===o||!Vs(e,o))return 5}return 0}addMerge(e,t){let{left:s,right:i,top:o,bottom:n}=t;i=gs(i,0,e.cols.length-1),n=gs(n,0,e.rows.length-1);if(os(s,o)===os(i,n))return;const r=this.getters.getCell(e.id,s,o);let a=this.nextId++;this.history.update("merges",e.id,a,{id:a,left:s,top:o,right:i,bottom:n,topLeft:{col:s,row:o}});let l=new Set;for(let t=o;t<=n;t++)for(let n=s;n<=i;n++){n===s&&t===o||this.dispatch("UPDATE_CELL",{sheetId:e.id,col:n,row:t,style:r?r.style:null,content:void 0});const i=this.getMerge(e.id,n,t);i&&l.add(i.id),this.history.update("mergeCellMap",e.id,n,t,a)}for(let t of l){const{top:s,bottom:i,left:o,right:n}=this.getMergeById(e.id,t);for(let t=s;t<=i;t++)for(let s=o;s<=n;s++){const i=this.getMerge(e.id,s,t);i&&i.id===a||(this.history.update("mergeCellMap",e.id,s,t,void 0),this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:t}))}this.history.update("merges",e.id,t,void 0)}}removeMerge(e,t){const{left:s,top:i,bottom:o,right:n}=t,r=this.getMerge(e,s,i);if(void 0!==r&&Vs(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=i;t<=o;t++)for(let i=s;i<=n;i++)this.history.update("mergeCellMap",e,i,t,void 0)}}removeAllMerges(e){for(let t in this.merges[e])this.history.update("merges",e,parseInt(t),void 0);for(let t in this.mergeCellMap[e])this.history.update("mergeCellMap",e,parseInt(t),void 0)}exportAndRemoveMerges(e,t,s){const i=this.merges[e];if(!i)return;const o=Ra(i),n=[];for(let e of o){const s=t(e);if(s){const[e,t]=s.split(":");e!==t&&n.push(s)}}this.removeAllMerges(e),this.pending={sheet:e,merges:n}}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){const s=this.getters.getSheet(e);for(let e of t)this.addMerge(s,Fs(e))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Ra(e))}}exportForExcel(e){this.export(e)}}function Ra(e){return Object.values(e).filter(Ms).map((e=>os(e.left,e.top)+":"+os(e.right,e.bottom)))}xa.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCell","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","isSingleCellOrMerge"];class La extends va{constructor(){super(...arguments),this.sheetIds={},this.visibleSheets=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":const t=this.visibleSheets.findIndex((t=>t===e.sheetId));return"left"===e.direction&&0===t||"right"===e.direction&&t===this.visibleSheets.length-1?14:0;case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.visibleSheets.length>1?0:9;case"REMOVE_COLUMNS_ROWS":const s=this.getSheet(e.sheetId);return("COL"===e.dimension?s.cols.length:s.rows.length)>e.elements.length?0:8;case"HIDE_COLUMNS_ROWS":{const t=this.sheets[e.sheetId],s="COL"===e.dimension?t.hiddenColsGroups:t.hiddenRowsGroups,i="COL"===e.dimension?t.cols:t.rows;return(s||[]).flat().concat(e.elements).length<i.length?0:51}default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIds",t.name,t.id);break;case"RESIZE_COLUMNS_ROWS":const s="COL"===e.dimension?"cols":"rows";for(let t of e.elements)this.setHeaderSize(this.getSheet(e.sheetId),s,t,e.size);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.direction);break;case"RENAME_SHEET":e.interactive||this.renameSheet(this.sheets[e.sheetId],e.name);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],e.elements):this.removeRows(this.sheets[e.sheetId],e.elements);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"HIDE_COLUMNS_ROWS":"COL"===e.dimension?this.setElementsVisibility(this.sheets[e.sheetId],e.elements,"cols","hide"):this.setElementsVisibility(this.sheets[e.sheetId],e.elements,"rows","hide");break;case"UNHIDE_COLUMNS_ROWS":"COL"===e.dimension?this.setElementsVisibility(this.sheets[e.sheetId],e.elements,"cols","show"):this.setElementsVisibility(this.sheets[e.sheetId],e.elements,"rows","show");break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e)}}import(e){for(let t of e.sheets)this.sheetIds[t.name]=t.id;for(let t of e.sheets){const e=t.name||r("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:i}=this.getImportedSheetSize(t),o={id:t.id,name:e,cols:ti(t.cols||{},s),rows:si(t.rows||{},i),hiddenColsGroups:[],hiddenRowsGroups:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible};this.visibleSheets.push(o.id),this.sheets[o.id]=o,this.updateHiddenElementsGroups(o.id,"cols"),this.updateHiddenElementsGroups(o.id,"rows")}}exportSheets(e,t=!1){e.sheets=this.visibleSheets.filter(Ms).map((e=>{const s=this.sheets[e];return{id:s.id,name:s.name,colNumber:s.cols.length,rowNumber:s.rows.length,rows:oi(s.rows,t),cols:ii(s.cols,t),merges:[],cells:{},conditionalFormats:[],figures:[],areGridLinesVisible:void 0===s.areGridLinesVisible||s.areGridLinesVisible}}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e,!0)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const s=((t=e).startsWith("'")&&(t=t.slice(1,-1).replace(/''/g,"'")),t);for(const e in this.sheetIds)if(e.toUpperCase()===s.toUpperCase())return this.sheetIds[e]}var t}getSheets(){const{visibleSheets:e,sheets:t}=this;return e.map((e=>t[e])).filter(Ms)}getVisibleSheets(){return this.visibleSheets}getEvaluationSheets(){return this.sheets}getCol(e,t){var s;return null===(s=this.sheets[e])||void 0===s?void 0:s.cols[t]}getRow(e,t){var s;return null===(s=this.sheets[e])||void 0===s?void 0:s.rows[t]}getCell(e,t,s){const i=this.tryGetSheet(e);return i&&i.rows[s]&&i.rows[s].cells[t]||void 0}getColCells(e,t){return this.getSheet(e).rows.reduce(((e,s)=>{const i=s.cells[t];return void 0!==i?e.concat(i):e}),[])}getColsZone(e,t,s){return{top:0,bottom:this.getSheet(e).rows.length-1,left:t,right:s}}getRowsZone(e,t,s){return{top:t,bottom:s,left:0,right:this.getSheet(e).cols.length-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getHiddenColsGroups(e){var t;return(null===(t=this.sheets[e])||void 0===t?void 0:t.hiddenColsGroups)||[]}getHiddenRowsGroups(e){var t;return(null===(t=this.sheets[e])||void 0===t?void 0:t.hiddenRowsGroups)||[]}getNumberCols(e){return this.getSheet(e).cols.length}getNumberRows(e){return this.getSheet(e).rows.length}getNextSheetName(e="Sheet"){let t=1;const s=this.getSheets().map((e=>e.name));let i=`${e}${t}`;for(;s.includes(i);)i=`${e}${t}`,t++;return i}isEmpty(e,t){return Ws(t,this.getSheet(e),(e=>e),void 0).flat().every((e=>!e||e.isEmpty()))}setHeaderSize(e,t,s,i){let o,n;const r=e[t],a=r[s],l=i-a.size;this.history.update("sheets",e.id,t,s,"size",i),a.isHidden||this.history.update("sheets",e.id,t,s,"end",a.end+l),o=a.end;for(let i=s+1;i<r.length;i++){const s=r[i];n=s.isHidden?o:o+s.size,this.history.update("sheets",e.id,t,i,"start",o),this.history.update("sheets",e.id,t,i,"end",n),o=n}}updateCellPosition(e){if(e.cell){const t=this.cellPosition[e.cellId];t&&this.history.update("sheets",e.sheetId,"rows",t.row,"cells",t.col,void 0),this.history.update("cellPosition",e.cell.id,{row:e.row,col:e.col,sheetId:e.sheetId}),this.history.update("sheets",e.sheetId,"rows",e.row,"cells",e.col,e.cell)}else this.history.update("cellPosition",e.cellId,void 0),this.history.update("sheets",e.sheetId,"rows",e.row,"cells",e.col,void 0)}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let s of t)for(let t=s.left;t<=s.right;t++)for(let i=s.top;i<=s.bottom;i++){this.sheets[e].rows[i].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:i})}}createSheet(e,t,s,i,o){const n={id:e,name:t,cols:Js(s),rows:ei(i),hiddenColsGroups:[],hiddenRowsGroups:[],areGridLinesVisible:!0},r=this.visibleSheets.slice();r.splice(o,0,n.id);const a=this.sheets;return this.history.update("visibleSheets",r),this.history.update("sheets",Object.assign({},a,{[n.id]:n})),n}moveSheet(e,t){const s=this.visibleSheets.slice(),i=s.findIndex((t=>t===e)),o=s.splice(i,1);s.splice(i+("left"===t?-1:1),0,o[0]),this.history.update("visibleSheets",s)}checkSheetName(e){const{visibleSheets:t,sheets:s}=this,i=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=s[e])||void 0===t?void 0:t.name.toLowerCase())===i}))?11:k.test(i)?13:0}checkSheetPosition(e){const{visibleSheets:t}=this;return e.position>t.length||e.position<0?15:0}isRenameAllowed(e){if(e.interactive)return 0;return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const s=e.name;this.history.update("sheets",e.id,"name",t.trim());const i=Object.assign({},this.sheetIds);i[t]=e.id,delete i[s],this.history.update("sheetIds",i)}duplicateSheet(e,t){const s=this.getSheet(e),i=this.getDuplicateSheetName(s.name),o=JSON.parse(JSON.stringify(s));o.id=t,o.name=i;for(let e=0;e<=o.cols.length;e++)for(let t=0;t<=o.rows.length;t++)o.rows[t]&&(o.rows[t].cells[e]=void 0);const n=this.visibleSheets.slice(),r=n.findIndex((t=>t===e));n.splice(r+1,0,o.id),this.history.update("visibleSheets",n),this.history.update("sheets",Object.assign({},this.sheets,{[o.id]:o}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:s}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:o.id,col:e,row:s,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIds);a[o.name]=o.id,this.history.update("sheetIds",a)}getDuplicateSheetName(e){let t=1;const s=this.getters.getSheets().map((e=>e.name)),i=a("Copy of %s",e);let o=i.toString();for(;s.includes(o);)o=`${i} (${t})`,t++;return o}deleteSheet(e){const t=e.name,s=Object.assign({},this.sheets);delete s[e.id],this.history.update("sheets",s);const i=this.visibleSheets.slice(),o=i.findIndex((t=>t===e.id));i.splice(o,1),this.history.update("visibleSheets",i);const n=Object.assign({},this.sheetIds);delete n[t],this.history.update("sheetIds",n)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let s of t)this.moveCellOnColumnsDeletion(e,s);this.updateColumnsStructureOnDeletion(e,t)}removeRows(e,t){t.sort(((e,t)=>t-e));for(let s of vs(t))this.moveCellOnRowsDeletion(e,s[s.length-1],s[0]),s.map((t=>this.updateRowsStructureOnDeletion(t,e)))}addColumns(e,t,s,i){this.moveCellsOnAddition(e,"before"===s?t:t+1,i,"columns"),this.updateColumnsStructureOnAddition(e,t,i)}addRows(e,t,s,i){this.addEmptyRows(e,i),this.moveCellsOnAddition(e,"before"===s?t:t+1,i,"rows"),this.updateRowsStructureOnAddition(e,t,i)}moveCellOnColumnsDeletion(e,t){for(let[s,i]of Object.entries(e.rows)){const o=parseInt(s,10);for(let s in i.cells){const n=parseInt(s,10),r=i.cells[s];r&&(n===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:n,row:o}),n>t&&this.updateCellPosition({sheetId:e.id,cellId:r.id,cell:r,col:n-1,row:o}))}}}moveCellsOnAddition(e,t,s,i){const o=[];for(const[n,r]of Object.entries(e.rows)){const a=parseInt(n,10);if("rows"!==i||a>=t)for(let n in r.cells){const l=parseInt(n,10),c=r.cells[n];c&&("rows"===i||l>=t)&&o.push({sheetId:e.id,cellId:c.id,cell:c,col:l+("columns"===i?s:0),row:a+("rows"===i?s:0)})}}for(let e of o.reverse())this.updateCellPosition(e)}moveCellOnRowsDeletion(e,t,s){const i=s-t+1;for(let[o,n]of Object.entries(e.rows)){const r=parseInt(o,10);if(r>=t&&r<=s)for(let t in n.cells){const s=parseInt(t,10);n.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:r})}if(r>s)for(let t in n.cells){const s=parseInt(t,10),o=n.cells[t];o&&this.updateCellPosition({sheetId:e.id,cellId:o.id,cell:o,col:s,row:r-i})}}}updateColumnsStructureOnDeletion(e,t){const s=[];let i=0,o=0;for(let n in e.cols){if(t.includes(parseInt(n,10)))continue;const{size:r,isHidden:a}=e.cols[n],l=a?i:i+r;s.push({name:ss(o),size:r,start:i,end:l,isHidden:a}),i=l,o++}this.history.update("sheets",e.id,"cols",s),this.updateHiddenElementsGroups(e.id,"cols")}updateColumnsStructureOnAddition(e,t,s){const i=[];let o=0,n=0;for(let r in e.cols){if(parseInt(r,10)===t){const{size:t}=e.cols[n];for(let e=0;e<s;e++)i.push({name:ss(n),size:t,start:o,end:o+t}),o+=t,n++}const{size:a,isHidden:l}=e.cols[r],c=l?o:o+a;i.push({name:ss(n),size:a,start:o,end:c,isHidden:l}),o=c,n++}this.history.update("sheets",e.id,"cols",i),this.updateHiddenElementsGroups(e.id,"cols")}updateRowsStructureOnDeletion(e,t){const s=[];let i=0,o=0;const n=t.rows.map((e=>e.cells));for(let r in t.rows){const a=t.rows[r],{size:l,isHidden:c}=a,h=c?i:i+l;parseInt(r,10)!==e&&(o++,s.push({start:i,end:h,size:l,cells:n.shift(),name:String(o),isHidden:c}),i=h)}this.history.update("sheets",t.id,"rows",s),this.updateHiddenElementsGroups(t.id,"rows")}updateRowsStructureOnAddition(e,t,s){const i=[];let o=0,n=0,r=0;const a=e.rows.map((e=>e.cells));for(let l in e.rows){const{size:c,isHidden:h}=e.rows[r],d=h?o:o+c;(parseInt(l,10)<t||parseInt(l,10)>=t+s)&&r++,n++,i.push({start:o,end:d,size:c,cells:a.shift(),name:String(n),isHidden:h}),o=d}this.history.update("sheets",e.id,"rows",i),this.updateHiddenElementsGroups(e.id,"rows")}addEmptyRows(e,t){const s=e.rows[e.rows.length-1].end,i=e.rows.slice();for(let e=0;e<t;e++)i.push({start:s,end:s,size:0,name:(i.length+1).toString(),cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(is);return{rowNumber:Math.max(e.rowNumber,Os(t.map((([e,t])=>t+1)))),colNumber:Math.max(e.colNumber,Os(t.map((([e,t])=>e+1))))}}setElementsVisibility(e,t,s,i){let o=0;const n="hide"===i;for(let i=0;i<e[s].length;i++){const{size:r,isHidden:a}=e[s][i],l=t.includes(i)?n:a||!1,c=l?o:o+r;this.history.update("sheets",e.id,s,i,"start",o),this.history.update("sheets",e.id,s,i,"end",c),this.history.update("sheets",e.id,s,i,"isHidden",l),o=c}this.updateHiddenElementsGroups(e.id,s)}updateHiddenElementsGroups(e,t){var s;const i="cols"===t?"hiddenColsGroups":"hiddenRowsGroups",o=((null===(s=this.sheets[e])||void 0===s?void 0:s[t])||[]).reduce(((e,t,s)=>{if(!t.isHidden)return e;const i=e[e.length-1];return i&&i[i.length-1]==s-1||e.push([]),e[e.length-1].push(s),e}),[]);this.history.update("sheets",e,i,o)}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?23:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?12:0}checkZones(e){const t=[];if("zone"in e&&t.push(e.zone),"target"in e&&Array.isArray(e.target)&&t.push(...e.target),!t.every($s))return 22;if(t.length&&"sheetId"in e){const s=this.getSheet(e.sheetId),i={top:0,left:0,bottom:s.rows.length-1,right:s.cols.length-1};return t.every((e=>{return Vs(Bs(t=i,e),t);var t}))?0:18}return 0}}La.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheets","getVisibleSheets","getEvaluationSheets","getCol","getRow","getCell","getCellPosition","getColCells","getColsZone","getRowsZone","getNumberCols","getNumberRows","getHiddenColsGroups","getHiddenRowsGroups","getGridLinesVisibility","getNextSheetName","isEmpty"];const Ma=new Le;Ma.add("INCREMENT_MODIFIER",{apply:(e,t)=>{var s;e.current+=e.increment;const i=e.current.toString(),o=jr(e.current,null===(s=t.cell)||void 0===s?void 0:s.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i},tooltip:i?{props:{content:o}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,s)=>{var i,o;const n=(null===(i=t.cell)||void 0===i?void 0:i.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:n},tooltip:n?{props:{content:null===(o=t.cell)||void 0===o?void 0:o.formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,s,i)=>{e.current+=e.increment;let o=0,n=0;switch(i){case 0:o=0,n=-e.current;break;case 1:o=0,n=e.current;break;case 2:o=-e.current,n=0;break;case 3:o=e.current,n=0}if(!t.cell||!t.cell.isFormula())return{cellData:{}};const r=t.sheetId,a=s.createAdaptedRanges(t.cell.dependencies.references,o,n,r),l=s.buildFormulaContent(r,t.cell.normalizedText,{...t.cell.dependencies,references:a});return{cellData:{border:t.border,style:t.cell.style,format:t.cell.format,content:l},tooltip:l?{props:{content:l}}:void 0}}});const Aa=new Le;Aa.add("simple_value_copy",{condition:(e,t)=>{var s;return 1===t.length&&!e.isFormula()&&!(null===(s=e.format)||void 0===s?void 0:s.match(A))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("copy_text",{condition:e=>!e.isFormula()&&e.evaluated.type===ke.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula(),generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_number",{condition:e=>e.evaluated.type===ke.number,generateRule:(e,t)=>{const s=function(e,t){let s=[],i=!1;for(let o of t)if(o===e&&(i=!0),(null==o?void 0:o.evaluated.type)===ke.number)s.push(o.evaluated.value);else{if(i)return s;s=[]}return s}(e,t);let i=1;return 2==s.length?i=2*(s[1]-s[0]):s.length>2&&(i=function(e){const t=[];let s=e[0];for(let i=1;i<e.length;i++){const o=e[i];t.push(o-s),s=o}return t.reduce(((e,t)=>e+t),0)/t.length}(s)*s.length),{type:"INCREMENT_MODIFIER",increment:i,current:e.evaluated.type===ke.number?e.evaluated.value:0}},sequence:40});const _a=new Le,Oa=(new Le).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let s=e.base;"after"===e.position&&s++;for(let i=0;i<e.quantity;i++)t.push(i+s);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],s=[...e.elements].sort(((e,t)=>e-t));for(let i of vs(s)){const s=0===i[0]?0:i[0]-1,o=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:s,sheetId:e.sheetId,position:o})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of De.values())Oa.contains(e)||Oa.add(e,Na);function Na(e){return[e]}const ka=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,shortCut:"",action:!1,children:[],separator:!1,icon:!1,id:e});function Fa(e,t){return Object.assign({},ka(e),t)}class $a extends Le{add(e,t){return this.content[e]=Fa(e,t),this}addChild(e,t,s){const i=t.splice(0,1)[0];let o=this.content[i];if(!o)throw new Error(`Path ${i+":"+t.join(":")} not found`);for(let e of t)if(o="function"==typeof o.children?void 0:o.children.find((t=>t.id===e)),!o)throw new Error(`Path ${i+":"+t.join(":")} not found`);return o.children.push(Fa(e,s)),this}getChildren(e,t){return"function"==typeof e.children?e.children(t).sort(((e,t)=>e.sequence-t.sequence)):e.children.sort(((e,t)=>e.sequence-t.sequence))}getName(e,t){return"function"==typeof e.name?e.name(t):e.name}getShortCut(e){return e.shortCut?e.shortCut:""}getAll(){return super.getAll().sort(((e,t)=>e.sequence-t.sequence))}}function Da(e){const t=e.getters.getActiveCols();if(t.size)return t.size;{const t=e.getters.getSelectedZones()[0];return t.right-t.left+1}}function Ua(e){const t=e.getters.getActiveRows();if(t.size)return t.size;{const t=e.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function Pa(e,t){e.dispatch("SET_FORMATTING",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones(),format:t})}function Ba(e,t){e.dispatch("SET_FORMATTING",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones(),style:t})}const Va=async e=>{e.dispatch("COPY",{target:e.getters.getSelectedZones()}),await e.clipboard.writeText(e.getters.getClipboardContent())},Ha=async e=>{e.dispatch("CUT",{target:e.getters.getSelectedZones()}),await e.clipboard.writeText(e.getters.getClipboardContent())},za=async e=>{const t=e.getters.getClipboardContent();let s;try{s=await e.clipboard.readText()}catch(e){console.warn("The OS clipboard could not be read."),console.error(e)}const i=e.getters.getSelectedZones();s&&s!==t?e.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:i,text:s}):e.dispatch("PASTE",{target:i,interactive:!0})},Za=e=>e.dispatch("PASTE",{target:e.getters.getSelectedZones(),pasteOption:"onlyValue"}),Ga=e=>e.dispatch("PASTE",{target:e.getters.getSelectedZones(),pasteOption:"onlyFormat"}),Wa=e=>e.dispatch("DELETE_CONTENT",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones()}),qa=e=>{let t,s;const i=e.getters.getActiveRows();if(0!==i.size)t=Ns([...i]),s=Os([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.top,s=i.bottom}return t===s?a("Delete row %s",(t+1).toString()):a("Delete rows %s - %s",(t+1).toString(),(s+1).toString())},ja=e=>{let t=[...e.getters.getActiveRows()];if(!t.length){const s=e.getters.getSelectedZones()[0];for(let e=s.top;e<=s.bottom;e++)t.push(e)}e.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Ya=e=>{let t,s;const i=e.getters.getActiveCols();if(0!==i.size)t=Ns([...i]),s=Os([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.left,s=i.right}return t===s?a("Delete column %s",ss(t)):a("Delete columns %s - %s",ss(t),ss(s))},Xa=e=>{let t=[...e.getters.getActiveCols()];if(!t.length){const s=e.getters.getSelectedZones()[0];for(let e=s.left;e<=s.right;e++)t.push(e)}e.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"COL",elements:t})},Ka=e=>{const t=e.getters.getSelectedZone();e.dispatch("INSERT_CELL",{shiftDimension:"ROW",zone:t,interactive:!0})},Qa=e=>{const t=e.getters.getSelectedZone();e.dispatch("INSERT_CELL",{shiftDimension:"COL",zone:t,interactive:!0})},Ja=e=>{const t=e.getters.getSelectedZone();e.dispatch("DELETE_CELL",{shiftDimension:"ROW",zone:t,interactive:!0})},el=e=>{const t=e.getters.getSelectedZone();e.dispatch("DELETE_CELL",{shiftDimension:"COL",zone:t,interactive:!0})},tl=e=>{const t=e.getters.getActiveRows();let s,i;if(t.size)s=Ns([...t]),i=t.size;else{const t=e.getters.getSelectedZones()[0];s=t.top,i=t.bottom-t.top+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"before",base:s,quantity:i,dimension:"ROW"})},sl=e=>{const t=e.getters.getActiveRows();let s,i;if(t.size)s=Os([...t]),i=t.size;else{const t=e.getters.getSelectedZones()[0];s=t.bottom,i=t.bottom-t.top+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"after",base:s,quantity:i,dimension:"ROW"})},il=e=>{const t=e.getters.getActiveCols();let s,i;if(t.size)s=Ns([...t]),i=t.size;else{const t=e.getters.getSelectedZones()[0];s=t.left,i=t.right-t.left+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"before",dimension:"COL",base:s,quantity:i})},ol=e=>{const t=e.getters.getActiveCols();let s,i;if(t.size)s=Os([...t]),i=t.size;else{const t=e.getters.getSelectedZones()[0];s=t.right,i=t.right-t.left+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"after",dimension:"COL",base:s,quantity:i})},nl=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.getters.getSelectedZones()})},rl=e=>{e.openLinkEditor()},al=e=>{const{anchor:t,zones:s}=e.getters.getSelection();e.dispatch("SORT_CELLS",{interactive:!0,sheetId:e.getters.getActiveSheetId(),anchor:t,zone:s[0],sortDirection:"ascending"})},ll=e=>{const{anchor:t,zones:s}=e.getters.getSelection();e.dispatch("SORT_CELLS",{interactive:!0,sheetId:e.getters.getActiveSheetId(),anchor:t,zone:s[0],sortDirection:"descending"})},cl=e=>1===e.getters.getSelectedZones().length,hl=new $a;hl.add("cut",{name:a("Cut"),shortCut:"Ctrl+X",sequence:10,action:Ha}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Va}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:za,isVisible:cl}).add("paste_special",{name:a("Paste special"),sequence:40,separator:!0,isVisible:cl}).addChild("paste_value_only",["paste_special"],{name:a("Paste values only"),sequence:10,action:Za}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Ga}).add("sort_range",{name:a("Sort range"),sequence:50,isVisible:cl,separator:!0}).addChild("sort_ascending",["sort_range"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:al}).addChild("sort_descending",["sort_range"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ll}).add("add_row_before",{name:e=>{const t=Ua(e);return 1===t?a("Insert row"):a("Insert %s rows",t.toString())},sequence:70,action:tl,isVisible:cl}).add("add_column_before",{name:e=>{const t=Da(e);return 1===t?a("Insert column"):a("Insert %s columns",t.toString())},sequence:90,action:il,isVisible:cl}).add("insert_cell",{name:a("Insert cells"),sequence:100,isVisible:cl,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:a("Shift down"),sequence:10,action:Ka}).addChild("insert_cell_right",["insert_cell"],{name:a("Shift right"),sequence:20,action:Qa}).add("delete_row",{name:qa,sequence:110,action:ja,isVisible:cl}).add("delete_column",{name:Ya,sequence:120,action:Xa,isVisible:cl}).add("delete_cell",{name:a("Delete cells"),sequence:130,isVisible:cl}).addChild("delete_cell_up",["delete_cell"],{name:a("Shift up"),sequence:10,action:Ja}).addChild("delete_cell_down",["delete_cell"],{name:a("Shift left"),sequence:20,action:el}).add("clear_cell",{name:a("Clear cells"),sequence:140,action:Wa,isEnabled:e=>{const t=e.getters.getActiveCell();return Boolean(t)},separator:!0}).add("insert_link",{name:a("Insert link"),separator:!0,sequence:150,action:rl}).add("conditional_formatting",{name:a("Conditional formatting"),sequence:160,action:nl,separator:!0});const dl=new $a;dl.add("cut",{name:a("Cut"),shortCut:"Ctrl+X",sequence:10,action:Ha}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Va}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:za}).add("paste_special",{name:a("Paste special"),sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{name:a("Paste value only"),sequence:10,action:Za}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Ga}).add("sort_columns",{name:e=>e.getters.getActiveCols().size>1?a("Sort columns"):a("Sort column"),sequence:50,isVisible:cl,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:al}).addChild("sort_descending",["sort_columns"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ll}).add("add_column_before",{name:e=>{const t=Da(e);return 1===t?a("Insert column left"):a("Insert %s columns left",t.toString())},sequence:70,action:il}).add("add_column_after",{name:e=>{const t=Da(e);return 1===t?a("Insert column right"):a("Insert %s columns right",t.toString())},sequence:80,action:ol}).add("delete_column",{name:Ya,sequence:90,action:Xa}).add("clear_column",{name:e=>{let t,s;const i=e.getters.getActiveCols();if(0!==i.size)t=Ns([...i]),s=Os([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.left,s=i.right}return t===s?a("Clear column %s",ss(t)):a("Clear columns %s - %s",ss(t),ss(s))},sequence:100,action:e=>{const t=e.getters.getActiveSheetId(),s=[...e.getters.getActiveCols()].map((s=>e.getters.getColsZone(t,s,s)));e.dispatch("DELETE_CONTENT",{target:s,sheetId:e.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.getters.getElementsFromSelection("COL");let s=t[0],i=t[t.length-1];return 1===t.length?a("Hide column %s",ss(s).toString()):i-s+1===t.length?a("Hide columns %s - %s",ss(s).toString(),ss(i).toString()):a("Hide columns")},sequence:85,action:e=>{const t=e.getters.getElementsFromSelection("COL");e.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.getters.getActiveSheet(),s=e.getters.getHiddenColsGroups(t.id).flat();return t.cols.length>s.length+e.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:"Unhide columns",sequence:86,action:e=>{const t=e.getters.getElementsFromSelection("COL");e.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.getters.getHiddenColsGroups(e.getters.getActiveSheetId()).flat();return e.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:a("Conditional formatting"),sequence:110,action:nl});const ul=new $a;ul.add("sheet",{name:a("Link sheet"),sequence:10,children:e=>e.getters.getSheets().map(((e,t)=>Fa(e.id,{name:e.name,sequence:t,action:()=>{return{link:{label:e.name,url:(t=e.id,`${xs}${t}`)},urlRepresentation:e.name,isUrlEditable:!1};var t}})))});const pl=new $a;pl.add("cut",{name:a("Cut"),sequence:10,shortCut:"Ctrl+X",action:Ha}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Va}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:za}).add("paste_special",{name:a("Paste special"),sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{name:a("Paste value only"),sequence:10,action:Za}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Ga}).add("add_row_before",{name:e=>{const t=Ua(e);return 1===t?a("Insert row above"):a("Insert %s rows above",t.toString())},sequence:50,action:tl}).add("add_row_after",{name:e=>{const t=Ua(e);return 1===t?a("Insert row below"):a("Insert %s rows below",t.toString())},sequence:60,action:sl}).add("delete_row",{name:qa,sequence:70,action:ja}).add("clear_row",{name:e=>{let t,s;const i=e.getters.getActiveRows();if(0!==i.size)t=Ns([...i]),s=Os([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.top,s=i.bottom}return t===s?a("Clear row %s",(t+1).toString()):a("Clear rows %s - %s",(t+1).toString(),(s+1).toString())},sequence:80,action:e=>{const t=e.getters.getActiveSheetId(),s=[...e.getters.getActiveRows()].map((s=>e.getters.getRowsZone(t,s,s)));e.dispatch("DELETE_CONTENT",{target:s,sheetId:e.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.getters.getElementsFromSelection("ROW");let s=t[0],i=t[t.length-1];return 1===t.length?a("Hide row %s",(s+1).toString()):i-s+1===t.length?a("Hide rows %s - %s",(s+1).toString(),(i+1).toString()):a("Hide rows")},sequence:85,action:e=>{const t=e.getters.getElementsFromSelection("ROW");e.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.getters.getActiveSheet(),s=e.getters.getHiddenRowsGroups(t.id).flat();return t.rows.length>s.length+e.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:"Unhide rows",sequence:86,action:e=>{const t=e.getters.getElementsFromSelection("ROW");e.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.getters.getHiddenRowsGroups(e.getters.getActiveSheetId()).flat();return e.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:a("Conditional formatting"),sequence:90,action:nl});const gl=new $a;gl.add("delete",{name:a("Delete"),sequence:10,isVisible:e=>e.getters.getSheets().length>1,action:e=>e.dispatch("DELETE_SHEET_CONFIRMATION",{sheetId:e.getters.getActiveSheetId()})}).add("duplicate",{name:a("Duplicate"),sequence:20,action:e=>{const t=e.getters.getActiveSheetId(),s=e.uuidGenerator.uuidv4();e.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:s}),e.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:s})}}).add("rename",{name:a("Rename"),sequence:30,action:e=>e.dispatch("RENAME_SHEET",{interactive:!0,sheetId:e.getters.getActiveSheetId()})}).add("move_right",{name:a("Move right"),sequence:40,isVisible:e=>{const t=e.getters.getActiveSheetId(),s=e.getters.getSheets();return s.findIndex((e=>e.id===t))!==s.length-1},action:e=>e.dispatch("MOVE_SHEET",{sheetId:e.getters.getActiveSheetId(),direction:"right"})}).add("move_left",{name:a("Move left"),sequence:50,isVisible:e=>{const t=e.getters.getActiveSheetId();return 0!==e.getters.getSheets().findIndex((e=>e.id===t))},action:e=>e.dispatch("MOVE_SHEET",{sheetId:e.getters.getActiveSheetId(),direction:"left"})});const fl=new $a;fl.add("file",{name:a("File"),sequence:10}).add("edit",{name:a("Edit"),sequence:20}).add("view",{name:a("View"),sequence:30}).add("insert",{name:a("Insert"),sequence:40}).add("format",{name:a("Format"),sequence:50}).add("data",{name:a("Data"),sequence:60}).addChild("save",["file"],{name:a("Save"),shortCut:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:a("Undo"),shortCut:"Ctrl+Z",sequence:10,action:e=>e.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:a("Redo"),shortCut:"Ctrl+Y",sequence:20,action:e=>e.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:a("Copy"),shortCut:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:Va}).addChild("cut",["edit"],{name:a("Cut"),shortCut:"Ctrl+X",sequence:40,action:Ha}).addChild("paste",["edit"],{name:a("Paste"),shortCut:"Ctrl+V",sequence:50,action:za}).addChild("paste_special",["edit"],{name:a("Paste special"),sequence:60,separator:!0}).addChild("paste_special_value",["edit","paste_special"],{name:a("Paste value only"),sequence:10,action:Za}).addChild("paste_special_format",["edit","paste_special"],{name:a("Paste format only"),sequence:20,action:Ga}).addChild("sort_range",["edit"],{name:a("Sort range"),sequence:62,isVisible:cl,separator:!0}).addChild("sort_ascending",["edit","sort_range"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:al}).addChild("sort_descending",["edit","sort_range"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ll}).addChild("find_and_replace",["edit"],{name:a("Find and replace"),shortCut:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:a("Delete values"),sequence:70,action:Wa}).addChild("edit_delete_row",["edit"],{name:qa,sequence:80,action:ja}).addChild("edit_delete_column",["edit"],{name:Ya,sequence:90,action:Xa}).addChild("edit_delete_cell_shift_up",["edit"],{name:a("Delete cell and shift up"),sequence:93,action:Ja}).addChild("edit_delete_cell_shift_left",["edit"],{name:a("Delete cell and shift left"),sequence:97,action:el}).addChild("edit_unhide_columns",["edit"],{name:a("Unhide all columns"),sequence:100,action:e=>{const t=e.getters.getActiveSheet();e.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t.id,dimension:"COL",elements:Array.from(Array(t.cols.length).keys())})},isVisible:e=>e.getters.getHiddenColsGroups(e.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:a("Unhide all rows"),sequence:100,action:e=>{const t=e.getters.getActiveSheet();e.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t.id,dimension:"ROW",elements:Array.from(Array(t.rows.length).keys())})},isVisible:e=>e.getters.getHiddenRowsGroups(e.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=Ua(e);return 1===t?a("Row above"):a("%s Rows above",t.toString())},sequence:10,action:tl,isVisible:e=>0===e.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Ua(e);return 1===t?a("Row below"):a("%s Rows below",t.toString())},sequence:20,action:sl,isVisible:e=>0===e.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Da(e);return 1===t?a("Column left"):a("%s Columns left",t.toString())},sequence:30,action:il,isVisible:e=>0===e.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Da(e);return 1===t?a("Column right"):a("%s Columns right",t.toString())},sequence:40,action:ol,isVisible:e=>0===e.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:a("Insert cells and shift down"),sequence:43,action:Ka}).addChild("insert_insert_cell_shift_right",["insert"],{name:a("Insert cells and shift right"),sequence:47,action:Qa,separator:!0}).addChild("insert_chart",["insert"],{name:a("Chart"),sequence:50,action:e=>{var t,s;const i=e.getters.getSelectedZone();let o=i;const n=e.uuidGenerator.uuidv4();let r;i.left!==i.right&&(o={...i,left:i.left+1});const a=[Ds(o)],l=e.getters.getActiveSheetId(),c={x:(null===(t=e.getters.getCol(l,i.right+1))||void 0===t?void 0:t.start)||0,y:(null===(s=e.getters.getRow(l,i.top))||void 0===s?void 0:s.start)||0};let h=!1;for(let t=o.left;t<=o.right;t++){const s=e.getters.getCell(l,t,i.top);if(s&&s.evaluated.type!==ke.number){h=!0;break}}i.left!==i.right&&(r=Ds({...i,right:i.left,top:h?i.top+1:i.top})),e.dispatch("CREATE_CHART",{sheetId:l,id:n,position:c,definition:{title:"",dataSets:a,labelRange:r,type:"bar",stackedBar:!1,dataSetsHaveTitle:h,background:g,verticalAxisPosition:"left",legendPosition:"top"}});const d=e.getters.getFigure(l,n);e.openSidePanel("ChartPanel",{figure:d})}}).addChild("insert_link",["insert"],{name:a("Link"),separator:!0,sequence:60,action:rl}).addChild("insert_sheet",["insert"],{name:a("New sheet"),sequence:70,action:e=>{const t=e.getters.getActiveSheetId(),s=e.getters.getVisibleSheets().findIndex((e=>e===t))+1,i=e.uuidGenerator.uuidv4();e.dispatch("CREATE_SHEET",{sheetId:i,position:s}),e.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},separator:!0}).addChild("view_gridlines",["view"],{name:e=>e.getters.getGridLinesVisibility(e.getters.getActiveSheetId())?a("Hide gridlines"):a("Show gridlines"),action:e=>{const t=e.getters.getActiveSheetId();e.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.getters.getGridLinesVisibility(t)})},sequence:5,separator:!0}).addChild("view_formulas",["view"],{name:e=>e.getters.shouldShowFormulas()?a("Hide formulas"):a("Show formulas"),action:e=>e.dispatch("SET_FORMULA_VISIBILITY",{show:!e.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:10}).addChild("format_number",["format"],{name:a("Numbers"),sequence:10,separator:!0}).addChild("format_number_general",["format","format_number"],{name:a("General"),sequence:10,separator:!0,action:e=>Pa(e,"")}).addChild("format_number_number",["format","format_number"],{name:a("Number (1,000.12)"),sequence:20,action:e=>Pa(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:a("Percent (10.12%)"),sequence:30,separator:!0,action:e=>Pa(e,"0.00%")}).addChild("format_number_date",["format","format_number"],{name:a("Date (9/26/2008)"),sequence:40,action:e=>Pa(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:a("Time (10:43:00 PM)"),sequence:50,action:e=>Pa(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:a("Date time (9/26/2008 22:43:00)"),sequence:60,action:e=>Pa(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:a("Duration (27:51:38)"),sequence:70,separator:!0,action:e=>Pa(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:a("Bold"),sequence:20,shortCut:"Ctrl+B",action:e=>Ba(e,{bold:!e.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:a("Italic"),sequence:30,shortCut:"Ctrl+I",action:e=>Ba(e,{italic:!e.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:a("Underline"),shortCut:"Ctrl+U",sequence:40,action:e=>Ba(e,{underline:!e.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:a("Strikethrough"),sequence:50,action:e=>Ba(e,{strikethrough:!e.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:a("Font size"),sequence:60,separator:!0}).addChild("format_cf",["format"],{name:a("Conditional formatting"),sequence:70,action:nl,separator:!0});for(let e of cs)fl.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>Ba(t,{fontSize:e.pt})});const ml=new class extends Le{addTransformation(e,t,s){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,s);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},{css:vl,xml:El}=t.tags,Sl=[["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff"],["#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff"],["#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc"],["#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd"],["#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0"],["#a61c00","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79"],["#85200c","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#0b5394","#351c75","#741b47"],["#5b0f00","#660000","#783f04","#7f6000","#274e13","#0c343d","#1c4587","#073763","#20124d","#4c1130"]],bl=24*Math.max(...Sl.map((e=>e.length)))+12;class Cl extends t.Component{constructor(){super(...arguments),this.COLORS=Sl}onColorClick(e){const t=e.target.dataset.color;t&&this.trigger("color-picked",{color:t})}}Cl.template=El`
2
2
  <div class="o-color-picker"
3
3
  t-att-class="props.dropdownDirection || 'right'"
4
4
  t-on-click="onColorClick">
@@ -1234,12 +1234,12 @@
1234
1234
  <c:f>${e}</c:f>
1235
1235
  <c:numCache />
1236
1236
  </c:numRef>
1237
- `}function hu(e){const t=e.content,s=ar.content,i=[];let o=Qd``;if(dr(t).filter((e=>"FUNCTION"===e.type)).every((e=>s[e.value.toUpperCase()].isExported))){let s=Qd``;const n=uu(t);return"#CYCLE"===e.value&&(i.push(["t","str"]),s=Qd`<v>${e.value}</v>`),o=Qd`
1237
+ `}function hu(e){const t=e.content,s=ar.content,i=[];let o=Qd``;const n=dr(t).filter((e=>"FUNCTION"===e.type)).every((e=>s[e.value.toUpperCase()].isExported)),r=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(e.value);if(n){return o=Qd`
1238
1238
  <f>
1239
- ${n}
1239
+ ${uu(t)}
1240
1240
  </f>
1241
- ${s}
1242
- `,{attrs:i,node:o}}{const t=e.value;if(""===t)return;const s=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);return i.push(["t",s]),o=Qd`<v>${t}</v>`,{attrs:i,node:o}}}function du(e,t){let s=e;const i=[];return["TRUE","FALSE"].includes(s.trim())?(s="TRUE"===s?"1":"0",i.push(["t","b"])):J(s)||(s=Vd(e,t),i.push(["t","s"])),{attrs:i,node:Qd`<v>${s}</v>`}}function uu(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Or(e)}catch(t){return e}return t=Nr(t,"STRING",pu),t=Nr(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),s=e.args,i=Nd[t];if(i){const o=ar.content[t].args.filter((e=>!e.optional)),n=o.length-e.args.length;if(n)for(let t=e.args.length;t<o.length;t++){const e=i[t-n];s.push({type:e.type,value:e.value})}}return{...e,args:s}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:kd.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?kr(t):e}function pu(e){const t=e.value.replace(new RegExp('"',"g"),""),s=G(t);if(s){let i=[];return(t.match(H)||t.match(z))&&i.push("yyyy-mm-dd"),t.match(Z)&&i.push("hh:mm:ss"),{...e,value:`"${j({value:s.value,format:i.join(" ")})}"`}}return{...e,value:e.value.replace(/\\"/g,'""')}}function gu(e,t){const s=[];for(const i of t)switch(i.rule.type){case"CellIsRule":s.push(fu(i,i.rule,e));break;case"ColorScaleRule":s.push(mu(i,i.rule));break;case"IconSetRule":s.push(vu(i,i.rule));break;default:console.warn(`Conditional formatting ${i.rule.type} not implemented`)}return s}function fu(e,t,s){const i=Eu(e),o=Fd(t.operator);i.push(...function(e){const t=Fd(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 n=function(e,t){const s=e[0].split(":")[0],i=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${i[0]}",${s})))`];case"NotContains":return[`ISERROR(SEARCH("${i[0]}",${s}))`];case"BeginsWith":return[`LEFT(${s},LEN("${i[0]}"))="${i[0]}"`];case"EndsWith":return[`RIGHT(${s},LEN("${i[0]}"))="${i[0]}"`];case"IsEmpty":return[`LEN(TRIM(${s}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${s}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[i[0]];case"Between":case"NotBetween":return[i[0],i[1]]}}(e.ranges,t).map((e=>Qd`<formula>${e}</formula>`)),r={font:{color:t.style.textColor,bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};return t.style.fillColor&&(r.fill={fgColor:t.style.fillColor}),i.push(["dxfId",Vd(r,s)]),Qd`
1241
+ ${Qd`<v>${e.value}</v>`}
1242
+ `,i.push(["t",r]),{attrs:i,node:o}}if(""!==e.value)return i.push(["t",r]),o=Qd`<v>${e.value}</v>`,{attrs:i,node:o}}function du(e,t){let s=e;const i=[];return["TRUE","FALSE"].includes(s.trim())?(s="TRUE"===s?"1":"0",i.push(["t","b"])):J(s)||(s=Vd(e,t),i.push(["t","s"])),{attrs:i,node:Qd`<v>${s}</v>`}}function uu(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Or(e)}catch(t){return e}return t=Nr(t,"STRING",pu),t=Nr(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),s=e.args,i=Nd[t];if(i){const o=ar.content[t].args.filter((e=>!e.optional)),n=o.length-e.args.length;if(n)for(let t=e.args.length;t<o.length;t++){const e=i[t-n];s.push({type:e.type,value:e.value})}}return{...e,args:s}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:kd.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?kr(t):e}function pu(e){const t=e.value.replace(new RegExp('"',"g"),""),s=G(t);if(s){let i=[];return(t.match(H)||t.match(z))&&i.push("yyyy-mm-dd"),t.match(Z)&&i.push("hh:mm:ss"),{...e,value:`"${j({value:s.value,format:i.join(" ")})}"`}}return{...e,value:e.value.replace(/\\"/g,'""')}}function gu(e,t){const s=[];for(const i of t)switch(i.rule.type){case"CellIsRule":s.push(fu(i,i.rule,e));break;case"ColorScaleRule":s.push(mu(i,i.rule));break;case"IconSetRule":s.push(vu(i,i.rule));break;default:console.warn(`Conditional formatting ${i.rule.type} not implemented`)}return s}function fu(e,t,s){const i=Eu(e),o=Fd(t.operator);i.push(...function(e){const t=Fd(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 n=function(e,t){const s=e[0].split(":")[0],i=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${i[0]}",${s})))`];case"NotContains":return[`ISERROR(SEARCH("${i[0]}",${s}))`];case"BeginsWith":return[`LEFT(${s},LEN("${i[0]}"))="${i[0]}"`];case"EndsWith":return[`RIGHT(${s},LEN("${i[0]}"))="${i[0]}"`];case"IsEmpty":return[`LEN(TRIM(${s}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${s}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[i[0]];case"Between":case"NotBetween":return[i[0],i[1]]}}(e.ranges,t).map((e=>Qd`<formula>${e}</formula>`)),r={font:{color:t.style.textColor,bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};return t.style.fillColor&&(r.fill={fgColor:t.style.fillColor}),i.push(["dxfId",Vd(r,s)]),Qd`
1243
1243
  <conditionalFormatting sqref="${e.ranges.join(" ")}">
1244
1244
  <cfRule ${jd(i)}>
1245
1245
  ${Kd(n)}
@@ -3072,4 +3072,4 @@
3072
3072
  height: ${15}px;
3073
3073
  vertical-align: sub;
3074
3074
  }
3075
- `;class Hf extends t.Component{constructor(e,s={}){super(e,s),this.model=new Ou(this.props.data,{notifyUser:e=>this.trigger("notify-user",{content:e}),askConfirmation:(e,t,s)=>this.trigger("ask-confirmation",{content:e,confirm:t,cancel:s}),editText:(e,t,s)=>this.trigger("edit-text",{title:e,placeholder:t,callback:s}),openSidePanel:(e,t={})=>this.openSidePanel(e,t),evalContext:{env:this.env},transportService:this.props.transportService,client:this.props.client,isReadonly:this.props.isReadonly,snapshotRequested:this.props.snapshotRequested},this.props.stateUpdateMessages),this.grid=Df("grid"),this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.linkEditor=t.useState({isOpen:!1}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.clipBoardString="",this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},$f({openSidePanel:(e,t={})=>this.openSidePanel(e,t),toggleSidePanel:(e,t={})=>this.toggleSidePanel(e,t),dispatch:this.model.dispatch,getters:this.model.getters,uuidGenerator:this.model.uuidGenerator,_t:Hf._t,clipboard:navigator.clipboard,export:this.model.exportData.bind(this.model),waitForIdle:this.model.waitForIdle.bind(this.model),exportXLSX:this.model.exportXLSX.bind(this.model),openLinkEditor:()=>this.openLinkEditor()}),Ff(window,"resize",this.render),Ff(document.body,"cut",this.copy.bind(this,!0)),Ff(document.body,"copy",this.copy.bind(this,!1)),Ff(document.body,"paste",this.paste),Ff(document.body,"keyup",this.onKeyup.bind(this)),Ff(window,"beforeunload",this.leaveCollaborativeSession.bind(this)),this.activateFirstSheet()}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}mounted(){this.model.on("update",this,this.render),this.model.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.props.client&&this.model.joinSession(this.props.client)}willUnmount(){this.leaveCollaborativeSession()}async willUpdateProps(e){this.props.isReadonly!==e.isReadonly&&this.model.updateReadOnly(e.isReadonly)}leaveCollaborativeSession(){this.model.off("update",this),this.model.leaveSession()}activateFirstSheet(){const e=this.model.getters.getActiveSheetId(),[t]=this.model.getters.getSheets();t.id!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:t.id})}destroy(){this.model.destroy(),super.destroy()}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}openLinkEditor(){this.linkEditor.isOpen=!0}closeLinkEditor(){this.linkEditor.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}copy(e,t){if(!this.grid.el.contains(document.activeElement))return;if("inactive"!==this.model.getters.getEditionMode())return;const s=e?"CUT":"COPY",i=this.model.getters.getSelectedZones();this.model.dispatch(s,{target:i});const o=this.model.getters.getClipboardContent();this.clipBoardString=o,t.clipboardData.setData("text/plain",o),t.preventDefault()}paste(e){if(!this.grid.el.contains(document.activeElement))return;const t=e.clipboardData;if(t.types.indexOf("text/plain")>-1){const e=t.getData("text/plain"),s=this.model.getters.getSelectedZones();this.clipBoardString===e?this.model.dispatch("PASTE",{target:s,interactive:!0}):this.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:s,text:e})}}save(){this.trigger("save-content",{data:this.model.exportData()})}onKeyup(e){"Control"===e.key&&this.model.getters.getSelectionMode()!==xh.expanding&&this.model.dispatch("STOP_SELECTION")}onKeydown(e){"Control"!==e.key||e.repeat||this.model.dispatch(this.model.getters.getSelectionMode()===xh.idle?"PREPARE_SELECTION_EXPANSION":"START_SELECTION_EXPANSION");let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let s=this.keyDownMapping[t];if(s)return e.preventDefault(),e.stopPropagation(),void s()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent(e.detail||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerContentFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent(e.detail||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerCellFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent(e.detail||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}}Hf.template=Bf,Hf.style=Vf,Hf.components={TopBar:kf,Grid:nf,BottomBar:ep,SidePanel:df,LinkEditor:Pg},Hf._t=e=>e;const zf={},Zf={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:f,HEADER_WIDTH:m,TOPBAR_HEIGHT:v,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:E,DEFAULT_CELL_HEIGHT:S,SCROLLBAR_WIDTH:b},Gf={autofillModifiersRegistry:Ma,autofillRulesRegistry:Aa,cellMenuRegistry:hl,colMenuRegistry:dl,linkMenuRegistry:ul,functionRegistry:ar,uiPluginRegistry:ad,corePluginRegistry:rd,rowMenuRegistry:pl,sidePanelRegistry:Sh,sheetMenuRegistry:gl,topbarMenuRegistry:fl,topbarComponentRegistry:bh,otRegistry:ml,inverseCommandRegistry:Oa,cellRegistry:qr},Wf={LinkCell:sa},qf={args:_e,toBoolean:ge,toNumber:he,toString:ue,toXC:os,toZone:Fs,toCartesian:is,numberToLetters:ss,createFullMenuItem:Fa,UuidGenerator:ni,formatDecimal:re,computeTextWidth:fs,isMarkdownLink:ys,parseMarkdownLink:Ts,markdownLink:ws,createEmptyWorkbookData:fa};e.CorePlugin=va,e.DATETIME_FORMAT=A,e.DataSource=hd,e.DispatchResult=Pe,e.Model=Ou,e.Revision=Kh,e.SPREADSHEET_DIMENSIONS=Zf,e.Spreadsheet=Hf,e.UIPlugin=Ch,e.__DEBUG__=As,e.__info__=zf,e.astToFormula=kr,e.cellTypes=Wf,e.convertAstNodes=Nr,e.coreTypes=De,e.functionCache=Br,e.helpers=qf,e.invalidateEvaluationCommands=Fe,e.normalize=Gr,e.parse=Or,e.readonlyAllowedCommands=$e,e.registries=Gf,e.setTranslationMethod=function(e){o=e},Object.defineProperty(e,"__esModule",{value:!0}),zf.version="15.0.26",zf.date="2024-08-02T08:17:56.757Z",zf.hash="3f93d36"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
3075
+ `;class Hf extends t.Component{constructor(e,s={}){super(e,s),this.model=new Ou(this.props.data,{notifyUser:e=>this.trigger("notify-user",{content:e}),askConfirmation:(e,t,s)=>this.trigger("ask-confirmation",{content:e,confirm:t,cancel:s}),editText:(e,t,s)=>this.trigger("edit-text",{title:e,placeholder:t,callback:s}),openSidePanel:(e,t={})=>this.openSidePanel(e,t),evalContext:{env:this.env},transportService:this.props.transportService,client:this.props.client,isReadonly:this.props.isReadonly,snapshotRequested:this.props.snapshotRequested},this.props.stateUpdateMessages),this.grid=Df("grid"),this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.linkEditor=t.useState({isOpen:!1}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.clipBoardString="",this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},$f({openSidePanel:(e,t={})=>this.openSidePanel(e,t),toggleSidePanel:(e,t={})=>this.toggleSidePanel(e,t),dispatch:this.model.dispatch,getters:this.model.getters,uuidGenerator:this.model.uuidGenerator,_t:Hf._t,clipboard:navigator.clipboard,export:this.model.exportData.bind(this.model),waitForIdle:this.model.waitForIdle.bind(this.model),exportXLSX:this.model.exportXLSX.bind(this.model),openLinkEditor:()=>this.openLinkEditor()}),Ff(window,"resize",this.render),Ff(document.body,"cut",this.copy.bind(this,!0)),Ff(document.body,"copy",this.copy.bind(this,!1)),Ff(document.body,"paste",this.paste),Ff(document.body,"keyup",this.onKeyup.bind(this)),Ff(window,"beforeunload",this.leaveCollaborativeSession.bind(this)),this.activateFirstSheet()}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}mounted(){this.model.on("update",this,this.render),this.model.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.props.client&&this.model.joinSession(this.props.client)}willUnmount(){this.leaveCollaborativeSession()}async willUpdateProps(e){this.props.isReadonly!==e.isReadonly&&this.model.updateReadOnly(e.isReadonly)}leaveCollaborativeSession(){this.model.off("update",this),this.model.leaveSession()}activateFirstSheet(){const e=this.model.getters.getActiveSheetId(),[t]=this.model.getters.getSheets();t.id!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:t.id})}destroy(){this.model.destroy(),super.destroy()}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}openLinkEditor(){this.linkEditor.isOpen=!0}closeLinkEditor(){this.linkEditor.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}copy(e,t){if(!this.grid.el.contains(document.activeElement))return;if("inactive"!==this.model.getters.getEditionMode())return;const s=e?"CUT":"COPY",i=this.model.getters.getSelectedZones();this.model.dispatch(s,{target:i});const o=this.model.getters.getClipboardContent();this.clipBoardString=o,t.clipboardData.setData("text/plain",o),t.preventDefault()}paste(e){if(!this.grid.el.contains(document.activeElement))return;const t=e.clipboardData;if(t.types.indexOf("text/plain")>-1){const e=t.getData("text/plain"),s=this.model.getters.getSelectedZones();this.clipBoardString===e?this.model.dispatch("PASTE",{target:s,interactive:!0}):this.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:s,text:e})}}save(){this.trigger("save-content",{data:this.model.exportData()})}onKeyup(e){"Control"===e.key&&this.model.getters.getSelectionMode()!==xh.expanding&&this.model.dispatch("STOP_SELECTION")}onKeydown(e){"Control"!==e.key||e.repeat||this.model.dispatch(this.model.getters.getSelectionMode()===xh.idle?"PREPARE_SELECTION_EXPANSION":"START_SELECTION_EXPANSION");let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let s=this.keyDownMapping[t];if(s)return e.preventDefault(),e.stopPropagation(),void s()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent(e.detail||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerContentFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent(e.detail||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerCellFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent(e.detail||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}}Hf.template=Bf,Hf.style=Vf,Hf.components={TopBar:kf,Grid:nf,BottomBar:ep,SidePanel:df,LinkEditor:Pg},Hf._t=e=>e;const zf={},Zf={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:f,HEADER_WIDTH:m,TOPBAR_HEIGHT:v,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:E,DEFAULT_CELL_HEIGHT:S,SCROLLBAR_WIDTH:b},Gf={autofillModifiersRegistry:Ma,autofillRulesRegistry:Aa,cellMenuRegistry:hl,colMenuRegistry:dl,linkMenuRegistry:ul,functionRegistry:ar,uiPluginRegistry:ad,corePluginRegistry:rd,rowMenuRegistry:pl,sidePanelRegistry:Sh,sheetMenuRegistry:gl,topbarMenuRegistry:fl,topbarComponentRegistry:bh,otRegistry:ml,inverseCommandRegistry:Oa,cellRegistry:qr},Wf={LinkCell:sa},qf={args:_e,toBoolean:ge,toNumber:he,toString:ue,toXC:os,toZone:Fs,toCartesian:is,numberToLetters:ss,createFullMenuItem:Fa,UuidGenerator:ni,formatDecimal:re,computeTextWidth:fs,isMarkdownLink:ys,parseMarkdownLink:Ts,markdownLink:ws,createEmptyWorkbookData:fa};e.CorePlugin=va,e.DATETIME_FORMAT=A,e.DataSource=hd,e.DispatchResult=Pe,e.Model=Ou,e.Revision=Kh,e.SPREADSHEET_DIMENSIONS=Zf,e.Spreadsheet=Hf,e.UIPlugin=Ch,e.__DEBUG__=As,e.__info__=zf,e.astToFormula=kr,e.cellTypes=Wf,e.convertAstNodes=Nr,e.coreTypes=De,e.functionCache=Br,e.helpers=qf,e.invalidateEvaluationCommands=Fe,e.normalize=Gr,e.parse=Or,e.readonlyAllowedCommands=$e,e.registries=Gf,e.setTranslationMethod=function(e){o=e},Object.defineProperty(e,"__esModule",{value:!0}),zf.version="15.0.28",zf.date="2024-09-05T09:27:39.727Z",zf.hash="0f4c167"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);