@odoo/o-spreadsheet 15.0.19 → 15.0.21

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){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===e||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 new Pe}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var Be,Ve,He,ze;e.CommandResult=void 0,(Be=e.CommandResult||(e.CommandResult={}))[Be.Success=0]="Success",Be[Be.CancelledForUnknownReason=1]="CancelledForUnknownReason",Be[Be.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",Be[Be.MergeIsDestructive=3]="MergeIsDestructive",Be[Be.CellIsMerged=4]="CellIsMerged",Be[Be.InvalidTarget=5]="InvalidTarget",Be[Be.EmptyUndoStack=6]="EmptyUndoStack",Be[Be.EmptyRedoStack=7]="EmptyRedoStack",Be[Be.NotEnoughElements=8]="NotEnoughElements",Be[Be.NotEnoughSheets=9]="NotEnoughSheets",Be[Be.MissingSheetName=10]="MissingSheetName",Be[Be.DuplicatedSheetName=11]="DuplicatedSheetName",Be[Be.DuplicatedSheetId=12]="DuplicatedSheetId",Be[Be.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",Be[Be.WrongSheetMove=14]="WrongSheetMove",Be[Be.WrongSheetPosition=15]="WrongSheetPosition",Be[Be.InvalidAnchorZone=16]="InvalidAnchorZone",Be[Be.SelectionOutOfBound=17]="SelectionOutOfBound",Be[Be.TargetOutOfSheet=18]="TargetOutOfSheet",Be[Be.WrongPasteSelection=19]="WrongPasteSelection",Be[Be.EmptyClipboard=20]="EmptyClipboard",Be[Be.EmptyRange=21]="EmptyRange",Be[Be.InvalidRange=22]="InvalidRange",Be[Be.InvalidSheetId=23]="InvalidSheetId",Be[Be.InputAlreadyFocused=24]="InputAlreadyFocused",Be[Be.MaximumRangesReached=25]="MaximumRangesReached",Be[Be.InvalidChartDefinition=26]="InvalidChartDefinition",Be[Be.EmptyDataSet=27]="EmptyDataSet",Be[Be.InvalidDataSet=28]="InvalidDataSet",Be[Be.InvalidLabelRange=29]="InvalidLabelRange",Be[Be.InvalidAutofillSelection=30]="InvalidAutofillSelection",Be[Be.WrongComposerSelection=31]="WrongComposerSelection",Be[Be.MinBiggerThanMax=32]="MinBiggerThanMax",Be[Be.LowerBiggerThanUpper=33]="LowerBiggerThanUpper",Be[Be.MidBiggerThanMax=34]="MidBiggerThanMax",Be[Be.MinBiggerThanMid=35]="MinBiggerThanMid",Be[Be.FirstArgMissing=36]="FirstArgMissing",Be[Be.SecondArgMissing=37]="SecondArgMissing",Be[Be.MinNaN=38]="MinNaN",Be[Be.MidNaN=39]="MidNaN",Be[Be.MaxNaN=40]="MaxNaN",Be[Be.ValueUpperInflectionNaN=41]="ValueUpperInflectionNaN",Be[Be.ValueLowerInflectionNaN=42]="ValueLowerInflectionNaN",Be[Be.MinInvalidFormula=43]="MinInvalidFormula",Be[Be.MidInvalidFormula=44]="MidInvalidFormula",Be[Be.MaxInvalidFormula=45]="MaxInvalidFormula",Be[Be.ValueUpperInvalidFormula=46]="ValueUpperInvalidFormula",Be[Be.ValueLowerInvalidFormula=47]="ValueLowerInvalidFormula",Be[Be.InvalidSortZone=48]="InvalidSortZone",Be[Be.WaitingSessionConfirmation=49]="WaitingSessionConfirmation",Be[Be.MergeOverlap=50]="MergeOverlap",Be[Be.TooManyHiddenElements=51]="TooManyHiddenElements",Be[Be.Readonly=52]="Readonly",Be[Be.InvalidOffset=53]="InvalidOffset",Be[Be.InvalidViewportSize=54]="InvalidViewportSize",Be[Be.FigureDoesNotExist=55]="FigureDoesNotExist",Be[Be.DuplicatedFigureId=56]="DuplicatedFigureId",Be[Be.DuplicatedChartId=57]="DuplicatedChartId",Be[Be.ChartDoesNotExist=58]="ChartDoesNotExist",function(e){e.FormatFromArgument="FormatFromArgument"}(Ve||(Ve={})),function(e){e[e.UP=0]="UP",e[e.DOWN=1]="DOWN",e[e.LEFT=2]="LEFT",e[e.RIGHT=3]="RIGHT"}(He||(He={})),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 Ze={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},Ge={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},We={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},qe={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},je={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},Ye={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},Xe={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},Ke={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},Qe={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},Je={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},et={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:Ve.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},tt={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:Ve.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},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.")}\n `),returns:["NUMBER"],returnFormat:Ve.FormatFromArgument,compute:function(e,t){return tt.compute(e,t,0)},isExported:!0},it={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},ot={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},nt={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},rt={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},at={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},lt={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},ct={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 ht(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const dt={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)=>ht(t)?e.add(t):e),new Set).size}},ut={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];ht(o)&&s.add(o)})),s.size}},pt={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},gt={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},ft={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},mt={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},vt={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},Et={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:Ve.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},St={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:Ve.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},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.")}\n `),returns:["NUMBER"],returnFormat:Ve.FormatFromArgument,compute:function(e,t=1){return St.compute(e,t,0)},isExported:!0},Ct={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},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:Ve.FormatFromArgument,compute:function(e,t=1){return tt.compute(e,t,0)},isExported:!0},yt={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},wt={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},Tt={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:Ve.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},xt={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:Ve.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},Rt={description:a("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Lt={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:Ve.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},Mt={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:Ve.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},At={description:a("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},_t={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:Ve.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},Ot={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:Ve.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},Nt={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:Ve.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},kt={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:Ve.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},Ft={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},$t={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},Dt={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},Ut={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},Pt={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:Ve.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},Bt={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:Ve.FormatFromArgument,compute:function(...e){return Ce(e,((e,t)=>e+t),0)},isExported:!0},Vt={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},Ht={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},Zt={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},Gt={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:Ve.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 Wt=Object.freeze({__proto__:null,ABS:Ze,ACOS:Ge,ACOSH:We,ACOT:qe,ACOTH:je,ASIN:Ye,ASINH:Xe,ATAN:Ke,ATAN2:Qe,ATANH:Je,CEILING:et,CEILING_MATH:tt,CEILING_PRECISE:st,COS:it,COSH:ot,COT:nt,COTH:rt,COUNTBLANK:at,COUNTIF:lt,COUNTIFS:ct,COUNTUNIQUE:dt,COUNTUNIQUEIFS:ut,CSC:pt,CSCH:gt,DECIMAL:ft,DEGREES:mt,EXP:vt,FLOOR:Et,FLOOR_MATH:St,FLOOR_PRECISE:bt,ISEVEN:Ct,ISO_CEILING:It,ISODD:yt,LN:wt,MOD:Tt,ODD:xt,PI:Rt,POWER:Lt,PRODUCT:Mt,RAND:At,RANDBETWEEN:_t,ROUND:Ot,ROUNDDOWN:Nt,ROUNDUP:kt,SEC:Ft,SECH:$t,SIN:Dt,SINH:Ut,SQRT:Pt,SUM:Bt,SUMIF:Vt,SUMIFS:Ht,TAN:zt,TANH:Zt,TRUNC:Gt});const qt=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function jt(e){return e.toString(16).padStart(6,"0")}let Yt=0;function Xt(){return Yt=++Yt%qt.length,qt[Yt]}function Kt(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 Qt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Jt=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 es(e){const t=e.split("!"),s=t.pop();return{sheetName:t.join("!")||void 0,xc:s}}function ts(e){return e<26?String.fromCharCode(65+e):ts(Math.floor(e/26)-1)+ts(e%26)}function ss(e){e=e.toUpperCase().trim();const[t,s,i]=e.match(Qt);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 is(e,t,s={colFixed:!1,rowFixed:!1}){return(s.colFixed?"$":"")+ts(e)+(s.rowFixed?"$":"")+String(t+1)}const os=140,ns=20,rs=.035;function as(e){return ns+(os-ns)*Math.exp(-rs*(e-1))}const ls=[{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}],cs={};for(let e of ls)cs[e.pt]=e.px;function hs(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ds(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]=ds(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 us(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function ps(e,t,s){return e<t?t:e>s?s:e}function gs(e,t,s){const i=s.italic?"italic ":"",o=s.bold?"bold":T,n=s.fontSize||x,r=cs[n];return e.font=`${i}${o} ${r}px ${R}`,e.measureText(t).width}function fs(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 ms(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*vs(e,t){t.next();for(const s of e){const e=t.next();yield{...s,next:e.done?void 0:e.value}}}function Es(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}function Ss(e){return null!==G(e)}const bs=/^\[(.+)\]\((.+)\)$/,Cs=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Is(e){return bs.test(e)}function ys(e,t){return`[${e}](${t})`}function ws(e){const t=e.match(bs)||[],s=t[1],i=t[2];if(!s||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:s,url:i}}const Ts="o-spreadsheet://";function xs(e){if(!Is(e))return!1;const{url:t}=ws(e);return t.startsWith(Ts)}function Rs(e){if(e.startsWith(Ts))return e.substr(Ts.length);throw new Error(`${e} is not a valid sheet link`)}function Ls(e){return void 0!==e}const Ms={};function As(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 e===t;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(!As(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function _s(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":");let s,i,o,n,r=ss(t[0].trim());if(o=n=r[0],s=i=r[1],2===t.length){let e=ss(t[1].trim());n=e[0],i=e[1]}return{top:s,bottom:i,left:o,right:n}}function Os(e){let{top:t,bottom:s,left:i,right:o}=_s(e);return o<i&&([o,i]=[i,o]),s<t&&([s,t]=[t,s]),{top:t,bottom:s,left:i,right:o}}function Ns(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 ks(e){const{top:t,bottom:s,left:i,right:o}=e;return t===s&&i===o?is(i,t):`${is(i,t)}:${is(o,s)}`}function Fs(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?qs(e,n,"RESIZE",o):r<e[t]?qs(e,n,"MOVE",o):{...e}}function $s(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 Ds(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 Us(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Ps(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Bs(e,t,s){const{left:i,right:o,top:n,bottom:r}=s;return e>=i&&e<=o&&t>=n&&t<=r}function Vs(e,t){const s={};for(let t of e)if(t){const e=Os(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=Os(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:Hs(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(ks)}function Hs(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 zs(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 Zs(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function Gs(e){const{width:t,height:s}=Zs(e);return 1===t||1===s}function Ws(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 fs(s,i+1))for(const s of fs(o,n+1))t.push([e,s]);return t}function qs(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 js(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 Ys(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 Xs(e){const t=[];let s=0;for(let i=0;i<e;i++){const e={start:s,end:s+E,size:E,name:ts(i)};t.push(e),s=e.end}return t}function Ks(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 Qs(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:ts(n)};r&&(a.isHidden=r),i.push(a),o=a.end}return i}function Js(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 ei(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 ti(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 si{constructor(){this.isFastIdStrategy=!1,this.fastIdStart=0}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 ii(e,t,s){return[oi(e,"cols",fs(t,e.cols.length)),oi(e,"rows",fs(s,e.rows.length))]}function oi(e,t,s){const i=e[t];return s.find((e=>!i[e].isHidden))}function ni(e,t){let s=e[t].length-1;for(;s>=0&&!0===e[t][s].isHidden;)s--;return e[t][s]}function ri(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 ai(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 li(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 ci={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},hi={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:Ve.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},di=a("[[FUNCTION_NAME]] has mismatched range sizes."),ui=a("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),pi={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:Ve.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)),di);let e=t.length,n=t[0].length;le((()=>e===s.length&&n===s[0].length),di);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),ui),i+=n*l,o+=l)}}else s=he(s),t=he(t),le((()=>s>=0),ui),i+=t*s,o+=s;return le((()=>0!==o),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/o}},gi={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:Ve.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},fi={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},mi={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},vi={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},Ei={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},Si={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 ri(e,t,!1)},isExported:!0},bi={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 ri(e,t,!1)},isExported:!0},Ci={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 ri(e,t,!0)},isExported:!0},Ii={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:Ve.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},yi={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:Ve.FormatFromArgument,compute:function(...e){const t=Ce(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},wi={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:Ve.FormatFromArgument,compute:function(...e){const t=Ie(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Ti={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},xi={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:Ve.FormatFromArgument,compute:function(...e){let t=[];return Ee(e,(e=>{t.push(e)})),li(t,.5,!0)},isExported:!0},Ri={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:Ve.FormatFromArgument,compute:function(...e){const t=Ce(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Li={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:Ve.FormatFromArgument,compute:function(...e){const t=Ie(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Mi={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},Ai={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:Ve.FormatFromArgument,compute:function(e,t){return Oi.compute(e,t)},isExported:!0},_i={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:Ve.FormatFromArgument,compute:function(e,t){return li([e],t,!1)},isExported:!0},Oi={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:Ve.FormatFromArgument,compute:function(e,t){return li([e],t,!0)},isExported:!0},Ni={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:Ve.FormatFromArgument,compute:function(e,t){return Fi.compute(e,t)},isExported:!0},ki={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:Ve.FormatFromArgument,compute:function(e,t){return li([e],.25*Math.trunc(he(t)),!1)},isExported:!0},Fi={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:Ve.FormatFromArgument,compute:function(e,t){return li([e],.25*Math.trunc(he(t)),!0)},isExported:!0},$i={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:Ve.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},Di={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(zi.compute(...e))},isExported:!0},Ui={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(Zi.compute(...e))},isExported:!0},Pi={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(Gi.compute(...e))},isExported:!0},Bi={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(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 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(ji.compute(...e))},isExported:!0},zi={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 ai(e,!0,!1)},isExported:!0},Zi={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 ai(e,!1,!1)},isExported:!0},Gi={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 ai(e,!0,!1)},isExported:!0},Wi={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 ai(e,!0,!0)},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 ai(e,!1,!1)},isExported:!0},ji={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 ai(e,!1,!0)},isExported:!0};var Yi=Object.freeze({__proto__:null,AVEDEV:ci,AVERAGE:hi,AVERAGE_WEIGHTED:pi,AVERAGEA:gi,AVERAGEIF:fi,AVERAGEIFS:mi,COUNT:vi,COUNTA:Ei,COVAR:Si,COVARIANCE_P:bi,COVARIANCE_S:Ci,LARGE:Ii,MAX:yi,MAXA:wi,MAXIFS:Ti,MEDIAN:xi,MIN:Ri,MINA:Li,MINIFS:Mi,PERCENTILE:Ai,PERCENTILE_EXC:_i,PERCENTILE_INC:Oi,QUARTILE:Ni,QUARTILE_EXC:ki,QUARTILE_INC:Fi,SMALL:$i,STDEV:Di,STDEV_P:Ui,STDEV_S:Pi,STDEVA:Bi,STDEVP:Vi,STDEVPA:Hi,VAR:zi,VAR_P:Zi,VAR_S:Gi,VARA:Wi,VARP:qi,VARPA:ji});function Xi(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 Ki=_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`),Qi={description:a("Average of a set of values from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return hi.compute([i])},isExported:!0},Ji={description:a("Counts values from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return vi.compute([i])},isExported:!0},eo={description:a("Counts values and text from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return Ei.compute([i])},isExported:!0},to={description:a("Single value from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return le((()=>1===i.length),a("More than one match found in DGET evaluation.")),i[0]},isExported:!0},so={description:a("Maximum of values from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return yi.compute([i])},isExported:!0},io={description:a("Minimum of values from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return Ri.compute([i])},isExported:!0},oo={description:a("Product of values from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return Mt.compute([i])},isExported:!0},no={description:a("Standard deviation of population sample from table."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return Di.compute([i])},isExported:!0},ro={description:a("Standard deviation of entire population from table."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return Vi.compute([i])},isExported:!0},ao={description:a("Sum of values from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return Bt.compute([i])},isExported:!0},lo={description:a("Variance of population sample from table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return zi.compute([i])},isExported:!0},co={description:a("Variance of a population from a table-like range."),args:Ki,returns:["NUMBER"],compute:function(e,t,s){const i=Xi(e,t,s);return qi.compute([i])},isExported:!0};var ho=Object.freeze({__proto__:null,DAVERAGE:Qi,DCOUNT:Ji,DCOUNTA:eo,DGET:to,DMAX:so,DMIN:io,DPRODUCT:oo,DSTDEV:no,DSTDEVP:ro,DSUM:ao,DVAR:lo,DVARP:co});const uo=new D(1899,11,30);function po(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}const go={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()-uo.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},fo={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},mo={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},vo={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},Eo={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()-uo.getTime();return Math.round(a/864e5)},isExported:!0},So={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()-uo.getTime();return Math.round(r/864e5)},isExported:!0},bo={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},Co={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},Io={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},yo={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},wo={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 xo.compute(e,t,1,s)},isExported:!0};function To(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 xo={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=To(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},Ro={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()-uo.getTime(),s=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/864e5)+s},isExported:!0},Lo={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},Mo={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},Ao={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},_o={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()-uo.getTime();return Math.round(t/864e5)},isExported:!0},Oo={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},No={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 Co.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},ko={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 Fo.compute(e,t,1,s)},isExported:!0},Fo={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=To(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-uo.getTime();return Math.round(p/864e5)},isExported:!0},$o={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},Do={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===(po(p)?29:28)&&(c=30,1===u&&h===(po(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+=po(e)?366:365;e=s/t}else t?po(p)&&(e=366):(po(p)&&d<2&&(e=366),po(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 Uo=Object.freeze({__proto__:null,DATE:go,DATEVALUE:fo,DAY:mo,DAYS:vo,EDATE:Eo,EOMONTH:So,HOUR:bo,ISOWEEKNUM:Co,MINUTE:Io,MONTH:yo,NETWORKDAYS:wo,NETWORKDAYS_INTL:xo,NOW:Ro,SECOND:Lo,TIME:Mo,TIMEVALUE:Ao,TODAY:_o,WEEKDAY:Oo,WEEKNUM:No,WORKDAY:ko,WORKDAY_INTL:Fo,YEAR:$o,YEARFRAC:Do});function Po(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 Bo={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}},Vo={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=Do.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}},Ho={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)}},zo={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 Po((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}},Zo={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 Vo.compute(e,t,s,i,o,n)/(1+he(i)/Math.trunc(he(o)))}};const Go={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)}},Wo={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)}},qo={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)}},jo={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=Do.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)}},Yo={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=Do.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=Po((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}},Xo={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=Do.compute(c,l,u),g=Do.compute(c,r,u),f=Do.compute(r,l,u);return(100*(1+h*p)/(d+100*h*g)-1)/f}};var Ko=Object.freeze({__proto__:null,DB:Bo,DURATION:Vo,FV:Ho,IRR:zo,MDURATION:Zo,NPV:Go,PDURATION:Wo,PV:qo,PRICE:jo,YIELD:Yo,YIELDMAT:Xo});const Qo={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},Jo={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},en={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},tn={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},sn={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 on=Object.freeze({__proto__:null,ISERROR:Qo,ISLOGICAL:Jo,ISNONTEXT:en,ISNUMBER:tn,ISTEXT:sn});const nn={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},rn={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},an={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},ln={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},cn={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},hn={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},dn={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 un=Object.freeze({__proto__:null,AND:nn,IF:rn,IFERROR:an,IFS:ln,NOT:cn,OR:hn,XOR:dn});function pn(e,t){for(let s=0;s<e.length;s++)if(e[s]===t)return s;return-1}const gn={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 Os(e).left+1},isExported:!0},fn={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=Os(e);return t.right-t.left+1},isExported:!0},mn={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):pn(r,e),le((()=>l>-1),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),t[l][o-1]},isExported:!0},vn={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},En={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=pn(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},Sn={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 Os(e).top+1},isExported:!0},bn={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=Os(e);return t.bottom-t.top+1},isExported:!0},Cn={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):pn(r,e),le((()=>l>-1),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),t[o-1][l]},isExported:!0};var In=Object.freeze({__proto__:null,COLUMN:gn,COLUMNS:fn,HLOOKUP:mn,LOOKUP:vn,MATCH:En,ROW:Sn,ROWS:bn,VLOOKUP:Cn});const yn={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:Ve.FormatFromArgument,compute:function(e,t){return he(e)+he(t)}},wn={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},Tn={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:Ve.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 xn(e){return null==e}const Rn={number:0,string:"",boolean:!1},Ln={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=xn(e)?Rn[typeof t]:e,t=xn(t)?Rn[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function Mn(e,t,s){e=xn(e)?Rn[typeof t]:e,t=xn(t)?Rn[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 An={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 Mn(e,t,((e,t)=>e>t))}},_n={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 Mn(e,t,((e,t)=>e>=t))}},On={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!_n.compute(e,t)}},Nn={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!An.compute(e,t)}},kn={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:Ve.FormatFromArgument,compute:function(e,t){return he(e)-he(t)}},Fn={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:Ve.FormatFromArgument,compute:function(e,t){return he(e)*he(t)}},$n={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!Ln.compute(e,t)}},Dn={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 Lt.compute(e,t)}},Un={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:Ve.FormatFromArgument,returns:["NUMBER"],compute:function(e){return-he(e)}},Pn={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}},Bn={description:a("A specified number, unchanged."),args:_e(`\n value (any) ${a("The number to return.")}\n `),returnFormat:Ve.FormatFromArgument,returns:["ANY"],compute:function(e){return e}};var Vn=Object.freeze({__proto__:null,ADD:yn,CONCAT:wn,DIVIDE:Tn,EQ:Ln,GT:An,GTE:_n,LT:On,LTE:Nn,MINUS:kn,MULTIPLY:Fn,NE:$n,POW:Dn,UMINUS:Un,UNARY_PERCENT:Pn,UPLUS:Bn});const Hn={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},zn={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},Zn={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},Gn={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},Wn={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)),"")}},qn={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},jn={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},Yn={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},Xn={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},Kn={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},Qn={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},Jn={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(hs(r),"g");if(0===o)return n.replace(c,l);let h=0;return n.replace(c,(e=>++h===o?l:e))},isExported:!0},er={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},tr={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},sr={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 ir={database:ho,date:Uo,financial:Ko,info:on,lookup:In,logical:un,math:Wt,operators:Vn,statistical:Yi,text:Object.freeze({__proto__:null,CHAR:Hn,CONCATENATE:zn,EXACT:Zn,FIND:Gn,JOIN:Wn,LEFT:qn,LEN:jn,LOWER:Yn,REPLACE:Xn,RIGHT:Kn,SEARCH:Qn,SUBSTITUTE:Jn,TEXTJOIN:er,TRIM:tr,UPPER:sr})};const or=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 ir){const t=ir[e];for(let s in t){const i=t[s];i.category=e,or.add(s,{isExported:!1,...i})}}const nr=/^[S|N]?\d+/,rr=or.content,ar="+,-,*,/,:,=,<>,>=,>,<=,<,%,^,&".split(",");function lr(e){const t=e.split(""),s=[];for(;t.length;){let e=br(t)||ur(t)||gr(t)||mr(t)||hr(t)||cr(t)||Cr(t)||fr(t)||Er(t);e||(e={type:"UNKNOWN",value:t.shift()}),s.push(e)}return s}function cr(e){if(e[0]===$){e.shift();const t=e.join("").match(nr);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 hr(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const dr={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function ur(e){if(e[0]in dr){const t=e.shift();return{type:dr[t],value:t}}return null}function pr(e,t){for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function gr(e){for(let t of ar)if(pr(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function fr(e){const t=e.join("").match(K);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function mr(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 vr=/\w|\.|!|\$/;function Er(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(vr);)t.push(e.shift());if(t.length){const e=t.join("");return{type:e.toUpperCase()in rr?"FUNCTION":"SYMBOL",value:e}}return null}const Sr=/\s/;function br(e){let t=0;for(;e[0]&&e[0].match(Sr);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function Cr(e){return pr(e,_)?(e.splice(0,_.length),{type:"INVALID_REFERENCE",value:_}):null}const Ir=["-","+"],yr=["*","+","&"],wr={"^":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},Tr=6;function xr(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 wr[e.value]||15}throw new Error(a("Unknown token: %s",e.value))}function Rr(e,t,s){if("OPERATOR"===t.type){const i=Lr(s,xr(t));return{type:"BIN_OPERATION",value:t.value,left:e,right:i}}throw new Error(N)}function Lr(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=Lr(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(Lr(t,Tr));"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(Lr(t,Tr))}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(Qt.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=Lr(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&&Ir.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,right:Lr(t,wr[e.value])};throw new Error(a("Unexpected token: %s",e.value))}}(s,e);for(;e[0]&&xr(e[0])>t;)i=Rr(i,e.shift(),e);return i}function Mr(e){const t=lr(e).filter((e=>"SPACE"!==e.type));"OPERATOR"===t[0].type&&"="===t[0].value&&t.splice(0,1);const s=Lr(t,0);if(t.length)throw new Error(N);return s}function Ar(e,t,s){switch(t===e.type&&(e=s(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>Ar(e,t,s)))};case"UNARY_OPERATION":return{...e,right:Ar(e.right,t,s)};case"BIN_OPERATION":return{...e,right:Ar(e.right,t,s),left:Ar(e.left,t,s)};default:return e}}function _r(e,t={references:[],numbers:[],strings:[]}){switch(e.type){case"FUNCALL":const s=e.args.map((e=>_r(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+Or(e,t);case"BIN_OPERATION":return function(e,t){const s=e.value,i=e.left,o=i.value;return"BIN_OPERATION"===i.type&&wr[o]<wr[s]?`(${_r(i,t)})`:_r(i,t)}(e,t)+e.value+Or(e,t)}}function Or(e,t){const s=e.value,i=e.right,o=wr[i.value],n=wr[s];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:o<n?r=!0:o!==n||yr.includes(s)||(r=!0),r?`(${_r(i,t)})`:_r(i,t)}const Nr=or.content,kr={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Fr={"-":"UMINUS","+":"UPLUS"};function $r(e){return e.map((e=>e.split("\n"))).flat().filter((e=>""!==e.trim()))}const Dr={};function Ur(e){if(!Dr[e.text]){const t=Mr(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=$r([`// ${e.text}`,i.code,`return ${i.id};`]).join("\n");let n=new Function("deps","sheetId","ref","range","ctx",o);function r(e){const t=Nr[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||kr["="]}", ${c.paramIndex})`;break;case"FUNCALL":d=s++;const a=r(t);h.push($r(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=Fr[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=kr[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${$r(h).join("\n\t")}\n\treturn ${p};\n}`}}return h.push(`let _${d} = ${p};`),{id:`_${d}`,code:$r(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=Nr[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=Nr[kr[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[]}Dr[e.text]=n,Dr[e.text].dependenciesFormat=c(t)}return Dr[e.text]}function Pr(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 Br(e){return Pr(lr(e),!0)}function Vr(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}))}(Pr(lr(e)))))}function Hr(e){const t=Br(e);let s={numbers:[],strings:[],references:[]};return{text:"".concat(...t.map((e=>{if("SYMBOL"===e.type&&Qt.test(e.value)){const t=e.value.trim();s.references.includes(t)||s.references.push(t);return zr(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 zr(`${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 zr(`${e.type[0]}${i}`)}return e.value}))),dependencies:s}}function zr(e){return`${$}${e}${$}`}const Zr=new Le;function Gr(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 Wr(e){return""===e?"":J(e)?te(e):Es(e)?"TRUE"===e.toUpperCase():Ss(e)?G(e).value:e}class qr{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 Gr(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 jr extends qr{constructor(e,t={}){super(e,{value:"",type:ke.empty},t),this.content=""}isEmpty(){return!0}}class Yr extends qr{constructor(e,t,s={}){super(e,{value:t,type:ke.number},s),this.content=ie(this.evaluated.value)}}class Xr extends qr{constructor(e,t,s={}){super(e,{value:t,type:ke.boolean},s),this.content=this.evaluated.value?"TRUE":"FALSE"}}class Kr extends qr{constructor(e,t,s={}){super(e,{value:t,type:ke.text},s),this.content=this.evaluated.value}}class Qr extends Yr{constructor(e,t,s){super(e,t,s),this.format=s.format}get composerContent(){return Gr(this.evaluated.value,this.format)}}class Jr extends qr{constructor(e,t,s={}){var i;const o=ws(t);s={...s,style:{...s.style,textColor:(null===(i=s.style)||void 0===i?void 0:i.textColor)||M,underline:!0}},super(e,{value:o.label,type:ke.text},s),this.link=o,this.content=t}isLink(){return!0}get composerContent(){return this.link.label}}class ea extends Jr{constructor(e,t,s={}){super(e,t,s),this.link.url=this.withHttp(this.link.url),this.link.isExternal=!0,this.content=ys(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 ta extends Jr{constructor(e,t,s={},i){super(e,t,s),this.sheetName=i,this.sheetId=Rs(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 sa extends qr{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 ia extends qr{constructor(e,t,s,i){super(e,{value:"#BAD_EXPR",type:ke.error,error:s},i),this.content=t}}function oa(e){const t=Br(e);let s=[];return{text:"".concat(...t.map((e=>{if("SYMBOL"===e.type&&Qt.test(e.value)){const t=e.value.trim();return s.includes(t)||s.push(t),`${$}${s.indexOf(t)}${$}`}return e.value}))),dependencies:s}}Zr.add("Formula",{sequence:10,match:e=>e.startsWith("="),createCell:(e,t,s,i,o)=>{const n=Hr(t),r=n.text,a=Ur(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 sa(((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 jr(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 Yr(e,te(t),s))}).add("Boolean",{sequence:40,match:e=>Es(e),createCell:(e,t,s)=>new Xr(e,"TRUE"===t.toUpperCase(),s)}).add("DateTime",{sequence:50,match:e=>Ss(e),createCell:(e,t,s)=>{const i=G(t),o=s.format||i.format;return new Qr(e,i.value,{...s,format:o})}}).add("MarkdownSheetLink",{sequence:60,match:e=>xs(e),createCell:(e,t,s,i,o)=>new ta(e,t,s,(e=>o.tryGetSheetName(e)))}).add("MarkdownLink",{sequence:70,match:e=>Is(e),createCell:(e,t,s)=>new ea(e,t,s)}).add("WebLink",{sequence:80,match:e=>{return t=e,Cs.test(t);var t},createCell:(e,t,s)=>new ea(e,ys(t,t),s)});const na=10,ra="Sheet1";function aa(e){return e?("version"in(e=JSON.parse(JSON.stringify(e)))&&e.version<na&&(e=function(e){for(let t=la.findIndex((t=>t.from===e.version));t<la.length;t++)e=la[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,s=new si;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(ua(),e,{version:na}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(da(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(da(ra,"Sheet1"));return e}(e),e}(e),e):ua()}const la=[{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=oa(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=Os(e.dataRange),s=e.labelCell+":"+is(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 ca(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:ra};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=ha(t,"SORT_CELLS"),t=ha(t,"SET_DECIMAL")}function ha(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 da(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[]}}function ua(e="Sheet1"){return{version:na,sheets:[da(ra,e)],entities:{},styles:{},borders:{},revisionId:O,uniqueFigureIds:!0}}class pa{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)}}pa.getters=[],pa.modes=["headless","normal"];class ga extends pa{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 fa extends ga{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":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){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=fs(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=fs(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))):[]}getRowsRange(e){if(!this.borders[e])return[];return fs(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.getRowsRange(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]=ss(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,Os(e))}export(e){let t=0;const s={};function i(e){for(let[t,i]of Object.entries(s))if(As(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=is(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)}}fa.getters=["getCellBorder"];const ma=new RegExp(String.fromCharCode(160),"g");class va extends ga{constructor(){super(...arguments),this.cells={},this.createCell=function(e){const t=Zr.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 Kr(s,i,o);try{return r.createCell(s,i,o,n,e)}catch(e){return new ia(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=fs(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=fs(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]=ss(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(As(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[is(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.uuidGenerator.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]=ss(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.style||{}}zoneToXC(e,t,s=[{colFixed:!1,rowFixed:!1}]){const i=is((t=this.getters.expandZone(e,t)).left,t.top,s[0]),o=is(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(ma,""))||"":(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.uuidGenerator.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 Bs(t,s,{top:0,left:0,bottom:i.rows.length-1,right:i.cols.length-1})?0:18}}va.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Ea extends ga{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={...ds(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}=Zs(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: ${ks(t)}`);if(s){const i=ks(t),o=ks(s);return{labelCell:this.getters.getRangeFromSheetXC(e,o),dataRange:this.getters.getRangeFromSheetXC(e,i)}}return{labelCell:void 0,dataRange:this.getters.getRangeFromSheetXC(e,ks(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=>!Jt.test(e)));return t?28:0}checkLabelRange(e){if(!e.definition.labelRange)return 0;return!Jt.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 Sa(e){return""===e?NaN:Number(e)}Ea.getters=["getChartDefinition","getChartDefinitionUI","getChartsIdBySheet"];class ba extends ga{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(ks)};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)Bs(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{Ur(Hr(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&&Sa(t)>=Sa(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&&Sa(s)>=Sa(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&&Sa(s)>=Sa(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)}}}ba.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Ca extends ga{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(Ls)}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)}}Ca.getters=["getFigures","getFigure","getFigureSheetId"];class Ia extends ga{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}=Os(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:is(s,o)+":"+is(i,n)}(t,e.elements)),!0):this.exportAndRemoveMerges(e.sheetId,(t=>function(e,t){let{left:s,right:i,top:o,bottom:n}=Os(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:is(s,o)+":"+is(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}=Os(e);return i>=t&&(i+=s),(i>=t||o>=t)&&(o+=s),i>o?null:is(i,n)+":"+is(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}=Os(e);return n>=t&&(n+=s),(n>=t||r>=t)&&(r+=s),n>r?null:is(i,n)+":"+is(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(Ls)}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&&Ps(s,r)&&(r=Ds(s,r))}return Us(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 Us(t,s);const{width:i,height:o}=Zs(t);return 1===i&&1===o}isMergeDestructive(e,t){let{left:s,right:i,top:o,bottom:n}=t;i=ps(i,0,e.cols.length-1),n=ps(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&&Ps(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||!Us(e,o))return 5}return 0}addMerge(e,t){let{left:s,right:i,top:o,bottom:n}=t;i=ps(i,0,e.cols.length-1),n=ps(n,0,e.rows.length-1);if(is(s,o)===is(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&&Us(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=ya(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,Os(e))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...ya(e))}}exportForExcel(e){this.export(e)}}function ya(e){return Object.values(e).filter(Ls).map((e=>is(e.left,e.top)+":"+is(e.right,e.bottom)))}Ia.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCell","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","isSingleCellOrMerge"];class wa extends ga{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:Qs(t.cols||{},s),rows:Js(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(Ls).map((e=>{const s=this.sheets[e];return{id:s.id,name:s.name,colNumber:s.cols.length,rowNumber:s.rows.length,rows:ti(s.rows,t),cols:ei(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(Ls)}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 zs(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:Xs(s),rows:Ks(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 ms(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.dispatch("UPDATE_CELL_POSITION",{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({type:"UPDATE_CELL_POSITION",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.dispatch(e.type,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.dispatch("UPDATE_CELL_POSITION",{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:ts(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:ts(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:ts(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(ss);return{rowNumber:Math.max(e.rowNumber,...new Set(t.map((([e,t])=>t+1)))),colNumber:Math.max(e.colNumber,...new Set(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(Ns))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 Us(Ds(t=i,e),t);var t}))?0:18}return 0}}wa.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheets","getVisibleSheets","getEvaluationSheets","getCol","getRow","getCell","getCellPosition","getColCells","getColsZone","getRowsZone","getNumberCols","getNumberRows","getHiddenColsGroups","getHiddenRowsGroups","getGridLinesVisibility","getNextSheetName","isEmpty"];const Ta=new Le;Ta.add("INCREMENT_MODIFIER",{apply:(e,t)=>{var s;e.current+=e.increment;const i=e.current.toString(),o=Gr(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 xa=new Le;xa.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 Ra=new Le,La=(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 ms(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())La.contains(e)||La.add(e,Ma);function Ma(e){return[e]}const Aa=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,shortCut:"",action:!1,children:[],separator:!1,icon:!1,id:e});function _a(e,t){return Object.assign({},Aa(e),t)}class Oa extends Le{add(e,t){return this.content[e]=_a(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(_a(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 Na(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 ka(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 Fa(e,t){e.dispatch("SET_FORMATTING",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones(),format:t})}function $a(e,t){e.dispatch("SET_FORMATTING",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones(),style:t})}const Da=async e=>{e.dispatch("COPY",{target:e.getters.getSelectedZones()}),await e.clipboard.writeText(e.getters.getClipboardContent())},Ua=async e=>{e.dispatch("CUT",{target:e.getters.getSelectedZones()}),await e.clipboard.writeText(e.getters.getClipboardContent())},Pa=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})},Ba=e=>e.dispatch("PASTE",{target:e.getters.getSelectedZones(),pasteOption:"onlyValue"}),Va=e=>e.dispatch("PASTE",{target:e.getters.getSelectedZones(),pasteOption:"onlyFormat"}),Ha=e=>e.dispatch("DELETE_CONTENT",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones()}),za=e=>{let t,s;const i=e.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),s=Math.max(...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())},Za=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})},Ga=e=>{let t,s;const i=e.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),s=Math.max(...i);else{const i=e.getters.getSelectedZones()[0];t=i.left,s=i.right}return t===s?a("Delete column %s",ts(t)):a("Delete columns %s - %s",ts(t),ts(s))},Wa=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})},qa=e=>{const t=e.getters.getSelectedZone();e.dispatch("INSERT_CELL",{shiftDimension:"ROW",zone:t,interactive:!0})},ja=e=>{const t=e.getters.getSelectedZone();e.dispatch("INSERT_CELL",{shiftDimension:"COL",zone:t,interactive:!0})},Ya=e=>{const t=e.getters.getSelectedZone();e.dispatch("DELETE_CELL",{shiftDimension:"ROW",zone:t,interactive:!0})},Xa=e=>{const t=e.getters.getSelectedZone();e.dispatch("DELETE_CELL",{shiftDimension:"COL",zone:t,interactive:!0})},Ka=e=>{const t=e.getters.getActiveRows();let s,i;if(t.size)s=Math.min(...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"})},Qa=e=>{const t=e.getters.getActiveRows();let s,i;if(t.size)s=Math.max(...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"})},Ja=e=>{const t=e.getters.getActiveCols();let s,i;if(t.size)s=Math.min(...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})},el=e=>{const t=e.getters.getActiveCols();let s,i;if(t.size)s=Math.max(...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})},tl=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.getters.getSelectedZones()})},sl=e=>{e.openLinkEditor()},il=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"})},ol=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"})},nl=e=>1===e.getters.getSelectedZones().length,rl=new Oa;rl.add("cut",{name:a("Cut"),shortCut:"Ctrl+X",sequence:10,action:Ua}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Da}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:Pa,isVisible:nl}).add("paste_special",{name:a("Paste special"),sequence:40,separator:!0,isVisible:nl}).addChild("paste_value_only",["paste_special"],{name:a("Paste values only"),sequence:10,action:Ba}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Va}).add("sort_range",{name:a("Sort range"),sequence:50,isVisible:nl,separator:!0}).addChild("sort_ascending",["sort_range"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:il}).addChild("sort_descending",["sort_range"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ol}).add("add_row_before",{name:e=>{const t=ka(e);return 1===t?a("Insert row"):a("Insert %s rows",t.toString())},sequence:70,action:Ka,isVisible:nl}).add("add_column_before",{name:e=>{const t=Na(e);return 1===t?a("Insert column"):a("Insert %s columns",t.toString())},sequence:90,action:Ja,isVisible:nl}).add("insert_cell",{name:a("Insert cells"),sequence:100,isVisible:nl,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:a("Shift down"),sequence:10,action:qa}).addChild("insert_cell_right",["insert_cell"],{name:a("Shift right"),sequence:20,action:ja}).add("delete_row",{name:za,sequence:110,action:Za,isVisible:nl}).add("delete_column",{name:Ga,sequence:120,action:Wa,isVisible:nl}).add("delete_cell",{name:a("Delete cells"),sequence:130,isVisible:nl}).addChild("delete_cell_up",["delete_cell"],{name:a("Shift up"),sequence:10,action:Ya}).addChild("delete_cell_down",["delete_cell"],{name:a("Shift left"),sequence:20,action:Xa}).add("clear_cell",{name:a("Clear cells"),sequence:140,action:Ha,isEnabled:e=>{const t=e.getters.getActiveCell();return Boolean(t)},separator:!0}).add("insert_link",{name:a("Insert link"),separator:!0,sequence:150,action:sl}).add("conditional_formatting",{name:a("Conditional formatting"),sequence:160,action:tl,separator:!0});const al=new Oa;al.add("cut",{name:a("Cut"),shortCut:"Ctrl+X",sequence:10,action:Ua}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Da}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:Pa}).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:Ba}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Va}).add("sort_columns",{name:e=>e.getters.getActiveCols().size>1?a("Sort columns"):a("Sort column"),sequence:50,isVisible:nl,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:il}).addChild("sort_descending",["sort_columns"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ol}).add("add_column_before",{name:e=>{const t=Na(e);return 1===t?a("Insert column left"):a("Insert %s columns left",t.toString())},sequence:70,action:Ja}).add("add_column_after",{name:e=>{const t=Na(e);return 1===t?a("Insert column right"):a("Insert %s columns right",t.toString())},sequence:80,action:el}).add("delete_column",{name:Ga,sequence:90,action:Wa}).add("clear_column",{name:e=>{let t,s;const i=e.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),s=Math.max(...i);else{const i=e.getters.getSelectedZones()[0];t=i.left,s=i.right}return t===s?a("Clear column %s",ts(t)):a("Clear columns %s - %s",ts(t),ts(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",ts(s).toString()):i-s+1===t.length?a("Hide columns %s - %s",ts(s).toString(),ts(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:tl});const ll=new Oa;ll.add("sheet",{name:a("Link sheet"),sequence:10,children:e=>e.getters.getSheets().map(((e,t)=>_a(e.id,{name:e.name,sequence:t,action:()=>{return{link:{label:e.name,url:(t=e.id,`${Ts}${t}`)},urlRepresentation:e.name,isUrlEditable:!1};var t}})))});const cl=new Oa;cl.add("cut",{name:a("Cut"),sequence:10,shortCut:"Ctrl+X",action:Ua}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Da}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:Pa}).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:Ba}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:Va}).add("add_row_before",{name:e=>{const t=ka(e);return 1===t?a("Insert row above"):a("Insert %s rows above",t.toString())},sequence:50,action:Ka}).add("add_row_after",{name:e=>{const t=ka(e);return 1===t?a("Insert row below"):a("Insert %s rows below",t.toString())},sequence:60,action:Qa}).add("delete_row",{name:za,sequence:70,action:Za}).add("clear_row",{name:e=>{let t,s;const i=e.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),s=Math.max(...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:tl});const hl=new Oa;hl.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 dl=new Oa;dl.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:Da}).addChild("cut",["edit"],{name:a("Cut"),shortCut:"Ctrl+X",sequence:40,action:Ua}).addChild("paste",["edit"],{name:a("Paste"),shortCut:"Ctrl+V",sequence:50,action:Pa}).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:Ba}).addChild("paste_special_format",["edit","paste_special"],{name:a("Paste format only"),sequence:20,action:Va}).addChild("sort_range",["edit"],{name:a("Sort range"),sequence:62,isVisible:nl,separator:!0}).addChild("sort_ascending",["edit","sort_range"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:il}).addChild("sort_descending",["edit","sort_range"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:ol}).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:Ha}).addChild("edit_delete_row",["edit"],{name:za,sequence:80,action:Za}).addChild("edit_delete_column",["edit"],{name:Ga,sequence:90,action:Wa}).addChild("edit_delete_cell_shift_up",["edit"],{name:a("Delete cell and shift up"),sequence:93,action:Ya}).addChild("edit_delete_cell_shift_left",["edit"],{name:a("Delete cell and shift left"),sequence:97,action:Xa}).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=ka(e);return 1===t?a("Row above"):a("%s Rows above",t.toString())},sequence:10,action:Ka,isVisible:e=>0===e.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=ka(e);return 1===t?a("Row below"):a("%s Rows below",t.toString())},sequence:20,action:Qa,isVisible:e=>0===e.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Na(e);return 1===t?a("Column left"):a("%s Columns left",t.toString())},sequence:30,action:Ja,isVisible:e=>0===e.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Na(e);return 1===t?a("Column right"):a("%s Columns right",t.toString())},sequence:40,action:el,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:qa}).addChild("insert_insert_cell_shift_right",["insert"],{name:a("Insert cells and shift right"),sequence:47,action:ja,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=[ks(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=ks({...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:sl}).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=>Fa(e,"")}).addChild("format_number_number",["format","format_number"],{name:a("Number (1,000.12)"),sequence:20,action:e=>Fa(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:a("Percent (10.12%)"),sequence:30,separator:!0,action:e=>Fa(e,"0.00%")}).addChild("format_number_date",["format","format_number"],{name:a("Date (9/26/2008)"),sequence:40,action:e=>Fa(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:a("Time (10:43:00 PM)"),sequence:50,action:e=>Fa(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=>Fa(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=>Fa(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:a("Bold"),sequence:20,shortCut:"Ctrl+B",action:e=>$a(e,{bold:!e.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:a("Italic"),sequence:30,shortCut:"Ctrl+I",action:e=>$a(e,{italic:!e.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:a("Underline"),shortCut:"Ctrl+U",sequence:40,action:e=>$a(e,{underline:!e.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:a("Strikethrough"),sequence:50,action:e=>$a(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:tl,separator:!0});for(let e of ls)dl.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>$a(t,{fontSize:e.pt})});const ul=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:pl,xml:gl}=t.tags,fl=[["#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"]],ml=24*Math.max(...fl.map((e=>e.length)))+12;class vl extends t.Component{constructor(){super(...arguments),this.COLORS=fl}onColorClick(e){const t=e.target.dataset.color;t&&this.trigger("color-picked",{color:t})}}vl.template=gl`
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,b=23,S=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 be(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 Se(e,t,s){return be(e,t,t,s)}function Ce(e,t,s){return be(e,((e,s)=>"number"==typeof s?t(e,s):e),((e,s)=>t(e,de(s))),s)}function Ie(e,t,s){return be(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){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===e||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 new Pe}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var Be,Ve,He,ze;e.CommandResult=void 0,(Be=e.CommandResult||(e.CommandResult={}))[Be.Success=0]="Success",Be[Be.CancelledForUnknownReason=1]="CancelledForUnknownReason",Be[Be.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",Be[Be.MergeIsDestructive=3]="MergeIsDestructive",Be[Be.CellIsMerged=4]="CellIsMerged",Be[Be.InvalidTarget=5]="InvalidTarget",Be[Be.EmptyUndoStack=6]="EmptyUndoStack",Be[Be.EmptyRedoStack=7]="EmptyRedoStack",Be[Be.NotEnoughElements=8]="NotEnoughElements",Be[Be.NotEnoughSheets=9]="NotEnoughSheets",Be[Be.MissingSheetName=10]="MissingSheetName",Be[Be.DuplicatedSheetName=11]="DuplicatedSheetName",Be[Be.DuplicatedSheetId=12]="DuplicatedSheetId",Be[Be.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",Be[Be.WrongSheetMove=14]="WrongSheetMove",Be[Be.WrongSheetPosition=15]="WrongSheetPosition",Be[Be.InvalidAnchorZone=16]="InvalidAnchorZone",Be[Be.SelectionOutOfBound=17]="SelectionOutOfBound",Be[Be.TargetOutOfSheet=18]="TargetOutOfSheet",Be[Be.WrongPasteSelection=19]="WrongPasteSelection",Be[Be.EmptyClipboard=20]="EmptyClipboard",Be[Be.EmptyRange=21]="EmptyRange",Be[Be.InvalidRange=22]="InvalidRange",Be[Be.InvalidSheetId=23]="InvalidSheetId",Be[Be.InputAlreadyFocused=24]="InputAlreadyFocused",Be[Be.MaximumRangesReached=25]="MaximumRangesReached",Be[Be.InvalidChartDefinition=26]="InvalidChartDefinition",Be[Be.EmptyDataSet=27]="EmptyDataSet",Be[Be.InvalidDataSet=28]="InvalidDataSet",Be[Be.InvalidLabelRange=29]="InvalidLabelRange",Be[Be.InvalidAutofillSelection=30]="InvalidAutofillSelection",Be[Be.WrongComposerSelection=31]="WrongComposerSelection",Be[Be.MinBiggerThanMax=32]="MinBiggerThanMax",Be[Be.LowerBiggerThanUpper=33]="LowerBiggerThanUpper",Be[Be.MidBiggerThanMax=34]="MidBiggerThanMax",Be[Be.MinBiggerThanMid=35]="MinBiggerThanMid",Be[Be.FirstArgMissing=36]="FirstArgMissing",Be[Be.SecondArgMissing=37]="SecondArgMissing",Be[Be.MinNaN=38]="MinNaN",Be[Be.MidNaN=39]="MidNaN",Be[Be.MaxNaN=40]="MaxNaN",Be[Be.ValueUpperInflectionNaN=41]="ValueUpperInflectionNaN",Be[Be.ValueLowerInflectionNaN=42]="ValueLowerInflectionNaN",Be[Be.MinInvalidFormula=43]="MinInvalidFormula",Be[Be.MidInvalidFormula=44]="MidInvalidFormula",Be[Be.MaxInvalidFormula=45]="MaxInvalidFormula",Be[Be.ValueUpperInvalidFormula=46]="ValueUpperInvalidFormula",Be[Be.ValueLowerInvalidFormula=47]="ValueLowerInvalidFormula",Be[Be.InvalidSortZone=48]="InvalidSortZone",Be[Be.WaitingSessionConfirmation=49]="WaitingSessionConfirmation",Be[Be.MergeOverlap=50]="MergeOverlap",Be[Be.TooManyHiddenElements=51]="TooManyHiddenElements",Be[Be.Readonly=52]="Readonly",Be[Be.InvalidOffset=53]="InvalidOffset",Be[Be.InvalidViewportSize=54]="InvalidViewportSize",Be[Be.FigureDoesNotExist=55]="FigureDoesNotExist",Be[Be.DuplicatedFigureId=56]="DuplicatedFigureId",Be[Be.DuplicatedChartId=57]="DuplicatedChartId",Be[Be.ChartDoesNotExist=58]="ChartDoesNotExist",function(e){e.FormatFromArgument="FormatFromArgument"}(Ve||(Ve={})),function(e){e[e.UP=0]="UP",e[e.DOWN=1]="DOWN",e[e.LEFT=2]="LEFT",e[e.RIGHT=3]="RIGHT"}(He||(He={})),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 Ze={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},Ge={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},We={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},qe={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},je={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},Ye={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},Xe={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},Ke={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},Qe={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},Je={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},et={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:Ve.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},tt={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:Ve.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},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.")}\n `),returns:["NUMBER"],returnFormat:Ve.FormatFromArgument,compute:function(e,t){return tt.compute(e,t,0)},isExported:!0},it={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},ot={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},nt={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},rt={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},at={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 Se(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},lt={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},ct={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 ht(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const dt={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 Se(e,((e,t)=>ht(t)?e.add(t):e),new Set).size}},ut={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];ht(o)&&s.add(o)})),s.size}},pt={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},gt={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},ft={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},mt={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},vt={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},Et={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:Ve.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:Ve.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},St={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:Ve.FormatFromArgument,compute:function(e,t=1){return bt.compute(e,t,0)},isExported:!0},Ct={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},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:Ve.FormatFromArgument,compute:function(e,t=1){return tt.compute(e,t,0)},isExported:!0},yt={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},wt={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},Tt={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:Ve.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},xt={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:Ve.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},Rt={description:a("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Lt={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:Ve.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},Mt={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:Ve.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},At={description:a("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},_t={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:Ve.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},Ot={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:Ve.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},Nt={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:Ve.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},kt={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:Ve.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},Ft={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},$t={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},Dt={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},Ut={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},Pt={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:Ve.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},Bt={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:Ve.FormatFromArgument,compute:function(...e){return Ce(e,((e,t)=>e+t),0)},isExported:!0},Vt={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},Ht={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},Zt={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},Gt={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:Ve.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 Wt=Object.freeze({__proto__:null,ABS:Ze,ACOS:Ge,ACOSH:We,ACOT:qe,ACOTH:je,ASIN:Ye,ASINH:Xe,ATAN:Ke,ATAN2:Qe,ATANH:Je,CEILING:et,CEILING_MATH:tt,CEILING_PRECISE:st,COS:it,COSH:ot,COT:nt,COTH:rt,COUNTBLANK:at,COUNTIF:lt,COUNTIFS:ct,COUNTUNIQUE:dt,COUNTUNIQUEIFS:ut,CSC:pt,CSCH:gt,DECIMAL:ft,DEGREES:mt,EXP:vt,FLOOR:Et,FLOOR_MATH:bt,FLOOR_PRECISE:St,ISEVEN:Ct,ISO_CEILING:It,ISODD:yt,LN:wt,MOD:Tt,ODD:xt,PI:Rt,POWER:Lt,PRODUCT:Mt,RAND:At,RANDBETWEEN:_t,ROUND:Ot,ROUNDDOWN:Nt,ROUNDUP:kt,SEC:Ft,SECH:$t,SIN:Dt,SINH:Ut,SQRT:Pt,SUM:Bt,SUMIF:Vt,SUMIFS:Ht,TAN:zt,TANH:Zt,TRUNC:Gt});const qt=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function jt(e){return e.toString(16).padStart(6,"0")}let Yt=0;function Xt(){return Yt=++Yt%qt.length,qt[Yt]}function Kt(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 Qt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Jt=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 es(e){const t=e.split("!"),s=t.pop();return{sheetName:t.join("!")||void 0,xc:s}}function ts(e){return e<26?String.fromCharCode(65+e):ts(Math.floor(e/26)-1)+ts(e%26)}function ss(e){e=e.toUpperCase().trim();const[t,s,i]=e.match(Qt);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 is(e,t,s={colFixed:!1,rowFixed:!1}){return(s.colFixed?"$":"")+ts(e)+(s.rowFixed?"$":"")+String(t+1)}const os=140,ns=20,rs=.035;function as(e){return ns+(os-ns)*Math.exp(-rs*(e-1))}const ls=[{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}],cs={};for(let e of ls)cs[e.pt]=e.px;function hs(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ds(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]=ds(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 us(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function ps(e,t,s){return e<t?t:e>s?s:e}function gs(e,t,s){const i=s.italic?"italic ":"",o=s.bold?"bold":T,n=s.fontSize||x,r=cs[n];return e.font=`${i}${o} ${r}px ${R}`,e.measureText(t).width}function fs(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 ms(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*vs(e,t){t.next();for(const s of e){const e=t.next();yield{...s,next:e.done?void 0:e.value}}}function Es(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}function bs(e){return null!==G(e)}const Ss=/^\[(.+)\]\((.+)\)$/,Cs=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Is(e){return Ss.test(e)}function ys(e,t){return`[${e}](${t})`}function ws(e){const t=e.match(Ss)||[],s=t[1],i=t[2];if(!s||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:s,url:i}}const Ts="o-spreadsheet://";function xs(e){if(!Is(e))return!1;const{url:t}=ws(e);return t.startsWith(Ts)}function Rs(e){if(e.startsWith(Ts))return e.substr(Ts.length);throw new Error(`${e} is not a valid sheet link`)}function Ls(e){return void 0!==e}const Ms={};function As(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(!As(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function _s(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 Os(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 Ns(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":");let s,i,o,n,r=ss(t[0].trim());if(o=n=r[0],s=i=r[1],2===t.length){let e=ss(t[1].trim());n=e[0],i=e[1]}return{top:s,bottom:i,left:o,right:n}}function ks(e){let{top:t,bottom:s,left:i,right:o}=Ns(e);return o<i&&([o,i]=[i,o]),s<t&&([s,t]=[t,s]),{top:t,bottom:s,left:i,right:o}}function Fs(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 $s(e){const{top:t,bottom:s,left:i,right:o}=e;return t===s&&i===o?is(i,t):`${is(i,t)}:${is(o,s)}`}function Ds(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?Ys(e,n,"RESIZE",o):r<e[t]?Ys(e,n,"MOVE",o):{...e}}function Us(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 Ps(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 Bs(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Vs(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Hs(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=ks(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=ks(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:Zs(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($s)}function Zs(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 Gs(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 Ws(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function qs(e){const{width:t,height:s}=Ws(e);return 1===t||1===s}function js(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 fs(s,i+1))for(const s of fs(o,n+1))t.push([e,s]);return t}function Ys(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 Xs(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 Ks(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 Qs(e){const t=[];let s=0;for(let i=0;i<e;i++){const e={start:s,end:s+E,size:E,name:ts(i)};t.push(e),s=e.end}return t}function Js(e){const t=[];let s=0;for(let i=0;i<e;i++){const e={start:s,end:s+b,size:b,name:String(i+1),cells:{}};t.push(e),s=e.end}return t}function ei(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:ts(n)};r&&(a.isHidden=r),i.push(a),o=a.end}return i}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||b,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 si(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 ii(e,t=!1){const s={};for(let i in e){const o=e[i];(o.size!==b||t)&&(s[i]={size:o.size}),o.isHidden&&(s[i]=s[i]||{},s[i].isHidden=o.isHidden)}return s}class oi{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 ni(e,t,s){return[ri(e,"cols",fs(t,e.cols.length)),ri(e,"rows",fs(s,e.rows.length))]}function ri(e,t,s){const i=e[t];return s.find((e=>!i[e].isHidden))}function ai(e,t){let s=e[t].length-1;for(;s>=0&&!0===e[t][s].isHidden;)s--;return e[t][s]}function li(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 ci(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 hi(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 di={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},ui={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:Ve.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},pi=a("[[FUNCTION_NAME]] has mismatched range sizes."),gi=a("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),fi={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:Ve.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)),pi);let e=t.length,n=t[0].length;le((()=>e===s.length&&n===s[0].length),pi);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),gi),i+=n*l,o+=l)}}else s=he(s),t=he(t),le((()=>s>=0),gi),i+=t*s,o+=s;return le((()=>0!==o),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/o}},mi={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:Ve.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},vi={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},Ei={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},Si={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 Se(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Ci={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 li(e,t,!1)},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 li(e,t,!1)},isExported:!0},yi={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 li(e,t,!0)},isExported:!0},wi={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:Ve.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},Ti={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:Ve.FormatFromArgument,compute:function(...e){const t=Ce(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},xi={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:Ve.FormatFromArgument,compute:function(...e){const t=Ie(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Ri={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},Li={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:Ve.FormatFromArgument,compute:function(...e){let t=[];return Ee(e,(e=>{t.push(e)})),hi(t,.5,!0)},isExported:!0},Mi={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:Ve.FormatFromArgument,compute:function(...e){const t=Ce(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Ai={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:Ve.FormatFromArgument,compute:function(...e){const t=Ie(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},_i={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},Oi={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:Ve.FormatFromArgument,compute:function(e,t){return ki.compute(e,t)},isExported:!0},Ni={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:Ve.FormatFromArgument,compute:function(e,t){return hi([e],t,!1)},isExported:!0},ki={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:Ve.FormatFromArgument,compute:function(e,t){return hi([e],t,!0)},isExported:!0},Fi={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:Ve.FormatFromArgument,compute:function(e,t){return Di.compute(e,t)},isExported:!0},$i={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:Ve.FormatFromArgument,compute:function(e,t){return hi([e],.25*Math.trunc(he(t)),!1)},isExported:!0},Di={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:Ve.FormatFromArgument,compute:function(e,t){return hi([e],.25*Math.trunc(he(t)),!0)},isExported:!0},Ui={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:Ve.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},Pi={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(Gi.compute(...e))},isExported:!0},Bi={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(Wi.compute(...e))},isExported:!0},Vi={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(qi.compute(...e))},isExported:!0},Hi={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(ji.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(Yi.compute(...e))},isExported:!0},Zi={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(Xi.compute(...e))},isExported:!0},Gi={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 ci(e,!0,!1)},isExported:!0},Wi={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 ci(e,!1,!1)},isExported:!0},qi={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 ci(e,!0,!1)},isExported:!0},ji={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 ci(e,!0,!0)},isExported:!0},Yi={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 ci(e,!1,!1)},isExported:!0},Xi={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 ci(e,!1,!0)},isExported:!0};var Ki=Object.freeze({__proto__:null,AVEDEV:di,AVERAGE:ui,AVERAGE_WEIGHTED:fi,AVERAGEA:mi,AVERAGEIF:vi,AVERAGEIFS:Ei,COUNT:bi,COUNTA:Si,COVAR:Ci,COVARIANCE_P:Ii,COVARIANCE_S:yi,LARGE:wi,MAX:Ti,MAXA:xi,MAXIFS:Ri,MEDIAN:Li,MIN:Mi,MINA:Ai,MINIFS:_i,PERCENTILE:Oi,PERCENTILE_EXC:Ni,PERCENTILE_INC:ki,QUARTILE:Fi,QUARTILE_EXC:$i,QUARTILE_INC:Di,SMALL:Ui,STDEV:Pi,STDEV_P:Bi,STDEV_S:Vi,STDEVA:Hi,STDEVP:zi,STDEVPA:Zi,VAR:Gi,VAR_P:Wi,VAR_S:qi,VARA:ji,VARP:Yi,VARPA:Xi});function Qi(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 Ji=_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`),eo={description:a("Average of a set of values from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return ui.compute([i])},isExported:!0},to={description:a("Counts values from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return bi.compute([i])},isExported:!0},so={description:a("Counts values and text from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return Si.compute([i])},isExported:!0},io={description:a("Single value from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return le((()=>1===i.length),a("More than one match found in DGET evaluation.")),i[0]},isExported:!0},oo={description:a("Maximum of values from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return Ti.compute([i])},isExported:!0},no={description:a("Minimum of values from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return Mi.compute([i])},isExported:!0},ro={description:a("Product of values from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return Mt.compute([i])},isExported:!0},ao={description:a("Standard deviation of population sample from table."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return Pi.compute([i])},isExported:!0},lo={description:a("Standard deviation of entire population from table."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return zi.compute([i])},isExported:!0},co={description:a("Sum of values from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return Bt.compute([i])},isExported:!0},ho={description:a("Variance of population sample from table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return Gi.compute([i])},isExported:!0},uo={description:a("Variance of a population from a table-like range."),args:Ji,returns:["NUMBER"],compute:function(e,t,s){const i=Qi(e,t,s);return Yi.compute([i])},isExported:!0};var po=Object.freeze({__proto__:null,DAVERAGE:eo,DCOUNT:to,DCOUNTA:so,DGET:io,DMAX:oo,DMIN:no,DPRODUCT:ro,DSTDEV:ao,DSTDEVP:lo,DSUM:co,DVAR:ho,DVARP:uo});const go=new D(1899,11,30);function fo(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}const mo={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()-go.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},vo={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},Eo={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},So={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()-go.getTime();return Math.round(a/864e5)},isExported:!0},Co={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()-go.getTime();return Math.round(r/864e5)},isExported:!0},Io={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},yo={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},wo={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},To={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},xo={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 Lo.compute(e,t,1,s)},isExported:!0};function Ro(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 Lo={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=Ro(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},Mo={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()-go.getTime(),s=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/864e5)+s},isExported:!0},Ao={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},_o={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},Oo={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},No={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()-go.getTime();return Math.round(t/864e5)},isExported:!0},ko={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},Fo={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 yo.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},$o={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 Do.compute(e,t,1,s)},isExported:!0},Do={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=Ro(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-go.getTime();return Math.round(p/864e5)},isExported:!0},Uo={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},Po={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===(fo(p)?29:28)&&(c=30,1===u&&h===(fo(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+=fo(e)?366:365;e=s/t}else t?fo(p)&&(e=366):(fo(p)&&d<2&&(e=366),fo(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 Bo=Object.freeze({__proto__:null,DATE:mo,DATEVALUE:vo,DAY:Eo,DAYS:bo,EDATE:So,EOMONTH:Co,HOUR:Io,ISOWEEKNUM:yo,MINUTE:wo,MONTH:To,NETWORKDAYS:xo,NETWORKDAYS_INTL:Lo,NOW:Mo,SECOND:Ao,TIME:_o,TIMEVALUE:Oo,TODAY:No,WEEKDAY:ko,WEEKNUM:Fo,WORKDAY:$o,WORKDAY_INTL:Do,YEAR:Uo,YEARFRAC:Po});function Vo(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 Ho={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=Po.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,b=0;for(let e=1;e<=f;e++){const t=(m+(e===f?1:0))/(1+v)**e;b+=(g+(e-1)/d)*t,E+=t}return 0===E?0:b/E}},Zo={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)}},Go={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 Vo((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}},Wo={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 qo={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)}},jo={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)}},Yo={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)}},Xo={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=Po.compute(l,c,g)*p,m=Math.ceil(f),v=f-Math.floor(f)||1,E=1+d/p,b=100*h/p;if(1===m)return(b+u)/(v*d/p+1)-b*(1-v);let S=0;for(let e=1;e<=m;e++)S+=b/E**(e-1+v);return u/E**(m-1+v)+S-b*(1-v)}},Ko={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=Po.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 b=Vo((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(b-1)*p}},Qo={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=Po.compute(c,l,u),g=Po.compute(c,r,u),f=Po.compute(r,l,u);return(100*(1+h*p)/(d+100*h*g)-1)/f}};var Jo=Object.freeze({__proto__:null,DB:Ho,DURATION:zo,FV:Zo,IRR:Go,MDURATION:Wo,NPV:qo,PDURATION:jo,PV:Yo,PRICE:Xo,YIELD:Ko,YIELDMAT:Qo});const en={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},tn={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},sn={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},on={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},nn={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 rn=Object.freeze({__proto__:null,ISERROR:en,ISLOGICAL:tn,ISNONTEXT:sn,ISNUMBER:on,ISTEXT:nn});const an={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},ln={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},cn={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},hn={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},dn={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},un={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},pn={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 gn=Object.freeze({__proto__:null,AND:an,IF:ln,IFERROR:cn,IFS:hn,NOT:dn,OR:un,XOR:pn});function fn(e,t){for(let s=0;s<e.length;s++)if(e[s]===t)return s;return-1}const mn={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 ks(e).left+1},isExported:!0},vn={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=ks(e);return t.right-t.left+1},isExported:!0},En={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):fn(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},Sn={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=fn(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},Cn={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 ks(e).top+1},isExported:!0},In={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=ks(e);return t.bottom-t.top+1},isExported:!0},yn={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):fn(r,e),le((()=>l>-1),a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ue(e))),t[o-1][l]},isExported:!0};var wn=Object.freeze({__proto__:null,COLUMN:mn,COLUMNS:vn,HLOOKUP:En,LOOKUP:bn,MATCH:Sn,ROW:Cn,ROWS:In,VLOOKUP:yn});const Tn={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:Ve.FormatFromArgument,compute:function(e,t){return he(e)+he(t)}},xn={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},Rn={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:Ve.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 Ln(e){return null==e}const Mn={number:0,string:"",boolean:!1},An={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=Ln(e)?Mn[typeof t]:e,t=Ln(t)?Mn[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function _n(e,t,s){e=Ln(e)?Mn[typeof t]:e,t=Ln(t)?Mn[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 On={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 _n(e,t,((e,t)=>e>t))}},Nn={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 _n(e,t,((e,t)=>e>=t))}},kn={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!Nn.compute(e,t)}},Fn={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!On.compute(e,t)}},$n={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:Ve.FormatFromArgument,compute:function(e,t){return he(e)-he(t)}},Dn={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:Ve.FormatFromArgument,compute:function(e,t){return he(e)*he(t)}},Un={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!An.compute(e,t)}},Pn={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 Lt.compute(e,t)}},Bn={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:Ve.FormatFromArgument,returns:["NUMBER"],compute:function(e){return-he(e)}},Vn={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}},Hn={description:a("A specified number, unchanged."),args:_e(`\n value (any) ${a("The number to return.")}\n `),returnFormat:Ve.FormatFromArgument,returns:["ANY"],compute:function(e){return e}};var zn=Object.freeze({__proto__:null,ADD:Tn,CONCAT:xn,DIVIDE:Rn,EQ:An,GT:On,GTE:Nn,LT:kn,LTE:Fn,MINUS:$n,MULTIPLY:Dn,NE:Un,POW:Pn,UMINUS:Bn,UNARY_PERCENT:Vn,UPLUS:Hn});const Zn={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},Gn={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 Se(e,((e,t)=>e+ue(t)),"")},isExported:!0},Wn={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},qn={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},jn={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 Se(t,((e,t)=>(e?e+s:"")+ue(t)),"")}},Yn={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},Xn={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},Kn={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},Qn={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},Jn={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},er={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},tr={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(hs(r),"g");if(0===o)return n.replace(c,l);let h=0;return n.replace(c,(e=>++h===o?l:e))},isExported:!0},sr={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 Se(s,((e,t)=>o&&""===ue(t)?e:(n++?e+i:"")+ue(t)),"")},isExported:!0},ir={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},or={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 nr={database:po,date:Bo,financial:Jo,info:rn,lookup:wn,logical:gn,math:Wt,operators:zn,statistical:Ki,text:Object.freeze({__proto__:null,CHAR:Zn,CONCATENATE:Gn,EXACT:Wn,FIND:qn,JOIN:jn,LEFT:Yn,LEN:Xn,LOWER:Kn,REPLACE:Qn,RIGHT:Jn,SEARCH:er,SUBSTITUTE:tr,TEXTJOIN:sr,TRIM:ir,UPPER:or})};const rr=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 nr){const t=nr[e];for(let s in t){const i=t[s];i.category=e,rr.add(s,{isExported:!1,...i})}}const ar=/^[S|N]?\d+/,lr=rr.content,cr="+,-,*,/,:,=,<>,>=,>,<=,<,%,^,&".split(",");function hr(e){const t=e.split(""),s=[];for(;t.length;){let e=Ir(t)||gr(t)||mr(t)||Er(t)||ur(t)||dr(t)||yr(t)||vr(t)||Sr(t);e||(e={type:"UNKNOWN",value:t.shift()}),s.push(e)}return s}function dr(e){if(e[0]===$){e.shift();const t=e.join("").match(ar);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 ur(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const pr={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function gr(e){if(e[0]in pr){const t=e.shift();return{type:pr[t],value:t}}return null}function fr(e,t){for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function mr(e){for(let t of cr)if(fr(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function vr(e){const t=e.join("").match(K);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Er(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 Sr(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 lr?"FUNCTION":"SYMBOL",value:e}}return null}const Cr=/\s/;function Ir(e){let t=0;for(;e[0]&&e[0].match(Cr);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function yr(e){return fr(e,_)?(e.splice(0,_.length),{type:"INVALID_REFERENCE",value:_}):null}const wr=["-","+"],Tr=["*","+","&"],xr={"^":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},Rr=6;function Lr(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 xr[e.value]||15}throw new Error(a("Unknown token: %s",e.value))}function Mr(e,t,s){if("OPERATOR"===t.type){const i=Ar(s,Lr(t));return{type:"BIN_OPERATION",value:t.value,left:e,right:i}}throw new Error(N)}function Ar(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=Ar(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(Ar(t,Rr));"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(Ar(t,Rr))}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(Qt.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=Ar(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&&wr.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,right:Ar(t,xr[e.value])};throw new Error(a("Unexpected token: %s",e.value))}}(s,e);for(;e[0]&&Lr(e[0])>t;)i=Mr(i,e.shift(),e);return i}function _r(e){const t=hr(e).filter((e=>"SPACE"!==e.type));"OPERATOR"===t[0].type&&"="===t[0].value&&t.splice(0,1);const s=Ar(t,0);if(t.length)throw new Error(N);return s}function Or(e,t,s){switch(t===e.type&&(e=s(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>Or(e,t,s)))};case"UNARY_OPERATION":return{...e,right:Or(e.right,t,s)};case"BIN_OPERATION":return{...e,right:Or(e.right,t,s),left:Or(e.left,t,s)};default:return e}}function Nr(e,t={references:[],numbers:[],strings:[]}){switch(e.type){case"FUNCALL":const s=e.args.map((e=>Nr(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+kr(e,t);case"BIN_OPERATION":return function(e,t){const s=e.value,i=e.left,o=i.value;return"BIN_OPERATION"===i.type&&xr[o]<xr[s]?`(${Nr(i,t)})`:Nr(i,t)}(e,t)+e.value+kr(e,t)}}function kr(e,t){const s=e.value,i=e.right,o=xr[i.value],n=xr[s];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:o<n?r=!0:o!==n||Tr.includes(s)||(r=!0),r?`(${Nr(i,t)})`:Nr(i,t)}const Fr=rr.content,$r={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Dr={"-":"UMINUS","+":"UPLUS"};function Ur(e){return e.map((e=>e.split("\n"))).flat().filter((e=>""!==e.trim()))}const Pr={};function Br(e){if(!Pr[e.text]){const t=_r(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=Ur([`// ${e.text}`,i.code,`return ${i.id};`]).join("\n");let n=new Function("deps","sheetId","ref","range","ctx",o);function r(e){const t=Fr[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||$r["="]}", ${c.paramIndex})`;break;case"FUNCALL":d=s++;const a=r(t);h.push(Ur(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=Dr[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=$r[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${Ur(h).join("\n\t")}\n\treturn ${p};\n}`}}return h.push(`let _${d} = ${p};`),{id:`_${d}`,code:Ur(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=Fr[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=Fr[$r[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[]}Pr[e.text]=n,Pr[e.text].dependenciesFormat=c(t)}return Pr[e.text]}function Vr(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 Hr(e){return Vr(hr(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}))}(Vr(hr(e)))))}function Zr(e){const t=Hr(e);let s={numbers:[],strings:[],references:[]};return{text:"".concat(...t.map((e=>{if("SYMBOL"===e.type&&Qt.test(e.value)){const t=e.value.trim();s.references.includes(t)||s.references.push(t);return Gr(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 Gr(`${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 Gr(`${e.type[0]}${i}`)}return e.value}))),dependencies:s}}function Gr(e){return`${$}${e}${$}`}const Wr=new Le;function qr(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 jr(e){return""===e?"":J(e)?te(e):Es(e)?"TRUE"===e.toUpperCase():bs(e)?G(e).value:e}class Yr{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 qr(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 Xr extends Yr{constructor(e,t={}){super(e,{value:"",type:ke.empty},t),this.content=""}isEmpty(){return!0}}class Kr extends Yr{constructor(e,t,s={}){super(e,{value:t,type:ke.number},s),this.content=ie(this.evaluated.value)}}class Qr extends Yr{constructor(e,t,s={}){super(e,{value:t,type:ke.boolean},s),this.content=this.evaluated.value?"TRUE":"FALSE"}}class Jr extends Yr{constructor(e,t,s={}){super(e,{value:t,type:ke.text},s),this.content=this.evaluated.value}}class ea extends Kr{constructor(e,t,s){super(e,t,s),this.format=s.format}get composerContent(){return qr(this.evaluated.value,this.format)}}class ta extends Yr{constructor(e,t,s={}){var i;const o=ws(t);s={...s,style:{...s.style,textColor:(null===(i=s.style)||void 0===i?void 0:i.textColor)||M,underline:!0}},super(e,{value:o.label,type:ke.text},s),this.link=o,this.content=t}isLink(){return!0}get composerContent(){return this.link.label}}class sa extends ta{constructor(e,t,s={}){super(e,t,s),this.link.url=this.withHttp(this.link.url),this.link.isExternal=!0,this.content=ys(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 ia extends ta{constructor(e,t,s={},i){super(e,t,s),this.sheetName=i,this.sheetId=Rs(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 oa extends Yr{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 na extends Yr{constructor(e,t,s,i){super(e,{value:"#BAD_EXPR",type:ke.error,error:s},i),this.content=t}}function ra(e){const t=Hr(e);let s=[];return{text:"".concat(...t.map((e=>{if("SYMBOL"===e.type&&Qt.test(e.value)){const t=e.value.trim();return s.includes(t)||s.push(t),`${$}${s.indexOf(t)}${$}`}return e.value}))),dependencies:s}}Wr.add("Formula",{sequence:10,match:e=>e.startsWith("="),createCell:(e,t,s,i,o)=>{const n=Zr(t),r=n.text,a=Br(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 oa(((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 Xr(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 Kr(e,te(t),s))}).add("Boolean",{sequence:40,match:e=>Es(e),createCell:(e,t,s)=>new Qr(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 ea(e,i.value,{...s,format:o})}}).add("MarkdownSheetLink",{sequence:60,match:e=>xs(e),createCell:(e,t,s,i,o)=>new ia(e,t,s,(e=>o.tryGetSheetName(e)))}).add("MarkdownLink",{sequence:70,match:e=>Is(e),createCell:(e,t,s)=>new sa(e,t,s)}).add("WebLink",{sequence:80,match:e=>{return t=e,Cs.test(t);var t},createCell:(e,t,s)=>new sa(e,ys(t,t),s)});const aa=10,la="Sheet1";function ca(e){return e?("version"in(e=JSON.parse(JSON.stringify(e)))&&e.version<aa&&(e=function(e){for(let t=ha.findIndex((t=>t.from===e.version));t<ha.length;t++)e=ha[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,s=new oi;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(ga(),e,{version:aa}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(pa(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(pa(la,"Sheet1"));return e}(e),e}(e),e):ga()}const ha=[{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=ra(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=ks(e.dataRange),s=e.labelCell+":"+is(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 da(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:la};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=ua(t,"SORT_CELLS"),t=ua(t,"SET_DECIMAL")}function ua(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 pa(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[]}}function ga(e="Sheet1"){return{version:aa,sheets:[pa(la,e)],entities:{},styles:{},borders:{},revisionId:O,uniqueFigureIds:!0}}class fa{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)}}fa.getters=[],fa.modes=["headless","normal"];class ma extends fa{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 va extends ma{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":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){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=fs(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=fs(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))):[]}getRowsRange(e){if(!this.borders[e])return[];return fs(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.getRowsRange(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]=ss(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,ks(e))}export(e){let t=0;const s={};function i(e){for(let[t,i]of Object.entries(s))if(As(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=is(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)}}va.getters=["getCellBorder"];const Ea=new RegExp(String.fromCharCode(160),"g");class ba extends ma{constructor(){super(...arguments),this.cells={},this.cellUuidGenerator=new oi(!0),this.createCell=function(e){const t=Wr.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 Jr(s,i,o);try{return r.createCell(s,i,o,n,e)}catch(e){return new na(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=fs(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=fs(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]=ss(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(As(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[is(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]=ss(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.style||{}}zoneToXC(e,t,s=[{colFixed:!1,rowFixed:!1}]){const i=is((t=this.getters.expandZone(e,t)).left,t.top,s[0]),o=is(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(Ea,""))||"":(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 Hs(t,s,{top:0,left:0,bottom:i.rows.length-1,right:i.cols.length-1})?0:18}}ba.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Sa extends ma{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={...ds(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}=Ws(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: ${$s(t)}`);if(s){const i=$s(t),o=$s(s);return{labelCell:this.getters.getRangeFromSheetXC(e,o),dataRange:this.getters.getRangeFromSheetXC(e,i)}}return{labelCell:void 0,dataRange:this.getters.getRangeFromSheetXC(e,$s(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=>!Jt.test(e)));return t?28:0}checkLabelRange(e){if(!e.definition.labelRange)return 0;return!Jt.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 Ca(e){return""===e?NaN:Number(e)}Sa.getters=["getChartDefinition","getChartDefinitionUI","getChartsIdBySheet"];class Ia extends ma{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($s)};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)Hs(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{Br(Zr(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&&Ca(t)>=Ca(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&&Ca(s)>=Ca(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&&Ca(s)>=Ca(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)}}}Ia.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class ya extends ma{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(Ls)}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)}}ya.getters=["getFigures","getFigure","getFigureSheetId"];class wa extends ma{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}=ks(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:is(s,o)+":"+is(i,n)}(t,e.elements)),!0):this.exportAndRemoveMerges(e.sheetId,(t=>function(e,t){let{left:s,right:i,top:o,bottom:n}=ks(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:is(s,o)+":"+is(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}=ks(e);return i>=t&&(i+=s),(i>=t||o>=t)&&(o+=s),i>o?null:is(i,n)+":"+is(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}=ks(e);return n>=t&&(n+=s),(n>=t||r>=t)&&(r+=s),n>r?null:is(i,n)+":"+is(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(Ls)}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&&Vs(s,r)&&(r=Ps(s,r))}return Bs(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 Bs(t,s);const{width:i,height:o}=Ws(t);return 1===i&&1===o}isMergeDestructive(e,t){let{left:s,right:i,top:o,bottom:n}=t;i=ps(i,0,e.cols.length-1),n=ps(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&&Vs(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||!Bs(e,o))return 5}return 0}addMerge(e,t){let{left:s,right:i,top:o,bottom:n}=t;i=ps(i,0,e.cols.length-1),n=ps(n,0,e.rows.length-1);if(is(s,o)===is(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&&Bs(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=Ta(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,ks(e))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Ta(e))}}exportForExcel(e){this.export(e)}}function Ta(e){return Object.values(e).filter(Ls).map((e=>is(e.left,e.top)+":"+is(e.right,e.bottom)))}wa.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCell","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","isSingleCellOrMerge"];class xa extends ma{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:ei(t.cols||{},s),rows:ti(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(Ls).map((e=>{const s=this.sheets[e];return{id:s.id,name:s.name,colNumber:s.cols.length,rowNumber:s.rows.length,rows:ii(s.rows,t),cols:si(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(Ls)}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 Gs(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:Qs(s),rows:Js(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 ms(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.dispatch("UPDATE_CELL_POSITION",{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({type:"UPDATE_CELL_POSITION",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.dispatch(e.type,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.dispatch("UPDATE_CELL_POSITION",{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:ts(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:ts(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:ts(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(ss);return{rowNumber:Math.max(e.rowNumber,_s(t.map((([e,t])=>t+1)))),colNumber:Math.max(e.colNumber,_s(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(Fs))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 Bs(Ps(t=i,e),t);var t}))?0:18}return 0}}xa.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheets","getVisibleSheets","getEvaluationSheets","getCol","getRow","getCell","getCellPosition","getColCells","getColsZone","getRowsZone","getNumberCols","getNumberRows","getHiddenColsGroups","getHiddenRowsGroups","getGridLinesVisibility","getNextSheetName","isEmpty"];const Ra=new Le;Ra.add("INCREMENT_MODIFIER",{apply:(e,t)=>{var s;e.current+=e.increment;const i=e.current.toString(),o=qr(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 La=new Le;La.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 Ma=new Le,Aa=(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 ms(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())Aa.contains(e)||Aa.add(e,_a);function _a(e){return[e]}const Oa=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,shortCut:"",action:!1,children:[],separator:!1,icon:!1,id:e});function Na(e,t){return Object.assign({},Oa(e),t)}class ka extends Le{add(e,t){return this.content[e]=Na(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(Na(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 Fa(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 $a(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 Da(e,t){e.dispatch("SET_FORMATTING",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones(),format:t})}function Ua(e,t){e.dispatch("SET_FORMATTING",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones(),style:t})}const Pa=async e=>{e.dispatch("COPY",{target:e.getters.getSelectedZones()}),await e.clipboard.writeText(e.getters.getClipboardContent())},Ba=async e=>{e.dispatch("CUT",{target:e.getters.getSelectedZones()}),await e.clipboard.writeText(e.getters.getClipboardContent())},Va=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})},Ha=e=>e.dispatch("PASTE",{target:e.getters.getSelectedZones(),pasteOption:"onlyValue"}),za=e=>e.dispatch("PASTE",{target:e.getters.getSelectedZones(),pasteOption:"onlyFormat"}),Za=e=>e.dispatch("DELETE_CONTENT",{sheetId:e.getters.getActiveSheetId(),target:e.getters.getSelectedZones()}),Ga=e=>{let t,s;const i=e.getters.getActiveRows();if(0!==i.size)t=Os([...i]),s=_s([...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())},Wa=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})},qa=e=>{let t,s;const i=e.getters.getActiveCols();if(0!==i.size)t=Os([...i]),s=_s([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.left,s=i.right}return t===s?a("Delete column %s",ts(t)):a("Delete columns %s - %s",ts(t),ts(s))},ja=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})},Ya=e=>{const t=e.getters.getSelectedZone();e.dispatch("INSERT_CELL",{shiftDimension:"ROW",zone:t,interactive:!0})},Xa=e=>{const t=e.getters.getSelectedZone();e.dispatch("INSERT_CELL",{shiftDimension:"COL",zone:t,interactive:!0})},Ka=e=>{const t=e.getters.getSelectedZone();e.dispatch("DELETE_CELL",{shiftDimension:"ROW",zone:t,interactive:!0})},Qa=e=>{const t=e.getters.getSelectedZone();e.dispatch("DELETE_CELL",{shiftDimension:"COL",zone:t,interactive:!0})},Ja=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.top,i=t.bottom-t.top+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"before",base:s,quantity:i,dimension:"ROW"})},el=e=>{const t=e.getters.getActiveRows();let s,i;if(t.size)s=_s([...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"})},tl=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.left,i=t.right-t.left+1}e.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.getters.getActiveSheetId(),position:"before",dimension:"COL",base:s,quantity:i})},sl=e=>{const t=e.getters.getActiveCols();let s,i;if(t.size)s=_s([...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})},il=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.getters.getSelectedZones()})},ol=e=>{e.openLinkEditor()},nl=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"})},rl=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"})},al=e=>1===e.getters.getSelectedZones().length,ll=new ka;ll.add("cut",{name:a("Cut"),shortCut:"Ctrl+X",sequence:10,action:Ba}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Pa}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:Va,isVisible:al}).add("paste_special",{name:a("Paste special"),sequence:40,separator:!0,isVisible:al}).addChild("paste_value_only",["paste_special"],{name:a("Paste values only"),sequence:10,action:Ha}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:za}).add("sort_range",{name:a("Sort range"),sequence:50,isVisible:al,separator:!0}).addChild("sort_ascending",["sort_range"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:nl}).addChild("sort_descending",["sort_range"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:rl}).add("add_row_before",{name:e=>{const t=$a(e);return 1===t?a("Insert row"):a("Insert %s rows",t.toString())},sequence:70,action:Ja,isVisible:al}).add("add_column_before",{name:e=>{const t=Fa(e);return 1===t?a("Insert column"):a("Insert %s columns",t.toString())},sequence:90,action:tl,isVisible:al}).add("insert_cell",{name:a("Insert cells"),sequence:100,isVisible:al,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:a("Shift down"),sequence:10,action:Ya}).addChild("insert_cell_right",["insert_cell"],{name:a("Shift right"),sequence:20,action:Xa}).add("delete_row",{name:Ga,sequence:110,action:Wa,isVisible:al}).add("delete_column",{name:qa,sequence:120,action:ja,isVisible:al}).add("delete_cell",{name:a("Delete cells"),sequence:130,isVisible:al}).addChild("delete_cell_up",["delete_cell"],{name:a("Shift up"),sequence:10,action:Ka}).addChild("delete_cell_down",["delete_cell"],{name:a("Shift left"),sequence:20,action:Qa}).add("clear_cell",{name:a("Clear cells"),sequence:140,action:Za,isEnabled:e=>{const t=e.getters.getActiveCell();return Boolean(t)},separator:!0}).add("insert_link",{name:a("Insert link"),separator:!0,sequence:150,action:ol}).add("conditional_formatting",{name:a("Conditional formatting"),sequence:160,action:il,separator:!0});const cl=new ka;cl.add("cut",{name:a("Cut"),shortCut:"Ctrl+X",sequence:10,action:Ba}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Pa}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:Va}).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:Ha}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:za}).add("sort_columns",{name:e=>e.getters.getActiveCols().size>1?a("Sort columns"):a("Sort column"),sequence:50,isVisible:al,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:nl}).addChild("sort_descending",["sort_columns"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:rl}).add("add_column_before",{name:e=>{const t=Fa(e);return 1===t?a("Insert column left"):a("Insert %s columns left",t.toString())},sequence:70,action:tl}).add("add_column_after",{name:e=>{const t=Fa(e);return 1===t?a("Insert column right"):a("Insert %s columns right",t.toString())},sequence:80,action:sl}).add("delete_column",{name:qa,sequence:90,action:ja}).add("clear_column",{name:e=>{let t,s;const i=e.getters.getActiveCols();if(0!==i.size)t=Os([...i]),s=_s([...i]);else{const i=e.getters.getSelectedZones()[0];t=i.left,s=i.right}return t===s?a("Clear column %s",ts(t)):a("Clear columns %s - %s",ts(t),ts(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",ts(s).toString()):i-s+1===t.length?a("Hide columns %s - %s",ts(s).toString(),ts(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:il});const hl=new ka;hl.add("sheet",{name:a("Link sheet"),sequence:10,children:e=>e.getters.getSheets().map(((e,t)=>Na(e.id,{name:e.name,sequence:t,action:()=>{return{link:{label:e.name,url:(t=e.id,`${Ts}${t}`)},urlRepresentation:e.name,isUrlEditable:!1};var t}})))});const dl=new ka;dl.add("cut",{name:a("Cut"),sequence:10,shortCut:"Ctrl+X",action:Ba}).add("copy",{name:a("Copy"),shortCut:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Pa}).add("paste",{name:a("Paste"),shortCut:"Ctrl+V",sequence:30,action:Va}).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:Ha}).addChild("paste_format_only",["paste_special"],{name:a("Paste format only"),sequence:20,action:za}).add("add_row_before",{name:e=>{const t=$a(e);return 1===t?a("Insert row above"):a("Insert %s rows above",t.toString())},sequence:50,action:Ja}).add("add_row_after",{name:e=>{const t=$a(e);return 1===t?a("Insert row below"):a("Insert %s rows below",t.toString())},sequence:60,action:el}).add("delete_row",{name:Ga,sequence:70,action:Wa}).add("clear_row",{name:e=>{let t,s;const i=e.getters.getActiveRows();if(0!==i.size)t=Os([...i]),s=_s([...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:il});const ul=new ka;ul.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 pl=new ka;pl.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:Pa}).addChild("cut",["edit"],{name:a("Cut"),shortCut:"Ctrl+X",sequence:40,action:Ba}).addChild("paste",["edit"],{name:a("Paste"),shortCut:"Ctrl+V",sequence:50,action:Va}).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:Ha}).addChild("paste_special_format",["edit","paste_special"],{name:a("Paste format only"),sequence:20,action:za}).addChild("sort_range",["edit"],{name:a("Sort range"),sequence:62,isVisible:al,separator:!0}).addChild("sort_ascending",["edit","sort_range"],{name:a("Ascending (A ⟶ Z)"),sequence:10,action:nl}).addChild("sort_descending",["edit","sort_range"],{name:a("Descending (Z ⟶ A)"),sequence:20,action:rl}).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:Za}).addChild("edit_delete_row",["edit"],{name:Ga,sequence:80,action:Wa}).addChild("edit_delete_column",["edit"],{name:qa,sequence:90,action:ja}).addChild("edit_delete_cell_shift_up",["edit"],{name:a("Delete cell and shift up"),sequence:93,action:Ka}).addChild("edit_delete_cell_shift_left",["edit"],{name:a("Delete cell and shift left"),sequence:97,action:Qa}).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=$a(e);return 1===t?a("Row above"):a("%s Rows above",t.toString())},sequence:10,action:Ja,isVisible:e=>0===e.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=$a(e);return 1===t?a("Row below"):a("%s Rows below",t.toString())},sequence:20,action:el,isVisible:e=>0===e.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Fa(e);return 1===t?a("Column left"):a("%s Columns left",t.toString())},sequence:30,action:tl,isVisible:e=>0===e.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Fa(e);return 1===t?a("Column right"):a("%s Columns right",t.toString())},sequence:40,action:sl,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:Ya}).addChild("insert_insert_cell_shift_right",["insert"],{name:a("Insert cells and shift right"),sequence:47,action:Xa,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=[$s(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=$s({...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:ol}).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=>Da(e,"")}).addChild("format_number_number",["format","format_number"],{name:a("Number (1,000.12)"),sequence:20,action:e=>Da(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:a("Percent (10.12%)"),sequence:30,separator:!0,action:e=>Da(e,"0.00%")}).addChild("format_number_date",["format","format_number"],{name:a("Date (9/26/2008)"),sequence:40,action:e=>Da(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:a("Time (10:43:00 PM)"),sequence:50,action:e=>Da(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=>Da(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=>Da(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:a("Bold"),sequence:20,shortCut:"Ctrl+B",action:e=>Ua(e,{bold:!e.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:a("Italic"),sequence:30,shortCut:"Ctrl+I",action:e=>Ua(e,{italic:!e.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:a("Underline"),shortCut:"Ctrl+U",sequence:40,action:e=>Ua(e,{underline:!e.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:a("Strikethrough"),sequence:50,action:e=>Ua(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:il,separator:!0});for(let e of ls)pl.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>Ua(t,{fontSize:e.pt})});const gl=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:fl,xml:ml}=t.tags,vl=[["#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"]],El=24*Math.max(...vl.map((e=>e.length)))+12;class bl extends t.Component{constructor(){super(...arguments),this.COLORS=vl}onColorClick(e){const t=e.target.dataset.color;t&&this.trigger("color-picked",{color:t})}}bl.template=ml`
2
2
  <div class="o-color-picker"
3
3
  t-att-class="props.dropdownDirection || 'right'"
4
4
  t-on-click="onColorClick">
@@ -7,7 +7,7 @@
7
7
  <div class="o-color-picker-line-item" t-att-data-color="color" t-attf-style="background-color:{{color}};"></div>
8
8
  </t>
9
9
  </div>
10
- </div>`,vl.style=pl`
10
+ </div>`,bl.style=fl`
11
11
  .o-color-picker {
12
12
  position: absolute;
13
13
  top: calc(100% + 5px);
@@ -41,10 +41,10 @@
41
41
  right: 0;
42
42
  }
43
43
  &.center {
44
- left: calc(50% - ${ml/2}px);
44
+ left: calc(50% - ${El/2}px);
45
45
  }
46
46
  }
47
- `;const El='<svg class="o-icon"><polygon fill="#000000" points="0 0 4 4 8 0" transform="translate(5 7)"/></svg>',Sl='<svg class="o-icon"><polygon fill="#000000" points="0 0 4 4 0 8" transform="translate(5 5)"/></svg>',bl='<svg class="o-icon"><path fill="#000000" fill-rule="evenodd" d="M9,3.5 C9,1.57 7.43,0 5.5,0 L1.77635684e-15,0 L1.77635684e-15,12 L6.25,12 C8.04,12 9.5,10.54 9.5,8.75 C9.5,7.45 8.73,6.34 7.63,5.82 C8.46,5.24 9,4.38 9,3.5 Z M5,2 C5.82999992,2 6.5,2.67 6.5,3.5 C6.5,4.33 5.82999992,5 5,5 L3,5 L3,2 L5,2 Z M3,10 L3,7 L5.5,7 C6.32999992,7 7,7.67 7,8.5 C7,9.33 6.32999992,10 5.5,10 L3,10 Z" transform="translate(4 3)"/></svg>',Cl='<svg class="o-icon"><polygon fill="#000000" fill-rule="evenodd" points="4 0 4 2 6.58 2 2.92 10 0 10 0 12 8 12 8 10 5.42 10 9.08 2 12 2 12 0" transform="translate(3 3)"/></svg>',Il='<svg class="o-icon"><path fill="#010101" fill-rule="evenodd" d="M2.8875,3.06 C2.8875,2.6025 2.985,2.18625 3.18375,1.8075 C3.3825,1.42875 3.66,1.10625 4.02,0.84 C4.38,0.57375 4.80375,0.3675 5.29875,0.22125 C5.79375,0.075 6.33375,0 6.92625,0 C7.53375,0 8.085,0.0825 8.58,0.25125 C9.075,0.42 9.49875,0.6525 9.85125,0.95625 C10.20375,1.25625 10.47375,1.6125 10.665,2.02875 C10.85625,2.44125 10.95,2.895 10.95,3.38625 L8.6925,3.38625 C8.6925,3.1575 8.655,2.94375 8.58375,2.74875 C8.5125,2.55 8.4,2.38125 8.25,2.2425 C8.1,2.10375 7.9125,1.99125 7.6875,1.91625 C7.4625,1.8375 7.19625,1.8 6.88875,1.8 C6.5925,1.8 6.3375,1.83375 6.11625,1.8975 C5.89875,1.96125 5.71875,2.05125 5.57625,2.1675 C5.43375,2.28375 5.325,2.41875 5.25375,2.5725 C5.1825,2.72625 5.145,2.895 5.145,3.0675 C5.145,3.4275 5.32875,3.73125 5.69625,3.975 C5.71780203,3.98908066 5.73942012,4.00311728 5.76118357,4.01733315 C6.02342923,4.18863185 6.5,4.5 7,5 L4,5 C4,5 3.21375,4.37625 3.17625,4.30875 C2.985,3.9525 2.8875,3.53625 2.8875,3.06 Z M14,6 L0,6 L0,8 L7.21875,8 C7.35375,8.0525 7.51875,8.105 7.63125,8.15375 C7.90875,8.2775 8.12625,8.40875 8.28375,8.53625 C8.44125,8.6675 8.54625,8.81 8.6025,8.96 C8.65875,9.11375 8.685,9.28625 8.685,9.47375 C8.685,9.65 8.65125,9.815 8.58375,9.965 C8.51625,10.11875 8.41125,10.25 8.2725,10.35875 C8.13375,10.4675 7.95375,10.55375 7.74,10.6175 C7.5225,10.68125 7.27125,10.71125 6.97875,10.71125 C6.6525,10.71125 6.35625,10.6775 6.09,10.61375 C5.82375,10.55 5.59875,10.445 5.41125,10.3025 C5.22375,10.16 5.0775,9.9725 4.9725,9.74375 C4.8675,9.515 4.78125,9.17 4.78125,9 L2.55,9 C2.55,9.2525 2.61,9.6875 2.72625,10.025 C2.8425,10.3625 3.0075,10.66625 3.21375,10.9325 C3.42,11.19875 3.6675,11.4275 3.94875,11.6225 C4.23,11.8175 4.53375,11.9825 4.86375,12.11 C5.19375,12.24125 5.535,12.33875 5.89875,12.39875 C6.25875,12.4625 6.6225,12.4925 6.9825,12.4925 C7.5825,12.4925 8.13,12.425 8.6175,12.28625 C9.105,12.1475 9.525,11.94875 9.87,11.69375 C10.215,11.435 10.48125,11.12 10.6725,10.74125 C10.86375,10.3625 10.95375,9.935 10.95375,9.455 C10.95375,9.005 10.875,8.6 10.72125,8.24375 C10.68375,8.1575 10.6425,8.075 10.59375,7.9925 L14,8 L14,6 Z" transform="translate(2 3)"/></svg>',yl='<svg class="o-icon"><path fill="#000000" d="M7,0 L5,0 L0.5,12 L2.5,12 L3.62,9 L8.37,9 L9.49,12 L11.49,12 L7,0 L7,0 Z M4.38,7 L6,2.67 L7.62,7 L4.38,7 L4.38,7 Z" transform="translate(3 1)"/></svg>',wl='<svg class="o-icon"><path fill="#000000" d="M14.5,8.87 C14.5,8.87 13,10.49 13,11.49 C13,12.32 13.67,12.99 14.5,12.99 C15.33,12.99 16,12.32 16,11.49 C16,10.5 14.5,8.87 14.5,8.87 L14.5,8.87 Z M12.71,6.79 L5.91,0 L4.85,1.06 L6.44,2.65 L2.29,6.79 C1.9,7.18 1.9,7.81 2.29,8.2 L6.79,12.7 C6.99,12.9 7.24,13 7.5,13 C7.76,13 8.01,12.9 8.21,12.71 L12.71,8.21 C13.1,7.82 13.1,7.18 12.71,6.79 L12.71,6.79 Z M4.21,7 L7.5,3.71 L10.79,7 L4.21,7 L4.21,7 Z"/></svg>',Tl='<svg class="o-icon"><path fill="#000000" d="M0,14 L10,14 L10,12 L0,12 L0,14 Z M10,4 L0,4 L0,6 L10,6 L10,4 Z M0,0 L0,2 L14,2 L14,0 L0,0 Z M0,10 L14,10 L14,8 L0,8 L0,10 Z" transform="translate(2 2)"/></svg>',xl='<svg class="o-icon"><path fill="#000000" d="M2,12 L2,14 L12,14 L12,12 L2,12 Z M2,4 L2,6 L12,6 L12,4 L2,4 Z M0,10 L14,10 L14,8 L0,8 L0,10 Z M0,0 L0,2 L14,2 L14,0 L0,0 Z" transform="translate(2 2)"/></svg>',Rl='<svg class="o-icon"><path fill="#000000" d="M4,14 L14,14 L14,12 L4,12 L4,14 Z M0,10 L14,10 L14,8 L0,8 L0,10 Z M0,0 L0,2 L14,2 L14,0 L0,0 Z M4,6 L14,6 L14,4 L4,4 L4,6 Z" transform="translate(2 2)"/></svg>',Ll='<svg class="o-icon"><path fill="#000000" d="M0,0 L0,14 L14,14 L14,0 L0,0 L0,0 Z M6,12 L2,12 L2,8 L6,8 L6,12 L6,12 Z M6,6 L2,6 L2,2 L6,2 L6,6 L6,6 Z M12,12 L8,12 L8,8 L12,8 L12,12 L12,12 Z M12,6 L8,6 L8,2 L12,2 L12,6 L12,6 Z" transform="translate(2 2)"/></svg>',Ml='<svg class="o-icon" viewBox="0 0 384 384"><rect x="0" y="277.333" width="384" height="42.667"/><rect x="0" y="170.667" width="384" height="42.667"/><rect x="0" y="64" width="384" height="42.667"/></svg>',Al='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>',_l='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>',Ol='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>',Nl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>',kl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>',Fl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>',$l='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>',Dl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>',Ul='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon red-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#DC6965" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>';function Pl(e){const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const Bl={arrowGood:{img:Pl(_l),svg:_l},arrowNeutral:{img:Pl(Ol),svg:Ol},arrowBad:{img:Pl(Al),svg:Al},smileyGood:{img:Pl(Nl),svg:Nl},smileyNeutral:{img:Pl(kl),svg:kl},smileyBad:{img:Pl(Fl),svg:Fl},dotGood:{img:Pl($l),svg:$l},dotNeutral:{img:Pl(Dl),svg:Dl},dotBad:{img:Pl(Ul),svg:Ul}},Vl={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}},{xml:Hl,css:zl}=t.tags,Zl=new si,Gl=Hl`
47
+ `;const Sl='<svg class="o-icon"><polygon fill="#000000" points="0 0 4 4 8 0" transform="translate(5 7)"/></svg>',Cl='<svg class="o-icon"><polygon fill="#000000" points="0 0 4 4 0 8" transform="translate(5 5)"/></svg>',Il='<svg class="o-icon"><path fill="#000000" fill-rule="evenodd" d="M9,3.5 C9,1.57 7.43,0 5.5,0 L1.77635684e-15,0 L1.77635684e-15,12 L6.25,12 C8.04,12 9.5,10.54 9.5,8.75 C9.5,7.45 8.73,6.34 7.63,5.82 C8.46,5.24 9,4.38 9,3.5 Z M5,2 C5.82999992,2 6.5,2.67 6.5,3.5 C6.5,4.33 5.82999992,5 5,5 L3,5 L3,2 L5,2 Z M3,10 L3,7 L5.5,7 C6.32999992,7 7,7.67 7,8.5 C7,9.33 6.32999992,10 5.5,10 L3,10 Z" transform="translate(4 3)"/></svg>',yl='<svg class="o-icon"><polygon fill="#000000" fill-rule="evenodd" points="4 0 4 2 6.58 2 2.92 10 0 10 0 12 8 12 8 10 5.42 10 9.08 2 12 2 12 0" transform="translate(3 3)"/></svg>',wl='<svg class="o-icon"><path fill="#010101" fill-rule="evenodd" d="M2.8875,3.06 C2.8875,2.6025 2.985,2.18625 3.18375,1.8075 C3.3825,1.42875 3.66,1.10625 4.02,0.84 C4.38,0.57375 4.80375,0.3675 5.29875,0.22125 C5.79375,0.075 6.33375,0 6.92625,0 C7.53375,0 8.085,0.0825 8.58,0.25125 C9.075,0.42 9.49875,0.6525 9.85125,0.95625 C10.20375,1.25625 10.47375,1.6125 10.665,2.02875 C10.85625,2.44125 10.95,2.895 10.95,3.38625 L8.6925,3.38625 C8.6925,3.1575 8.655,2.94375 8.58375,2.74875 C8.5125,2.55 8.4,2.38125 8.25,2.2425 C8.1,2.10375 7.9125,1.99125 7.6875,1.91625 C7.4625,1.8375 7.19625,1.8 6.88875,1.8 C6.5925,1.8 6.3375,1.83375 6.11625,1.8975 C5.89875,1.96125 5.71875,2.05125 5.57625,2.1675 C5.43375,2.28375 5.325,2.41875 5.25375,2.5725 C5.1825,2.72625 5.145,2.895 5.145,3.0675 C5.145,3.4275 5.32875,3.73125 5.69625,3.975 C5.71780203,3.98908066 5.73942012,4.00311728 5.76118357,4.01733315 C6.02342923,4.18863185 6.5,4.5 7,5 L4,5 C4,5 3.21375,4.37625 3.17625,4.30875 C2.985,3.9525 2.8875,3.53625 2.8875,3.06 Z M14,6 L0,6 L0,8 L7.21875,8 C7.35375,8.0525 7.51875,8.105 7.63125,8.15375 C7.90875,8.2775 8.12625,8.40875 8.28375,8.53625 C8.44125,8.6675 8.54625,8.81 8.6025,8.96 C8.65875,9.11375 8.685,9.28625 8.685,9.47375 C8.685,9.65 8.65125,9.815 8.58375,9.965 C8.51625,10.11875 8.41125,10.25 8.2725,10.35875 C8.13375,10.4675 7.95375,10.55375 7.74,10.6175 C7.5225,10.68125 7.27125,10.71125 6.97875,10.71125 C6.6525,10.71125 6.35625,10.6775 6.09,10.61375 C5.82375,10.55 5.59875,10.445 5.41125,10.3025 C5.22375,10.16 5.0775,9.9725 4.9725,9.74375 C4.8675,9.515 4.78125,9.17 4.78125,9 L2.55,9 C2.55,9.2525 2.61,9.6875 2.72625,10.025 C2.8425,10.3625 3.0075,10.66625 3.21375,10.9325 C3.42,11.19875 3.6675,11.4275 3.94875,11.6225 C4.23,11.8175 4.53375,11.9825 4.86375,12.11 C5.19375,12.24125 5.535,12.33875 5.89875,12.39875 C6.25875,12.4625 6.6225,12.4925 6.9825,12.4925 C7.5825,12.4925 8.13,12.425 8.6175,12.28625 C9.105,12.1475 9.525,11.94875 9.87,11.69375 C10.215,11.435 10.48125,11.12 10.6725,10.74125 C10.86375,10.3625 10.95375,9.935 10.95375,9.455 C10.95375,9.005 10.875,8.6 10.72125,8.24375 C10.68375,8.1575 10.6425,8.075 10.59375,7.9925 L14,8 L14,6 Z" transform="translate(2 3)"/></svg>',Tl='<svg class="o-icon"><path fill="#000000" d="M7,0 L5,0 L0.5,12 L2.5,12 L3.62,9 L8.37,9 L9.49,12 L11.49,12 L7,0 L7,0 Z M4.38,7 L6,2.67 L7.62,7 L4.38,7 L4.38,7 Z" transform="translate(3 1)"/></svg>',xl='<svg class="o-icon"><path fill="#000000" d="M14.5,8.87 C14.5,8.87 13,10.49 13,11.49 C13,12.32 13.67,12.99 14.5,12.99 C15.33,12.99 16,12.32 16,11.49 C16,10.5 14.5,8.87 14.5,8.87 L14.5,8.87 Z M12.71,6.79 L5.91,0 L4.85,1.06 L6.44,2.65 L2.29,6.79 C1.9,7.18 1.9,7.81 2.29,8.2 L6.79,12.7 C6.99,12.9 7.24,13 7.5,13 C7.76,13 8.01,12.9 8.21,12.71 L12.71,8.21 C13.1,7.82 13.1,7.18 12.71,6.79 L12.71,6.79 Z M4.21,7 L7.5,3.71 L10.79,7 L4.21,7 L4.21,7 Z"/></svg>',Rl='<svg class="o-icon"><path fill="#000000" d="M0,14 L10,14 L10,12 L0,12 L0,14 Z M10,4 L0,4 L0,6 L10,6 L10,4 Z M0,0 L0,2 L14,2 L14,0 L0,0 Z M0,10 L14,10 L14,8 L0,8 L0,10 Z" transform="translate(2 2)"/></svg>',Ll='<svg class="o-icon"><path fill="#000000" d="M2,12 L2,14 L12,14 L12,12 L2,12 Z M2,4 L2,6 L12,6 L12,4 L2,4 Z M0,10 L14,10 L14,8 L0,8 L0,10 Z M0,0 L0,2 L14,2 L14,0 L0,0 Z" transform="translate(2 2)"/></svg>',Ml='<svg class="o-icon"><path fill="#000000" d="M4,14 L14,14 L14,12 L4,12 L4,14 Z M0,10 L14,10 L14,8 L0,8 L0,10 Z M0,0 L0,2 L14,2 L14,0 L0,0 Z M4,6 L14,6 L14,4 L4,4 L4,6 Z" transform="translate(2 2)"/></svg>',Al='<svg class="o-icon"><path fill="#000000" d="M0,0 L0,14 L14,14 L14,0 L0,0 L0,0 Z M6,12 L2,12 L2,8 L6,8 L6,12 L6,12 Z M6,6 L2,6 L2,2 L6,2 L6,6 L6,6 Z M12,12 L8,12 L8,8 L12,8 L12,12 L12,12 Z M12,6 L8,6 L8,2 L12,2 L12,6 L12,6 Z" transform="translate(2 2)"/></svg>',_l='<svg class="o-icon" viewBox="0 0 384 384"><rect x="0" y="277.333" width="384" height="42.667"/><rect x="0" y="170.667" width="384" height="42.667"/><rect x="0" y="64" width="384" height="42.667"/></svg>',Ol='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>',Nl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>',kl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>',Fl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>',$l='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>',Dl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>',Ul='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>',Pl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>',Bl='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon red-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#DC6965" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>';function Vl(e){const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const Hl={arrowGood:{img:Vl(Nl),svg:Nl},arrowNeutral:{img:Vl(kl),svg:kl},arrowBad:{img:Vl(Ol),svg:Ol},smileyGood:{img:Vl(Fl),svg:Fl},smileyNeutral:{img:Vl($l),svg:$l},smileyBad:{img:Vl(Dl),svg:Dl},dotGood:{img:Vl(Ul),svg:Ul},dotNeutral:{img:Vl(Pl),svg:Pl},dotBad:{img:Vl(Bl),svg:Bl}},zl={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}},{xml:Zl,css:Gl}=t.tags,Wl=new oi,ql=Zl`
48
48
  <div class="o-selection">
49
49
  <div t-foreach="ranges" t-as="range" t-key="range.id" class="o-selection-input">
50
50
  <input
@@ -80,7 +80,7 @@
80
80
  t-on-click="disable">Confirm</button>
81
81
  </div>
82
82
 
83
- </div>`,Wl=zl`
83
+ </div>`,jl=Gl`
84
84
  .o-selection {
85
85
  .o-selection-input {
86
86
  display: flex;
@@ -125,7 +125,7 @@
125
125
  }
126
126
  }
127
127
  }
128
- `;class ql extends t.Component{constructor(){super(...arguments),this.id=Zl.uuidv4(),this.previousRanges=this.props.ranges||[],this.getters=this.env.getters,this.dispatch=this.env.dispatch,this.originSheet=this.env.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1})}get ranges(){const e=this.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges?this.props.ranges.map(((e,t)=>({xc:e,id:t.toString(),isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}mounted(){this.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges,hasSingleRange:this.props.hasSingleRange})}async willUnmount(){this.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}async patched(){const e=this.getters.getSelectionInputValue(this.id);this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){const e=this.getters.getSelectionInputValue(this.id);this.trigger("selection-changed",{ranges:e}),this.previousRanges=e}focus(e){this.state.isMissing=!1,this.dispatch("STOP_EDITION",{cancel:!0}),this.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){this.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),this.trigger("selection-confirmed")}onInputChanged(e,t){const s=t.target;this.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:s.value}),s.blur(),this.triggerChange()}disable(){this.dispatch("UNFOCUS_SELECTION_INPUT");const e=this.getters.getSelectionInputValue(this.id);this.props.required&&0===e.length&&(this.state.isMissing=!0);const t=this.getters.getActiveSheetId();this.originSheet!==t&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:this.originSheet}),this.trigger("selection-confirmed")}}ql.template=Gl,ql.style=Wl;const jl={CF_TITLE:a("Format rules"),IS_RULE:a("Format cells if..."),FORMATTING_STYLE:a("Formatting style"),BOLD:a("Bold"),ITALIC:a("Italic"),UNDERLINE:a("Underline"),STRIKE_THROUGH:a("Strikethrough"),TEXT_COLOR:a("Text Color"),FILL_COLOR:a("Fill Color"),CANCEL:a("Cancel"),SAVE:a("Save"),PREVIEW_TEXT:a("Preview text"),Errors:{22:a("The range is invalid"),36:a("The argument is missing. Please provide a value"),37:a("The second argument is missing. Please provide a value"),38:a("The minpoint must be a number"),39:a("The midpoint must be a number"),40:a("The maxpoint must be a number"),41:a("The first value must be a number"),42:a("The second value must be a number"),32:a("Minimum must be smaller then Maximum"),35:a("Minimum must be smaller then Midpoint"),34:a("Midpoint must be smaller then Maximum"),33:a("Lower inflection point must be smaller then upper inflection point"),43:a("Invalid Minpoint formula"),45:a("Invalid Maxpoint formula"),44:a("Invalid Midpoint formula"),46:a("Invalid upper inflection point formula"),47:a("Invalid lower inflection point formula"),21:a("A range needs to be defined"),unexpected:a("The rule is invalid for an unknown reason")},SingleColor:a("Single color"),ColorScale:a("Color scale"),IconSet:a("Icon set"),newRule:a("Add another rule"),FixedNumber:a("Number"),Percentage:a("Percentage"),Percentile:a("Percentile"),Formula:a("Formula")},Yl=a("Cell values"),Xl=a("None"),Kl=a("Preview"),Ql=a("Minpoint"),Jl=a("Maxpoint"),ec=a("Midpoint"),tc=a("When value is"),sc=a("Else"),ic=a("Reverse icons"),oc=a("Icons"),nc=a("Type"),rc=a("Value"),ac={IsEmpty:a("Is empty"),IsNotEmpty:a("Is not empty"),ContainsText:a("Contains"),NotContains:a("Does not contain"),BeginsWith:a("Starts with"),EndsWith:a("Ends with"),Equal:a("Is equal to"),NotEqual:a("Is not equal to"),GreaterThan:a("Is greater than"),GreaterThanOrEqual:a("Is greater than or equal to"),LessThan:a("Is less than"),LessThanOrEqual:a("Is less than or equal to"),Between:a("Is between"),NotBetween:a("Is not between")},lc={ChartType:a("Chart type"),Line:a("Line"),Bar:a("Bar"),Pie:a("Pie"),StackedBar:a("Stacked barchart"),Title:a("Title"),Series:a("Series"),DataSeries:a("Data Series"),MyDataHasTitle:a("Data series include title"),DataCategories:a("Categories / Labels"),UpdateChart:a("Update chart"),CreateChart:a("Create chart"),TitlePlaceholder:a("New Chart"),BackgroundColor:a("Background color"),SelectColor:a("Select a color..."),VerticalAxisPosition:a("Vertical axis position"),LegendPosition:a("Legend position"),Left:a("Left"),Right:a("Right"),None:a("None"),Top:a("Top"),Bottom:a("Bottom"),Center:a("Center"),Linear:a("Linear"),Exponential:a("Exponential"),Logarithmic:a("Logarithmic"),Errors:{27:a("A dataset needs to be defined"),28:a("The dataset is invalid"),29:a("Labels are invalid"),unexpected:a("The chart definition is invalid for an unknown reason")}},cc=a("Search"),hc=a("Replace"),dc=a("Next"),uc=a("Previous"),pc=a("Match case"),gc=a("Match entire cell content"),fc=a("Search in formulas"),mc=a("Replace all"),vc=a("Also modify formulas"),Ec=a("Text"),Sc=a("Link"),bc=a("Confirm"),Cc=a("Cancel"),Ic=a("Edit link"),yc=a("Remove link"),wc=a("and"),{xml:Tc,css:xc}=t.tags,Rc=Tc`
128
+ `;class Yl extends t.Component{constructor(){super(...arguments),this.id=Wl.uuidv4(),this.previousRanges=this.props.ranges||[],this.getters=this.env.getters,this.dispatch=this.env.dispatch,this.originSheet=this.env.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1})}get ranges(){const e=this.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges?this.props.ranges.map(((e,t)=>({xc:e,id:t.toString(),isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}mounted(){this.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges,hasSingleRange:this.props.hasSingleRange})}async willUnmount(){this.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}async patched(){const e=this.getters.getSelectionInputValue(this.id);this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){const e=this.getters.getSelectionInputValue(this.id);this.trigger("selection-changed",{ranges:e}),this.previousRanges=e}focus(e){this.state.isMissing=!1,this.dispatch("STOP_EDITION",{cancel:!0}),this.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){this.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),this.trigger("selection-confirmed")}onInputChanged(e,t){const s=t.target;this.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:s.value}),s.blur(),this.triggerChange()}disable(){this.dispatch("UNFOCUS_SELECTION_INPUT");const e=this.getters.getSelectionInputValue(this.id);this.props.required&&0===e.length&&(this.state.isMissing=!0);const t=this.getters.getActiveSheetId();this.originSheet!==t&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:this.originSheet}),this.trigger("selection-confirmed")}}Yl.template=ql,Yl.style=jl;const Xl={CF_TITLE:a("Format rules"),IS_RULE:a("Format cells if..."),FORMATTING_STYLE:a("Formatting style"),BOLD:a("Bold"),ITALIC:a("Italic"),UNDERLINE:a("Underline"),STRIKE_THROUGH:a("Strikethrough"),TEXT_COLOR:a("Text Color"),FILL_COLOR:a("Fill Color"),CANCEL:a("Cancel"),SAVE:a("Save"),PREVIEW_TEXT:a("Preview text"),Errors:{22:a("The range is invalid"),36:a("The argument is missing. Please provide a value"),37:a("The second argument is missing. Please provide a value"),38:a("The minpoint must be a number"),39:a("The midpoint must be a number"),40:a("The maxpoint must be a number"),41:a("The first value must be a number"),42:a("The second value must be a number"),32:a("Minimum must be smaller then Maximum"),35:a("Minimum must be smaller then Midpoint"),34:a("Midpoint must be smaller then Maximum"),33:a("Lower inflection point must be smaller then upper inflection point"),43:a("Invalid Minpoint formula"),45:a("Invalid Maxpoint formula"),44:a("Invalid Midpoint formula"),46:a("Invalid upper inflection point formula"),47:a("Invalid lower inflection point formula"),21:a("A range needs to be defined"),unexpected:a("The rule is invalid for an unknown reason")},SingleColor:a("Single color"),ColorScale:a("Color scale"),IconSet:a("Icon set"),newRule:a("Add another rule"),FixedNumber:a("Number"),Percentage:a("Percentage"),Percentile:a("Percentile"),Formula:a("Formula")},Kl=a("Cell values"),Ql=a("None"),Jl=a("Preview"),ec=a("Minpoint"),tc=a("Maxpoint"),sc=a("Midpoint"),ic=a("When value is"),oc=a("Else"),nc=a("Reverse icons"),rc=a("Icons"),ac=a("Type"),lc=a("Value"),cc={IsEmpty:a("Is empty"),IsNotEmpty:a("Is not empty"),ContainsText:a("Contains"),NotContains:a("Does not contain"),BeginsWith:a("Starts with"),EndsWith:a("Ends with"),Equal:a("Is equal to"),NotEqual:a("Is not equal to"),GreaterThan:a("Is greater than"),GreaterThanOrEqual:a("Is greater than or equal to"),LessThan:a("Is less than"),LessThanOrEqual:a("Is less than or equal to"),Between:a("Is between"),NotBetween:a("Is not between")},hc={ChartType:a("Chart type"),Line:a("Line"),Bar:a("Bar"),Pie:a("Pie"),StackedBar:a("Stacked barchart"),Title:a("Title"),Series:a("Series"),DataSeries:a("Data Series"),MyDataHasTitle:a("Data series include title"),DataCategories:a("Categories / Labels"),UpdateChart:a("Update chart"),CreateChart:a("Create chart"),TitlePlaceholder:a("New Chart"),BackgroundColor:a("Background color"),SelectColor:a("Select a color..."),VerticalAxisPosition:a("Vertical axis position"),LegendPosition:a("Legend position"),Left:a("Left"),Right:a("Right"),None:a("None"),Top:a("Top"),Bottom:a("Bottom"),Center:a("Center"),Linear:a("Linear"),Exponential:a("Exponential"),Logarithmic:a("Logarithmic"),Errors:{27:a("A dataset needs to be defined"),28:a("The dataset is invalid"),29:a("Labels are invalid"),unexpected:a("The chart definition is invalid for an unknown reason")}},dc=a("Search"),uc=a("Replace"),pc=a("Next"),gc=a("Previous"),fc=a("Match case"),mc=a("Match entire cell content"),vc=a("Search in formulas"),Ec=a("Replace all"),bc=a("Also modify formulas"),Sc=a("Text"),Cc=a("Link"),Ic=a("Confirm"),yc=a("Cancel"),wc=a("Edit link"),Tc=a("Remove link"),xc=a("and"),{xml:Rc,css:Lc}=t.tags,Mc=Rc`
129
129
  <div class="o-chart">
130
130
  <div class="o-panel">
131
131
  <div class="o-panel-element"
@@ -141,34 +141,34 @@
141
141
  </div>
142
142
 
143
143
  <t t-if="state.panel === 'configuration'">
144
- <t t-call="${Tc`
144
+ <t t-call="${Rc`
145
145
  <div>
146
146
  <div class="o-section">
147
- <div class="o-section-title" t-esc="env._t('${lc.ChartType}')"/>
147
+ <div class="o-section-title" t-esc="env._t('${hc.ChartType}')"/>
148
148
  <select t-model="state.chart.type" class="o-input o-type-selector" t-on-change="updateSelect('type')">
149
- <option value="bar" t-esc="env._t('${lc.Bar}')"/>
150
- <option value="line" t-esc="env._t('${lc.Line}')"/>
151
- <option value="pie" t-esc="env._t('${lc.Pie}')"/>
149
+ <option value="bar" t-esc="env._t('${hc.Bar}')"/>
150
+ <option value="line" t-esc="env._t('${hc.Line}')"/>
151
+ <option value="pie" t-esc="env._t('${hc.Pie}')"/>
152
152
  </select>
153
153
  <t t-if="state.chart.type === 'bar'">
154
154
  <div class="o_checkbox">
155
155
  <input type="checkbox" name="stackedBar" t-model="state.chart.stackedBar" t-on-change="updateStacked"/>
156
- <t t-esc="env._t('${lc.StackedBar}')"/>
156
+ <t t-esc="env._t('${hc.StackedBar}')"/>
157
157
  </div>
158
158
  </t>
159
159
  </div>
160
160
  <div class="o-section o-data-series">
161
- <div class="o-section-title" t-esc="env._t('${lc.DataSeries}')"/>
161
+ <div class="o-section-title" t-esc="env._t('${hc.DataSeries}')"/>
162
162
  <SelectionInput t-key="getKey('dataSets')"
163
163
  ranges="state.chart.dataSets"
164
164
  isInvalid="isDatasetInvalid"
165
165
  required="true"
166
166
  t-on-selection-changed="onSeriesChanged"
167
167
  t-on-selection-confirmed="updateDataSet" />
168
- <input type="checkbox" t-model="state.chart.dataSetsHaveTitle" t-on-change="updateDataSet"/><t t-esc="env._t('${lc.MyDataHasTitle}')"/>
168
+ <input type="checkbox" t-model="state.chart.dataSetsHaveTitle" t-on-change="updateDataSet"/><t t-esc="env._t('${hc.MyDataHasTitle}')"/>
169
169
  </div>
170
170
  <div class="o-section o-data-labels">
171
- <div class="o-section-title" t-esc="env._t('${lc.DataCategories}')"/>
171
+ <div class="o-section-title" t-esc="env._t('${hc.DataCategories}')"/>
172
172
  <SelectionInput t-key="getKey('label')"
173
173
  ranges="[state.chart.labelRange || '']"
174
174
  isInvalid="isLabelInvalid"
@@ -185,42 +185,42 @@
185
185
  `}"/>
186
186
  </t>
187
187
  <t t-else="">
188
- <t t-call="${Tc`
188
+ <t t-call="${Rc`
189
189
  <div>
190
190
  <div class="o-section o-chart-title">
191
- <div class="o-section-title" t-esc="env._t('${lc.BackgroundColor}')"/>
191
+ <div class="o-section-title" t-esc="env._t('${hc.BackgroundColor}')"/>
192
192
  <div class="o-with-color-picker">
193
- <t t-esc="env._t('${lc.SelectColor}')"/>
193
+ <t t-esc="env._t('${hc.SelectColor}')"/>
194
194
  <span t-attf-style="border-color:{{state.chart.background}}"
195
- t-on-click.stop="toggleColorPicker">${wl}</span>
195
+ t-on-click.stop="toggleColorPicker">${xl}</span>
196
196
  <ColorPicker t-if="state.fillColorTool" t-on-color-picked="setColor" t-key="backgroundColor"/>
197
197
  </div>
198
198
  </div>
199
199
  <div class="o-section o-chart-title">
200
- <div class="o-section-title" t-esc="env._t('${lc.Title}')"/>
201
- <input type="text" t-model="state.chart.title" t-on-change="updateTitle" class="o-input" t-att-placeholder="env._t('${lc.TitlePlaceholder}')"/>
200
+ <div class="o-section-title" t-esc="env._t('${hc.Title}')"/>
201
+ <input type="text" t-model="state.chart.title" t-on-change="updateTitle" class="o-input" t-att-placeholder="env._t('${hc.TitlePlaceholder}')"/>
202
202
  </div>
203
203
  <div class="o-section">
204
- <div class="o-section-title"><t t-esc="env._t('${lc.VerticalAxisPosition}')"/></div>
204
+ <div class="o-section-title"><t t-esc="env._t('${hc.VerticalAxisPosition}')"/></div>
205
205
  <select t-model="state.chart.verticalAxisPosition" class="o-input o-type-selector" t-on-change="updateSelect('verticalAxisPosition')">
206
- <option value="left" t-esc="env._t('${lc.Left}')"/>
207
- <option value="right" t-esc="env._t('${lc.Right}')"/>
206
+ <option value="left" t-esc="env._t('${hc.Left}')"/>
207
+ <option value="right" t-esc="env._t('${hc.Right}')"/>
208
208
  </select>
209
209
  </div>
210
210
  <div class="o-section">
211
- <div class="o-section-title"><t t-esc="env._t('${lc.LegendPosition}')"/></div>
211
+ <div class="o-section-title"><t t-esc="env._t('${hc.LegendPosition}')"/></div>
212
212
  <select t-model="state.chart.legendPosition" class="o-input o-type-selector" t-on-change="updateSelect('legendPosition')">
213
- <option value="top" t-esc="env._t('${lc.Top}')"/>
214
- <option value="bottom" t-esc="env._t('${lc.Bottom}')"/>
215
- <option value="left" t-esc="env._t('${lc.Left}')"/>
216
- <option value="right" t-esc="env._t('${lc.Right}')"/>
213
+ <option value="top" t-esc="env._t('${hc.Top}')"/>
214
+ <option value="bottom" t-esc="env._t('${hc.Bottom}')"/>
215
+ <option value="left" t-esc="env._t('${hc.Left}')"/>
216
+ <option value="right" t-esc="env._t('${hc.Right}')"/>
217
217
  </select>
218
218
  </div>
219
219
  </div>
220
220
  `}"/>
221
221
  </t>
222
222
  </div>
223
- `,Lc=xc`
223
+ `,Ac=Lc`
224
224
  .o-chart {
225
225
  .o-panel {
226
226
  display: flex;
@@ -250,7 +250,7 @@
250
250
  border-bottom: 4px solid;
251
251
  }
252
252
  }
253
- `;class Mc extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters,this.chartSheetId=this.findSheetId(this.props.figure.id),this.state=t.useState(this.initialState(this.props.figure))}async willUpdateProps(e){this.getters.getChartDefinition(e.figure.id)?e.figure.id!==this.props.figure.id&&(this.chartSheetId=this.findSheetId(e.figure.id),this.state.panel="configuration",this.state.fillColorTool=!1,this.state.datasetDispatchResult=void 0,this.state.labelsDispatchResult=void 0,this.state.chart=this.env.getters.getChartDefinitionUI(this.chartSheetId,e.figure.id)):this.trigger("close-side-panel")}get errorMessages(){var e,t;return[...(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.labelsDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>this.env._t(lc.Errors[e]||lc.Errors.unexpected)))}get isDatasetInvalid(){var e,t;return!(!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(27))&&!(null===(t=this.state.datasetDispatchResult)||void 0===t?void 0:t.isCancelledBecause(28)))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(29))}onSeriesChanged(e){this.state.chart.dataSets=e.detail.ranges}updateDataSet(){this.state.datasetDispatchResult=this.updateChart({dataSets:this.state.chart.dataSets,dataSetsHaveTitle:this.state.chart.dataSetsHaveTitle})}updateStacked(){this.updateChart({stackedBar:this.state.chart.stackedBar})}updateTitle(){this.updateChart({title:this.state.chart.title})}updateSelect(e,t){this.state.chart[e]=t.target.value,this.updateChart({[e]:t.target.value})}updateLabelRange(){this.state.labelsDispatchResult=this.updateChart({labelRange:this.state.chart.labelRange||null})}updateChart(e){return this.env.dispatch("UPDATE_CHART",{id:this.props.figure.id,sheetId:this.chartSheetId,definition:e})}onLabelRangeChanged(e){this.state.chart.labelRange=e.detail.ranges[0]}getKey(e){return e+this.props.figure.id}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}setColor(e){this.state.chart.background=e.detail.color,this.state.fillColorTool=!1,this.updateChart({background:this.state.chart.background})}activate(e){this.state.panel=e}initialState(e){const t=this.findSheetId(e.id);return{chart:this.env.getters.getChartDefinitionUI(t,e.id),panel:"configuration",fillColorTool:!1}}findSheetId(e){return this.env.getters.getFigureSheetId(e)||""}}function Ac(e,t){return!!t.target&&e.contains(t.target)}function _c({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}Mc.template=Rc,Mc.style=Lc,Mc.components={SelectionInput:ql,ColorPicker:vl};const{useExternalListener:Oc}=t.hooks,{xml:Nc,css:kc}=t.tags,Fc=Nc`
253
+ `;class _c extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters,this.chartSheetId=this.findSheetId(this.props.figure.id),this.state=t.useState(this.initialState(this.props.figure))}async willUpdateProps(e){this.getters.getChartDefinition(e.figure.id)?e.figure.id!==this.props.figure.id&&(this.chartSheetId=this.findSheetId(e.figure.id),this.state.panel="configuration",this.state.fillColorTool=!1,this.state.datasetDispatchResult=void 0,this.state.labelsDispatchResult=void 0,this.state.chart=this.env.getters.getChartDefinitionUI(this.chartSheetId,e.figure.id)):this.trigger("close-side-panel")}get errorMessages(){var e,t;return[...(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.labelsDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>this.env._t(hc.Errors[e]||hc.Errors.unexpected)))}get isDatasetInvalid(){var e,t;return!(!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(27))&&!(null===(t=this.state.datasetDispatchResult)||void 0===t?void 0:t.isCancelledBecause(28)))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(29))}onSeriesChanged(e){this.state.chart.dataSets=e.detail.ranges}updateDataSet(){this.state.datasetDispatchResult=this.updateChart({dataSets:this.state.chart.dataSets,dataSetsHaveTitle:this.state.chart.dataSetsHaveTitle})}updateStacked(){this.updateChart({stackedBar:this.state.chart.stackedBar})}updateTitle(){this.updateChart({title:this.state.chart.title})}updateSelect(e,t){this.state.chart[e]=t.target.value,this.updateChart({[e]:t.target.value})}updateLabelRange(){this.state.labelsDispatchResult=this.updateChart({labelRange:this.state.chart.labelRange||null})}updateChart(e){return this.env.dispatch("UPDATE_CHART",{id:this.props.figure.id,sheetId:this.chartSheetId,definition:e})}onLabelRangeChanged(e){this.state.chart.labelRange=e.detail.ranges[0]}getKey(e){return e+this.props.figure.id}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}setColor(e){this.state.chart.background=e.detail.color,this.state.fillColorTool=!1,this.updateChart({background:this.state.chart.background})}activate(e){this.state.panel=e}initialState(e){const t=this.findSheetId(e.id);return{chart:this.env.getters.getChartDefinitionUI(t,e.id),panel:"configuration",fillColorTool:!1}}findSheetId(e){return this.env.getters.getFigureSheetId(e)||""}}function Oc(e,t){return!!t.target&&e.contains(t.target)}function Nc({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}_c.template=Mc,_c.style=Ac,_c.components={SelectionInput:Yl,ColorPicker:bl};const{useExternalListener:kc}=t.hooks,{xml:Fc,css:$c}=t.tags,Dc=Fc`
254
254
  <div class="o-cf-preview-line"
255
255
  t-attf-style="font-weight:{{currentStyle.bold ?'bold':'normal'}};
256
256
  text-decoration:{{getTextDecoration(currentStyle)}};
@@ -258,10 +258,10 @@
258
258
  color:{{currentStyle.textColor}};
259
259
  border-radius: 4px;
260
260
  background-color:{{currentStyle.fillColor}};"
261
- t-esc="previewText || env._t('${jl.PREVIEW_TEXT}')" />
262
- `,$c=Nc`
261
+ t-esc="previewText || env._t('${Xl.PREVIEW_TEXT}')" />
262
+ `,Uc=Fc`
263
263
  <div>
264
- <div class="o-cf-title-text" t-esc="env._t('${jl.IS_RULE}')"></div>
264
+ <div class="o-cf-title-text" t-esc="env._t('${Xl.IS_RULE}')"></div>
265
265
  <select t-model="state.condition.operator" class="o-input o-cell-is-operator">
266
266
  <t t-foreach="Object.keys(cellIsOperators)" t-as="op" t-key="op_index">
267
267
  <option t-att-value="op" t-esc="cellIsOperators[op]"/>
@@ -281,42 +281,42 @@
281
281
  class="o-input o-cell-is-value o-required"/>
282
282
  </t>
283
283
  </t>
284
- <div class="o-cf-title-text" t-esc="env._t('${jl.FORMATTING_STYLE}')"></div>
284
+ <div class="o-cf-title-text" t-esc="env._t('${Xl.FORMATTING_STYLE}')"></div>
285
285
 
286
- <t t-call="${Fc}">
286
+ <t t-call="${Dc}">
287
287
  <t t-set="currentStyle" t-value="state.style"/>
288
288
  </t>
289
289
  <div class="o-tools">
290
- <div class="o-tool" t-att-title="env._t('${jl.BOLD}')" t-att-class="{active:state.style.bold}" t-on-click="toggleTool('bold')">
291
- ${bl}
290
+ <div class="o-tool" t-att-title="env._t('${Xl.BOLD}')" t-att-class="{active:state.style.bold}" t-on-click="toggleTool('bold')">
291
+ ${Il}
292
292
  </div>
293
- <div class="o-tool" t-att-title="env._t('${jl.ITALIC}')" t-att-class="{active:state.style.italic}" t-on-click="toggleTool('italic')">
294
- ${Cl}
293
+ <div class="o-tool" t-att-title="env._t('${Xl.ITALIC}')" t-att-class="{active:state.style.italic}" t-on-click="toggleTool('italic')">
294
+ ${yl}
295
295
  </div>
296
- <div class="o-tool" t-att-title="env._t('${jl.UNDERLINE}')" t-att-class="{active:state.style.underline}"
296
+ <div class="o-tool" t-att-title="env._t('${Xl.UNDERLINE}')" t-att-class="{active:state.style.underline}"
297
297
  t-on-click="toggleTool('underline')">${'<svg class="o-icon"><path fill="#000000" d="M6,12 C8.76,12 11,9.76 11,7 L11,0 L9,0 L9,7 C9,8.75029916 7.49912807,10 6,10 C4.50087193,10 3,8.75837486 3,7 L3,0 L1,0 L1,7 C1,9.76 3.24,12 6,12 Z M0,13 L0,15 L12,15 L12,13 L0,13 Z" transform="translate(3 3)"/></svg>'}
298
298
  </div>
299
- <div class="o-tool" t-att-title="env._t('${jl.STRIKE_THROUGH}')" t-att-class="{active:state.style.strikethrough}"
300
- t-on-click="toggleTool('strikethrough')">${Il}
299
+ <div class="o-tool" t-att-title="env._t('${Xl.STRIKE_THROUGH}')" t-att-class="{active:state.style.strikethrough}"
300
+ t-on-click="toggleTool('strikethrough')">${wl}
301
301
  </div>
302
302
  <div class="o-tool o-dropdown o-with-color">
303
- <span t-att-title="env._t('${jl.TEXT_COLOR}')" t-attf-style="border-color:{{state.style.textColor}}"
303
+ <span t-att-title="env._t('${Xl.TEXT_COLOR}')" t-attf-style="border-color:{{state.style.textColor}}"
304
304
  t-on-click.stop="toggleMenu('textColorTool')">
305
- ${yl}
305
+ ${Tl}
306
306
  </span>
307
307
  <ColorPicker t-if="state.textColorTool" dropdownDirection="'center'" t-on-color-picked="setColor('textColor')" t-key="textColor"/>
308
308
  </div>
309
309
  <div class="o-divider"/>
310
310
  <div class="o-tool o-dropdown o-with-color">
311
- <span t-att-title="env._t('${jl.FILL_COLOR}')" t-attf-style="border-color:{{state.style.fillColor}}"
311
+ <span t-att-title="env._t('${Xl.FILL_COLOR}')" t-attf-style="border-color:{{state.style.fillColor}}"
312
312
  t-on-click.stop="toggleMenu('fillColorTool')">
313
- ${wl}
313
+ ${xl}
314
314
  </span>
315
315
  <ColorPicker t-if="state.fillColorTool" dropdownDirection="'center'" t-on-color-picked="setColor('fillColor')" t-key="fillColor"/>
316
316
  </div>
317
317
  </div>
318
318
  </div>
319
- `,Dc=kc`
319
+ `,Pc=$c`
320
320
  .o-cf-preview-line {
321
321
  border: 1px solid darkgrey;
322
322
  padding: 10px;
@@ -332,30 +332,30 @@
332
332
  .o-color-picker {
333
333
  pointer-events: all;
334
334
  }
335
- `;class Uc extends t.Component{constructor(){super(...arguments),this.cellIsOperators=ac,this.getTextDecoration=_c,this.state=t.useState({condition:{operator:this.props.rule&&this.props.rule.operator?this.props.rule.operator:"IsNotEmpty",value1:this.props.rule&&this.props.rule.values.length>0?this.props.rule.values[0]:"",value2:this.props.rule.values.length>1?this.props.rule.values[1]:""},textColorTool:!1,fillColorTool:!1,style:{fillColor:this.props.rule.style.fillColor,textColor:this.props.rule.style.textColor,bold:this.props.rule.style.bold,italic:this.props.rule.style.italic,strikethrough:this.props.rule.style.strikethrough,underline:this.props.rule.style.underline}}),Oc(window,"click",this.closeMenus)}get isValue1Invalid(){var e;return!!(null===(e=this.props.errors)||void 0===e?void 0:e.includes(36))}get isValue2Invalid(){var e;return!!(null===(e=this.props.errors)||void 0===e?void 0:e.includes(37))}getRule(){const e={},t=this.state.style;return void 0!==t.bold&&(e.bold=t.bold),void 0!==t.italic&&(e.italic=t.italic),void 0!==t.strikethrough&&(e.strikethrough=t.strikethrough),void 0!==t.underline&&(e.underline=t.underline),t.fillColor&&(e.fillColor=t.fillColor),t.textColor&&(e.textColor=t.textColor),{type:"CellIsRule",operator:this.state.condition.operator,values:[this.state.condition.value1,this.state.condition.value2],style:e}}toggleMenu(e){const t=this.state[e];this.closeMenus(),this.state[e]=!t}toggleTool(e){this.state.style[e]=!this.state.style[e],this.closeMenus()}setColor(e,t){const s=t.detail.color;this.state.style[e]=s,this.closeMenus()}closeMenus(){this.state.textColorTool=!1,this.state.fillColorTool=!1}static getDefaultRule(){return{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}}}}Uc.template=$c,Uc.style=Dc,Uc.components={ColorPicker:vl},Uc.defaultProps={errors:[]};const{useExternalListener:Pc}=t.hooks,{xml:Bc,css:Vc}=t.tags,Hc=Bc`
335
+ `;class Bc extends t.Component{constructor(){super(...arguments),this.cellIsOperators=cc,this.getTextDecoration=Nc,this.state=t.useState({condition:{operator:this.props.rule&&this.props.rule.operator?this.props.rule.operator:"IsNotEmpty",value1:this.props.rule&&this.props.rule.values.length>0?this.props.rule.values[0]:"",value2:this.props.rule.values.length>1?this.props.rule.values[1]:""},textColorTool:!1,fillColorTool:!1,style:{fillColor:this.props.rule.style.fillColor,textColor:this.props.rule.style.textColor,bold:this.props.rule.style.bold,italic:this.props.rule.style.italic,strikethrough:this.props.rule.style.strikethrough,underline:this.props.rule.style.underline}}),kc(window,"click",this.closeMenus)}get isValue1Invalid(){var e;return!!(null===(e=this.props.errors)||void 0===e?void 0:e.includes(36))}get isValue2Invalid(){var e;return!!(null===(e=this.props.errors)||void 0===e?void 0:e.includes(37))}getRule(){const e={},t=this.state.style;return void 0!==t.bold&&(e.bold=t.bold),void 0!==t.italic&&(e.italic=t.italic),void 0!==t.strikethrough&&(e.strikethrough=t.strikethrough),void 0!==t.underline&&(e.underline=t.underline),t.fillColor&&(e.fillColor=t.fillColor),t.textColor&&(e.textColor=t.textColor),{type:"CellIsRule",operator:this.state.condition.operator,values:[this.state.condition.value1,this.state.condition.value2],style:e}}toggleMenu(e){const t=this.state[e];this.closeMenus(),this.state[e]=!t}toggleTool(e){this.state.style[e]=!this.state.style[e],this.closeMenus()}setColor(e,t){const s=t.detail.color;this.state.style[e]=s,this.closeMenus()}closeMenus(){this.state.textColorTool=!1,this.state.fillColorTool=!1}static getDefaultRule(){return{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}}}}Bc.template=Uc,Bc.style=Pc,Bc.components={ColorPicker:bl},Bc.defaultProps={errors:[]};const{useExternalListener:Vc}=t.hooks,{xml:Hc,css:zc}=t.tags,Zc=Hc`
336
336
  <div class="o-cf-preview-gradient" t-attf-style="{{getPreviewGradient()}}">
337
- <t t-esc="env._t('${jl.PREVIEW_TEXT}')"/>
337
+ <t t-esc="env._t('${Xl.PREVIEW_TEXT}')"/>
338
338
  </div>
339
- `,zc=Bc`
339
+ `,Gc=Hc`
340
340
  <div t-attf-class="o-threshold o-threshold-{{thresholdType}}">
341
341
  <select class="o-input" name="valueType" t-model="threshold.type" t-on-click="closeMenus">
342
342
  <option value="value" t-if="thresholdType!=='midpoint'">
343
- <t t-esc="env._t('${Yl}')"/>
343
+ <t t-esc="env._t('${Kl}')"/>
344
344
  </option>
345
345
  <option value="none" t-if="thresholdType==='midpoint'">
346
- <t t-esc="env._t('${Xl}')"/>
346
+ <t t-esc="env._t('${Ql}')"/>
347
347
  </option>
348
348
  <option value="number">
349
- <t t-esc="env._t('${jl.FixedNumber}')"/>
349
+ <t t-esc="env._t('${Xl.FixedNumber}')"/>
350
350
  </option>
351
351
  <option value="percentage">
352
- <t t-esc="env._t('${jl.Percentage}')"/>
352
+ <t t-esc="env._t('${Xl.Percentage}')"/>
353
353
  </option>
354
354
  <option value="percentile">
355
- <t t-esc="env._t('${jl.Percentile}')"/>
355
+ <t t-esc="env._t('${Xl.Percentile}')"/>
356
356
  </option>
357
357
  <option value="formula">
358
- <t t-esc="env._t('${jl.Formula}')"/>
358
+ <t t-esc="env._t('${Xl.Formula}')"/>
359
359
  </option>
360
360
  </select>
361
361
  <input type="text" class="o-input o-threshold-value o-required"
@@ -369,38 +369,38 @@
369
369
  <div class="o-tools">
370
370
  <div class="o-tool o-dropdown o-with-color">
371
371
  <span title="Fill Color" t-attf-style="border-color:#{{colorNumberString(threshold.color)}}"
372
- t-on-click.stop="toggleMenu(thresholdType+'ColorTool')">${wl}</span>
372
+ t-on-click.stop="toggleMenu(thresholdType+'ColorTool')">${xl}</span>
373
373
  <ColorPicker t-if="stateColorScale[thresholdType+'ColorTool']" dropdownDirection="'left'" t-on-color-picked="setColor(thresholdType)"/>
374
374
  </div>
375
375
  </div>
376
- </div>`,Zc=Bc`
376
+ </div>`,Wc=Hc`
377
377
  <div>
378
378
  <div class="o-cf-title-text">
379
- <t t-esc="env._t('${Kl}')"/>
379
+ <t t-esc="env._t('${Jl}')"/>
380
380
  </div>
381
- <t t-call="${Hc}"/>
381
+ <t t-call="${Zc}"/>
382
382
  <div class="o-cf-title-text">
383
- <t t-esc="env._t('${Ql}')"/>
383
+ <t t-esc="env._t('${ec}')"/>
384
384
  </div>
385
- <t t-call="${zc}">
385
+ <t t-call="${Gc}">
386
386
  <t t-set="threshold" t-value="stateColorScale.minimum" ></t>
387
387
  <t t-set="thresholdType" t-value="'minimum'" ></t>
388
388
  </t>
389
389
  <div class="o-cf-title-text">
390
- <t t-esc="env._t('${ec}')"/>
390
+ <t t-esc="env._t('${sc}')"/>
391
391
  </div>
392
- <t t-call="${zc}">
392
+ <t t-call="${Gc}">
393
393
  <t t-set="threshold" t-value="stateColorScale.midpoint" ></t>
394
394
  <t t-set="thresholdType" t-value="'midpoint'" ></t>
395
395
  </t>
396
396
  <div class="o-cf-title-text">
397
- <t t-esc="env._t('${Jl}')"/>
397
+ <t t-esc="env._t('${tc}')"/>
398
398
  </div>
399
- <t t-call="${zc}">
399
+ <t t-call="${Gc}">
400
400
  <t t-set="threshold" t-value="stateColorScale.maximum" ></t>
401
401
  <t t-set="thresholdType" t-value="'maximum'" ></t>
402
402
  </t>
403
- </div>`,Gc=Vc`
403
+ </div>`,qc=zc`
404
404
  .o-threshold {
405
405
  display: flex;
406
406
  flex-direction: horizontal;
@@ -421,7 +421,7 @@
421
421
  padding: 10px;
422
422
  border-radius: 4px;
423
423
  }
424
- `;class Wc extends t.Component{constructor(){super(...arguments),this.colorNumberString=jt,this.stateColorScale=t.useState({minimum:this.props.rule.minimum,maximum:this.props.rule.maximum,midpoint:this.props.rule.midpoint?this.props.rule.midpoint:{color:11982760,type:"none"},maximumColorTool:!1,minimumColorTool:!1,midpointColorTool:!1}),Pc(window,"click",this.closeMenus)}getRule(){const e={...this.stateColorScale.minimum},t={...this.stateColorScale.midpoint};return{type:"ColorScaleRule",minimum:e,maximum:{...this.stateColorScale.maximum},midpoint:"none"===t.type?void 0:t}}toggleMenu(e){const t=this.stateColorScale[e];this.closeMenus(),this.stateColorScale[e]=!t}setColor(e,t){const s=t.detail.color;this.stateColorScale[e].color=Number.parseInt(s.substr(1),16),this.closeMenus()}getPreviewGradient(){const e=jt(this.stateColorScale.minimum.color),t=jt(this.stateColorScale.midpoint.color),s=jt(this.stateColorScale.maximum.color),i="background-image: linear-gradient(to right, #";return"none"===this.stateColorScale.midpoint.type?i+e+", #"+s+")":i+e+", #"+t+", #"+s+")"}isValueInvalid(e){switch(e){case"minimum":return this.props.errors.includes(43)||this.props.errors.includes(35)||this.props.errors.includes(32)||this.props.errors.includes(38);case"midpoint":return this.props.errors.includes(44)||this.props.errors.includes(39)||this.props.errors.includes(34);case"maximum":return this.props.errors.includes(45)||this.props.errors.includes(40);default:return!1}}closeMenus(){this.stateColorScale.minimumColorTool=!1,this.stateColorScale.midpointColorTool=!1,this.stateColorScale.maximumColorTool=!1}static getDefaultRule(){return{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}}}}Wc.template=Zc,Wc.style=Gc,Wc.components={ColorPicker:vl},Wc.defaultProps={errors:[]};const{css:qc,xml:jc}=t.tags;class Yc extends t.Component{constructor(){super(...arguments),this.icons=Bl,this.iconSets=Vl}onIconClick(e){e&&this.trigger("icon-picked",{icon:e})}}Yc.template=jc`
424
+ `;class jc extends t.Component{constructor(){super(...arguments),this.colorNumberString=jt,this.stateColorScale=t.useState({minimum:this.props.rule.minimum,maximum:this.props.rule.maximum,midpoint:this.props.rule.midpoint?this.props.rule.midpoint:{color:11982760,type:"none"},maximumColorTool:!1,minimumColorTool:!1,midpointColorTool:!1}),Vc(window,"click",this.closeMenus)}getRule(){const e={...this.stateColorScale.minimum},t={...this.stateColorScale.midpoint};return{type:"ColorScaleRule",minimum:e,maximum:{...this.stateColorScale.maximum},midpoint:"none"===t.type?void 0:t}}toggleMenu(e){const t=this.stateColorScale[e];this.closeMenus(),this.stateColorScale[e]=!t}setColor(e,t){const s=t.detail.color;this.stateColorScale[e].color=Number.parseInt(s.substr(1),16),this.closeMenus()}getPreviewGradient(){const e=jt(this.stateColorScale.minimum.color),t=jt(this.stateColorScale.midpoint.color),s=jt(this.stateColorScale.maximum.color),i="background-image: linear-gradient(to right, #";return"none"===this.stateColorScale.midpoint.type?i+e+", #"+s+")":i+e+", #"+t+", #"+s+")"}isValueInvalid(e){switch(e){case"minimum":return this.props.errors.includes(43)||this.props.errors.includes(35)||this.props.errors.includes(32)||this.props.errors.includes(38);case"midpoint":return this.props.errors.includes(44)||this.props.errors.includes(39)||this.props.errors.includes(34);case"maximum":return this.props.errors.includes(45)||this.props.errors.includes(40);default:return!1}}closeMenus(){this.stateColorScale.minimumColorTool=!1,this.stateColorScale.midpointColorTool=!1,this.stateColorScale.maximumColorTool=!1}static getDefaultRule(){return{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}}}}jc.template=Wc,jc.style=qc,jc.components={ColorPicker:bl},jc.defaultProps={errors:[]};const{css:Yc,xml:Xc}=t.tags;class Kc extends t.Component{constructor(){super(...arguments),this.icons=Hl,this.iconSets=zl}onIconClick(e){e&&this.trigger("icon-picked",{icon:e})}}Kc.template=Xc`
425
425
  <div class="o-icon-picker" >
426
426
  <t t-foreach="iconSets" t-as="iconSet" t-key="iconset">
427
427
  <div class="o-cf-icon-line">
@@ -436,7 +436,7 @@
436
436
  </div>
437
437
  </div>
438
438
  </t>
439
- </div>`,Yc.style=qc`
439
+ </div>`,Kc.style=Yc`
440
440
  .o-icon-picker {
441
441
  position: absolute;
442
442
  z-index: 10;
@@ -455,10 +455,10 @@
455
455
  outline: 1px solid gray;
456
456
  }
457
457
  }
458
- `;const{useExternalListener:Xc}=t.hooks,{xml:Kc,css:Qc}=t.tags,Jc=Kc`
458
+ `;const{useExternalListener:Qc}=t.hooks,{xml:Jc,css:eh}=t.tags,th=Jc`
459
459
  <div>
460
460
  <div class="o-cf-title-text">
461
- <t t-esc="env._t('${oc}')"/>
461
+ <t t-esc="env._t('${rc}')"/>
462
462
  </div>
463
463
  <div class="o-cf-iconsets">
464
464
  <div class="o-cf-iconset" t-foreach="['arrows', 'smiley', 'dots']" t-as="iconSet" t-on-click="setIconSet(iconSet)">
@@ -474,7 +474,7 @@
474
474
  </div>
475
475
  </div>
476
476
  </div>
477
- `,eh=Kc`
477
+ `,sh=Jc`
478
478
  <tr>
479
479
  <td>
480
480
  <div t-on-click.stop="toggleMenu(icon+'IconTool')">
@@ -485,7 +485,7 @@
485
485
  <IconPicker t-if="stateIconSetCF[icon+'IconTool']" t-on-icon-picked="setIcon(icon)"/>
486
486
  </td>
487
487
  <td>
488
- <t t-esc="env._t('${tc}')"/>
488
+ <t t-esc="env._t('${ic}')"/>
489
489
  </td>
490
490
  <td>
491
491
  <select class="o-input" name="valueType" t-model="inflectionPointValue.operator">
@@ -506,24 +506,24 @@
506
506
  <td>
507
507
  <select class="o-input" name="valueType" t-model="inflectionPointValue.type">
508
508
  <option value="number">
509
- <t t-esc="env._t('${jl.FixedNumber}')"/>
509
+ <t t-esc="env._t('${Xl.FixedNumber}')"/>
510
510
  </option>
511
511
  <option value="percentage">
512
- <t t-esc="env._t('${jl.Percentage}')"/>
512
+ <t t-esc="env._t('${Xl.Percentage}')"/>
513
513
  </option>
514
514
  <option value="percentile">
515
- <t t-esc="env._t('${jl.Percentile}')"/>
515
+ <t t-esc="env._t('${Xl.Percentile}')"/>
516
516
  </option>
517
517
  <option value="formula">
518
- <t t-esc="env._t('${jl.Formula}')"/>
518
+ <t t-esc="env._t('${Xl.Formula}')"/>
519
519
  </option>
520
520
  </select>
521
521
  </td>
522
522
  </tr>
523
- `,th=Kc`
523
+ `,ih=Jc`
524
524
  <div class="o-cf-iconset-rule">
525
- <t t-call="${Jc}"/>
526
- <t t-call="${Kc`
525
+ <t t-call="${th}"/>
526
+ <t t-call="${Jc`
527
527
  <div class="o-inflection">
528
528
  <table>
529
529
  <tr>
@@ -531,19 +531,19 @@
531
531
  <th class="o-cf-iconset-text"></th>
532
532
  <th class="o-cf-iconset-operator"></th>
533
533
  <th class="o-cf-iconset-value">
534
- <t t-esc="env._t('${rc}')"/>
534
+ <t t-esc="env._t('${lc}')"/>
535
535
  </th>
536
536
  <th class="o-cf-iconset-type">
537
- <t t-esc="env._t('${nc}')"/>
537
+ <t t-esc="env._t('${ac}')"/>
538
538
  </th>
539
539
  </tr>
540
- <t t-call="${eh}">
540
+ <t t-call="${sh}">
541
541
  <t t-set="iconValue" t-value="stateIconSetCF.upperIcon" ></t>
542
542
  <t t-set="icon" t-value="'upper'" ></t>
543
543
  <t t-set="inflectionPointValue" t-value="stateIconSetCF.upperInflectionPoint" ></t>
544
544
  <t t-set="inflectionPoint" t-value="'upperInflectionPoint'" ></t>
545
545
  </t>
546
- <t t-call="${eh}">
546
+ <t t-call="${sh}">
547
547
  <t t-set="iconValue" t-value="stateIconSetCF.middleIcon" ></t>
548
548
  <t t-set="icon" t-value="'middle'" ></t>
549
549
  <t t-set="inflectionPointValue" t-value="stateIconSetCF.lowerInflectionPoint" ></t>
@@ -558,7 +558,7 @@
558
558
  </div>
559
559
  <IconPicker t-if="stateIconSetCF['lowerIconTool']" t-on-icon-picked="setIcon('lower')"/>
560
560
  </td>
561
- <td><t t-esc="env._t('${sc}')"/></td>
561
+ <td><t t-esc="env._t('${oc}')"/></td>
562
562
  <td></td>
563
563
  <td></td>
564
564
  <td></td>
@@ -569,9 +569,9 @@
569
569
  <div class="mr-1 d-inline-block">
570
570
  <t t-raw="reverseIcon"/>
571
571
  </div>
572
- <t t-esc="env._t('${ic}')"/>
572
+ <t t-esc="env._t('${nc}')"/>
573
573
  </div>
574
- </div>`,sh=Qc`
574
+ </div>`,oh=eh`
575
575
  .o-cf-iconset-rule {
576
576
  font-size: 12;
577
577
  .o-cf-iconsets {
@@ -650,12 +650,12 @@
650
650
  }
651
651
  }
652
652
  }
653
- `;class ih extends t.Component{constructor(){super(...arguments),this.icons=Bl,this.iconSets=Vl,this.reverseIcon='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon refresh" viewBox="0 0 512 512"><path fill="currentColor" d="M440.65 12.57l4 82.77A247.16 247.16 0 0 0 255.83 8C134.73 8 33.91 94.92 12.29 209.82A12 12 0 0 0 24.09 224h49.05a12 12 0 0 0 11.67-9.26 175.91 175.91 0 0 1 317-56.94l-101.46-4.86a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12H500a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12h-47.37a12 12 0 0 0-11.98 12.57zM255.83 432a175.61 175.61 0 0 1-146-77.8l101.8 4.87a12 12 0 0 0 12.57-12v-47.4a12 12 0 0 0-12-12H12a12 12 0 0 0-12 12V500a12 12 0 0 0 12 12h47.35a12 12 0 0 0 12-12.6l-4.15-82.57A247.17 247.17 0 0 0 255.83 504c121.11 0 221.93-86.92 243.55-201.82a12 12 0 0 0-11.8-14.18h-49.05a12 12 0 0 0-11.67 9.26A175.86 175.86 0 0 1 255.83 432z"></path></svg>',this.stateIconSetCF=t.useState({reversed:!1,upperInflectionPoint:this.props.rule.upperInflectionPoint,lowerInflectionPoint:this.props.rule.lowerInflectionPoint,upperIcon:this.props.rule.icons.upper,middleIcon:this.props.rule.icons.middle,lowerIcon:this.props.rule.icons.lower,upperIconTool:!1,middleIconTool:!1,lowerIconTool:!1}),Xc(window,"click",this.closeMenus)}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.props.errors.includes(42)||this.props.errors.includes(47)||this.props.errors.includes(33);case"upperInflectionPoint":return this.props.errors.includes(41)||this.props.errors.includes(46)||this.props.errors.includes(33);default:return!0}}toggleMenu(e){const t=this.stateIconSetCF[e];this.closeMenus(),this.stateIconSetCF[e]=!t}closeMenus(){this.stateIconSetCF.upperIconTool=!1,this.stateIconSetCF.middleIconTool=!1,this.stateIconSetCF.lowerIconTool=!1}setIconSet(e){this.stateIconSetCF.upperIcon=this.iconSets[e].good,this.stateIconSetCF.middleIcon=this.iconSets[e].neutral,this.stateIconSetCF.lowerIcon=this.iconSets[e].bad}setIcon(e,t){this.stateIconSetCF[e+"Icon"]=t.detail.icon}getRule(){const e={...this.stateIconSetCF.upperInflectionPoint};return{type:"IconSetRule",lowerInflectionPoint:{...this.stateIconSetCF.lowerInflectionPoint},upperInflectionPoint:e,icons:{upper:this.stateIconSetCF.upperIcon,middle:this.stateIconSetCF.middleIcon,lower:this.stateIconSetCF.lowerIcon}}}getIconsSelction(){return Object.keys(this.icons)}reverseIcons(){const e=this.stateIconSetCF.upperIcon;this.stateIconSetCF.upperIcon=this.stateIconSetCF.lowerIcon,this.stateIconSetCF.lowerIcon=e}static getDefaultRule(){return{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}ih.template=th,ih.style=sh,ih.components={IconPicker:Yc};const{xml:oh,css:nh}=t.tags,{useRef:rh}=t.hooks,ah=oh`
653
+ `;class nh extends t.Component{constructor(){super(...arguments),this.icons=Hl,this.iconSets=zl,this.reverseIcon='<svg xmlns="http://www.w3.org/2000/svg" class="o-cf-icon refresh" viewBox="0 0 512 512"><path fill="currentColor" d="M440.65 12.57l4 82.77A247.16 247.16 0 0 0 255.83 8C134.73 8 33.91 94.92 12.29 209.82A12 12 0 0 0 24.09 224h49.05a12 12 0 0 0 11.67-9.26 175.91 175.91 0 0 1 317-56.94l-101.46-4.86a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12H500a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12h-47.37a12 12 0 0 0-11.98 12.57zM255.83 432a175.61 175.61 0 0 1-146-77.8l101.8 4.87a12 12 0 0 0 12.57-12v-47.4a12 12 0 0 0-12-12H12a12 12 0 0 0-12 12V500a12 12 0 0 0 12 12h47.35a12 12 0 0 0 12-12.6l-4.15-82.57A247.17 247.17 0 0 0 255.83 504c121.11 0 221.93-86.92 243.55-201.82a12 12 0 0 0-11.8-14.18h-49.05a12 12 0 0 0-11.67 9.26A175.86 175.86 0 0 1 255.83 432z"></path></svg>',this.stateIconSetCF=t.useState({reversed:!1,upperInflectionPoint:this.props.rule.upperInflectionPoint,lowerInflectionPoint:this.props.rule.lowerInflectionPoint,upperIcon:this.props.rule.icons.upper,middleIcon:this.props.rule.icons.middle,lowerIcon:this.props.rule.icons.lower,upperIconTool:!1,middleIconTool:!1,lowerIconTool:!1}),Qc(window,"click",this.closeMenus)}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.props.errors.includes(42)||this.props.errors.includes(47)||this.props.errors.includes(33);case"upperInflectionPoint":return this.props.errors.includes(41)||this.props.errors.includes(46)||this.props.errors.includes(33);default:return!0}}toggleMenu(e){const t=this.stateIconSetCF[e];this.closeMenus(),this.stateIconSetCF[e]=!t}closeMenus(){this.stateIconSetCF.upperIconTool=!1,this.stateIconSetCF.middleIconTool=!1,this.stateIconSetCF.lowerIconTool=!1}setIconSet(e){this.stateIconSetCF.upperIcon=this.iconSets[e].good,this.stateIconSetCF.middleIcon=this.iconSets[e].neutral,this.stateIconSetCF.lowerIcon=this.iconSets[e].bad}setIcon(e,t){this.stateIconSetCF[e+"Icon"]=t.detail.icon}getRule(){const e={...this.stateIconSetCF.upperInflectionPoint};return{type:"IconSetRule",lowerInflectionPoint:{...this.stateIconSetCF.lowerInflectionPoint},upperInflectionPoint:e,icons:{upper:this.stateIconSetCF.upperIcon,middle:this.stateIconSetCF.middleIcon,lower:this.stateIconSetCF.lowerIcon}}}getIconsSelction(){return Object.keys(this.icons)}reverseIcons(){const e=this.stateIconSetCF.upperIcon;this.stateIconSetCF.upperIcon=this.stateIconSetCF.lowerIcon,this.stateIconSetCF.lowerIcon=e}static getDefaultRule(){return{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}nh.template=ih,nh.style=oh,nh.components={IconPicker:Kc};const{xml:rh,css:ah}=t.tags,{useRef:lh}=t.hooks,ch=rh`
654
654
  <div class="o-cf">
655
655
  <t t-if="state.mode === 'list'">
656
656
  <div class="o-cf-preview-list" >
657
657
  <div t-on-click="editConditionalFormat(cf)" t-foreach="conditionalFormats" t-as="cf" t-key="cf.id">
658
- <t t-call="${oh`
658
+ <t t-call="${rh`
659
659
  <div class="o-cf-preview">
660
660
  <t t-if="cf.rule.type==='IconSetRule'">
661
661
  <div class="o-cf-preview-icon">
@@ -678,7 +678,7 @@
678
678
  <t t-if="cf.rule.values">
679
679
  <t t-esc="cf.rule.values[0]" />
680
680
  <t t-if="cf.rule.values[1]">
681
- <t t-esc="' ' + env._t('${wc}')"/> <t t-esc="cf.rule.values[1]"/>
681
+ <t t-esc="' ' + env._t('${xc}')"/> <t t-esc="cf.rule.values[1]"/>
682
682
  </t>
683
683
  </t>
684
684
  </div>
@@ -694,7 +694,7 @@
694
694
  </div>
695
695
  </div>
696
696
  <div class="btn btn-link o-cf-add" t-on-click.prevent.stop="addConditionalFormat">
697
- <t t-esc="'+ ' + env._t('${jl.newRule}')"/>
697
+ <t t-esc="'+ ' + env._t('${Xl.newRule}')"/>
698
698
  </div>
699
699
  </t>
700
700
  <t t-if="state.mode === 'edit' || state.mode === 'add'" t-key="state.currentCF.id">
@@ -709,25 +709,25 @@
709
709
  t-on-selection-changed="onRangesChanged"
710
710
  required="true"/>
711
711
  </div>
712
- <div class="o-section-title" t-esc="env._t('${jl.CF_TITLE}')"></div>
712
+ <div class="o-section-title" t-esc="env._t('${Xl.CF_TITLE}')"></div>
713
713
  <div class="o_field_radio o_horizontal o_field_widget o-cf-type-selector">
714
714
  <div class="custom-control custom-radio o_cf_radio_item" t-on-click="changeRuleType('CellIsRule')">
715
715
  <input class="custom-control-input o_radio_input" t-att-checked="state.currentCFType === 'CellIsRule'" type="radio" id="cellIsRule" name="ruleType" value="CellIsRule"/>
716
716
  <label for="cellIsRule" class="custom-control-label o_form_label">
717
- <t t-esc="env._t('${jl.SingleColor}')"/>
717
+ <t t-esc="env._t('${Xl.SingleColor}')"/>
718
718
  </label>
719
719
  </div>
720
720
  <div class="custom-control custom-radio o_cf_radio_item" t-on-click="changeRuleType('ColorScaleRule')">
721
721
  <input class="custom-control-input o_radio_input" t-att-checked="state.currentCFType === 'ColorScaleRule'" type="radio" id="colorScaleRule" name="ruleType" value="ColorScaleRule"/>
722
722
  <label for="colorScaleRule" class="custom-control-label o_form_label">
723
- <t t-esc="env._t('${jl.ColorScale}')"/>
723
+ <t t-esc="env._t('${Xl.ColorScale}')"/>
724
724
  </label>
725
725
  </div>
726
726
 
727
727
  <div class="custom-control custom-radio o_cf_radio_item" t-on-click="changeRuleType('IconSetRule')">
728
728
  <input class="custom-control-input o_radio_input" t-att-checked="state.currentCFType === 'IconSetRule'" type="radio" id="iconSetRule" name="ruleType" value="IconSetRule"/>
729
729
  <label for="iconSetRule" class="custom-control-label o_form_label">
730
- <t t-esc="env._t('${jl.IconSet}')"/>
730
+ <t t-esc="env._t('${Xl.IconSet}')"/>
731
731
  </label>
732
732
  </div>
733
733
  </div>
@@ -739,8 +739,8 @@
739
739
  t-key="state.currentCF.id + state.currentCFType"
740
740
  rule="state.rules[state.currentCFType]"/>
741
741
  <div class="o-sidePanelButtons">
742
- <button t-on-click="switchToList" class="o-sidePanelButton o-cf-cancel" t-esc="env._t('${jl.CANCEL}')"></button>
743
- <button t-on-click="saveConditionalFormat" class="o-sidePanelButton o-cf-save" t-esc="env._t('${jl.SAVE}')"></button>
742
+ <button t-on-click="switchToList" class="o-sidePanelButton o-cf-cancel" t-esc="env._t('${Xl.CANCEL}')"></button>
743
+ <button t-on-click="saveConditionalFormat" class="o-sidePanelButton o-cf-save" t-esc="env._t('${Xl.SAVE}')"></button>
744
744
  </div>
745
745
  </div>
746
746
  <div class="o-section">
@@ -750,7 +750,7 @@
750
750
  </div>
751
751
  </div>
752
752
  </t>
753
- </div>`,lh=nh`
753
+ </div>`,hh=ah`
754
754
  label {
755
755
  vertical-align: middle;
756
756
  }
@@ -942,10 +942,10 @@
942
942
  margin-top: 10px;
943
943
  }
944
944
  }
945
- `;class ch extends t.Component{constructor(e,s){super(e,s),this.icons=Bl,this.trashIcon='<svg xmlns ="http://www.w3.org/2000/svg" class="o-cf-icon trash" viewBox = "0 0 448 512" > <path fill="currentColor" d = "M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z" > </path></svg >',this.cellIsOperators=ac,this.editor=rh("editorRef"),this.getters=this.env.getters,this.state=t.useState({mode:"list",rules:{},errors:[]}),this.editors={CellIsRule:Uc,ColorScaleRule:Wc,IconSetRule:ih},this.activeSheetId=this.getters.getActiveSheetId();const i=this.getters.getRulesSelection(this.activeSheetId,s.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}}get conditionalFormats(){return this.getters.getConditionalFormats(this.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(21)}errorMessage(e){return this.env._t(jl.Errors[e]||jl.Errors.unexpected)}async willUpdateProps(e){const t=this.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.getters.getActiveSheetId(),s=this.getters.getRulesSelection(t,e.selection||[]);if(1===s.length){const e=this.conditionalFormats.find((e=>e.id===s[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules={}}getStyle(e){if("CellIsRule"===e.type){return`font-weight:${e.style.bold?"bold":"normal"};\n text-decoration:${_c(e.style)};\n font-style:${e.style.italic?"italic":"normal"};\n color:${e.style.textColor||"none"};\n background-color:${e.style.fillColor||"none"};`}if("ColorScaleRule"===e.type){const t=jt(e.minimum.color),s=e.midpoint?jt(e.midpoint.color):null,i=jt(e.maximum.color),o="background-image: linear-gradient(to right, #";return s?o+t+", #"+s+", #"+i+")":o+t+", #"+i+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":return ac[e.rule.operator];case"ColorScaleRule":return this.env._t("Color scale");case"IconSetRule":return this.env._t("Icon Set");default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Jt))))return void(this.state.errors=[22]);const e=this.env.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.uuidGenerator.uuidv4()},target:this.state.currentCF.ranges.map(Os),sheetId:this.getters.getActiveSheetId()});e.isSuccessful?this.switchToList():this.state.errors=e.reasons}}getEditorRule(){return this.editor.comp.getRule()}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.rules.CellIsRule=Uc.getDefaultRule(),this.state.currentCF={id:this.env.uuidGenerator.uuidv4(),ranges:this.getters.getSelectedZones().map((e=>this.getters.zoneToXC(this.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.getters.getActiveSheetId()})}editConditionalFormat(e){this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType="CellIsRule"===e.rule.type?"CellIsRule":"ColorScaleRule"===e.rule.type?"ColorScaleRule":"IconSetRule",this.state.rules[e.rule.type]=e.rule}changeRuleType(e){if(this.state.currentCFType!==e&&(this.state.currentCFType&&(this.state.rules[this.state.currentCFType]=this.getEditorRule()),this.state.errors=[],this.state.currentCFType=e,!(e in this.state.rules)))switch(e){case"CellIsRule":this.state.rules.CellIsRule=Uc.getDefaultRule();break;case"ColorScaleRule":this.state.rules.ColorScaleRule=Wc.getDefaultRule();break;case"IconSetRule":this.state.rules.IconSetRule=ih.getDefaultRule()}}onRangesChanged({detail:e}){this.state.currentCF&&(this.state.currentCF.ranges=e.ranges)}}ch.template=ah,ch.style=lh,ch.components={CellIsRuleEditor:Uc,ColorScaleRuleEditor:Wc,IconSetRuleEditor:ih,SelectionInput:ql};const{xml:hh,css:dh}=t.tags,uh=hh`
945
+ `;class dh extends t.Component{constructor(e,s){super(e,s),this.icons=Hl,this.trashIcon='<svg xmlns ="http://www.w3.org/2000/svg" class="o-cf-icon trash" viewBox = "0 0 448 512" > <path fill="currentColor" d = "M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z" > </path></svg >',this.cellIsOperators=cc,this.editor=lh("editorRef"),this.getters=this.env.getters,this.state=t.useState({mode:"list",rules:{},errors:[]}),this.editors={CellIsRule:Bc,ColorScaleRule:jc,IconSetRule:nh},this.activeSheetId=this.getters.getActiveSheetId();const i=this.getters.getRulesSelection(this.activeSheetId,s.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}}get conditionalFormats(){return this.getters.getConditionalFormats(this.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(21)}errorMessage(e){return this.env._t(Xl.Errors[e]||Xl.Errors.unexpected)}async willUpdateProps(e){const t=this.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.getters.getActiveSheetId(),s=this.getters.getRulesSelection(t,e.selection||[]);if(1===s.length){const e=this.conditionalFormats.find((e=>e.id===s[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules={}}getStyle(e){if("CellIsRule"===e.type){return`font-weight:${e.style.bold?"bold":"normal"};\n text-decoration:${Nc(e.style)};\n font-style:${e.style.italic?"italic":"normal"};\n color:${e.style.textColor||"none"};\n background-color:${e.style.fillColor||"none"};`}if("ColorScaleRule"===e.type){const t=jt(e.minimum.color),s=e.midpoint?jt(e.midpoint.color):null,i=jt(e.maximum.color),o="background-image: linear-gradient(to right, #";return s?o+t+", #"+s+", #"+i+")":o+t+", #"+i+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":return cc[e.rule.operator];case"ColorScaleRule":return this.env._t("Color scale");case"IconSetRule":return this.env._t("Icon Set");default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Jt))))return void(this.state.errors=[22]);const e=this.env.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.uuidGenerator.uuidv4()},target:this.state.currentCF.ranges.map(ks),sheetId:this.getters.getActiveSheetId()});e.isSuccessful?this.switchToList():this.state.errors=e.reasons}}getEditorRule(){return this.editor.comp.getRule()}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.rules.CellIsRule=Bc.getDefaultRule(),this.state.currentCF={id:this.env.uuidGenerator.uuidv4(),ranges:this.getters.getSelectedZones().map((e=>this.getters.zoneToXC(this.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.getters.getActiveSheetId()})}editConditionalFormat(e){this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType="CellIsRule"===e.rule.type?"CellIsRule":"ColorScaleRule"===e.rule.type?"ColorScaleRule":"IconSetRule",this.state.rules[e.rule.type]=e.rule}changeRuleType(e){if(this.state.currentCFType!==e&&(this.state.currentCFType&&(this.state.rules[this.state.currentCFType]=this.getEditorRule()),this.state.errors=[],this.state.currentCFType=e,!(e in this.state.rules)))switch(e){case"CellIsRule":this.state.rules.CellIsRule=Bc.getDefaultRule();break;case"ColorScaleRule":this.state.rules.ColorScaleRule=jc.getDefaultRule();break;case"IconSetRule":this.state.rules.IconSetRule=nh.getDefaultRule()}}onRangesChanged({detail:e}){this.state.currentCF&&(this.state.currentCF.ranges=e.ranges)}}dh.template=ch,dh.style=hh,dh.components={CellIsRuleEditor:Bc,ColorScaleRuleEditor:jc,IconSetRuleEditor:nh,SelectionInput:Yl};const{xml:uh,css:ph}=t.tags,gh=uh`
946
946
  <div class="o-find-and-replace" tabindex="0" t-on-focusin="onFocusSidePanel">
947
947
  <div class="o-section">
948
- <div class="o-section-title" t-esc="env._t('${cc}')"/>
948
+ <div class="o-section-title" t-esc="env._t('${dc}')"/>
949
949
  <div class="o-input-search-container">
950
950
  <input type="text" class="o-input o-input-with-count" t-on-input="onInput" t-on-keydown="onKeydownSearch"/>
951
951
  <div class="o-input-count" t-if="hasSearchResult">
@@ -958,19 +958,19 @@
958
958
  <div class="o-far-item">
959
959
  <label class="o-far-checkbox">
960
960
  <input t-model="state.searchOptions.matchCase" t-on-change="updateSearch()" class="o-far-input" type="checkbox"/>
961
- <span class="o-far-label"><t t-esc="env._t('${pc}')"/></span>
961
+ <span class="o-far-label"><t t-esc="env._t('${fc}')"/></span>
962
962
  </label>
963
963
  </div>
964
964
  <div class="o-far-item">
965
965
  <label class="o-far-checkbox">
966
966
  <input t-model="state.searchOptions.exactMatch" t-on-change="updateSearch()" class="o-far-input" type="checkbox"/>
967
- <span class="o-far-label"><t t-esc="env._t('${gc}')"/></span>
967
+ <span class="o-far-label"><t t-esc="env._t('${mc}')"/></span>
968
968
  </label>
969
969
  </div>
970
970
  <div class="o-far-item">
971
971
  <label class="o-far-checkbox">
972
972
  <input t-model="state.searchOptions.searchFormulas" t-on-change="searchFormulas" class="o-far-input" type="checkbox" />
973
- <span class="o-far-label"><t t-esc="env._t('${fc}')"/></span>
973
+ <span class="o-far-label"><t t-esc="env._t('${vc}')"/></span>
974
974
  </label>
975
975
  </div>
976
976
  </div>
@@ -979,14 +979,14 @@
979
979
  <button t-att-disabled="!hasSearchResult"
980
980
  t-on-click="onSelectPreviousCell"
981
981
  class="o-sidePanelButton"
982
- t-esc="env._t('${uc}')"/>
982
+ t-esc="env._t('${gc}')"/>
983
983
  <button t-att-disabled="!hasSearchResult"
984
984
  t-on-click="onSelectNextCell"
985
985
  class="o-sidePanelButton"
986
- t-esc="env._t('${dc}')"/>
986
+ t-esc="env._t('${pc}')"/>
987
987
  </div>
988
988
  <div class="o-section" t-if="!getters.isReadonly()">
989
- <div t-esc="env._t('${hc}')" class="o-section-title"/>
989
+ <div t-esc="env._t('${uc}')" class="o-section-title"/>
990
990
  <div class="o-input-search-container">
991
991
  <input type="text" class="o-input o-input-without-count" t-model="state.replaceWith" t-on-keydown="onKeydownReplace"/>
992
992
  </div>
@@ -995,20 +995,20 @@
995
995
  <label class="o-far-checkbox">
996
996
  <input class="o-far-input" t-att-disabled="state.searchOptions.searchFormulas" type="checkbox"
997
997
  t-model="state.replaceOptions.modifyFormulas"/>
998
- <span class="o-far-label"><t t-esc="env._t('${vc}')"/></span>
998
+ <span class="o-far-label"><t t-esc="env._t('${bc}')"/></span>
999
999
  </label>
1000
1000
  </div>
1001
1001
  </div>
1002
1002
 
1003
1003
  <div class="o-sidePanelButtons" t-if="!getters.isReadonly()">
1004
1004
  <button t-att-disabled="env.getters.getCurrentSelectedMatchIndex() === null" t-on-click="replace"
1005
- class="o-sidePanelButton" t-esc="env._t('${hc}')"/>
1005
+ class="o-sidePanelButton" t-esc="env._t('${uc}')"/>
1006
1006
  <button t-att-disabled="env.getters.getCurrentSelectedMatchIndex() === null" t-on-click="replaceAll"
1007
- class="o-sidePanelButton" t-esc="env._t('${mc}')"/>
1007
+ class="o-sidePanelButton" t-esc="env._t('${Ec}')"/>
1008
1008
  </div>
1009
1009
 
1010
1010
  </div>
1011
- `,ph=dh`
1011
+ `,fh=ph`
1012
1012
  .o-find-and-replace {
1013
1013
  .o-far-item {
1014
1014
  display: block;
@@ -1041,25 +1041,25 @@
1041
1041
  }
1042
1042
  }
1043
1043
  }
1044
- `;class gh extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters,this.state=t.useState(this.initialState())}get hasSearchResult(){return null!==this.env.getters.getCurrentSelectedMatchIndex()}mounted(){this.focusInput()}async willUnmount(){this.env.dispatch("CLEAR_SEARCH")}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.getters.shouldShowFormulas(),this.state.replaceOptions.modifyFormulas=this.state.searchOptions.searchFormulas?this.state.searchOptions.searchFormulas:this.state.replaceOptions.modifyFormulas,this.env.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.state.replaceOptions.modifyFormulas=this.state.searchOptions.searchFormulas,this.updateSearch()}onSelectPreviousCell(){this.env.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.inDebounce),this.inDebounce=setTimeout((()=>this.updateSearch.call(this)),400)}replace(){this.env.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith,replaceOptions:this.state.replaceOptions})}replaceAll(){this.env.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith,replaceOptions:this.state.replaceOptions})}focusInput(){const e=this.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1},replaceOptions:{modifyFormulas:!1}}}}gh.template=uh,gh.style=ph;const fh=new Le;fh.add("ConditionalFormatting",{title:a("Conditional formatting"),Body:ch}),fh.add("ChartPanel",{title:a("Chart"),Body:Mc}),fh.add("FindAndReplace",{title:a("Find and Replace"),Body:gh});const mh=new Le;class vh extends pa{constructor(e,t,s,i){super(t,s,i),this.getters=e,this.ui=i}drawGrid(e,t){}}vh.layers=[];class Eh{constructor(e,t,s){this.index=0,this.cells=e,this.getters=t,this.direction=s}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:s,tooltip:i}=Ta.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:s,tooltip:i,origin:{col:e.data.col,row:e.data.row}}}}class Sh extends vh{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:ps(e.col,0,this.getters.getSheet(t).cols.length),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:ps(e.row,0,this.getters.getSheet(t).rows.length),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:30;case"AUTOFILL_AUTO":const s=this.getters.getSelectedZone();return s.top===s.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),s=this.autofillZone;switch(this.direction){case 1:for(let i=t.left;i<=t.right;i++){const o=[];for(let e=t.top;e<=t.bottom;e++)o.push(is(i,e));const n=this.createGenerator(o);for(let t=s.top;t<=s.bottom;t++)this.computeNewCell(n,i,t,e)}break;case 0:for(let i=t.left;i<=t.right;i++){const o=[];for(let e=t.bottom;e>=t.top;e--)o.push(is(i,e));const n=this.createGenerator(o);for(let t=s.bottom;t>=s.top;t--)this.computeNewCell(n,i,t,e)}break;case 2:for(let i=t.top;i<=t.bottom;i++){const o=[];for(let e=t.right;e>=t.left;e--)o.push(is(e,i));const n=this.createGenerator(o);for(let t=s.right;t>=s.left;t--)this.computeNewCell(n,t,i,e)}break;case 3:for(let i=t.top;i<=t.bottom;i++){const o=[];for(let e=t.left;e<=t.right;e++)o.push(is(e,i));const n=this.createGenerator(o);for(let t=s.left;t<=s.right;t++)this.computeNewCell(n,t,i,e)}}if(e){const e=Ds(this.getters.getSelectedZone(),this.autofillZone);this.autofillZone=void 0,this.lastCellSelected={},this.direction=void 0,this.tooltip=void 0,this.dispatch("SET_SELECTION",{zones:[e],anchor:[e.left,e.top],anchorZone:e})}}select(e,t){const s=this.getters.getSelectedZone();if(Bs(e,t,s))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case 0:this.saveZone(t,s.top-1,s.left,s.right);break;case 1:this.saveZone(s.bottom+1,t,s.left,s.right);break;case 2:this.saveZone(s.top,s.bottom,e,s.left-1);break;case 3:this.saveZone(s.top,s.bottom,s.right+1,e)}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let s=e.left,i=e.bottom;if(s>0){let e=this.getters.getCell(t,s-1,i);for(;e&&!e.isEmpty();)i+=1,e=this.getters.getCell(t,s-1,i)}if(i===e.bottom&&(s=e.right,s<=this.getters.getActiveSheet().cols.length)){let e=this.getters.getCell(t,s+1,i);for(;e&&!e.isEmpty();)i+=1,e=this.getters.getCell(t,s+1,i)}i!==e.bottom&&(this.select(e.left,i-1),this.autofill(!0))}computeNewCell(e,t,s,i){const{cellData:o,tooltip:n,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=o;this.tooltip=n,i&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:s,content:a,style:l,border:c,format:h})}getRule(e,t){const s=xa.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((s=>s.condition(e,t)));return s&&s.generateRule(e,t)}createGenerator(e){const t=[],s=[],i=this.getters.getActiveSheetId();for(let t of e){const[e,o]=ss(t),n=this.getters.getCell(i,e,o);s.push({col:e,row:o,cell:n,sheetId:i})}const o=s.map((e=>e.cell));for(let e of s){let s={type:"COPY_MODIFIER"};if(e&&e.cell){s=this.getRule(e.cell,o)||s}const{sheetId:i,col:n,row:r}=e,a=this.getters.getCellBorder(i,n,r)||void 0;t.push({data:{...e,border:a},rule:s})}return new Eh(t,this.getters,this.direction)}saveZone(e,t,s,i){this.autofillZone={top:e,bottom:t,left:s,right:i}}getDirection(e,t){const s=this.getters.getSelectedZone(),i={up:{number:s.top-t,value:0},down:{number:t-s.bottom,value:1},left:{number:s.left-e,value:2},right:{number:e-s.right,value:3}};if(1===Object.values(i).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(i).find((e=>e.number>0?1:0)).value;const o=i.up.number>0?"up":"down",n=i.left.number>0?"left":"right";return Math.abs(i[o].number)>=Math.abs(i[n].number)?i[o].value:i[n].value}autoFillMerge(e,t,s,i){const o=this.getters.getActiveSheet();if(this.getters.isInMerge(o.id,s,i)&&!this.getters.isInMerge(o.id,e,t)){const e=this.getters.getMerge(o.id,s,i);e&&this.dispatch("REMOVE_MERGE",{sheetId:o.id,target:[e]})}const n=this.getters.getMerge(o.id,e,t);(null==n?void 0:n.topLeft.col)===e&&(null==n?void 0:n.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:o.id,target:[{top:i,bottom:i+n.bottom-n.top,left:s,right:s+n.right-n.left}]})}drawGrid(e){if(!this.autofillZone)return;const{viewport:t,ctx:s,thinLineWidth:i}=e,[o,n,r,a]=this.getters.getRect(this.autofillZone,t);r>0&&a>0&&(s.strokeStyle="black",s.lineWidth=i,s.setLineDash([3]),s.strokeRect(o,n,r,a),s.setLineDash([]))}}Sh.layers=[6],Sh.getters=["getAutofillTooltip"],Sh.modes=["normal"];class bh extends vh{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:s}=this.getters.getSelection();for(const i of t){const t=this.getAutomaticSums(e,i,s);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,s){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,s):this.sumData(e,t)}sumData(e,t){const s=this.dimensionsToSum(e,t),i=this.sumDimensions(e,t,s).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return s.has("ROW")&&s.has("COL")&&i.push(this.sumTotal(t)),i}sumAdjacentData(e,t,s){const[i,o]=Bs(s[0],s[1],t)?s:[t.left,t.top],n=this.findAdjacentData(e,i,o);return n?this.getters.isSingleCellOrMerge(e,t)||Gs(Ds(n,t))?[{position:[i,o],zone:n}]:this.sumDimensions(e,Ds(n,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,s){const i=this.getters.getSheet(e),o=this.findSuitableZoneToSum(i,...this.getters.getMainCell(e,t,s));if(o)return this.getters.expandZone(e,o)}findSuitableZoneToSum(e,t,s){const i=this.getters.getCell(e.id,t,s-1),o=this.getters.getCell(e.id,t-1,s);if(this.isNumber(o)&&!this.isNumber(i))return this.findHorizontalZone(e,t,s);const n=this.findVerticalZone(e,t,s);if(this.isZoneValid(n))return n;const r=this.findHorizontalZone(e,t,s);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,s){const i={top:0,bottom:s-1,left:t,right:t},o=this.reduceZoneStart(e,i,i.bottom);return{...i,top:o}}findHorizontalZone(e,t,s){const i={top:s,bottom:s,left:0,right:t-1},o=this.reduceZoneStart(e,i,i.right);return{...i,left:o}}reduceZoneStart(e,t,s){const i=zs(t,e,(e=>e),void 0).flat(),o=fs(s,-1,-1),n=o.filter((e=>{var t;return i[e]&&!(null===(t=i[e])||void 0===t?void 0:t.isAutoSummable)})),r=Math.max(...n),a=ms(o.filter((e=>this.isNumber(i[e]))))[0]||[];return Math.max(...a)<r?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return(null==e?void 0:e.evaluated.type)===ke.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(A))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const s=new Set;return Gs(t)?(s.add(1===Zs(t).width?"COL":"ROW"),s):(this.lastColIsEmpty(e,t)&&s.add("ROW"),this.lastRowIsEmpty(e,t)&&s.add("COL"),0===s.size&&s.add("COL"),s)}sumDimensions(e,t,s){return[...s.has("COL")?this.sumColumns(t,e):[],...s.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:s}=e;return{position:[s,t],zone:{...e,top:t,right:s-1}}}sumColumns(e,t){const s=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,s.bottom-1)},Ws(s).map((t=>({position:t,zone:{...e,right:t[0],left:t[0]}})))}sumRows(e,t){const s=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,s.right-1)},Ws(s).map((t=>({position:t,zone:{...e,top:t[1],bottom:t[1]}})))}dispatchCellUpdates(e,t){for(const s of t){const[t,i]=s.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,content:`=SUM(${this.getters.zoneToXC(e,s.zone)})`})}}nextEmptyRow(e,t){let s=t.bottom+1;const{left:i,right:o}=t;for(;!this.getters.isEmpty(e,{bottom:s,top:s,left:i,right:o});)s++;return{...t,top:s,bottom:s}}nextEmptyCol(e,t){let s=t.right+1;const{top:i,bottom:o}=t;for(;!this.getters.isEmpty(e,{left:s,right:s,top:i,bottom:o});)s++;return{...t,left:s,right:s}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}bh.getters=["getAutomaticSums"],bh.modes=["normal","headless"];class Ch extends vh{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"PASTE":return this.isPasteAllowed(this.state,e.target,!!e.force);case"INSERT_CELL":{const{cut:t,paste:s}=this.getInsertCellsTargets(e.zone,e.shiftDimension),i=this.getClipboardState(t,"CUT");return this.isPasteAllowed(i,s,!1)}case"DELETE_CELL":{const{cut:t,paste:s}=this.getDeleteCellsTargets(e.zone,e.shiftDimension),i=this.getClipboardState(t,"CUT");return this.isPasteAllowed(i,s,!1)}}return 0}handle(e){var t,s;switch(e.type){case"COPY":case"CUT":this.state=this.getClipboardState(e.target,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);if(this._isPaintingFormat=!1,e.interactive)this.interactivePaste(this.state,e.target,e);else{const t=this.state.cells.length,s=this.state.cells[0].length;this.paste(this.state,e.target,i),this.selectPastedZone(s,t,e.target),this.status="invisible"}break;case"DELETE_CELL":{const{cut:t,paste:s}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Ns(t[0])){for(const[t,s]of Ws(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:s,sheetId:this.getters.getActiveSheetId()});break}const i=this.getClipboardState(t,"CUT");e.interactive?this.interactivePaste(i,s,e):this.paste(i,s);break}case"INSERT_CELL":{const{cut:t,paste:s}=this.getInsertCellsTargets(e.zone,e.shiftDimension),i=this.getClipboardState(t,"CUT");e.interactive?this.interactivePaste(i,s,e):this.paste(i,s);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(s=this.state)||void 0===s?void 0:s.operation))return;for(let t of e.elements){if(this.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":this.pasteFromClipboard(e.target,e.text);break;case"ACTIVATE_PAINT_FORMAT":this.state=this.getClipboardState(e.target,"COPY"),this._isPaintingFormat=!0,this.status="visible";break;default:Ue(e)&&(this.status="invisible")}}getClipboardContent(){return this.state&&this.state.cells.length&&this.state.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.cell,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const s=this.getters.getActiveSheet();let i;return i="COL"===t?{...e,left:e.right+1,right:s.cols.length-1}:{...e,top:e.bottom+1,bottom:s.rows.length-1},{cut:[i],paste:[e]}}getInsertCellsTargets(e,t){const s=this.getters.getActiveSheet();let i,o;return"COL"===t?(i={...e,right:s.cols.length-1},o={...e,left:e.right+1,right:e.right+1}):(i={...e,bottom:s.rows.length-1},o={...e,top:e.bottom+1,bottom:s.rows.length-1}),{cut:[i],paste:[o]}}removeMergeIfTopLeft(e){const{sheetId:t,col:s,row:i}=e,[o,n]=this.getters.getMainCell(t,s,i);if(n===i&&o===s){const e=this.getters.getMerge(t,s,i);e&&this.dispatch("REMOVE_MERGE",{sheetId:t,target:[e]})}}pasteMergeIfExist(e,t){let{sheetId:s,col:i,row:o}=e;const[n,r]=this.getters.getMainCell(s,i,o);if(n===i&&r===o){const e=this.getters.getMerge(s,i,o);if(!e)return;({sheetId:s,col:i,row:o}=t),this.dispatch("ADD_MERGE",{sheetId:s,force:!0,target:[{left:i,top:o,right:i+e.right-e.left,bottom:o+e.bottom-e.top}]})}}getPasteZones(e,t){if(!t.length||!t[0].length)return e;const s=[],i=t.length,o=t[0].length,n=e[e.length-1],r=n.left,a=n.top,l=Math.max(1,Math.floor((n.right+1-r)/o)),c=Math.max(1,Math.floor((n.bottom+1-a)/i));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)s.push({left:r,top:a,right:r-1+e*o,bottom:a-1+t*i});return s}getClipboardState(e,t){const s=new Set(e.map((e=>e.top))),i=new Set(e.map((e=>e.bottom)));let o=1===s.size&&1===i.size?e:[e[e.length-1]];o=o.map((e=>({...e})));const n=[],r=[],a=this.getters.getActiveSheetId(),{top:l,bottom:c}=o[0];for(let e=l;e<=c;e++){const t=[];n.push(t);for(let s of o)for(let i=s.left;i<=s.right;i++){const s=this.getters.getCell(a,i,e),o=this.getters.getCellBorder(a,i,e)||void 0;t.push({cell:s,border:o,position:{col:i,row:e,sheetId:a}});const n=this.getters.getMerge(a,i,e);n&&n.top===e&&n.left===i&&r.push(n)}}return{cells:n,operation:t,sheetId:a,zones:o,merges:r}}pasteFromClipboard(e,t){this.status="invisible";const s=t.replace(/\r/g,"").split("\n").map((e=>e.split("\t"))),{left:i,top:o}=e[0],n=Math.max.apply(Math,s.map((e=>e.length))),r=s.length,a=this.getters.getActiveSheet();this.addMissingDimensions(a,n,r,i,o);for(let e=0;e<s.length;e++)for(let t=0;t<s[e].length;t++)this.dispatch("UPDATE_CELL",{row:o+e,col:i+t,content:s[e][t],sheetId:a.id});const l={left:i,top:o,right:i+n-1,bottom:o+r-1};this.dispatch("SET_SELECTION",{anchor:[i,o],zones:[l],anchorZone:l})}isPasteAllowed(e,t,s){const i=this.getters.getActiveSheetId();if(!e)return 20;if(t.length>1&&(e.cells.length>1||e.cells[0].length>1))return 19;if(!s)for(let s of this.getPasteZones(t,e.cells))if(this.getters.doesIntersectMerge(i,s))return 2;return 0}paste(e,t,s){if("CUT"===e.operation&&this.clearClippedZones(e),t.length>1)for(const i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,t,o,s);else{const i=e.cells.length,o=e.cells[0].length,n=t[0],r=Math.max(1,Math.floor((n.right+1-n.left)/o)),a=Math.max(1,Math.floor((n.bottom+1-n.top)/i));for(let t=0;t<r;t++)for(let r=0;r<a;r++)this.pasteZone(e,n.left+t*o,n.top+r*i,s)}"CUT"===e.operation&&(this.dispatch("REMOVE_MERGE",{sheetId:e.sheetId,target:e.merges}),this.state=void 0)}selectPastedZone(e,t,s){const i=s[0],o=i.left,n=i.top,r=Math.max(1,Math.floor((i.right+1-i.left)/e)),a=Math.max(1,Math.floor((i.bottom+1-i.top)/t));if(t>1||e>1){const s={left:o,top:n,right:o+r*e-1,bottom:n+a*t-1},[i,l]=this.getters.getSelection().anchor,c=ps(i,o,o+r*e-1),h=ps(l,n,n+a*t-1);this.dispatch("SET_SELECTION",{anchor:[c,h],zones:[s],anchorZone:s})}}clearClippedZones(e){for(const t of e.cells)for(const e of t)e.cell&&this.dispatch("CLEAR_CELL",e.position);this.dispatch("CLEAR_FORMATTING",{sheetId:e.sheetId,target:e.zones})}pasteZone(e,t,s,i){const o=e.cells.length,n=e.cells[0].length,r="onlyValue"!==i&&this.state&&this.state===e,a=this.getters.getActiveSheet();this.addMissingDimensions(a,n,o,t,s);for(let l=0;l<o;l++){const o=e.cells[l];for(let c=0;c<n;c++){const n=o[c],h={col:t+c,row:s+l,sheetId:a.id};this.removeMergeIfTopLeft(h),this.pasteMergeIfExist(n.position,h),this.pasteCell(n,h,e.operation,e.zones,i),r&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:h,operation:e.operation})}}}addMissingDimensions(e,t,s,i,o){const{cols:n,rows:r,id:a}=e,l=s+o-r.length;l>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:r.length-1,sheetId:a,quantity:l,position:"after"});const c=t+i-n.length;c>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:n.length-1,sheetId:a,quantity:c,position:"after"})}pasteCell(e,t,s,i,o){const{sheetId:n,col:r,row:a}=t,l=this.getters.getCell(n,r,a);if("onlyValue"!==o&&this.dispatch("SET_BORDER",{sheetId:n,col:r,row:a,border:e.border}),e.cell){if("onlyFormat"===o)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.cell.format});if("onlyValue"===o){const s=Gr(e.cell.evaluated.value);return void this.dispatch("UPDATE_CELL",{...t,content:s})}let l=e.cell.content;if(e.cell.isFormula()){const t=r-e.position.col,o=a-e.position.row;l=this.getUpdatedContent(n,e.cell,t,o,i,s)}this.dispatch("UPDATE_CELL",{...t,content:l,style:e.cell.style||null,format:e.cell.format})}else l&&("onlyValue"===o?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===o?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,s,i,o,n){if("CUT"===n){const n=[];for(const r of t.dependencies.references)this.isZoneOverlapClippedZone(o,r.zone)?n.push(...this.getters.createAdaptedRanges([r],s,i,e)):n.push(r);const r={...t.dependencies,references:n};return this.getters.buildFormulaContent(e,t.normalizedText,r)}const r=this.getters.createAdaptedRanges(t.dependencies.references,s,i,e),a={...t.dependencies,references:r};return this.getters.buildFormulaContent(e,t.normalizedText,a)}isZoneOverlapClippedZone(e,t){return e.some((e=>Ps(t,e)))}interactivePaste(e,t,s){const i=this.isPasteAllowed(e,t,!1);0!==i?(19===i&&this.ui.notifyUser(a("This operation is not allowed with multiple selections.")),2===i&&this.ui.notifyUser(a("This operation is not possible due to a merge. Please remove the merges first than try again."))):this.dispatch(s.type,{...s,interactive:!1})}isColRowDirtyingClipboard(e,t){if(!this.state||!this.state.zones)return!1;for(let s of this.state.zones){if("COL"===t&&e<=s.right)return!0;if("ROW"===t&&e<=s.bottom)return!0}return!1}drawGrid(e){const{viewport:t,ctx:s,thinLineWidth:i}=e;if("visible"===this.status&&this.state&&this.state.zones&&this.state.zones.length&&this.state.sheetId===this.getters.getActiveSheetId()){s.setLineDash([8,5]),s.strokeStyle=p,s.lineWidth=3.3*i;for(const e of this.state.zones){const[i,o,n,r]=this.getters.getRect(e,t);n>0&&r>0&&s.strokeRect(i,o,n,r)}}}}var Ih;Ch.layers=[2],Ch.getters=["getClipboardContent","isPaintingFormat"],Ch.modes=["normal"],function(e){e[e.idle=0]="idle",e[e.selecting=1]="selecting",e[e.readyToExpand=2]="readyToExpand",e[e.expanding=3]="expanding"}(Ih||(Ih={}));class yh extends vh{constructor(e,t,s,i){super(e,t,s,i),this.selection={zones:[{top:0,left:0,bottom:0,right:0}],anchor:[0,0],anchorZone:{top:0,left:0,bottom:0,right:0}},this.selectedFigureId=null,this.activeCol=0,this.activeRow=0,this.mode=Ih.idle,this.sheetsData={},this.activeSheet=null,this.moveClient=i.moveClient}allowDispatch(e){switch(e.type){case"SET_SELECTION":if(-1===e.zones.findIndex((t=>Us(t,e.anchorZone))))return 16;break;case"ALTER_SELECTION":if(e.delta){const{left:t,right:s,top:i,bottom:o}=this.getSelectedZone(),n=this.getters.getActiveSheet(),r=oi(n,"cols",fs(t,s+1)),a=oi(n,"rows",fs(i,o+1));if(0!==e.delta[0]&&void 0===a||0!==e.delta[1]&&void 0===r)return 17}break;case"MOVE_POSITION":{const{cols:t,rows:s}=this.getters.getActiveSheet();if(0!==e.deltaX&&s[this.activeRow].isHidden||0!==e.deltaY&&t[this.activeCol].isHidden)return 17;const{col:i,row:o}=this.getNextAvailablePosition(e.deltaX,e.deltaY);if(o<0||o>s.length-1||i<0||i>t.length-1)return 17;break}case"SELECT_COLUMN":{const{index:t}=e;if(t<0||t>=this.getters.getActiveSheet().cols.length)return 17;break}case"SELECT_ROW":{const{index:t}=e;if(t<0||t>=this.getters.getActiveSheet().rows.length)return 17;break}case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 23}case"MOVE_COLUMNS_ROWS":const t=this.isMoveElementAllowed(e);return 2===t&&this.ui.notifyUser(a("Merged cells are preventing this operation. Unmerge those cells and try again.")),t}return 0}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":case"CREATE_FIGURE":case"CREATE_CHART":case"UPDATE_FIGURE":case"EVALUATE_CELLS":case"DISABLE_SELECTION_INPUT":case"ENABLE_NEW_SELECTION_INPUT":case"RESIZE_VIEWPORT":break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;default:this.selectedFigureId=null}switch(e.type){case"START":const t=ii(this.getters.getSheets()[0],0,0);this.activeCol=t[0],this.activeRow=t[1],this.dispatch("ACTIVATE_SHEET",{sheetIdTo:this.getters.getSheets()[0].id,sheetIdFrom:this.getters.getSheets()[0].id}),this.selectCell(...t);break;case"ACTIVATE_SHEET":this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={selection:JSON.parse(JSON.stringify(this.selection)),activeCol:this.activeCol,activeRow:this.activeRow},e.sheetIdTo in this.sheetsData?Object.assign(this,this.sheetsData[e.sheetIdTo]):this.selectCell(...ii(this.getters.getSheet(e.sheetIdTo),0,0));break;case"SET_SELECTION":this.setSelection(e.anchor,e.zones,e.anchorZone,e.strict);break;case"START_SELECTION":this.mode=Ih.selecting;break;case"PREPARE_SELECTION_EXPANSION":this.mode=Ih.readyToExpand;break;case"START_SELECTION_EXPANSION":this.mode=Ih.expanding;break;case"STOP_SELECTION":this.mode=Ih.idle;break;case"MOVE_POSITION":this.movePosition(e.deltaX,e.deltaY);break;case"SELECT_CELL":this.selectCell(e.col,e.row);break;case"SELECT_COLUMN":this.selectColumn(e.index,e.createRange||!1,e.updateRange||!1);break;case"SELECT_ROW":this.selectRow(e.index,e.createRange||!1,e.updateRange||!1);break;case"SELECT_ALL":this.selectAll();break;case"ALTER_SELECTION":e.delta&&this.moveSelection(e.delta[0],e.delta[1]),e.cell&&this.addCellToSelection(...e.cell);break;case"UNDO":case"REDO":case"DELETE_SHEET":if(!this.getters.tryGetSheet(this.getActiveSheetId())){const e=this.getters.getVisibleSheets();this.activeSheet=this.getters.getSheet(e[0]),this.selectCell(0,0)}this.ensureSelectionValidity();break;case"REMOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&("COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e));break;case"ADD_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onAddElements(e);break;case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"UPDATE_CHART":case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left")}}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){const e=this.getters.getActiveSheetId(),[t,s]=this.getters.getMainCell(e,this.activeCol,this.activeRow);return this.getters.getCell(e,t,s)}getActiveCols(){const e=new Set;for(let t of this.selection.zones)if(0===t.top&&t.bottom===this.getters.getActiveSheet().rows.length-1)for(let s=t.left;s<=t.right;s++)e.add(s);return e}getActiveRows(){const e=new Set;for(let t of this.selection.zones)if(0===t.left&&t.right===this.getters.getActiveSheet().cols.length-1)for(let s=t.top;s<=t.bottom;s++)e.add(s);return e}getCurrentStyle(){const e=this.getters.getActiveCell();return e?this.getters.getCellStyle(e):{}}getSelectedZones(){return this.selection.zones}getSelectedZone(){return this.selection.anchorZone}getSelection(){return this.selection}getSelectedFigureId(){return this.selectedFigureId}getPosition(){return[this.activeCol,this.activeRow]}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getPosition();{const t=this.sheetsData[e];return t?[t.activeCol,t.activeRow]:ii(this.getters.getSheet(e),0,0)}}getAggregate(){let e=0,t=0;for(let s of this.selection.zones)for(let i=s.top;i<=s.bottom;i++){const o=this.getters.getRow(this.getters.getActiveSheetId(),i);if(void 0!==o)for(let i=s.left;i<=s.right;i++){const s=o.cells[i];(null==s?void 0:s.evaluated.type)===ke.number&&(t++,e+=s.evaluated.value)}}return t<2?null:ie(e)}getSelectionMode(){return this.mode}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Us(t,e)))}getVisibleFigures(e){const t=[],s=this.getters.getFigures(e),{offsetX:i,offsetY:o}=this.getters.getSnappedViewport(e),{width:n,height:r}=this.getters.getViewportDimension();for(let e of s)e.x>=i+n||e.x+e.width<=i||e.y>=o+r||e.y+e.height<=o||t.push(e);return t}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let s=[];const i="COL"===e?"left":"top",o="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[o]-e[i]+1},((t,s)=>e[i]+s));s=s.concat(t)}return[...new Set(s)].sort()}selectColumn(e,t,s){const i=this.getters.getActiveSheet().rows.length-1;let o={left:e,right:e,top:0,bottom:i};const n=this.selection.zones;let r,a;const l=this.getters.getActiveSheet().rows.findIndex((e=>!e.isHidden));if(s){const[e,t]=this.selection.anchor;o=Ds(o,{left:e,right:e,top:l,bottom:i}),r=this.updateSelectionZones(o),a=[e,t]}else r=t?n.concat(o):[o],a=[e,l];this.dispatch("SET_SELECTION",{zones:r,anchor:a,strict:!0,anchorZone:o})}selectRow(e,t,s){const i=this.getters.getActiveSheet().cols.length-1;let o={top:e,bottom:e,left:0,right:i};const n=this.selection.zones;let r,a;const l=this.getters.getActiveSheet().cols.findIndex((e=>!e.isHidden));if(s){const[e,t]=this.selection.anchor;o=Ds(o,{left:l,right:i,top:t,bottom:t}),r=this.updateSelectionZones(o),a=[e,t]}else r=t?n.concat(o):[o],a=[l,e];this.dispatch("SET_SELECTION",{zones:r,anchor:a,strict:!0,anchorZone:o})}selectAll(){const e={left:0,top:0,bottom:this.getters.getActiveSheet().rows.length-1,right:this.getters.getActiveSheet().cols.length-1};this.dispatch("SET_SELECTION",{zones:[e],anchor:[0,0],anchorZone:e})}selectCell(e,t){const s=this.getters.getActiveSheet();this.moveClient({sheetId:s.id,col:e,row:t});let i=this.getters.expandZone(s.id,{left:e,right:e,top:t,bottom:t});this.mode===Ih.expanding?this.selection.zones.push(i):this.selection.zones=[i],this.selection.zones=js(this.selection.zones),this.selection.anchorZone=i,this.selection.anchor=[e,t],this.activeCol=e,this.activeRow=t}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}getNextAvailablePosition(e,t){return{col:this.getNextAvailableCol(e,this.activeCol,this.activeRow),row:this.getNextAvailableRow(t,this.activeCol,this.activeRow)}}getNextAvailableCol(e,t,s){const{cols:i,id:o}=this.getActiveSheet(),n={col:t,row:s};return this.getNextAvailableHeader(e,i,t,n,(e=>this.getters.isInSameMerge(o,t,s,e,s)))}getNextAvailableRow(e,t,s){const{rows:i,id:o}=this.getActiveSheet(),n={col:t,row:s};return this.getNextAvailableHeader(e,i,s,n,(e=>this.getters.isInSameMerge(o,t,s,t,e)))}getNextAvailableHeader(e,t,s,i,o){var n,r,a;const l=this.getters.getActiveSheetId(),{col:c,row:h}=i;if(0===e)return s;let d=s+e;if(this.getters.isInMerge(l,c,h)){for(;o(d);)d+=e;for(;null===(n=t[d])||void 0===n?void 0:n.isHidden;)d+=e}else if(null===(r=t[d])||void 0===r?void 0:r.isHidden)for(;null===(a=t[d])||void 0===a?void 0:a.isHidden;)d+=e;return d<0||d>t.length-1?t[s].isHidden?this.getNextAvailableHeader(-e,t,s,i,o):s:d}movePosition(e,t){const{col:s,row:i}=this.getNextAvailablePosition(e,t);this.selectCell(s,i)}setSelection(e,t,s,i=!1){this.selectCell(...e);const o=this.getters.getActiveSheetId();let n;t=js(t),n=i?{zones:t,anchorZone:s,anchor:e}:{anchor:e,zones:t.map((e=>this.getters.expandZone(o,e))),anchorZone:this.getters.expandZone(o,s)},this.selection=this.clipSelection(o,n)}getReferencePosition(){const e=this.getters.getActiveSheet(),t=this.selection,{left:s,right:i,top:o,bottom:n}=t.anchorZone,[r,a]=t.anchor;return{col:e.cols[r].isHidden&&oi(e,"cols",fs(s,i+1))||r,row:e.rows[a].isHidden&&oi(e,"rows",fs(o,n+1))||a}}moveSelection(e,t){const s=this.selection;let i=[];const[o,n]=s.anchor,{left:r,right:a,top:l,bottom:c}=s.anchorZone;let h=s.anchorZone;const d=this.getters.getActiveSheet(),u=e=>{const{left:t,right:s,top:i,bottom:o}=this.getters.expandZone(d.id,e);return{left:Math.max(0,t),right:Math.min(d.cols.length-1,s),top:Math.max(0,i),bottom:Math.min(d.rows.length-1,o)}},{col:p,row:g}=this.getReferencePosition();let f=0;for(;null!==h;){if(f++,e<0){const t=this.getNextAvailableCol(e,a-(f-1),g);h=p<=a-f?u({top:l,left:r,bottom:c,right:t}):null}if(e>0){const t=this.getNextAvailableCol(e,r+(f-1),g);h=r+f<=p?u({top:l,left:t,bottom:c,right:a}):null}if(t<0){const e=this.getNextAvailableRow(t,p,c-(f-1));h=g<=c-f?u({top:l,left:r,bottom:e,right:a}):null}if(t>0){const e=this.getNextAvailableRow(t,p,l+(f-1));h=l+f<=g?u({top:e,left:r,bottom:c,right:a}):null}if(h=h?Ys(h):h,h&&!Us(h,s.anchorZone))return i=this.updateSelectionZones(h),void this.dispatch("SET_SELECTION",{zones:i,anchor:[o,n],anchorZone:h})}h=u(Ds({top:n,bottom:n,left:o,right:o},Ys({top:this.getNextAvailableRow(t,p,l),left:this.getNextAvailableCol(e,r,g),bottom:this.getNextAvailableRow(t,p,c),right:this.getNextAvailableCol(e,a,g)}))),Us(h,s.anchorZone)||(i=this.updateSelectionZones(h),this.dispatch("SET_SELECTION",{zones:i,anchor:[o,n],anchorZone:h}))}addCellToSelection(e,t){const s=this.selection,[i,o]=s.anchor,n={left:Math.min(i,e),top:Math.min(o,t),right:Math.max(i,e),bottom:Math.max(o,t)},r=this.updateSelectionZones(n);this.dispatch("SET_SELECTION",{zones:r,anchor:[i,o],anchorZone:n})}ensureSelectionValidity(){const{anchor:e,zones:t,anchorZone:s}=this.clipSelection(this.getActiveSheetId(),this.selection);this.setSelection(e,t,s);const i=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of i)delete this.sheetsData[e];for(const e in this.sheetsData){const{anchor:t,zones:s,anchorZone:i}=this.clipSelection(e,this.sheetsData[e].selection);this.sheetsData[e]={selection:{anchor:t,zones:s,anchorZone:i},activeCol:t[0],activeRow:t[1]}}}clipSelection(e,t){const s=this.getters.getSheet(e),i=s.cols.length-1,o=s.rows.length-1,n=t.zones.map((e=>({left:ps(e.left,0,i),right:ps(e.right,0,i),top:ps(e.top,0,o),bottom:ps(e.bottom,0,o)})));return{anchor:[ps(t.anchor[0],0,i),ps(t.anchor[1],0,o)],zones:n,anchorZone:{left:ps(t.anchorZone.left,0,i),right:ps(t.anchorZone.right,0,i),top:ps(t.anchorZone.top,0,o),bottom:ps(t.anchorZone.bottom,0,o)}}}onColumnsRemoved(e){const t=$s(this.getSelectedZone(),"left",e.elements);this.setSelection([t.left,t.top],[t],t,!0),this.ensureSelectionValidity()}onRowsRemoved(e){const t=$s(this.getSelectedZone(),"top",e.elements);this.setSelection([t.left,t.top],[t],t,!0),this.ensureSelectionValidity()}onAddElements(e){const t=Fs(this.getSelectedZone(),"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.setSelection([t.left,t.top],[t],t,!0)}updateSelectionZones(e){let t=[...this.selection.zones];const s=this.selection.anchorZone,i=t.findIndex((e=>Us(e,s)));return i>=0&&(t[i]=e),t}activateNextSheet(e){const t=this.getters.getSheets().map((e=>e.id)),s=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[s]})}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const s="COL"===e.dimension,i=e.elements[0],o=e.elements[t-1],n=e.base<i,r=n&&s?t:0,a=n&&!s?t:0,l=this.getters.getSheet(e.sheetId);this.dispatch("CUT",{target:[{left:s?i+r:0,right:s?o+r:l.cols.length-1,top:s?0:i+a,bottom:s?l.rows.length-1:o+a}]}),this.dispatch("PASTE",{target:[{left:s?e.base:0,right:s?e.base+t-1:l.cols.length-1,top:s?0:e.base,bottom:s?l.rows.length-1:e.base+t-1}]});const c=n?e.elements.map((e=>e+t)):e.elements;let h=e.base;for(const t of c){const s="COL"===e.dimension?this.getters.getCol(e.sheetId,t).size:this.getters.getRow(e.sheetId,t).size;this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:s,elements:[h]}),h+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:c})}isMoveElementAllowed(e){const t="COL"===e.dimension,s=e.elements[0],i=e.elements[e.elements.length-1],o=e.sheetId,n=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return n(o,s-1,s)||n(o,i,i+1)||n(o,e.base-1,e.base)?2:0}drawGrid(e){if("inactive"!==this.getters.getEditionMode())return;const{viewport:t,ctx:s,thinLineWidth:i}=e,o=this.getSelectedZones();s.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;s.fillStyle=n?"#f3f7fe":"#e9f0ff",s.strokeStyle=p,s.lineWidth=1.5*i,s.globalCompositeOperation="multiply";for(const e of o){const[i,o,n,r]=this.getters.getRect(e,t);s.fillRect(i,o,n,r),s.strokeRect(i,o,n,r)}s.globalCompositeOperation="source-over";const r=this.getters.getActiveSheetId(),[a,l]=this.getPosition();let c;s.strokeStyle=p,s.lineWidth=3*i,c=this.getters.isInMerge(r,a,l)?this.getters.getMerge(r,a,l):{top:l,bottom:l,left:a,right:a};const[h,d,u,g]=this.getters.getRect(c,t);u>0&&g>0&&s.strokeRect(h,d,u,g)}}yh.layers=[5],yh.modes=["normal"],yh.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getAggregate","getSelectedFigureId","getVisibleFigures","getSelection","getPosition","getSheetPosition","getSelectionMode","isSelected","getElementsFromSelection"];const wh=a("The cell you are trying to edit has been deleted.");class Th extends vh{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheet="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.multiSelectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),s=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(s.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection);break;case"STOP_EDITION":e.cancel?(this.cancelEdition(),this.resetContent()):this.stopEdition();break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0);break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEdition(),this.resetContent();break;case"SELECT_CELL":case"SET_SELECTION":case"MOVE_POSITION":switch(this.mode){case"editing":this.dispatch("STOP_EDITION");break;case"waitingForRangeSelection":this.insertSelectedRange();break;case"rangeSelected":switch(e.type){case"MOVE_POSITION":this.replaceAllSelectedRanges();break;case"SELECT_CELL":this.getters.getSelectionMode()===Ih.expanding?this.insertSelectedRange():this.replaceAllSelectedRanges();break;case"SET_SELECTION":e.strict?this.getters.getSelectionMode()===Ih.expanding?this.insertSelectedRange():this.replaceAllSelectedRanges():this.replaceSelectedRange()}}break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.currentTokens.filter((e=>"SYMBOL"===e.type)).find((t=>{let s=t.value;const{xc:i,sheetName:o}=es(s),n=o||this.getters.getSheetName(this.sheet),r=this.getters.getActiveSheetId();return Us(this.getters.expandZone(r,Os(i)),e.zone)&&this.getters.getSheetName(r)===n}));this.previousRef=t.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=t.start;break;case"CHANGE_HIGHLIGHT":const s=this.getZoneReference(e.zone,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(s),this.previousRef=s,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheet)||"inactive"===this.mode||(this.cancelEdition(),this.resetContent(),this.ui.notifyUser(wh))}}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheet}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"waitingForRangeSelection"===this.mode||"rangeSelected"===this.mode||"resettingPosition"===this.mode}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((s=>s.start<=e&&s.end>=t))}validateSelection(e,t,s){return t>=0&&t<=e&&s>=0&&s<=e?0:31}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUser(wh);const{top:t,left:s}=$s({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",e.elements);this.col=s,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUser(wh);const{top:t,left:s}=$s({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",e.elements);this.col=s,this.row=t}onAddElements(e){const{top:t,left:s}=Fs({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=s,this.row=t}startComposerRangeSelection(){this.mode="resettingPosition",this.sheet===this.getters.getActiveSheetId()&&this.dispatch("SELECT_CELL",{col:this.col,row:this.row}),this.mode="waitingForRangeSelection",this.multiSelectionInitialStart=this.selectionStart}startEdition(e,t){const s=this.getters.getActiveCell();this.initialContent=(null==s?void 0:s.composerContent)||"",this.mode="editing";const[i,o]=this.getters.getPosition();this.col=i,this.row=o,this.sheet=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={}}stopEdition(){if("inactive"!==this.mode){this.cancelEdition();const e=this.getters.getActiveSheetId(),t=this.getters.getSheets().find((e=>e.id===this.sheet)).id,[s,i]=this.getters.getMainCell(t,this.col,this.row);let o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const t=this.getters.getCell(e,s,i);if(o.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,s=e-t;s>0&&(o+=new Array(s).fill(")").join(""))}else(null==t?void 0:t.isLink())&&(o=ys(o,t.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheet,col:s,row:i,content:o})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheet,content:"",col:s,row:i});e!==this.sheet&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheet}),this.setContent("")}}cancelEdition(){this.mode="inactive"}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,s){e=e.replace(/[\r\n]/g,"");const i=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(i||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?Vr(e):[],this.currentTokens.length>100&&s&&this.ui.notifyUser(a("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"))),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(){const e=Math.min(this.selectionStart,this.selectionEnd),t=this.getZoneReference(this.getters.getSelectedZone());if("waitingForRangeSelection"===this.mode)return this.insertText(t,e),this.selectionInitialStart=e,void(this.mode="rangeSelected");this.insertText(","+t,e),this.selectionInitialStart=e+1}replaceSelectedRange(){const{end:e}=this.getters.getComposerSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:this.selectionInitialStart,end:e}),this.replaceSelection(this.getZoneReference(this.getters.getSelectedZone()))}replaceAllSelectedRanges(){const{end:e}=this.getters.getComposerSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:this.multiSelectionInitialStart,end:e}),this.replaceSelection(this.getZoneReference(this.getters.getSelectedZone())),this.selectionInitialStart=this.multiSelectionInitialStart}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const s=this.getters.getActiveSheetId();let i=this.getters.zoneToXC(s,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){i=`${us(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${i}`}return i}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),s=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,s)}replaceText(e,t,s){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(s,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const s=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),i=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:{start:i,end:i}})}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=[],t={};for(let s of this.currentTokens.filter((e=>"SYMBOL"===e.type))){let i=s.value;const{xc:o,sheetName:n}=es(i);if(Jt.test(o)){const s=(n?`${n}!`:`${this.getters.getSheetName(this.getters.getEditionSheet())}!`)+o.replace(/\$/g,"");e.push(s);const i=this.colorIndexByRange[s];void 0!==i&&(t[s]=i)}}this.colorIndexByRange=t;let s=Object.values(t),i=0;return e.map((e=>{if(void 0===this.colorIndexByRange[e]){for(;s.includes(i);)i++;s.push(i),this.colorIndexByRange[e]=i}return[e,qt[this.colorIndexByRange[e]%qt.length]]}))}canStartComposerRangeSelection(){if("editing"!==this.mode&&this.selectionStart===this.selectionEnd)return!1;if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(e){const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let s=t,i=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type||s<1)return!1;s--,i=this.currentTokens[s]}for(s=t+1,i=this.currentTokens[s];i&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type)return!1;s++,i=this.currentTokens[s]}s++,i=this.currentTokens[s]}return!0}return!1}}Th.getters=["getEditionMode","isSelectingForComposer","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"],Th.modes=["normal"];const xh=or.mapping;class Rh extends vh{constructor(e,t,s,i){super(e,t,s,i),this.isUpToDate=new Set,this.evalContext=i.evalContext,i.dataSources.on("data-loaded",this,(()=>{this.dispatch("EVALUATE_CELLS",{sheetId:this.getters.getActiveSheetId()})}))}handle(e){switch(Fe.has(e.type)&&this.isUpToDate.clear(),e.type){case"UPDATE_CELL":"content"in e&&this.isUpToDate.clear();break;case"ACTIVATE_SHEET":this.evaluate(e.sheetIdTo),this.isUpToDate.add(e.sheetIdTo);break;case"EVALUATE_CELLS":this.evaluate(e.sheetId),this.isUpToDate.add(e.sheetId);break;case"EVALUATE_ALL_SHEETS":this.evaluateAllSheets()}}finalize(){const e=this.getters.getActiveSheetId();this.isUpToDate.has(e)||(this.evaluate(e),this.isUpToDate.add(e))}evaluateFormula(e,t=this.getters.getActiveSheetId()){try{let s=Hr(e);const i=Ur(s),o=this.getFormulaParameters((()=>{})),n=[];for(let e of s.dependencies.references)n.push(this.getters.getRangeFromSheetXC(t,e));return i({...s.dependencies,references:n},t,...o)}catch(e){return"#ERROR"}}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[[]]:zs(e.zone,t,(e=>this.getters.getCellText(e,this.getters.shouldShowFormulas())),"")}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[[]]:zs(e.zone,t,(e=>e.evaluated.value))}evaluate(e){const t=this.getters.getCells(e),s=this.getFormulaParameters(o),i={};for(let s of Object.values(t))o(s,e);function o(e,t){if(!e.isFormula())return;const o=e.id;if(o in i)null===i[o]&&e.assignError("#CYCLE",a("Circular reference"));else{i[o]=null;try{if(s[2].__originCellXC=()=>{const e=s[2].getters.getCellPosition(o);return is(e.col,e.row)},e.assignValue(e.compiledFormula(e.dependencies,t,...s)),Array.isArray(e.evaluated.value))throw new Error(a("This formula depends on invalid values"))}catch(t){!function(e,t){if(e instanceof Error||(e=new Error(e)),"#CYCLE"!==t.evaluated.value){t.assignValue("#ERROR");const i=s[2].__lastFnCalled||"";t.assignError("#ERROR",e.message.replace("[[FUNCTION_NAME]]",i))}}(t,e)}i[o]=!0}}}getFormulaParameters(e){const t=Object.assign(Object.create(xh),this.evalContext,{getters:this.getters});function s(t,s){if(e(t,s),t.evaluated.type===ke.error)throw new Error(a("This formula depends on invalid values"));return t.evaluated.value}function i(e){o(e);const i=t.getters.getSheet(e.sheetId),n={top:0,bottom:i.rows.length-1,left:0,right:i.cols.length-1},r=[],a=function(e,t){if(Ps(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}(e.zone,n);if(!a)return r.push([]),r;for(let i=a.left;i<=a.right;i++){const o=[];for(let n=a.top;n<=a.bottom;n++){const r=t.getters.getCell(e.sheetId,i,n);o.push(r?s(r,e.sheetId):void 0)}r.push(o)}return r}function o(e){if(!Ns(e.zone))throw new Error(a("Invalid reference"));if(e.invalidSheetName)throw new Error(a("Invalid sheet name: %s",e.invalidSheetName))}return[function(e,i,n,r,l,c){const h=i[e];if(o(h),r)return t.getters.getRangeString(h,n);if(h.zone.bottom!==h.zone.top||h.zone.left!==h.zone.right)throw new Error(c?a("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",l.toString(),c.toString()):a("Function %s expects its parameters to be single values or single cell references, not ranges.",l.toString()));return function(e){var i;const o=null===(i=t.getters.getSheet(e.sheetId).rows[e.zone.top])||void 0===i?void 0:i.cells[e.zone.left];return!o||o.isEmpty()?null:s(o,e.sheetId)}(h)},function(e,t,s){return i(t[e])},t]}evaluateAllSheets(){for(const e of this.getters.getVisibleSheets())this.evaluate(e),this.isUpToDate.add(e)}}Rh.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues"],Rh.modes=["normal"];const Lh=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Mh{constructor(){this.graphColorIndex=0}next(){return Lh[this.graphColorIndex++%Lh.length]}}class Ah extends vh{constructor(){super(...arguments),this.chartRuntime={},this.outOfDate=new Set}handle(e){if(Fe.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type&&"content"in e)for(let e of Object.keys(this.chartRuntime))this.outOfDate.add(e);switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":const t=this.getters.getChartDefinition(e.id);this.chartRuntime[e.id]=this.mapDefinitionToRuntime(t);break;case"DELETE_FIGURE":delete this.chartRuntime[e.id];break;case"REFRESH_CHART":this.evaluateUsedSheets([e.id]),this.outOfDate.add(e.id);break;case"ACTIVATE_SHEET":const s=this.getters.getChartsIdBySheet(e.sheetIdTo);this.evaluateUsedSheets(s);break;case"DELETE_SHEET":for(let e of Object.keys(this.chartRuntime))this.getters.getChartDefinition(e)||delete this.chartRuntime[e]}}getChartRuntime(e){if(this.outOfDate.has(e)||!(e in this.chartRuntime)){const t=this.getters.getChartDefinition(e);if(void 0===t)return;this.chartRuntime[e]=this.mapDefinitionToRuntime(t),this.outOfDate.delete(e)}return this.chartRuntime[e]}truncateLabel(e){return e?e.length>20?e.substring(0,20)+"…":e:""}getDefaultConfiguration(e,t){const s={};e.labelRange||1!==e.dataSets.length?s.position=e.legendPosition:s.display=!1;const i={type:e.type,options:{legend:s,responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:e.title}},data:{labels:t.map(this.truncateLabel),datasets:[]}};return"pie"!==e.type?(i.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2}}],yAxes:[{position:e.verticalAxisPosition,ticks:{beginAtZero:!0}}]},"bar"===e.type&&e.stackedBar&&(i.options.scales.xAxes[0].stacked=!0,i.options.scales.yAxes[0].stacked=!0)):i.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},i}getSheetIdsUsedInChart(e){const t=new Set;for(let s of e.dataSets)t.add(s.dataRange.sheetId);return e.labelRange&&t.add(e.labelRange.sheetId),t}evaluateUsedSheets(e){const t=new Set;for(let s of e){const e=this.getters.getChartDefinition(s);(void 0!==e?this.getSheetIdsUsedInChart(e):[]).forEach((e=>{e!==this.getters.getActiveSheetId()&&t.add(e)}))}for(let e of t)this.dispatch("EVALUATE_CELLS",{sheetId:e})}mapDefinitionToRuntime(e){let t=[];if(e.labelRange)e.labelRange.invalidXc||e.labelRange.invalidSheetName||(t=this.getters.getRangeFormattedValues(e.labelRange).flat(1));else if(1===e.dataSets.length)for(let s=0;s<this.getData(e.dataSets[0],e.sheetId).length;s++)t.push("");else if(e.dataSets[0]){t=fs(0,this.getData(e.dataSets[0],e.sheetId).length).map((e=>e.toString()))}const s=this.getDefaultConfiguration(e,t),i=new Mh,o=[];if("pie"===e.type){const t=Math.max(...e.dataSets.map((t=>this.getData(t,e.sheetId).length)));for(let e=0;e<=t;e++)o.push(i.next())}for(const[t,n]of Object.entries(e.dataSets)){let r;if(n.labelCell){const e=n.labelCell,s=e?this.getters.getCell(e.sheetId,e.zone.left,e.zone.top):void 0;r=s&&e?this.truncateLabel(s.formattedValue):r=`${lc.Series} ${parseInt(t)+1}`}else r=r=`${lc.Series} ${parseInt(t)+1}`;const a="pie"!==e.type?i.next():"#FFFFFF",l={label:r,data:n.dataRange?this.getData(n,e.sheetId):[],lineTension:0,borderColor:a,backgroundColor:a};"pie"===e.type&&(l.backgroundColor=o),s.data.datasets.push(l)}return s}getData(e,t){if(e.dataRange){const t=e.labelCell?[ks(e.labelCell.zone)]:[],s=Vs([ks(e.dataRange.zone)],t)[0];if(void 0===s)return[];const i=this.getters.getRangeFromSheetXC(e.dataRange.sheetId,s);return this.getters.getRangeValues(i).flat(1)}return[]}}Ah.getters=["getChartRuntime"],Ah.modes=["normal"];class _h extends vh{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.uuidGenerator=new si,this.rulePredicate={CellIsRule:(e,t)=>{var s,i,o,n,r,l;if(e&&e.evaluated.type===ke.error)return!1;const c=t.values.map(Wr);switch(t.operator){case"IsEmpty":return!Ls(e)||""===(null===(s=e.evaluated.value)||void 0===s?void 0:s.toString().trim());case"IsNotEmpty":return Ls(e)&&""!==(null===(i=e.evaluated.value)||void 0===i?void 0:i.toString().trim());case"BeginsWith":return!(!e&&""===c[0])&&(Ls(e)&&(null===(o=e.evaluated.value)||void 0===o?void 0:o.toString().startsWith(c[0].toString())));case"EndsWith":return!(!e&&""===c[0])&&(Ls(e)&&(null===(n=e.evaluated.value)||void 0===n?void 0:n.toString().endsWith(c[0].toString())));case"Between":return Ls(e)&&e.evaluated.value>=c[0]&&e.evaluated.value<=c[1];case"NotBetween":return!(Ls(e)&&e.evaluated.value>=c[0]&&e.evaluated.value<=c[1]);case"ContainsText":return Ls(e)&&(null===(r=e.evaluated.value)||void 0===r?void 0:r.toString().indexOf(c[0].toString()))>-1;case"NotContains":return!Ls(e)||!e.evaluated.value||-1==(null===(l=e.evaluated.value)||void 0===l?void 0:l.toString().indexOf(c[0].toString()));case"GreaterThan":return Ls(e)&&e.evaluated.value>c[0];case"GreaterThanOrEqual":return Ls(e)&&e.evaluated.value>=c[0];case"LessThan":return Ls(e)&&e.evaluated.value<c[0];case"LessThanOrEqual":return Ls(e)&&e.evaluated.value<=c[0];case"NotEqual":return!(!Ls(e)&&""===c[0])&&(Ls(e)&&e.evaluated.value!==c[0]);case"Equal":return!e&&""===c[0]||Ls(e)&&e.evaluated.value===c[0];default:console.warn(a("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch(e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const s=this.getters.getActiveSheetId(),i=this.getters.getRulesByCell(s,e.originCol,e.originRow);for(const t of i)this.adaptRules(s,t,[is(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation);break;case"DUPLICATE_SHEET":case"CREATE_SHEET":case"DELETE_SHEET":case"ADD_CONDITIONAL_FORMAT":case"REMOVE_CONDITIONAL_FORMAT":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":case"UNDO":case"REDO":case"DELETE_CELL":case"INSERT_CELL":this.isStale=!0}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getConditionalStyle(e,t){var s;const i=this.getters.getActiveSheetId(),o=this.computedStyles[i];return o&&(null===(s=o[e])||void 0===s?void 0:s[t])}getConditionalIcon(e,t){var s;const i=this.getters.getActiveSheetId(),o=this.computedIcons[i];return o&&(null===(s=o[e])||void 0===s?void 0:s[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const s=this.computedStyles[t];for(let i of this.getters.getConditionalFormats(t))switch(i.rule.type){case"ColorScaleRule":for(let e of i.ranges)this.applyColorScale(e,i.rule);break;case"IconSetRule":for(let e of i.ranges)this.applyIcon(e,i.rule);break;default:for(let o of i.ranges){const n=Os(o);for(let o=n.top;o<=n.bottom;o++)for(let r=n.left;r<=n.right;r++){const n=this.rulePredicate[i.rule.type];let a=this.getters.getCell(t,r,o);n&&n(a,i.rule)&&(s[r]||(s[r]=[]),s[r][o]=Object.assign((null===(e=s[r])||void 0===e?void 0:e[o])||{},i.rule.style))}}}}parsePoint(e,t,s){switch(t.type){case"value":return this.getters.evaluateFormula(`=${s}(${e})`);case"number":return Number(t.value);case"percentage":const i=this.getters.evaluateFormula(`=min(${e})`);return i+(this.getters.evaluateFormula(`=max(${e})`)-i)*Number(t.value)/100;case"percentile":return this.getters.evaluateFormula(`=PERCENTILE(${e},${Number(t.value)/100})`);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return"number"==typeof o?o:null;default:return null}}applyIcon(e,t){const s=this.parsePoint(e,t.lowerInflectionPoint),i=this.parsePoint(e,t.upperInflectionPoint);if(null===s||null===i||s>i)return;const o=Os(e),n=this.getters.getActiveSheetId(),r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=o.top;e<=o.bottom;e++)for(let l=o.left;l<=o.right;l++){const o=this.getters.getCell(n,l,e);if((null==o?void 0:o.evaluated.type)!==ke.number)continue;const c=this.computeIcon(o.evaluated.value,i,t.upperInflectionPoint.operator,s,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,s,i,o,n){return"ge"===s&&e>=t||"gt"===s&&e>t?n[0]:"ge"===o&&e>=i||"gt"===o&&e>i?n[1]:n[2]}applyColorScale(e,t){var s;const i=this.parsePoint(e,t.minimum,"min"),o=t.midpoint?this.parsePoint(e,t.midpoint):null,n=this.parsePoint(e,t.maximum,"max");if(null===i||null===n||i>=n||o&&(i>=o||o>=n))return;const r=Os(e),a=this.getters.getActiveSheetId(),l=this.computedStyles[a],c=[];t.midpoint&&o?(c.push({minValue:i,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(i,o,t.minimum.color,t.midpoint.color)}),c.push({minValue:o,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.midpoint.color,t.maximum.color)})):c.push({minValue:i,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(i,n,t.minimum.color,t.maximum.color)});for(let e=r.top;e<=r.bottom;e++)for(let t=r.left;t<=r.right;t++){const r=this.getters.getCell(a,t,e);if((null==r?void 0:r.evaluated.type)===ke.number){const a=ps(r.evaluated.value,i,n);let h;h=2===c.length&&o?a<=o?this.colorCell(a,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(a,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(a,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(s=l[t])||void 0===s?void 0:s[e])||{},l[t][e].fillColor="#"+jt(h)}}}computeColorDiffUnits(e,t,s,i){const o=t-e;return[((s>>16)%256-(i>>16)%256)/o,((s>>8)%256-(i>>8)%256)/o,(s%256-i%256)/o]}colorCell(e,t,s,i){const[o,n,r]=i;return Math.round((s>>16)%256-o*(e-t))<<16|Math.round((s>>8)%256-n*(e-t))<<8|Math.round(s%256-r*(e-t))}adaptRules(e,t,s,i){if(0===s.length&&0===i.length)return;const o=this.getters.getConditionalFormats(e),n=o.findIndex((e=>e.id===t.id));let r=[];n>-1&&(r=o[n].ranges),r=r.concat(s);const a=Vs(r,i);0!==a.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},target:a.map(Os),sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e})}pasteCf(e,t,s){const i=is(t.col,t.row);for(let o of this.getters.getConditionalFormats(e.sheetId))for(let n of o.ranges)if(Bs(e.col,e.row,Os(n))){const n=o,r=[];if("CUT"===s&&r.push(is(e.col,e.row)),e.sheetId===t.sheetId)this.adaptRules(e.sheetId,n,[i],r);else{this.adaptRules(e.sheetId,n,[],r);const s=this.getCFToCopyTo(t.sheetId,n);this.adaptRules(t.sheetId,s,[i],[])}}}getCFToCopyTo(e,t){const s=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&As(e.rule,t.rule)));return s||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}_h.getters=["getConditionalStyle","getConditionalIcon"],_h.modes=["normal"];var Oh;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(Oh||(Oh={}));class Nh extends vh{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.replaceOptions={modifyFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(Oh.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(Oh.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith,e.replaceOptions);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith,e.replaceOptions);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(Oh.current)}updateRegex(){let e=hs(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),s=[];if(this.toSearch)for(const e of Object.values(t))if(e&&this.currentSearchRegex&&this.currentSearchRegex.test(this.searchOptions.searchFormulas&&e.isFormula()?e.content:String(e.evaluated.value))){const t=this.getters.getCellPosition(e.id),i={col:t.col,row:t.row,selected:!1};s.push(i)}return s.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let s;s=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,s=(s%t.length+t.length)%t.length,null!==this.selectedMatchIndex&&this.selectedMatchIndex===s||(this.selectedMatchIndex=s,this.dispatch("SELECT_CELL",{col:t[s].col,row:t[s].row}));for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.replaceOptions={modifyFormulas:!1}}replace(e,t){if(this.replaceOptions=t,null===this.selectedMatchIndex||!this.currentSearchRegex)return;const s=this.searchMatches[this.selectedMatchIndex],i=this.getters.getActiveSheetId(),o=this.getters.getCell(i,s.col,s.row),n=this.toReplace(o,i);if(o&&n){const t=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),i=n.toString().replace(t,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:s.col,row:s.row,content:i}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(Oh.current)}else this.selectNextCell(Oh.next)}replaceAll(e,t){const s=this.searchMatches.length;for(let i=0;i<s;i++)this.replace(e,t)}toReplace(e,t){if(e){if(this.searchOptions.searchFormulas&&e.isFormula())return e.content;if(this.replaceOptions.modifyFormulas||!e.isFormula())return e.evaluated.value.toString()}return null}drawGrid(e){const{ctx:t,viewport:s}=e,i=this.getters.getActiveSheetId();for(const e of this.searchMatches){const o=this.getters.getMerge(i,e.col,e.row),n=o?o.left:e.col,r=o?o.right:e.col,a=o?o.top:e.row,l=o?o.bottom:e.row,[c,h,d,u]=this.getters.getRect({top:a,left:n,right:r,bottom:l},s);d>0&&u>0&&(t.fillStyle="#8B008B33",t.fillRect(c,h,d,u),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(c,h,d,u)))}}}Nh.layers=[3],Nh.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class kh extends vh{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,s){const i=this.searchNumberFormat(e,t);if(void 0!==i){const o=this.changeDecimalFormat(i,s);this.dispatch("SET_FORMATTING",{sheetId:e,target:t,format:o})}}searchNumberFormat(e,t){var s;for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let o=i.left;o<=i.right;o++){const i=this.getters.getCell(e,o,t);if((null==i?void 0:i.evaluated.type)===ke.number&&!(null===(s=i.format)||void 0===s?void 0:s.match(A)))return i.format||this.setDefaultNumberFormat(i.evaluated.value)}}setDefaultNumberFormat(e){const t=e.toString().split(".");return 1===t.length?"0":"0."+Array(t[1].length+1).join("0")}changeDecimalFormat(e,t){const s=Math.sign(t),i=e.split(";");let o=[];for(let e of i){const t=e.indexOf("."),i=e.toUpperCase().indexOf("E");let n;const r=i>-1?e.slice(0,i):e,a=t>-1?r.slice(t).match(/0/g).length:0,l=r.lastIndexOf("0");l>-1?s>0?n=a<ne?e.slice(0,l+1)+(0===a?".0":"0")+e.slice(l+1):e:a>0?(n=e.slice(0,l)+e.slice(l+1),1===a&&(n=n.slice(0,t)+n.slice(t+1))):n=e:n=e,o.push(n)}return o.join(";")}}kh.modes=["normal"];class Fh extends vh{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){if(0===e.length)return[];const t=this.getters.getActiveSheetId(),s=[];for(let[i,o]of e){const{xc:e,sheetName:n}=es(i),r=n?this.getters.getSheetIdByName(n):t;if(r){let i=Os(e);const{height:n,width:a}=Zs(i);i=n*a==1?this.getters.expandZone(t,Os(e)):i,s.push({zone:i,color:o,sheet:r})}}return s.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getSheet(e.sheet).rows.length&&e.zone.right<this.getters.getSheet(e.sheet).cols.length))}drawGrid(e){const{ctx:t,viewport:s,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;for(let e of this.getHighlights().filter(((e,t)=>this.getHighlights().findIndex((t=>Us(t.zone,e.zone)&&t.sheet===o))===t))){const[i,o,r,a]=this.getters.getRect(e.zone,s);r>0&&a>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,r-n,a-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,r-2*n,a-2*n))}}}function $h(e,t){return e.isFormula()&&t?"left":e.defaultAlign}function Dh(e,t){let s=0,i=e.length-1;for(;s<=i;){const o=Math.floor((s+i)/2),n=e[o];if(t<n.start)i=o-1;else if(t>n.end)s=o+1;else{if(!n.isHidden)return o;s+=1}}return-1}Fh.modes=["normal"],Fh.layers=[1],Fh.getters=["getHighlights"];class Uh extends vh{constructor(){super(...arguments),this.boxes=[]}getColIndex(e,t,s){if(e<m)return-1;const i=(s||this.getters.getActiveSheet()).cols;return Dh(i,e-m+i[t].start+1)}getRowIndex(e,t,s){if(e<f)return-1;const i=(s||this.getters.getActiveSheet()).rows;return Dh(i,e-f+i[t].start+1)}getRect(e,t){const{left:s,top:i,right:o,bottom:n}=e;let{offsetY:r,offsetX:a}=t;a-=m,r-=f;const{cols:l,rows:c}=this.getters.getActiveSheet(),h=Math.max(l[s].start-a,m),d=l[o].end-a-h,u=Math.max(c[i].start-r,f);return[h,u,d,c[n].end-r-u]}isVisibleInViewport(e,t,s){const{right:i,left:o,top:n,bottom:r}=s;return t<=r&&t>=n&&e>=o&&e<=i}getEdgeScrollCol(e){let t=!1,s=0,i=0;const{width:o}=this.getters.getViewportDimension(),{width:n}=this.getters.getGridDimension(this.getters.getActiveSheet()),{left:r,offsetX:a}=this.getters.getActiveSnappedViewport();return e<m&&r>0?(t=!0,s=-1,i=as(m-e)):e>o&&a<n-o&&(t=!0,s=1,i=as(e-o)),{canEdgeScroll:t,direction:s,delay:i}}getEdgeScrollRow(e){let t=!1,s=0,i=0;const{height:o}=this.getters.getViewportDimension(),{height:n}=this.getters.getGridDimension(this.getters.getActiveSheet()),{top:r,offsetY:a}=this.getters.getActiveSnappedViewport();return e<f&&r>0?(t=!0,s=-1,i=as(f-e)):e>o&&a<n-o&&(t=!0,s=1,i=as(e-o)),{canEdgeScroll:t,direction:s,delay:i}}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(e),this.drawBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e);break;case 7:this.drawHeaders(e)}}drawBackground(e){const{ctx:t,viewport:s,thinLineWidth:i}=e;let{offsetX:o,offsetY:n,top:r,left:a,bottom:l,right:c}=s;const{width:h,height:d}=this.getters.getViewportDimension(),{cols:u,rows:p,id:g}=this.getters.getActiveSheet();if(t.fillStyle="white",t.fillRect(0,0,h,d),o-=m,n-=f,!this.getters.getGridLinesVisibility(g))return;t.lineWidth=2*i,t.strokeStyle="#E2E3E3",t.beginPath();const v=Math.min(d,p[l].end-n);for(let e=a;e<=c;e++){if(u[e].isHidden)continue;const s=u[e].end-o;t.moveTo(s,0),t.lineTo(s,v)}const E=Math.min(h,u[c].end-o);for(let e=r;e<=l;e++){if(p[e].isHidden)continue;const s=p[e].end-n;t.moveTo(0,s),t.lineTo(E,s)}t.stroke()}drawCellBackground(e){const{ctx:t,thinLineWidth:s}=e;t.lineWidth=.3*s;const i=.1*s;t.strokeStyle="#111";const o=this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());for(let e of this.boxes){let s=e.style;s&&s.fillColor&&"#ffffff"!==s.fillColor&&(t.fillStyle=s.fillColor,t.fillRect(e.x,e.y,e.width,e.height),o&&t.strokeRect(e.x+i,e.y+i,e.width-2*i,e.height-2*i)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawBorders(e){const{ctx:t,thinLineWidth:s}=e;for(let e of this.boxes){let t=e.border;if(t){const{x:s,y:o,width:n,height:r}=e;t.left&&i(t.left,s,o,s,o+r),t.top&&i(t.top,s,o,s+n,o),t.right&&i(t.right,s+n,o,s+n,o+r),t.bottom&&i(t.bottom,s,o+r,s+n,o+r)}}function i([e,i],o,n,r,a){t.strokeStyle=i,t.lineWidth=("thin"===e?2:3)*s,t.beginPath(),t.moveTo(o,n),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:s}=e;let i;t.textBaseline="middle";for(let e of this.boxes)if(e.text){const o=e.style||{},n=e.align,r=o.italic?"italic ":"",a=o.bold?"bold":T,l=o.fontSize||x,c=cs[l],h=`${r}${a} ${c}px ${R}`;let d;h!==i&&(i=h,t.font=h),t.fillStyle=o.textColor||"#000";let u=e.y+e.height/2+1;d="left"===n?e.x+(e.image?e.image.size+2*I:4):"right"===n?e.x+e.width-4:e.x+e.width/2,t.textAlign=n,e.clipRect&&(t.save(),t.beginPath(),t.rect(...e.clipRect),t.clip()),t.fillText(e.text,Math.round(d),Math.round(u)),(o.strikethrough||o.underline)&&("right"===n?d-=e.textWidth:"center"===n&&(d-=e.textWidth/2),o.strikethrough&&t.fillRect(d,u,e.textWidth,2.6*s),o.underline&&(u=e.y+e.height/2+1+c/2,t.fillRect(d,u,e.textWidth,1.3*s))),e.clipRect&&t.restore()}}async drawIcon(e){const{ctx:t}=e;for(let e of this.boxes)if(e.image){let s=e.x,i=e.y;const o=e.image.image,n=e.image.size,r=(e.height-n)/2;e.image.clipIcon&&(t.save(),t.beginPath(),t.rect(...e.image.clipIcon),t.clip()),t.drawImage(o,s+I,i+r,n,n),e.image.clipIcon&&t.restore()}}drawHeaders(e){const{ctx:t,viewport:s,thinLineWidth:i}=e;let{offsetX:o,offsetY:n,left:r,top:a,right:l,bottom:p}=s;const{width:g,height:v}=this.getters.getViewportDimension();o-=m,n-=f;const E=this.getters.getSelectedZones(),{cols:S,rows:b}=this.getters.getActiveSheet(),C=this.getters.getActiveCols(),I=this.getters.getActiveRows();t.fillStyle=c,t.font=`400 11px ${R}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333",t.fillRect(0,0,g,f),t.fillRect(0,0,m,v),t.fillStyle=h;for(let e of E){const s=Math.max(m,S[e.left].start-o),i=Math.max(m,S[e.right].end-o),r=Math.max(f,b[e.top].start-n),a=Math.max(f,b[e.bottom].end-n);t.fillStyle=C.has(e.left)?d:h,t.fillRect(s,0,i-s,f),t.fillStyle=I.has(e.top)?d:h,t.fillRect(0,r,m,a-r)}t.beginPath(),t.moveTo(m,0),t.lineTo(m,v),t.moveTo(0,f),t.lineTo(g,f),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(let e=r;e<=l;e++){const s=S[e];s.isHidden||(t.fillStyle=C.has(e)?"#fff":u,t.fillText(s.name,(s.start+s.end)/2-o,13),t.moveTo(s.end-o,0),t.lineTo(s.end-o,f))}for(let e=a;e<=p;e++){const s=b[e];s.isHidden||(t.fillStyle=I.has(e)?"#fff":u,t.fillText(s.name,24,(s.start+s.end)/2-n),t.moveTo(0,s.end-n),t.lineTo(m,s.end-n))}t.stroke()}hasContent(e,t){const s=this.getters.getActiveSheetId(),i=this.getters.getCell(s,e,t);return i&&!i.isEmpty()||this.getters.isInMerge(s,e,t)}getGridBoxes(e){const{viewport:t}=e;let{right:s,left:i,top:o,bottom:n,offsetX:r,offsetY:a}=t;r-=m,a-=f;const l=this.getters.shouldShowFormulas(),c=[],{cols:h,rows:d,id:u}=this.getters.getActiveSheet();for(let e=o;e<=n;e++){const t=d[e];if(!t.isHidden)for(let o=i;o<=s;o++){const n=h[o];if(n.isHidden)continue;let d=t.cells[o];const p=this.getters.getCellBorder(u,o,e),g=this.getters.getConditionalStyle(o,e),f=this.getters.getConditionalIcon(o,e);if(!this.getters.isInMerge(u,o,e))if(d){const u=this.getters.getCellText(d,l);let m=this.getters.getCellStyle(d);g&&(m=Object.assign({},m,g));let v=u?m&&m.align||$h(d,l):void 0,E=null,S=null;const b=this.getters.getTextWidth(d),C=m.fontSize||x,y=cs[C],w=f?y+2*I:0,T=w+b>h[o].size||cs[C]>t.size;if(T&&d.evaluated.type===ke.number&&(v="center"!==v?"left":v),f){const e=n.end-n.start;E=[n.start-r+w,t.start-a,Math.max(0,e-w),t.size],S=[n.start-r,t.start-a,Math.min(w,e),t.size]}else if(T){let l,c;switch(v){case"left":for(l=o;l<s&&!this.hasContent(l+1,e);)l++;c=h[l].end-n.start,(c<b||cs[C]>t.size)&&(E=[n.start-r,t.start-a,c,t.size]);break;case"right":for(l=o;l>i&&!this.hasContent(l-1,e);)l--;c=n.end-h[l].start,(c<b||cs[C]>t.size)&&(E=[h[l].start-r,t.start-a,c,t.size]);break;case"center":let d=o;for(;d>i&&!this.hasContent(d-1,e);)d--;let u=o;for(;u<s&&!this.hasContent(u+1,e);)u++;const p=Math.min(d,o),g=Math.max(u,o);c=h[g].end-h[p].start,(c<b||p===o||g===o||cs[C]>t.size)&&(E=[h[p].start-r,t.start-a,c,t.size])}}c.push({x:n.start-r,y:t.start-a,width:n.size,height:t.size,text:u,textWidth:b,border:p,style:m,align:v,clipRect:E,error:d.evaluated.type===ke.error?d.evaluated.error:void 0,image:f?{type:"icon",size:y,clipIcon:S,image:Bl[f].img}:void 0})}else c.push({x:n.start-r,y:t.start-a,width:n.size,height:t.size,text:"",textWidth:0,border:p,style:g||null,align:void 0,clipRect:null,error:void 0})}}const p=this.getters.getActiveSheetId();for(let e of this.getters.getMerges(p))if(!this.getters.isMergeHidden(p,e)&&Ps(e,t)){const t=this.getters.getCell(p,e.left,e.top),s=this.getters.getCellBorder(p,e.left,e.top),i=this.getters.getCellBorder(p,e.right,e.bottom),o=h[e.right].end-h[e.left].start;let n,u,g,f,m;if(g=t?this.getters.getCellStyle(t):null,t||i||s){n=t?this.getters.getCellText(t,l):"",u=t?this.getters.getTextWidth(t):null;const o=this.getters.getConditionalStyle(e.topLeft.col,e.topLeft.row);o&&(g=Object.assign({},g,o)),f=n?g&&g.align||$h(t,l):null,m={bottom:i?i.bottom:null,left:s?s.left:null,right:i?i.right:null,top:s?s.top:null}}g=g||{},g.fillColor&&"#ffffff"!==g.fillColor||(g=Object.create(g),g.fillColor="#fff");const v=h[e.left].start-r,E=d[e.top].start-a,S=d[e.bottom].end-d[e.top].start,b=this.getters.getConditionalIcon(e.left,e.top),C=g.fontSize||x,y=cs[C],w=b?2*I+y:0,T=w+u;f=n&&(null==t?void 0:t.evaluated.type)===ke.number&&T>o&&"center"!==f?"left":f;const R=b?[v+w,E,Math.max(0,o-w),S]:[v,E,o,S],L=b?[v,E,Math.min(w,o),S]:null;c.push({x:v,y:E,width:o,height:S,text:n,textWidth:u,border:m,style:g,align:f,clipRect:R,error:t&&t.evaluated.type===ke.error?t.evaluated.error:void 0,image:b?{type:"icon",clipIcon:L,size:y,image:Bl[b].img}:void 0})}return c}}Uh.layers=[0,7],Uh.getters=["getColIndex","getRowIndex","getRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow"],Uh.modes=["normal"];const Ph=new si;class Bh extends vh{constructor(){super(...arguments),this.inputs={},this.activeSheets={},this.inputHasSingleRange={},this.focusedInputId=null,this.focusedRange=null,this.willAddNewRange=!1}allowDispatch(e){switch(e.type){case"FOCUS_RANGE":const t=this.getIndex(e.id,e.rangeId);if(this.focusedInputId===e.id&&this.focusedRange===t)return 24;break;case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange[e.id]&&1===this.inputs[e.id].length)return 25}return 0}handle(e){switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id],delete this.activeSheets[e.id],delete this.inputHasSingleRange[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(e.id,this.getIndex(e.id,e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.id,e.rangeId);if(null!==t){const s=e.id;this.focusedInputId===s&&this.focusedRange===t||this.dispatch("FOCUS_RANGE",{id:s,rangeId:this.inputs[s][t].id});const i=e.value.split(",").map((e=>e.trim()));this.setRange(s,t,i)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(e.id,this.inputs[e.id].length,[""]),this.focusLast(e.id);break;case"REMOVE_RANGE":const t=this.getIndex(e.id,e.rangeId);null!==t&&this.removeRange(e.id,t);break;case"SELECT_CELL":case"SET_SELECTION":if(!this.focusedInputId)break;const s=this.getSelectionInputValue(this.focusedInputId),i=(this.inputHasSingleRange[this.focusedInputId]?[this.getters.getSelectedZone()]:this.getters.getSelectedZones()).map(ks).filter((e=>!s.includes(e))),o=this.activeSheets[this.focusedInputId],n=this.getters.getActiveSheetId(),r=this.getters.getSheetName(n);this.add(i.map((e=>n===o?e:`${us(r)}!${e}`)));break;case"PREPARE_SELECTION_EXPANSION":{const[e,t]=[this.focusedInputId,this.focusedRange];null===e||null===t||this.inputHasSingleRange[e]||(this.willAddNewRange=""!==this.inputs[e][t].xc.trim());break}}}getSelectionInput(e){return this.inputs[e]?this.inputs[e].map(((t,s)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.focusedRange&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.focusedRange===s}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:s}=es(e);return null!==t.match(Jt)&&(!s||void 0!==this.getters.getSheetIdByName(s))}getSelectionInputValue(e){return this.cleanInputs(this.inputs[e].map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].map((e=>this.inputToHighlights(this.focusedInputId,e))).flat():[]}initInput(e,t,s=!1){this.inputs[e]=[],this.insertNewRange(e,0,t),this.activeSheets[e]=this.getters.getActiveSheetId(),this.inputHasSingleRange[e]=s,0===this.inputs[e].length&&this.dispatch("ADD_EMPTY_RANGE",{id:e})}focus(e,t){this.focusedInputId=e,this.focusedRange=t}focusLast(e){this.focus(e,this.inputs[e].length-1)}unfocus(){this.focusedInputId=null,this.focusedRange=null}add(e){if(null===this.focusedInputId||null===this.focusedRange||this.getters.isSelectingForComposer()||0===e.length)return;if(this.getters.getSelectionMode()===Ih.expanding&&this.willAddNewRange){const t=this.focusedInputId;this.insertNewRange(t,this.inputs[t].length,e),this.focusLast(this.focusedInputId),this.willAddNewRange=!1}else this.setRange(this.focusedInputId,this.focusedRange,e)}setContent(e,t,s){this.inputs[e][t]={...this.inputs[e][t],id:Ph.uuidv4(),xc:s}}insertNewRange(e,t,s){this.inputs[e].splice(t,0,...s.map(((t,s)=>({xc:t,id:(this.inputs[e].length+s+1).toString(),color:Xt()}))))}setRange(e,t,s){const[,...i]=s;this.setContent(e,t,s[0]),this.insertNewRange(e,t+1,i),i.length&&this.focus(e,t+i.length)}removeRange(e,t){this.inputs[e].splice(t,1),this.focusedInputId===e&&null!==this.focusedRange&&this.focusLast(e)}inputToHighlights(e,{xc:t,color:s}){const i=this.cleanInputs([t]).filter((e=>this.isRangeValid(e))).filter((t=>this.shouldBeHighlighted(this.activeSheets[e],t)));if(0===i.length)return[];const[o,...n]=i,r=[[o,s||Xt()]];for(const e of n)r.push([e,Xt()]);return r}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:s}=es(t),i=this.getters.getSheetIdByName(s),o=this.getters.getActiveSheet().id;return this.isRangeValid(t)&&(i===o||void 0===i&&o===e)}getIndex(e,t){const s=this.inputs[e].findIndex((e=>e.id===t));return s>=0?s:null}}Bh.modes=["normal"],Bh.layers=[1],Bh.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class Vh{constructor(){this.bus=new i.core.EventBus}on(e,t,s){this.bus.on(e,t,s)}trigger(e,t){this.bus.trigger(e,t)}off(e,t){this.bus.off(e,t)}clear(){this.bus.clear()}}function Hh(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?function(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--;if(!(o>n))return{...e,[t]:o,[i]:n}}(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?function(e,t,s,i,o){const n="left"===t?"columns":"rows",r="before"===i?s-1:s,a="left"===t?"right":"bottom",l="before"===i?e[a]>r:e[a]>=r;return e[t]<=r&&l?qs(e,n,"RESIZE",o):r<e[t]?qs(e,n,"MOVE",o):{...e}}(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function zh(e,t){const s=e.definition;let i,o;return s.labelRange&&(i=Hh(Os(s.labelRange),t)),s.dataSets&&(o=s.dataSets.map(Os).map((e=>Hh(e,t))).filter(Ls).map(ks)),{...e,definition:{...s,dataSets:o,labelRange:i?ks(i):void 0}}}ul.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],zh),ul.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],zh),ul.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),ul.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var s;if(e.name===t.name)return{...e,name:(null===(s=e.name)||void 0===s?void 0:s.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),ul.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const s=[];for(const i of e.target)for(const e of t.target)Ps(i,e)||s.push({...i});if(s.length)return{...e,target:s};return}));const Zh=[{match:function(e){return"sheetId"in e},fn:function(e,t){const s="DELETE_SHEET"===t.type&&t.sheetId;if(e.sheetId===s)return"IGNORE_COMMAND";if("CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId)return e;return"SKIP_TRANSFORMATION"}},{match:function(e){return"target"in e},fn:function(e,t){const s=[];for(const i of e.target){const e=Hh(i,t);e&&s.push(e)}if(!s.length)return"IGNORE_COMMAND";return{...e,target:s}}},{match:function(e){return"col"in e&&"row"in e},fn:function(e,t){if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const s="COL"===t.dimension?"col":"row";let i=e[s];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(i))return"IGNORE_COMMAND";for(let t of e)i>=t&&i--}"ADD_COLUMNS_ROWS"===t.type&&(i>t.base||i===t.base&&"before"===t.position)&&(i+=t.quantity);return{...e,[s]:i}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const s of t.target){if(!(e.col===s.left&&e.row===s.top)&&Bs(e.col,e.row,s))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e},fn:function(e,t){if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const s="ADD_COLUMNS_ROWS"===e.type,i=s?"base":"elements";let o=s?[e[i]]:e[i];if("REMOVE_COLUMNS_ROWS"===t.type&&(o=o.map((e=>{if(t.elements.includes(e))return;const s=t.elements.sort(((e,t)=>t-e));for(let t of s)e>t&&e--;return e})).filter(Ls)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;o=o.map((s=>s>e?s+t.quantity:s))}if(o.length){let t=o;return s&&(t=o[0]),{...e,[i]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}}];function Gh(e,t){const s=ul.getTransformation(e.type,t.type);return s?s(e,t):function(e,t){for(const{match:s,fn:i}of Zh)if(s(e)){const s=i(e,t);if("SKIP_TRANSFORMATION"===s)continue;if("IGNORE_COMMAND"===s)return;return s}return e}(e,t)}function Wh(e,t){let s=[...e];for(const e of t)s=s.map((t=>Gh(t,e))).filter(Ls);return s}class qh{constructor(e,t,s,i){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...s],this._changes=i?[...i]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class jh extends Error{}class Yh extends Vh{constructor(e,t,s=O){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=s,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new si,this.debouncedMove=i.utils.debounce(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const s=new qh(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(s.id,s),this.trigger("new-local-state-update",{id:s.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:s.id,clientId:s.clientId,commands:s.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new jh("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(Ls))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const s=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==s?void 0:s.col)===e.col&&s.row===e.row&&s.sheetId===e.sheetId)return;const i=s?"CLIENT_MOVED":"CLIENT_JOINED",o=this.getClient();this.clients[this.clientId]={...o,position:e},this.transportService.sendMessage({type:i,version:1,client:{...o,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":const{clientId:t,commands:s}=e,i=new qh(e.nextRevisionId,t,s);if(i.clientId!==this.clientId){this.revisions.insert(i.id,i,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:Wh(s,t)})}break;case"SNAPSHOT_CREATED":{const t=new qh(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Xh=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class Kh extends vh{constructor(){super(...arguments),this.availableColors=new Set(Xh),this.colors={}}isPositionValid(e){const t=this.getters.getSheet(e.sheetId);return e.row<t.rows.length&&e.col<t.cols.length}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(Xh));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof jh)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const s of this.getters.getConnectedClients())if(s.id!==this.getters.getClient().id&&s.position&&s.position.sheetId===e&&this.isPositionValid(s.position)){const e=s.position;this.colors[s.id]||(this.colors[s.id]=this.chooseNewColor());const i=this.colors[s.id];t.push({...s,position:e,color:i})}return t}drawGrid(e){const{viewport:t,ctx:s,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:r}=e.position,a=this.getters.expandZone(o,{top:n,bottom:n,left:r,right:r}),[l,c,h,d]=this.getters.getRect(a,t);if(h<=0||d<=0)continue;const u=e.color,p=`${u}10`;s.fillStyle=p,s.lineWidth=4*i,s.strokeStyle=u,s.globalCompositeOperation="multiply",s.fillRect(l,c,h,d),s.globalCompositeOperation="source-over",s.strokeRect(l,c,h,d),s.font=`bold ${x+1}px ${R}`}}}Kh.getters=["getClientsToDisplay"],Kh.layers=[5],Kh.modes=["normal"];class Qh extends vh{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Bs(e.anchor[0],e.anchor[1],e.zone))throw new Error(a("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)e.interactive?this.interactiveSortSelection(e.sheetId,e.anchor,e.zone,e.sortDirection):this.sortZone(e.sheetId,e.anchor,e.zone,e.sortDirection)}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;for(let s=t.top;s<=t.bottom;s++)for(let i=t.left;i<=t.right;i++)if(!this.getters.isInMerge(e,i,s))return 48;return 0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const s=this.getters.getMerges(e).filter((e=>Ps(e,t))),i=Zs(s[0]);let[o,n]=[i.width,i.height];return s.every((e=>{let[t,s]=[e.right-e.left+1,e.bottom-e.top+1];return t===o&&s===n}))?0:48}interactiveSortSelection(e,t,s,i){let o=Pe.Success,n=s.right>s.left;if(this.getters.doesIntersectMerge(e,s)){let t;n=!1;for(let i=s.top;i<=s.bottom;i++){t=[];for(let o=s.left;o<=s.right;o++){let s=this.getters.getMerge(e,o,i);s&&!t.includes(s.id.toString())&&t.push(s.id.toString())}if(t.length>=2){n=!0;break}}}if(n)o=this.dispatch("SORT_CELLS",{sheetId:e,anchor:t,zone:s,sortDirection:i});else{const n=this.getContiguousZone(e,s);Us(n,s)?o=this.dispatch("SORT_CELLS",{sheetId:e,anchor:t,zone:s,sortDirection:i}):this.ui.askConfirmation(a("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{s=n,o=this.dispatch("SORT_CELLS",{sheetId:e,anchor:t,zone:s,sortDirection:i})}),(()=>{o=this.dispatch("SORT_CELLS",{sheetId:e,anchor:t,zone:s,sortDirection:i})}))}o.isCancelledBecause(48)&&(this.dispatch("SET_SELECTION",{anchor:t,zones:[s],anchorZone:s}),this.ui.notifyUser(a("Cannot sort. To sort, select only cells or only merges that have the same size.")))}expand(e,t){const{left:s,right:i,top:o,bottom:n}=this.getters.expandZone(e.id,t);return{left:Math.max(0,s),right:Math.min(e.cols.length-1,i),top:Math.max(0,o),bottom:Math.min(e.rows.length-1,n)}}checkExpandedValues(e,t){const s=this.expand(e,t),i=e.id;let o,n=[];if(this.getters.doesIntersectMerge(i,s)){const{left:e,right:t,top:r,bottom:a}=s;for(let s=e;s<=t;s++)for(let e=r;e<=a;e++){const[t,r]=this.getters.getMainCell(i,s,e);o=this.getters.getCell(i,t,r),n.push((null==o?void 0:o.formattedValue)||"")}}else{const t=zs(s,e,(e=>e.formattedValue),"");n=t.flat()}return n.some((e=>""!==e))}getContiguousZone(e,t){let s,{top:i,bottom:o,left:n,right:r}=t;const a=this.getters.getSheet(e);let l=!1;for(;!l;)l=!0,i>0&&(s=this.checkExpandedValues(a,{left:n-1,right:r+1,top:i-1,bottom:i-1}),s&&(l=!1,i--)),n>0&&(s=this.checkExpandedValues(a,{left:n-1,right:n-1,top:i-1,bottom:o+1}),s&&(l=!1,n--)),r<a.cols.length-1&&(s=this.checkExpandedValues(a,{left:r+1,right:r+1,top:i-1,bottom:o+1}),s&&(l=!1,r++)),o<a.rows.length-1&&(s=this.checkExpandedValues(a,{left:n-1,right:r+1,top:o+1,bottom:o+1}),s&&(l=!1,o++));return{left:n,right:r,top:i,bottom:o}}hasHeader(e,t,s,i){const{left:o,right:n,top:r,bottom:a}=t;if(a-r+1==1)return!1;let l=zs({left:o,right:n,top:r,bottom:r+2*i-1},e,(e=>e.evaluated.type),ke.empty,s,i);return l[0][0]===ke.empty&&(l=l.slice(1)),!l.some((e=>e[0]===ke.empty))&&!!l.some((e=>e[1]!==ke.empty&&e[0]!==e[1]))}sortCellsList(e,t){const s=e.map(((e,t)=>({index:t,val:e}))),i=s.filter((e=>!(null==e.val||""===e.val.evaluated.value))),o=s.filter((e=>null==e.val||""===e.val.evaluated.value)),n="descending"===t?-1:1,r=[ke.number,ke.error,ke.text,ke.boolean];return i.map((e=>{return{index:e.index,val:(t=e.val,{type:t.evaluated.type,value:t.evaluated.value})};var t})).sort(((e,t)=>{let s=r.indexOf(e.val.type)-r.indexOf(t.val.type);return 0===s&&(s=e.val.type===ke.text||e.val.type===ke.error?e.val.value.localeCompare(t.val.value):e.val.value-t.val.value),n*s})).concat(o)}sortZone(e,t,s,i){let o=1,n=1,r=t[0],a=Object.assign({},s);if(this.getters.doesIntersectMerge(e,a)){const[s,i]=t,a=this.getters.getMerge(e,s,i);o=a.right-a.left+1,n=a.bottom-a.top+1,r=a.topLeft.col}const l=this.getters.getSheet(e);this.hasHeader(l,a,o,n)&&(a.top+=n);const c=zs(a,l,(e=>e),void 0,o,n),h=c[r-a.left],d=this.sortCellsList(h,i).map((e=>e.index)),[u,p]=[c.length,c[0].length];for(let t=0;t<u;t++)for(let s=0;s<p;s++){let i=c[t][d[s]],r=a.left+t*o,l=a.top+s*n,h={sheetId:e,col:r,row:l,content:"",value:""};if(i){let t=i.content;if(i.isFormula()){const s=l-this.getters.getCellPosition(i.id).row,o=this.getters.createAdaptedRanges(i.dependencies.references,0,s,e);t=this.getters.buildFormulaContent(e,i.normalizedText,{...i.dependencies,references:o})}h.style=i.style,h.content=t,h.format=i.format,h.value=i.evaluated.value}this.dispatch("UPDATE_CELL",h)}}}Qh.getters=["getContiguousZone"];class Jh extends vh{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}Jh.modes=["normal"],Jh.getters=["shouldShowFormulas"];class ed extends vh{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":case"DELETE_SHEET_CONFIRMATION":try{this.getters.getSheet(e.sheetId);break}catch(e){return 23}}return 0}handle(e){switch(e.type){case"RENAME_SHEET":e.interactive&&this.interactiveRenameSheet(e.sheetId,a("Rename Sheet"));break;case"DELETE_SHEET_CONFIRMATION":this.interactiveDeleteSheet(e.sheetId);break;case"ADD_MERGE":e.interactive&&this.interactiveMerge(e.sheetId,e.target);break;case"AUTORESIZE_COLUMNS":for(let t of e.cols){const s=this.getColMaxWidth(e.sheetId,t);0!==s&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:s+6,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows){const s=this.getRowMaxHeight(e.sheetId,t);0!==s&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:s+6,sheetId:e.sheetId})}}}getCellWidth(e){let t=this.getTextWidth(e);const s=this.getters.getCellPosition(e.id);return this.getters.getConditionalIcon(s.col,s.row)&&(t+=function(e,t){const s=t.fontSize||x;return cs[s]+2*I}(this.ctx,this.getters.getCellStyle(e))),t}getTextWidth(e){const t=this.getters.getCellText(e,this.getters.shouldShowFormulas());return gs(this.ctx,t,this.getters.getCellStyle(e))}getCellHeight(e){const t=this.getters.getCellStyle(e).fontSize||x;return cs[t]}getCellText(e,t=!1){return t&&(e.isFormula()||e.evaluated.type===ke.error)?e.content:e.formattedValue}getColMaxWidth(e,t){const s=this.getters.getColCells(e,t).map((e=>this.getCellWidth(e)));return Math.max(0,...s)}getRowMaxHeight(e,t){const s=this.getters.getSheet(e),i=Object.values(s.rows[t].cells).map((e=>this.getCellHeight(e)));return Math.max(0,...i)}interactiveRenameSheet(e,t){const s=this.getters.getSheetName(e);this.ui.editText(t,s,(t=>{if(!t)return;const s=this.dispatch("RENAME_SHEET",{sheetId:e,name:t}),i=this.getters.getSheetName(e);s.isSuccessful||i===t||this.interactiveRenameSheet(e,a("Please enter a valid sheet name"))}))}interactiveDeleteSheet(e){this.ui.askConfirmation(a("Are you sure you want to delete this sheet ?"),(()=>{this.dispatch("DELETE_SHEET",{sheetId:e})}))}interactiveMerge(e,t){const s=this.dispatch("ADD_MERGE",{sheetId:e,target:t});s.isSuccessful||s.isCancelledBecause(3)&&this.ui.askConfirmation(a("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),(()=>{this.dispatch("ADD_MERGE",{sheetId:e,target:t,force:!0})}))}}ed.getters=["getCellWidth","getCellHeight","getTextWidth","getCellText"];class td extends vh{constructor(){super(...arguments),this.viewports={},this.snappedViewports={},this.updateSnap=!1,this.clientWidth=1e3,this.clientHeight=1e3}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkOffsetValidity(e.offsetX,e.offsetY);case"RESIZE_VIEWPORT":return e.width<0||e.height<0?54:0;default:return 0}}handle(e){switch(e.type){case"UNDO":case"REDO":this.cleanViewports(),this.resetViewports();break;case"RESIZE_VIEWPORT":this.cleanViewports(),this.resizeViewport(e.height,e.width);break;case"SET_VIEWPORT_OFFSET":this.setViewportOffset(e.offsetX,e.offsetY);break;case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":"COL"===e.dimension?this.adjustViewportOffsetX(e.sheetId,this.getViewport(e.sheetId)):this.adjustViewportOffsetY(e.sheetId,this.getViewport(e.sheetId));break;case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":"COL"===e.dimension?this.adjustViewportZoneX(e.sheetId,this.getViewport(e.sheetId)):this.adjustViewportZoneY(e.sheetId,this.getViewport(e.sheetId));break;case"ACTIVATE_SHEET":this.refreshViewport(e.sheetIdTo);break;case"SELECT_CELL":case"MOVE_POSITION":this.refreshViewport(this.getters.getActiveSheetId())}}finalize(){this.updateSnap&&(this.snapViewportToCell(this.getters.getActiveSheetId()),this.updateSnap=!1)}getViewportDimension(){return{width:this.clientWidth,height:this.clientHeight}}getActiveViewport(){const e=this.getters.getActiveSheetId();return this.getViewport(e)}getActiveSnappedViewport(){const e=this.getters.getActiveSheetId();return this.getSnappedViewport(e)}getGridDimension(e){const t=ni(e,"cols"),s=this.clientWidth-m,i=ni(e,"rows"),o=this.clientHeight-f,n=e.cols.find((e=>e.end>t.end-s))||e.cols[e.cols.length-1],r=e.rows.find((e=>e.end>i.end-o))||e.rows[e.rows.length-1];return{width:t.end+Math.max(E,Math.min(n.size,s-t.size)),height:i.end+Math.max(S+5,Math.min(r.size,o-i.size))}}getMaximumViewportOffset(e){const{width:t,height:s}=this.getters.getGridDimension(e);return{maxOffsetX:Math.max(0,t-this.clientWidth+m+1),maxOffsetY:Math.max(0,s-this.clientHeight+f+1)}}checkOffsetValidity(e,t){const s=this.getters.getActiveSheet(),{maxOffsetX:i,maxOffsetY:o}=this.getMaximumViewportOffset(s);return e<0||t<0||t>o||e>i?53:0}getSnappedViewport(e){return this.snapViewportToCell(e),this.snappedViewports[e]}getViewport(e){return this.viewports[e]?this.viewports[e]:this.generateViewportState(e)}cleanViewports(){const e=this.getters.getVisibleSheets();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetViewports(){for(let[e,t]of Object.entries(this.viewports))this.adjustViewportOffsetX(e,t),this.adjustViewportOffsetY(e,t),this.adjustViewportsPosition(e)}adjustViewportOffsetX(e,t){const{offsetX:s}=t,{width:i}=this.getGridDimension(this.getters.getSheet(e));if(this.clientWidth-m+s>i){const e=this.clientWidth-m+s-i;t.offsetX=Math.max(0,s-e)}this.adjustViewportZoneX(e,t)}adjustViewportOffsetY(e,t){const{offsetY:s}=t,{height:i}=this.getGridDimension(this.getters.getSheet(e));if(this.clientHeight-f+s>i){const e=this.clientHeight-f+s-i;t.offsetY=Math.max(0,s-e)}this.adjustViewportZoneY(e,t)}resizeViewport(e,t){this.clientHeight=e,this.clientWidth=t,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.adjustViewportOffsetX(e,this.viewports[e]),this.adjustViewportOffsetY(e,this.viewports[e])}setViewportOffset(e,t){const s=this.getters.getActiveSheetId();this.getActiveViewport(),this.viewports[s].offsetX=e,this.viewports[s].offsetY=t,this.adjustViewportZone(s,this.viewports[s])}generateViewportState(e){return this.viewports[e]={left:0,right:0,top:0,bottom:0,offsetX:0,offsetY:0},this.viewports[e]}refreshViewport(e){const t=this.getViewport(e);this.adjustViewportZone(e,t),this.adjustViewportsPosition(e)}adjustViewportZone(e,t){this.adjustViewportZoneX(e,t),this.adjustViewportZoneY(e,t)}adjustViewportZoneX(e,t){const s=this.getters.getSheet(e),i=s.cols;t.left=this.getters.getColIndex(t.offsetX+m,0,s);const o=this.clientWidth+t.offsetX-m;t.right=i.length-1;for(let e=t.left;e<i.length;e++)if(o<i[e].end){t.right=e;break}this.updateSnap=!0}adjustViewportZoneY(e,t){const s=this.getters.getSheet(e),i=s.rows;t.top=this.getters.getRowIndex(t.offsetY+f,0,s);const o=this.clientHeight+t.offsetY-f;t.bottom=i.length-1;for(let e=t.top;e<i.length;e++)if(o<i[e].end){t.bottom=e;break}this.updateSnap=!0}adjustViewportsPosition(e,t){const s=this.getters.getSheet(e),{cols:i,rows:o}=s,n=this.getSnappedViewport(e);t=t||this.getters.getSheetPosition(e);const[r,a]=ii(s,...this.getters.getMainCell(e,t[0],t[1]));for(;i[r].end>n.offsetX+this.clientWidth-m&&n.offsetX<i[r].start;)n.offsetX=i[n.left].end,this.adjustViewportZoneX(e,n);for(;r<n.left;){const t=i.slice(0,n.left).reverse().findIndex((e=>!e.isHidden));n.offsetX=i[n.left-1-t].start,this.adjustViewportZoneX(e,n)}for(;o[a].end>n.offsetY+this.clientHeight-f&&n.offsetY<o[a].start;)n.offsetY=o[n.top].end,this.adjustViewportZoneY(e,n);for(;a<n.top;){const t=o.slice(0,n.top).reverse().findIndex((e=>!e.isHidden));n.offsetY=o[n.top-1-t].start,this.adjustViewportZoneY(e,n)}const{top:l,left:c}=this.viewports[e];l===n.top&&c===n.left||(this.viewports[e]=n),this.updateSnap=!1}snapViewportToCell(e){const{cols:t,rows:s}=this.getters.getSheet(e),i=this.getViewport(e),o=Object.assign({},i);this.adjustViewportOffsetX(e,o),this.adjustViewportOffsetY(e,o),o.offsetX=t[o.left].start,o.offsetY=s[o.top].start,this.adjustViewportZone(e,o),this.snappedViewports[e]=o}}td.getters=["getActiveViewport","getSnappedViewport","getActiveSnappedViewport","getViewportDimension","getGridDimension","getMaximumViewportOffset"],td.modes=["normal"];const sd=(new Le).add("sheet",wa).add("cell",va).add("merge",Ia).add("borders",fa).add("conditional formatting",ba).add("figures",Ca).add("chart",Ea),id=(new Le).add("selection",yh).add("ui_sheet",ed).add("ui_options",Jh).add("evaluation",Rh).add("evaluation_cf",_h).add("evaluation_chart",Ah).add("clipboard",Ch).add("edition",Th).add("highlight",Fh).add("selectionInput",Bh).add("viewport",td).add("grid renderer",Uh).add("autofill",Sh).add("find_and_replace",Nh).add("sort",Qh).add("automatic_sum",bh).add("format",kh).add("selection_multiuser",Kh);class od{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}class nd extends i.core.EventBus{constructor(){super(...arguments),this.registry=new Le}add(e,t){this.registry.add(e,t);const s=i.utils.debounce((()=>this.trigger("data-loaded",{id:e})),0);return t.on("data-loaded",this,(()=>s())),t.loadMetadata(),this}get(e){return this.registry.get(e)}getAll(){return this.registry.getAll()}remove(e){this.get(e).off("data-loaded",this),this.registry.remove(e)}async waitForReady(){const e=[];for(const t of this.getAll())e.push(t.get());return Promise.all(e)}}class rd extends i.core.EventBus{async loadMetadata(){this.metadataPromise||(this.metadataPromise=this._fetchMetadata().then((e=>(this.metadata=e,e)))),await this.metadataPromise}async get(e){return e&&e.forceFetch&&(this.data=void 0,this.dataPromise=void 0),await this.loadMetadata(),this.dataPromise||(this.dataPromise=this._fetch(e).then((e=>(this.data=e,this.lastUpdate=Date.now(),this.trigger("data-loaded"),e)))),this.dataPromise}getSync(){return this.data}getMetadataSync(){return this.metadata}getLastUpdate(){return this.lastUpdate}}function ad(e){return La.get(e.type)(e)}function ld(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class cd{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const s of this.operations){if(s.id===e)return e;if(s.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const s=this.buildTransformation.with(e.data),{before:i,operation:o,after:n}=this.locateOperation(t);this.operations=[...i,o,e,...n.map((e=>e.transformed(s)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new cd(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:s}=this.locateOperation(e);this.operations=t.concat([s])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class hd{constructor(e,t){this.id=e,this.data=t}transformed(e){return new hd(this.id,e(this.data))}}class dd{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new dd(function*(e,t){for(const s of e)if(yield s,s.operation.id===t)return}(this.operations,e))}stopBefore(e){return new dd(function*(e,t){for(const s of e){if(s.operation.id===t)return;yield s}}(this.operations,e))}startAfter(e){return new dd(function*(e,t){let s=!0;for(const i of e)s||(yield i),i.operation.id===t&&(s=!1)}(this.operations,e))}}class ud{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new dd(vs(this._execution(e),this._execution(e)))}revertedExecution(e){return new dd(vs(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var s;const i=e.getLastOperationId()||(null===(s=this.previousBranch(e))||void 0===s?void 0:s.getLastOperationId());e.append(t),i&&this.insertPrevious(e,t,i)}insertOperationAfter(e,t,s){e.insert(t,s),this.updateNextWith(e,t,s),this.insertPrevious(e,t,s)}undo(e,t){const s=this.buildTransformation.without(t.data),i=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const o=e.fork(t.id);i&&this.branchingOperationIds.set(o,i),this.insertBranchAfter(e,o),this.transform(o,s)}redo(e){const t=this.nextBranch(e);if(!t)return;const s=this.nextBranch(t);this.removeBranchFromTree(t);const i=this.branchingOperationIds.get(t);i?this.branchingOperationIds.set(e,i):this.branchingOperationIds.delete(e),s&&this.rebaseUp(s)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const s of this.revertedExecution(e))if(s.operation.id===t)return s;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:s}=this.findPreviousBranchingOperation(e);if(!t||!s)return;const i=this.buildTransformation.without(s.data),o=t.fork(s.id);this.branchingOperationIds.set(o,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,o),o.transform(i);const n=this.nextBranch(o);n&&this.rebaseUp(n)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const s=this.branches.findIndex((t=>t===e));this.branches.splice(s+1,0,t)}updateNextWith(e,t,s){const i=this.branchingOperationIds.get(e),o=this.nextBranch(e);if(i&&o)if(e.getFirstOperationAmong(s,i)===i){const n=this.addToNextBranch(e,o,i,t,s);this.updateNextWith(o,n,s)}else{const e=this.buildTransformation.with(t.data);this.transform(o,e)}}addToNextBranch(e,t,s,i,o){let n=i;return o===s?(n=this.getTransformedOperation(e,s,i),t.prepend(n)):t.contains(o)?(n=this.getTransformedOperation(e,s,i),t.insert(n,o)):t.append(i),n}getTransformedOperation(e,t,s){const i=e.getOperation(t),o=this.buildTransformation.without(i.data);return s.transformed(o)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const s=this.nextBranch(e);s&&this.transform(s,t)}insertPrevious(e,t,s){const{previousBranch:i,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!i||!o)return;const n=this.buildTransformation.with(o.data),r=e.fork(s);r.transform(n),i.cutAfter(s),i.appendBranch(r);const a=t.transformed(n);this.insertPrevious(i,a,s)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const s=this.branchingOperationIds.get(t);return s?{previousBranch:t,branchingOperation:t.getOperation(s)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let s=!!t;const i=e.getOperations();for(let o=i.length-1;o>=0;o--){const n=i[o];n.id===t&&(s=!1),s||(yield{operation:n,branch:e,isCancelled:!this.shouldExecute(e,n)})}const o=this.previousBranch(e);yield*o?this._revertedExecution(o):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class pd{constructor(e,t,s,i,o){this.applyOperation=t,this.revertOperation=s,this.buildEmpty=i,this.buildTransformation=o,this.HEAD_BRANCH=new cd(this.buildTransformation),this.tree=new ud(o,this.HEAD_BRANCH);const n=new hd(e,i(e));this.tree.insertOperationLast(this.HEAD_BRANCH,n),this.HEAD_OPERATION=n}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const s=new hd(e,t),i=this.tree.getLastBranch();this.tree.insertOperationLast(i,s),this.HEAD_BRANCH=i,this.HEAD_OPERATION=s}insert(e,t,s){const i=new hd(e,t);this.revertTo(s),this.tree.insertOperationAfter(this.HEAD_BRANCH,i,s),this.fastForward()}undo(e,t,s){const{branch:i,operation:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(i,o),this.fastForward(),this.insert(t,this.buildEmpty(t),s)}redo(e,t,s){const{branch:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(i),this.fastForward(),this.insert(t,this.buildEmpty(t),s)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:s,isCancelled:i}of e)i||this.revertOperation(s.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:s,isCancelled:i}of e)i||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=s}}function gd(e,t,s){return new pd(e,(e=>{const i=e.commands.slice(),{changes:o}=t((()=>{for(const e of i)s(e)}));e.setChanges(o)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){fd(t.changes[e],"before")}}([e])),(e=>new qh(e,"empty",[],[])),{with:e=>t=>new qh(t.id,t.clientId,Wh(t.commands,e.commands)),without:e=>t=>new qh(t.id,t.clientId,Wh(t.commands,e.commands.map(ad).flat()))})}function fd(e,t){let s=e.path[0];const i=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const i=e.path[t];if(void 0===s[i]){const o=e.path[t+1];s[i]=ld(o)}s=s[i]}void 0===e[t]?delete s[i]:s[i]=e[t]}class md extends i.core.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class vd{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return 0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",s="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";e.elements.sort(((e,t)=>t-e));const o=ms(e.elements);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of o){const o=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=o&&o<=n.zone[s]){const e=Math.min(n.zone[s],l)-o+1;a="RESIZE",r=this.createAdaptedRange(r,i,a,-e)}else if(n.zone[t]>=o&&n.zone[s]<=l)a="REMOVE",r=this.buildInvalidRange(_);else if(n.zone[t]<=l&&n.zone[s]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,i,a,-e),r=this.createAdaptedRange(r,i,"MOVE",-(n.zone[t]-o))}else o<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,i,a,-(l-o+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",s="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(o.zone[t]<=e.base&&e.base<o.zone[s])return{changeType:"RESIZE",range:this.createAdaptedRange(o,i,"RESIZE",e.quantity)};if(e.base<o.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(o,i,"MOVE",e.quantity)}}else{if(o.zone[t]<e.base&&e.base<=o.zone[s])return{changeType:"RESIZE",range:this.createAdaptedRange(o,i,"RESIZE",e.quantity)};if(e.base<=o.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(o,i,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>t.sheetId!==e.sheetId?{changeType:"NONE"}:{changeType:"REMOVE",range:t={...this.buildInvalidRange(_),invalidSheetName:this.getters.getSheetName(e.sheetId)}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const s={...t,zone:{...t.zone}};return s.invalidSheetName=void 0,s.sheetId=e.sheetId,{changeType:"CHANGE",range:s}}return{changeType:"NONE"}}))}}finalize(){}verifyRangeRemoved(e){return t=>{const s=e(t);return"NONE"===s.changeType||Ns(s.range.zone)?s:{range:s.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,s,i){return{...e,zone:qs(e.zone,t,s,i)}}executeOnAllRanges(e,t){const s=this.verifyRangeRemoved(e);for(const e of this.providers)e(s,t)}addRangeProvider(e){this.providers.push(e)}orderZone(e,t){if(e.right<e.left){let s=e.right;e.right=e.left,e.left=s;let i=t[1].colFixed;t[1].colFixed=t[0].colFixed,t[0].colFixed=i}if(e.bottom<e.top){let s=e.bottom;e.bottom=e.top,e.top=s;let i=t[1].rowFixed;t[1].rowFixed=t[0].rowFixed,t[0].rowFixed=i}}createAdaptedRanges(e,t,s,i){return e.map((e=>Ns(e.zone)?(e={...e,sheetId:e.prefixSheet?e.sheetId:i,zone:{left:e.zone.left+(e.parts[0].colFixed?0:t),right:e.zone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.zone.top+(e.parts[0].rowFixed?0:s),bottom:e.zone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:s)}},this.orderZone(e.zone,e.parts),e):e))}getRangeFromSheetXC(e,t){let s,i,o,n=t,r=!1;if(!Jt.test(t))return this.buildInvalidRange(t);t.includes("!")&&(({xc:n,sheetName:s}=es(t)),s?(i=this.getters.getSheetIdByName(s),r=!0,i||(o=s)):o=s);const a=_s(n);let l=n.split(":").map((e=>({colFixed:e.startsWith("$"),rowFixed:e.includes("$",1)})));return this.orderZone(a,l),{sheetId:i||e,zone:a,parts:l,invalidSheetName:o,prefixSheet:r}}getRangeString(e,t){if(!e)return _;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return _;if(e.zone.left<0||e.zone.top<0)return _;let s=e.sheetId!==t||e.invalidSheetName||e.prefixSheet,i="";if(s&&(i=e.invalidSheetName?e.invalidSheetName:us(this.getters.getSheetName(e.sheetId))),s&&!i)return _;let o=Array(9);return o[0]=e.parts&&e.parts[0].colFixed?"$":"",o[1]=ts(e.zone.left),o[2]=e.parts&&e.parts[0].rowFixed?"$":"",o[3]=String(e.zone.top+1),e.parts&&2===e.parts.length&&(e.zone.top!==e.zone.bottom||e.zone.left!==e.zone.right||e.parts[0].rowFixed||e.parts[0].colFixed||e.parts[1].rowFixed||e.parts[1].colFixed)&&(o[4]=":",o[5]=e.parts[1].colFixed?"$":"",o[6]=ts(e.zone.right),o[7]=e.parts[1].rowFixed?"$":"",o[8]=String(e.zone.bottom+1)),`${s?i+"!":""}${o.join("")}`}buildInvalidRange(e){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:e}}}vd.getters=["getRangeString","getRangeFromSheetXC","createAdaptedRanges"];class Ed{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let s=e[0],i=e[e.length-1];const o=e.length-2;for(let t=1;t<=o;t++){const i=e[t];if(void 0===s[i]){const o=e[t+1];s[i]=ld(o)}s=s[i]}s[i]!==t&&(this.changes.push({path:e,before:s[i],after:t}),void 0===t?delete s[i]:s[i]=t)}}const Sd={General:0,0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},bd={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},Cd={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"},Id="http://schemas.openxmlformats.org/drawingml/2006/main",yd="http://schemas.openxmlformats.org/drawingml/2006/chart",wd={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml"},Td="http://schemas.openxmlformats.org/officeDocument/2006/relationships",xd=.75,Rd=.1425,Ld=164,Md={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},Ad=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"];function _d(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function Od(e){return Math.round(xd*e*window.devicePixelRatio*100)/100}function Nd(e){return Math.round(Rd*e*100)/100}function kd(e,t){let s={};e.style&&(s=t.styles[e.style]);let i={};e.border&&(i=t.borders[e.border]);const o={font:{size:(null==s?void 0:s.fontSize)||x,color:(null==s?void 0:s.textColor)?s.textColor:"000000",family:2,name:"Arial"},fill:(null==s?void 0:s.fillColor)?{fgColor:s.fillColor}:{reservedAttribute:"none"},numFmt:e.format,border:i||{},verticalAlignment:"center",horizontalAlignment:null==s?void 0:s.align};return o.font.strike=!!(null==s?void 0:s.strikethrough)||void 0,o.font.underline=!!(null==s?void 0:s.underline)||void 0,o.font.bold=!!(null==s?void 0:s.bold)||void 0,o.font.italic=!!(null==s?void 0:s.italic)||void 0,o}function Fd(e,t){const{id:s}=Dd(t.font,e.fonts),{id:i}=Dd(t.fill,e.fills),{id:o}=Dd(t.border,e.borders),n=function(e,t){if(!e)return 0;let s=Sd[e];if(!s){const{id:i}=Dd(e,t);s=i+Ld}return s}(t.numFmt,e.numFmts),r={fontId:s,fillId:i,borderId:o,numFmtId:n,verticalAlignment:t.verticalAlignment,horizontalAlignment:t.horizontalAlignment},{id:a}=Dd(r,e.styles);return a}function $d(e,t,s){let i,o=e.find((e=>e.path===t));return o?(i=`rId${(o.rels.length+1).toString()}`,o.rels.push({...s,id:i})):(i="rId1",e.push({path:t,rels:[{...s,id:i}]})),i}function Dd(e,t){for(let[s,i]of Object.entries(t))if(JSON.stringify(i)===JSON.stringify(e))return{id:parseInt(s,10),list:t};let s=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===s&&(t.push(e),s=t.length-1),{id:s,list:t}}const Ud=[];function Pd(e){const t=Ud.findIndex((t=>t===e));return-1===t?(Ud.push(e),Ud.length):t+1}function Bd(e){return Math.round(914400*e/96)}class Vd{constructor(e){this.xmlString=e}toString(){return this.xmlString}}function Hd(e,t,s){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:s}}function zd(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function Zd(e){return new Vd(e.map((([e,t])=>`${e}="${zd(t)}"`)).join(" "))}function Gd(e){const t=(new DOMParser).parseFromString(e.toString(),"text/xml"),s=t.querySelector("parsererror");if(s){const t=s.innerHTML,i=parseInt(t.split(":")[0],10),o=e.toString().trim().split("\n"),n=o.slice(Math.max(i-3,0),Math.min(i+2,o.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${n}`)}return t}function Wd(e,t){return jd`
1044
+ `;class mh extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters,this.state=t.useState(this.initialState())}get hasSearchResult(){return null!==this.env.getters.getCurrentSelectedMatchIndex()}mounted(){this.focusInput()}async willUnmount(){this.env.dispatch("CLEAR_SEARCH")}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.getters.shouldShowFormulas(),this.state.replaceOptions.modifyFormulas=this.state.searchOptions.searchFormulas?this.state.searchOptions.searchFormulas:this.state.replaceOptions.modifyFormulas,this.env.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.state.replaceOptions.modifyFormulas=this.state.searchOptions.searchFormulas,this.updateSearch()}onSelectPreviousCell(){this.env.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.inDebounce),this.inDebounce=setTimeout((()=>this.updateSearch.call(this)),400)}replace(){this.env.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith,replaceOptions:this.state.replaceOptions})}replaceAll(){this.env.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith,replaceOptions:this.state.replaceOptions})}focusInput(){const e=this.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1},replaceOptions:{modifyFormulas:!1}}}}mh.template=gh,mh.style=fh;const vh=new Le;vh.add("ConditionalFormatting",{title:a("Conditional formatting"),Body:dh}),vh.add("ChartPanel",{title:a("Chart"),Body:_c}),vh.add("FindAndReplace",{title:a("Find and Replace"),Body:mh});const Eh=new Le;class bh extends fa{constructor(e,t,s,i){super(t,s,i),this.getters=e,this.ui=i}drawGrid(e,t){}}bh.layers=[];class Sh{constructor(e,t,s){this.index=0,this.cells=e,this.getters=t,this.direction=s}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:s,tooltip:i}=Ra.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:s,tooltip:i,origin:{col:e.data.col,row:e.data.row}}}}class Ch extends bh{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:ps(e.col,0,this.getters.getSheet(t).cols.length),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:ps(e.row,0,this.getters.getSheet(t).rows.length),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:30;case"AUTOFILL_AUTO":const s=this.getters.getSelectedZone();return s.top===s.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),s=this.autofillZone;switch(this.direction){case 1:for(let i=t.left;i<=t.right;i++){const o=[];for(let e=t.top;e<=t.bottom;e++)o.push(is(i,e));const n=this.createGenerator(o);for(let t=s.top;t<=s.bottom;t++)this.computeNewCell(n,i,t,e)}break;case 0:for(let i=t.left;i<=t.right;i++){const o=[];for(let e=t.bottom;e>=t.top;e--)o.push(is(i,e));const n=this.createGenerator(o);for(let t=s.bottom;t>=s.top;t--)this.computeNewCell(n,i,t,e)}break;case 2:for(let i=t.top;i<=t.bottom;i++){const o=[];for(let e=t.right;e>=t.left;e--)o.push(is(e,i));const n=this.createGenerator(o);for(let t=s.right;t>=s.left;t--)this.computeNewCell(n,t,i,e)}break;case 3:for(let i=t.top;i<=t.bottom;i++){const o=[];for(let e=t.left;e<=t.right;e++)o.push(is(e,i));const n=this.createGenerator(o);for(let t=s.left;t<=s.right;t++)this.computeNewCell(n,t,i,e)}}if(e){const e=Ps(this.getters.getSelectedZone(),this.autofillZone);this.autofillZone=void 0,this.lastCellSelected={},this.direction=void 0,this.tooltip=void 0,this.dispatch("SET_SELECTION",{zones:[e],anchor:[e.left,e.top],anchorZone:e})}}select(e,t){const s=this.getters.getSelectedZone();if(Hs(e,t,s))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case 0:this.saveZone(t,s.top-1,s.left,s.right);break;case 1:this.saveZone(s.bottom+1,t,s.left,s.right);break;case 2:this.saveZone(s.top,s.bottom,e,s.left-1);break;case 3:this.saveZone(s.top,s.bottom,s.right+1,e)}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let s=e.left,i=e.bottom;if(s>0){let e=this.getters.getCell(t,s-1,i);for(;e&&!e.isEmpty();)i+=1,e=this.getters.getCell(t,s-1,i)}if(i===e.bottom&&(s=e.right,s<=this.getters.getActiveSheet().cols.length)){let e=this.getters.getCell(t,s+1,i);for(;e&&!e.isEmpty();)i+=1,e=this.getters.getCell(t,s+1,i)}i!==e.bottom&&(this.select(e.left,i-1),this.autofill(!0))}computeNewCell(e,t,s,i){const{cellData:o,tooltip:n,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=o;this.tooltip=n,i&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:s,content:a,style:l,border:c,format:h})}getRule(e,t){const s=La.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((s=>s.condition(e,t)));return s&&s.generateRule(e,t)}createGenerator(e){const t=[],s=[],i=this.getters.getActiveSheetId();for(let t of e){const[e,o]=ss(t),n=this.getters.getCell(i,e,o);s.push({col:e,row:o,cell:n,sheetId:i})}const o=s.map((e=>e.cell));for(let e of s){let s={type:"COPY_MODIFIER"};if(e&&e.cell){s=this.getRule(e.cell,o)||s}const{sheetId:i,col:n,row:r}=e,a=this.getters.getCellBorder(i,n,r)||void 0;t.push({data:{...e,border:a},rule:s})}return new Sh(t,this.getters,this.direction)}saveZone(e,t,s,i){this.autofillZone={top:e,bottom:t,left:s,right:i}}getDirection(e,t){const s=this.getters.getSelectedZone(),i={up:{number:s.top-t,value:0},down:{number:t-s.bottom,value:1},left:{number:s.left-e,value:2},right:{number:e-s.right,value:3}};if(1===Object.values(i).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(i).find((e=>e.number>0?1:0)).value;const o=i.up.number>0?"up":"down",n=i.left.number>0?"left":"right";return Math.abs(i[o].number)>=Math.abs(i[n].number)?i[o].value:i[n].value}autoFillMerge(e,t,s,i){const o=this.getters.getActiveSheet();if(this.getters.isInMerge(o.id,s,i)&&!this.getters.isInMerge(o.id,e,t)){const e=this.getters.getMerge(o.id,s,i);e&&this.dispatch("REMOVE_MERGE",{sheetId:o.id,target:[e]})}const n=this.getters.getMerge(o.id,e,t);(null==n?void 0:n.topLeft.col)===e&&(null==n?void 0:n.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:o.id,target:[{top:i,bottom:i+n.bottom-n.top,left:s,right:s+n.right-n.left}]})}drawGrid(e){if(!this.autofillZone)return;const{viewport:t,ctx:s,thinLineWidth:i}=e,[o,n,r,a]=this.getters.getRect(this.autofillZone,t);r>0&&a>0&&(s.strokeStyle="black",s.lineWidth=i,s.setLineDash([3]),s.strokeRect(o,n,r,a),s.setLineDash([]))}}Ch.layers=[6],Ch.getters=["getAutofillTooltip"],Ch.modes=["normal"];class Ih extends bh{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:s}=this.getters.getSelection();for(const i of t){const t=this.getAutomaticSums(e,i,s);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,s){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,s):this.sumData(e,t)}sumData(e,t){const s=this.dimensionsToSum(e,t),i=this.sumDimensions(e,t,s).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return s.has("ROW")&&s.has("COL")&&i.push(this.sumTotal(t)),i}sumAdjacentData(e,t,s){const[i,o]=Hs(s[0],s[1],t)?s:[t.left,t.top],n=this.findAdjacentData(e,i,o);return n?this.getters.isSingleCellOrMerge(e,t)||qs(Ps(n,t))?[{position:[i,o],zone:n}]:this.sumDimensions(e,Ps(n,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,s){const i=this.getters.getSheet(e),o=this.findSuitableZoneToSum(i,...this.getters.getMainCell(e,t,s));if(o)return this.getters.expandZone(e,o)}findSuitableZoneToSum(e,t,s){const i=this.getters.getCell(e.id,t,s-1),o=this.getters.getCell(e.id,t-1,s);if(this.isNumber(o)&&!this.isNumber(i))return this.findHorizontalZone(e,t,s);const n=this.findVerticalZone(e,t,s);if(this.isZoneValid(n))return n;const r=this.findHorizontalZone(e,t,s);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,s){const i={top:0,bottom:s-1,left:t,right:t},o=this.reduceZoneStart(e,i,i.bottom);return{...i,top:o}}findHorizontalZone(e,t,s){const i={top:s,bottom:s,left:0,right:t-1},o=this.reduceZoneStart(e,i,i.right);return{...i,left:o}}reduceZoneStart(e,t,s){const i=Gs(t,e,(e=>e),void 0).flat(),o=fs(s,-1,-1),n=_s(o.filter((e=>{var t;return i[e]&&!(null===(t=i[e])||void 0===t?void 0:t.isAutoSummable)}))),r=ms(o.filter((e=>this.isNumber(i[e]))))[0]||[];return _s(r)<n?1/0:Os(r)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return(null==e?void 0:e.evaluated.type)===ke.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(A))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const s=new Set;return qs(t)?(s.add(1===Ws(t).width?"COL":"ROW"),s):(this.lastColIsEmpty(e,t)&&s.add("ROW"),this.lastRowIsEmpty(e,t)&&s.add("COL"),0===s.size&&s.add("COL"),s)}sumDimensions(e,t,s){return[...s.has("COL")?this.sumColumns(t,e):[],...s.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:s}=e;return{position:[s,t],zone:{...e,top:t,right:s-1}}}sumColumns(e,t){const s=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,s.bottom-1)},js(s).map((t=>({position:t,zone:{...e,right:t[0],left:t[0]}})))}sumRows(e,t){const s=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,s.right-1)},js(s).map((t=>({position:t,zone:{...e,top:t[1],bottom:t[1]}})))}dispatchCellUpdates(e,t){for(const s of t){const[t,i]=s.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,content:`=SUM(${this.getters.zoneToXC(e,s.zone)})`})}}nextEmptyRow(e,t){let s=t.bottom+1;const{left:i,right:o}=t;for(;!this.getters.isEmpty(e,{bottom:s,top:s,left:i,right:o});)s++;return{...t,top:s,bottom:s}}nextEmptyCol(e,t){let s=t.right+1;const{top:i,bottom:o}=t;for(;!this.getters.isEmpty(e,{left:s,right:s,top:i,bottom:o});)s++;return{...t,left:s,right:s}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}Ih.getters=["getAutomaticSums"],Ih.modes=["normal","headless"];class yh extends bh{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"PASTE":return this.isPasteAllowed(this.state,e.target,!!e.force);case"INSERT_CELL":{const{cut:t,paste:s}=this.getInsertCellsTargets(e.zone,e.shiftDimension),i=this.getClipboardState(t,"CUT");return this.isPasteAllowed(i,s,!1)}case"DELETE_CELL":{const{cut:t,paste:s}=this.getDeleteCellsTargets(e.zone,e.shiftDimension),i=this.getClipboardState(t,"CUT");return this.isPasteAllowed(i,s,!1)}}return 0}handle(e){var t,s;switch(e.type){case"COPY":case"CUT":this.state=this.getClipboardState(e.target,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);if(this._isPaintingFormat=!1,e.interactive)this.interactivePaste(this.state,e.target,e);else{const t=this.state.cells.length,s=this.state.cells[0].length;this.paste(this.state,e.target,i),this.selectPastedZone(s,t,e.target),this.status="invisible"}break;case"DELETE_CELL":{const{cut:t,paste:s}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Fs(t[0])){for(const[t,s]of js(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:s,sheetId:this.getters.getActiveSheetId()});break}const i=this.getClipboardState(t,"CUT");e.interactive?this.interactivePaste(i,s,e):this.paste(i,s);break}case"INSERT_CELL":{const{cut:t,paste:s}=this.getInsertCellsTargets(e.zone,e.shiftDimension),i=this.getClipboardState(t,"CUT");e.interactive?this.interactivePaste(i,s,e):this.paste(i,s);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(s=this.state)||void 0===s?void 0:s.operation))return;for(let t of e.elements){if(this.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":this.pasteFromClipboard(e.target,e.text);break;case"ACTIVATE_PAINT_FORMAT":this.state=this.getClipboardState(e.target,"COPY"),this._isPaintingFormat=!0,this.status="visible";break;default:Ue(e)&&(this.status="invisible")}}getClipboardContent(){return this.state&&this.state.cells.length&&this.state.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.cell,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const s=this.getters.getActiveSheet();let i;return i="COL"===t?{...e,left:e.right+1,right:s.cols.length-1}:{...e,top:e.bottom+1,bottom:s.rows.length-1},{cut:[i],paste:[e]}}getInsertCellsTargets(e,t){const s=this.getters.getActiveSheet();let i,o;return"COL"===t?(i={...e,right:s.cols.length-1},o={...e,left:e.right+1,right:e.right+1}):(i={...e,bottom:s.rows.length-1},o={...e,top:e.bottom+1,bottom:s.rows.length-1}),{cut:[i],paste:[o]}}removeMergeIfTopLeft(e){const{sheetId:t,col:s,row:i}=e,[o,n]=this.getters.getMainCell(t,s,i);if(n===i&&o===s){const e=this.getters.getMerge(t,s,i);e&&this.dispatch("REMOVE_MERGE",{sheetId:t,target:[e]})}}pasteMergeIfExist(e,t){let{sheetId:s,col:i,row:o}=e;const[n,r]=this.getters.getMainCell(s,i,o);if(n===i&&r===o){const e=this.getters.getMerge(s,i,o);if(!e)return;({sheetId:s,col:i,row:o}=t),this.dispatch("ADD_MERGE",{sheetId:s,force:!0,target:[{left:i,top:o,right:i+e.right-e.left,bottom:o+e.bottom-e.top}]})}}getPasteZones(e,t){if(!t.length||!t[0].length)return e;const s=[],i=t.length,o=t[0].length,n=e[e.length-1],r=n.left,a=n.top,l=Math.max(1,Math.floor((n.right+1-r)/o)),c=Math.max(1,Math.floor((n.bottom+1-a)/i));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)s.push({left:r,top:a,right:r-1+e*o,bottom:a-1+t*i});return s}getClipboardState(e,t){const s=new Set(e.map((e=>e.top))),i=new Set(e.map((e=>e.bottom)));let o=1===s.size&&1===i.size?e:[e[e.length-1]];o=o.map((e=>({...e})));const n=[],r=[],a=this.getters.getActiveSheetId(),{top:l,bottom:c}=o[0];for(let e=l;e<=c;e++){const t=[];n.push(t);for(let s of o)for(let i=s.left;i<=s.right;i++){const s=this.getters.getCell(a,i,e),o=this.getters.getCellBorder(a,i,e)||void 0;t.push({cell:s,border:o,position:{col:i,row:e,sheetId:a}});const n=this.getters.getMerge(a,i,e);n&&n.top===e&&n.left===i&&r.push(n)}}return{cells:n,operation:t,sheetId:a,zones:o,merges:r}}pasteFromClipboard(e,t){this.status="invisible";const s=t.replace(/\r/g,"").split("\n").map((e=>e.split("\t"))),{left:i,top:o}=e[0],n=Math.max.apply(Math,s.map((e=>e.length))),r=s.length,a=this.getters.getActiveSheet();this.addMissingDimensions(a,n,r,i,o);for(let e=0;e<s.length;e++)for(let t=0;t<s[e].length;t++)this.dispatch("UPDATE_CELL",{row:o+e,col:i+t,content:s[e][t],sheetId:a.id});const l={left:i,top:o,right:i+n-1,bottom:o+r-1};this.dispatch("SET_SELECTION",{anchor:[i,o],zones:[l],anchorZone:l})}isPasteAllowed(e,t,s){const i=this.getters.getActiveSheetId();if(!e)return 20;if(t.length>1&&(e.cells.length>1||e.cells[0].length>1))return 19;if(!s)for(let s of this.getPasteZones(t,e.cells))if(this.getters.doesIntersectMerge(i,s))return 2;return 0}paste(e,t,s){if("CUT"===e.operation&&this.clearClippedZones(e),t.length>1)for(const i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,t,o,s);else{const i=e.cells.length,o=e.cells[0].length,n=t[0],r=Math.max(1,Math.floor((n.right+1-n.left)/o)),a=Math.max(1,Math.floor((n.bottom+1-n.top)/i));for(let t=0;t<r;t++)for(let r=0;r<a;r++)this.pasteZone(e,n.left+t*o,n.top+r*i,s)}"CUT"===e.operation&&(this.dispatch("REMOVE_MERGE",{sheetId:e.sheetId,target:e.merges}),this.state=void 0)}selectPastedZone(e,t,s){const i=s[0],o=i.left,n=i.top,r=Math.max(1,Math.floor((i.right+1-i.left)/e)),a=Math.max(1,Math.floor((i.bottom+1-i.top)/t));if(t>1||e>1){const s={left:o,top:n,right:o+r*e-1,bottom:n+a*t-1},[i,l]=this.getters.getSelection().anchor,c=ps(i,o,o+r*e-1),h=ps(l,n,n+a*t-1);this.dispatch("SET_SELECTION",{anchor:[c,h],zones:[s],anchorZone:s})}}clearClippedZones(e){for(const t of e.cells)for(const e of t)e.cell&&this.dispatch("CLEAR_CELL",e.position);this.dispatch("CLEAR_FORMATTING",{sheetId:e.sheetId,target:e.zones})}pasteZone(e,t,s,i){const o=e.cells.length,n=e.cells[0].length,r="onlyValue"!==i&&this.state&&this.state===e,a=this.getters.getActiveSheet();this.addMissingDimensions(a,n,o,t,s);for(let l=0;l<o;l++){const o=e.cells[l];for(let c=0;c<n;c++){const n=o[c],h={col:t+c,row:s+l,sheetId:a.id};this.removeMergeIfTopLeft(h),this.pasteMergeIfExist(n.position,h),this.pasteCell(n,h,e.operation,e.zones,i),r&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:h,operation:e.operation})}}}addMissingDimensions(e,t,s,i,o){const{cols:n,rows:r,id:a}=e,l=s+o-r.length;l>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:r.length-1,sheetId:a,quantity:l,position:"after"});const c=t+i-n.length;c>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:n.length-1,sheetId:a,quantity:c,position:"after"})}pasteCell(e,t,s,i,o){const{sheetId:n,col:r,row:a}=t,l=this.getters.getCell(n,r,a);if("onlyValue"!==o&&this.dispatch("SET_BORDER",{sheetId:n,col:r,row:a,border:e.border}),e.cell){if("onlyFormat"===o)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.cell.format});if("onlyValue"===o){const s=qr(e.cell.evaluated.value);return void this.dispatch("UPDATE_CELL",{...t,content:s})}let l=e.cell.content;if(e.cell.isFormula()){const t=r-e.position.col,o=a-e.position.row;l=this.getUpdatedContent(n,e.cell,t,o,i,s)}this.dispatch("UPDATE_CELL",{...t,content:l,style:e.cell.style||null,format:e.cell.format})}else l&&("onlyValue"===o?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===o?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,s,i,o,n){if("CUT"===n){const n=[];for(const r of t.dependencies.references)this.isZoneOverlapClippedZone(o,r.zone)?n.push(...this.getters.createAdaptedRanges([r],s,i,e)):n.push(r);const r={...t.dependencies,references:n};return this.getters.buildFormulaContent(e,t.normalizedText,r)}const r=this.getters.createAdaptedRanges(t.dependencies.references,s,i,e),a={...t.dependencies,references:r};return this.getters.buildFormulaContent(e,t.normalizedText,a)}isZoneOverlapClippedZone(e,t){return e.some((e=>Vs(t,e)))}interactivePaste(e,t,s){const i=this.isPasteAllowed(e,t,!1);0!==i?(19===i&&this.ui.notifyUser(a("This operation is not allowed with multiple selections.")),2===i&&this.ui.notifyUser(a("This operation is not possible due to a merge. Please remove the merges first than try again."))):this.dispatch(s.type,{...s,interactive:!1})}isColRowDirtyingClipboard(e,t){if(!this.state||!this.state.zones)return!1;for(let s of this.state.zones){if("COL"===t&&e<=s.right)return!0;if("ROW"===t&&e<=s.bottom)return!0}return!1}drawGrid(e){const{viewport:t,ctx:s,thinLineWidth:i}=e;if("visible"===this.status&&this.state&&this.state.zones&&this.state.zones.length&&this.state.sheetId===this.getters.getActiveSheetId()){s.setLineDash([8,5]),s.strokeStyle=p,s.lineWidth=3.3*i;for(const e of this.state.zones){const[i,o,n,r]=this.getters.getRect(e,t);n>0&&r>0&&s.strokeRect(i,o,n,r)}}}}var wh;yh.layers=[2],yh.getters=["getClipboardContent","isPaintingFormat"],yh.modes=["normal"],function(e){e[e.idle=0]="idle",e[e.selecting=1]="selecting",e[e.readyToExpand=2]="readyToExpand",e[e.expanding=3]="expanding"}(wh||(wh={}));class Th extends bh{constructor(e,t,s,i){super(e,t,s,i),this.selection={zones:[{top:0,left:0,bottom:0,right:0}],anchor:[0,0],anchorZone:{top:0,left:0,bottom:0,right:0}},this.selectedFigureId=null,this.activeCol=0,this.activeRow=0,this.mode=wh.idle,this.sheetsData={},this.activeSheet=null,this.moveClient=i.moveClient}allowDispatch(e){switch(e.type){case"SET_SELECTION":if(-1===e.zones.findIndex((t=>Bs(t,e.anchorZone))))return 16;break;case"ALTER_SELECTION":if(e.delta){const{left:t,right:s,top:i,bottom:o}=this.getSelectedZone(),n=this.getters.getActiveSheet(),r=ri(n,"cols",fs(t,s+1)),a=ri(n,"rows",fs(i,o+1));if(0!==e.delta[0]&&void 0===a||0!==e.delta[1]&&void 0===r)return 17}break;case"MOVE_POSITION":{const{cols:t,rows:s}=this.getters.getActiveSheet();if(0!==e.deltaX&&s[this.activeRow].isHidden||0!==e.deltaY&&t[this.activeCol].isHidden)return 17;const{col:i,row:o}=this.getNextAvailablePosition(e.deltaX,e.deltaY);if(o<0||o>s.length-1||i<0||i>t.length-1)return 17;break}case"SELECT_COLUMN":{const{index:t}=e;if(t<0||t>=this.getters.getActiveSheet().cols.length)return 17;break}case"SELECT_ROW":{const{index:t}=e;if(t<0||t>=this.getters.getActiveSheet().rows.length)return 17;break}case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 23}case"MOVE_COLUMNS_ROWS":const t=this.isMoveElementAllowed(e);return 2===t&&this.ui.notifyUser(a("Merged cells are preventing this operation. Unmerge those cells and try again.")),t}return 0}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":case"CREATE_FIGURE":case"CREATE_CHART":case"UPDATE_FIGURE":case"EVALUATE_CELLS":case"DISABLE_SELECTION_INPUT":case"ENABLE_NEW_SELECTION_INPUT":case"RESIZE_VIEWPORT":break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;default:this.selectedFigureId=null}switch(e.type){case"START":const t=ni(this.getters.getSheets()[0],0,0);this.activeCol=t[0],this.activeRow=t[1],this.dispatch("ACTIVATE_SHEET",{sheetIdTo:this.getters.getSheets()[0].id,sheetIdFrom:this.getters.getSheets()[0].id}),this.selectCell(...t);break;case"ACTIVATE_SHEET":this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={selection:JSON.parse(JSON.stringify(this.selection)),activeCol:this.activeCol,activeRow:this.activeRow},e.sheetIdTo in this.sheetsData?Object.assign(this,this.sheetsData[e.sheetIdTo]):this.selectCell(...ni(this.getters.getSheet(e.sheetIdTo),0,0));break;case"SET_SELECTION":this.setSelection(e.anchor,e.zones,e.anchorZone,e.strict);break;case"START_SELECTION":this.mode=wh.selecting;break;case"PREPARE_SELECTION_EXPANSION":this.mode=wh.readyToExpand;break;case"START_SELECTION_EXPANSION":this.mode=wh.expanding;break;case"STOP_SELECTION":this.mode=wh.idle;break;case"MOVE_POSITION":this.movePosition(e.deltaX,e.deltaY);break;case"SELECT_CELL":this.selectCell(e.col,e.row);break;case"SELECT_COLUMN":this.selectColumn(e.index,e.createRange||!1,e.updateRange||!1);break;case"SELECT_ROW":this.selectRow(e.index,e.createRange||!1,e.updateRange||!1);break;case"SELECT_ALL":this.selectAll();break;case"ALTER_SELECTION":e.delta&&this.moveSelection(e.delta[0],e.delta[1]),e.cell&&this.addCellToSelection(...e.cell);break;case"UNDO":case"REDO":case"DELETE_SHEET":if(!this.getters.tryGetSheet(this.getActiveSheetId())){const e=this.getters.getVisibleSheets();this.activeSheet=this.getters.getSheet(e[0]),this.selectCell(0,0)}this.ensureSelectionValidity();break;case"REMOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&("COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e));break;case"ADD_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onAddElements(e);break;case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"UPDATE_CHART":case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left")}}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){const e=this.getters.getActiveSheetId(),[t,s]=this.getters.getMainCell(e,this.activeCol,this.activeRow);return this.getters.getCell(e,t,s)}getActiveCols(){const e=new Set;for(let t of this.selection.zones)if(0===t.top&&t.bottom===this.getters.getActiveSheet().rows.length-1)for(let s=t.left;s<=t.right;s++)e.add(s);return e}getActiveRows(){const e=new Set;for(let t of this.selection.zones)if(0===t.left&&t.right===this.getters.getActiveSheet().cols.length-1)for(let s=t.top;s<=t.bottom;s++)e.add(s);return e}getCurrentStyle(){const e=this.getters.getActiveCell();return e?this.getters.getCellStyle(e):{}}getSelectedZones(){return this.selection.zones}getSelectedZone(){return this.selection.anchorZone}getSelection(){return this.selection}getSelectedFigureId(){return this.selectedFigureId}getPosition(){return[this.activeCol,this.activeRow]}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getPosition();{const t=this.sheetsData[e];return t?[t.activeCol,t.activeRow]:ni(this.getters.getSheet(e),0,0)}}getAggregate(){let e=0,t=0;for(let s of this.selection.zones)for(let i=s.top;i<=s.bottom;i++){const o=this.getters.getRow(this.getters.getActiveSheetId(),i);if(void 0!==o)for(let i=s.left;i<=s.right;i++){const s=o.cells[i];(null==s?void 0:s.evaluated.type)===ke.number&&(t++,e+=s.evaluated.value)}}return t<2?null:ie(e)}getSelectionMode(){return this.mode}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Bs(t,e)))}getVisibleFigures(e){const t=[],s=this.getters.getFigures(e),{offsetX:i,offsetY:o}=this.getters.getSnappedViewport(e),{width:n,height:r}=this.getters.getViewportDimension();for(let e of s)e.x>=i+n||e.x+e.width<=i||e.y>=o+r||e.y+e.height<=o||t.push(e);return t}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let s=[];const i="COL"===e?"left":"top",o="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[o]-e[i]+1},((t,s)=>e[i]+s));s=s.concat(t)}return[...new Set(s)].sort()}selectColumn(e,t,s){const i=this.getters.getActiveSheet().rows.length-1;let o={left:e,right:e,top:0,bottom:i};const n=this.selection.zones;let r,a;const l=this.getters.getActiveSheet().rows.findIndex((e=>!e.isHidden));if(s){const[e,t]=this.selection.anchor;o=Ps(o,{left:e,right:e,top:l,bottom:i}),r=this.updateSelectionZones(o),a=[e,t]}else r=t?n.concat(o):[o],a=[e,l];this.dispatch("SET_SELECTION",{zones:r,anchor:a,strict:!0,anchorZone:o})}selectRow(e,t,s){const i=this.getters.getActiveSheet().cols.length-1;let o={top:e,bottom:e,left:0,right:i};const n=this.selection.zones;let r,a;const l=this.getters.getActiveSheet().cols.findIndex((e=>!e.isHidden));if(s){const[e,t]=this.selection.anchor;o=Ps(o,{left:l,right:i,top:t,bottom:t}),r=this.updateSelectionZones(o),a=[e,t]}else r=t?n.concat(o):[o],a=[l,e];this.dispatch("SET_SELECTION",{zones:r,anchor:a,strict:!0,anchorZone:o})}selectAll(){const e={left:0,top:0,bottom:this.getters.getActiveSheet().rows.length-1,right:this.getters.getActiveSheet().cols.length-1};this.dispatch("SET_SELECTION",{zones:[e],anchor:[0,0],anchorZone:e})}selectCell(e,t){const s=this.getters.getActiveSheet();this.moveClient({sheetId:s.id,col:e,row:t});let i=this.getters.expandZone(s.id,{left:e,right:e,top:t,bottom:t});this.mode===wh.expanding?this.selection.zones.push(i):this.selection.zones=[i],this.selection.zones=Xs(this.selection.zones),this.selection.anchorZone=i,this.selection.anchor=[e,t],this.activeCol=e,this.activeRow=t}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}getNextAvailablePosition(e,t){return{col:this.getNextAvailableCol(e,this.activeCol,this.activeRow),row:this.getNextAvailableRow(t,this.activeCol,this.activeRow)}}getNextAvailableCol(e,t,s){const{cols:i,id:o}=this.getActiveSheet(),n={col:t,row:s};return this.getNextAvailableHeader(e,i,t,n,(e=>this.getters.isInSameMerge(o,t,s,e,s)))}getNextAvailableRow(e,t,s){const{rows:i,id:o}=this.getActiveSheet(),n={col:t,row:s};return this.getNextAvailableHeader(e,i,s,n,(e=>this.getters.isInSameMerge(o,t,s,t,e)))}getNextAvailableHeader(e,t,s,i,o){var n,r,a;const l=this.getters.getActiveSheetId(),{col:c,row:h}=i;if(0===e)return s;let d=s+e;if(this.getters.isInMerge(l,c,h)){for(;o(d);)d+=e;for(;null===(n=t[d])||void 0===n?void 0:n.isHidden;)d+=e}else if(null===(r=t[d])||void 0===r?void 0:r.isHidden)for(;null===(a=t[d])||void 0===a?void 0:a.isHidden;)d+=e;return d<0||d>t.length-1?t[s].isHidden?this.getNextAvailableHeader(-e,t,s,i,o):s:d}movePosition(e,t){const{col:s,row:i}=this.getNextAvailablePosition(e,t);this.selectCell(s,i)}setSelection(e,t,s,i=!1){this.selectCell(...e);const o=this.getters.getActiveSheetId();let n;t=Xs(t),n=i?{zones:t,anchorZone:s,anchor:e}:{anchor:e,zones:t.map((e=>this.getters.expandZone(o,e))),anchorZone:this.getters.expandZone(o,s)},this.selection=this.clipSelection(o,n)}getReferencePosition(){const e=this.getters.getActiveSheet(),t=this.selection,{left:s,right:i,top:o,bottom:n}=t.anchorZone,[r,a]=t.anchor;return{col:e.cols[r].isHidden&&ri(e,"cols",fs(s,i+1))||r,row:e.rows[a].isHidden&&ri(e,"rows",fs(o,n+1))||a}}moveSelection(e,t){const s=this.selection;let i=[];const[o,n]=s.anchor,{left:r,right:a,top:l,bottom:c}=s.anchorZone;let h=s.anchorZone;const d=this.getters.getActiveSheet(),u=e=>{const{left:t,right:s,top:i,bottom:o}=this.getters.expandZone(d.id,e);return{left:Math.max(0,t),right:Math.min(d.cols.length-1,s),top:Math.max(0,i),bottom:Math.min(d.rows.length-1,o)}},{col:p,row:g}=this.getReferencePosition();let f=0;for(;null!==h;){if(f++,e<0){const t=this.getNextAvailableCol(e,a-(f-1),g);h=p<=a-f?u({top:l,left:r,bottom:c,right:t}):null}if(e>0){const t=this.getNextAvailableCol(e,r+(f-1),g);h=r+f<=p?u({top:l,left:t,bottom:c,right:a}):null}if(t<0){const e=this.getNextAvailableRow(t,p,c-(f-1));h=g<=c-f?u({top:l,left:r,bottom:e,right:a}):null}if(t>0){const e=this.getNextAvailableRow(t,p,l+(f-1));h=l+f<=g?u({top:e,left:r,bottom:c,right:a}):null}if(h=h?Ks(h):h,h&&!Bs(h,s.anchorZone))return i=this.updateSelectionZones(h),void this.dispatch("SET_SELECTION",{zones:i,anchor:[o,n],anchorZone:h})}h=u(Ps({top:n,bottom:n,left:o,right:o},Ks({top:this.getNextAvailableRow(t,p,l),left:this.getNextAvailableCol(e,r,g),bottom:this.getNextAvailableRow(t,p,c),right:this.getNextAvailableCol(e,a,g)}))),Bs(h,s.anchorZone)||(i=this.updateSelectionZones(h),this.dispatch("SET_SELECTION",{zones:i,anchor:[o,n],anchorZone:h}))}addCellToSelection(e,t){const s=this.selection,[i,o]=s.anchor,n={left:Math.min(i,e),top:Math.min(o,t),right:Math.max(i,e),bottom:Math.max(o,t)},r=this.updateSelectionZones(n);this.dispatch("SET_SELECTION",{zones:r,anchor:[i,o],anchorZone:n})}ensureSelectionValidity(){const{anchor:e,zones:t,anchorZone:s}=this.clipSelection(this.getActiveSheetId(),this.selection);this.setSelection(e,t,s);const i=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of i)delete this.sheetsData[e];for(const e in this.sheetsData){const{anchor:t,zones:s,anchorZone:i}=this.clipSelection(e,this.sheetsData[e].selection);this.sheetsData[e]={selection:{anchor:t,zones:s,anchorZone:i},activeCol:t[0],activeRow:t[1]}}}clipSelection(e,t){const s=this.getters.getSheet(e),i=s.cols.length-1,o=s.rows.length-1,n=t.zones.map((e=>({left:ps(e.left,0,i),right:ps(e.right,0,i),top:ps(e.top,0,o),bottom:ps(e.bottom,0,o)})));return{anchor:[ps(t.anchor[0],0,i),ps(t.anchor[1],0,o)],zones:n,anchorZone:{left:ps(t.anchorZone.left,0,i),right:ps(t.anchorZone.right,0,i),top:ps(t.anchorZone.top,0,o),bottom:ps(t.anchorZone.bottom,0,o)}}}onColumnsRemoved(e){const t=Us(this.getSelectedZone(),"left",e.elements);this.setSelection([t.left,t.top],[t],t,!0),this.ensureSelectionValidity()}onRowsRemoved(e){const t=Us(this.getSelectedZone(),"top",e.elements);this.setSelection([t.left,t.top],[t],t,!0),this.ensureSelectionValidity()}onAddElements(e){const t=Ds(this.getSelectedZone(),"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.setSelection([t.left,t.top],[t],t,!0)}updateSelectionZones(e){let t=[...this.selection.zones];const s=this.selection.anchorZone,i=t.findIndex((e=>Bs(e,s)));return i>=0&&(t[i]=e),t}activateNextSheet(e){const t=this.getters.getSheets().map((e=>e.id)),s=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[s]})}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const s="COL"===e.dimension,i=e.elements[0],o=e.elements[t-1],n=e.base<i,r=n&&s?t:0,a=n&&!s?t:0,l=this.getters.getSheet(e.sheetId);this.dispatch("CUT",{target:[{left:s?i+r:0,right:s?o+r:l.cols.length-1,top:s?0:i+a,bottom:s?l.rows.length-1:o+a}]}),this.dispatch("PASTE",{target:[{left:s?e.base:0,right:s?e.base+t-1:l.cols.length-1,top:s?0:e.base,bottom:s?l.rows.length-1:e.base+t-1}]});const c=n?e.elements.map((e=>e+t)):e.elements;let h=e.base;for(const t of c){const s="COL"===e.dimension?this.getters.getCol(e.sheetId,t).size:this.getters.getRow(e.sheetId,t).size;this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:s,elements:[h]}),h+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:c})}isMoveElementAllowed(e){const t="COL"===e.dimension,s=e.elements[0],i=e.elements[e.elements.length-1],o=e.sheetId,n=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return n(o,s-1,s)||n(o,i,i+1)||n(o,e.base-1,e.base)?2:0}drawGrid(e){if("inactive"!==this.getters.getEditionMode())return;const{viewport:t,ctx:s,thinLineWidth:i}=e,o=this.getSelectedZones();s.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;s.fillStyle=n?"#f3f7fe":"#e9f0ff",s.strokeStyle=p,s.lineWidth=1.5*i,s.globalCompositeOperation="multiply";for(const e of o){const[i,o,n,r]=this.getters.getRect(e,t);s.fillRect(i,o,n,r),s.strokeRect(i,o,n,r)}s.globalCompositeOperation="source-over";const r=this.getters.getActiveSheetId(),[a,l]=this.getPosition();let c;s.strokeStyle=p,s.lineWidth=3*i,c=this.getters.isInMerge(r,a,l)?this.getters.getMerge(r,a,l):{top:l,bottom:l,left:a,right:a};const[h,d,u,g]=this.getters.getRect(c,t);u>0&&g>0&&s.strokeRect(h,d,u,g)}}Th.layers=[5],Th.modes=["normal"],Th.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getAggregate","getSelectedFigureId","getVisibleFigures","getSelection","getPosition","getSheetPosition","getSelectionMode","isSelected","getElementsFromSelection"];const xh=a("The cell you are trying to edit has been deleted.");class Rh extends bh{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheet="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.multiSelectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),s=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(s.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection);break;case"STOP_EDITION":e.cancel?(this.cancelEdition(),this.resetContent()):this.stopEdition();break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0);break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEdition(),this.resetContent();break;case"SELECT_CELL":case"SET_SELECTION":case"MOVE_POSITION":switch(this.mode){case"editing":this.dispatch("STOP_EDITION");break;case"waitingForRangeSelection":this.insertSelectedRange();break;case"rangeSelected":switch(e.type){case"MOVE_POSITION":this.replaceAllSelectedRanges();break;case"SELECT_CELL":this.getters.getSelectionMode()===wh.expanding?this.insertSelectedRange():this.replaceAllSelectedRanges();break;case"SET_SELECTION":e.strict?this.getters.getSelectionMode()===wh.expanding?this.insertSelectedRange():this.replaceAllSelectedRanges():this.replaceSelectedRange()}}break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.currentTokens.filter((e=>"SYMBOL"===e.type)).find((t=>{let s=t.value;const{xc:i,sheetName:o}=es(s),n=o||this.getters.getSheetName(this.sheet),r=this.getters.getActiveSheetId();return Bs(this.getters.expandZone(r,ks(i)),e.zone)&&this.getters.getSheetName(r)===n}));this.previousRef=t.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=t.start;break;case"CHANGE_HIGHLIGHT":const s=this.getZoneReference(e.zone,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(s),this.previousRef=s,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheet)||"inactive"===this.mode||(this.cancelEdition(),this.resetContent(),this.ui.notifyUser(xh))}}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheet}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"waitingForRangeSelection"===this.mode||"rangeSelected"===this.mode||"resettingPosition"===this.mode}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((s=>s.start<=e&&s.end>=t))}validateSelection(e,t,s){return t>=0&&t<=e&&s>=0&&s<=e?0:31}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUser(xh);const{top:t,left:s}=Us({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",e.elements);this.col=s,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUser(xh);const{top:t,left:s}=Us({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",e.elements);this.col=s,this.row=t}onAddElements(e){const{top:t,left:s}=Ds({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=s,this.row=t}startComposerRangeSelection(){this.mode="resettingPosition",this.sheet===this.getters.getActiveSheetId()&&this.dispatch("SELECT_CELL",{col:this.col,row:this.row}),this.mode="waitingForRangeSelection",this.multiSelectionInitialStart=this.selectionStart}startEdition(e,t){const s=this.getters.getActiveCell();this.initialContent=(null==s?void 0:s.composerContent)||"",this.mode="editing";const[i,o]=this.getters.getPosition();this.col=i,this.row=o,this.sheet=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={}}stopEdition(){if("inactive"!==this.mode){this.cancelEdition();const e=this.getters.getActiveSheetId(),t=this.getters.getSheets().find((e=>e.id===this.sheet)).id,[s,i]=this.getters.getMainCell(t,this.col,this.row);let o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const t=this.getters.getCell(e,s,i);if(o.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,s=e-t;s>0&&(o+=new Array(s).fill(")").join(""))}else(null==t?void 0:t.isLink())&&(o=ys(o,t.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheet,col:s,row:i,content:o})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheet,content:"",col:s,row:i});e!==this.sheet&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheet}),this.setContent("")}}cancelEdition(){this.mode="inactive"}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,s){e=e.replace(/[\r\n]/g,"");const i=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(i||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?zr(e):[],this.currentTokens.length>100&&s&&this.ui.notifyUser(a("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"))),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(){const e=Math.min(this.selectionStart,this.selectionEnd),t=this.getZoneReference(this.getters.getSelectedZone());if("waitingForRangeSelection"===this.mode)return this.insertText(t,e),this.selectionInitialStart=e,void(this.mode="rangeSelected");this.insertText(","+t,e),this.selectionInitialStart=e+1}replaceSelectedRange(){const{end:e}=this.getters.getComposerSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:this.selectionInitialStart,end:e}),this.replaceSelection(this.getZoneReference(this.getters.getSelectedZone()))}replaceAllSelectedRanges(){const{end:e}=this.getters.getComposerSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:this.multiSelectionInitialStart,end:e}),this.replaceSelection(this.getZoneReference(this.getters.getSelectedZone())),this.selectionInitialStart=this.multiSelectionInitialStart}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const s=this.getters.getActiveSheetId();let i=this.getters.zoneToXC(s,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){i=`${us(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${i}`}return i}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),s=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,s)}replaceText(e,t,s){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(s,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const s=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),i=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:{start:i,end:i}})}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=[],t={};for(let s of this.currentTokens.filter((e=>"SYMBOL"===e.type))){let i=s.value;const{xc:o,sheetName:n}=es(i);if(Jt.test(o)){const s=(n?`${n}!`:`${this.getters.getSheetName(this.getters.getEditionSheet())}!`)+o.replace(/\$/g,"");e.push(s);const i=this.colorIndexByRange[s];void 0!==i&&(t[s]=i)}}this.colorIndexByRange=t;let s=Object.values(t),i=0;return e.map((e=>{if(void 0===this.colorIndexByRange[e]){for(;s.includes(i);)i++;s.push(i),this.colorIndexByRange[e]=i}return[e,qt[this.colorIndexByRange[e]%qt.length]]}))}canStartComposerRangeSelection(){if("editing"!==this.mode&&this.selectionStart===this.selectionEnd)return!1;if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(e){const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let s=t,i=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type||s<1)return!1;s--,i=this.currentTokens[s]}for(s=t+1,i=this.currentTokens[s];i&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type)return!1;s++,i=this.currentTokens[s]}s++,i=this.currentTokens[s]}return!0}return!1}}Rh.getters=["getEditionMode","isSelectingForComposer","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"],Rh.modes=["normal"];const Lh=rr.mapping;class Mh extends bh{constructor(e,t,s,i){super(e,t,s,i),this.isUpToDate=new Set,this.evalContext=i.evalContext,i.dataSources.on("data-loaded",this,(()=>{this.dispatch("EVALUATE_CELLS",{sheetId:this.getters.getActiveSheetId()})}))}handle(e){switch(Fe.has(e.type)&&this.isUpToDate.clear(),e.type){case"UPDATE_CELL":"content"in e&&this.isUpToDate.clear();break;case"ACTIVATE_SHEET":this.evaluate(e.sheetIdTo),this.isUpToDate.add(e.sheetIdTo);break;case"EVALUATE_CELLS":this.evaluate(e.sheetId),this.isUpToDate.add(e.sheetId);break;case"EVALUATE_ALL_SHEETS":this.evaluateAllSheets()}}finalize(){const e=this.getters.getActiveSheetId();this.isUpToDate.has(e)||(this.evaluate(e),this.isUpToDate.add(e))}evaluateFormula(e,t=this.getters.getActiveSheetId()){try{let s=Zr(e);const i=Br(s),o=this.getFormulaParameters((()=>{})),n=[];for(let e of s.dependencies.references)n.push(this.getters.getRangeFromSheetXC(t,e));return i({...s.dependencies,references:n},t,...o)}catch(e){return"#ERROR"}}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[[]]:Gs(e.zone,t,(e=>this.getters.getCellText(e,this.getters.shouldShowFormulas())),"")}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[[]]:Gs(e.zone,t,(e=>e.evaluated.value))}evaluate(e){const t=this.getters.getCells(e),s=this.getFormulaParameters(o),i={};for(let s of Object.values(t))o(s,e);function o(e,t){if(!e.isFormula())return;const o=e.id;if(o in i)null===i[o]&&e.assignError("#CYCLE",a("Circular reference"));else{i[o]=null;try{if(s[2].__originCellXC=()=>{const e=s[2].getters.getCellPosition(o);return is(e.col,e.row)},e.assignValue(e.compiledFormula(e.dependencies,t,...s)),Array.isArray(e.evaluated.value))throw new Error(a("This formula depends on invalid values"))}catch(t){!function(e,t){if(e instanceof Error||(e=new Error(e)),"#CYCLE"!==t.evaluated.value){t.assignValue("#ERROR");const i=s[2].__lastFnCalled||"";t.assignError("#ERROR",e.message.replace("[[FUNCTION_NAME]]",i))}}(t,e)}i[o]=!0}}}getFormulaParameters(e){const t=Object.assign(Object.create(Lh),this.evalContext,{getters:this.getters});function s(t,s){if(e(t,s),t.evaluated.type===ke.error)throw new Error(a("This formula depends on invalid values"));return t.evaluated.value}function i(e){o(e);const i=t.getters.getSheet(e.sheetId),n={top:0,bottom:i.rows.length-1,left:0,right:i.cols.length-1},r=[],a=function(e,t){if(Vs(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}(e.zone,n);if(!a)return r.push([]),r;for(let i=a.left;i<=a.right;i++){const o=[];for(let n=a.top;n<=a.bottom;n++){const r=t.getters.getCell(e.sheetId,i,n);o.push(r?s(r,e.sheetId):void 0)}r.push(o)}return r}function o(e){if(!Fs(e.zone))throw new Error(a("Invalid reference"));if(e.invalidSheetName)throw new Error(a("Invalid sheet name: %s",e.invalidSheetName))}return[function(e,i,n,r,l,c){const h=i[e];if(o(h),r)return t.getters.getRangeString(h,n);if(h.zone.bottom!==h.zone.top||h.zone.left!==h.zone.right)throw new Error(c?a("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",l.toString(),c.toString()):a("Function %s expects its parameters to be single values or single cell references, not ranges.",l.toString()));return function(e){var i;const o=null===(i=t.getters.getSheet(e.sheetId).rows[e.zone.top])||void 0===i?void 0:i.cells[e.zone.left];return!o||o.isEmpty()?null:s(o,e.sheetId)}(h)},function(e,t,s){return i(t[e])},t]}evaluateAllSheets(){for(const e of this.getters.getVisibleSheets())this.evaluate(e),this.isUpToDate.add(e)}}Mh.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues"],Mh.modes=["normal"];const Ah=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class _h{constructor(){this.graphColorIndex=0}next(){return Ah[this.graphColorIndex++%Ah.length]}}class Oh extends bh{constructor(){super(...arguments),this.chartRuntime={},this.outOfDate=new Set}handle(e){if(Fe.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type&&"content"in e)for(let e of Object.keys(this.chartRuntime))this.outOfDate.add(e);switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":const t=this.getters.getChartDefinition(e.id);this.chartRuntime[e.id]=this.mapDefinitionToRuntime(t);break;case"DELETE_FIGURE":delete this.chartRuntime[e.id];break;case"REFRESH_CHART":this.evaluateUsedSheets([e.id]),this.outOfDate.add(e.id);break;case"ACTIVATE_SHEET":const s=this.getters.getChartsIdBySheet(e.sheetIdTo);this.evaluateUsedSheets(s);break;case"DELETE_SHEET":for(let e of Object.keys(this.chartRuntime))this.getters.getChartDefinition(e)||delete this.chartRuntime[e]}}getChartRuntime(e){if(this.outOfDate.has(e)||!(e in this.chartRuntime)){const t=this.getters.getChartDefinition(e);if(void 0===t)return;this.chartRuntime[e]=this.mapDefinitionToRuntime(t),this.outOfDate.delete(e)}return this.chartRuntime[e]}truncateLabel(e){return e?e.length>20?e.substring(0,20)+"…":e:""}getDefaultConfiguration(e,t){const s={};e.labelRange||1!==e.dataSets.length?s.position=e.legendPosition:s.display=!1;const i={type:e.type,options:{legend:s,responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:e.title}},data:{labels:t.map(this.truncateLabel),datasets:[]}};return"pie"!==e.type?(i.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2}}],yAxes:[{position:e.verticalAxisPosition,ticks:{beginAtZero:!0}}]},"bar"===e.type&&e.stackedBar&&(i.options.scales.xAxes[0].stacked=!0,i.options.scales.yAxes[0].stacked=!0)):i.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},i}getSheetIdsUsedInChart(e){const t=new Set;for(let s of e.dataSets)t.add(s.dataRange.sheetId);return e.labelRange&&t.add(e.labelRange.sheetId),t}evaluateUsedSheets(e){const t=new Set;for(let s of e){const e=this.getters.getChartDefinition(s);(void 0!==e?this.getSheetIdsUsedInChart(e):[]).forEach((e=>{e!==this.getters.getActiveSheetId()&&t.add(e)}))}for(let e of t)this.dispatch("EVALUATE_CELLS",{sheetId:e})}mapDefinitionToRuntime(e){let t=[];if(e.labelRange)e.labelRange.invalidXc||e.labelRange.invalidSheetName||(t=this.getters.getRangeFormattedValues(e.labelRange).flat(1));else if(1===e.dataSets.length)for(let s=0;s<this.getData(e.dataSets[0],e.sheetId).length;s++)t.push("");else if(e.dataSets[0]){t=fs(0,this.getData(e.dataSets[0],e.sheetId).length).map((e=>e.toString()))}const s=this.getDefaultConfiguration(e,t),i=new _h,o=[];if("pie"===e.type){const t=Math.max(...e.dataSets.map((t=>this.getData(t,e.sheetId).length)));for(let e=0;e<=t;e++)o.push(i.next())}for(const[t,n]of Object.entries(e.dataSets)){let r;if(n.labelCell){const e=n.labelCell,s=e?this.getters.getCell(e.sheetId,e.zone.left,e.zone.top):void 0;r=s&&e?this.truncateLabel(s.formattedValue):r=`${hc.Series} ${parseInt(t)+1}`}else r=r=`${hc.Series} ${parseInt(t)+1}`;const a="pie"!==e.type?i.next():"#FFFFFF",l={label:r,data:n.dataRange?this.getData(n,e.sheetId):[],lineTension:0,borderColor:a,backgroundColor:a};"pie"===e.type&&(l.backgroundColor=o),s.data.datasets.push(l)}return s}getData(e,t){if(e.dataRange){const t=e.labelCell?[$s(e.labelCell.zone)]:[],s=zs([$s(e.dataRange.zone)],t)[0];if(void 0===s)return[];const i=this.getters.getRangeFromSheetXC(e.dataRange.sheetId,s);return this.getters.getRangeValues(i).flat(1)}return[]}}Oh.getters=["getChartRuntime"],Oh.modes=["normal"];class Nh extends bh{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.uuidGenerator=new oi,this.rulePredicate={CellIsRule:(e,t)=>{var s,i,o,n,r,l;if(e&&e.evaluated.type===ke.error)return!1;const c=t.values.map(jr);switch(t.operator){case"IsEmpty":return!Ls(e)||""===(null===(s=e.evaluated.value)||void 0===s?void 0:s.toString().trim());case"IsNotEmpty":return Ls(e)&&""!==(null===(i=e.evaluated.value)||void 0===i?void 0:i.toString().trim());case"BeginsWith":return!(!e&&""===c[0])&&(Ls(e)&&(null===(o=e.evaluated.value)||void 0===o?void 0:o.toString().startsWith(c[0].toString())));case"EndsWith":return!(!e&&""===c[0])&&(Ls(e)&&(null===(n=e.evaluated.value)||void 0===n?void 0:n.toString().endsWith(c[0].toString())));case"Between":return Ls(e)&&e.evaluated.value>=c[0]&&e.evaluated.value<=c[1];case"NotBetween":return!(Ls(e)&&e.evaluated.value>=c[0]&&e.evaluated.value<=c[1]);case"ContainsText":return Ls(e)&&(null===(r=e.evaluated.value)||void 0===r?void 0:r.toString().indexOf(c[0].toString()))>-1;case"NotContains":return!Ls(e)||!e.evaluated.value||-1==(null===(l=e.evaluated.value)||void 0===l?void 0:l.toString().indexOf(c[0].toString()));case"GreaterThan":return Ls(e)&&e.evaluated.value>c[0];case"GreaterThanOrEqual":return Ls(e)&&e.evaluated.value>=c[0];case"LessThan":return Ls(e)&&e.evaluated.value<c[0];case"LessThanOrEqual":return Ls(e)&&e.evaluated.value<=c[0];case"NotEqual":return!(!Ls(e)&&""===c[0])&&(Ls(e)&&e.evaluated.value!==c[0]);case"Equal":return!e&&""===c[0]||Ls(e)&&e.evaluated.value===c[0];default:console.warn(a("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch(e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const s=this.getters.getActiveSheetId(),i=this.getters.getRulesByCell(s,e.originCol,e.originRow);for(const t of i)this.adaptRules(s,t,[is(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation);break;case"DUPLICATE_SHEET":case"CREATE_SHEET":case"DELETE_SHEET":case"ADD_CONDITIONAL_FORMAT":case"REMOVE_CONDITIONAL_FORMAT":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":case"UNDO":case"REDO":case"DELETE_CELL":case"INSERT_CELL":this.isStale=!0}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getConditionalStyle(e,t){var s;const i=this.getters.getActiveSheetId(),o=this.computedStyles[i];return o&&(null===(s=o[e])||void 0===s?void 0:s[t])}getConditionalIcon(e,t){var s;const i=this.getters.getActiveSheetId(),o=this.computedIcons[i];return o&&(null===(s=o[e])||void 0===s?void 0:s[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const s=this.computedStyles[t];for(let i of this.getters.getConditionalFormats(t))switch(i.rule.type){case"ColorScaleRule":for(let e of i.ranges)this.applyColorScale(e,i.rule);break;case"IconSetRule":for(let e of i.ranges)this.applyIcon(e,i.rule);break;default:for(let o of i.ranges){const n=ks(o);for(let o=n.top;o<=n.bottom;o++)for(let r=n.left;r<=n.right;r++){const n=this.rulePredicate[i.rule.type];let a=this.getters.getCell(t,r,o);n&&n(a,i.rule)&&(s[r]||(s[r]=[]),s[r][o]=Object.assign((null===(e=s[r])||void 0===e?void 0:e[o])||{},i.rule.style))}}}}parsePoint(e,t,s){switch(t.type){case"value":return this.getters.evaluateFormula(`=${s}(${e})`);case"number":return Number(t.value);case"percentage":const i=this.getters.evaluateFormula(`=min(${e})`);return i+(this.getters.evaluateFormula(`=max(${e})`)-i)*Number(t.value)/100;case"percentile":return this.getters.evaluateFormula(`=PERCENTILE(${e},${Number(t.value)/100})`);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return"number"==typeof o?o:null;default:return null}}applyIcon(e,t){const s=this.parsePoint(e,t.lowerInflectionPoint),i=this.parsePoint(e,t.upperInflectionPoint);if(null===s||null===i||s>i)return;const o=ks(e),n=this.getters.getActiveSheetId(),r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=o.top;e<=o.bottom;e++)for(let l=o.left;l<=o.right;l++){const o=this.getters.getCell(n,l,e);if((null==o?void 0:o.evaluated.type)!==ke.number)continue;const c=this.computeIcon(o.evaluated.value,i,t.upperInflectionPoint.operator,s,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,s,i,o,n){return"ge"===s&&e>=t||"gt"===s&&e>t?n[0]:"ge"===o&&e>=i||"gt"===o&&e>i?n[1]:n[2]}applyColorScale(e,t){var s;const i=this.parsePoint(e,t.minimum,"min"),o=t.midpoint?this.parsePoint(e,t.midpoint):null,n=this.parsePoint(e,t.maximum,"max");if(null===i||null===n||i>=n||o&&(i>=o||o>=n))return;const r=ks(e),a=this.getters.getActiveSheetId(),l=this.computedStyles[a],c=[];t.midpoint&&o?(c.push({minValue:i,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(i,o,t.minimum.color,t.midpoint.color)}),c.push({minValue:o,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.midpoint.color,t.maximum.color)})):c.push({minValue:i,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(i,n,t.minimum.color,t.maximum.color)});for(let e=r.top;e<=r.bottom;e++)for(let t=r.left;t<=r.right;t++){const r=this.getters.getCell(a,t,e);if((null==r?void 0:r.evaluated.type)===ke.number){const a=ps(r.evaluated.value,i,n);let h;h=2===c.length&&o?a<=o?this.colorCell(a,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(a,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(a,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(s=l[t])||void 0===s?void 0:s[e])||{},l[t][e].fillColor="#"+jt(h)}}}computeColorDiffUnits(e,t,s,i){const o=t-e;return[((s>>16)%256-(i>>16)%256)/o,((s>>8)%256-(i>>8)%256)/o,(s%256-i%256)/o]}colorCell(e,t,s,i){const[o,n,r]=i;return Math.round((s>>16)%256-o*(e-t))<<16|Math.round((s>>8)%256-n*(e-t))<<8|Math.round(s%256-r*(e-t))}adaptRules(e,t,s,i){if(0===s.length&&0===i.length)return;const o=this.getters.getConditionalFormats(e),n=o.findIndex((e=>e.id===t.id));let r=[];n>-1&&(r=o[n].ranges),r=r.concat(s);const a=zs(r,i);0!==a.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},target:a.map(ks),sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e})}pasteCf(e,t,s){const i=is(t.col,t.row);for(let o of this.getters.getConditionalFormats(e.sheetId))for(let n of o.ranges)if(Hs(e.col,e.row,ks(n))){const n=o,r=[];if("CUT"===s&&r.push(is(e.col,e.row)),e.sheetId===t.sheetId)this.adaptRules(e.sheetId,n,[i],r);else{this.adaptRules(e.sheetId,n,[],r);const s=this.getCFToCopyTo(t.sheetId,n);this.adaptRules(t.sheetId,s,[i],[])}}}getCFToCopyTo(e,t){const s=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&As(e.rule,t.rule)));return s||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}Nh.getters=["getConditionalStyle","getConditionalIcon"],Nh.modes=["normal"];var kh;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(kh||(kh={}));class Fh extends bh{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.replaceOptions={modifyFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(kh.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(kh.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith,e.replaceOptions);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith,e.replaceOptions);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(kh.current)}updateRegex(){let e=hs(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),s=[];if(this.toSearch)for(const e of Object.values(t))if(e&&this.currentSearchRegex&&this.currentSearchRegex.test(this.searchOptions.searchFormulas&&e.isFormula()?e.content:String(e.evaluated.value))){const t=this.getters.getCellPosition(e.id),i={col:t.col,row:t.row,selected:!1};s.push(i)}return s.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let s;s=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,s=(s%t.length+t.length)%t.length,null!==this.selectedMatchIndex&&this.selectedMatchIndex===s||(this.selectedMatchIndex=s,this.dispatch("SELECT_CELL",{col:t[s].col,row:t[s].row}));for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.replaceOptions={modifyFormulas:!1}}replace(e,t){if(this.replaceOptions=t,null===this.selectedMatchIndex||!this.currentSearchRegex)return;const s=this.searchMatches[this.selectedMatchIndex],i=this.getters.getActiveSheetId(),o=this.getters.getCell(i,s.col,s.row),n=this.toReplace(o,i);if(o&&n){const t=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),i=n.toString().replace(t,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:s.col,row:s.row,content:i}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(kh.current)}else this.selectNextCell(kh.next)}replaceAll(e,t){const s=this.searchMatches.length;for(let i=0;i<s;i++)this.replace(e,t)}toReplace(e,t){if(e){if(this.searchOptions.searchFormulas&&e.isFormula())return e.content;if(this.replaceOptions.modifyFormulas||!e.isFormula())return e.evaluated.value.toString()}return null}drawGrid(e){const{ctx:t,viewport:s}=e,i=this.getters.getActiveSheetId();for(const e of this.searchMatches){const o=this.getters.getMerge(i,e.col,e.row),n=o?o.left:e.col,r=o?o.right:e.col,a=o?o.top:e.row,l=o?o.bottom:e.row,[c,h,d,u]=this.getters.getRect({top:a,left:n,right:r,bottom:l},s);d>0&&u>0&&(t.fillStyle="#8B008B33",t.fillRect(c,h,d,u),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(c,h,d,u)))}}}Fh.layers=[3],Fh.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class $h extends bh{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,s){const i=this.searchNumberFormat(e,t);if(void 0!==i){const o=this.changeDecimalFormat(i,s);this.dispatch("SET_FORMATTING",{sheetId:e,target:t,format:o})}}searchNumberFormat(e,t){var s;for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let o=i.left;o<=i.right;o++){const i=this.getters.getCell(e,o,t);if((null==i?void 0:i.evaluated.type)===ke.number&&!(null===(s=i.format)||void 0===s?void 0:s.match(A)))return i.format||this.setDefaultNumberFormat(i.evaluated.value)}}setDefaultNumberFormat(e){const t=e.toString().split(".");return 1===t.length?"0":"0."+Array(t[1].length+1).join("0")}changeDecimalFormat(e,t){const s=Math.sign(t),i=e.split(";");let o=[];for(let e of i){const t=e.indexOf("."),i=e.toUpperCase().indexOf("E");let n;const r=i>-1?e.slice(0,i):e,a=t>-1?r.slice(t).match(/0/g).length:0,l=r.lastIndexOf("0");l>-1?s>0?n=a<ne?e.slice(0,l+1)+(0===a?".0":"0")+e.slice(l+1):e:a>0?(n=e.slice(0,l)+e.slice(l+1),1===a&&(n=n.slice(0,t)+n.slice(t+1))):n=e:n=e,o.push(n)}return o.join(";")}}$h.modes=["normal"];class Dh extends bh{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){if(0===e.length)return[];const t=this.getters.getActiveSheetId(),s=[];for(let[i,o]of e){const{xc:e,sheetName:n}=es(i),r=n?this.getters.getSheetIdByName(n):t;if(r){let i=ks(e);const{height:n,width:a}=Ws(i);i=n*a==1?this.getters.expandZone(t,ks(e)):i,s.push({zone:i,color:o,sheet:r})}}return s.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getSheet(e.sheet).rows.length&&e.zone.right<this.getters.getSheet(e.sheet).cols.length))}drawGrid(e){const{ctx:t,viewport:s,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;for(let e of this.getHighlights().filter(((e,t)=>this.getHighlights().findIndex((t=>Bs(t.zone,e.zone)&&t.sheet===o))===t))){const[i,o,r,a]=this.getters.getRect(e.zone,s);r>0&&a>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,r-n,a-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,r-2*n,a-2*n))}}}function Uh(e,t){return e.isFormula()&&t?"left":e.defaultAlign}function Ph(e,t){let s=0,i=e.length-1;for(;s<=i;){const o=Math.floor((s+i)/2),n=e[o];if(t<n.start)i=o-1;else if(t>n.end)s=o+1;else{if(!n.isHidden)return o;s+=1}}return-1}Dh.modes=["normal"],Dh.layers=[1],Dh.getters=["getHighlights"];class Bh extends bh{constructor(){super(...arguments),this.boxes=[]}getColIndex(e,t,s){if(e<m)return-1;const i=(s||this.getters.getActiveSheet()).cols;return Ph(i,e-m+i[t].start+1)}getRowIndex(e,t,s){if(e<f)return-1;const i=(s||this.getters.getActiveSheet()).rows;return Ph(i,e-f+i[t].start+1)}getRect(e,t){const{left:s,top:i,right:o,bottom:n}=e;let{offsetY:r,offsetX:a}=t;a-=m,r-=f;const{cols:l,rows:c}=this.getters.getActiveSheet(),h=Math.max(l[s].start-a,m),d=l[o].end-a-h,u=Math.max(c[i].start-r,f);return[h,u,d,c[n].end-r-u]}isVisibleInViewport(e,t,s){const{right:i,left:o,top:n,bottom:r}=s;return t<=r&&t>=n&&e>=o&&e<=i}getEdgeScrollCol(e){let t=!1,s=0,i=0;const{width:o}=this.getters.getViewportDimension(),{width:n}=this.getters.getGridDimension(this.getters.getActiveSheet()),{left:r,offsetX:a}=this.getters.getActiveSnappedViewport();return e<m&&r>0?(t=!0,s=-1,i=as(m-e)):e>o&&a<n-o&&(t=!0,s=1,i=as(e-o)),{canEdgeScroll:t,direction:s,delay:i}}getEdgeScrollRow(e){let t=!1,s=0,i=0;const{height:o}=this.getters.getViewportDimension(),{height:n}=this.getters.getGridDimension(this.getters.getActiveSheet()),{top:r,offsetY:a}=this.getters.getActiveSnappedViewport();return e<f&&r>0?(t=!0,s=-1,i=as(f-e)):e>o&&a<n-o&&(t=!0,s=1,i=as(e-o)),{canEdgeScroll:t,direction:s,delay:i}}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(e),this.drawBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e);break;case 7:this.drawHeaders(e)}}drawBackground(e){const{ctx:t,viewport:s,thinLineWidth:i}=e;let{offsetX:o,offsetY:n,top:r,left:a,bottom:l,right:c}=s;const{width:h,height:d}=this.getters.getViewportDimension(),{cols:u,rows:p,id:g}=this.getters.getActiveSheet();if(t.fillStyle="white",t.fillRect(0,0,h,d),o-=m,n-=f,!this.getters.getGridLinesVisibility(g))return;t.lineWidth=2*i,t.strokeStyle="#E2E3E3",t.beginPath();const v=Math.min(d,p[l].end-n);for(let e=a;e<=c;e++){if(u[e].isHidden)continue;const s=u[e].end-o;t.moveTo(s,0),t.lineTo(s,v)}const E=Math.min(h,u[c].end-o);for(let e=r;e<=l;e++){if(p[e].isHidden)continue;const s=p[e].end-n;t.moveTo(0,s),t.lineTo(E,s)}t.stroke()}drawCellBackground(e){const{ctx:t,thinLineWidth:s}=e;t.lineWidth=.3*s;const i=.1*s;t.strokeStyle="#111";const o=this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());for(let e of this.boxes){let s=e.style;s&&s.fillColor&&"#ffffff"!==s.fillColor&&(t.fillStyle=s.fillColor,t.fillRect(e.x,e.y,e.width,e.height),o&&t.strokeRect(e.x+i,e.y+i,e.width-2*i,e.height-2*i)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawBorders(e){const{ctx:t,thinLineWidth:s}=e;for(let e of this.boxes){let t=e.border;if(t){const{x:s,y:o,width:n,height:r}=e;t.left&&i(t.left,s,o,s,o+r),t.top&&i(t.top,s,o,s+n,o),t.right&&i(t.right,s+n,o,s+n,o+r),t.bottom&&i(t.bottom,s,o+r,s+n,o+r)}}function i([e,i],o,n,r,a){t.strokeStyle=i,t.lineWidth=("thin"===e?2:3)*s,t.beginPath(),t.moveTo(o,n),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:s}=e;let i;t.textBaseline="middle";for(let e of this.boxes)if(e.text){const o=e.style||{},n=e.align,r=o.italic?"italic ":"",a=o.bold?"bold":T,l=o.fontSize||x,c=cs[l],h=`${r}${a} ${c}px ${R}`;let d;h!==i&&(i=h,t.font=h),t.fillStyle=o.textColor||"#000";let u=e.y+e.height/2+1;d="left"===n?e.x+(e.image?e.image.size+2*I:4):"right"===n?e.x+e.width-4:e.x+e.width/2,t.textAlign=n,e.clipRect&&(t.save(),t.beginPath(),t.rect(...e.clipRect),t.clip()),t.fillText(e.text,Math.round(d),Math.round(u)),(o.strikethrough||o.underline)&&("right"===n?d-=e.textWidth:"center"===n&&(d-=e.textWidth/2),o.strikethrough&&t.fillRect(d,u,e.textWidth,2.6*s),o.underline&&(u=e.y+e.height/2+1+c/2,t.fillRect(d,u,e.textWidth,1.3*s))),e.clipRect&&t.restore()}}async drawIcon(e){const{ctx:t}=e;for(let e of this.boxes)if(e.image){let s=e.x,i=e.y;const o=e.image.image,n=e.image.size,r=(e.height-n)/2;e.image.clipIcon&&(t.save(),t.beginPath(),t.rect(...e.image.clipIcon),t.clip()),t.drawImage(o,s+I,i+r,n,n),e.image.clipIcon&&t.restore()}}drawHeaders(e){const{ctx:t,viewport:s,thinLineWidth:i}=e;let{offsetX:o,offsetY:n,left:r,top:a,right:l,bottom:p}=s;const{width:g,height:v}=this.getters.getViewportDimension();o-=m,n-=f;const E=this.getters.getSelectedZones(),{cols:b,rows:S}=this.getters.getActiveSheet(),C=this.getters.getActiveCols(),I=this.getters.getActiveRows();t.fillStyle=c,t.font=`400 11px ${R}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333",t.fillRect(0,0,g,f),t.fillRect(0,0,m,v),t.fillStyle=h;for(let e of E){const s=Math.max(m,b[e.left].start-o),i=Math.max(m,b[e.right].end-o),r=Math.max(f,S[e.top].start-n),a=Math.max(f,S[e.bottom].end-n);t.fillStyle=C.has(e.left)?d:h,t.fillRect(s,0,i-s,f),t.fillStyle=I.has(e.top)?d:h,t.fillRect(0,r,m,a-r)}t.beginPath(),t.moveTo(m,0),t.lineTo(m,v),t.moveTo(0,f),t.lineTo(g,f),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(let e=r;e<=l;e++){const s=b[e];s.isHidden||(t.fillStyle=C.has(e)?"#fff":u,t.fillText(s.name,(s.start+s.end)/2-o,13),t.moveTo(s.end-o,0),t.lineTo(s.end-o,f))}for(let e=a;e<=p;e++){const s=S[e];s.isHidden||(t.fillStyle=I.has(e)?"#fff":u,t.fillText(s.name,24,(s.start+s.end)/2-n),t.moveTo(0,s.end-n),t.lineTo(m,s.end-n))}t.stroke()}hasContent(e,t){const s=this.getters.getActiveSheetId(),i=this.getters.getCell(s,e,t);return i&&!i.isEmpty()||this.getters.isInMerge(s,e,t)}getGridBoxes(e){const{viewport:t}=e;let{right:s,left:i,top:o,bottom:n,offsetX:r,offsetY:a}=t;r-=m,a-=f;const l=this.getters.shouldShowFormulas(),c=[],{cols:h,rows:d,id:u}=this.getters.getActiveSheet();for(let e=o;e<=n;e++){const t=d[e];if(!t.isHidden)for(let o=i;o<=s;o++){const n=h[o];if(n.isHidden)continue;let d=t.cells[o];const p=this.getters.getCellBorder(u,o,e),g=this.getters.getConditionalStyle(o,e),f=this.getters.getConditionalIcon(o,e);if(!this.getters.isInMerge(u,o,e))if(d){const u=this.getters.getCellText(d,l);let m=this.getters.getCellStyle(d);g&&(m=Object.assign({},m,g));let v=u?m&&m.align||Uh(d,l):void 0,E=null,b=null;const S=this.getters.getTextWidth(d),C=m.fontSize||x,y=cs[C],w=f?y+2*I:0,T=w+S>h[o].size||cs[C]>t.size;if(T&&d.evaluated.type===ke.number&&(v="center"!==v?"left":v),f){const e=n.end-n.start;E=[n.start-r+w,t.start-a,Math.max(0,e-w),t.size],b=[n.start-r,t.start-a,Math.min(w,e),t.size]}else if(T){let l,c;switch(v){case"left":for(l=o;l<s&&!this.hasContent(l+1,e);)l++;c=h[l].end-n.start,(c<S||cs[C]>t.size)&&(E=[n.start-r,t.start-a,c,t.size]);break;case"right":for(l=o;l>i&&!this.hasContent(l-1,e);)l--;c=n.end-h[l].start,(c<S||cs[C]>t.size)&&(E=[h[l].start-r,t.start-a,c,t.size]);break;case"center":let d=o;for(;d>i&&!this.hasContent(d-1,e);)d--;let u=o;for(;u<s&&!this.hasContent(u+1,e);)u++;const p=Math.min(d,o),g=Math.max(u,o);c=h[g].end-h[p].start,(c<S||p===o||g===o||cs[C]>t.size)&&(E=[h[p].start-r,t.start-a,c,t.size])}}c.push({x:n.start-r,y:t.start-a,width:n.size,height:t.size,text:u,textWidth:S,border:p,style:m,align:v,clipRect:E,error:d.evaluated.type===ke.error?d.evaluated.error:void 0,image:f?{type:"icon",size:y,clipIcon:b,image:Hl[f].img}:void 0})}else c.push({x:n.start-r,y:t.start-a,width:n.size,height:t.size,text:"",textWidth:0,border:p,style:g||null,align:void 0,clipRect:null,error:void 0})}}const p=this.getters.getActiveSheetId();for(let e of this.getters.getMerges(p))if(!this.getters.isMergeHidden(p,e)&&Vs(e,t)){const t=this.getters.getCell(p,e.left,e.top),s=this.getters.getCellBorder(p,e.left,e.top),i=this.getters.getCellBorder(p,e.right,e.bottom),o=h[e.right].end-h[e.left].start;let n,u,g,f,m;if(g=t?this.getters.getCellStyle(t):null,t||i||s){n=t?this.getters.getCellText(t,l):"",u=t?this.getters.getTextWidth(t):null;const o=this.getters.getConditionalStyle(e.topLeft.col,e.topLeft.row);o&&(g=Object.assign({},g,o)),f=n?g&&g.align||Uh(t,l):null,m={bottom:i?i.bottom:null,left:s?s.left:null,right:i?i.right:null,top:s?s.top:null}}g=g||{},g.fillColor&&"#ffffff"!==g.fillColor||(g=Object.create(g),g.fillColor="#fff");const v=h[e.left].start-r,E=d[e.top].start-a,b=d[e.bottom].end-d[e.top].start,S=this.getters.getConditionalIcon(e.left,e.top),C=g.fontSize||x,y=cs[C],w=S?2*I+y:0,T=w+u;f=n&&(null==t?void 0:t.evaluated.type)===ke.number&&T>o&&"center"!==f?"left":f;const R=S?[v+w,E,Math.max(0,o-w),b]:[v,E,o,b],L=S?[v,E,Math.min(w,o),b]:null;c.push({x:v,y:E,width:o,height:b,text:n,textWidth:u,border:m,style:g,align:f,clipRect:R,error:t&&t.evaluated.type===ke.error?t.evaluated.error:void 0,image:S?{type:"icon",clipIcon:L,size:y,image:Hl[S].img}:void 0})}return c}}Bh.layers=[0,7],Bh.getters=["getColIndex","getRowIndex","getRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow"],Bh.modes=["normal"];const Vh=new oi;class Hh extends bh{constructor(){super(...arguments),this.inputs={},this.activeSheets={},this.inputHasSingleRange={},this.focusedInputId=null,this.focusedRange=null,this.willAddNewRange=!1}allowDispatch(e){switch(e.type){case"FOCUS_RANGE":const t=this.getIndex(e.id,e.rangeId);if(this.focusedInputId===e.id&&this.focusedRange===t)return 24;break;case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange[e.id]&&1===this.inputs[e.id].length)return 25}return 0}handle(e){switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id],delete this.activeSheets[e.id],delete this.inputHasSingleRange[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(e.id,this.getIndex(e.id,e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.id,e.rangeId);if(null!==t){const s=e.id;this.focusedInputId===s&&this.focusedRange===t||this.dispatch("FOCUS_RANGE",{id:s,rangeId:this.inputs[s][t].id});const i=e.value.split(",").map((e=>e.trim()));this.setRange(s,t,i)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(e.id,this.inputs[e.id].length,[""]),this.focusLast(e.id);break;case"REMOVE_RANGE":const t=this.getIndex(e.id,e.rangeId);null!==t&&this.removeRange(e.id,t);break;case"SELECT_CELL":case"SET_SELECTION":if(!this.focusedInputId)break;const s=this.getSelectionInputValue(this.focusedInputId),i=(this.inputHasSingleRange[this.focusedInputId]?[this.getters.getSelectedZone()]:this.getters.getSelectedZones()).map($s).filter((e=>!s.includes(e))),o=this.activeSheets[this.focusedInputId],n=this.getters.getActiveSheetId(),r=this.getters.getSheetName(n);this.add(i.map((e=>n===o?e:`${us(r)}!${e}`)));break;case"PREPARE_SELECTION_EXPANSION":{const[e,t]=[this.focusedInputId,this.focusedRange];null===e||null===t||this.inputHasSingleRange[e]||(this.willAddNewRange=""!==this.inputs[e][t].xc.trim());break}}}getSelectionInput(e){return this.inputs[e]?this.inputs[e].map(((t,s)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.focusedRange&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.focusedRange===s}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:s}=es(e);return null!==t.match(Jt)&&(!s||void 0!==this.getters.getSheetIdByName(s))}getSelectionInputValue(e){return this.cleanInputs(this.inputs[e].map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].map((e=>this.inputToHighlights(this.focusedInputId,e))).flat():[]}initInput(e,t,s=!1){this.inputs[e]=[],this.insertNewRange(e,0,t),this.activeSheets[e]=this.getters.getActiveSheetId(),this.inputHasSingleRange[e]=s,0===this.inputs[e].length&&this.dispatch("ADD_EMPTY_RANGE",{id:e})}focus(e,t){this.focusedInputId=e,this.focusedRange=t}focusLast(e){this.focus(e,this.inputs[e].length-1)}unfocus(){this.focusedInputId=null,this.focusedRange=null}add(e){if(null===this.focusedInputId||null===this.focusedRange||this.getters.isSelectingForComposer()||0===e.length)return;if(this.getters.getSelectionMode()===wh.expanding&&this.willAddNewRange){const t=this.focusedInputId;this.insertNewRange(t,this.inputs[t].length,e),this.focusLast(this.focusedInputId),this.willAddNewRange=!1}else this.setRange(this.focusedInputId,this.focusedRange,e)}setContent(e,t,s){this.inputs[e][t]={...this.inputs[e][t],id:Vh.uuidv4(),xc:s}}insertNewRange(e,t,s){this.inputs[e].splice(t,0,...s.map(((t,s)=>({xc:t,id:(this.inputs[e].length+s+1).toString(),color:Xt()}))))}setRange(e,t,s){const[,...i]=s;this.setContent(e,t,s[0]),this.insertNewRange(e,t+1,i),i.length&&this.focus(e,t+i.length)}removeRange(e,t){this.inputs[e].splice(t,1),this.focusedInputId===e&&null!==this.focusedRange&&this.focusLast(e)}inputToHighlights(e,{xc:t,color:s}){const i=this.cleanInputs([t]).filter((e=>this.isRangeValid(e))).filter((t=>this.shouldBeHighlighted(this.activeSheets[e],t)));if(0===i.length)return[];const[o,...n]=i,r=[[o,s||Xt()]];for(const e of n)r.push([e,Xt()]);return r}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:s}=es(t),i=this.getters.getSheetIdByName(s),o=this.getters.getActiveSheet().id;return this.isRangeValid(t)&&(i===o||void 0===i&&o===e)}getIndex(e,t){const s=this.inputs[e].findIndex((e=>e.id===t));return s>=0?s:null}}Hh.modes=["normal"],Hh.layers=[1],Hh.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class zh{constructor(){this.bus=new i.core.EventBus}on(e,t,s){this.bus.on(e,t,s)}trigger(e,t){this.bus.trigger(e,t)}off(e,t){this.bus.off(e,t)}clear(){this.bus.clear()}}function Zh(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?function(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--;if(!(o>n))return{...e,[t]:o,[i]:n}}(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?function(e,t,s,i,o){const n="left"===t?"columns":"rows",r="before"===i?s-1:s,a="left"===t?"right":"bottom",l="before"===i?e[a]>r:e[a]>=r;return e[t]<=r&&l?Ys(e,n,"RESIZE",o):r<e[t]?Ys(e,n,"MOVE",o):{...e}}(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Gh(e,t){const s=e.definition;let i,o;return s.labelRange&&(i=Zh(ks(s.labelRange),t)),s.dataSets&&(o=s.dataSets.map(ks).map((e=>Zh(e,t))).filter(Ls).map($s)),{...e,definition:{...s,dataSets:o,labelRange:i?$s(i):void 0}}}gl.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Gh),gl.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Gh),gl.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),gl.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var s;if(e.name===t.name)return{...e,name:(null===(s=e.name)||void 0===s?void 0:s.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),gl.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const s=[];for(const i of e.target)for(const e of t.target)Vs(i,e)||s.push({...i});if(s.length)return{...e,target:s};return}));const Wh=[{match:function(e){return"sheetId"in e},fn:function(e,t){const s="DELETE_SHEET"===t.type&&t.sheetId;if(e.sheetId===s)return"IGNORE_COMMAND";if("CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId)return e;return"SKIP_TRANSFORMATION"}},{match:function(e){return"target"in e},fn:function(e,t){const s=[];for(const i of e.target){const e=Zh(i,t);e&&s.push(e)}if(!s.length)return"IGNORE_COMMAND";return{...e,target:s}}},{match:function(e){return"col"in e&&"row"in e},fn:function(e,t){if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const s="COL"===t.dimension?"col":"row";let i=e[s];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(i))return"IGNORE_COMMAND";for(let t of e)i>=t&&i--}"ADD_COLUMNS_ROWS"===t.type&&(i>t.base||i===t.base&&"before"===t.position)&&(i+=t.quantity);return{...e,[s]:i}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const s of t.target){if(!(e.col===s.left&&e.row===s.top)&&Hs(e.col,e.row,s))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e},fn:function(e,t){if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const s="ADD_COLUMNS_ROWS"===e.type,i=s?"base":"elements";let o=s?[e[i]]:e[i];if("REMOVE_COLUMNS_ROWS"===t.type&&(o=o.map((e=>{if(t.elements.includes(e))return;const s=t.elements.sort(((e,t)=>t-e));for(let t of s)e>t&&e--;return e})).filter(Ls)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;o=o.map((s=>s>e?s+t.quantity:s))}if(o.length){let t=o;return s&&(t=o[0]),{...e,[i]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}}];function qh(e,t){const s=gl.getTransformation(e.type,t.type);return s?s(e,t):function(e,t){for(const{match:s,fn:i}of Wh)if(s(e)){const s=i(e,t);if("SKIP_TRANSFORMATION"===s)continue;if("IGNORE_COMMAND"===s)return;return s}return e}(e,t)}function jh(e,t){let s=[...e];for(const e of t)s=s.map((t=>qh(t,e))).filter(Ls);return s}class Yh{constructor(e,t,s,i){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...s],this._changes=i?[...i]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Xh extends Error{}class Kh extends zh{constructor(e,t,s=O){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=s,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new oi,this.debouncedMove=i.utils.debounce(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const s=new Yh(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(s.id,s),this.trigger("new-local-state-update",{id:s.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:s.id,clientId:s.clientId,commands:s.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new Xh("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(Ls))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const s=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==s?void 0:s.col)===e.col&&s.row===e.row&&s.sheetId===e.sheetId)return;const i=s?"CLIENT_MOVED":"CLIENT_JOINED",o=this.getClient();this.clients[this.clientId]={...o,position:e},this.transportService.sendMessage({type:i,version:1,client:{...o,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":const{clientId:t,commands:s}=e,i=new Yh(e.nextRevisionId,t,s);if(i.clientId!==this.clientId){this.revisions.insert(i.id,i,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:jh(s,t)})}break;case"SNAPSHOT_CREATED":{const t=new Yh(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Qh=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class Jh extends bh{constructor(){super(...arguments),this.availableColors=new Set(Qh),this.colors={}}isPositionValid(e){const t=this.getters.getSheet(e.sheetId);return e.row<t.rows.length&&e.col<t.cols.length}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(Qh));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof Xh)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const s of this.getters.getConnectedClients())if(s.id!==this.getters.getClient().id&&s.position&&s.position.sheetId===e&&this.isPositionValid(s.position)){const e=s.position;this.colors[s.id]||(this.colors[s.id]=this.chooseNewColor());const i=this.colors[s.id];t.push({...s,position:e,color:i})}return t}drawGrid(e){const{viewport:t,ctx:s,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:r}=e.position,a=this.getters.expandZone(o,{top:n,bottom:n,left:r,right:r}),[l,c,h,d]=this.getters.getRect(a,t);if(h<=0||d<=0)continue;const u=e.color,p=`${u}10`;s.fillStyle=p,s.lineWidth=4*i,s.strokeStyle=u,s.globalCompositeOperation="multiply",s.fillRect(l,c,h,d),s.globalCompositeOperation="source-over",s.strokeRect(l,c,h,d),s.font=`bold ${x+1}px ${R}`}}}Jh.getters=["getClientsToDisplay"],Jh.layers=[5],Jh.modes=["normal"];class ed extends bh{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Hs(e.anchor[0],e.anchor[1],e.zone))throw new Error(a("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)e.interactive?this.interactiveSortSelection(e.sheetId,e.anchor,e.zone,e.sortDirection):this.sortZone(e.sheetId,e.anchor,e.zone,e.sortDirection)}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;for(let s=t.top;s<=t.bottom;s++)for(let i=t.left;i<=t.right;i++)if(!this.getters.isInMerge(e,i,s))return 48;return 0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const s=this.getters.getMerges(e).filter((e=>Vs(e,t))),i=Ws(s[0]);let[o,n]=[i.width,i.height];return s.every((e=>{let[t,s]=[e.right-e.left+1,e.bottom-e.top+1];return t===o&&s===n}))?0:48}interactiveSortSelection(e,t,s,i){let o=Pe.Success,n=s.right>s.left;if(this.getters.doesIntersectMerge(e,s)){let t;n=!1;for(let i=s.top;i<=s.bottom;i++){t=[];for(let o=s.left;o<=s.right;o++){let s=this.getters.getMerge(e,o,i);s&&!t.includes(s.id.toString())&&t.push(s.id.toString())}if(t.length>=2){n=!0;break}}}if(n)o=this.dispatch("SORT_CELLS",{sheetId:e,anchor:t,zone:s,sortDirection:i});else{const n=this.getContiguousZone(e,s);Bs(n,s)?o=this.dispatch("SORT_CELLS",{sheetId:e,anchor:t,zone:s,sortDirection:i}):this.ui.askConfirmation(a("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{s=n,o=this.dispatch("SORT_CELLS",{sheetId:e,anchor:t,zone:s,sortDirection:i})}),(()=>{o=this.dispatch("SORT_CELLS",{sheetId:e,anchor:t,zone:s,sortDirection:i})}))}o.isCancelledBecause(48)&&(this.dispatch("SET_SELECTION",{anchor:t,zones:[s],anchorZone:s}),this.ui.notifyUser(a("Cannot sort. To sort, select only cells or only merges that have the same size.")))}expand(e,t){const{left:s,right:i,top:o,bottom:n}=this.getters.expandZone(e.id,t);return{left:Math.max(0,s),right:Math.min(e.cols.length-1,i),top:Math.max(0,o),bottom:Math.min(e.rows.length-1,n)}}checkExpandedValues(e,t){const s=this.expand(e,t),i=e.id;let o,n=[];if(this.getters.doesIntersectMerge(i,s)){const{left:e,right:t,top:r,bottom:a}=s;for(let s=e;s<=t;s++)for(let e=r;e<=a;e++){const[t,r]=this.getters.getMainCell(i,s,e);o=this.getters.getCell(i,t,r),n.push((null==o?void 0:o.formattedValue)||"")}}else{const t=Gs(s,e,(e=>e.formattedValue),"");n=t.flat()}return n.some((e=>""!==e))}getContiguousZone(e,t){let s,{top:i,bottom:o,left:n,right:r}=t;const a=this.getters.getSheet(e);let l=!1;for(;!l;)l=!0,i>0&&(s=this.checkExpandedValues(a,{left:n-1,right:r+1,top:i-1,bottom:i-1}),s&&(l=!1,i--)),n>0&&(s=this.checkExpandedValues(a,{left:n-1,right:n-1,top:i-1,bottom:o+1}),s&&(l=!1,n--)),r<a.cols.length-1&&(s=this.checkExpandedValues(a,{left:r+1,right:r+1,top:i-1,bottom:o+1}),s&&(l=!1,r++)),o<a.rows.length-1&&(s=this.checkExpandedValues(a,{left:n-1,right:r+1,top:o+1,bottom:o+1}),s&&(l=!1,o++));return{left:n,right:r,top:i,bottom:o}}hasHeader(e,t,s,i){const{left:o,right:n,top:r,bottom:a}=t;if(a-r+1==1)return!1;let l=Gs({left:o,right:n,top:r,bottom:r+2*i-1},e,(e=>e.evaluated.type),ke.empty,s,i);return l[0][0]===ke.empty&&(l=l.slice(1)),!l.some((e=>e[0]===ke.empty))&&!!l.some((e=>e[1]!==ke.empty&&e[0]!==e[1]))}sortCellsList(e,t){const s=e.map(((e,t)=>({index:t,val:e}))),i=s.filter((e=>!(null==e.val||""===e.val.evaluated.value))),o=s.filter((e=>null==e.val||""===e.val.evaluated.value)),n="descending"===t?-1:1,r=[ke.number,ke.error,ke.text,ke.boolean];return i.map((e=>{return{index:e.index,val:(t=e.val,{type:t.evaluated.type,value:t.evaluated.value})};var t})).sort(((e,t)=>{let s=r.indexOf(e.val.type)-r.indexOf(t.val.type);return 0===s&&(s=e.val.type===ke.text||e.val.type===ke.error?e.val.value.localeCompare(t.val.value):e.val.value-t.val.value),n*s})).concat(o)}sortZone(e,t,s,i){let o=1,n=1,r=t[0],a=Object.assign({},s);if(this.getters.doesIntersectMerge(e,a)){const[s,i]=t,a=this.getters.getMerge(e,s,i);o=a.right-a.left+1,n=a.bottom-a.top+1,r=a.topLeft.col}const l=this.getters.getSheet(e);this.hasHeader(l,a,o,n)&&(a.top+=n);const c=Gs(a,l,(e=>e),void 0,o,n),h=c[r-a.left],d=this.sortCellsList(h,i).map((e=>e.index)),[u,p]=[c.length,c[0].length];for(let t=0;t<u;t++)for(let s=0;s<p;s++){let i=c[t][d[s]],r=a.left+t*o,l=a.top+s*n,h={sheetId:e,col:r,row:l,content:"",value:""};if(i){let t=i.content;if(i.isFormula()){const s=l-this.getters.getCellPosition(i.id).row,o=this.getters.createAdaptedRanges(i.dependencies.references,0,s,e);t=this.getters.buildFormulaContent(e,i.normalizedText,{...i.dependencies,references:o})}h.style=i.style,h.content=t,h.format=i.format,h.value=i.evaluated.value}this.dispatch("UPDATE_CELL",h)}}}ed.getters=["getContiguousZone"];class td extends bh{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}td.modes=["normal"],td.getters=["shouldShowFormulas"];class sd extends bh{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":case"DELETE_SHEET_CONFIRMATION":try{this.getters.getSheet(e.sheetId);break}catch(e){return 23}}return 0}handle(e){switch(e.type){case"RENAME_SHEET":e.interactive&&this.interactiveRenameSheet(e.sheetId,a("Rename Sheet"));break;case"DELETE_SHEET_CONFIRMATION":this.interactiveDeleteSheet(e.sheetId);break;case"ADD_MERGE":e.interactive&&this.interactiveMerge(e.sheetId,e.target);break;case"AUTORESIZE_COLUMNS":for(let t of e.cols){const s=this.getColMaxWidth(e.sheetId,t);0!==s&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:s+6,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows){const s=this.getRowMaxHeight(e.sheetId,t);0!==s&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:s+6,sheetId:e.sheetId})}}}getCellWidth(e){let t=this.getTextWidth(e);const s=this.getters.getCellPosition(e.id);return this.getters.getConditionalIcon(s.col,s.row)&&(t+=function(e,t){const s=t.fontSize||x;return cs[s]+2*I}(this.ctx,this.getters.getCellStyle(e))),t}getTextWidth(e){const t=this.getters.getCellText(e,this.getters.shouldShowFormulas());return gs(this.ctx,t,this.getters.getCellStyle(e))}getCellHeight(e){const t=this.getters.getCellStyle(e).fontSize||x;return cs[t]}getCellText(e,t=!1){return t&&(e.isFormula()||e.evaluated.type===ke.error)?e.content:e.formattedValue}getColMaxWidth(e,t){const s=this.getters.getColCells(e,t).map((e=>this.getCellWidth(e)));return Math.max(0,_s(s))}getRowMaxHeight(e,t){const s=this.getters.getSheet(e),i=Object.values(s.rows[t].cells).map((e=>this.getCellHeight(e)));return Math.max(0,_s(i))}interactiveRenameSheet(e,t){const s=this.getters.getSheetName(e);this.ui.editText(t,s,(t=>{if(!t)return;const s=this.dispatch("RENAME_SHEET",{sheetId:e,name:t}),i=this.getters.getSheetName(e);s.isSuccessful||i===t||this.interactiveRenameSheet(e,a("Please enter a valid sheet name"))}))}interactiveDeleteSheet(e){this.ui.askConfirmation(a("Are you sure you want to delete this sheet ?"),(()=>{this.dispatch("DELETE_SHEET",{sheetId:e})}))}interactiveMerge(e,t){const s=this.dispatch("ADD_MERGE",{sheetId:e,target:t});s.isSuccessful||s.isCancelledBecause(3)&&this.ui.askConfirmation(a("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),(()=>{this.dispatch("ADD_MERGE",{sheetId:e,target:t,force:!0})}))}}sd.getters=["getCellWidth","getCellHeight","getTextWidth","getCellText"];class id extends bh{constructor(){super(...arguments),this.viewports={},this.snappedViewports={},this.updateSnap=!1,this.clientWidth=1e3,this.clientHeight=1e3}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkOffsetValidity(e.offsetX,e.offsetY);case"RESIZE_VIEWPORT":return e.width<0||e.height<0?54:0;default:return 0}}handle(e){switch(e.type){case"UNDO":case"REDO":this.cleanViewports(),this.resetViewports();break;case"RESIZE_VIEWPORT":this.cleanViewports(),this.resizeViewport(e.height,e.width);break;case"SET_VIEWPORT_OFFSET":this.setViewportOffset(e.offsetX,e.offsetY);break;case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":"COL"===e.dimension?this.adjustViewportOffsetX(e.sheetId,this.getViewport(e.sheetId)):this.adjustViewportOffsetY(e.sheetId,this.getViewport(e.sheetId));break;case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":"COL"===e.dimension?this.adjustViewportZoneX(e.sheetId,this.getViewport(e.sheetId)):this.adjustViewportZoneY(e.sheetId,this.getViewport(e.sheetId));break;case"ACTIVATE_SHEET":this.refreshViewport(e.sheetIdTo);break;case"SELECT_CELL":case"MOVE_POSITION":this.refreshViewport(this.getters.getActiveSheetId())}}finalize(){this.updateSnap&&(this.snapViewportToCell(this.getters.getActiveSheetId()),this.updateSnap=!1)}getViewportDimension(){return{width:this.clientWidth,height:this.clientHeight}}getActiveViewport(){const e=this.getters.getActiveSheetId();return this.getViewport(e)}getActiveSnappedViewport(){const e=this.getters.getActiveSheetId();return this.getSnappedViewport(e)}getGridDimension(e){const t=ai(e,"cols"),s=this.clientWidth-m,i=ai(e,"rows"),o=this.clientHeight-f,n=e.cols.find((e=>e.end>t.end-s))||e.cols[e.cols.length-1],r=e.rows.find((e=>e.end>i.end-o))||e.rows[e.rows.length-1];return{width:t.end+Math.max(E,Math.min(n.size,s-t.size)),height:i.end+Math.max(b+5,Math.min(r.size,o-i.size))}}getMaximumViewportOffset(e){const{width:t,height:s}=this.getters.getGridDimension(e);return{maxOffsetX:Math.max(0,t-this.clientWidth+m+1),maxOffsetY:Math.max(0,s-this.clientHeight+f+1)}}checkOffsetValidity(e,t){const s=this.getters.getActiveSheet(),{maxOffsetX:i,maxOffsetY:o}=this.getMaximumViewportOffset(s);return e<0||t<0||t>o||e>i?53:0}getSnappedViewport(e){return this.snapViewportToCell(e),this.snappedViewports[e]}getViewport(e){return this.viewports[e]?this.viewports[e]:this.generateViewportState(e)}cleanViewports(){const e=this.getters.getVisibleSheets();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetViewports(){for(let[e,t]of Object.entries(this.viewports))this.adjustViewportOffsetX(e,t),this.adjustViewportOffsetY(e,t),this.adjustViewportsPosition(e)}adjustViewportOffsetX(e,t){const{offsetX:s}=t,{width:i}=this.getGridDimension(this.getters.getSheet(e));if(this.clientWidth-m+s>i){const e=this.clientWidth-m+s-i;t.offsetX=Math.max(0,s-e)}this.adjustViewportZoneX(e,t)}adjustViewportOffsetY(e,t){const{offsetY:s}=t,{height:i}=this.getGridDimension(this.getters.getSheet(e));if(this.clientHeight-f+s>i){const e=this.clientHeight-f+s-i;t.offsetY=Math.max(0,s-e)}this.adjustViewportZoneY(e,t)}resizeViewport(e,t){this.clientHeight=e,this.clientWidth=t,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.adjustViewportOffsetX(e,this.viewports[e]),this.adjustViewportOffsetY(e,this.viewports[e])}setViewportOffset(e,t){const s=this.getters.getActiveSheetId();this.getActiveViewport(),this.viewports[s].offsetX=e,this.viewports[s].offsetY=t,this.adjustViewportZone(s,this.viewports[s])}generateViewportState(e){return this.viewports[e]={left:0,right:0,top:0,bottom:0,offsetX:0,offsetY:0},this.viewports[e]}refreshViewport(e){const t=this.getViewport(e);this.adjustViewportZone(e,t),this.adjustViewportsPosition(e)}adjustViewportZone(e,t){this.adjustViewportZoneX(e,t),this.adjustViewportZoneY(e,t)}adjustViewportZoneX(e,t){const s=this.getters.getSheet(e),i=s.cols;t.left=this.getters.getColIndex(t.offsetX+m,0,s);const o=this.clientWidth+t.offsetX-m;t.right=i.length-1;for(let e=t.left;e<i.length;e++)if(o<i[e].end){t.right=e;break}this.updateSnap=!0}adjustViewportZoneY(e,t){const s=this.getters.getSheet(e),i=s.rows;t.top=this.getters.getRowIndex(t.offsetY+f,0,s);const o=this.clientHeight+t.offsetY-f;t.bottom=i.length-1;for(let e=t.top;e<i.length;e++)if(o<i[e].end){t.bottom=e;break}this.updateSnap=!0}adjustViewportsPosition(e,t){const s=this.getters.getSheet(e),{cols:i,rows:o}=s,n=this.getSnappedViewport(e);t=t||this.getters.getSheetPosition(e);const[r,a]=ni(s,...this.getters.getMainCell(e,t[0],t[1]));for(;i[r].end>n.offsetX+this.clientWidth-m&&n.offsetX<i[r].start;)n.offsetX=i[n.left].end,this.adjustViewportZoneX(e,n);for(;r<n.left;){const t=i.slice(0,n.left).reverse().findIndex((e=>!e.isHidden));n.offsetX=i[n.left-1-t].start,this.adjustViewportZoneX(e,n)}for(;o[a].end>n.offsetY+this.clientHeight-f&&n.offsetY<o[a].start;)n.offsetY=o[n.top].end,this.adjustViewportZoneY(e,n);for(;a<n.top;){const t=o.slice(0,n.top).reverse().findIndex((e=>!e.isHidden));n.offsetY=o[n.top-1-t].start,this.adjustViewportZoneY(e,n)}const{top:l,left:c}=this.viewports[e];l===n.top&&c===n.left||(this.viewports[e]=n),this.updateSnap=!1}snapViewportToCell(e){const{cols:t,rows:s}=this.getters.getSheet(e),i=this.getViewport(e),o=Object.assign({},i);this.adjustViewportOffsetX(e,o),this.adjustViewportOffsetY(e,o),o.offsetX=t[o.left].start,o.offsetY=s[o.top].start,this.adjustViewportZone(e,o),this.snappedViewports[e]=o}}id.getters=["getActiveViewport","getSnappedViewport","getActiveSnappedViewport","getViewportDimension","getGridDimension","getMaximumViewportOffset"],id.modes=["normal"];const od=(new Le).add("sheet",xa).add("cell",ba).add("merge",wa).add("borders",va).add("conditional formatting",Ia).add("figures",ya).add("chart",Sa),nd=(new Le).add("selection",Th).add("ui_sheet",sd).add("ui_options",td).add("evaluation",Mh).add("evaluation_cf",Nh).add("evaluation_chart",Oh).add("clipboard",yh).add("edition",Rh).add("highlight",Dh).add("selectionInput",Hh).add("viewport",id).add("grid renderer",Bh).add("autofill",Ch).add("find_and_replace",Fh).add("sort",ed).add("automatic_sum",Ih).add("format",$h).add("selection_multiuser",Jh);class rd{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}class ad extends i.core.EventBus{constructor(){super(...arguments),this.registry=new Le}add(e,t){this.registry.add(e,t);const s=i.utils.debounce((()=>this.trigger("data-loaded",{id:e})),0);return t.on("data-loaded",this,(()=>s())),t.loadMetadata(),this}get(e){return this.registry.get(e)}getAll(){return this.registry.getAll()}remove(e){this.get(e).off("data-loaded",this),this.registry.remove(e)}async waitForReady(){const e=[];for(const t of this.getAll())e.push(t.get());return Promise.all(e)}}class ld extends i.core.EventBus{async loadMetadata(){this.metadataPromise||(this.metadataPromise=this._fetchMetadata().then((e=>(this.metadata=e,e)))),await this.metadataPromise}async get(e){return e&&e.forceFetch&&(this.data=void 0,this.dataPromise=void 0),await this.loadMetadata(),this.dataPromise||(this.dataPromise=this._fetch(e).then((e=>(this.data=e,this.lastUpdate=Date.now(),this.trigger("data-loaded"),e)))),this.dataPromise}getSync(){return this.data}getMetadataSync(){return this.metadata}getLastUpdate(){return this.lastUpdate}}function cd(e){return Aa.get(e.type)(e)}function hd(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class dd{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const s of this.operations){if(s.id===e)return e;if(s.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const s=this.buildTransformation.with(e.data),{before:i,operation:o,after:n}=this.locateOperation(t);this.operations=[...i,o,e,...n.map((e=>e.transformed(s)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new dd(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:s}=this.locateOperation(e);this.operations=t.concat([s])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class ud{constructor(e,t){this.id=e,this.data=t}transformed(e){return new ud(this.id,e(this.data))}}class pd{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new pd(function*(e,t){for(const s of e)if(yield s,s.operation.id===t)return}(this.operations,e))}stopBefore(e){return new pd(function*(e,t){for(const s of e){if(s.operation.id===t)return;yield s}}(this.operations,e))}startAfter(e){return new pd(function*(e,t){let s=!0;for(const i of e)s||(yield i),i.operation.id===t&&(s=!1)}(this.operations,e))}}class gd{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new pd(vs(this._execution(e),this._execution(e)))}revertedExecution(e){return new pd(vs(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var s;const i=e.getLastOperationId()||(null===(s=this.previousBranch(e))||void 0===s?void 0:s.getLastOperationId());e.append(t),i&&this.insertPrevious(e,t,i)}insertOperationAfter(e,t,s){e.insert(t,s),this.updateNextWith(e,t,s),this.insertPrevious(e,t,s)}undo(e,t){const s=this.buildTransformation.without(t.data),i=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const o=e.fork(t.id);i&&this.branchingOperationIds.set(o,i),this.insertBranchAfter(e,o),this.transform(o,s)}redo(e){const t=this.nextBranch(e);if(!t)return;const s=this.nextBranch(t);this.removeBranchFromTree(t);const i=this.branchingOperationIds.get(t);i?this.branchingOperationIds.set(e,i):this.branchingOperationIds.delete(e),s&&this.rebaseUp(s)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const s of this.revertedExecution(e))if(s.operation.id===t)return s;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:s}=this.findPreviousBranchingOperation(e);if(!t||!s)return;const i=this.buildTransformation.without(s.data),o=t.fork(s.id);this.branchingOperationIds.set(o,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,o),o.transform(i);const n=this.nextBranch(o);n&&this.rebaseUp(n)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const s=this.branches.findIndex((t=>t===e));this.branches.splice(s+1,0,t)}updateNextWith(e,t,s){const i=this.branchingOperationIds.get(e),o=this.nextBranch(e);if(i&&o)if(e.getFirstOperationAmong(s,i)===i){const n=this.addToNextBranch(e,o,i,t,s);this.updateNextWith(o,n,s)}else{const e=this.buildTransformation.with(t.data);this.transform(o,e)}}addToNextBranch(e,t,s,i,o){let n=i;return o===s?(n=this.getTransformedOperation(e,s,i),t.prepend(n)):t.contains(o)?(n=this.getTransformedOperation(e,s,i),t.insert(n,o)):t.append(i),n}getTransformedOperation(e,t,s){const i=e.getOperation(t),o=this.buildTransformation.without(i.data);return s.transformed(o)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const s=this.nextBranch(e);s&&this.transform(s,t)}insertPrevious(e,t,s){const{previousBranch:i,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!i||!o)return;const n=this.buildTransformation.with(o.data),r=e.fork(s);r.transform(n),i.cutAfter(s),i.appendBranch(r);const a=t.transformed(n);this.insertPrevious(i,a,s)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const s=this.branchingOperationIds.get(t);return s?{previousBranch:t,branchingOperation:t.getOperation(s)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let s=!!t;const i=e.getOperations();for(let o=i.length-1;o>=0;o--){const n=i[o];n.id===t&&(s=!1),s||(yield{operation:n,branch:e,isCancelled:!this.shouldExecute(e,n)})}const o=this.previousBranch(e);yield*o?this._revertedExecution(o):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class fd{constructor(e,t,s,i,o){this.applyOperation=t,this.revertOperation=s,this.buildEmpty=i,this.buildTransformation=o,this.HEAD_BRANCH=new dd(this.buildTransformation),this.tree=new gd(o,this.HEAD_BRANCH);const n=new ud(e,i(e));this.tree.insertOperationLast(this.HEAD_BRANCH,n),this.HEAD_OPERATION=n}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const s=new ud(e,t),i=this.tree.getLastBranch();this.tree.insertOperationLast(i,s),this.HEAD_BRANCH=i,this.HEAD_OPERATION=s}insert(e,t,s){const i=new ud(e,t);this.revertTo(s),this.tree.insertOperationAfter(this.HEAD_BRANCH,i,s),this.fastForward()}undo(e,t,s){const{branch:i,operation:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(i,o),this.fastForward(),this.insert(t,this.buildEmpty(t),s)}redo(e,t,s){const{branch:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(i),this.fastForward(),this.insert(t,this.buildEmpty(t),s)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:s,isCancelled:i}of e)i||this.revertOperation(s.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:s,isCancelled:i}of e)i||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=s}}function md(e,t,s){return new fd(e,(e=>{const i=e.commands.slice(),{changes:o}=t((()=>{for(const e of i)s(e)}));e.setChanges(o)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){vd(t.changes[e],"before")}}([e])),(e=>new Yh(e,"empty",[],[])),{with:e=>t=>new Yh(t.id,t.clientId,jh(t.commands,e.commands)),without:e=>t=>new Yh(t.id,t.clientId,jh(t.commands,e.commands.map(cd).flat()))})}function vd(e,t){let s=e.path[0];const i=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const i=e.path[t];if(void 0===s[i]){const o=e.path[t+1];s[i]=hd(o)}s=s[i]}void 0===e[t]?delete s[i]:s[i]=e[t]}class Ed extends i.core.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class bd{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return 0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",s="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";e.elements.sort(((e,t)=>t-e));const o=ms(e.elements);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of o){const o=Os(e),l=_s(e);if(n.zone[t]<=o&&o<=n.zone[s]){const e=Math.min(n.zone[s],l)-o+1;a="RESIZE",r=this.createAdaptedRange(r,i,a,-e)}else if(n.zone[t]>=o&&n.zone[s]<=l)a="REMOVE",r=this.buildInvalidRange(_);else if(n.zone[t]<=l&&n.zone[s]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,i,a,-e),r=this.createAdaptedRange(r,i,"MOVE",-(n.zone[t]-o))}else o<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,i,a,-(l-o+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",s="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(o.zone[t]<=e.base&&e.base<o.zone[s])return{changeType:"RESIZE",range:this.createAdaptedRange(o,i,"RESIZE",e.quantity)};if(e.base<o.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(o,i,"MOVE",e.quantity)}}else{if(o.zone[t]<e.base&&e.base<=o.zone[s])return{changeType:"RESIZE",range:this.createAdaptedRange(o,i,"RESIZE",e.quantity)};if(e.base<=o.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(o,i,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>t.sheetId!==e.sheetId?{changeType:"NONE"}:{changeType:"REMOVE",range:t={...this.buildInvalidRange(_),invalidSheetName:this.getters.getSheetName(e.sheetId)}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const s={...t,zone:{...t.zone}};return s.invalidSheetName=void 0,s.sheetId=e.sheetId,{changeType:"CHANGE",range:s}}return{changeType:"NONE"}}))}}finalize(){}verifyRangeRemoved(e){return t=>{const s=e(t);return"NONE"===s.changeType||Fs(s.range.zone)?s:{range:s.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,s,i){return{...e,zone:Ys(e.zone,t,s,i)}}executeOnAllRanges(e,t){const s=this.verifyRangeRemoved(e);for(const e of this.providers)e(s,t)}addRangeProvider(e){this.providers.push(e)}orderZone(e,t){if(e.right<e.left){let s=e.right;e.right=e.left,e.left=s;let i=t[1].colFixed;t[1].colFixed=t[0].colFixed,t[0].colFixed=i}if(e.bottom<e.top){let s=e.bottom;e.bottom=e.top,e.top=s;let i=t[1].rowFixed;t[1].rowFixed=t[0].rowFixed,t[0].rowFixed=i}}createAdaptedRanges(e,t,s,i){return e.map((e=>Fs(e.zone)?(e={...e,sheetId:e.prefixSheet?e.sheetId:i,zone:{left:e.zone.left+(e.parts[0].colFixed?0:t),right:e.zone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.zone.top+(e.parts[0].rowFixed?0:s),bottom:e.zone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:s)}},this.orderZone(e.zone,e.parts),e):e))}getRangeFromSheetXC(e,t){let s,i,o,n=t,r=!1;if(!Jt.test(t))return this.buildInvalidRange(t);t.includes("!")&&(({xc:n,sheetName:s}=es(t)),s?(i=this.getters.getSheetIdByName(s),r=!0,i||(o=s)):o=s);const a=Ns(n);let l=n.split(":").map((e=>({colFixed:e.startsWith("$"),rowFixed:e.includes("$",1)})));return this.orderZone(a,l),{sheetId:i||e,zone:a,parts:l,invalidSheetName:o,prefixSheet:r}}getRangeString(e,t){if(!e)return _;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return _;if(e.zone.left<0||e.zone.top<0)return _;let s=e.sheetId!==t||e.invalidSheetName||e.prefixSheet,i="";if(s&&(i=e.invalidSheetName?e.invalidSheetName:us(this.getters.getSheetName(e.sheetId))),s&&!i)return _;let o=Array(9);return o[0]=e.parts&&e.parts[0].colFixed?"$":"",o[1]=ts(e.zone.left),o[2]=e.parts&&e.parts[0].rowFixed?"$":"",o[3]=String(e.zone.top+1),e.parts&&2===e.parts.length&&(e.zone.top!==e.zone.bottom||e.zone.left!==e.zone.right||e.parts[0].rowFixed||e.parts[0].colFixed||e.parts[1].rowFixed||e.parts[1].colFixed)&&(o[4]=":",o[5]=e.parts[1].colFixed?"$":"",o[6]=ts(e.zone.right),o[7]=e.parts[1].rowFixed?"$":"",o[8]=String(e.zone.bottom+1)),`${s?i+"!":""}${o.join("")}`}buildInvalidRange(e){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:e}}}bd.getters=["getRangeString","getRangeFromSheetXC","createAdaptedRanges"];class Sd{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let s=e[0],i=e[e.length-1];const o=e.length-2;for(let t=1;t<=o;t++){const i=e[t];if(void 0===s[i]){const o=e[t+1];s[i]=hd(o)}s=s[i]}s[i]!==t&&(this.changes.push({path:e,before:s[i],after:t}),void 0===t?delete s[i]:s[i]=t)}}const Cd={General:0,0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},Id={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},yd={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"},wd="http://schemas.openxmlformats.org/drawingml/2006/main",Td="http://schemas.openxmlformats.org/drawingml/2006/chart",xd={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml"},Rd="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Ld=.75,Md=.1425,Ad=164,_d={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},Od=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"];function Nd(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function kd(e){return Math.round(Ld*e*window.devicePixelRatio*100)/100}function Fd(e){return Math.round(Md*e*100)/100}function $d(e,t){let s={};e.style&&(s=t.styles[e.style]);const i={font:{size:(null==s?void 0:s.fontSize)||x,color:(null==s?void 0:s.textColor)?s.textColor:"000000",family:2,name:"Arial"},fill:(null==s?void 0:s.fillColor)?{fgColor:s.fillColor}:{reservedAttribute:"none"},numFmt:e.format,border:e.border||0,verticalAlignment:"center",horizontalAlignment:null==s?void 0:s.align};return i.font.strike=!!(null==s?void 0:s.strikethrough)||void 0,i.font.underline=!!(null==s?void 0:s.underline)||void 0,i.font.bold=!!(null==s?void 0:s.bold)||void 0,i.font.italic=!!(null==s?void 0:s.italic)||void 0,i}function Dd(e,t){const s=function(e,t){if(!e)return 0;let s=Cd[e];s||(s=Pd(e,t)+Ad);return s}(t.numFmt,e.numFmts),i={fontId:Pd(t.font,e.fonts),fillId:Pd(t.fill,e.fills),borderId:t.border,numFmtId:s,verticalAlignment:t.verticalAlignment,horizontalAlignment:t.horizontalAlignment};return Pd(i,e.styles)}function Ud(e,t,s){let i,o=e.find((e=>e.path===t));return o?(i=`rId${(o.rels.length+1).toString()}`,o.rels.push({...s,id:i})):(i="rId1",e.push({path:t,rels:[{...s,id:i}]})),i}function Pd(e,t){let s=t.length;const i="object"==typeof e?As:(e,t)=>e===t;for(let o=0;o<s;o++)if(i(e,t[o]))return o;return t[t.length]=e,t.length-1}const Bd=[];function Vd(e){const t=Bd.findIndex((t=>t===e));return-1===t?(Bd.push(e),Bd.length):t+1}function Hd(e){return Math.round(914400*e/96)}class zd{constructor(e){this.xmlString=e}toString(){return this.xmlString}}function Zd(e,t,s){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:s}}function Gd(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function Wd(e){return new zd(e.map((([e,t])=>`${e}="${Gd(t)}"`)).join(" "))}function qd(e){const t=(new DOMParser).parseFromString(e.toString(),"text/xml"),s=t.querySelector("parsererror");if(s){const t=s.innerHTML,i=parseInt(t.split(":")[0],10),o=e.toString().trim().split("\n"),n=o.slice(Math.max(i-3,0),Math.min(i+2,o.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${n}`)}return t}function jd(e,t){return Xd`
1045
1045
  <Override ContentType="${t}" PartName="${e}" />
1046
- `}function qd(e){return new Vd(e.join("\n"))}function jd(e,...t){let s=[e[0]];for(let i=0;i<t.length;i++){const o=t[i]instanceof Vd?t[i]:zd(t[i]);s.push(o+e[i+1])}return new Vd(s.join(""))}const Yd=17781237,Xd=88853993;function Kd(e){const t=[["xmlns:r",Td],["xmlns:a",Id],["xmlns:c",yd]],s=Qd({backgroundColor:Kt(e.data.backgroundColor),line:{color:"000000"}});let i=jd``;e.data.title&&(i=jd`
1046
+ `}function Yd(e){return new zd(e.join("\n"))}function Xd(e,...t){let s=[e[0]];for(let i=0;i<t.length;i++){const o=t[i]instanceof zd?t[i]:Gd(t[i]);s.push(o+e[i+1])}return new zd(s.join(""))}const Kd=17781237,Qd=88853993;function Jd(e){const t=[["xmlns:r",Rd],["xmlns:a",wd],["xmlns:c",Td]],s=eu({backgroundColor:Kt(e.data.backgroundColor),line:{color:"000000"}});let i=Xd``;e.data.title&&(i=Xd`
1047
1047
  <c:title>
1048
- ${eu(e.data.title)}
1048
+ ${su(e.data.title)}
1049
1049
  <c:overlay val="0" />
1050
1050
  </c:title>
1051
- `);let o=jd``;switch(e.data.type){case"bar":o=function(e){const t=new Mh,s=[];for(const[i,o]of Object.entries(e.dataSets)){const n=Kt(t.next()),r=Qd({backgroundColor:n,line:{color:n}});s.push(jd`
1051
+ `);let o=Xd``;switch(e.data.type){case"bar":o=function(e){const t=new _h,s=[];for(const[i,o]of Object.entries(e.dataSets)){const n=Kt(t.next()),r=eu({backgroundColor:n,line:{color:n}});s.push(Xd`
1052
1052
  <c:ser>
1053
1053
  <c:idx val="${i}"/>
1054
1054
  <c:order val="${i}"/>
1055
- ${o.label?jd`<c:tx>${ou(o.label)}</c:tx>`:""}
1055
+ ${o.label?Xd`<c:tx>${ru(o.label)}</c:tx>`:""}
1056
1056
  ${r}
1057
- ${e.labelRange?jd`<c:cat>${ou(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
1057
+ ${e.labelRange?Xd`<c:cat>${ru(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
1058
1058
  <c:val> <!-- x-coordinate values -->
1059
- ${nu(o.range)}
1059
+ ${au(o.range)}
1060
1060
  </c:val>
1061
1061
  </c:ser>
1062
- `)}const i="left"===e.verticalAxisPosition?"l":"r",o=e.stackedBar?"stacked":"clustered",n=e.stackedBar?100:-20;return jd`
1062
+ `)}const i="left"===e.verticalAxisPosition?"l":"r",o=e.stackedBar?"stacked":"clustered",n=e.stackedBar?100:-20;return Xd`
1063
1063
  <c:barChart>
1064
1064
  <c:barDir val="col"/>
1065
1065
  <c:grouping val="${o}"/>
@@ -1067,13 +1067,13 @@
1067
1067
  <c:gapWidth val="70"/>
1068
1068
  <!-- each data marker in the series does not have a different color -->
1069
1069
  <c:varyColors val="0"/>
1070
- ${qd(s)}
1071
- <c:axId val="${Yd}" />
1072
- <c:axId val="${Xd}" />
1070
+ ${Yd(s)}
1071
+ <c:axId val="${Kd}" />
1072
+ <c:axId val="${Qd}" />
1073
1073
  </c:barChart>
1074
- ${iu("b","c:catAx",Yd,Xd)}
1075
- ${iu(i,"c:valAx",Xd,Yd)}
1076
- `}(e.data);break;case"line":o=function(e){const t=new Mh,s=[];for(const[i,o]of Object.entries(e.dataSets)){const n=Qd({line:{width:2.5,style:"solid",color:Kt(t.next())}});s.push(jd`
1074
+ ${nu("b","c:catAx",Kd,Qd)}
1075
+ ${nu(i,"c:valAx",Qd,Kd)}
1076
+ `}(e.data);break;case"line":o=function(e){const t=new _h,s=[];for(const[i,o]of Object.entries(e.dataSets)){const n=eu({line:{width:2.5,style:"solid",color:Kt(t.next())}});s.push(Xd`
1077
1077
  <c:ser>
1078
1078
  <c:idx val="${i}"/>
1079
1079
  <c:order val="${i}"/>
@@ -1082,49 +1082,49 @@
1082
1082
  <c:symbol val="circle" />
1083
1083
  <c:size val="5"/>
1084
1084
  </c:marker>
1085
- ${o.label?jd`<c:tx>${ou(o.label)}</c:tx>`:""}
1085
+ ${o.label?Xd`<c:tx>${ru(o.label)}</c:tx>`:""}
1086
1086
  ${n}
1087
- ${e.labelRange?jd`<c:cat>${ou(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
1087
+ ${e.labelRange?Xd`<c:cat>${ru(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
1088
1088
  <c:val> <!-- x-coordinate values -->
1089
- ${nu(o.range)}
1089
+ ${au(o.range)}
1090
1090
  </c:val>
1091
1091
  </c:ser>
1092
- `)}const i="left"===e.verticalAxisPosition?"l":"r";return jd`
1092
+ `)}const i="left"===e.verticalAxisPosition?"l":"r";return Xd`
1093
1093
  <c:lineChart>
1094
1094
  <!-- each data marker in the series does not have a different color -->
1095
1095
  <c:varyColors val="0"/>
1096
- ${qd(s)}
1097
- <c:axId val="${Yd}" />
1098
- <c:axId val="${Xd}" />
1096
+ ${Yd(s)}
1097
+ <c:axId val="${Kd}" />
1098
+ <c:axId val="${Qd}" />
1099
1099
  </c:lineChart>
1100
- ${iu("b","c:catAx",Yd,Xd)}
1101
- ${iu(i,"c:valAx",Xd,Yd)}
1102
- `}(e.data);break;case"pie":o=function(e,{holeSize:t}={holeSize:50}){const s=new Mh,i=Math.max(...e.dataSets.map((e=>{const t=Os(e.range),{height:s,width:i}=Zs(t);return s*i}))),o=fs(0,i).map((()=>Kt(s.next()))),n=[];for(const[t,s]of Object.entries(e.dataSets).reverse()){const i=Os(s.range),{height:r,width:a}=Zs(i),l=[];for(const e of fs(0,r*a)){const t=Qd({backgroundColor:o[e],line:{color:"FFFFFF",width:1.5}});l.push(jd`
1100
+ ${nu("b","c:catAx",Kd,Qd)}
1101
+ ${nu(i,"c:valAx",Qd,Kd)}
1102
+ `}(e.data);break;case"pie":o=function(e,{holeSize:t}={holeSize:50}){const s=new _h,i=Math.max(...e.dataSets.map((e=>{const t=ks(e.range),{height:s,width:i}=Ws(t);return s*i}))),o=fs(0,i).map((()=>Kt(s.next()))),n=[];for(const[t,s]of Object.entries(e.dataSets).reverse()){const i=ks(s.range),{height:r,width:a}=Ws(i),l=[];for(const e of fs(0,r*a)){const t=eu({backgroundColor:o[e],line:{color:"FFFFFF",width:1.5}});l.push(Xd`
1103
1103
  <c:dPt>
1104
1104
  <c:idx val="${e}"/>
1105
1105
  ${t}
1106
1106
  </c:dPt>
1107
- `)}n.push(jd`
1107
+ `)}n.push(Xd`
1108
1108
  <c:ser>
1109
1109
  <c:idx val="${t}"/>
1110
1110
  <c:order val="${t}"/>
1111
- ${s.label?jd`<c:tx>${ou(s.label)}</c:tx>`:""}
1112
- ${qd(l)}
1113
- ${su({showLeaderLines:!0})}
1114
- ${e.labelRange?jd`<c:cat>${ou(e.labelRange)}</c:cat>`:""}
1111
+ ${s.label?Xd`<c:tx>${ru(s.label)}</c:tx>`:""}
1112
+ ${Yd(l)}
1113
+ ${ou({showLeaderLines:!0})}
1114
+ ${e.labelRange?Xd`<c:cat>${ru(e.labelRange)}</c:cat>`:""}
1115
1115
  <c:val>
1116
- ${nu(s.range)}
1116
+ ${au(s.range)}
1117
1117
  </c:val>
1118
1118
  </c:ser>
1119
- `)}return jd`
1119
+ `)}return Xd`
1120
1120
  <c:doughnutChart>
1121
1121
  <c:varyColors val="1" />
1122
1122
  <c:holeSize val="${t}" />
1123
- ${su()}
1124
- ${qd(n)}
1123
+ ${ou()}
1124
+ ${Yd(n)}
1125
1125
  </c:doughnutChart>
1126
- `}(e.data,{holeSize:0})}let n="t";switch(e.data.legendPosition){case"bottom":n="b";break;case"left":n="l";break;case"right":n="r";break;case"top":n="t"}const r=jd`
1127
- <c:chartSpace ${Zd(t)}>
1126
+ `}(e.data,{holeSize:0})}let n="t";switch(e.data.legendPosition){case"bottom":n="b";break;case"left":n="l";break;case"right":n="r";break;case"top":n="t"}const r=Xd`
1127
+ <c:chartSpace ${Wd(t)}>
1128
1128
  <c:roundedCorners val="0" />
1129
1129
  <!-- <manualLayout/> to manually position the chart in the figure container -->
1130
1130
  ${s}
@@ -1135,32 +1135,32 @@
1135
1135
  <!-- how the chart element is placed on the chart -->
1136
1136
  <c:layout />
1137
1137
  ${o}
1138
- ${Qd({backgroundColor:Kt(e.data.backgroundColor)})}
1138
+ ${eu({backgroundColor:Kt(e.data.backgroundColor)})}
1139
1139
  </c:plotArea>
1140
- ${function(e){return jd`
1140
+ ${function(e){return Xd`
1141
1141
  <c:legend>
1142
1142
  <c:legendPos val="${e}"/>
1143
1143
  <c:overlay val="0"/>
1144
- ${tu(10)}
1144
+ ${iu(10)}
1145
1145
  </c:legend>
1146
1146
  `}(n)}
1147
1147
  </c:chart>
1148
1148
  </c:chartSpace>
1149
- `;return Gd(r)}function Qd(e){return jd`
1149
+ `;return qd(r)}function eu(e){return Xd`
1150
1150
  <c:spPr>
1151
- ${e.backgroundColor?Jd(e.backgroundColor):""}
1152
- ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",Bd(e.width)]);const s=e.style?jd`<a:prstDash val="${e.style}"/>`:"";return jd`
1153
- <a:ln ${Zd(t)}>
1154
- ${Jd(e.color)}
1151
+ ${e.backgroundColor?tu(e.backgroundColor):""}
1152
+ ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",Hd(e.width)]);const s=e.style?Xd`<a:prstDash val="${e.style}"/>`:"";return Xd`
1153
+ <a:ln ${Wd(t)}>
1154
+ ${tu(e.color)}
1155
1155
  ${s}
1156
1156
  </a:ln>
1157
1157
  `}(e.line):""}
1158
1158
  </c:spPr>
1159
- `}function Jd(e){return jd`
1159
+ `}function tu(e){return Xd`
1160
1160
  <a:solidFill>
1161
1161
  <a:srgbClr val="${e}"/>
1162
1162
  </a:solidFill>
1163
- `}function eu(e,t=22){return jd`
1163
+ `}function su(e,t=22){return Xd`
1164
1164
  <c:tx>
1165
1165
  <c:rich>
1166
1166
  <a:bodyPr />
@@ -1168,7 +1168,7 @@
1168
1168
  <a:p>
1169
1169
  <a:pPr lvl="0">
1170
1170
  <a:defRPr b="0">
1171
- ${Jd("000000")}
1171
+ ${tu("000000")}
1172
1172
  <a:latin typeface="+mn-lt"/>
1173
1173
  </a:defRPr>
1174
1174
  </a:pPr>
@@ -1179,20 +1179,20 @@
1179
1179
  </a:p>
1180
1180
  </c:rich>
1181
1181
  </c:tx>
1182
- `}function tu(e=12,t=!1,s=!1){return jd`
1182
+ `}function iu(e=12,t=!1,s=!1){return Xd`
1183
1183
  <c:txPr>
1184
1184
  <a:bodyPr/>
1185
1185
  <a:lstStyle/>
1186
1186
  <a:p>
1187
1187
  <a:pPr lvl="0">
1188
- <a:defRPr ${Zd([["b",t?"1":"0"],["i",s?"1":"0"],["sz",100*e]])}>
1189
- ${Jd("000000")}
1188
+ <a:defRPr ${Wd([["b",t?"1":"0"],["i",s?"1":"0"],["sz",100*e]])}>
1189
+ ${tu("000000")}
1190
1190
  <a:latin typeface="+mn-lt"/>
1191
1191
  </a:defRPr>
1192
1192
  </a:pPr>
1193
1193
  </a:p>
1194
1194
  </c:txPr>
1195
- `}function su({showLeaderLines:e}={showLeaderLines:!1}){return jd`
1195
+ `}function ou({showLeaderLines:e}={showLeaderLines:!1}){return Xd`
1196
1196
  <dLbls>
1197
1197
  <c:showLegendKey val="0"/>
1198
1198
  <c:showVal val="0"/>
@@ -1202,7 +1202,7 @@
1202
1202
  <c:showBubbleSize val="0"/>
1203
1203
  <c:showLeaderLines val="${e?"1":"0"}"/>
1204
1204
  </dLbls>
1205
- `}function iu(e,t,s,i){return jd`
1205
+ `}function nu(e,t,s,i){return Xd`
1206
1206
  <${t}>
1207
1207
  <c:axId val="${s}"/>
1208
1208
  <c:crossAx val="${i}"/> <!-- reference to the other axe of the chart -->
@@ -1211,58 +1211,58 @@
1211
1211
  <c:orientation val="minMax" />
1212
1212
  </c:scaling>
1213
1213
  <c:axPos val="${e}" />
1214
- ${function(e="B7B7B7"){return jd`
1214
+ ${function(e="B7B7B7"){return Xd`
1215
1215
  <c:majorGridlines>
1216
- ${Qd({line:{color:e}})}
1216
+ ${eu({line:{color:e}})}
1217
1217
  </c:majorGridlines>
1218
1218
  `}()}
1219
1219
  <c:majorTickMark val="out" />
1220
1220
  <c:minorTickMark val="none" />
1221
1221
  <c:numFmt formatCode="General" sourceLinked="1" />
1222
1222
  <c:title>
1223
- ${eu("")}
1223
+ ${su("")}
1224
1224
  </c:title>
1225
- ${tu(10)}
1225
+ ${iu(10)}
1226
1226
  </${t}>
1227
1227
  <!-- <tickLblPos/> omitted -->
1228
- `}function ou(e){return jd`
1228
+ `}function ru(e){return Xd`
1229
1229
  <c:strRef>
1230
1230
  <c:f>${e}</c:f>
1231
1231
  </c:strRef>
1232
- `}function nu(e){return jd`
1232
+ `}function au(e){return Xd`
1233
1233
  <c:numRef>
1234
1234
  <c:f>${e}</c:f>
1235
1235
  <c:numCache />
1236
1236
  </c:numRef>
1237
- `}function ru(e){const t=e.content,s=or.content,i=[];let o=jd``;if(lr(t).filter((e=>"FUNCTION"===e.type)).every((e=>s[e.value.toUpperCase()].isExported))){let s=jd``;const n=lu(t);return"#CYCLE"===e.value&&(i.push(["t","str"]),s=jd`<v>${e.value}</v>`),o=jd`
1237
+ `}function lu(e){const t=e.content,s=rr.content,i=[];let o=Xd``;if(hr(t).filter((e=>"FUNCTION"===e.type)).every((e=>s[e.value.toUpperCase()].isExported))){let s=Xd``;const n=hu(t);return"#CYCLE"===e.value&&(i.push(["t","str"]),s=Xd`<v>${e.value}</v>`),o=Xd`
1238
1238
  <f>
1239
1239
  ${n}
1240
1240
  </f>
1241
1241
  ${s}
1242
- `,{attrs:i,node:o}}{const t=e.value,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=jd`<v>${t}</v>`,{attrs:i,node:o}}}function au(e,t){let s=e;const i=[];if(["TRUE","FALSE"].includes(s.trim()))s="TRUE"===s?"1":"0",i.push(["t","b"]);else if(!J(s)){const{id:o}=Dd(e,t);s=o.toString(),i.push(["t","s"])}return{attrs:i,node:jd`<v>${s}</v>`}}function lu(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Mr(e)}catch(t){return e}return t=Ar(t,"STRING",cu),t=Ar(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),s=e.args,i=Md[t];if(i){const o=or.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:Ad.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?_r(t):e}function cu(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 hu(e,t){const s=[];for(const i of t)switch(i.rule.type){case"CellIsRule":s.push(du(i,i.rule,e));break;case"ColorScaleRule":s.push(uu(i,i.rule));break;case"IconSetRule":s.push(pu(i,i.rule));break;default:console.warn(`Conditional formatting ${i.rule.type} not implemented`)}return s}function du(e,t,s){const i=gu(e),o=_d(t.operator);i.push(...function(e){const t=_d(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=>jd`<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}};t.style.fillColor&&(r.fill={fgColor:t.style.fillColor});const{id:a}=Dd(r,s);return i.push(["dxfId",a]),jd`
1242
+ `,{attrs:i,node:o}}{const t=e.value,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=Xd`<v>${t}</v>`,{attrs:i,node:o}}}function cu(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=Pd(e,t),i.push(["t","s"])),{attrs:i,node:Xd`<v>${s}</v>`}}function hu(e){let t;"="===e[0]&&(e=e.slice(1));try{t=_r(e)}catch(t){return e}return t=Or(t,"STRING",du),t=Or(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),s=e.args,i=_d[t];if(i){const o=rr.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:Od.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?Nr(t):e}function du(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 uu(e,t){const s=[];for(const i of t)switch(i.rule.type){case"CellIsRule":s.push(pu(i,i.rule,e));break;case"ColorScaleRule":s.push(gu(i,i.rule));break;case"IconSetRule":s.push(fu(i,i.rule));break;default:console.warn(`Conditional formatting ${i.rule.type} not implemented`)}return s}function pu(e,t,s){const i=mu(e),o=Nd(t.operator);i.push(...function(e){const t=Nd(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=>Xd`<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",Pd(r,s)]),Xd`
1243
1243
  <conditionalFormatting sqref="${e.ranges.join(" ")}">
1244
- <cfRule ${Zd(i)}>
1245
- ${qd(n)}
1244
+ <cfRule ${Wd(i)}>
1245
+ ${Yd(n)}
1246
1246
  </cfRule>
1247
1247
  </conditionalFormatting>
1248
- `}function uu(e,t){const s=gu(e);s.push(["type","colorScale"]);const i=[];for(const o of e.ranges){const e=[],n=[];let r=!0;for(let s of["minimum","midpoint","maximum"]){const i=t[s];i&&("formula"!==i.type?(e.push(mu(i,s)),n.push([["rgb",jt(i.color)]])):r=!1)}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>jd`<cfvo ${Zd(e)}/>`)),l=n.map((e=>jd`<color ${Zd(e)}/>`));i.push(jd`
1248
+ `}function gu(e,t){const s=mu(e);s.push(["type","colorScale"]);const i=[];for(const o of e.ranges){const e=[],n=[];let r=!0;for(let s of["minimum","midpoint","maximum"]){const i=t[s];i&&("formula"!==i.type?(e.push(Eu(i,s)),n.push([["rgb",jt(i.color)]])):r=!1)}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>Xd`<cfvo ${Wd(e)}/>`)),l=n.map((e=>Xd`<color ${Wd(e)}/>`));i.push(Xd`
1249
1249
  <conditionalFormatting sqref="${o}">
1250
- <cfRule ${Zd(s)}>
1250
+ <cfRule ${Wd(s)}>
1251
1251
  <colorScale>
1252
- ${qd(a)}
1253
- ${qd(l)}
1252
+ ${Yd(a)}
1253
+ ${Yd(l)}
1254
1254
  </colorScale>
1255
1255
  </cfRule>
1256
1256
  </conditionalFormatting>
1257
- `)}return qd(i)}function pu(e,t){const s=gu(e);s.push(["type","iconSet"]);const i=[];for(const o of e.ranges){const e=[[["type","percent"],["val",0]]];let n=!0;for(let s of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[s].type){n=!1;continue}const i=t[s];e.push([...mu(i,s),["gte","ge"===i.operator?"1":"0"]])}if(!n){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const r=e.map((e=>jd`<cfvo ${Zd(e)} />`));i.push(jd`
1257
+ `)}return Yd(i)}function fu(e,t){const s=mu(e);s.push(["type","iconSet"]);const i=[];for(const o of e.ranges){const e=[[["type","percent"],["val",0]]];let n=!0;for(let s of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[s].type){n=!1;continue}const i=t[s];e.push([...Eu(i,s),["gte","ge"===i.operator?"1":"0"]])}if(!n){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const r=e.map((e=>Xd`<cfvo ${Wd(e)} />`));i.push(Xd`
1258
1258
  <conditionalFormatting sqref="${o}">
1259
- <cfRule ${Zd(s)}>
1260
- <iconSet iconSet="${fu(t.icons)}">
1261
- ${qd(r)}
1259
+ <cfRule ${Wd(s)}>
1260
+ <iconSet iconSet="${vu(t.icons)}">
1261
+ ${Yd(r)}
1262
1262
  </iconSet>
1263
1263
  </cfRule>
1264
1264
  </conditionalFormatting>
1265
- `)}return qd(i)}function gu(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function fu(e){return bd[Object.keys(bd).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function mu(e,t){const s=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),i=[["type",s]];if("min"!==s&&"max"!==s){let t=e.value;if("formula"===s)try{!function(e){const{dependencies:t}=Hr(e);t.references.length&&console.warn("Relative references might not work in conditional format formula thresholds in Excel.")}(e.value),t=lu(e.value)}catch(s){t=e.value}i.push(["val",t])}return i}function vu(e,t,s){const i=[["xmlns:xdr",Cd.drawing],["xmlns:r",Td],["xmlns:a",Id],["xmlns:c",yd]],o=[];for(const[i,n]of Object.entries(s)){const{from:s,to:r}=Eu(n,t),a=Pd(n.id),l=[["id",a],["name",`Chart ${a}`],["title","Chart"]];o.push(jd`
1265
+ `)}return Yd(i)}function mu(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function vu(e){return Id[Object.keys(Id).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function Eu(e,t){const s=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),i=[["type",s]];if("min"!==s&&"max"!==s){let t=e.value;if("formula"===s)try{!function(e){const{dependencies:t}=Zr(e);t.references.length&&console.warn("Relative references might not work in conditional format formula thresholds in Excel.")}(e.value),t=hu(e.value)}catch(s){t=e.value}i.push(["val",t])}return i}function bu(e,t,s){const i=[["xmlns:xdr",yd.drawing],["xmlns:r",Rd],["xmlns:a",wd],["xmlns:c",Td]],o=[];for(const[i,n]of Object.entries(s)){const{from:s,to:r}=Su(n,t),a=Vd(n.id),l=[["id",a],["name",`Chart ${a}`],["title","Chart"]];o.push(Xd`
1266
1266
  <xdr:twoCellAnchor>
1267
1267
  <xdr:from>
1268
1268
  <xdr:col>${s.col}</xdr:col>
@@ -1278,7 +1278,7 @@
1278
1278
  </xdr:to>
1279
1279
  <xdr:graphicFrame>
1280
1280
  <xdr:nvGraphicFramePr>
1281
- <xdr:cNvPr ${Zd(l)} />
1281
+ <xdr:cNvPr ${Wd(l)} />
1282
1282
  <xdr:cNvGraphicFramePr />
1283
1283
  </xdr:nvGraphicFramePr>
1284
1284
  <xdr:xfrm>
@@ -1286,171 +1286,171 @@
1286
1286
  <a:ext cx="0" cy="0"/>
1287
1287
  </xdr:xfrm>
1288
1288
  <a:graphic>
1289
- <a:graphicData uri="${yd}">
1289
+ <a:graphicData uri="${Td}">
1290
1290
  <c:chart r:id="${e[i]}" />
1291
1291
  </a:graphicData>
1292
1292
  </a:graphic>
1293
1293
  </xdr:graphicFrame>
1294
1294
  <xdr:clientData fLocksWithSheet="0"/>
1295
1295
  </xdr:twoCellAnchor>
1296
- `)}return Gd(jd`
1297
- <xdr:wsDr ${Zd(i)}>
1298
- ${qd(o)}
1296
+ `)}return qd(Xd`
1297
+ <xdr:wsDr ${Wd(i)}>
1298
+ ${Yd(o)}
1299
1299
  </xdr:wsDr>
1300
- `)}function Eu(e,t){const{x:s,y:i,height:o,width:n}=e,r=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=Su(r,s),{index:h,offset:d}=Su(r,s+n),{index:u,offset:p}=Su(a,i),{index:g,offset:f}=Su(a,i+o);return{from:{col:l,colOff:c,row:u,rowOff:p},to:{col:h,colOff:d,row:g,rowOff:f}}}function Su(e,t){let s=0;for(const[i,o]of Object.entries(e)){if(s<=t&&t<s+o.size)return{index:parseInt(i),offset:Bd(t-s+w)};s+=o.size}return{index:e.length-1,offset:Bd(t-s+w)}}function bu(e){return 0===Object.values(e).filter(Ls).length?jd``:jd`
1300
+ `)}function Su(e,t){const{x:s,y:i,height:o,width:n}=e,r=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=Cu(r,s),{index:h,offset:d}=Cu(r,s+n),{index:u,offset:p}=Cu(a,i),{index:g,offset:f}=Cu(a,i+o);return{from:{col:l,colOff:c,row:u,rowOff:p},to:{col:h,colOff:d,row:g,rowOff:f}}}function Cu(e,t){let s=0;for(const[i,o]of Object.entries(e)){if(s<=t&&t<s+o.size)return{index:parseInt(i),offset:Hd(t-s+w)};s+=o.size}return{index:e.length-1,offset:Hd(t-s+w)}}function Iu(e){return 0===Object.values(e).filter(Ls).length?Xd``:Xd`
1301
1301
  <font>
1302
- ${e.bold?jd`<b />`:""}
1303
- ${e.italic?jd`<i />`:""}
1304
- ${e.underline?jd`<u />`:""}
1305
- ${e.strike?jd`<strike />`:""}
1306
- ${e.size?jd`<sz val="${e.size}" />`:""}
1307
- ${e.color?jd`<color rgb="${Kt(e.color)}" />`:""}
1308
- ${e.name?jd`<name val="${e.name}" />`:""}
1302
+ ${e.bold?Xd`<b />`:""}
1303
+ ${e.italic?Xd`<i />`:""}
1304
+ ${e.underline?Xd`<u />`:""}
1305
+ ${e.strike?Xd`<strike />`:""}
1306
+ ${e.size?Xd`<sz val="${e.size}" />`:""}
1307
+ ${e.color?Xd`<color rgb="${Kt(e.color)}" />`:""}
1308
+ ${e.name?Xd`<name val="${e.name}" />`:""}
1309
1309
  </font>
1310
- `}function Cu(e){return e?Zd([["style",e[0]],["color",Kt(e[1])]]):jd``}function Iu(e){if(!Object.values(e).length)return jd``;const t=[];for(let[s,i]of Object.entries(e)){const e=[["min",parseInt(s)+1],["max",parseInt(s)+1],["width",Nd(i.size||E)],["customWidth",1],["hidden",i.isHidden?1:0]];t.push(jd`
1311
- <col ${Zd(e)}/>
1312
- `)}return jd`
1310
+ `}function yu(e){return e?Wd([["style",e[0]],["color",Kt(e[1])]]):Xd``}function wu(e){if(!Object.values(e).length)return Xd``;const t=[];for(let[s,i]of Object.entries(e)){const e=[["min",parseInt(s)+1],["max",parseInt(s)+1],["width",Fd(i.size||E)],["customWidth",1],["hidden",i.isHidden?1:0]];t.push(Xd`
1311
+ <col ${Wd(e)}/>
1312
+ `)}return Xd`
1313
1313
  <cols>
1314
- ${qd(t)}
1314
+ ${Yd(t)}
1315
1315
  </cols>
1316
- `}function yu(e,t,s){const i=[];for(let o=0;o<s.rowNumber;o++){const n=[["r",o+1]],r=s.rows[o]||{};n.push(["ht",Od(r.size||S)],["customHeight",1],["hidden",r.isHidden?1:0]);const a=[];for(let i=0;i<s.colNumber;i++){const n=is(i,o),r=s.cells[n];if(r){const s=[["r",n]],i=Fd(e,kd(r,t));s.push(["s",i]);let o=[],l=jd``;if(r.isFormula)({attrs:o,node:l}=ru(r));else if(r.content&&Is(r.content)){const{label:t}=ws(r.content);({attrs:o,node:l}=au(t,e.sharedStrings))}else r.content&&""!==r.content&&({attrs:o,node:l}=au(r.content,e.sharedStrings));s.push(...o),a.push(jd`
1317
- <c ${Zd(s)}>
1316
+ `}function Tu(e,t,s){const i=[];for(let o=0;o<s.rowNumber;o++){const n=[["r",o+1]],r=s.rows[o]||{};n.push(["ht",kd(r.size||b)],["customHeight",1],["hidden",r.isHidden?1:0]);const a=[];for(let i=0;i<s.colNumber;i++){const n=is(i,o),r=s.cells[n];if(r){const s=[["r",n]],i=Dd(e,$d(r,t));s.push(["s",i]);let o=[],l=Xd``;if(r.isFormula)({attrs:o,node:l}=lu(r));else if(r.content&&Is(r.content)){const{label:t}=ws(r.content);({attrs:o,node:l}=cu(t,e.sharedStrings))}else r.content&&""!==r.content&&({attrs:o,node:l}=cu(r.content,e.sharedStrings));s.push(...o),a.push(Xd`
1317
+ <c ${Wd(s)}>
1318
1318
  ${l}
1319
1319
  </c>
1320
- `)}}a.length&&i.push(jd`
1321
- <row ${Zd(n)}>
1322
- ${qd(a)}
1320
+ `)}}a.length&&i.push(Xd`
1321
+ <row ${Wd(n)}>
1322
+ ${Yd(a)}
1323
1323
  </row>
1324
- `)}return jd`
1324
+ `)}return Xd`
1325
1325
  <sheetData>
1326
- ${qd(i)}
1326
+ ${Yd(i)}
1327
1327
  </sheetData>
1328
- `}function wu(e,t,s){var i;const o=t.sheets[s].cells,n=[];for(const r in o){const a=null===(i=o[r])||void 0===i?void 0:i.content;if(a&&Is(a)){const{label:i,url:o}=ws(a);if(xs(a)){const e=Rs(o),s=t.sheets.find((t=>t.id===e)),a=s?`${s.name}!A1`:_;n.push(jd`
1328
+ `}function xu(e,t,s){var i;const o=t.sheets[s].cells,n=[];for(const r in o){const a=null===(i=o[r])||void 0===i?void 0:i.content;if(a&&Is(a)){const{label:i,url:o}=ws(a);if(xs(a)){const e=Rs(o),s=t.sheets.find((t=>t.id===e)),a=s?`${s.name}!A1`:_;n.push(Xd`
1329
1329
  <hyperlink display="${i}" location="${a}" ref="${r}"/>
1330
- `)}else{const t=$d(e.relsFiles,`xl/worksheets/_rels/sheet${s}.xml.rels`,{target:o,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",targetMode:"External"});n.push(jd`
1330
+ `)}else{const t=Ud(e.relsFiles,`xl/worksheets/_rels/sheet${s}.xml.rels`,{target:o,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",targetMode:"External"});n.push(Xd`
1331
1331
  <hyperlink r:id="${t}" ref="${r}"/>
1332
- `)}}}return n.length?jd`
1332
+ `)}}}return n.length?Xd`
1333
1333
  <hyperlinks>
1334
- ${qd(n)}
1334
+ ${Yd(n)}
1335
1335
  </hyperlinks>
1336
- `:jd``}function Tu(e){if(e.length){const t=e.map((e=>jd`<mergeCell ref="${e}" />`));return jd`
1336
+ `:Xd``}function Ru(e){if(e.length){const t=e.map((e=>Xd`<mergeCell ref="${e}" />`));return Xd`
1337
1337
  <mergeCells count="${e.length}">
1338
- ${qd(t)}
1338
+ ${Yd(t)}
1339
1339
  </mergeCells>
1340
- `}return jd``}function xu(e){const t=[],s={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,verticalAlignment:"center"}],fonts:[{size:x,family:2,color:"000000",name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const s=[["xmlns",Cd.workbook],["xmlns:r",Td]],i=[];for(const[s,o]of Object.entries(e.sheets)){const e=[["name",o.name],["sheetId",parseInt(s)+1],["r:id",`rId${parseInt(s)+1}`]];i.push(jd`
1341
- <sheet ${Zd(e)} />
1342
- `),$d(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",target:`worksheets/sheet${s}.xml`})}const o=jd`
1343
- <workbook ${Zd(s)}>
1340
+ `}return Xd``}function Lu(e){const t=[],s=function(e){const t=[{},...Object.values(e.borders)];return{relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,verticalAlignment:"center"}],fonts:[{size:x,family:2,color:"000000",name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:t,numFmts:[],dxfs:[]}}(e);return t.push(function(e,t){const s=[["xmlns",yd.workbook],["xmlns:r",Rd]],i=[];for(const[s,o]of Object.entries(e.sheets)){const e=[["name",o.name],["sheetId",parseInt(s)+1],["r:id",`rId${parseInt(s)+1}`]];i.push(Xd`
1341
+ <sheet ${Wd(e)} />
1342
+ `),Ud(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",target:`worksheets/sheet${s}.xml`})}const o=Xd`
1343
+ <workbook ${Wd(s)}>
1344
1344
  <sheets>
1345
- ${qd(i)}
1345
+ ${Yd(i)}
1346
1346
  </sheets>
1347
1347
  </workbook>
1348
- `;return Hd(Gd(o),"xl/workbook.xml","workbook")}(e,s)),t.push(...function(e,t){const s=[];for(const[i,o]of Object.entries(e.sheets)){const n=[["xmlns",Cd.worksheet],["xmlns:r",Td]],r=[["defaultRowHeight",Od(S)],["defaultColWidth",Nd(E)]];let a=jd``;const l=o.charts;if(l.length){const e=[];for(const o of l){const n=Pd(o.id),r=$d(t.relsFiles,`xl/drawings/_rels/drawing${i}.xml.rels`,{target:`../charts/chart${n}.xml`,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"});e.push(r),s.push(Hd(Kd(o),`xl/charts/chart${n}.xml`,"chart"))}const n=$d(t.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:`../drawings/drawing${i}.xml`,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"});s.push(Hd(vu(e,o,l),`xl/drawings/drawing${i}.xml`,"drawing")),a=jd`<drawing r:id="${n}" />`}const c=jd`
1349
- <worksheet ${Zd(n)}>
1350
- <sheetFormatPr ${Zd(r)} />
1351
- ${Iu(o.cols)}
1352
- ${yu(t,e,o)}
1353
- ${Tu(o.merges)}
1354
- ${qd(hu(t.dxfs,o.conditionalFormats))}
1355
- ${wu(t,e,i)}
1348
+ `;return Zd(qd(o),"xl/workbook.xml","workbook")}(e,s)),t.push(...function(e,t){const s=[];for(const[i,o]of Object.entries(e.sheets)){const n=[["xmlns",yd.worksheet],["xmlns:r",Rd]],r=[["defaultRowHeight",kd(b)],["defaultColWidth",Fd(E)]];let a=Xd``;const l=o.charts;if(l.length){const e=[];for(const o of l){const n=Vd(o.id),r=Ud(t.relsFiles,`xl/drawings/_rels/drawing${i}.xml.rels`,{target:`../charts/chart${n}.xml`,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"});e.push(r),s.push(Zd(Jd(o),`xl/charts/chart${n}.xml`,"chart"))}const n=Ud(t.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:`../drawings/drawing${i}.xml`,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"});s.push(Zd(bu(e,o,l),`xl/drawings/drawing${i}.xml`,"drawing")),a=Xd`<drawing r:id="${n}" />`}const c=Xd`
1349
+ <worksheet ${Wd(n)}>
1350
+ <sheetFormatPr ${Wd(r)} />
1351
+ ${wu(o.cols)}
1352
+ ${Tu(t,e,o)}
1353
+ ${Ru(o.merges)}
1354
+ ${Yd(uu(t.dxfs,o.conditionalFormats))}
1355
+ ${xu(t,e,i)}
1356
1356
  ${a}
1357
1357
  </worksheet>
1358
- `;s.push(Hd(Gd(c),`xl/worksheets/sheet${i}.xml`,"sheet"))}return $d(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",target:"sharedStrings.xml"}),$d(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",target:"styles.xml"}),s}(e,s)),t.push(function(e){const t=jd`
1359
- <styleSheet ${Zd([["xmlns",Cd.styleSheet],["xmlns:r",Td]])}>
1360
- ${function(e){const t=[];for(let[s,i]of Object.entries(e)){const e=[["numFmtId",parseInt(s)+Ld],["formatCode",i]];t.push(jd`
1361
- <numFmt ${Zd(e)}/>
1362
- `)}return jd`
1358
+ `;s.push(Zd(qd(c),`xl/worksheets/sheet${i}.xml`,"sheet"))}return Ud(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",target:"sharedStrings.xml"}),Ud(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",target:"styles.xml"}),s}(e,s)),t.push(function(e){const t=Xd`
1359
+ <styleSheet ${Wd([["xmlns",yd.styleSheet],["xmlns:r",Rd]])}>
1360
+ ${function(e){const t=[];for(let[s,i]of Object.entries(e)){const e=[["numFmtId",parseInt(s)+Ad],["formatCode",i]];t.push(Xd`
1361
+ <numFmt ${Wd(e)}/>
1362
+ `)}return Xd`
1363
1363
  <numFmts count="${e.length}">
1364
- ${qd(t)}
1364
+ ${Yd(t)}
1365
1365
  </numFmts>
1366
1366
  `}(e.numFmts)}
1367
- ${s=e.fonts,jd`
1367
+ ${s=e.fonts,Xd`
1368
1368
  <fonts count="${s.length}">
1369
- ${qd(Object.values(s).map(bu))}
1369
+ ${Yd(Object.values(s).map(Iu))}
1370
1370
  </fonts>
1371
1371
  `}
1372
- ${function(e){const t=[];for(let s of Object.values(e))void 0!==s.reservedAttribute?t.push(jd`
1372
+ ${function(e){const t=[];for(let s of Object.values(e))void 0!==s.reservedAttribute?t.push(Xd`
1373
1373
  <fill>
1374
1374
  <patternFill patternType="${s.reservedAttribute}" />
1375
1375
  </fill>
1376
- `):t.push(jd`
1376
+ `):t.push(Xd`
1377
1377
  <fill>
1378
1378
  <patternFill patternType="solid">
1379
1379
  <fgColor rgb="${Kt(s.fgColor)}" />
1380
1380
  <bgColor indexed="64" />
1381
1381
  </patternFill>
1382
1382
  </fill>
1383
- `);return jd`
1383
+ `);return Xd`
1384
1384
  <fills count="${e.length}">
1385
- ${qd(t)}
1385
+ ${Yd(t)}
1386
1386
  </fills>
1387
1387
  `}(e.fills)}
1388
- ${function(e){const t=[];for(let s of Object.values(e))t.push(jd`
1388
+ ${function(e){const t=[];for(let s of Object.values(e))t.push(Xd`
1389
1389
  <border>
1390
- <left ${Cu(s.left)} />
1391
- <right ${Cu(s.right)} />
1392
- <top ${Cu(s.top)} />
1393
- <bottom ${Cu(s.bottom)} />
1394
- <diagonal ${Cu(s.diagonal)} />
1390
+ <left ${yu(s.left)} />
1391
+ <right ${yu(s.right)} />
1392
+ <top ${yu(s.top)} />
1393
+ <bottom ${yu(s.bottom)} />
1394
+ <diagonal ${yu(s.diagonal)} />
1395
1395
  </border>
1396
- `);return jd`
1396
+ `);return Xd`
1397
1397
  <borders count="${e.length}">
1398
- ${qd(t)}
1398
+ ${Yd(t)}
1399
1399
  </borders>
1400
1400
  `}(e.borders)}
1401
- ${function(e){const t=[];for(let s of e){const e=[["numFmtId",s.numFmtId],["fillId",s.fillId],["fontId",s.fontId],["borderId",s.borderId]],i=[];s.verticalAlignment&&i.push(["vertical",s.verticalAlignment]),s.horizontalAlignment&&i.push(["horizontal",s.horizontalAlignment]),t.push(jd`
1402
- <xf ${Zd(e)}>
1403
- ${i?jd`<alignment ${Zd(i)} />`:""}
1401
+ ${function(e){const t=[];for(let s of e){const e=[["numFmtId",s.numFmtId],["fillId",s.fillId],["fontId",s.fontId],["borderId",s.borderId]],i=[];s.verticalAlignment&&i.push(["vertical",s.verticalAlignment]),s.horizontalAlignment&&i.push(["horizontal",s.horizontalAlignment]),t.push(Xd`
1402
+ <xf ${Wd(e)}>
1403
+ ${i?Xd`<alignment ${Wd(i)} />`:""}
1404
1404
  </xf>
1405
- `)}return jd`
1405
+ `)}return Xd`
1406
1406
  <cellXfs count="${e.length}">
1407
- ${qd(t)}
1407
+ ${Yd(t)}
1408
1408
  </cellXfs>
1409
1409
  `}(e.styles)}
1410
- ${function(e){const t=[];for(const s of e){let e=jd``;s.font&&(e=bu(s.font));let i=jd``;s.fill&&(i=jd`
1410
+ ${function(e){const t=[];for(const s of e){let e=Xd``;s.font&&(e=Iu(s.font));let i=Xd``;s.fill&&(i=Xd`
1411
1411
  <fill>
1412
1412
  <patternFill>
1413
1413
  <bgColor rgb="${Kt(s.fill.fgColor)}" />
1414
1414
  </patternFill>
1415
1415
  </fill>
1416
- `),t.push(jd`
1416
+ `),t.push(Xd`
1417
1417
  <dxf>
1418
1418
  ${e}
1419
1419
  ${i}
1420
1420
  </dxf>
1421
- `)}return jd`
1421
+ `)}return Xd`
1422
1422
  <dxfs count="${e.length}">
1423
- ${qd(t)}
1423
+ ${Yd(t)}
1424
1424
  </dxfs>
1425
1425
  `}(e.dxfs)}
1426
1426
  </styleSheet>
1427
- `;var s;return Hd(Gd(t),"xl/styles.xml","styles")}(s)),t.push(function(e){const t=[["xmlns",Cd.sst],["count",e.length],["uniqueCount",e.length]],s=e.map((e=>jd`<si><t>${e}</t></si>`)),i=jd`
1428
- <sst ${Zd(t)}>
1429
- ${qd(s)}
1427
+ `;var s;return Zd(qd(t),"xl/styles.xml","styles")}(s)),t.push(function(e){const t=[["xmlns",yd.sst],["count",e.length],["uniqueCount",e.length]],s=e.map((e=>Xd`<si><t>${e}</t></si>`)),i=Xd`
1428
+ <sst ${Wd(t)}>
1429
+ ${Yd(s)}
1430
1430
  </sst>
1431
- `;return Hd(Gd(i),"xl/sharedStrings.xml","sharedStrings")}(s.sharedStrings)),t.push(...function(e){const t=[];for(const s of e){const e=[];for(const t of s.rels){const s=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&s.push(["TargetMode",t.targetMode]),e.push(jd`
1432
- <Relationship ${Zd(s)} />
1433
- `)}const i=jd`
1434
- <Relationships xmlns="${Cd.Relationships}">
1435
- ${qd(e)}
1431
+ `;return Zd(qd(i),"xl/sharedStrings.xml","sharedStrings")}(s.sharedStrings)),t.push(...function(e){const t=[];for(const s of e){const e=[];for(const t of s.rels){const s=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&s.push(["TargetMode",t.targetMode]),e.push(Xd`
1432
+ <Relationship ${Wd(s)} />
1433
+ `)}const i=Xd`
1434
+ <Relationships xmlns="${yd.Relationships}">
1435
+ ${Yd(e)}
1436
1436
  </Relationships>
1437
- `;t.push(Hd(Gd(i),s.path))}return t}(s.relsFiles)),t.push(function(e){const t=[];for(const s of e)s.contentType&&t.push(Wd("/"+s.path,wd[s.contentType]));const s=jd`
1438
- <Types xmlns="${Cd.Types}">
1437
+ `;t.push(Zd(qd(i),s.path))}return t}(s.relsFiles)),t.push(function(e){const t=[];for(const s of e)s.contentType&&t.push(jd("/"+s.path,xd[s.contentType]));const s=Xd`
1438
+ <Types xmlns="${yd.Types}">
1439
1439
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
1440
1440
  <Default Extension="xml" ContentType="application/xml" />
1441
- ${qd(t)}
1441
+ ${Yd(t)}
1442
1442
  </Types>
1443
- `;return Hd(Gd(s),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"],["Target","xl/workbook.xml"]],t=jd`
1444
- <Relationships xmlns="${Cd.Relationships}">
1445
- <Relationship ${Zd(e)} />
1443
+ `;return Zd(qd(s),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"],["Target","xl/workbook.xml"]],t=Xd`
1444
+ <Relationships xmlns="${yd.Relationships}">
1445
+ <Relationship ${Wd(e)} />
1446
1446
  </Relationships>
1447
- `;return Hd(Gd(t),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}var Ru;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing",e[e.Interactive=4]="Interactive"}(Ru||(Ru={}));class Lu extends i.core.EventBus{constructor(e={},t={},s=[],i=new si){super(),this.corePlugins=[],this.uiPlugins=[],this.dataSources=new nd,this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const s={type:e,...t};let i=s.interactive?4:this.status;if(this.config.isReadonly&&(o=s,!$e.has(o.type)))return new Pe(52);var o;if(!this.session.canApplyOptimisticUpdate())return new Pe(49);switch(i){case 0:const t=this.checkDispatchAllowed(s);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:o}=this.state.recordChanges((()=>{Ue(s)&&this.state.addCommand(s),this.dispatchToHandlers(this.handlers,s),this.finalize()}));this.session.save(o,i),this.status=0,"headless"!==this.config.mode&&this.trigger("update");break;case 1:if(Ue(s)){const e=this.checkDispatchAllowed(s);if(!e.isSuccessful)return e;this.state.addCommand(s),this.dispatchToHandlers(this.handlers,s)}else this.dispatchToHandlers(this.handlers,s);break;case 4:Ue(s)&&this.state.addCommand(s),this.dispatchToHandlers(this.handlers,s);break;case 3:throw new Error(a("Cannot dispatch commands in the finalize state"));case 2:if(Ue(s))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,s)}return Pe.Success},this.dispatchFromCorePlugin=(e,t)=>{const s={type:e,...t},i=this.status;this.status=2;const o=this.isReplayingCommand?[this.range,...this.corePlugins]:this.handlers;return this.dispatchToHandlers(o,s),this.status=i,Pe.Success},Ms.model=this,s=ca(e,s);const o=aa(e);this.state=new Ed,this.uuidGenerator=i,this.config=this.setupConfig(t),this.session=this.setupSession(o.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new md(this.dispatchFromCorePlugin,this.session),this.getters={isReadonly:()=>this.config.isReadonly,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.range=new vd(this.getters),this.getters.getRangeString=this.range.getRangeString.bind(this.range),this.getters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.getters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.uuidGenerator.setIsFastStrategy(!0);for(let e of sd.getAll())this.setupCorePlugin(e,o);for(let e of id.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.setupSessionEvents(),this.session.loadInitialMessages(s),this.joinSession(t.client),t.snapshotRequested&&this.session.snapshot(this.exportData())}get handlers(){return[this.range,...this.corePlugins,...this.uiPlugins,this.history]}joinSession(e){this.session.join(e)}leaveSession(){this.session.leave()}destroy(){delete Ms.model}setupUiPlugin(e){if(e.modes.includes(this.config.mode)){const t=new e(this.getters,this.state,this.dispatch,this.config);for(let s of e.getters){if(!(s in t))throw new Error(`Invalid getter name: ${s} for plugin ${t.constructor}`);this.getters[s]=t[s].bind(t)}this.uiPlugins.push(t);const s=e.layers.map((e=>[t,e]));this.renderers.push(...s),this.renderers.sort(((e,t)=>e[1]-t[1]))}}setupCorePlugin(e,t){if(e.modes.includes(this.config.mode)){const s=new e(this.getters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);s.import(t);for(let t of e.getters){if(!(t in s))throw new Error(`Invalid getter name: ${t} for plugin ${s.constructor}`);this.getters[t]=s[t].bind(s)}this.corePlugins.push(s)}}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Yh(gd(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:a("Anonymous").toString()},s=e.transportService||new od;return{mode:e.mode||"normal",openSidePanel:e.openSidePanel||(()=>{}),notifyUser:e.notifyUser||(()=>{}),askConfirmation:e.askConfirmation||(()=>{}),editText:e.editText||(()=>{}),evalContext:e.evalContext||{},transportService:s,client:t,moveClient:()=>{},isHeadless:"headless"===e.mode||!1,isReadonly:e.isReadonly||!1,snapshotRequested:!1,dataSources:this.dataSources}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new Pe(t.flat()):Pe.Success}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){for(const s of e)s.beforeHandle(t);for(const s of e)s.handle(t)}drawGrid(e){e.viewport=this.getters.getActiveSnappedViewport();for(let[t,s]of this.renderers)e.ctx.save(),t.drawGrid(e,s),e.ctx.restore()}exportData(){let e=ua();for(let t of this.handlers)t instanceof ga&&t.export(e);return e.revisionId=this.session.getRevisionId()||O,e=JSON.parse(JSON.stringify(e)),e}updateReadOnly(e){e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.isReadonly=e||!1}waitForIdle(){return this.dataSources.waitForReady()}async exportXLSX(){await this.waitForIdle(),this.dispatch("EVALUATE_ALL_SHEETS");let e={...ua(),sheets:[(t=ra,s="Sheet1",{...da(t,s),charts:[]})]};var t,s;for(let t of this.handlers)t instanceof ga&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),xu(e)}}const{useComponent:Mu,useState:Au,onPatched:_u,onMounted:Ou}=t.hooks;function Nu(e){const t=Au({x:0,y:0}),s=Mu(),i=function(){const e=Au({x:0,y:0});let t=document.querySelector(".o-spreadsheet");function s(){if(t||(t=document.querySelector(".o-spreadsheet")),t){const{top:s,left:i}=t.getBoundingClientRect();e.x=i,e.y=s}}return Ou(s),_u(s),e}();function o(){const o=(null==e?void 0:e.el)||s.el,{top:n,left:r}=o.getBoundingClientRect(),a=r-i.x,l=n-i.y;a===t.x&&l===t.y||(t.x=a,t.y=l)}return Ou(o),_u(o),t}const{Portal:ku}=t.misc,{xml:Fu}=t.tags,$u=Fu`
1447
+ `;return Zd(qd(t),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}var Mu;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing",e[e.Interactive=4]="Interactive"}(Mu||(Mu={}));class Au extends i.core.EventBus{constructor(e={},t={},s=[],i=new oi){super(),this.corePlugins=[],this.uiPlugins=[],this.dataSources=new ad,this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const s={type:e,...t};let i=s.interactive?4:this.status;if(this.config.isReadonly&&(o=s,!$e.has(o.type)))return new Pe(52);var o;if(!this.session.canApplyOptimisticUpdate())return new Pe(49);switch(i){case 0:const t=this.checkDispatchAllowed(s);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:o}=this.state.recordChanges((()=>{Ue(s)&&this.state.addCommand(s),this.dispatchToHandlers(this.handlers,s),this.finalize()}));this.session.save(o,i),this.status=0,"headless"!==this.config.mode&&this.trigger("update");break;case 1:if(Ue(s)){const e=this.checkDispatchAllowed(s);if(!e.isSuccessful)return e;this.state.addCommand(s),this.dispatchToHandlers(this.handlers,s)}else this.dispatchToHandlers(this.handlers,s);break;case 4:Ue(s)&&this.state.addCommand(s),this.dispatchToHandlers(this.handlers,s);break;case 3:throw new Error(a("Cannot dispatch commands in the finalize state"));case 2:if(Ue(s))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,s)}return Pe.Success},this.dispatchFromCorePlugin=(e,t)=>{const s={type:e,...t},i=this.status;this.status=2;const o=this.isReplayingCommand?[this.range,...this.corePlugins]:this.handlers;return this.dispatchToHandlers(o,s),this.status=i,Pe.Success},Ms.model=this,s=da(e,s);const o=ca(e);this.state=new Sd,this.uuidGenerator=i,this.config=this.setupConfig(t),this.session=this.setupSession(o.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new Ed(this.dispatchFromCorePlugin,this.session),this.getters={isReadonly:()=>this.config.isReadonly,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.range=new bd(this.getters),this.getters.getRangeString=this.range.getRangeString.bind(this.range),this.getters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.getters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.uuidGenerator.setIsFastStrategy(!0);for(let e of od.getAll())this.setupCorePlugin(e,o);for(let e of nd.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.setupSessionEvents(),this.session.loadInitialMessages(s),this.joinSession(t.client),t.snapshotRequested&&this.session.snapshot(this.exportData())}get handlers(){return[this.range,...this.corePlugins,...this.uiPlugins,this.history]}joinSession(e){this.session.join(e)}leaveSession(){this.session.leave()}destroy(){delete Ms.model}setupUiPlugin(e){if(e.modes.includes(this.config.mode)){const t=new e(this.getters,this.state,this.dispatch,this.config);for(let s of e.getters){if(!(s in t))throw new Error(`Invalid getter name: ${s} for plugin ${t.constructor}`);this.getters[s]=t[s].bind(t)}this.uiPlugins.push(t);const s=e.layers.map((e=>[t,e]));this.renderers.push(...s),this.renderers.sort(((e,t)=>e[1]-t[1]))}}setupCorePlugin(e,t){if(e.modes.includes(this.config.mode)){const s=new e(this.getters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);s.import(t);for(let t of e.getters){if(!(t in s))throw new Error(`Invalid getter name: ${t} for plugin ${s.constructor}`);this.getters[t]=s[t].bind(s)}this.corePlugins.push(s)}}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Kh(md(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:a("Anonymous").toString()},s=e.transportService||new rd;return{mode:e.mode||"normal",openSidePanel:e.openSidePanel||(()=>{}),notifyUser:e.notifyUser||(()=>{}),askConfirmation:e.askConfirmation||(()=>{}),editText:e.editText||(()=>{}),evalContext:e.evalContext||{},transportService:s,client:t,moveClient:()=>{},isHeadless:"headless"===e.mode||!1,isReadonly:e.isReadonly||!1,snapshotRequested:!1,dataSources:this.dataSources}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new Pe(t.flat()):Pe.Success}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){for(const s of e)s.beforeHandle(t);for(const s of e)s.handle(t)}drawGrid(e){e.viewport=this.getters.getActiveSnappedViewport();for(let[t,s]of this.renderers)e.ctx.save(),t.drawGrid(e,s),e.ctx.restore()}exportData(){let e=ga();for(let t of this.handlers)t instanceof ma&&t.export(e);return e.revisionId=this.session.getRevisionId()||O,e=JSON.parse(JSON.stringify(e)),e}updateReadOnly(e){e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.isReadonly=e||!1}waitForIdle(){return this.dataSources.waitForReady()}async exportXLSX(){await this.waitForIdle(),this.dispatch("EVALUATE_ALL_SHEETS");let e={...ga(),sheets:[(t=la,s="Sheet1",{...pa(t,s),charts:[]})]};var t,s;for(let t of this.handlers)t instanceof ma&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),Lu(e)}}const{useComponent:_u,useState:Ou,onPatched:Nu,onMounted:ku}=t.hooks;function Fu(e){const t=Ou({x:0,y:0}),s=_u(),i=function(){const e=Ou({x:0,y:0});let t=document.querySelector(".o-spreadsheet");function s(){if(t||(t=document.querySelector(".o-spreadsheet")),t){const{top:s,left:i}=t.getBoundingClientRect();e.x=i,e.y=s}}return ku(s),Nu(s),e}();function o(){const o=(null==e?void 0:e.el)||s.el,{top:n,left:r}=o.getBoundingClientRect(),a=r-i.x,l=n-i.y;a===t.x&&l===t.y||(t.x=a,t.y=l)}return ku(o),Nu(o),t}const{Portal:$u}=t.misc,{xml:Du}=t.tags,Uu=Du`
1448
1448
  <Portal target="'.o-spreadsheet'">
1449
1449
  <div class="o-popover" t-att-style="style">
1450
1450
  <t t-slot="default"/>
1451
1451
  </div>
1452
1452
  </Portal>
1453
- `;class Du extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters}get maxHeight(){return Math.max(0,this.viewportDimension.height-36-b)}get style(){const e=`left:${this.horizontalPosition()}`;return`\n position: absolute;\n z-index: 5;\n ${`top:${this.verticalPosition()}`}px;\n ${e}px;\n ${`max-height:${this.maxHeight}`}px;\n width:${this.props.childWidth}px;\n overflow-y: auto;\n overflow-x: hidden;\n box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);\n `}get viewportDimension(){return this.getters.getViewportDimension()}get shouldRenderRight(){const{x:e}=this.props.position;return e+this.props.childWidth<this.viewportDimension.width}get shouldRenderBottom(){const{y:e}=this.props.position;return e+Math.min(this.props.childHeight,this.maxHeight)<this.viewportDimension.height+v}horizontalPosition(){const{x:e}=this.props.position;return this.shouldRenderRight?e:e-this.props.childWidth-this.props.flipHorizontalOffset}verticalPosition(){const{y:e}=this.props.position;return this.shouldRenderBottom?e:Math.max(e-this.props.childHeight+this.props.flipVerticalOffset,this.props.marginTop)}}Du.template=$u,Du.components={Portal:ku},Du.defaultProps={flipHorizontalOffset:0,flipVerticalOffset:0,verticalOffset:0,marginTop:0};const{xml:Uu,css:Pu}=t.tags,{useExternalListener:Bu,useRef:Vu}=t.hooks,Hu=Uu`
1453
+ `;class Pu extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters}get maxHeight(){return Math.max(0,this.viewportDimension.height-36-S)}get style(){const e=`left:${this.horizontalPosition()}`;return`\n position: absolute;\n z-index: 5;\n ${`top:${this.verticalPosition()}`}px;\n ${e}px;\n ${`max-height:${this.maxHeight}`}px;\n width:${this.props.childWidth}px;\n overflow-y: auto;\n overflow-x: hidden;\n box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);\n `}get viewportDimension(){return this.getters.getViewportDimension()}get shouldRenderRight(){const{x:e}=this.props.position;return e+this.props.childWidth<this.viewportDimension.width}get shouldRenderBottom(){const{y:e}=this.props.position;return e+Math.min(this.props.childHeight,this.maxHeight)<this.viewportDimension.height+v}horizontalPosition(){const{x:e}=this.props.position;return this.shouldRenderRight?e:e-this.props.childWidth-this.props.flipHorizontalOffset}verticalPosition(){const{y:e}=this.props.position;return this.shouldRenderBottom?e:Math.max(e-this.props.childHeight+this.props.flipVerticalOffset,this.props.marginTop)}}Pu.template=Uu,Pu.components={Portal:$u},Pu.defaultProps={flipHorizontalOffset:0,flipVerticalOffset:0,verticalOffset:0,marginTop:0};const{xml:Bu,css:Vu}=t.tags,{useExternalListener:Hu,useRef:zu}=t.hooks,Zu=Bu`
1454
1454
  <Popover
1455
1455
  position="props.position"
1456
1456
  childWidth="${y}"
@@ -1476,7 +1476,7 @@
1476
1476
  <t t-esc="getName(menuItem)"/>
1477
1477
  <span class="o-menu-item-shortcut" t-esc="getShortCut(menuItem)"/>
1478
1478
  <t t-if="isMenuRoot">
1479
- ${Sl}
1479
+ ${Cl}
1480
1480
  </t>
1481
1481
  <t t-elif="menuItem.icon">
1482
1482
  <i t-att-class="menuItem.icon" class="o-menu-item-icon"/>
@@ -1491,7 +1491,7 @@
1491
1491
  depth="props.depth + 1"
1492
1492
  t-ref="subMenuRef"
1493
1493
  t-on-close="subMenu.isOpen=false"/>
1494
- </Popover>`,zu=Pu`
1494
+ </Popover>`,Gu=Vu`
1495
1495
  .o-menu {
1496
1496
  background-color: white;
1497
1497
  padding: 8px 0px;
@@ -1539,10 +1539,10 @@
1539
1539
  margin-bottom: ${5}px;
1540
1540
  }
1541
1541
  }
1542
- `;class Zu extends t.Component{constructor(){super(...arguments),this.position=Nu(Vu("menu")),this.subMenuRef=Vu("subMenuRef"),Bu(window,"click",this.onClick),Bu(window,"contextmenu",this.onContextMenu),this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]})}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){return this.menuComponentHeight(this.props.menuItems)}get subMenuHeight(){return this.menuComponentHeight(this.subMenu.menuItems)}get popover(){const e=1===this.props.depth;return{marginTop:95,flipHorizontalOffset:y*(this.props.depth-1),flipVerticalOffset:e?0:24}}async activateMenu(e){const t=await e.action(this.env);this.close(),this.trigger("menu-clicked",t)}close(){this.subMenu.isOpen=!1,this.trigger("close")}subMenuVerticalPosition(e){const t=this.props.menuItems.slice(0,e);return this.menuComponentHeight(t)+this.position.y}onClick(e){this.el&&Ac(this.el,e)||this.close()}onContextMenu(e){this.el&&Ac(this.el,e)||(this.subMenu.isOpen=!1)}menuComponentHeight(e){const t=e.filter((e=>e.separator));return 24*e.length+11*t.length}getName(e){return rl.getName(e,this.env)}getShortCut(e){return rl.getShortCut(e)}isRoot(e){return!e.action}isEnabled(e){return!!e.isEnabled(this.env)&&(!this.env.getters.isReadonly()||e.isReadonlyAllowed)}closeSubMenus(){this.subMenuRef.comp&&this.subMenuRef.comp.closeSubMenus(),this.subMenu.isOpen=!1}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){this.closeSubMenus();const s=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+y,y:s-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=rl.getChildren(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.subMenu.isOpen=!0}onClickMenu(e,t){this.isEnabled(e)&&(this.isRoot(e)?this.openSubMenu(e,t):this.activateMenu(e))}onMouseOver(e,t){e.isEnabled(this.env)&&(this.isRoot(e)?this.openSubMenu(e,t):this.subMenu.isOpen=!1)}}Zu.template=Hu,Zu.components={Menu:Zu,Popover:Du},Zu.style=zu,Zu.defaultProps={depth:1};const{xml:Gu,css:Wu}=t.tags,{useState:qu}=t.hooks,ju=Gu`
1542
+ `;class Wu extends t.Component{constructor(){super(...arguments),this.position=Fu(zu("menu")),this.subMenuRef=zu("subMenuRef"),Hu(window,"click",this.onClick),Hu(window,"contextmenu",this.onContextMenu),this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]})}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){return this.menuComponentHeight(this.props.menuItems)}get subMenuHeight(){return this.menuComponentHeight(this.subMenu.menuItems)}get popover(){const e=1===this.props.depth;return{marginTop:95,flipHorizontalOffset:y*(this.props.depth-1),flipVerticalOffset:e?0:24}}async activateMenu(e){const t=await e.action(this.env);this.close(),this.trigger("menu-clicked",t)}close(){this.subMenu.isOpen=!1,this.trigger("close")}subMenuVerticalPosition(e){const t=this.props.menuItems.slice(0,e);return this.menuComponentHeight(t)+this.position.y}onClick(e){this.el&&Oc(this.el,e)||this.close()}onContextMenu(e){this.el&&Oc(this.el,e)||(this.subMenu.isOpen=!1)}menuComponentHeight(e){const t=e.filter((e=>e.separator));return 24*e.length+11*t.length}getName(e){return ll.getName(e,this.env)}getShortCut(e){return ll.getShortCut(e)}isRoot(e){return!e.action}isEnabled(e){return!!e.isEnabled(this.env)&&(!this.env.getters.isReadonly()||e.isReadonlyAllowed)}closeSubMenus(){this.subMenuRef.comp&&this.subMenuRef.comp.closeSubMenus(),this.subMenu.isOpen=!1}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){this.closeSubMenus();const s=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+y,y:s-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=ll.getChildren(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.subMenu.isOpen=!0}onClickMenu(e,t){this.isEnabled(e)&&(this.isRoot(e)?this.openSubMenu(e,t):this.activateMenu(e))}onMouseOver(e,t){e.isEnabled(this.env)&&(this.isRoot(e)?this.openSubMenu(e,t):this.subMenu.isOpen=!1)}}Wu.template=Zu,Wu.components={Menu:Wu,Popover:Pu},Wu.style=Gu,Wu.defaultProps={depth:1};const{xml:qu,css:ju}=t.tags,{useState:Yu}=t.hooks,Xu=qu`
1543
1543
  <div class="o-spreadsheet-bottom-bar">
1544
1544
  <div class="o-sheet-item o-add-sheet" t-att-class="{'disabled': getters.isReadonly()}" t-on-click="addSheet">${'<svg class="o-icon"><path fill="#000000" d="M8,0 L10,0 L10,8 L18,8 L18,10 L10,10 L10,18 L8,18 L8,10 L0,10 L0,8 L8,8"/></svg>'}</div>
1545
- <div class="o-sheet-item o-list-sheets" t-on-click="listSheets">${Ml}</div>
1545
+ <div class="o-sheet-item o-list-sheets" t-on-click="listSheets">${_l}</div>
1546
1546
  <div class="o-all-sheets">
1547
1547
  <t t-foreach="getters.getSheets()" t-as="sheet" t-key="sheet.id">
1548
1548
  <div class="o-sheet-item o-sheet" t-on-click="activateSheet(sheet.id)"
@@ -1551,7 +1551,7 @@
1551
1551
  t-att-data-id="sheet.id"
1552
1552
  t-att-class="{active: sheet.id === getters.getActiveSheetId()}">
1553
1553
  <span class="o-sheet-name" t-esc="sheet.name" t-on-dblclick="onDblClick(sheet.id)"/>
1554
- <span class="o-sheet-icon" t-on-click.stop="onIconClick(sheet.id)">${El}</span>
1554
+ <span class="o-sheet-icon" t-on-click.stop="onIconClick(sheet.id)">${Sl}</span>
1555
1555
  </div>
1556
1556
  </t>
1557
1557
  </div>
@@ -1561,7 +1561,7 @@
1561
1561
  position="menuState.position"
1562
1562
  menuItems="menuState.menuItems"
1563
1563
  t-on-close="menuState.isOpen=false"/>
1564
- </div>`,Yu=Wu`
1564
+ </div>`,Ku=ju`
1565
1565
  .o-spreadsheet-bottom-bar {
1566
1566
  background-color: ${l};
1567
1567
  padding-left: ${m}px;
@@ -1644,7 +1644,7 @@
1644
1644
  opacity: 0;
1645
1645
  }
1646
1646
  }
1647
- `;class Xu extends t.Component{constructor(){super(...arguments),this.position=Nu(),this.getters=this.env.getters,this.menuState=qu({isOpen:!1,position:null,menuItems:[]})}mounted(){this.focusSheet()}patched(){this.focusSheet()}focusSheet(){const e=this.el.querySelector(`[data-id="${this.getters.getActiveSheetId()}"]`);e&&e.scrollIntoView&&e.scrollIntoView()}addSheet(){const e=this.env.getters.getActiveSheetId(),t=this.env.getters.getVisibleSheets().findIndex((t=>t===e))+1,s=this.env.uuidGenerator.uuidv4(),i=this.getters.getNextSheetName(this.env._t("Sheet"));this.env.dispatch("CREATE_SHEET",{sheetId:s,position:t,name:i}),this.env.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:s})}listSheets(e){const t=new Oa,s=this.getters.getActiveSheetId();let i=0;for(let e of this.getters.getSheets())t.add(e.id,{name:e.name,sequence:i,isReadonlyAllowed:!0,action:t=>t.dispatch("ACTIVATE_SHEET",{sheetIdFrom:s,sheetIdTo:e.id})}),i++;const o=e.currentTarget,{left:n}=o.getBoundingClientRect();this.openContextMenu(n,t)}activateSheet(e){this.env.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:e})}onDblClick(e){this.env.dispatch("RENAME_SHEET",{interactive:!0,sheetId:e})}openContextMenu(e,t){this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position={x:e,y:this.position.y}}onIconClick(e,t){if(this.getters.getActiveSheetId()!==e&&this.activateSheet(e),this.menuState.isOpen)this.menuState.isOpen=!1;else{const e=t.currentTarget.parentElement,{left:s}=e.getBoundingClientRect();this.openContextMenu(s,hl)}}onContextMenu(e,t){this.getters.getActiveSheetId()!==e&&this.activateSheet(e);const s=t.currentTarget,{left:i}=s.getBoundingClientRect();this.openContextMenu(i,hl)}}function Ku(e,t){const s=o=>{t(o),window.removeEventListener("mouseup",s),window.removeEventListener("dragstart",i),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function i(e){e.preventDefault()}window.addEventListener("mouseup",s),window.addEventListener("dragstart",i),window.addEventListener("mousemove",e),window.addEventListener("wheel",e)}function Qu(e,t,s,i){const o=e.getBoundingClientRect();let n,r=null;const a=e=>{if(n=e,r)return;const i=n.clientX-o.left,l=n.clientY-o.top,c=t.getters.getEdgeScrollCol(i),h=t.getters.getEdgeScrollRow(l),{top:d,left:u,bottom:p,right:g}=t.getters.getActiveSnappedViewport();let f,m;if(f=c.canEdgeScroll?c.direction>0?g:u-1:t.getters.getColIndex(i,u),m=h.canEdgeScroll?h.direction>0?p:d-1:t.getters.getRowIndex(l,d),s(f,m),c.canEdgeScroll){const{left:e,offsetY:s}=t.getters.getActiveSnappedViewport(),{cols:i}=t.getters.getActiveSheet(),o=i[e+c.direction].start;t.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o,offsetY:s}),r=setTimeout((()=>{r=null,a(n)}),Math.round(c.delay))}if(h.canEdgeScroll){const{top:e,offsetX:s}=t.getters.getActiveSnappedViewport(),{rows:i}=t.getters.getActiveSheet(),o=i[e+h.direction].start;t.dispatch("SET_VIEWPORT_OFFSET",{offsetX:s,offsetY:o}),r=setTimeout((()=>{r=null,a(n)}),Math.round(h.delay))}};Ku(a,(()=>{clearTimeout(r),i()}))}Xu.template=ju,Xu.style=Yu,Xu.components={Menu:Zu};const{xml:Ju,css:ep}=t.tags,{useState:tp}=t.hooks,sp=Ju`
1647
+ `;class Qu extends t.Component{constructor(){super(...arguments),this.position=Fu(),this.getters=this.env.getters,this.menuState=Yu({isOpen:!1,position:null,menuItems:[]})}mounted(){this.focusSheet()}patched(){this.focusSheet()}focusSheet(){const e=this.el.querySelector(`[data-id="${this.getters.getActiveSheetId()}"]`);e&&e.scrollIntoView&&e.scrollIntoView()}addSheet(){const e=this.env.getters.getActiveSheetId(),t=this.env.getters.getVisibleSheets().findIndex((t=>t===e))+1,s=this.env.uuidGenerator.uuidv4(),i=this.getters.getNextSheetName(this.env._t("Sheet"));this.env.dispatch("CREATE_SHEET",{sheetId:s,position:t,name:i}),this.env.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:s})}listSheets(e){const t=new ka,s=this.getters.getActiveSheetId();let i=0;for(let e of this.getters.getSheets())t.add(e.id,{name:e.name,sequence:i,isReadonlyAllowed:!0,action:t=>t.dispatch("ACTIVATE_SHEET",{sheetIdFrom:s,sheetIdTo:e.id})}),i++;const o=e.currentTarget,{left:n}=o.getBoundingClientRect();this.openContextMenu(n,t)}activateSheet(e){this.env.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:e})}onDblClick(e){this.env.dispatch("RENAME_SHEET",{interactive:!0,sheetId:e})}openContextMenu(e,t){this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position={x:e,y:this.position.y}}onIconClick(e,t){if(this.getters.getActiveSheetId()!==e&&this.activateSheet(e),this.menuState.isOpen)this.menuState.isOpen=!1;else{const e=t.currentTarget.parentElement,{left:s}=e.getBoundingClientRect();this.openContextMenu(s,ul)}}onContextMenu(e,t){this.getters.getActiveSheetId()!==e&&this.activateSheet(e);const s=t.currentTarget,{left:i}=s.getBoundingClientRect();this.openContextMenu(i,ul)}}function Ju(e,t){const s=o=>{t(o),window.removeEventListener("mouseup",s),window.removeEventListener("dragstart",i),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function i(e){e.preventDefault()}window.addEventListener("mouseup",s),window.addEventListener("dragstart",i),window.addEventListener("mousemove",e),window.addEventListener("wheel",e)}function ep(e,t,s,i){const o=e.getBoundingClientRect();let n,r=null;const a=e=>{if(n=e,r)return;const i=n.clientX-o.left,l=n.clientY-o.top,c=t.getters.getEdgeScrollCol(i),h=t.getters.getEdgeScrollRow(l),{top:d,left:u,bottom:p,right:g}=t.getters.getActiveSnappedViewport();let f,m;if(f=c.canEdgeScroll?c.direction>0?g:u-1:t.getters.getColIndex(i,u),m=h.canEdgeScroll?h.direction>0?p:d-1:t.getters.getRowIndex(l,d),s(f,m),c.canEdgeScroll){const{left:e,offsetY:s}=t.getters.getActiveSnappedViewport(),{cols:i}=t.getters.getActiveSheet(),o=i[e+c.direction].start;t.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o,offsetY:s}),r=setTimeout((()=>{r=null,a(n)}),Math.round(c.delay))}if(h.canEdgeScroll){const{top:e,offsetX:s}=t.getters.getActiveSnappedViewport(),{rows:i}=t.getters.getActiveSheet(),o=i[e+h.direction].start;t.dispatch("SET_VIEWPORT_OFFSET",{offsetX:s,offsetY:o}),r=setTimeout((()=>{r=null,a(n)}),Math.round(h.delay))}};Ju(a,(()=>{clearTimeout(r),i()}))}Qu.template=Xu,Qu.style=Ku,Qu.components={Menu:Wu};const{xml:tp,css:sp}=t.tags,{useState:ip}=t.hooks,op=tp`
1648
1648
  <div class="o-autofill" t-on-mousedown="onMouseDown" t-att-style="style" t-on-dblclick="onDblClick">
1649
1649
  <div class="o-autofill-handler" t-att-style="styleHandler"/>
1650
1650
  <t t-set="tooltip" t-value="getTooltip()"/>
@@ -1652,7 +1652,7 @@
1652
1652
  <t t-component="tooltip.component" t-props="tooltip.props"/>
1653
1653
  </div>
1654
1654
  </div>
1655
- `,ip=ep`
1655
+ `,np=sp`
1656
1656
  .o-autofill {
1657
1657
  height: 6px;
1658
1658
  width: 6px;
@@ -1680,9 +1680,9 @@
1680
1680
  white-space: nowrap;
1681
1681
  }
1682
1682
  }
1683
- `;class op extends t.Component{constructor(){super(...arguments),this.state=tp({position:{left:0,top:0},handler:!1})}get style(){const{left:e,top:t}=this.props.position;return`top:${t}px;left:${e}px`}get styleHandler(){let e=this.state.handler?this.state.position:{left:0,top:0};return`top:${e.top}px;left:${e.left}px;`}get styleNextvalue(){let e=this.state.handler?this.state.position:{left:0,top:0};return`top:${e.top+5}px;left:${e.left+15}px;`}getTooltip(){const e=this.env.getters.getAutofillTooltip();return e&&!e.component&&(e.component=np),e}onMouseDown(e){this.state.handler=!0,this.state.position={left:0,top:0};const{offsetY:t,offsetX:s}=this.env.getters.getActiveSnappedViewport(),i=e.clientX+s,o=e.clientY+t;let n,r;Ku((e=>{const t=this.el.parentElement.getBoundingClientRect(),{top:s,left:a,offsetY:l,offsetX:c}=this.env.getters.getActiveSnappedViewport();this.state.position={left:e.clientX-i+c,top:e.clientY-o+l};const h=this.env.getters.getColIndex(e.clientX-t.left,a),d=this.env.getters.getRowIndex(e.clientY-t.top,s);if(n!==h||r!==d){const e=this.env.getters.getActiveSheet();n=-1===h?n:ps(h,0,e.cols.length),r=-1===d?r:ps(d,0,e.rows.length),void 0!==n&&void 0!==r&&this.env.dispatch("AUTOFILL_SELECT",{col:n,row:r})}}),(()=>{this.state.handler=!1,this.env.dispatch("AUTOFILL")}))}onDblClick(){this.env.dispatch("AUTOFILL_AUTO")}}op.template=sp,op.style=ip;class np extends t.Component{}np.template=Ju`
1683
+ `;class rp extends t.Component{constructor(){super(...arguments),this.state=ip({position:{left:0,top:0},handler:!1})}get style(){const{left:e,top:t}=this.props.position;return`top:${t}px;left:${e}px`}get styleHandler(){let e=this.state.handler?this.state.position:{left:0,top:0};return`top:${e.top}px;left:${e.left}px;`}get styleNextvalue(){let e=this.state.handler?this.state.position:{left:0,top:0};return`top:${e.top+5}px;left:${e.left+15}px;`}getTooltip(){const e=this.env.getters.getAutofillTooltip();return e&&!e.component&&(e.component=ap),e}onMouseDown(e){this.state.handler=!0,this.state.position={left:0,top:0};const{offsetY:t,offsetX:s}=this.env.getters.getActiveSnappedViewport(),i=e.clientX+s,o=e.clientY+t;let n,r;Ju((e=>{const t=this.el.parentElement.getBoundingClientRect(),{top:s,left:a,offsetY:l,offsetX:c}=this.env.getters.getActiveSnappedViewport();this.state.position={left:e.clientX-i+c,top:e.clientY-o+l};const h=this.env.getters.getColIndex(e.clientX-t.left,a),d=this.env.getters.getRowIndex(e.clientY-t.top,s);if(n!==h||r!==d){const e=this.env.getters.getActiveSheet();n=-1===h?n:ps(h,0,e.cols.length),r=-1===d?r:ps(d,0,e.rows.length),void 0!==n&&void 0!==r&&this.env.dispatch("AUTOFILL_SELECT",{col:n,row:r})}}),(()=>{this.state.handler=!1,this.env.dispatch("AUTOFILL")}))}onDblClick(){this.env.dispatch("AUTOFILL_AUTO")}}rp.template=op,rp.style=np;class ap extends t.Component{}ap.template=tp`
1684
1684
  <div t-esc="props.content"/>
1685
- `;const{css:rp,xml:ap}=t.tags,lp=ap`
1685
+ `;const{css:lp,xml:cp}=t.tags,hp=cp`
1686
1686
  <div>
1687
1687
  <div
1688
1688
  class="o-client-tag"
@@ -1690,7 +1690,7 @@
1690
1690
  t-esc="props.name"
1691
1691
  />
1692
1692
  </div>
1693
- `,cp=rp`
1693
+ `,dp=lp`
1694
1694
  .o-client-tag {
1695
1695
  position: absolute;
1696
1696
  border-top-left-radius: 4px;
@@ -1700,7 +1700,7 @@
1700
1700
  opacity: 0;
1701
1701
  pointer-events: none;
1702
1702
  }
1703
- `;class hp extends t.Component{get tagStyle(){const{col:e,row:t,color:s}=this.props,i=this.env.getters.getActiveSnappedViewport(),{height:o}=this.env.getters.getViewportDimension(),[n,r,,]=this.env.getters.getRect({left:e,top:t,right:e,bottom:t},i);return`bottom: ${o-r+15}px;left: ${n-1}px;border: 1px solid ${s};background-color: ${s};${this.props.active?"opacity:1 !important":""}`}}hp.template=lp,hp.style=cp;const{xml:dp,css:up}=t.tags,pp=or.content,gp=new Le;gp.add("functions",(()=>Object.keys(pp).map((e=>({text:e,description:pp[e].description})))));const fp=dp`
1703
+ `;class up extends t.Component{get tagStyle(){const{col:e,row:t,color:s}=this.props,i=this.env.getters.getActiveSnappedViewport(),{height:o}=this.env.getters.getViewportDimension(),[n,r,,]=this.env.getters.getRect({left:e,top:t,right:e,bottom:t},i);return`bottom: ${o-r+15}px;left: ${n-1}px;border: 1px solid ${s};background-color: ${s};${this.props.active?"opacity:1 !important":""}`}}up.template=hp,up.style=dp;const{xml:pp,css:gp}=t.tags,fp=rr.content,mp=new Le;mp.add("functions",(()=>Object.keys(fp).map((e=>({text:e,description:fp[e].description})))));const vp=pp`
1704
1704
  <div t-att-class="{'o-autocomplete-dropdown':state.values.length}"
1705
1705
  t-att-style="state.values.length > 0 ? props.borderStyle : null"
1706
1706
  >
@@ -1710,7 +1710,7 @@
1710
1710
  <div class="o-autocomplete-description" t-esc="v.description" t-if="state.selectedIndex === v_index"/>
1711
1711
  </div>
1712
1712
  </t>
1713
- </div>`,mp=up`
1713
+ </div>`,Ep=gp`
1714
1714
  .o-autocomplete-dropdown {
1715
1715
  pointer-events: auto;
1716
1716
  background-color: #fff;
@@ -1734,7 +1734,7 @@
1734
1734
  }
1735
1735
  }
1736
1736
  }
1737
- `;class vp extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],selectedIndex:0})}mounted(){this.filter(this.props.search)}willUpdateProps(e){return e.search!==this.props.search&&this.filter(e.search),super.willUpdateProps(e)}async filter(e){let t=gp.get(this.props.provider)();t=this.props.filter?this.props.filter(e,t):t.filter((t=>t.text.toUpperCase().startsWith(e.toUpperCase()))).sort(((e,t)=>e.text<t.text?-1:e.text>t.text?1:0)),this.state.values=t.slice(0,10),this.state.selectedIndex=0}fillValue(e){this.state.selectedIndex=e,this.trigger("completed",{text:this.getValueToFill()})}moveDown(){this.state.selectedIndex=(this.state.selectedIndex+1)%this.state.values.length}moveUp(){this.state.selectedIndex--,this.state.selectedIndex<0&&(this.state.selectedIndex=this.state.values.length-1)}getValueToFill(){if(this.state.values.length)return this.state.values[this.state.selectedIndex].text}}vp.template=fp,vp.style=mp;class Ep{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let s=window.getSelection();this.removeSelection();let i=document.createRange();if(e==t&&0===e)i.setStart(this.el,0),i.setEnd(this.el,0),s.addRange(i);else{(e<0||t>this.el.textContent.length)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${this.el.textContent.length}`),e<0&&(e=0),t>this.el.textContent.length&&(t=this.el.textContent.length),e>this.el.textContent.length&&(e=this.el.textContent.length));let o=this.findChildAtCharacterIndex(e),n=this.findChildAtCharacterIndex(t);i.setStart(o.node,o.offset),s.addRange(i),s.extend(n.node,n.offset)}}findChildAtCharacterIndex(e){let t,s,i=this.iterateChildren(this.el),o=e;do{t=i.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<o?o-=t.value.textContent.length:i.return(t.value),s=t.value)}while(!t.done);return t.value?{node:t.value,offset:o}:{node:s,offset:o}}*iterateChildren(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*this.iterateChildren(t)}setText(e){if(0!==e.length)for(const t of e){const e=document.createElement("span");e.innerText=t.value,t.color&&(e.style.color=t.color),t.class&&e.classList.add(t.class),this.el.appendChild(e)}}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:s,endSelectionOffset:i}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,s),end:this.findSelectionIndex(t,i)}}findSelectionIndex(e,t){let s=this.iterateChildren(this.el),i=0,o=s.next();for(;!o.done&&o.value!==e;)o.value.hasChildNodes()||o.value.textContent&&(i+=o.value.textContent.length),o=s.next();if(o.value===e)if(o.value.hasChildNodes()){const e=[...o.value.childNodes].slice(0,t);for(const t of e)t.textContent&&(i+=t.textContent.length)}else i+=t;return i}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}}const Sp=a("ABOUT"),bp=a("optional"),Cp=a("by default"),Ip=a("repeatable"),{xml:yp,css:wp}=t.tags,{useState:Tp}=t.hooks,xp=yp`
1737
+ `;class bp extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],selectedIndex:0})}mounted(){this.filter(this.props.search)}willUpdateProps(e){return e.search!==this.props.search&&this.filter(e.search),super.willUpdateProps(e)}async filter(e){let t=mp.get(this.props.provider)();t=this.props.filter?this.props.filter(e,t):t.filter((t=>t.text.toUpperCase().startsWith(e.toUpperCase()))).sort(((e,t)=>e.text<t.text?-1:e.text>t.text?1:0)),this.state.values=t.slice(0,10),this.state.selectedIndex=0}fillValue(e){this.state.selectedIndex=e,this.trigger("completed",{text:this.getValueToFill()})}moveDown(){this.state.selectedIndex=(this.state.selectedIndex+1)%this.state.values.length}moveUp(){this.state.selectedIndex--,this.state.selectedIndex<0&&(this.state.selectedIndex=this.state.values.length-1)}getValueToFill(){if(this.state.values.length)return this.state.values[this.state.selectedIndex].text}}bp.template=vp,bp.style=Ep;class Sp{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let s=window.getSelection();this.removeSelection();let i=document.createRange();if(e==t&&0===e)i.setStart(this.el,0),i.setEnd(this.el,0),s.addRange(i);else{(e<0||t>this.el.textContent.length)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${this.el.textContent.length}`),e<0&&(e=0),t>this.el.textContent.length&&(t=this.el.textContent.length),e>this.el.textContent.length&&(e=this.el.textContent.length));let o=this.findChildAtCharacterIndex(e),n=this.findChildAtCharacterIndex(t);i.setStart(o.node,o.offset),s.addRange(i),s.extend(n.node,n.offset)}}findChildAtCharacterIndex(e){let t,s,i=this.iterateChildren(this.el),o=e;do{t=i.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<o?o-=t.value.textContent.length:i.return(t.value),s=t.value)}while(!t.done);return t.value?{node:t.value,offset:o}:{node:s,offset:o}}*iterateChildren(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*this.iterateChildren(t)}setText(e){if(0!==e.length)for(const t of e){const e=document.createElement("span");e.innerText=t.value,t.color&&(e.style.color=t.color),t.class&&e.classList.add(t.class),this.el.appendChild(e)}}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:s,endSelectionOffset:i}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,s),end:this.findSelectionIndex(t,i)}}findSelectionIndex(e,t){let s=this.iterateChildren(this.el),i=0,o=s.next();for(;!o.done&&o.value!==e;)o.value.hasChildNodes()||o.value.textContent&&(i+=o.value.textContent.length),o=s.next();if(o.value===e)if(o.value.hasChildNodes()){const e=[...o.value.childNodes].slice(0,t);for(const t of e)t.textContent&&(i+=t.textContent.length)}else i+=t;return i}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}}const Cp=a("ABOUT"),Ip=a("optional"),yp=a("by default"),wp=a("repeatable"),{xml:Tp,css:xp}=t.tags,{useState:Rp}=t.hooks,Lp=Tp`
1738
1738
  <div class="o-formula-assistant-container"
1739
1739
  t-att-style="props.borderStyle"
1740
1740
  t-att-class="{
@@ -1761,7 +1761,7 @@
1761
1761
  </div>
1762
1762
 
1763
1763
  <div class="o-formula-assistant-core">
1764
- <div class="o-formula-assistant-gray" t-esc="env._t('${Sp}')"/>
1764
+ <div class="o-formula-assistant-gray" t-esc="env._t('${Cp}')"/>
1765
1765
  <div t-esc="context.functionDescription.description"/>
1766
1766
  </div>
1767
1767
 
@@ -1773,12 +1773,12 @@
1773
1773
  }" >
1774
1774
  <div>
1775
1775
  <span t-esc="arg.name" />
1776
- <span t-if="arg.optional || arg.repeating || arg.default "> - [<t t-esc="env._t('${bp}')"/>] </span>
1776
+ <span t-if="arg.optional || arg.repeating || arg.default "> - [<t t-esc="env._t('${Ip}')"/>] </span>
1777
1777
  <span t-if="arg.default">
1778
1778
  <t t-esc="arg.defaultValue" />
1779
- <t t-esc="env._t(' ${Cp}')"/>
1779
+ <t t-esc="env._t(' ${yp}')"/>
1780
1780
  </span>
1781
- <span t-if="arg.repeating" t-esc="env._t('${Ip}')"/>
1781
+ <span t-if="arg.repeating" t-esc="env._t('${wp}')"/>
1782
1782
  </div>
1783
1783
  <div class="o-formula-assistant-arg-description" t-esc="arg.description"/>
1784
1784
  </div>
@@ -1786,7 +1786,7 @@
1786
1786
 
1787
1787
  </div>
1788
1788
  </div>
1789
- `,Rp=wp`
1789
+ `,Mp=xp`
1790
1790
  .o-formula-assistant {
1791
1791
  white-space: normal;
1792
1792
  background-color: #fff;
@@ -1833,7 +1833,7 @@
1833
1833
  .o-formula-assistant-transparency {
1834
1834
  opacity: 0.3;
1835
1835
  }
1836
- `;class Lp extends t.Component{constructor(){super(...arguments),this.assistantState=Tp({allowCellSelectionBehind:!1}),this.timeOutId=0}willUnmount(){this.timeOutId&&clearTimeout(this.timeOutId)}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}Lp.template=xp,Lp.style=Rp;const{useState:Mp,useRef:Ap}=t.hooks,{xml:_p,css:Op}=t.tags,Np=or.content,kp="#4a4e4d",Fp="#3da4ab",$p="#02c39a",Dp="selector-flag",Up={OPERATOR:Fp,NUMBER:$p,STRING:"#f6cd61",FUNCTION:kp,DEBUGGER:Fp,LEFT_PAREN:kp,RIGHT_PAREN:kp,COMMA:kp},Pp=_p`
1836
+ `;class Ap extends t.Component{constructor(){super(...arguments),this.assistantState=Rp({allowCellSelectionBehind:!1}),this.timeOutId=0}willUnmount(){this.timeOutId&&clearTimeout(this.timeOutId)}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}Ap.template=Lp,Ap.style=Mp;const{useState:_p,useRef:Op}=t.hooks,{xml:Np,css:kp}=t.tags,Fp=rr.content,$p="#4a4e4d",Dp="#3da4ab",Up="#02c39a",Pp="selector-flag",Bp={OPERATOR:Dp,NUMBER:Up,STRING:"#f6cd61",FUNCTION:$p,DEBUGGER:Dp,LEFT_PAREN:$p,RIGHT_PAREN:$p,COMMA:$p},Vp=Np`
1837
1837
  <div class="o-composer-container">
1838
1838
  <div
1839
1839
  t-att-class="{ 'o-composer': true, 'text-muted': getters.isReadonly(), 'unfocusable': getters.isReadonly() }"
@@ -1874,7 +1874,7 @@
1874
1874
  />
1875
1875
  </div>
1876
1876
  </div>
1877
- `,Bp=Op`
1877
+ `,Hp=kp`
1878
1878
  .o-composer-container {
1879
1879
  padding: 0;
1880
1880
  margin: 0;
@@ -1895,7 +1895,7 @@
1895
1895
  }
1896
1896
  span {
1897
1897
  white-space: pre;
1898
- &.${Dp}:after {
1898
+ &.${Pp}:after {
1899
1899
  content: "${"␣"}";
1900
1900
  color: ${"darkgrey"};
1901
1901
  }
@@ -1912,7 +1912,7 @@
1912
1912
  .o-topbar-toolbar .o-composer-container:focus-within {
1913
1913
  border: 1px solid ${p};
1914
1914
  }
1915
- `;class Vp extends t.Component{constructor(){super(...arguments),this.composerRef=Ap("o_composer"),this.autoCompleteRef=Ap("o_autocomplete_provider"),this.getters=this.env.getters,this.dispatch=this.env.dispatch,this.composerState=Mp({positionStart:0,positionEnd:0}),this.autoCompleteState=Mp({showProvider:!1,provider:"functions",search:""}),this.functionDescriptionState=Mp({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,this.borderStyle="box-shadow: 0 1px 4px 3px rgba(60, 64, 67, 0.15);",this.shouldProcessInputEvents=!1,this.tokens=[],this.keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:()=>console.warn("Not implemented"),Tab:e=>this.processTabKey(e)},this.contentHelper=new Ep(this.composerRef.el)}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const[e,t,,s]=this.props.rect;let i="";return t>this.props.delimitation.height-(t+s)&&(i+="\n top: -8px;\n transform: translate(0, -100%);\n "),e+300>this.props.delimitation.width&&(i+="right:0px;"),i+="width:300px;"}return"width:300px;"}mounted(){Ms.composer=this;const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent()}willUnmount(){delete Ms.composer,this.trigger("composer-unmounted")}patched(){this.isKeyStillDown||this.processContent()}processArrowKeys(e){if(this.getters.isSelectingForComposer())return void(this.functionDescriptionState.showDescription=!1);if("cellFocus"===this.props.focus&&!this.autoCompleteState.showProvider)return;e.stopPropagation();const t=this.autoCompleteRef.comp;["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&t&&(e.preventDefault(),"ArrowUp"===e.key?t.moveUp():t.moveDown()),this.updateCursorIfNeeded()}processTabKey(e){e.preventDefault(),e.stopPropagation();const t=this.autoCompleteRef.comp;if(this.autoCompleteState.showProvider&&t){const e=t.getValueToFill();if(e)return void this.autoComplete(e)}else this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const s=e.shiftKey?-1:1;this.dispatch("MOVE_POSITION",{deltaX:s,deltaY:0})}processEnterKey(e){e.preventDefault(),e.stopPropagation(),this.isKeyStillDown=!1;const t=this.autoCompleteRef.comp;if(this.autoCompleteState.showProvider&&t){const e=t.getValueToFill();if(e)return void this.autoComplete(e)}this.dispatch("STOP_EDITION"),this.dispatch("MOVE_POSITION",{deltaX:0,deltaY:e.shiftKey?-1:1})}processEscapeKey(){this.dispatch("STOP_EDITION",{cancel:!0})}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):(e.stopPropagation(),this.updateCursorIfNeeded())}updateCursorIfNeeded(){if(!this.getters.isSelectingForComposer()){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onInput(){if("inactive"===this.props.focus||!this.shouldProcessInputEvents)return;this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const e=this.composerRef.el;this.dispatch("SET_CURRENT_CONTENT",{content:e.childNodes.length?e.textContent:"",selection:this.contentHelper.getCurrentSelection()})}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Shift","Tab","Enter"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.autoCompleteState.search="",this.autoCompleteState.showProvider=!0,void this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:s}=this.getters.getComposerSelection(),{start:i,end:o}=this.contentHelper.getCurrentSelection();i===t&&o===s||this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.trigger("composer-content-focused",{selection:e}),this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}onCompleted(e){this.autoComplete(e.detail.text)}processContent(){if(this.compositionActive)return;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&this.contentHelper.selectRange(0,0);const e=this.getContent();if(0!==e.length){this.contentHelper.setText(e);const{start:t,end:s}=this.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,s)}this.shouldProcessInputEvents=!0}getContent(){let e;const t=this.getters.getCurrentContent(),s=t.startsWith("=")&&this.getters.getCurrentTokens().length>0;return e=""===t?[]:s&&"inactive"!==this.getters.getEditionMode()?this.getColoredTokens():[{value:t}],e}getColoredTokens(){const e=this.getters.getCurrentTokens(),t=this.getters.getTokenAtCursor(),s=[],{end:i}=this.getters.getComposerSelection();for(const o of e){switch(o.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":s.push({value:o.value,color:Up[o.type]||"#000"});break;case"SYMBOL":let e=o.value;const{xc:i,sheetName:n}=es(e);Jt.test(i)?s.push({value:o.value,color:this.rangeColor(i,n)||"#000"}):["TRUE","FALSE"].includes(e.toUpperCase())?s.push({value:o.value,color:$p}):s.push({value:o.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===o.parenIndex?s.push({value:o.value,color:"pink"}):s.push({value:o.value,color:Up[o.type]||"#000"});break;default:s.push({value:o.value,color:"#000"})}"waitingForRangeSelection"===this.getters.getEditionMode()&&i===o.end&&(s[s.length-1].class=Dp)}return s}rangeColor(e,t){if("inactive"===this.getters.getEditionMode())return;const s=this.getters.getHighlights(),i=t?this.getters.getSheetIdByName(t):this.getters.getEditionSheet(),o=s.find((t=>{if(t.sheet!==i)return!1;let s=Os(e);const{height:o,width:n}=Zs(s);return s=o*n==1?this.getters.expandZone(i,Os(e)):s,t.sheet===i&&Us(s,t.zone)}));return o&&o.color?o.color:void 0}processTokenAtCursor(){let e=this.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.getters.getTokenAtCursor();if(e){const{xc:t}=es(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Jt.test(t))this.autoCompleteState.search=e.value,this.autoCompleteState.showProvider=!0;else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,s=t.parent.toUpperCase(),i=Np[s],o=t.argPosition;this.functionDescriptionState.functionName=s,this.functionDescriptionState.functionDescription=i,this.functionDescriptionState.argToFocus=i.getArgToFocus(o+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.getters.getTokenAtCursor();if(t){let s=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(s=t.start);const o=this.getters.getCurrentTokens();if(this.autoCompleteState.provider&&o.length){e+="(";const s=o.map((e=>e.start)).indexOf(t.start);if(s+1<o.length){"LEFT_PAREN"===o[s+1].type&&i++}}this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:s,end:i})}this.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Vp.template=Pp,Vp.style=Bp,Vp.components={TextValueProvider:vp,FunctionDescriptionProvider:Lp},Vp.defaultProps={inputStyle:"",focus:"inactive"};const{useState:Hp}=t.hooks,{xml:zp,css:Zp}=t.tags,Gp=zp`
1915
+ `;class zp extends t.Component{constructor(){super(...arguments),this.composerRef=Op("o_composer"),this.autoCompleteRef=Op("o_autocomplete_provider"),this.getters=this.env.getters,this.dispatch=this.env.dispatch,this.composerState=_p({positionStart:0,positionEnd:0}),this.autoCompleteState=_p({showProvider:!1,provider:"functions",search:""}),this.functionDescriptionState=_p({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,this.borderStyle="box-shadow: 0 1px 4px 3px rgba(60, 64, 67, 0.15);",this.shouldProcessInputEvents=!1,this.tokens=[],this.keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:()=>console.warn("Not implemented"),Tab:e=>this.processTabKey(e)},this.contentHelper=new Sp(this.composerRef.el)}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const[e,t,,s]=this.props.rect;let i="";return t>this.props.delimitation.height-(t+s)&&(i+="\n top: -8px;\n transform: translate(0, -100%);\n "),e+300>this.props.delimitation.width&&(i+="right:0px;"),i+="width:300px;"}return"width:300px;"}mounted(){Ms.composer=this;const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent()}willUnmount(){delete Ms.composer,this.trigger("composer-unmounted")}patched(){this.isKeyStillDown||this.processContent()}processArrowKeys(e){if(this.getters.isSelectingForComposer())return void(this.functionDescriptionState.showDescription=!1);if("cellFocus"===this.props.focus&&!this.autoCompleteState.showProvider)return;e.stopPropagation();const t=this.autoCompleteRef.comp;["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&t&&(e.preventDefault(),"ArrowUp"===e.key?t.moveUp():t.moveDown()),this.updateCursorIfNeeded()}processTabKey(e){e.preventDefault(),e.stopPropagation();const t=this.autoCompleteRef.comp;if(this.autoCompleteState.showProvider&&t){const e=t.getValueToFill();if(e)return void this.autoComplete(e)}else this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const s=e.shiftKey?-1:1;this.dispatch("MOVE_POSITION",{deltaX:s,deltaY:0})}processEnterKey(e){e.preventDefault(),e.stopPropagation(),this.isKeyStillDown=!1;const t=this.autoCompleteRef.comp;if(this.autoCompleteState.showProvider&&t){const e=t.getValueToFill();if(e)return void this.autoComplete(e)}this.dispatch("STOP_EDITION"),this.dispatch("MOVE_POSITION",{deltaX:0,deltaY:e.shiftKey?-1:1})}processEscapeKey(){this.dispatch("STOP_EDITION",{cancel:!0})}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):(e.stopPropagation(),this.updateCursorIfNeeded())}updateCursorIfNeeded(){if(!this.getters.isSelectingForComposer()){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onInput(){if("inactive"===this.props.focus||!this.shouldProcessInputEvents)return;this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const e=this.composerRef.el;this.dispatch("SET_CURRENT_CONTENT",{content:e.childNodes.length?e.textContent:"",selection:this.contentHelper.getCurrentSelection()})}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Shift","Tab","Enter"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.autoCompleteState.search="",this.autoCompleteState.showProvider=!0,void this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:s}=this.getters.getComposerSelection(),{start:i,end:o}=this.contentHelper.getCurrentSelection();i===t&&o===s||this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.trigger("composer-content-focused",{selection:e}),this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}onCompleted(e){this.autoComplete(e.detail.text)}processContent(){if(this.compositionActive)return;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&this.contentHelper.selectRange(0,0);const e=this.getContent();if(0!==e.length){this.contentHelper.setText(e);const{start:t,end:s}=this.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,s)}this.shouldProcessInputEvents=!0}getContent(){let e;const t=this.getters.getCurrentContent(),s=t.startsWith("=")&&this.getters.getCurrentTokens().length>0;return e=""===t?[]:s&&"inactive"!==this.getters.getEditionMode()?this.getColoredTokens():[{value:t}],e}getColoredTokens(){const e=this.getters.getCurrentTokens(),t=this.getters.getTokenAtCursor(),s=[],{end:i}=this.getters.getComposerSelection();for(const o of e){switch(o.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":s.push({value:o.value,color:Bp[o.type]||"#000"});break;case"SYMBOL":let e=o.value;const{xc:i,sheetName:n}=es(e);Jt.test(i)?s.push({value:o.value,color:this.rangeColor(i,n)||"#000"}):["TRUE","FALSE"].includes(e.toUpperCase())?s.push({value:o.value,color:Up}):s.push({value:o.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===o.parenIndex?s.push({value:o.value,color:"pink"}):s.push({value:o.value,color:Bp[o.type]||"#000"});break;default:s.push({value:o.value,color:"#000"})}"waitingForRangeSelection"===this.getters.getEditionMode()&&i===o.end&&(s[s.length-1].class=Pp)}return s}rangeColor(e,t){if("inactive"===this.getters.getEditionMode())return;const s=this.getters.getHighlights(),i=t?this.getters.getSheetIdByName(t):this.getters.getEditionSheet(),o=s.find((t=>{if(t.sheet!==i)return!1;let s=ks(e);const{height:o,width:n}=Ws(s);return s=o*n==1?this.getters.expandZone(i,ks(e)):s,t.sheet===i&&Bs(s,t.zone)}));return o&&o.color?o.color:void 0}processTokenAtCursor(){let e=this.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.getters.getTokenAtCursor();if(e){const{xc:t}=es(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Jt.test(t))this.autoCompleteState.search=e.value,this.autoCompleteState.showProvider=!0;else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,s=t.parent.toUpperCase(),i=Fp[s],o=t.argPosition;this.functionDescriptionState.functionName=s,this.functionDescriptionState.functionDescription=i,this.functionDescriptionState.argToFocus=i.getArgToFocus(o+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.getters.getTokenAtCursor();if(t){let s=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(s=t.start);const o=this.getters.getCurrentTokens();if(this.autoCompleteState.provider&&o.length){e+="(";const s=o.map((e=>e.start)).indexOf(t.start);if(s+1<o.length){"LEFT_PAREN"===o[s+1].type&&i++}}this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:s,end:i})}this.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}zp.template=Vp,zp.style=Hp,zp.components={TextValueProvider:bp,FunctionDescriptionProvider:Ap},zp.defaultProps={inputStyle:"",focus:"inactive"};const{useState:Zp}=t.hooks,{xml:Gp,css:Wp}=t.tags,qp=Gp`
1916
1916
  <div class="o-grid-composer" t-att-style="containerStyle">
1917
1917
  <Composer
1918
1918
  focus = "props.focus"
@@ -1922,18 +1922,18 @@
1922
1922
  t-on-keydown = "onKeydown"
1923
1923
  />
1924
1924
  </div>
1925
- `,Wp=Zp`
1925
+ `,jp=Wp`
1926
1926
  .o-grid-composer {
1927
1927
  z-index: 5;
1928
1928
  box-sizing: border-box;
1929
1929
  position: absolute;
1930
1930
  border: ${3*.4*window.devicePixelRatio||1}px solid ${p};
1931
1931
  }
1932
- `;class qp extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters,this.composerState=Hp({rect:null,delimitation:null});const[e,t]=this.getters.getPosition();this.zone=this.getters.expandZone(this.getters.getActiveSheetId(),{left:e,right:e,top:t,bottom:t}),this.rect=this.getters.getRect(this.zone,this.getters.getActiveSnappedViewport())}get containerStyle(){const e=this.getters.getCurrentContent().startsWith("="),t=this.getters.getCurrentStyle(),[s,i,o,n]=this.rect,r=!e&&t.fillColor||"#ffffff",a=!e&&t.textColor||"#000000",l=!e&&t.fontSize||10,c=!e&&t.bold?"bold":500,h=!e&&t.italic?"italic":"normal",d=e?"none":_c(t);let u="left";if(!e){const e=this.getters.getActiveCell();u=t.align||(null==e?void 0:e.defaultAlign)||"left"}return`\n left: ${s-1}px;\n top: ${i}px;\n min-width: ${o+2}px;\n min-height: ${n+1}px;\n\n background: ${r};\n color: ${a};\n\n font-size: ${cs[l]}px;\n font-weight: ${c};\n font-style: ${h};\n text-decoration: ${d};\n\n text-align: ${u};\n `}get composerStyle(){return`\n line-height: ${S}px;\n max-height: inherit;\n overflow: hidden;\n `}mounted(){const e=this.el,t=e.parentElement.clientHeight-this.rect[1]-15;e.style.maxHeight=t+"px";const s=e.parentElement.clientWidth-this.rect[0]-14;e.style.maxWidth=s+"px",this.composerState.rect=[this.rect[0],this.rect[1],e.clientWidth,e.clientHeight],this.composerState.delimitation={width:e.parentElement.clientWidth,height:e.parentElement.clientHeight}}onKeydown(e){["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)&&e.preventDefault()}}qp.template=Gp,qp.style=Wp,qp.components={Composer:Vp};const{xml:jp,css:Yp}=t.tags,Xp=jp`
1932
+ `;class Yp extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters,this.composerState=Zp({rect:null,delimitation:null});const[e,t]=this.getters.getPosition();this.zone=this.getters.expandZone(this.getters.getActiveSheetId(),{left:e,right:e,top:t,bottom:t}),this.rect=this.getters.getRect(this.zone,this.getters.getActiveSnappedViewport())}get containerStyle(){const e=this.getters.getCurrentContent().startsWith("="),t=this.getters.getCurrentStyle(),[s,i,o,n]=this.rect,r=!e&&t.fillColor||"#ffffff",a=!e&&t.textColor||"#000000",l=!e&&t.fontSize||10,c=!e&&t.bold?"bold":500,h=!e&&t.italic?"italic":"normal",d=e?"none":Nc(t);let u="left";if(!e){const e=this.getters.getActiveCell();u=t.align||(null==e?void 0:e.defaultAlign)||"left"}return`\n left: ${s-1}px;\n top: ${i}px;\n min-width: ${o+2}px;\n min-height: ${n+1}px;\n\n background: ${r};\n color: ${a};\n\n font-size: ${cs[l]}px;\n font-weight: ${c};\n font-style: ${h};\n text-decoration: ${d};\n\n text-align: ${u};\n `}get composerStyle(){return`\n line-height: ${b}px;\n max-height: inherit;\n overflow: hidden;\n `}mounted(){const e=this.el,t=e.parentElement.clientHeight-this.rect[1]-15;e.style.maxHeight=t+"px";const s=e.parentElement.clientWidth-this.rect[0]-14;e.style.maxWidth=s+"px",this.composerState.rect=[this.rect[0],this.rect[1],e.clientWidth,e.clientHeight],this.composerState.delimitation={width:e.parentElement.clientWidth,height:e.parentElement.clientHeight}}onKeydown(e){["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)&&e.preventDefault()}}Yp.template=qp,Yp.style=jp,Yp.components={Composer:zp};const{xml:Xp,css:Kp}=t.tags,Qp=Xp`
1933
1933
  <div class="o-error-tooltip">
1934
1934
  <t t-esc="props.text"/>
1935
1935
  </div>
1936
- `,Kp=Yp`
1936
+ `,Jp=Kp`
1937
1937
  .o-error-tooltip {
1938
1938
  font-size: 13px;
1939
1939
  background-color: white;
@@ -1944,15 +1944,15 @@
1944
1944
  .o-popover:has(.o-error-tooltip) {
1945
1945
  z-index: 4 !important;
1946
1946
  }
1947
- `;class Qp extends t.Component{}Qp.template=Xp,Qp.style=Kp;const{useState:Jp}=i,{xml:eg,css:tg}=t.tags,{useRef:sg}=t.hooks,ig=eg`
1947
+ `;class eg extends t.Component{}eg.template=Qp,eg.style=Jp;const{useState:tg}=i,{xml:sg,css:ig}=t.tags,{useRef:og}=t.hooks,ng=sg`
1948
1948
  <div class="o-chart-container">
1949
- <div class="o-chart-menu" t-on-click="showMenu">${Ml}</div>
1949
+ <div class="o-chart-menu" t-on-click="showMenu">${_l}</div>
1950
1950
  <canvas class="w-100 h-100" t-att-style="canvasStyle" t-ref="graphContainer"/>
1951
1951
  <Menu t-if="menuState.isOpen"
1952
1952
  position="menuState.position"
1953
1953
  menuItems="menuState.menuItems"
1954
1954
  t-on-close="menuState.isOpen=false"/>
1955
- </div>`,og=tg`
1955
+ </div>`,rg=ig`
1956
1956
  .o-chart-container {
1957
1957
  width: 100%;
1958
1958
  height: 100%;
@@ -1973,7 +1973,7 @@
1973
1973
  }
1974
1974
  }
1975
1975
  }
1976
- `;class ng extends t.Component{constructor(){super(...arguments),this.menuState=Jp({isOpen:!1,position:null,menuItems:[]}),this.canvas=sg("graphContainer"),this.state={background:g},this.position=Nu()}get canvasStyle(){return`background-color: ${this.state.background}`}mounted(){const e=this.props.figure,t=this.env.getters.getChartRuntime(e.id);t&&this.createChart(t)}patched(){var e,t,s;const i=this.props.figure,o=this.env.getters.getChartRuntime(i.id);o?(o.type!==this.chart.config.type?(this.chart&&this.chart.destroy(),this.createChart(o)):o.data&&o.data.datasets?(this.chart.data=o.data,(null===(e=o.options)||void 0===e?void 0:e.title)&&(this.chart.config.options.title=o.options.title)):this.chart.data.datasets=void 0,this.chart.config.options.legend=null===(t=o.options)||void 0===t?void 0:t.legend,this.chart.config.options.scales=null===(s=o.options)||void 0===s?void 0:s.scales,this.chart.update({duration:0})):this.chart&&this.chart.destroy();const n=this.env.getters.getChartDefinition(i.id);n&&(this.state.background=n.background)}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e);const s=this.env.getters.getChartDefinition(this.props.figure.id);s&&(this.state.background=s.background)}showMenu(e){const t=new Oa;t.add("edit",{name:a("Edit"),sequence:1,action:()=>this.env.openSidePanel("ChartPanel",{figure:this.props.figure}),isVisible:()=>!!this.env.getters.getChartDefinition(this.props.figure.id)}),t.add("delete",{name:a("Delete"),sequence:10,action:()=>{this.env.dispatch("DELETE_FIGURE",{sheetId:this.env.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.sidePanelIsOpen&&this.env.toggleSidePanel("ChartPanel",{figure:this.props.figure}),this.trigger("figure-deleted")}}),t.add("refresh",{name:a("Refresh"),sequence:11,action:()=>{this.env.dispatch("REFRESH_CHART",{id:this.props.figure.id})}}),this.openContextMenu(e.currentTarget,t)}openContextMenu(e,t){const s=e.offsetLeft,i=e.offsetTop;this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position={x:this.position.x+s-y,y:this.position.y+i}}}ng.template=ig,ng.style=og,ng.components={Menu:Zu};const{xml:rg,css:ag}=i.tags,{useState:lg}=i,cg=rg`<div>
1976
+ `;class ag extends t.Component{constructor(){super(...arguments),this.menuState=tg({isOpen:!1,position:null,menuItems:[]}),this.canvas=og("graphContainer"),this.state={background:g},this.position=Fu()}get canvasStyle(){return`background-color: ${this.state.background}`}mounted(){const e=this.props.figure,t=this.env.getters.getChartRuntime(e.id);t&&this.createChart(t)}patched(){var e,t,s;const i=this.props.figure,o=this.env.getters.getChartRuntime(i.id);o?(o.type!==this.chart.config.type?(this.chart&&this.chart.destroy(),this.createChart(o)):o.data&&o.data.datasets?(this.chart.data=o.data,(null===(e=o.options)||void 0===e?void 0:e.title)&&(this.chart.config.options.title=o.options.title)):this.chart.data.datasets=void 0,this.chart.config.options.legend=null===(t=o.options)||void 0===t?void 0:t.legend,this.chart.config.options.scales=null===(s=o.options)||void 0===s?void 0:s.scales,this.chart.update({duration:0})):this.chart&&this.chart.destroy();const n=this.env.getters.getChartDefinition(i.id);n&&(this.state.background=n.background)}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e);const s=this.env.getters.getChartDefinition(this.props.figure.id);s&&(this.state.background=s.background)}showMenu(e){const t=new ka;t.add("edit",{name:a("Edit"),sequence:1,action:()=>this.env.openSidePanel("ChartPanel",{figure:this.props.figure}),isVisible:()=>!!this.env.getters.getChartDefinition(this.props.figure.id)}),t.add("delete",{name:a("Delete"),sequence:10,action:()=>{this.env.dispatch("DELETE_FIGURE",{sheetId:this.env.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.sidePanelIsOpen&&this.env.toggleSidePanel("ChartPanel",{figure:this.props.figure}),this.trigger("figure-deleted")}}),t.add("refresh",{name:a("Refresh"),sequence:11,action:()=>{this.env.dispatch("REFRESH_CHART",{id:this.props.figure.id})}}),this.openContextMenu(e.currentTarget,t)}openContextMenu(e,t){const s=e.offsetLeft,i=e.offsetTop;this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position={x:this.position.x+s-y,y:this.position.y+i}}}ag.template=ng,ag.style=rg,ag.components={Menu:Wu};const{xml:lg,css:cg}=i.tags,{useState:hg}=i,dg=lg`<div>
1977
1977
  <t t-foreach="getVisibleFigures()" t-as="info" t-key="info.id">
1978
1978
  <div class="o-figure-wrapper"
1979
1979
  t-att-style="getStyle(info)"
@@ -2003,7 +2003,7 @@
2003
2003
  </div>
2004
2004
  </t>
2005
2005
  </div>
2006
- `,hg=ag`
2006
+ `,ug=cg`
2007
2007
  .o-figure-wrapper {
2008
2008
  overflow: hidden;
2009
2009
  }
@@ -2076,7 +2076,7 @@
2076
2076
  }
2077
2077
  }
2078
2078
  }
2079
- `;class dg extends t.Component{constructor(){super(...arguments),this.figureRegistry=Ra,this.dnd=lg({figureId:"",x:0,y:0,width:0,height:0}),this.getters=this.env.getters,this.dispatch=this.env.dispatch}getVisibleFigures(){const e=this.getters.getSelectedFigureId();return this.getters.getVisibleFigures(this.getters.getActiveSheetId()).map((t=>({id:t.id,isSelected:t.id===e,figure:t})))}getDims(e){const{figure:t,isSelected:s}=e,i=2*(s?2:1),{width:o,height:n}=s&&this.dnd.figureId?this.dnd:t;return`width:${o+i}px;height:${n+i}px`}getStyle(e){const{figure:t,isSelected:s}=e,{offsetX:i,offsetY:o}=this.getters.getActiveSnappedViewport(),n=t.id===(s&&this.dnd.figureId)?this.dnd:t,{width:r,height:a}=n;let l=n.x-i+m-1,c=n.y-o+f-1;const h=Math.max(0,m-l);l+=h;const d=Math.max(0,f-c);if(c+=d,r<0||a<0)return"position:absolute;display:none;";const u=10+(s?2:1);return`position:absolute; top:${c+1}px; left:${l+1}px; width:${r-h+u}px; height:${a-d+u}px`}mounted(){this.render()}resize(e,t,s,i){i.stopPropagation();const o=i.clientX,n=i.clientY;this.dnd.figureId=e.id,this.dnd.x=e.x,this.dnd.y=e.y,this.dnd.width=e.width,this.dnd.height=e.height;Ku((i=>{const r=t*(i.clientX-o),a=s*(i.clientY-n);this.dnd.width=Math.max(e.width+r,80),this.dnd.height=Math.max(e.height+a,80),t<0&&(this.dnd.x=e.x-r),s<0&&(this.dnd.y=e.y-a)}),(i=>{this.dnd.figureId="";const o={x:this.dnd.x,y:this.dnd.y};t&&(o.width=this.dnd.width),s&&(o.height=this.dnd.height),this.dispatch("UPDATE_FIGURE",{sheetId:this.getters.getActiveSheetId(),id:e.id,...o})}))}onMouseDown(e,t){if(t.button>0)return;if(!this.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;this.props.sidePanelIsOpen&&this.env.openSidePanel("ChartPanel",{figure:e});const s=t.clientX,i=t.clientY;this.dnd.figureId=e.id,this.dnd.x=e.x,this.dnd.y=e.y,this.dnd.width=e.width,this.dnd.height=e.height;Ku((t=>{this.dnd.x=Math.max(e.x-s+t.clientX,0),this.dnd.y=Math.max(e.y-i+t.clientY,0)}),(t=>{this.dnd.figureId="",this.dispatch("UPDATE_FIGURE",{sheetId:this.getters.getActiveSheetId(),id:e.id,x:this.dnd.x,y:this.dnd.y})}))}onKeyDown(e,t){switch(t.preventDefault(),t.key){case"Delete":this.dispatch("DELETE_FIGURE",{sheetId:this.getters.getActiveSheetId(),id:e.id}),this.trigger("figure-deleted");break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const s={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[t.key];this.dispatch("UPDATE_FIGURE",{sheetId:this.getters.getActiveSheetId(),id:e.id,x:e.x+s[0],y:e.y+s[1]})}}}dg.template=cg,dg.style=hg,dg.components={},Ra.add("chart",{Component:ng,SidePanelComponent:"ChartPanel"});const{xml:ug,css:pg}=t.tags,gg=ug`
2079
+ `;class pg extends t.Component{constructor(){super(...arguments),this.figureRegistry=Ma,this.dnd=hg({figureId:"",x:0,y:0,width:0,height:0}),this.getters=this.env.getters,this.dispatch=this.env.dispatch}getVisibleFigures(){const e=this.getters.getSelectedFigureId();return this.getters.getVisibleFigures(this.getters.getActiveSheetId()).map((t=>({id:t.id,isSelected:t.id===e,figure:t})))}getDims(e){const{figure:t,isSelected:s}=e,i=2*(s?2:1),{width:o,height:n}=s&&this.dnd.figureId?this.dnd:t;return`width:${o+i}px;height:${n+i}px`}getStyle(e){const{figure:t,isSelected:s}=e,{offsetX:i,offsetY:o}=this.getters.getActiveSnappedViewport(),n=t.id===(s&&this.dnd.figureId)?this.dnd:t,{width:r,height:a}=n;let l=n.x-i+m-1,c=n.y-o+f-1;const h=Math.max(0,m-l);l+=h;const d=Math.max(0,f-c);if(c+=d,r<0||a<0)return"position:absolute;display:none;";const u=10+(s?2:1);return`position:absolute; top:${c+1}px; left:${l+1}px; width:${r-h+u}px; height:${a-d+u}px`}mounted(){this.render()}resize(e,t,s,i){i.stopPropagation();const o=i.clientX,n=i.clientY;this.dnd.figureId=e.id,this.dnd.x=e.x,this.dnd.y=e.y,this.dnd.width=e.width,this.dnd.height=e.height;Ju((i=>{const r=t*(i.clientX-o),a=s*(i.clientY-n);this.dnd.width=Math.max(e.width+r,80),this.dnd.height=Math.max(e.height+a,80),t<0&&(this.dnd.x=e.x-r),s<0&&(this.dnd.y=e.y-a)}),(i=>{this.dnd.figureId="";const o={x:this.dnd.x,y:this.dnd.y};t&&(o.width=this.dnd.width),s&&(o.height=this.dnd.height),this.dispatch("UPDATE_FIGURE",{sheetId:this.getters.getActiveSheetId(),id:e.id,...o})}))}onMouseDown(e,t){if(t.button>0)return;if(!this.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;this.props.sidePanelIsOpen&&this.env.openSidePanel("ChartPanel",{figure:e});const s=t.clientX,i=t.clientY;this.dnd.figureId=e.id,this.dnd.x=e.x,this.dnd.y=e.y,this.dnd.width=e.width,this.dnd.height=e.height;Ju((t=>{this.dnd.x=Math.max(e.x-s+t.clientX,0),this.dnd.y=Math.max(e.y-i+t.clientY,0)}),(t=>{this.dnd.figureId="",this.dispatch("UPDATE_FIGURE",{sheetId:this.getters.getActiveSheetId(),id:e.id,x:this.dnd.x,y:this.dnd.y})}))}onKeyDown(e,t){switch(t.preventDefault(),t.key){case"Delete":this.dispatch("DELETE_FIGURE",{sheetId:this.getters.getActiveSheetId(),id:e.id}),this.trigger("figure-deleted");break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const s={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[t.key];this.dispatch("UPDATE_FIGURE",{sheetId:this.getters.getActiveSheetId(),id:e.id,x:e.x+s[0],y:e.y+s[1]})}}}pg.template=dg,pg.style=ug,pg.components={},Ma.add("chart",{Component:ag,SidePanelComponent:"ChartPanel"});const{xml:gg,css:fg}=t.tags,mg=gg`
2080
2080
  <div class="o-border"
2081
2081
  t-on-mousedown="onMouseDown"
2082
2082
  t-att-style="style"
@@ -2089,7 +2089,7 @@
2089
2089
  }"
2090
2090
  >
2091
2091
  </div>
2092
- `,fg=pg`
2092
+ `,vg=fg`
2093
2093
  .o-border {
2094
2094
  position: absolute;
2095
2095
  &:hover {
@@ -2100,7 +2100,7 @@
2100
2100
  .o-moving {
2101
2101
  cursor: grabbing;
2102
2102
  }
2103
- `;class mg extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),s=["n","s"].includes(this.props.orientation),i=["w","e"].includes(this.props.orientation),o=this.env.getters.getActiveSheet(),n=this.props.zone,r=o.cols[n.left].start+2,a=o.cols[n.right].end-4,l=o.rows[n.top].start+2,c=o.rows[n.bottom].end-4,h=t?r:a,d=e?l:c,u=s?a-r:4,p=i?c-l:4,{offsetX:g,offsetY:v}=this.env.getters.getActiveSnappedViewport();return`\n left:${h+m-g}px;\n top:${d+f-v}px;\n width:${u}px;\n height:${p}px;\n `}onMouseDown(e){this.trigger("move-highlight",{clientX:e.clientX,clientY:e.clientY})}}mg.template=gg,mg.style=fg;const{xml:vg,css:Eg}=t.tags,Sg=vg`
2103
+ `;class Eg extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),s=["n","s"].includes(this.props.orientation),i=["w","e"].includes(this.props.orientation),o=this.env.getters.getActiveSheet(),n=this.props.zone,r=o.cols[n.left].start+2,a=o.cols[n.right].end-4,l=o.rows[n.top].start+2,c=o.rows[n.bottom].end-4,h=t?r:a,d=e?l:c,u=s?a-r:4,p=i?c-l:4,{offsetX:g,offsetY:v}=this.env.getters.getActiveSnappedViewport();return`\n left:${h+m-g}px;\n top:${d+f-v}px;\n width:${u}px;\n height:${p}px;\n `}onMouseDown(e){this.trigger("move-highlight",{clientX:e.clientX,clientY:e.clientY})}}Eg.template=mg,Eg.style=vg;const{xml:bg,css:Sg}=t.tags,Cg=bg`
2104
2104
  <div class="o-corner"
2105
2105
  t-on-mousedown="onMouseDown"
2106
2106
  t-att-style="style"
@@ -2113,7 +2113,7 @@
2113
2113
  }"
2114
2114
  >
2115
2115
  </div>
2116
- `,bg=Eg`
2116
+ `,Ig=Sg`
2117
2117
  .o-corner {
2118
2118
  position: absolute;
2119
2119
  height: 6px;
@@ -2135,7 +2135,7 @@
2135
2135
  .o-resizing {
2136
2136
  cursor: grabbing;
2137
2137
  }
2138
- `;class Cg extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const{offsetX:e,offsetY:t}=this.env.getters.getActiveSnappedViewport(),s=this.env.getters.getActiveSheet(),i=this.props.zone,o=this.isLeft?s.cols[i.left].start:s.cols[i.right].end,n=this.isTop?s.rows[i.top].start:s.rows[i.bottom].end;return`\n left:${o+m-e-4}px;\n top:${n+f-t-4}px;\n background-color:${this.props.color};\n `}onMouseDown(e){this.trigger("resize-highlight",{isLeft:this.isLeft,isTop:this.isTop})}}Cg.template=Sg,Cg.style=bg;const{xml:Ig}=t.tags,yg=Ig`
2138
+ `;class yg extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const{offsetX:e,offsetY:t}=this.env.getters.getActiveSnappedViewport(),s=this.env.getters.getActiveSheet(),i=this.props.zone,o=this.isLeft?s.cols[i.left].start:s.cols[i.right].end,n=this.isTop?s.rows[i.top].start:s.rows[i.bottom].end;return`\n left:${o+m-e-4}px;\n top:${n+f-t-4}px;\n background-color:${this.props.color};\n `}onMouseDown(e){this.trigger("resize-highlight",{isLeft:this.isLeft,isTop:this.isTop})}}yg.template=Cg,yg.style=Ig;const{xml:wg}=t.tags,Tg=wg`
2139
2139
  <div class="o-highlight">
2140
2140
  <t t-foreach="['nw', 'ne', 'sw', 'se']" t-as="orientation" t-key="orientation">
2141
2141
  <Corner
@@ -2155,7 +2155,7 @@
2155
2155
  />
2156
2156
  </t>
2157
2157
  </div>
2158
- `;class wg extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e){this.highlightState.shiftingMode="isResizing";const t=this.props.zone,s=e.detail.isLeft?t.right:t.left,i=e.detail.isTop?t.bottom:t.top;let o=e.detail.isLeft?t.left:t.right,n=e.detail.isTop?t.top:t.bottom,r=t;this.env.dispatch("START_CHANGE_HIGHLIGHT",{zone:r});Qu(this.el.parentElement,this.env,((e,t)=>{if(o!==e||n!==t){const a=this.env.getters.getActiveSheet();o=ps(-1===e?o:e,0,a.cols.length-1),n=ps(-1===t?n:t,0,a.rows.length-1);let l={left:Math.min(s,o),top:Math.min(i,n),right:Math.max(s,o),bottom:Math.max(i,n)};l=this.env.getters.expandZone(a.id,l),Us(l,r)||(this.env.dispatch("CHANGE_HIGHLIGHT",{zone:l}),r=l)}}),(()=>{this.highlightState.shiftingMode="none",this.env.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e){this.highlightState.shiftingMode="isMoving";const t=this.props.zone,s=this.el.parentElement,i=s.getBoundingClientRect(),o=this.env.getters.getActiveSheet(),{top:n,left:r}=this.env.getters.getActiveSnappedViewport(),a=this.env.getters.getColIndex(e.detail.clientX-i.left,r),l=this.env.getters.getRowIndex(e.detail.clientY-i.top,n),c=-t.left,h=o.cols.length-t.right-1,d=-t.top,u=o.rows.length-t.bottom-1;let p=t;this.env.dispatch("START_CHANGE_HIGHLIGHT",{zone:p});let g=a,f=l;Qu(s,this.env,((e,s)=>{if(g!==e||f!==s){g=-1===e?g:e,f=-1===s?f:s;const i=ps(g-a,c,h),n=ps(f-l,d,u);let r={left:t.left+i,top:t.top+n,right:t.right+i,bottom:t.bottom+n};r=this.env.getters.expandZone(o.id,r),Us(r,p)||(this.env.dispatch("CHANGE_HIGHLIGHT",{zone:r}),p=r)}}),(()=>{this.highlightState.shiftingMode="none",this.env.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}wg.template=yg,wg.components={Corner:Cg,Border:mg};const{xml:Tg,css:xg}=t.tags,Rg=Tg`
2158
+ `;class xg extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e){this.highlightState.shiftingMode="isResizing";const t=this.props.zone,s=e.detail.isLeft?t.right:t.left,i=e.detail.isTop?t.bottom:t.top;let o=e.detail.isLeft?t.left:t.right,n=e.detail.isTop?t.top:t.bottom,r=t;this.env.dispatch("START_CHANGE_HIGHLIGHT",{zone:r});ep(this.el.parentElement,this.env,((e,t)=>{if(o!==e||n!==t){const a=this.env.getters.getActiveSheet();o=ps(-1===e?o:e,0,a.cols.length-1),n=ps(-1===t?n:t,0,a.rows.length-1);let l={left:Math.min(s,o),top:Math.min(i,n),right:Math.max(s,o),bottom:Math.max(i,n)};l=this.env.getters.expandZone(a.id,l),Bs(l,r)||(this.env.dispatch("CHANGE_HIGHLIGHT",{zone:l}),r=l)}}),(()=>{this.highlightState.shiftingMode="none",this.env.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e){this.highlightState.shiftingMode="isMoving";const t=this.props.zone,s=this.el.parentElement,i=s.getBoundingClientRect(),o=this.env.getters.getActiveSheet(),{top:n,left:r}=this.env.getters.getActiveSnappedViewport(),a=this.env.getters.getColIndex(e.detail.clientX-i.left,r),l=this.env.getters.getRowIndex(e.detail.clientY-i.top,n),c=-t.left,h=o.cols.length-t.right-1,d=-t.top,u=o.rows.length-t.bottom-1;let p=t;this.env.dispatch("START_CHANGE_HIGHLIGHT",{zone:p});let g=a,f=l;ep(s,this.env,((e,s)=>{if(g!==e||f!==s){g=-1===e?g:e,f=-1===s?f:s;const i=ps(g-a,c,h),n=ps(f-l,d,u);let r={left:t.left+i,top:t.top+n,right:t.right+i,bottom:t.bottom+n};r=this.env.getters.expandZone(o.id,r),Bs(r,p)||(this.env.dispatch("CHANGE_HIGHLIGHT",{zone:r}),p=r)}}),(()=>{this.highlightState.shiftingMode="none",this.env.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}xg.template=Tg,xg.components={Corner:yg,Border:Eg};const{xml:Rg,css:Lg}=t.tags,Mg=Rg`
2159
2159
  <div class="o-link-tool">
2160
2160
  <t t-set="link" t-value="cell.link"/>
2161
2161
  <a t-if="link.isExternal"
@@ -2172,10 +2172,10 @@
2172
2172
  t-att-title="cell.urlRepresentation">
2173
2173
  <t t-esc="cell.urlRepresentation"/>
2174
2174
  </a>
2175
- <span t-if="!env.getters.isReadonly()" class="o-link-icon o-unlink" t-on-click="unlink" title="${yc}">${'<svg class="o-icon" viewBox="0 0 512 512"><path fill="currentColor" d="M304.083 405.907c4.686 4.686 4.686 12.284 0 16.971l-44.674 44.674c-59.263 59.262-155.693 59.266-214.961 0-59.264-59.265-59.264-155.696 0-214.96l44.675-44.675c4.686-4.686 12.284-4.686 16.971 0l39.598 39.598c4.686 4.686 4.686 12.284 0 16.971l-44.675 44.674c-28.072 28.073-28.072 73.75 0 101.823 28.072 28.072 73.75 28.073 101.824 0l44.674-44.674c4.686-4.686 12.284-4.686 16.971 0l39.597 39.598zm-56.568-260.216c4.686 4.686 12.284 4.686 16.971 0l44.674-44.674c28.072-28.075 73.75-28.073 101.824 0 28.072 28.073 28.072 73.75 0 101.823l-44.675 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.598 39.598c4.686 4.686 12.284 4.686 16.971 0l44.675-44.675c59.265-59.265 59.265-155.695 0-214.96-59.266-59.264-155.695-59.264-214.961 0l-44.674 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.597 39.598zm234.828 359.28l22.627-22.627c9.373-9.373 9.373-24.569 0-33.941L63.598 7.029c-9.373-9.373-24.569-9.373-33.941 0L7.029 29.657c-9.373 9.373-9.373 24.569 0 33.941l441.373 441.373c9.373 9.372 24.569 9.372 33.941 0z"></path></svg>'}</span>
2176
- <span t-if="!env.getters.isReadonly()" class="o-link-icon o-edit-link" t-on-click="edit" title="${Ic}">${'<svg class="o-icon" viewBox="0 0 576 512"><path fill="currentColor" d="M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z"></path></svg>'}</span>
2175
+ <span t-if="!env.getters.isReadonly()" class="o-link-icon o-unlink" t-on-click="unlink" title="${Tc}">${'<svg class="o-icon" viewBox="0 0 512 512"><path fill="currentColor" d="M304.083 405.907c4.686 4.686 4.686 12.284 0 16.971l-44.674 44.674c-59.263 59.262-155.693 59.266-214.961 0-59.264-59.265-59.264-155.696 0-214.96l44.675-44.675c4.686-4.686 12.284-4.686 16.971 0l39.598 39.598c4.686 4.686 4.686 12.284 0 16.971l-44.675 44.674c-28.072 28.073-28.072 73.75 0 101.823 28.072 28.072 73.75 28.073 101.824 0l44.674-44.674c4.686-4.686 12.284-4.686 16.971 0l39.597 39.598zm-56.568-260.216c4.686 4.686 12.284 4.686 16.971 0l44.674-44.674c28.072-28.075 73.75-28.073 101.824 0 28.072 28.073 28.072 73.75 0 101.823l-44.675 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.598 39.598c4.686 4.686 12.284 4.686 16.971 0l44.675-44.675c59.265-59.265 59.265-155.695 0-214.96-59.266-59.264-155.695-59.264-214.961 0l-44.674 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.597 39.598zm234.828 359.28l22.627-22.627c9.373-9.373 9.373-24.569 0-33.941L63.598 7.029c-9.373-9.373-24.569-9.373-33.941 0L7.029 29.657c-9.373 9.373-9.373 24.569 0 33.941l441.373 441.373c9.373 9.372 24.569 9.372 33.941 0z"></path></svg>'}</span>
2176
+ <span t-if="!env.getters.isReadonly()" class="o-link-icon o-edit-link" t-on-click="edit" title="${wc}">${'<svg class="o-icon" viewBox="0 0 576 512"><path fill="currentColor" d="M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z"></path></svg>'}</span>
2177
2177
  </div>
2178
- `,Lg=xg`
2178
+ `,Ag=Lg`
2179
2179
  .o-link-tool {
2180
2180
  font-size: 13px;
2181
2181
  background-color: white;
@@ -2212,15 +2212,15 @@
2212
2212
  cursor: pointer;
2213
2213
  color: #000;
2214
2214
  }
2215
- `;class Mg extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters}get cell(){const{col:e,row:t}=this.props.cellPosition,s=this.getters.getActiveSheetId(),i=this.getters.getCell(s,e,t);if(null==i?void 0:i.isLink())return i;throw new Error(`LinkDisplay Component can only be used with link cells. ${is(e,t)} is not a link.`)}openLink(){this.cell.action(this.env)}edit(){this.env.openLinkEditor()}unlink(){const e=this.getters.getActiveSheetId(),[t,s]=this.getters.getPosition(),[i,o]=this.getters.getMainCell(e,t,s),n=this.cell.style,r=(null==n?void 0:n.textColor)===M||null==n?void 0:n.textColor;this.env.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:e,content:this.cell.link.label,style:{...n,textColor:r,underline:void 0}})}}Mg.template=Rg,Mg.components={Menu:Zu},Mg.style=Lg;const{xml:Ag,css:_g}=t.tags,{useRef:Og}=t.hooks,Ng=Ag`
2215
+ `;class _g extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters}get cell(){const{col:e,row:t}=this.props.cellPosition,s=this.getters.getActiveSheetId(),i=this.getters.getCell(s,e,t);if(null==i?void 0:i.isLink())return i;throw new Error(`LinkDisplay Component can only be used with link cells. ${is(e,t)} is not a link.`)}openLink(){this.cell.action(this.env)}edit(){this.env.openLinkEditor()}unlink(){const e=this.getters.getActiveSheetId(),[t,s]=this.getters.getPosition(),[i,o]=this.getters.getMainCell(e,t,s),n=this.cell.style,r=(null==n?void 0:n.textColor)===M||null==n?void 0:n.textColor;this.env.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:e,content:this.cell.link.label,style:{...n,textColor:r,underline:void 0}})}}_g.template=Mg,_g.components={Menu:Wu},_g.style=Ag;const{xml:Og,css:Ng}=t.tags,{useRef:kg}=t.hooks,Fg=Og`
2216
2216
  <div class="o-link-editor" t-on-click.stop="menu.isOpen=false" t-on-keydown.stop="onKeyDown">
2217
2217
  <div class="o-section">
2218
- <div t-esc="env._t('${Ec}')" class="o-section-title"/>
2218
+ <div t-esc="env._t('${Sc}')" class="o-section-title"/>
2219
2219
  <div class="d-flex">
2220
2220
  <input type="text" class="o-input flex-grow-1" t-model="state.link.label"></input>
2221
2221
  </div>
2222
2222
 
2223
- <div t-esc="env._t('${Sc}')" class="o-section-title mt-3"/>
2223
+ <div t-esc="env._t('${Cc}')" class="o-section-title mt-3"/>
2224
2224
  <div class="o-link-url">
2225
2225
  <t t-if="state.isUrlEditable">
2226
2226
  <input type="text" t-ref="urlInput" t-model="state.link.url"></input>
@@ -2229,7 +2229,7 @@
2229
2229
  <input type="text" t-att-value="state.urlRepresentation" disabled="1"></input>
2230
2230
  </t>
2231
2231
  <button t-if="state.link.url" t-on-click="removeLink" class="o-remove-url">✖</button>
2232
- <button t-if="!state.link.url" t-on-click.stop="openMenu" class="o-special-link">${Ml}</button>
2232
+ <button t-if="!state.link.url" t-on-click.stop="openMenu" class="o-special-link">${_l}</button>
2233
2233
  </div>
2234
2234
  </div>
2235
2235
  <Menu
@@ -2239,10 +2239,10 @@
2239
2239
  t-on-menu-clicked="onSpecialLink"
2240
2240
  t-on-close.stop="menu.isOpen=false"/>
2241
2241
  <div class="o-buttons">
2242
- <button t-on-click="cancel" class="o-button o-cancel" t-esc="env._t('${Cc}')"></button>
2243
- <button t-on-click="save" class="o-button o-save" t-esc="env._t('${bc}')" t-att-disabled="!state.link.url" ></button>
2242
+ <button t-on-click="cancel" class="o-button o-cancel" t-esc="env._t('${yc}')"></button>
2243
+ <button t-on-click="save" class="o-button o-save" t-esc="env._t('${Ic}')" t-att-disabled="!state.link.url" ></button>
2244
2244
  </div>
2245
- </div>`,kg=_g`
2245
+ </div>`,$g=Ng`
2246
2246
  .o-link-editor {
2247
2247
  font-size: 13px;
2248
2248
  background-color: white;
@@ -2312,7 +2312,7 @@
2312
2312
  }
2313
2313
  }
2314
2314
  }
2315
- `;class Fg extends t.Component{constructor(){super(...arguments),this.menuItems=ll.getAll(),this.getters=this.env.getters,this.state=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.position=Nu(),this.urlInput=Og("urlInput")}mounted(){var e;null===(e=this.urlInput.el)||void 0===e||e.focus()}get defaultState(){const{col:e,row:t}=this.props.cellPosition,s=this.getters.getActiveSheetId(),i=this.getters.getCell(s,e,t);return(null==i?void 0:i.isLink())?{link:{url:i.link.url,label:i.formattedValue},urlRepresentation:i.urlRepresentation,isUrlEditable:i.isUrlEditable}:{link:{url:"",label:(null==i?void 0:i.formattedValue)||""},isUrlEditable:!0,urlRepresentation:""}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e;this.state.link.url=t.link.url,this.state.link.label=t.link.label,this.state.isUrlEditable=t.isUrlEditable,this.state.urlRepresentation=t.urlRepresentation}openMenu(){this.menu.isOpen=!0}removeLink(){this.state.link.url="",this.state.urlRepresentation="",this.state.isUrlEditable=!0}save(){const{col:e,row:t}=this.props.cellPosition,s=this.state.link.label||this.state.link.url;this.env.dispatch("UPDATE_CELL",{col:e,row:t,sheetId:this.getters.getActiveSheetId(),content:ys(s,this.state.link.url)}),this.trigger("link-editor-closed")}cancel(){this.trigger("link-editor-closed")}onKeyDown(e){switch(e.key){case"Enter":this.state.link.url&&this.save();break;case"Escape":this.cancel()}}}Fg.template=Ng,Fg.components={Menu:Zu},Fg.style=kg;const{xml:$g,css:Dg}=t.tags,{useState:Ug}=t.hooks;class Pg extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.getters=this.env.getters,this.dispatch=this.env.dispatch,this.state=Ug({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),s=this._getElementIndex(t);if(s<0)return;const i=this._getElement(s),o=this._getStateOffset();t-(i.start-o)<this.PADDING&&s!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start-o-this._getHeaderSize(),this.state.activeElement=this._getPreviousVisibleElement(s)):i.end-o-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end-o-this._getHeaderSize(),this.state.activeElement=s):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),s=this._getActiveElements(),i=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();s.has(i)&&i<=t&&t<=o?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),s=this.state.draggerLinePosition,i=this._getElement(this.state.activeElement).size,o=s-i+this.MIN_ELEMENT_SIZE,n=this._getMaxSize();Ku((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=s+this.state.delta,this.state.draggerLinePosition<o&&(this.state.draggerLinePosition=o,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>n&&(this.state.draggerLinePosition=n,this.state.delta=n-s)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?this.startSelection(e,t):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getElement(this._getSelectedZoneStart()),s=this._getElement(this._getSelectedZoneEnd()),i=this._getClientPosition(e),o=t.start-this._getStateOffset()-this._getHeaderSize();this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=s.end-t.start;this.dragOverlayBeyondTheViewport(e,((e,s)=>{if(e>=0){const n=this._getElement(e),r=this._getStateOffset()+this._getHeaderSize();e<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=n.start-r,this.state.base=e):this._getSelectedZoneEnd()<e?(this.state.draggerLinePosition=n.end-r,this.state.base=e+1):(this.state.draggerLinePosition=t.start-r,this.state.base=this._getSelectedZoneStart());const a=this._getClientPosition(s)-i;this.state.draggerShadowPosition=Math.max(o+a,0)}}),(e=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,this.dispatch(e.ctrlKey?"START_SELECTION_EXPANSION":"START_SELECTION"),e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;this.dragOverlayBeyondTheViewport(e,((e,t)=>{e!==this.lastSelectedElementIndex&&-1!==e&&(this._increaseSelection(e),this.lastSelectedElementIndex=e)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.dispatch(e.ctrlKey?"PREPARE_SELECTION_EXPANSION":"STOP_SELECTION"),this._computeGrabDisplay(e)}))}dragOverlayBeyondTheViewport(e,t,s){let i,o=null;const n=this._getClientPosition(e),r=this._getEvOffset(e),a=e=>{if(i=e,o)return;const s=this._getClientPosition(i)-n+r,l=this._getEdgeScroll(s),{first:c,last:h}=this._getBoundaries();let d;d=l.canEdgeScroll?l.direction>0?h:c-1:this._getElementIndex(s),t(d,i),l.canEdgeScroll&&(this._adjustViewport(l.direction),o=setTimeout((()=>{o=null,a(i)}),Math.round(l.delay)))};Ku(a,(e=>{clearTimeout(o),s(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const s=this._getType(),{x:i,y:o}=this._getXY(e);this.trigger("open-contextmenu",{type:s,x:i,y:o})}}class Bg extends Pg{constructor(){super(...arguments),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX+m}_getStateOffset(){return this.getters.getActiveSnappedViewport().offsetX-m}_getViewportOffset(){return this.getters.getActiveSnappedViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.getters.getColIndex(e,this.getters.getActiveSnappedViewport().left)}_getSelectedZoneStart(){return this.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.getters.getSelectedZone().right}_getEdgeScroll(e){return this.getters.getEdgeScrollCol(e)}_getBoundaries(){const{left:e,right:t}=this.getters.getActiveSnappedViewport();return{first:e,last:t}}_getElement(e){return this.getters.getCol(this.getters.getActiveSheetId(),e)}_getBottomRightValue(e){return e.end}_getHeaderSize(){return m}_getMaxSize(){return this.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElement(e).size,s=this.getters.getActiveCols();this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.getters.getActiveSheetId(),elements:s.has(e)?[...s]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();for(let i=t;i<=s;i++)e.push(i);this.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e})}_selectElement(e,t){this.dispatch("SELECT_COLUMN",{index:e,createRange:t})}_increaseSelection(e){this.dispatch("SELECT_COLUMN",{index:e,updateRange:!0})}_adjustViewport(e){const{left:t,offsetY:s}=this.getters.getActiveSnappedViewport(),{cols:i}=this.getters.getActiveSheet(),o=i[t+e].start;this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o,offsetY:s})}_fitElementSize(e){const t=this.getters.getActiveCols();this.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.getters.getActiveCols()}_getXY(e){return{x:e.offsetX+m,y:e.offsetY}}_getPreviousVisibleElement(e){return e-1-this.getters.getActiveSheet().cols.slice(0,e).reverse().findIndex((e=>!e.isHidden))}unhide(e){this.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){const t=this.getters.getCol(this.getters.getActiveSheetId(),e),s=this._getStateOffset();return t.start-s-this._getHeaderSize()}}Bg.template=$g`
2315
+ `;class Dg extends t.Component{constructor(){super(...arguments),this.menuItems=hl.getAll(),this.getters=this.env.getters,this.state=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.position=Fu(),this.urlInput=kg("urlInput")}mounted(){var e;null===(e=this.urlInput.el)||void 0===e||e.focus()}get defaultState(){const{col:e,row:t}=this.props.cellPosition,s=this.getters.getActiveSheetId(),i=this.getters.getCell(s,e,t);return(null==i?void 0:i.isLink())?{link:{url:i.link.url,label:i.formattedValue},urlRepresentation:i.urlRepresentation,isUrlEditable:i.isUrlEditable}:{link:{url:"",label:(null==i?void 0:i.formattedValue)||""},isUrlEditable:!0,urlRepresentation:""}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e;this.state.link.url=t.link.url,this.state.link.label=t.link.label,this.state.isUrlEditable=t.isUrlEditable,this.state.urlRepresentation=t.urlRepresentation}openMenu(){this.menu.isOpen=!0}removeLink(){this.state.link.url="",this.state.urlRepresentation="",this.state.isUrlEditable=!0}save(){const{col:e,row:t}=this.props.cellPosition,s=this.state.link.label||this.state.link.url;this.env.dispatch("UPDATE_CELL",{col:e,row:t,sheetId:this.getters.getActiveSheetId(),content:ys(s,this.state.link.url)}),this.trigger("link-editor-closed")}cancel(){this.trigger("link-editor-closed")}onKeyDown(e){switch(e.key){case"Enter":this.state.link.url&&this.save();break;case"Escape":this.cancel()}}}Dg.template=Fg,Dg.components={Menu:Wu},Dg.style=$g;const{xml:Ug,css:Pg}=t.tags,{useState:Bg}=t.hooks;class Vg extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.getters=this.env.getters,this.dispatch=this.env.dispatch,this.state=Bg({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),s=this._getElementIndex(t);if(s<0)return;const i=this._getElement(s),o=this._getStateOffset();t-(i.start-o)<this.PADDING&&s!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start-o-this._getHeaderSize(),this.state.activeElement=this._getPreviousVisibleElement(s)):i.end-o-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end-o-this._getHeaderSize(),this.state.activeElement=s):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),s=this._getActiveElements(),i=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();s.has(i)&&i<=t&&t<=o?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),s=this.state.draggerLinePosition,i=this._getElement(this.state.activeElement).size,o=s-i+this.MIN_ELEMENT_SIZE,n=this._getMaxSize();Ju((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=s+this.state.delta,this.state.draggerLinePosition<o&&(this.state.draggerLinePosition=o,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>n&&(this.state.draggerLinePosition=n,this.state.delta=n-s)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?this.startSelection(e,t):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getElement(this._getSelectedZoneStart()),s=this._getElement(this._getSelectedZoneEnd()),i=this._getClientPosition(e),o=t.start-this._getStateOffset()-this._getHeaderSize();this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=s.end-t.start;this.dragOverlayBeyondTheViewport(e,((e,s)=>{if(e>=0){const n=this._getElement(e),r=this._getStateOffset()+this._getHeaderSize();e<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=n.start-r,this.state.base=e):this._getSelectedZoneEnd()<e?(this.state.draggerLinePosition=n.end-r,this.state.base=e+1):(this.state.draggerLinePosition=t.start-r,this.state.base=this._getSelectedZoneStart());const a=this._getClientPosition(s)-i;this.state.draggerShadowPosition=Math.max(o+a,0)}}),(e=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,this.dispatch(e.ctrlKey?"START_SELECTION_EXPANSION":"START_SELECTION"),e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;this.dragOverlayBeyondTheViewport(e,((e,t)=>{e!==this.lastSelectedElementIndex&&-1!==e&&(this._increaseSelection(e),this.lastSelectedElementIndex=e)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.dispatch(e.ctrlKey?"PREPARE_SELECTION_EXPANSION":"STOP_SELECTION"),this._computeGrabDisplay(e)}))}dragOverlayBeyondTheViewport(e,t,s){let i,o=null;const n=this._getClientPosition(e),r=this._getEvOffset(e),a=e=>{if(i=e,o)return;const s=this._getClientPosition(i)-n+r,l=this._getEdgeScroll(s),{first:c,last:h}=this._getBoundaries();let d;d=l.canEdgeScroll?l.direction>0?h:c-1:this._getElementIndex(s),t(d,i),l.canEdgeScroll&&(this._adjustViewport(l.direction),o=setTimeout((()=>{o=null,a(i)}),Math.round(l.delay)))};Ju(a,(e=>{clearTimeout(o),s(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const s=this._getType(),{x:i,y:o}=this._getXY(e);this.trigger("open-contextmenu",{type:s,x:i,y:o})}}class Hg extends Vg{constructor(){super(...arguments),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX+m}_getStateOffset(){return this.getters.getActiveSnappedViewport().offsetX-m}_getViewportOffset(){return this.getters.getActiveSnappedViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.getters.getColIndex(e,this.getters.getActiveSnappedViewport().left)}_getSelectedZoneStart(){return this.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.getters.getSelectedZone().right}_getEdgeScroll(e){return this.getters.getEdgeScrollCol(e)}_getBoundaries(){const{left:e,right:t}=this.getters.getActiveSnappedViewport();return{first:e,last:t}}_getElement(e){return this.getters.getCol(this.getters.getActiveSheetId(),e)}_getBottomRightValue(e){return e.end}_getHeaderSize(){return m}_getMaxSize(){return this.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElement(e).size,s=this.getters.getActiveCols();this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.getters.getActiveSheetId(),elements:s.has(e)?[...s]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();for(let i=t;i<=s;i++)e.push(i);this.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e})}_selectElement(e,t){this.dispatch("SELECT_COLUMN",{index:e,createRange:t})}_increaseSelection(e){this.dispatch("SELECT_COLUMN",{index:e,updateRange:!0})}_adjustViewport(e){const{left:t,offsetY:s}=this.getters.getActiveSnappedViewport(),{cols:i}=this.getters.getActiveSheet(),o=i[t+e].start;this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o,offsetY:s})}_fitElementSize(e){const t=this.getters.getActiveCols();this.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.getters.getActiveCols()}_getXY(e){return{x:e.offsetX+m,y:e.offsetY}}_getPreviousVisibleElement(e){return e-1-this.getters.getActiveSheet().cols.slice(0,e).reverse().findIndex((e=>!e.isHidden))}unhide(e){this.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){const t=this.getters.getCol(this.getters.getActiveSheetId(),e),s=this._getStateOffset();return t.start-s-this._getHeaderSize()}}Hg.template=Ug`
2316
2316
  <div class="o-col-resizer" t-on-mousemove.self="onMouseMove" t-on-mouseleave="onMouseLeave" t-on-mousedown.self.prevent="select"
2317
2317
  t-on-mouseup.self="onMouseUp" t-on-contextmenu.self="onContextMenu" t-att-class="{'o-grab': state.waitingForMove, 'o-dragging': state.isMoving, }">
2318
2318
  <div t-if="state.isMoving" class="dragging-col-line" t-attf-style="left:{{state.draggerLinePosition}}px;"/>
@@ -2331,11 +2331,11 @@
2331
2331
  </t>
2332
2332
  <t t-if="!hiddenItem.includes(getters.getActiveSheet().cols.length-1)">
2333
2333
  <div class="o-unhide" t-att-data-index="hiddenItem_index" t-attf-style="left:{{unhideStyleValue(hiddenItem[0]) + 3}}px;" t-on-click="unhide(hiddenItem)">
2334
- ${Sl}
2334
+ ${Cl}
2335
2335
  </div>
2336
2336
  </t>
2337
2337
  </t>
2338
- </div>`,Bg.style=Dg`
2338
+ </div>`,Hg.style=Pg`
2339
2339
  .o-col-resizer {
2340
2340
  position: absolute;
2341
2341
  top: 0;
@@ -2394,7 +2394,7 @@
2394
2394
  top: calc(${C}px / 2 - ${18}px / 2);
2395
2395
  }
2396
2396
  }
2397
- `;class Vg extends Pg{constructor(){super(...arguments),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY+f}_getStateOffset(){return this.getters.getActiveSnappedViewport().offsetY-f}_getViewportOffset(){return this.getters.getActiveSnappedViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.getters.getRowIndex(e,this.getters.getActiveSnappedViewport().top)}_getSelectedZoneStart(){return this.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.getters.getEdgeScrollRow(e)}_getBoundaries(){const{top:e,bottom:t}=this.getters.getActiveSnappedViewport();return{first:e,last:t}}_getElement(e){return this.getters.getRow(this.getters.getActiveSheetId(),e)}_getHeaderSize(){return f}_getMaxSize(){return this.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElement(e).size,s=this.getters.getActiveRows();this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.getters.getActiveSheetId(),elements:s.has(e)?[...s]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();for(let i=t;i<=s;i++)e.push(i);this.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e})}_selectElement(e,t){this.dispatch("SELECT_ROW",{index:e,createRange:t})}_increaseSelection(e){this.dispatch("SELECT_ROW",{index:e,updateRange:!0})}_adjustViewport(e){const{top:t,offsetX:s}=this.getters.getActiveSnappedViewport(),{rows:i}=this.getters.getActiveSheet(),o=i[t+e].start;this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:s,offsetY:o})}_fitElementSize(e){const t=this.getters.getActiveRows();this.dispatch("AUTORESIZE_ROWS",{sheetId:this.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.getters.getActiveRows()}_getXY(e){return{x:e.offsetX,y:e.offsetY+f}}_getPreviousVisibleElement(e){return e-1-this.getters.getActiveSheet().rows.slice(0,e).reverse().findIndex((e=>!e.isHidden))}unhide(e){this.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){const t=this.getters.getRow(this.getters.getActiveSheetId(),e),s=this._getStateOffset();return t.start-s-this._getHeaderSize()}}Vg.template=$g`
2397
+ `;class zg extends Vg{constructor(){super(...arguments),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY+f}_getStateOffset(){return this.getters.getActiveSnappedViewport().offsetY-f}_getViewportOffset(){return this.getters.getActiveSnappedViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.getters.getRowIndex(e,this.getters.getActiveSnappedViewport().top)}_getSelectedZoneStart(){return this.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.getters.getEdgeScrollRow(e)}_getBoundaries(){const{top:e,bottom:t}=this.getters.getActiveSnappedViewport();return{first:e,last:t}}_getElement(e){return this.getters.getRow(this.getters.getActiveSheetId(),e)}_getHeaderSize(){return f}_getMaxSize(){return this.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElement(e).size,s=this.getters.getActiveRows();this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.getters.getActiveSheetId(),elements:s.has(e)?[...s]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();for(let i=t;i<=s;i++)e.push(i);this.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e})}_selectElement(e,t){this.dispatch("SELECT_ROW",{index:e,createRange:t})}_increaseSelection(e){this.dispatch("SELECT_ROW",{index:e,updateRange:!0})}_adjustViewport(e){const{top:t,offsetX:s}=this.getters.getActiveSnappedViewport(),{rows:i}=this.getters.getActiveSheet(),o=i[t+e].start;this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:s,offsetY:o})}_fitElementSize(e){const t=this.getters.getActiveRows();this.dispatch("AUTORESIZE_ROWS",{sheetId:this.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.getters.getActiveRows()}_getXY(e){return{x:e.offsetX,y:e.offsetY+f}}_getPreviousVisibleElement(e){return e-1-this.getters.getActiveSheet().rows.slice(0,e).reverse().findIndex((e=>!e.isHidden))}unhide(e){this.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){const t=this.getters.getRow(this.getters.getActiveSheetId(),e),s=this._getStateOffset();return t.start-s-this._getHeaderSize()}}zg.template=Ug`
2398
2398
  <div class="o-row-resizer" t-on-mousemove.self="onMouseMove" t-on-mouseleave="onMouseLeave" t-on-mousedown.self.prevent="select"
2399
2399
  t-on-mouseup.self="onMouseUp" t-on-contextmenu.self="onContextMenu" t-att-class="{'o-grab': state.waitingForMove, 'o-dragging': state.isMoving}">
2400
2400
  <div t-if="state.isMoving" class="dragging-row-line" t-attf-style="top:{{state.draggerLinePosition}}px;"/>
@@ -2413,11 +2413,11 @@
2413
2413
  </t>
2414
2414
  <t t-if="!hiddenItem.includes(getters.getActiveSheet().rows.length-1)">
2415
2415
  <div class="o-unhide" t-att-data-index="hiddenItem_index" t-attf-style="top:{{unhideStyleValue(hiddenItem[0]) + 3}}px;" t-on-click="unhide(hiddenItem)">
2416
- ${El}
2416
+ ${Sl}
2417
2417
  </div>
2418
2418
  </t>
2419
2419
  </t>
2420
- </div>`,Vg.style=Dg`
2420
+ </div>`,zg.style=Pg`
2421
2421
  .o-row-resizer {
2422
2422
  position: absolute;
2423
2423
  top: ${f}px;
@@ -2478,12 +2478,12 @@
2478
2478
  background-color: lightgrey;
2479
2479
  }
2480
2480
  }
2481
- `;class Hg extends t.Component{selectAll(){this.env.dispatch("SELECT_ALL")}}Hg.template=$g`
2481
+ `;class Zg extends t.Component{selectAll(){this.env.dispatch("SELECT_ALL")}}Zg.template=Ug`
2482
2482
  <div class="o-overlay">
2483
2483
  <ColResizer />
2484
2484
  <RowResizer />
2485
2485
  <div class="all" t-on-mousedown.self="selectAll"/>
2486
- </div>`,Hg.style=Dg`
2486
+ </div>`,Zg.style=Pg`
2487
2487
  .o-overlay {
2488
2488
  .all {
2489
2489
  position: absolute;
@@ -2494,7 +2494,7 @@
2494
2494
  height: ${f}px;
2495
2495
  }
2496
2496
  }
2497
- `,Hg.components={ColResizer:Bg,RowResizer:Vg};class zg{constructor(e,t){this.el=e,this.direction=t}get scroll(){return"horizontal"===this.direction?this.el.scrollLeft:this.el.scrollTop}set scroll(e){"horizontal"===this.direction?this.el.scrollLeft=e:this.el.scrollTop=e}}const{xml:Zg,css:Gg}=t.tags,{useRef:Wg,onMounted:qg,onWillUnmount:jg,useState:Yg}=t.hooks,Xg={ROW:cl,COL:al,CELL:rl};function Kg(e,t){const s=Yg({}),{browser:i,getters:o}=e,{Date:n,setInterval:r,clearInterval:a}=i,l=Wg("canvas");let c,h=0,d=0,u=0;function p(){const[e,i]=function(){const e=t();return[o.getColIndex(h,e.left),o.getRowIndex(d,e.top)]}(),r=n.now()-u;if(e===s.col&&i===s.row||(s.col=void 0,s.row=void 0),400<r&&r<600){if(e<0||i<0)return;s.col=e,s.row=i}}function g(e){h=e.offsetX,d=e.offsetY,u=n.now()}return qg((()=>{l.el.addEventListener("mousemove",g),c=r(p,200)})),jg((()=>{l.el.removeEventListener("mousemove",g),a(c)})),s}const Qg=Zg`
2497
+ `,Zg.components={ColResizer:Hg,RowResizer:zg};class Gg{constructor(e,t){this.el=e,this.direction=t}get scroll(){return"horizontal"===this.direction?this.el.scrollLeft:this.el.scrollTop}set scroll(e){"horizontal"===this.direction?this.el.scrollLeft=e:this.el.scrollTop=e}}const{xml:Wg,css:qg}=t.tags,{useRef:jg,onMounted:Yg,onWillUnmount:Xg,useState:Kg}=t.hooks,Qg={ROW:dl,COL:cl,CELL:ll};function Jg(e,t){const s=Kg({}),{browser:i,getters:o}=e,{Date:n,setInterval:r,clearInterval:a}=i,l=jg("canvas");let c,h=0,d=0,u=0;function p(){const[e,i]=function(){const e=t();return[o.getColIndex(h,e.left),o.getRowIndex(d,e.top)]}(),r=n.now()-u;if(e===s.col&&i===s.row||(s.col=void 0,s.row=void 0),400<r&&r<600){if(e<0||i<0)return;s.col=e,s.row=i}}function g(e){h=e.offsetX,d=e.offsetY,u=n.now()}return Yg((()=>{l.el.addEventListener("mousemove",g),c=r(p,200)})),Xg((()=>{l.el.removeEventListener("mousemove",g),a(c)})),s}const ef=Wg`
2498
2498
  <div class="o-grid" t-on-click="focus" t-on-keydown="onKeydown" t-on-wheel="onMouseWheel">
2499
2499
  <t t-if="getters.getEditionMode() !== 'inactive'">
2500
2500
  <GridComposer
@@ -2572,7 +2572,7 @@
2572
2572
  <div class="o-scrollbar horizontal" t-on-scroll="onScroll" t-ref="hscrollbar">
2573
2573
  <div t-attf-style="height:1px;width:{{gridSize.width}}px"/>
2574
2574
  </div>
2575
- </div>`,Jg=Gg`
2575
+ </div>`,tf=qg`
2576
2576
  .o-grid {
2577
2577
  position: relative;
2578
2578
  overflow: hidden;
@@ -2593,20 +2593,20 @@
2593
2593
  &.vertical {
2594
2594
  right: 0;
2595
2595
  top: ${f}px;
2596
- bottom: ${b}px;
2597
- width: ${b}px;
2596
+ bottom: ${S}px;
2597
+ width: ${S}px;
2598
2598
  overflow-x: hidden;
2599
2599
  }
2600
2600
  &.horizontal {
2601
2601
  bottom: 0;
2602
- height: ${b}px;
2602
+ height: ${S}px;
2603
2603
  right: ${16}px;
2604
2604
  left: ${m}px;
2605
2605
  overflow-y: hidden;
2606
2606
  }
2607
2607
  }
2608
2608
  }
2609
- `;class ef extends t.Component{constructor(){super(...arguments),this.menuState=Yg({isOpen:!1,position:null,menuItems:[]}),this.vScrollbarRef=Wg("vscrollbar"),this.hScrollbarRef=Wg("hscrollbar"),this.canvas=Wg("canvas"),this.hiddenInput=Wg("hiddenInput"),this.getters=this.env.getters,this.dispatch=this.env.dispatch,this.currentSheet=this.getters.getActiveSheetId(),this.clickedCol=0,this.clickedRow=0,this.hoveredCell=Kg(this.env,(()=>this.getters.getActiveSnappedViewport())),this.keyDownMapping={ENTER:()=>{const e=this.getters.getActiveCell();!e||e.isEmpty()?this.trigger("composer-cell-focused"):this.trigger("composer-content-focused")},TAB:()=>this.dispatch("MOVE_POSITION",{deltaX:1,deltaY:0}),"SHIFT+TAB":()=>this.dispatch("MOVE_POSITION",{deltaX:-1,deltaY:0}),F2:()=>{const e=this.getters.getActiveCell();!e||e.isEmpty()?this.trigger("composer-cell-focused"):this.trigger("composer-content-focused")},DELETE:()=>{this.dispatch("DELETE_CONTENT",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones()})},"CTRL+A":()=>this.dispatch("SELECT_ALL"),"CTRL+S":()=>{this.trigger("save-requested")},"CTRL+Z":()=>this.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.dispatch("SET_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),style:{bold:!this.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.dispatch("SET_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),style:{italic:!this.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.dispatch("SET_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),style:{underline:!this.getters.getCurrentStyle().underline}}),"ALT+=":()=>{var e;const t=this.getters.getActiveSheetId(),s=this.getters.getSelectedZone(),i=this.getters.getAutomaticSums(t,s,this.getters.getPosition());if(this.getters.isSingleCellOrMerge(t,s)||this.getters.isEmpty(t,s)&&i.length<=1){const s=(null===(e=i[0])||void 0===e?void 0:e.zone)?this.getters.zoneToXC(t,i[0].zone):"",o=`=SUM(${s})`;this.trigger("composer-cell-focused",{content:o,selection:{start:5,end:5+s.length}})}else this.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.getters.getActiveSheet(),[t,s]=ii(e,0,0);this.dispatch("SELECT_CELL",{col:t,row:s})},"CTRL+END":()=>{const e=this.getters.getActiveSheet(),t=oi(e,"cols",fs(0,e.cols.length).reverse()),s=oi(e,"rows",fs(0,e.rows.length).reverse());this.dispatch("SELECT_CELL",{col:t,row:s})},"SHIFT+ ":()=>{const{cols:e}=this.getters.getActiveSheet(),t={...this.getters.getSelectedZone(),left:0,right:e.length-1};this.dispatch("SET_SELECTION",{anchor:this.getters.getPosition(),zones:[t],anchorZone:t})},"CTRL+ ":()=>{const{rows:e}=this.getters.getActiveSheet(),t={...this.getters.getSelectedZone(),top:0,bottom:e.length-1};this.dispatch("SET_SELECTION",{anchor:this.getters.getPosition(),zones:[t],anchorZone:t})},"CTRL+SHIFT+ ":()=>{this.dispatch("SELECT_ALL")},"SHIFT+PAGEDOWN":()=>{this.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.dispatch("ACTIVATE_PREVIOUS_SHEET")}},this.vScrollbar=new zg(this.vScrollbarRef.el,"vertical"),this.hScrollbar=new zg(this.hScrollbarRef.el,"horizontal"),function(e,t){const s=Wg("canvas");let i=null,o=null;function n(e){1===e.touches.length&&(i=e.touches[0].clientX,o=e.touches[0].clientY)}function r(){i=null,o=null}function a(s){if(1!==s.touches.length)return;t()&&(s.preventDefault(),s.stopPropagation());const n=s.touches[0].clientX,r=s.touches[0].clientY;e(i-n,o-r),i=n,o=r}qg((()=>{s.el.addEventListener("touchstart",n),s.el.addEventListener("touchend",r),s.el.addEventListener("touchmove",a)})),jg((()=>{s.el.removeEventListener("touchstart",n),s.el.removeEventListener("touchend",r),s.el.removeEventListener("touchmove",a)}))}(this.moveCanvas.bind(this),(()=>this.vScrollbar.scroll>0)),this.props.exposeFocus((()=>this.focus()))}get errorTooltip(){const{col:e,row:t}=this.hoveredCell;if(void 0===e||void 0===t)return{isOpen:!1};const s=this.getters.getActiveSheetId(),[i,o]=this.getters.getMainCell(s,e,t),n=this.getters.getCell(s,i,o);if(n&&n.evaluated.type===ke.error){const s=this.getters.getActiveSnappedViewport(),[i,o,r]=this.getters.getRect({left:e,top:t,right:e,bottom:t},s);return{isOpen:!0,position:{x:i+r,y:o+v},text:n.evaluated.error,cellWidth:r}}return{isOpen:!1}}get activeCellPosition(){const[e,t]=this.getters.getMainCell(this.getters.getActiveSheetId(),...this.getters.getPosition());return{col:e,row:t}}get shouldDisplayLink(){const e=this.getters.getActiveSheetId(),{col:t,row:s}=this.activeCellPosition,i=this.getters.getActiveSnappedViewport(),o=this.getters.getCell(e,t,s);return this.getters.isVisibleInViewport(t,s,i)&&!!o&&o.isLink()&&!this.menuState.isOpen&&!this.props.linkEditorIsOpen&&!this.props.sidePanelIsOpen}get popoverPosition(){const[e,t]=this.getters.getBottomLeftCell(this.getters.getActiveSheetId(),...this.getters.getPosition()),s=this.getters.getActiveSnappedViewport(),[i,o,n,r]=this.getters.getRect({left:e,top:t,right:e,bottom:t},s);return{position:{x:i,y:o+r+v},cellWidth:n,cellHeight:r}}mounted(){this.vScrollbar.el=this.vScrollbarRef.el,this.hScrollbar.el=this.hScrollbarRef.el,this.focus(),this.resizeGrid(),this.drawGrid()}patched(){this.resizeGrid(),this.drawGrid()}focus(){this.getters.isSelectingForComposer()||this.getters.getSelectedFigureId()||this.hiddenInput.el.focus()}resizeGrid(){const e=this.el.clientHeight-b,t=this.el.clientWidth-b,{height:s,width:i}=this.getters.getViewportDimension();e==s&&t===i||this.dispatch("RESIZE_VIEWPORT",{height:e,width:t})}onScroll(){const{offsetX:e,offsetY:t}=this.getters.getActiveViewport();if(e!==this.hScrollbar.scroll||t!==this.vScrollbar.scroll){const{maxOffsetX:e,maxOffsetY:t}=this.getters.getMaximumViewportOffset(this.getters.getActiveSheet());this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:Math.min(this.hScrollbar.scroll,e),offsetY:Math.min(this.vScrollbar.scroll,t)})}}checkSheetChanges(){const e=this.getters.getActiveSheetId();e!==this.currentSheet&&(this.focus(),this.currentSheet=e)}getAutofillPosition(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheet(),{offsetX:s,offsetY:i}=this.getters.getActiveSnappedViewport();return{left:t.cols[e.right].end-4+m-s,top:t.rows[e.bottom].end-4+f-i}}drawGrid(){const{offsetX:e,offsetY:t}=this.getters.getActiveViewport();this.hScrollbar.scroll=e,this.vScrollbar.scroll=t,this.checkSheetChanges();const s=this.canvas.el,i=window.devicePixelRatio||1,o=s.getContext("2d",{alpha:!1}),n=.4*i,r={ctx:o,viewport:this.getters.getActiveViewport(),dpr:i,thinLineWidth:n},{width:a,height:l}=this.getters.getViewportDimension();s.style.width=`${a}px`,s.style.height=`${l}px`,s.width=a*i,s.height=l*i,s.setAttribute("style",`width:${a}px;height:${l}px;`),o.translate(-.5,-.5),o.scale(i,i),this.props.model.drawGrid(r)}moveCanvas(e,t){this.vScrollbar.scroll=this.vScrollbar.scroll+t,this.hScrollbar.scroll=this.hScrollbar.scroll+e,this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:this.hScrollbar.scroll,offsetY:this.vScrollbar.scroll})}getClientPositionKey(e){var t,s,i;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(s=e.position)||void 0===s?void 0:s.col}-${null===(i=e.position)||void 0===i?void 0:i.row}`}onMouseWheel(e){if(e.ctrlKey)return;function t(t){return t*(0===e.deltaMode?1:S)}const s=e.shiftKey?e.deltaY:e.deltaX,i=e.shiftKey?e.deltaX:e.deltaY;this.moveCanvas(t(s),t(i))}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getCoordinates(e){const t=this.el.getBoundingClientRect();return[e.pageX-t.left,e.pageY-t.top]}getCartesianCoordinates(e){const[t,s]=this.getCoordinates(e),{left:i,top:o}=this.getters.getActiveSnappedViewport();return[this.getters.getColIndex(t,i),this.getters.getRowIndex(s,o)]}onMouseDown(e){if(e.button>0)return;const[t,s]=this.getCartesianCoordinates(e);if(t<0||s<0)return;this.clickedCol=t,this.clickedRow=s;const i=this.getters.getActiveSheetId(),[o,n]=this.getters.getMainCell(i,t,s),r=this.getters.getCell(i,o,n);(null==r?void 0:r.isLink())||this.closeLinkEditor(),this.dispatch(e.ctrlKey?"START_SELECTION_EXPANSION":"START_SELECTION"),e.shiftKey?this.dispatch("ALTER_SELECTION",{cell:[t,s]}):(this.dispatch("SELECT_CELL",{col:t,row:s}),this.checkSheetChanges());let a,l=t,c=s,h=!1,d=null,u=0;const p=this.getters.getActiveSheet(),g=e=>{if(a=e,d)return;const[t,s]=this.getCoordinates(a);h=!1,u=0;const i=this.getters.getEdgeScrollCol(t),o=this.getters.getEdgeScrollRow(s),{left:n,right:r,top:f,bottom:m}=this.getters.getActiveSnappedViewport();let v,E;if(i.canEdgeScroll?v=i.direction>0?r:n-1:(v=this.getters.getColIndex(t,n),v=-1===v?l:v),o.canEdgeScroll?E=o.direction>0?m:f-1:(E=this.getters.getRowIndex(s,f),E=-1===E?c:E),h=i.canEdgeScroll||o.canEdgeScroll,u=Math.min(i.canEdgeScroll?i.delay:os,o.canEdgeScroll?o.delay:os),v===l&&E===c||(l=v,c=E,this.dispatch("ALTER_SELECTION",{cell:[v,E]})),h){const e=p.cols[n+i.direction].start,t=p.rows[f+o.direction].start;this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t}),d=setTimeout((()=>{d=null,g(a)}),Math.round(u))}};Ku(g,(e=>{clearTimeout(d),this.dispatch(e.ctrlKey?"PREPARE_SELECTION_EXPANSION":"STOP_SELECTION"),this.canvas.el.removeEventListener("mousemove",g),this.getters.isPaintingFormat()&&this.dispatch("PASTE",{target:this.getters.getSelectedZones()})}))}onDoubleClick(e){const[t,s]=this.getCartesianCoordinates(e);if(this.clickedCol===t&&this.clickedRow===s){const e=this.getters.getActiveCell();!e||e.isEmpty()?this.trigger("composer-cell-focused"):this.trigger("composer-content-focused")}}closeLinkEditor(){this.trigger("link-editor-closed")}processTabKey(e){e.preventDefault();const t=e.shiftKey?-1:1;this.dispatch("MOVE_POSITION",{deltaX:t,deltaY:0})}processArrows(e){e.preventDefault(),e.stopPropagation(),this.closeLinkEditor();const t={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];if(e.shiftKey){const e=this.getters.getSelectedZone();this.dispatch("ALTER_SELECTION",{delta:t});const s=this.getters.getSelectedZone(),i=this.getters.getActiveSnappedViewport(),o=this.getters.getActiveSheet(),[n,r]=function(e,t,s){let i,o;const{left:n,right:r,top:a,bottom:l}=e,{left:c,right:h,top:d,bottom:u}=t;return i=c!=n?c:h!=r?h:s.left,o=d!=a?d:u!=l?u:s.top,[i,o]}(e,s,i),{left:a,right:l,top:c,bottom:h,offsetX:d,offsetY:u}=i,p=n<a||n>l-1?o.cols[a+t[0]].start:d,g=r<c||r>h-1?o.rows[c+t[1]].start:u;p===d&&g===u||this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:p,offsetY:g})}else this.dispatch("MOVE_POSITION",{deltaX:t[0],deltaY:t[1]});this.getters.isPaintingFormat()&&this.dispatch("PASTE",{target:this.getters.getSelectedZones()})}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.trigger("composer-cell-focused",{content:e.data}))}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let s=this.keyDownMapping[t];return s?(e.preventDefault(),e.stopPropagation(),void s()):void 0}onInputContextMenu(e){e.preventDefault();const t=this.getters.getSelectedZone(),{left:s,top:i}=t;let o="CELL";this.dispatch("STOP_EDITION"),this.getters.getActiveCols().has(s)?o="COL":this.getters.getActiveRows().has(i)&&(o="ROW");const[n,r,a,l]=this.getters.getRect(t,this.getters.getActiveSnappedViewport());this.toggleContextMenu(o,n+a,r+l)}onCanvasContextMenu(e){e.preventDefault();const[t,s]=this.getCartesianCoordinates(e);if(t<0||s<0)return;const i=this.getters.getSelectedZones();let o="CELL";Bs(t,s,i[i.length-1])?this.getters.getActiveCols().has(t)?o="COL":this.getters.getActiveRows().has(s)&&(o="ROW"):(this.dispatch("STOP_EDITION"),this.dispatch("SELECT_CELL",{col:t,row:s})),this.toggleContextMenu(o,e.offsetX,e.offsetY)}onOverlayContextMenu(e){const t=e.detail.type,s=e.detail.x,i=e.detail.y;this.toggleContextMenu(t,s,i)}toggleContextMenu(e,t,s){this.closeLinkEditor(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:s+v},this.menuState.menuItems=Xg[e].getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}ef.template=Qg,ef.style=Jg,ef.components={GridComposer:qp,Overlay:Hg,Menu:Zu,Autofill:op,FiguresContainer:dg,ClientTag:hp,Highlight:wg,ErrorToolTip:Qp,LinkDisplay:Mg,LinkEditor:Fg,Popover:Du};const{xml:tf,css:sf}=t.tags,{useState:of}=t.hooks,nf=tf`
2609
+ `;class sf extends t.Component{constructor(){super(...arguments),this.menuState=Kg({isOpen:!1,position:null,menuItems:[]}),this.vScrollbarRef=jg("vscrollbar"),this.hScrollbarRef=jg("hscrollbar"),this.canvas=jg("canvas"),this.hiddenInput=jg("hiddenInput"),this.getters=this.env.getters,this.dispatch=this.env.dispatch,this.currentSheet=this.getters.getActiveSheetId(),this.clickedCol=0,this.clickedRow=0,this.hoveredCell=Jg(this.env,(()=>this.getters.getActiveSnappedViewport())),this.keyDownMapping={ENTER:()=>{const e=this.getters.getActiveCell();!e||e.isEmpty()?this.trigger("composer-cell-focused"):this.trigger("composer-content-focused")},TAB:()=>this.dispatch("MOVE_POSITION",{deltaX:1,deltaY:0}),"SHIFT+TAB":()=>this.dispatch("MOVE_POSITION",{deltaX:-1,deltaY:0}),F2:()=>{const e=this.getters.getActiveCell();!e||e.isEmpty()?this.trigger("composer-cell-focused"):this.trigger("composer-content-focused")},DELETE:()=>{this.dispatch("DELETE_CONTENT",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones()})},"CTRL+A":()=>this.dispatch("SELECT_ALL"),"CTRL+S":()=>{this.trigger("save-requested")},"CTRL+Z":()=>this.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.dispatch("SET_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),style:{bold:!this.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.dispatch("SET_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),style:{italic:!this.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.dispatch("SET_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),style:{underline:!this.getters.getCurrentStyle().underline}}),"ALT+=":()=>{var e;const t=this.getters.getActiveSheetId(),s=this.getters.getSelectedZone(),i=this.getters.getAutomaticSums(t,s,this.getters.getPosition());if(this.getters.isSingleCellOrMerge(t,s)||this.getters.isEmpty(t,s)&&i.length<=1){const s=(null===(e=i[0])||void 0===e?void 0:e.zone)?this.getters.zoneToXC(t,i[0].zone):"",o=`=SUM(${s})`;this.trigger("composer-cell-focused",{content:o,selection:{start:5,end:5+s.length}})}else this.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.getters.getActiveSheet(),[t,s]=ni(e,0,0);this.dispatch("SELECT_CELL",{col:t,row:s})},"CTRL+END":()=>{const e=this.getters.getActiveSheet(),t=ri(e,"cols",fs(0,e.cols.length).reverse()),s=ri(e,"rows",fs(0,e.rows.length).reverse());this.dispatch("SELECT_CELL",{col:t,row:s})},"SHIFT+ ":()=>{const{cols:e}=this.getters.getActiveSheet(),t={...this.getters.getSelectedZone(),left:0,right:e.length-1};this.dispatch("SET_SELECTION",{anchor:this.getters.getPosition(),zones:[t],anchorZone:t})},"CTRL+ ":()=>{const{rows:e}=this.getters.getActiveSheet(),t={...this.getters.getSelectedZone(),top:0,bottom:e.length-1};this.dispatch("SET_SELECTION",{anchor:this.getters.getPosition(),zones:[t],anchorZone:t})},"CTRL+SHIFT+ ":()=>{this.dispatch("SELECT_ALL")},"SHIFT+PAGEDOWN":()=>{this.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.dispatch("ACTIVATE_PREVIOUS_SHEET")}},this.vScrollbar=new Gg(this.vScrollbarRef.el,"vertical"),this.hScrollbar=new Gg(this.hScrollbarRef.el,"horizontal"),function(e,t){const s=jg("canvas");let i=null,o=null;function n(e){1===e.touches.length&&(i=e.touches[0].clientX,o=e.touches[0].clientY)}function r(){i=null,o=null}function a(s){if(1!==s.touches.length)return;t()&&(s.preventDefault(),s.stopPropagation());const n=s.touches[0].clientX,r=s.touches[0].clientY;e(i-n,o-r),i=n,o=r}Yg((()=>{s.el.addEventListener("touchstart",n),s.el.addEventListener("touchend",r),s.el.addEventListener("touchmove",a)})),Xg((()=>{s.el.removeEventListener("touchstart",n),s.el.removeEventListener("touchend",r),s.el.removeEventListener("touchmove",a)}))}(this.moveCanvas.bind(this),(()=>this.vScrollbar.scroll>0)),this.props.exposeFocus((()=>this.focus()))}get errorTooltip(){const{col:e,row:t}=this.hoveredCell;if(void 0===e||void 0===t)return{isOpen:!1};const s=this.getters.getActiveSheetId(),[i,o]=this.getters.getMainCell(s,e,t),n=this.getters.getCell(s,i,o);if(n&&n.evaluated.type===ke.error){const s=this.getters.getActiveSnappedViewport(),[i,o,r]=this.getters.getRect({left:e,top:t,right:e,bottom:t},s);return{isOpen:!0,position:{x:i+r,y:o+v},text:n.evaluated.error,cellWidth:r}}return{isOpen:!1}}get activeCellPosition(){const[e,t]=this.getters.getMainCell(this.getters.getActiveSheetId(),...this.getters.getPosition());return{col:e,row:t}}get shouldDisplayLink(){const e=this.getters.getActiveSheetId(),{col:t,row:s}=this.activeCellPosition,i=this.getters.getActiveSnappedViewport(),o=this.getters.getCell(e,t,s);return this.getters.isVisibleInViewport(t,s,i)&&!!o&&o.isLink()&&!this.menuState.isOpen&&!this.props.linkEditorIsOpen&&!this.props.sidePanelIsOpen}get popoverPosition(){const[e,t]=this.getters.getBottomLeftCell(this.getters.getActiveSheetId(),...this.getters.getPosition()),s=this.getters.getActiveSnappedViewport(),[i,o,n,r]=this.getters.getRect({left:e,top:t,right:e,bottom:t},s);return{position:{x:i,y:o+r+v},cellWidth:n,cellHeight:r}}mounted(){this.vScrollbar.el=this.vScrollbarRef.el,this.hScrollbar.el=this.hScrollbarRef.el,this.focus(),this.resizeGrid(),this.drawGrid()}patched(){this.resizeGrid(),this.drawGrid()}focus(){this.getters.isSelectingForComposer()||this.getters.getSelectedFigureId()||this.hiddenInput.el.focus()}resizeGrid(){const e=this.el.clientHeight-S,t=this.el.clientWidth-S,{height:s,width:i}=this.getters.getViewportDimension();e==s&&t===i||this.dispatch("RESIZE_VIEWPORT",{height:e,width:t})}onScroll(){const{offsetX:e,offsetY:t}=this.getters.getActiveViewport();if(e!==this.hScrollbar.scroll||t!==this.vScrollbar.scroll){const{maxOffsetX:e,maxOffsetY:t}=this.getters.getMaximumViewportOffset(this.getters.getActiveSheet());this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:Math.min(this.hScrollbar.scroll,e),offsetY:Math.min(this.vScrollbar.scroll,t)})}}checkSheetChanges(){const e=this.getters.getActiveSheetId();e!==this.currentSheet&&(this.focus(),this.currentSheet=e)}getAutofillPosition(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheet(),{offsetX:s,offsetY:i}=this.getters.getActiveSnappedViewport();return{left:t.cols[e.right].end-4+m-s,top:t.rows[e.bottom].end-4+f-i}}drawGrid(){const{offsetX:e,offsetY:t}=this.getters.getActiveViewport();this.hScrollbar.scroll=e,this.vScrollbar.scroll=t,this.checkSheetChanges();const s=this.canvas.el,i=window.devicePixelRatio||1,o=s.getContext("2d",{alpha:!1}),n=.4*i,r={ctx:o,viewport:this.getters.getActiveViewport(),dpr:i,thinLineWidth:n},{width:a,height:l}=this.getters.getViewportDimension();s.style.width=`${a}px`,s.style.height=`${l}px`,s.width=a*i,s.height=l*i,s.setAttribute("style",`width:${a}px;height:${l}px;`),o.translate(-.5,-.5),o.scale(i,i),this.props.model.drawGrid(r)}moveCanvas(e,t){this.vScrollbar.scroll=this.vScrollbar.scroll+t,this.hScrollbar.scroll=this.hScrollbar.scroll+e,this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:this.hScrollbar.scroll,offsetY:this.vScrollbar.scroll})}getClientPositionKey(e){var t,s,i;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(s=e.position)||void 0===s?void 0:s.col}-${null===(i=e.position)||void 0===i?void 0:i.row}`}onMouseWheel(e){if(e.ctrlKey)return;function t(t){return t*(0===e.deltaMode?1:b)}const s=e.shiftKey?e.deltaY:e.deltaX,i=e.shiftKey?e.deltaX:e.deltaY;this.moveCanvas(t(s),t(i))}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getCoordinates(e){const t=this.el.getBoundingClientRect();return[e.pageX-t.left,e.pageY-t.top]}getCartesianCoordinates(e){const[t,s]=this.getCoordinates(e),{left:i,top:o}=this.getters.getActiveSnappedViewport();return[this.getters.getColIndex(t,i),this.getters.getRowIndex(s,o)]}onMouseDown(e){if(e.button>0)return;const[t,s]=this.getCartesianCoordinates(e);if(t<0||s<0)return;this.clickedCol=t,this.clickedRow=s;const i=this.getters.getActiveSheetId(),[o,n]=this.getters.getMainCell(i,t,s),r=this.getters.getCell(i,o,n);(null==r?void 0:r.isLink())||this.closeLinkEditor(),this.dispatch(e.ctrlKey?"START_SELECTION_EXPANSION":"START_SELECTION"),e.shiftKey?this.dispatch("ALTER_SELECTION",{cell:[t,s]}):(this.dispatch("SELECT_CELL",{col:t,row:s}),this.checkSheetChanges());let a,l=t,c=s,h=!1,d=null,u=0;const p=this.getters.getActiveSheet(),g=e=>{if(a=e,d)return;const[t,s]=this.getCoordinates(a);h=!1,u=0;const i=this.getters.getEdgeScrollCol(t),o=this.getters.getEdgeScrollRow(s),{left:n,right:r,top:f,bottom:m}=this.getters.getActiveSnappedViewport();let v,E;if(i.canEdgeScroll?v=i.direction>0?r:n-1:(v=this.getters.getColIndex(t,n),v=-1===v?l:v),o.canEdgeScroll?E=o.direction>0?m:f-1:(E=this.getters.getRowIndex(s,f),E=-1===E?c:E),h=i.canEdgeScroll||o.canEdgeScroll,u=Math.min(i.canEdgeScroll?i.delay:os,o.canEdgeScroll?o.delay:os),v===l&&E===c||(l=v,c=E,this.dispatch("ALTER_SELECTION",{cell:[v,E]})),h){const e=p.cols[n+i.direction].start,t=p.rows[f+o.direction].start;this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t}),d=setTimeout((()=>{d=null,g(a)}),Math.round(u))}};Ju(g,(e=>{clearTimeout(d),this.dispatch(e.ctrlKey?"PREPARE_SELECTION_EXPANSION":"STOP_SELECTION"),this.canvas.el.removeEventListener("mousemove",g),this.getters.isPaintingFormat()&&this.dispatch("PASTE",{target:this.getters.getSelectedZones()})}))}onDoubleClick(e){const[t,s]=this.getCartesianCoordinates(e);if(this.clickedCol===t&&this.clickedRow===s){const e=this.getters.getActiveCell();!e||e.isEmpty()?this.trigger("composer-cell-focused"):this.trigger("composer-content-focused")}}closeLinkEditor(){this.trigger("link-editor-closed")}processTabKey(e){e.preventDefault();const t=e.shiftKey?-1:1;this.dispatch("MOVE_POSITION",{deltaX:t,deltaY:0})}processArrows(e){e.preventDefault(),e.stopPropagation(),this.closeLinkEditor();const t={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];if(e.shiftKey){const e=this.getters.getSelectedZone();this.dispatch("ALTER_SELECTION",{delta:t});const s=this.getters.getSelectedZone(),i=this.getters.getActiveSnappedViewport(),o=this.getters.getActiveSheet(),[n,r]=function(e,t,s){let i,o;const{left:n,right:r,top:a,bottom:l}=e,{left:c,right:h,top:d,bottom:u}=t;return i=c!=n?c:h!=r?h:s.left,o=d!=a?d:u!=l?u:s.top,[i,o]}(e,s,i),{left:a,right:l,top:c,bottom:h,offsetX:d,offsetY:u}=i,p=n<a||n>l-1?o.cols[a+t[0]].start:d,g=r<c||r>h-1?o.rows[c+t[1]].start:u;p===d&&g===u||this.dispatch("SET_VIEWPORT_OFFSET",{offsetX:p,offsetY:g})}else this.dispatch("MOVE_POSITION",{deltaX:t[0],deltaY:t[1]});this.getters.isPaintingFormat()&&this.dispatch("PASTE",{target:this.getters.getSelectedZones()})}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.trigger("composer-cell-focused",{content:e.data}))}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let s=this.keyDownMapping[t];return s?(e.preventDefault(),e.stopPropagation(),void s()):void 0}onInputContextMenu(e){e.preventDefault();const t=this.getters.getSelectedZone(),{left:s,top:i}=t;let o="CELL";this.dispatch("STOP_EDITION"),this.getters.getActiveCols().has(s)?o="COL":this.getters.getActiveRows().has(i)&&(o="ROW");const[n,r,a,l]=this.getters.getRect(t,this.getters.getActiveSnappedViewport());this.toggleContextMenu(o,n+a,r+l)}onCanvasContextMenu(e){e.preventDefault();const[t,s]=this.getCartesianCoordinates(e);if(t<0||s<0)return;const i=this.getters.getSelectedZones();let o="CELL";Hs(t,s,i[i.length-1])?this.getters.getActiveCols().has(t)?o="COL":this.getters.getActiveRows().has(s)&&(o="ROW"):(this.dispatch("STOP_EDITION"),this.dispatch("SELECT_CELL",{col:t,row:s})),this.toggleContextMenu(o,e.offsetX,e.offsetY)}onOverlayContextMenu(e){const t=e.detail.type,s=e.detail.x,i=e.detail.y;this.toggleContextMenu(t,s,i)}toggleContextMenu(e,t,s){this.closeLinkEditor(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:s+v},this.menuState.menuItems=Qg[e].getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}sf.template=ef,sf.style=tf,sf.components={GridComposer:Yp,Overlay:Zg,Menu:Wu,Autofill:rp,FiguresContainer:pg,ClientTag:up,Highlight:xg,ErrorToolTip:eg,LinkDisplay:_g,LinkEditor:Dg,Popover:Pu};const{xml:of,css:nf}=t.tags,{useState:rf}=t.hooks,af=of`
2610
2610
  <div class="o-sidePanel" >
2611
2611
  <div class="o-sidePanelHeader">
2612
2612
  <div class="o-sidePanelTitle" t-esc="getTitle()"/>
@@ -2618,7 +2618,7 @@
2618
2618
  <div class="o-sidePanelFooter" t-if="state.panel.Footer">
2619
2619
  <t t-component="state.panel.Footer" t-props="props.panelProps" t-key="'Footer_' + props.component"/>
2620
2620
  </div>
2621
- </div>`,rf=sf`
2621
+ </div>`,lf=nf`
2622
2622
  .o-sidePanel {
2623
2623
  display: flex;
2624
2624
  flex-direction: column;
@@ -2717,7 +2717,7 @@
2717
2717
  text-align: left;
2718
2718
  }
2719
2719
  }
2720
- `;class af extends t.Component{constructor(){super(...arguments),this.state=of({panel:fh.get(this.props.component)})}async willUpdateProps(e){this.state.panel=fh.get(e.component)}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}af.template=nf,af.style=rf;const{xml:lf,css:cf}=t.tags,{useExternalListener:hf,useRef:df}=t.hooks,uf=a("Undo"),pf=a("Redo"),gf=a("Paint Format"),ff=a("Clear Format"),mf=a("Format as percent"),vf=a("Decrease decimal places"),Ef=a("Increase decimal places"),Sf=a("More formats"),bf=a("Font Size"),Cf=a("Bold"),If=a("Italic"),yf=a("Strikethrough"),wf=a("Text Color"),Tf=a("Fill Color"),xf=a("Borders"),Rf=a("Merge Cells"),Lf=a("Horizontal align"),Mf=[{name:"general",text:a("General (no specific format)")},{name:"number",text:a("Number (1,000.12)"),value:"#,##0.00"},{name:"percent",text:a("Percent (10.12%)"),value:"0.00%"},{name:"date",text:a("Date (9/26/2008)"),value:"m/d/yyyy"},{name:"time",text:a("Time (10:43:00 PM)"),value:"hh:mm:ss a"},{name:"datetime",text:a("Date time (9/26/2008 22:43:00)"),value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:a("Duration (27:51:38)"),value:"hhhh:mm:ss"}];class Af extends t.Component{constructor(){super(...arguments),this.formats=Mf,this.currentFormat="general",this.fontSizes=ls,this.dispatch=this.env.dispatch,this.getters=this.env.getters,this.style={},this.state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:""}),this.isSelectingMenu=!1,this.openedEl=null,this.inMerge=!1,this.cannotMerge=!1,this.undoTool=!1,this.redoTool=!1,this.paintFormatTool=!1,this.fillColor="white",this.textColor="black",this.menus=[],this.menuRef=df("menuRef"),this.composerStyle="\n line-height: 34px;\n padding-left: 8px;\n height: 34px;\n background-color: white;\n ",hf(window,"click",this.onClick)}get topbarComponents(){return mh.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}async willStart(){this.updateCellState()}async willUpdateProps(){this.updateCellState()}onClick(e){this.openedEl&&Ac(this.openedEl,e)||this.closeMenus()}toogleStyle(e){$a(this.env,{[e]:!this.style[e]})}toogleFormat(e){const t=Mf.find((t=>t.name===e)),s=t&&t.value||"";Fa(this.env,s)}toggleAlign(e){$a(this.env,{align:e})}onMenuMouseOver(e,t){this.isSelectingMenu&&this.toggleContextMenu(e,t)}toggleDropdownTool(e,t){const s=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=s?"":e,this.openedEl=s?null:t.target}toggleContextMenu(e,t){this.closeMenus();const s=t.target.offsetLeft,i=t.target.clientHeight+t.target.offsetTop;this.state.menuState.isOpen=!0,this.state.menuState.position={x:s,y:i},this.state.menuState.menuItems=dl.getChildren(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.isSelectingMenu=!0,this.openedEl=t.target}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.isSelectingMenu=!1,this.openedEl=null,this.menuRef.comp&&this.menuRef.comp.closeSubMenus()}updateCellState(){this.style=this.getters.getCurrentStyle(),this.fillColor=this.style.fillColor||"white",this.textColor=this.style.textColor||"black";const e=this.getters.getSelectedZones(),{top:t,left:s,right:i,bottom:o}=e[0];if(this.cannotMerge=e.length>1||t===o&&s===i,this.inMerge=!1,!this.cannotMerge){const[t,s]=this.getters.getPosition(),i=this.getters.expandZone(this.getters.getActiveSheetId(),{left:t,right:t,top:s,bottom:s});this.inMerge=Us(e[0],i)}this.undoTool=this.getters.canUndo(),this.redoTool=this.getters.canRedo(),this.paintFormatTool=this.getters.isPaintingFormat();const n=this.getters.getActiveCell();if(n&&n.format){const e=this.formats.find((e=>e.value===n.format));this.currentFormat=e?e.name:""}else this.currentFormat="general";this.menus=dl.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}getMenuName(e){return dl.getName(e,this.env)}toggleMerge(){const e=this.getters.getSelectedZones(),t=[e[e.length-1]],s=this.getters.getActiveSheetId();this.inMerge?this.dispatch("REMOVE_MERGE",{sheetId:s,target:t}):this.dispatch("ADD_MERGE",{sheetId:s,target:t,interactive:!0})}setColor(e,t){$a(this.env,{[e]:t.detail.color})}setBorder(e){this.dispatch("SET_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),border:e})}setFormat(e){const t=e.target.dataset.format;t&&this.toogleFormat(t)}setDecimal(e){this.dispatch("SET_DECIMAL",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),step:e})}paintFormat(){this.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.getters.getSelectedZones()})}clearFormatting(){this.dispatch("CLEAR_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones()})}setSize(e){const t=parseFloat(e.target.dataset.size);$a(this.env,{fontSize:t})}doAction(e){e(this.env),this.closeMenus()}undo(){this.dispatch("REQUEST_UNDO")}redo(){this.dispatch("REQUEST_REDO")}}Af.template=lf`
2720
+ `;class cf extends t.Component{constructor(){super(...arguments),this.state=rf({panel:vh.get(this.props.component)})}async willUpdateProps(e){this.state.panel=vh.get(e.component)}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}cf.template=af,cf.style=lf;const{xml:hf,css:df}=t.tags,{useExternalListener:uf,useRef:pf}=t.hooks,gf=a("Undo"),ff=a("Redo"),mf=a("Paint Format"),vf=a("Clear Format"),Ef=a("Format as percent"),bf=a("Decrease decimal places"),Sf=a("Increase decimal places"),Cf=a("More formats"),If=a("Font Size"),yf=a("Bold"),wf=a("Italic"),Tf=a("Strikethrough"),xf=a("Text Color"),Rf=a("Fill Color"),Lf=a("Borders"),Mf=a("Merge Cells"),Af=a("Horizontal align"),_f=[{name:"general",text:a("General (no specific format)")},{name:"number",text:a("Number (1,000.12)"),value:"#,##0.00"},{name:"percent",text:a("Percent (10.12%)"),value:"0.00%"},{name:"date",text:a("Date (9/26/2008)"),value:"m/d/yyyy"},{name:"time",text:a("Time (10:43:00 PM)"),value:"hh:mm:ss a"},{name:"datetime",text:a("Date time (9/26/2008 22:43:00)"),value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:a("Duration (27:51:38)"),value:"hhhh:mm:ss"}];class Of extends t.Component{constructor(){super(...arguments),this.formats=_f,this.currentFormat="general",this.fontSizes=ls,this.dispatch=this.env.dispatch,this.getters=this.env.getters,this.style={},this.state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:""}),this.isSelectingMenu=!1,this.openedEl=null,this.inMerge=!1,this.cannotMerge=!1,this.undoTool=!1,this.redoTool=!1,this.paintFormatTool=!1,this.fillColor="white",this.textColor="black",this.menus=[],this.menuRef=pf("menuRef"),this.composerStyle="\n line-height: 34px;\n padding-left: 8px;\n height: 34px;\n background-color: white;\n ",uf(window,"click",this.onClick)}get topbarComponents(){return Eh.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}async willStart(){this.updateCellState()}async willUpdateProps(){this.updateCellState()}onClick(e){this.openedEl&&Oc(this.openedEl,e)||this.closeMenus()}toogleStyle(e){Ua(this.env,{[e]:!this.style[e]})}toogleFormat(e){const t=_f.find((t=>t.name===e)),s=t&&t.value||"";Da(this.env,s)}toggleAlign(e){Ua(this.env,{align:e})}onMenuMouseOver(e,t){this.isSelectingMenu&&this.toggleContextMenu(e,t)}toggleDropdownTool(e,t){const s=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=s?"":e,this.openedEl=s?null:t.target}toggleContextMenu(e,t){this.closeMenus();const s=t.target.offsetLeft,i=t.target.clientHeight+t.target.offsetTop;this.state.menuState.isOpen=!0,this.state.menuState.position={x:s,y:i},this.state.menuState.menuItems=pl.getChildren(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.isSelectingMenu=!0,this.openedEl=t.target}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.isSelectingMenu=!1,this.openedEl=null,this.menuRef.comp&&this.menuRef.comp.closeSubMenus()}updateCellState(){this.style=this.getters.getCurrentStyle(),this.fillColor=this.style.fillColor||"white",this.textColor=this.style.textColor||"black";const e=this.getters.getSelectedZones(),{top:t,left:s,right:i,bottom:o}=e[0];if(this.cannotMerge=e.length>1||t===o&&s===i,this.inMerge=!1,!this.cannotMerge){const[t,s]=this.getters.getPosition(),i=this.getters.expandZone(this.getters.getActiveSheetId(),{left:t,right:t,top:s,bottom:s});this.inMerge=Bs(e[0],i)}this.undoTool=this.getters.canUndo(),this.redoTool=this.getters.canRedo(),this.paintFormatTool=this.getters.isPaintingFormat();const n=this.getters.getActiveCell();if(n&&n.format){const e=this.formats.find((e=>e.value===n.format));this.currentFormat=e?e.name:""}else this.currentFormat="general";this.menus=pl.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}getMenuName(e){return pl.getName(e,this.env)}toggleMerge(){const e=this.getters.getSelectedZones(),t=[e[e.length-1]],s=this.getters.getActiveSheetId();this.inMerge?this.dispatch("REMOVE_MERGE",{sheetId:s,target:t}):this.dispatch("ADD_MERGE",{sheetId:s,target:t,interactive:!0})}setColor(e,t){Ua(this.env,{[e]:t.detail.color})}setBorder(e){this.dispatch("SET_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),border:e})}setFormat(e){const t=e.target.dataset.format;t&&this.toogleFormat(t)}setDecimal(e){this.dispatch("SET_DECIMAL",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones(),step:e})}paintFormat(){this.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.getters.getSelectedZones()})}clearFormatting(){this.dispatch("CLEAR_FORMATTING",{sheetId:this.getters.getActiveSheetId(),target:this.getters.getSelectedZones()})}setSize(e){const t=parseFloat(e.target.dataset.size);Ua(this.env,{fontSize:t})}doAction(e){e(this.env),this.closeMenus()}undo(){this.dispatch("REQUEST_UNDO")}redo(){this.dispatch("REQUEST_REDO")}}Of.template=hf`
2721
2721
  <div class="o-spreadsheet-topbar">
2722
2722
  <div class="o-topbar-top">
2723
2723
  <!-- Menus -->
@@ -2752,16 +2752,16 @@
2752
2752
  </span>
2753
2753
  </div>
2754
2754
  <div t-else="" class="o-toolbar-tools">
2755
- <div class="o-tool" title="${uf}" t-att-class="{'o-disabled': !undoTool}" t-on-click="undo" >${'<svg class="o-icon"><path fill="#000000" d="M11.5656391,4.43436088 L9,7 L16,7 L16,0 L13.0418424,2.95815758 C11.5936787,1.73635959 9.72260775,1 7.67955083,1 C4.22126258,1 1.25575599,3.10984908 0,6 L2,7 C2.93658775,4.60974406 5.12943697,3.08011229 7.67955083,3 C9.14881247,3.0528747 10.4994783,3.57862053 11.5656391,4.43436088 Z" transform="matrix(-1 0 0 1 17 5)"/></svg>'}</div>
2756
- <div class="o-tool" title="${pf}" t-att-class="{'o-disabled': !redoTool}" t-on-click="redo">${'<svg class="o-icon"><path fill="#000000" d="M11.5656391,4.43436088 L9,7 L16,7 L16,0 L13.0418424,2.95815758 C11.5936787,1.73635959 9.72260775,1 7.67955083,1 C4.22126258,1 1.25575599,3.10984908 0,6 L2,7 C2.93658775,4.60974406 5.12943697,3.08011229 7.67955083,3 C9.14881247,3.0528747 10.4994783,3.57862053 11.5656391,4.43436088 Z" transform="translate(1 5)"/></svg>'}</div>
2757
- <div class="o-tool" title="${gf}" t-att-class="{active:paintFormatTool}" t-on-click="paintFormat">${'<svg class="o-icon"><path fill="#000000" d="M9,0 L1,0 C0.45,0 0,0.45 0,1 L0,4 C0,4.55 0.45,5 1,5 L9,5 C9.55,5 10,4.55 10,4 L10,3 L11,3 L11,6 L4,6 L4,14 L6,14 L6,8 L13,8 L13,2 L10,2 L10,1 C10,0.45 9.55,0 9,0 Z" transform="translate(3 2)"/></svg>'}</div>
2758
- <div class="o-tool" title="${ff}" t-on-click="clearFormatting()">${'<svg class="o-icon"><path fill="#000000" d="M0.27,1.55 L5.43,6.7 L3,12 L5.5,12 L7.14,8.42 L11.73,13 L13,11.73 L1.55,0.27 L0.27,1.55 L0.27,1.55 Z M3.82,0 L5.82,2 L7.58,2 L7.03,3.21 L8.74,4.92 L10.08,2 L14,2 L14,0 L3.82,0 L3.82,0 Z" transform="translate(2 3)"/></svg>'}</div>
2755
+ <div class="o-tool" title="${gf}" t-att-class="{'o-disabled': !undoTool}" t-on-click="undo" >${'<svg class="o-icon"><path fill="#000000" d="M11.5656391,4.43436088 L9,7 L16,7 L16,0 L13.0418424,2.95815758 C11.5936787,1.73635959 9.72260775,1 7.67955083,1 C4.22126258,1 1.25575599,3.10984908 0,6 L2,7 C2.93658775,4.60974406 5.12943697,3.08011229 7.67955083,3 C9.14881247,3.0528747 10.4994783,3.57862053 11.5656391,4.43436088 Z" transform="matrix(-1 0 0 1 17 5)"/></svg>'}</div>
2756
+ <div class="o-tool" title="${ff}" t-att-class="{'o-disabled': !redoTool}" t-on-click="redo">${'<svg class="o-icon"><path fill="#000000" d="M11.5656391,4.43436088 L9,7 L16,7 L16,0 L13.0418424,2.95815758 C11.5936787,1.73635959 9.72260775,1 7.67955083,1 C4.22126258,1 1.25575599,3.10984908 0,6 L2,7 C2.93658775,4.60974406 5.12943697,3.08011229 7.67955083,3 C9.14881247,3.0528747 10.4994783,3.57862053 11.5656391,4.43436088 Z" transform="translate(1 5)"/></svg>'}</div>
2757
+ <div class="o-tool" title="${mf}" t-att-class="{active:paintFormatTool}" t-on-click="paintFormat">${'<svg class="o-icon"><path fill="#000000" d="M9,0 L1,0 C0.45,0 0,0.45 0,1 L0,4 C0,4.55 0.45,5 1,5 L9,5 C9.55,5 10,4.55 10,4 L10,3 L11,3 L11,6 L4,6 L4,14 L6,14 L6,8 L13,8 L13,2 L10,2 L10,1 C10,0.45 9.55,0 9,0 Z" transform="translate(3 2)"/></svg>'}</div>
2758
+ <div class="o-tool" title="${vf}" t-on-click="clearFormatting()">${'<svg class="o-icon"><path fill="#000000" d="M0.27,1.55 L5.43,6.7 L3,12 L5.5,12 L7.14,8.42 L11.73,13 L13,11.73 L1.55,0.27 L0.27,1.55 L0.27,1.55 Z M3.82,0 L5.82,2 L7.58,2 L7.03,3.21 L8.74,4.92 L10.08,2 L14,2 L14,0 L3.82,0 L3.82,0 Z" transform="translate(2 3)"/></svg>'}</div>
2759
2759
  <div class="o-divider"/>
2760
- <div class="o-tool" title="${mf}" t-on-click="toogleFormat('percent')">%</div>
2761
- <div class="o-tool" title="${vf}" t-on-click="setDecimal(-1)">.0</div>
2762
- <div class="o-tool" title="${Ef}" t-on-click="setDecimal(+1)">.00</div>
2763
- <div class="o-tool o-dropdown" title="${Sf}" t-on-click="toggleDropdownTool('formatTool')">
2764
- <div class="o-text-icon">123${El}</div>
2760
+ <div class="o-tool" title="${Ef}" t-on-click="toogleFormat('percent')">%</div>
2761
+ <div class="o-tool" title="${bf}" t-on-click="setDecimal(-1)">.0</div>
2762
+ <div class="o-tool" title="${Sf}" t-on-click="setDecimal(+1)">.00</div>
2763
+ <div class="o-tool o-dropdown" title="${Cf}" t-on-click="toggleDropdownTool('formatTool')">
2764
+ <div class="o-text-icon">123${Sl}</div>
2765
2765
  <div class="o-dropdown-content o-text-options o-format-tool " t-if="state.activeTool === 'formatTool'" t-on-click="setFormat">
2766
2766
  <t t-foreach="formats" t-as="format" t-key="format.name">
2767
2767
  <div t-att-data-format="format.name" t-att-class="{active: currentFormat === format.name}"><t t-esc="format.text"/></div>
@@ -2769,9 +2769,9 @@
2769
2769
  </div>
2770
2770
  </div>
2771
2771
  <div class="o-divider"/>
2772
- <!-- <div class="o-tool" title="Font"><span>Roboto</span> ${El}</div> -->
2773
- <div class="o-tool o-dropdown" title="${bf}" t-on-click="toggleDropdownTool('fontSizeTool')">
2774
- <div class="o-text-icon"><t t-esc="style.fontSize || ${x}"/> ${El}</div>
2772
+ <!-- <div class="o-tool" title="Font"><span>Roboto</span> ${Sl}</div> -->
2773
+ <div class="o-tool o-dropdown" title="${If}" t-on-click="toggleDropdownTool('fontSizeTool')">
2774
+ <div class="o-text-icon"><t t-esc="style.fontSize || ${x}"/> ${Sl}</div>
2775
2775
  <div class="o-dropdown-content o-text-options " t-if="state.activeTool === 'fontSizeTool'" t-on-click="setSize">
2776
2776
  <t t-foreach="fontSizes" t-as="font" t-key="font_index">
2777
2777
  <div t-esc="font.pt" t-att-data-size="font.pt"/>
@@ -2779,23 +2779,23 @@
2779
2779
  </div>
2780
2780
  </div>
2781
2781
  <div class="o-divider"/>
2782
- <div class="o-tool" title="${Cf}" t-att-class="{active:style.bold}" t-on-click="toogleStyle('bold')">${bl}</div>
2783
- <div class="o-tool" title="${If}" t-att-class="{active:style.italic}" t-on-click="toogleStyle('italic')">${Cl}</div>
2784
- <div class="o-tool" title="${yf}" t-att-class="{active:style.strikethrough}" t-on-click="toogleStyle('strikethrough')">${Il}</div>
2785
- <div class="o-tool o-dropdown o-with-color" title="${wf}" t-on-click="toggleDropdownTool('textColorTool')" >
2786
- <span t-attf-style="border-color:{{textColor}}">${yl}</span>
2782
+ <div class="o-tool" title="${yf}" t-att-class="{active:style.bold}" t-on-click="toogleStyle('bold')">${Il}</div>
2783
+ <div class="o-tool" title="${wf}" t-att-class="{active:style.italic}" t-on-click="toogleStyle('italic')">${yl}</div>
2784
+ <div class="o-tool" title="${Tf}" t-att-class="{active:style.strikethrough}" t-on-click="toogleStyle('strikethrough')">${wl}</div>
2785
+ <div class="o-tool o-dropdown o-with-color" title="${xf}" t-on-click="toggleDropdownTool('textColorTool')" >
2786
+ <span t-attf-style="border-color:{{textColor}}">${Tl}</span>
2787
2787
  <ColorPicker t-if="state.activeTool === 'textColorTool'" t-on-color-picked="setColor('textColor')" t-key="textColor"/>
2788
2788
  </div>
2789
2789
  <div class="o-divider"/>
2790
- <div class="o-tool o-dropdown o-with-color" title="${Tf}" t-on-click="toggleDropdownTool('fillColorTool')">
2791
- <span t-attf-style="border-color:{{fillColor}}">${wl}</span>
2790
+ <div class="o-tool o-dropdown o-with-color" title="${Rf}" t-on-click="toggleDropdownTool('fillColorTool')">
2791
+ <span t-attf-style="border-color:{{fillColor}}">${xl}</span>
2792
2792
  <ColorPicker t-if="state.activeTool === 'fillColorTool'" t-on-color-picked="setColor('fillColor')" t-key="fillColor"/>
2793
2793
  </div>
2794
- <div class="o-tool o-dropdown" t-on-click="toggleDropdownTool('borderTool')" title="${xf}">
2795
- <span>${Ll}</span>
2794
+ <div class="o-tool o-dropdown" t-on-click="toggleDropdownTool('borderTool')" title="${Lf}">
2795
+ <span>${Al}</span>
2796
2796
  <div class="o-dropdown-content o-border" t-if="state.activeTool === 'borderTool'">
2797
2797
  <div class="o-dropdown-line">
2798
- <span class="o-line-item" t-on-click="setBorder('all')">${Ll}</span>
2798
+ <span class="o-line-item" t-on-click="setBorder('all')">${Al}</span>
2799
2799
  <span class="o-line-item" t-on-click="setBorder('hv')">${'<svg class="o-icon"><g fill="#000000"><path d="M0,14 L2,14 L2,12 L0,12 L0,14 L0,14 Z M2,3 L0,3 L0,5 L2,5 L2,3 L2,3 Z M3,14 L5,14 L5,12 L3,12 L3,14 L3,14 Z M11,0 L9,0 L9,2 L11,2 L11,0 L11,0 Z M2,0 L0,0 L0,2 L2,2 L2,0 L2,0 Z M5,0 L3,0 L3,2 L5,2 L5,0 L5,0 Z M0,11 L2,11 L2,9 L0,9 L0,11 L0,11 Z M9,14 L11,14 L11,12 L9,12 L9,14 L9,14 Z M12,0 L12,2 L14,2 L14,0 L12,0 L12,0 Z M12,5 L14,5 L14,3 L12,3 L12,5 L12,5 Z M12,14 L14,14 L14,12 L12,12 L12,14 L12,14 Z M12,11 L14,11 L14,9 L12,9 L12,11 L12,11 Z" opacity=".54"/><polygon points="8 0 6 0 6 6 0 6 0 8 6 8 6 14 8 14 8 8 14 8 14 6 8 6"/></g></svg>'}</span>
2800
2800
  <span class="o-line-item" t-on-click="setBorder('h')">${'<svg class="o-icon"><g fill="#000000"><path d="M6,14 L8,14 L8,12 L6,12 L6,14 L6,14 Z M3,2 L5,2 L5,0 L3,0 L3,2 L3,2 Z M6,11 L8,11 L8,9 L6,9 L6,11 L6,11 Z M3,14 L5,14 L5,12 L3,12 L3,14 L3,14 Z M0,5 L2,5 L2,3 L0,3 L0,5 L0,5 Z M0,14 L2,14 L2,12 L0,12 L0,14 L0,14 Z M0,2 L2,2 L2,0 L0,0 L0,2 L0,2 Z M0,11 L2,11 L2,9 L0,9 L0,11 L0,11 Z M12,11 L14,11 L14,9 L12,9 L12,11 L12,11 Z M12,14 L14,14 L14,12 L12,12 L12,14 L12,14 Z M12,5 L14,5 L14,3 L12,3 L12,5 L12,5 Z M12,0 L12,2 L14,2 L14,0 L12,0 L12,0 Z M6,2 L8,2 L8,0 L6,0 L6,2 L6,2 Z M9,2 L11,2 L11,0 L9,0 L9,2 L9,2 Z M6,5 L8,5 L8,3 L6,3 L6,5 L6,5 Z M9,14 L11,14 L11,12 L9,12 L9,14 L9,14 Z" opacity=".54"/><polygon points="0 8 14 8 14 6 0 6"/></g></svg>'}</span>
2801
2801
  <span class="o-line-item" t-on-click="setBorder('v')">${'<svg class="o-icon"><g fill="#000000"><path d="M3,14 L5,14 L5,12 L3,12 L3,14 L3,14 Z M0,5 L2,5 L2,3 L0,3 L0,5 L0,5 Z M0,2 L2,2 L2,0 L0,0 L0,2 L0,2 Z M3,8 L5,8 L5,6 L3,6 L3,8 L3,8 Z M3,2 L5,2 L5,0 L3,0 L3,2 L3,2 Z M0,14 L2,14 L2,12 L0,12 L0,14 L0,14 Z M0,8 L2,8 L2,6 L0,6 L0,8 L0,8 Z M0,11 L2,11 L2,9 L0,9 L0,11 L0,11 Z M12,0 L12,2 L14,2 L14,0 L12,0 L12,0 Z M12,8 L14,8 L14,6 L12,6 L12,8 L12,8 Z M12,14 L14,14 L14,12 L12,12 L12,14 L12,14 Z M12,5 L14,5 L14,3 L12,3 L12,5 L12,5 Z M12,11 L14,11 L14,9 L12,9 L12,11 L12,11 Z M9,14 L11,14 L11,12 L9,12 L9,14 L9,14 Z M9,8 L11,8 L11,6 L9,6 L9,8 L9,8 Z M9,2 L11,2 L11,0 L9,0 L9,2 L9,2 Z" opacity=".54"/><polygon points="6 14 8 14 8 0 6 0"/></g></svg>'}</span>
@@ -2810,28 +2810,28 @@
2810
2810
  </div>
2811
2811
  </div>
2812
2812
  </div>
2813
- <div class="o-tool" title="${Rf}" t-att-class="{active:inMerge, 'o-disabled': cannotMerge}" t-on-click="toggleMerge">${'<svg class="o-icon"><path fill="#000000" d="M3,6 L1,6 L1,2 L8,2 L8,4 L3,4 L3,6 Z M10,4 L10,2 L17,2 L17,6 L15,6 L15,4 L10,4 Z M10,14 L15,14 L15,12 L17,12 L17,16 L10,16 L10,14 Z M1,12 L3,12 L3,14 L8,14 L8,16 L1,16 L1,12 Z M1,8 L5,8 L5,6 L8,9 L5,12 L5,10 L1,10 L1,8 Z M10,9 L13,6 L13,8 L17,8 L17,10 L13,10 L13,12 L10,9 Z"/></svg>'}</div>
2813
+ <div class="o-tool" title="${Mf}" t-att-class="{active:inMerge, 'o-disabled': cannotMerge}" t-on-click="toggleMerge">${'<svg class="o-icon"><path fill="#000000" d="M3,6 L1,6 L1,2 L8,2 L8,4 L3,4 L3,6 Z M10,4 L10,2 L17,2 L17,6 L15,6 L15,4 L10,4 Z M10,14 L15,14 L15,12 L17,12 L17,16 L10,16 L10,14 Z M1,12 L3,12 L3,14 L8,14 L8,16 L1,16 L1,12 Z M1,8 L5,8 L5,6 L8,9 L5,12 L5,10 L1,10 L1,8 Z M10,9 L13,6 L13,8 L17,8 L17,10 L13,10 L13,12 L10,9 Z"/></svg>'}</div>
2814
2814
  <div class="o-divider"/>
2815
- <div class="o-tool o-dropdown" title="${Lf}" t-on-click="toggleDropdownTool('alignTool')">
2815
+ <div class="o-tool o-dropdown" title="${Af}" t-on-click="toggleDropdownTool('alignTool')">
2816
2816
  <span>
2817
- <t t-if="style.align === 'right'">${Rl}</t>
2818
- <t t-elif="style.align === 'center'">${xl}</t>
2819
- <t t-else="">${Tl}</t>
2820
- ${El}
2817
+ <t t-if="style.align === 'right'">${Ml}</t>
2818
+ <t t-elif="style.align === 'center'">${Ll}</t>
2819
+ <t t-else="">${Rl}</t>
2820
+ ${Sl}
2821
2821
  </span>
2822
2822
  <div t-if="state.activeTool === 'alignTool'" class="o-dropdown-content">
2823
- <div class="o-dropdown-item" t-on-click="toggleAlign('left')">${Tl}</div>
2824
- <div class="o-dropdown-item" t-on-click="toggleAlign('center')">${xl}</div>
2825
- <div class="o-dropdown-item" t-on-click="toggleAlign('right')">${Rl}</div>
2823
+ <div class="o-dropdown-item" t-on-click="toggleAlign('left')">${Rl}</div>
2824
+ <div class="o-dropdown-item" t-on-click="toggleAlign('center')">${Ll}</div>
2825
+ <div class="o-dropdown-item" t-on-click="toggleAlign('right')">${Ml}</div>
2826
2826
  </div>
2827
2827
  </div>
2828
- <!-- <div class="o-tool" title="Vertical align"><span>${'<svg class="o-icon"><path fill="#000000" d="M9.5,3 L7,3 L7,0 L5,0 L5,3 L2.5,3 L6,6.5 L9.5,3 L9.5,3 Z M0,8 L0,10 L12,10 L12,8 L0,8 L0,8 Z M2.5,15 L5,15 L5,18 L7,18 L7,15 L9.5,15 L6,11.5 L2.5,15 L2.5,15 Z" transform="translate(3)"/></svg>'}</span> ${El}</div> -->
2828
+ <!-- <div class="o-tool" title="Vertical align"><span>${'<svg class="o-icon"><path fill="#000000" d="M9.5,3 L7,3 L7,0 L5,0 L5,3 L2.5,3 L6,6.5 L9.5,3 L9.5,3 Z M0,8 L0,10 L12,10 L12,8 L0,8 L0,8 Z M2.5,15 L5,15 L5,18 L7,18 L7,15 L9.5,15 L6,11.5 L2.5,15 L2.5,15 Z" transform="translate(3)"/></svg>'}</span> ${Sl}</div> -->
2829
2829
  <!-- <div class="o-tool" title="Text Wrapping">${'<svg class="o-icon"><path fill="#000000" d="M14,0 L0,0 L0,2 L14,2 L14,0 Z M0,12 L4,12 L4,10 L0,10 L0,12 Z M11.5,5 L0,5 L0,7 L11.75,7 C12.58,7 13.25,7.67 13.25,8.5 C13.25,9.33 12.58,10 11.75,10 L9,10 L9,8 L6,11 L9,14 L9,12 L11.5,12 C13.43,12 15,10.43 15,8.5 C15,6.57 13.43,5 11.5,5 Z" transform="translate(2 3)"/></svg>'}</div> -->
2830
2830
  </div>
2831
2831
  <Composer inputStyle="composerStyle" focus="props.focusComposer"/>
2832
2832
 
2833
2833
  </div>
2834
- </div>`,Af.style=cf`
2834
+ </div>`,Of.style=df`
2835
2835
  .o-spreadsheet-topbar {
2836
2836
  background-color: white;
2837
2837
  line-height: 1.2;
@@ -3016,7 +3016,7 @@
3016
3016
  }
3017
3017
  }
3018
3018
  }
3019
- `,Af.components={ColorPicker:vl,Menu:Zu,Composer:Vp};const{useExternalListener:_f,useSubEnv:Of,useRef:Nf}=t.hooks,{xml:kf,css:Ff}=t.tags,$f=kf`
3019
+ `,Of.components={ColorPicker:bl,Menu:Wu,Composer:zp};const{useExternalListener:Nf,useSubEnv:kf,useRef:Ff}=t.hooks,{xml:$f,css:Df}=t.tags,Uf=$f`
3020
3020
  <div class="o-spreadsheet" t-on-save-requested="save" t-on-keydown="onKeydown">
3021
3021
  <TopBar
3022
3022
  t-on-click="focusGrid"
@@ -3039,7 +3039,7 @@
3039
3039
  component="sidePanel.component"
3040
3040
  panelProps="sidePanel.panelProps"/>
3041
3041
  <BottomBar t-on-click="focusGrid" class="o-two-columns"/>
3042
- </div>`,Df=Ff`
3042
+ </div>`,Pf=Df`
3043
3043
  .o-spreadsheet {
3044
3044
  position: relative;
3045
3045
  display: grid;
@@ -3072,4 +3072,4 @@
3072
3072
  height: ${15}px;
3073
3073
  vertical-align: sub;
3074
3074
  }
3075
- `;class Uf extends t.Component{constructor(e,s={}){super(e,s),this.model=new Lu(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=Nf("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",{})},Of({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:Uf._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()}),_f(window,"resize",this.render),_f(document.body,"cut",this.copy.bind(this,!0)),_f(document.body,"copy",this.copy.bind(this,!1)),_f(document.body,"paste",this.paste),_f(document.body,"keyup",this.onKeyup.bind(this)),_f(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()!==Ih.expanding&&this.model.dispatch("STOP_SELECTION")}onKeydown(e){"Control"!==e.key||e.repeat||this.model.dispatch(this.model.getters.getSelectionMode()===Ih.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})}}Uf.template=$f,Uf.style=Df,Uf.components={TopBar:Af,Grid:ef,BottomBar:Xu,SidePanel:af,LinkEditor:Fg},Uf._t=e=>e;const Pf={},Bf={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},Vf={autofillModifiersRegistry:Ta,autofillRulesRegistry:xa,cellMenuRegistry:rl,colMenuRegistry:al,linkMenuRegistry:ll,functionRegistry:or,uiPluginRegistry:id,corePluginRegistry:sd,rowMenuRegistry:cl,sidePanelRegistry:fh,sheetMenuRegistry:hl,topbarMenuRegistry:dl,topbarComponentRegistry:mh,otRegistry:ul,inverseCommandRegistry:La,cellRegistry:Zr},Hf={LinkCell:Jr},zf={args:_e,toBoolean:ge,toNumber:he,toString:ue,toXC:is,toZone:Os,toCartesian:ss,numberToLetters:ts,createFullMenuItem:_a,UuidGenerator:si,formatDecimal:re,computeTextWidth:gs,isMarkdownLink:Is,parseMarkdownLink:ws,markdownLink:ys,createEmptyWorkbookData:ua};e.CorePlugin=ga,e.DATETIME_FORMAT=A,e.DataSource=rd,e.DispatchResult=Pe,e.Model=Lu,e.Revision=qh,e.SPREADSHEET_DIMENSIONS=Bf,e.Spreadsheet=Uf,e.UIPlugin=vh,e.__DEBUG__=Ms,e.__info__=Pf,e.astToFormula=_r,e.cellTypes=Hf,e.convertAstNodes=Ar,e.coreTypes=De,e.functionCache=Dr,e.helpers=zf,e.invalidateEvaluationCommands=Fe,e.normalize=Hr,e.parse=Mr,e.readonlyAllowedCommands=$e,e.registries=Vf,e.setTranslationMethod=function(e){o=e},Object.defineProperty(e,"__esModule",{value:!0}),Pf.version="15.0.19",Pf.date="2024-03-15T10:55:52.497Z",Pf.hash="277ed99"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
3075
+ `;class Bf extends t.Component{constructor(e,s={}){super(e,s),this.model=new Au(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=Ff("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",{})},kf({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:Bf._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()}),Nf(window,"resize",this.render),Nf(document.body,"cut",this.copy.bind(this,!0)),Nf(document.body,"copy",this.copy.bind(this,!1)),Nf(document.body,"paste",this.paste),Nf(document.body,"keyup",this.onKeyup.bind(this)),Nf(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()!==wh.expanding&&this.model.dispatch("STOP_SELECTION")}onKeydown(e){"Control"!==e.key||e.repeat||this.model.dispatch(this.model.getters.getSelectionMode()===wh.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})}}Bf.template=Uf,Bf.style=Pf,Bf.components={TopBar:Of,Grid:sf,BottomBar:Qu,SidePanel:cf,LinkEditor:Dg},Bf._t=e=>e;const Vf={},Hf={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:b,SCROLLBAR_WIDTH:S},zf={autofillModifiersRegistry:Ra,autofillRulesRegistry:La,cellMenuRegistry:ll,colMenuRegistry:cl,linkMenuRegistry:hl,functionRegistry:rr,uiPluginRegistry:nd,corePluginRegistry:od,rowMenuRegistry:dl,sidePanelRegistry:vh,sheetMenuRegistry:ul,topbarMenuRegistry:pl,topbarComponentRegistry:Eh,otRegistry:gl,inverseCommandRegistry:Aa,cellRegistry:Wr},Zf={LinkCell:ta},Gf={args:_e,toBoolean:ge,toNumber:he,toString:ue,toXC:is,toZone:ks,toCartesian:ss,numberToLetters:ts,createFullMenuItem:Na,UuidGenerator:oi,formatDecimal:re,computeTextWidth:gs,isMarkdownLink:Is,parseMarkdownLink:ws,markdownLink:ys,createEmptyWorkbookData:ga};e.CorePlugin=ma,e.DATETIME_FORMAT=A,e.DataSource=ld,e.DispatchResult=Pe,e.Model=Au,e.Revision=Yh,e.SPREADSHEET_DIMENSIONS=Hf,e.Spreadsheet=Bf,e.UIPlugin=bh,e.__DEBUG__=Ms,e.__info__=Vf,e.astToFormula=Nr,e.cellTypes=Zf,e.convertAstNodes=Or,e.coreTypes=De,e.functionCache=Pr,e.helpers=Gf,e.invalidateEvaluationCommands=Fe,e.normalize=Zr,e.parse=_r,e.readonlyAllowedCommands=$e,e.registries=zf,e.setTranslationMethod=function(e){o=e},Object.defineProperty(e,"__esModule",{value:!0}),Vf.version="15.0.21",Vf.date="2024-04-10T12:08:56.252Z",Vf.hash="4d672af"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);