@odoo/o-spreadsheet 16.0.16 → 16.0.18

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,11 +1,12 @@
1
- !function(e,t){"use strict";let i=e=>e;function o(e,...t){if(1===t.length&&"object"==typeof t[0]){const i=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>i[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const n=function(e,...t){return o(i(e),...t)},r=function(e,...t){return new s(e,t)};class s extends String{constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return o(i(e),...this.values)}toString(){return this.valueOf()}}var a,l;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(a||(a={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(l||(l={}));class c extends Error{constructor(e,t,i=l.error){super(t),this.errorType=e,this.logLevel=i}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,r("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,r("Invalid reference"))}}class g extends c{constructor(){super(a.NotAvailable,r("Data not available"),l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,r('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",v="#F8F9FA",b="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y="#CACACA",x=11982760,R="#01666b",I="#188038",T="#E6F4EA",A="#CEEAD6",M=["#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"],O=26,N=48,_=96,F=23,D=15,k=18,$=14,L=4,P=4,U=3,V=P,z=17,B=250,H=1,W="400",G=10,q="'Roboto', arial",Z=["thin","#000"],j=["thin",I],X=/[ymdhs:]/,Y=a.InvalidReference,K="START_REVISION",Q=20,J=.4,ee=["'","*","?","/","\\","[","]"],te=/'|\*|\?|\/|\\|\[|\]/,ie="|",oe=r("Invalid expression");var ne;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.ColorPicker=25]="ColorPicker",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.ChartAnchor=1e3]="ChartAnchor"}(ne||(ne={}));const re=[{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}],se={};for(let e of re)se[e.pt]=e.px;const ae=new Date(1899,11,30),le=864e5,ce=2e3,he=(new Date).getFullYear(),de=new Date(0)-ae,ue=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ge=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,pe=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function me(e){let t;const i=(e=e.trim()).match(pe);if(i){if(t=function(e){if(e=e.trim(),pe.test(e)){const t=/AM/i.test(e),i=/PM/i.test(e),o=(t||i?e.substring(0,e.length-2).trim():e).split(/:/),n=o.length>=2,r=3===o.length;let s=Number(o[0]),a=n?Number(o[1]):0,l=r?Number(o[2]):0,c=r?"hh:mm:ss":"hh:mm";if(t||i)c+=" a";else if(!n)return null;s>=12&&t?s-=12:s<12&&i&&(s+=12),a+=Math.floor(l/60),l%=60,s+=Math.floor(a/60),a%=60,s>=24&&(c="hhhh:mm:ss");return{value:s/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,s,a,l)}}return null}(i[0]),null===t)return null;e=e.replace(i[0],"").trim()}let o;const n=e.match(ue),r=e.match(ge);if(n||r){let t;if(n?(t=n[0],o=fe(t,"mdy")):(t=r[0],o=fe(t,"ymd")),null===o)return null;e=e.replace(t,"").trim()}return""!==e||!o&&!t?null:o&&t?{value:o.value+t.value,format:o.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(o.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,o.jsDate.getMonth()+t.jsDate.getMonth()-11,o.jsDate.getDate()+t.jsDate.getDate()-30,o.jsDate.getHours()+t.jsDate.getHours(),o.jsDate.getMinutes()+t.jsDate.getMinutes(),o.jsDate.getSeconds()+t.jsDate.getSeconds())}:o||t}function fe(e,t){const i="mdy"===t;if(i||"ymd"===t){const t=e.split(/\/|-|\s/),o=i?0:1,n=i?1:2,r=i?2:0,s=Number(t[o]),a=Number(t[n]),l=2===t[o].length&&s<10||2===t[n].length&&a<10,c=t[r]?function(e){const t=Number(e);switch(e.length){case 1:return ce+t;case 2:return ce+(ce+t>he+10?-100:0)+t;case 3:case 4:return t}return 0}(t[r]):he,h=new Date(c,s-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==s-1||h.getDate()!==a)return null;const u=h-ae;let g=l?`mm${d}dd`:`m${d}d`;return t[r]&&(g=i?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/le),format:g,jsDate:h}}return null}function ve(e){const t=Math.trunc(e);let i=new Date(t*le-de),o=e-t;o=o<0?1+o:o;const n=Math.round(24*o),r=Math.round(24*(o-n/24)*60),s=Math.round(24*(o-n/24-r/24/60)*60*60);return i.setHours(n),i.setMinutes(r),i.setSeconds(s),i}function be(e){const t=e.getTime()-ae.getTime();return Math.round(t/le)}function Se(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Ce(e){return Se(e)===e.getDate()}function Ee(e,t,i){const o=e.getFullYear(),n=e.getMonth(),r=e.getDate(),s=new Date(o,n+t);return i&&r===Se(e)||r>Se(s)?s.setDate(Se(s)):s.setDate(r),s}function we(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function ye(e,t,i){if(e===t)return 0;if(e>t){const i=t;t=e,e=i}const o=ve(e),n=ve(t);let r=o.getDate(),s=n.getDate();const a=o.getMonth(),l=n.getMonth(),c=o.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(i){case 0:31===r&&(r=30),30===r&&31===s&&(s=30),1===a&&r===(we(c)?29:28)&&(r=30,1===l&&s===(we(h)?29:28)&&(s=30)),d=c+(30*a+r)/360,u=h+(30*l+s)/360;break;case 1:let i=365;const o=c===h;if(!o&&!(c+1===h)||!o&&a<l||!o&&a===l&&r<s){let e=0,t=0;for(let i=c;i<=h;i++)e++,t+=we(i)?366:365;i=t/e}else o?we(c)&&(i=366):(we(c)&&a<2&&(i=366),we(h)&&(l>1||1===l&&29===s)&&(i=366));d=e/i,u=t/i;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===r&&(r=30),31===s&&(s=30),d=c+(30*a+r)/360,u=h+(30*l+s)/360}return u-d}function xe(e){return JSON.stringify(e,Object.keys(e).sort())}function Re(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Ie(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Te(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();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 i in e)t[i]=Te(e[i]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function Ae(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function Me(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function Oe(e,t,i){return e<t?t:e>i?i:e}function Ne(e,t,i){const o=Fe(i);if(_e[o]||(_e[o]={}),void 0===_e[o][t]){e.save(),e.font=o;const i=e.measureText(t).width;e.restore(),_e[o][t]=i}return _e[o][t]}const _e={};function Fe(e){return`${e.italic?"italic ":""}${e.bold?"bold":W} ${De(e)}px ${q}`}function De(e){const t=e.fontSize||G;if(!se[t])throw new Error("Size of the font is not supported");return se[t]}function ke(e,t,i=1){if(t<=e&&i>0)return[];if(0===i)throw new Error("range() step must not be zero");const o=Math.ceil(Math.abs((t-e)/i)),n=Array(o);for(let t=0;t<o;t++)n[t]=e+t*i;return n}function $e(e){return e.reduce(((e,t,i,o)=>{if(1===Math.abs(t-o[i-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Le(e,t){t.next();for(const i of e){const e=t.next();yield{...i,next:e.done?void 0:e.value}}}function Pe(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}function Ue(e){return null!==me(e)}const Ve=/^\[([^\[]+)\]\((.+)\)$/,ze=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Be(e){return Ve.test(e)}function He(e,t){return`[${e}](${t})`}function We(e){const t=e.match(Ve)||[],i=t[1],o=t[2];if(!i||!o)throw new Error(`Could not parse markdown link ${e}.`);return{label:i,url:o}}const Ge="o-spreadsheet://";function qe(e){if(!Be(e))return!1;const{url:t}=We(e);return t.startsWith(Ge)}function Ze(e){return`${Ge}${e}`}function je(e){if(e.startsWith(Ge))return e.substr(Ge.length);throw new Error(`${e} is not a valid sheet link`)}function Xe(e){return void 0!==e}function Ye(e){return void 0!==e&&""!==e}function Ke(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Ke(e):!e))}function Qe(e,t){for(let[i,o]of Object.entries(t))if(xe(o)===xe(e))return parseInt(i,10);const i=Object.keys(t),o=0===i.length?0:Math.max(...i.map((e=>parseInt(e,10))));return t[o+1]=e,o+1}function Je(e,t,i){let o;return function(){const n=this,r=arguments;const s=i&&!o;clearTimeout(o),o=setTimeout((function(){o=null,i||e.apply(n,r)}),t),s&&e.apply(n,r)}}function et(e){let t="";for(let i=0,o=e.length;i<o;i++)t+=e[i];return t}function tt(e){let t,i=!1;const o=()=>(i||(t=e instanceof Function?e():e,i=!0),t);return o.map=e=>tt((()=>e(o()))),o}function it(e,t){let i=e.slice(t).find((e=>e));return i||(i=e.slice(0,t).reverse().find((e=>e))),i||""}function ot(e,t){return"after"===e?t+1:t}function nt(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const i=new Set;Object.keys(e).forEach((e=>i.add(e))),Object.keys(t).forEach((e=>i.add(e)));for(let o of i){if(typeof e[o]!=typeof e[o])return!1;if("object"==typeof e[o]){if(!nt(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function rt(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function st(e){return e?e.toLowerCase():""}const at=/rgba?\(|\s+|\)/gi,lt=/^#([A-F\d]{2}){3,4}$/g,ct=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function ht(e){return ut(e.toString(16).padStart(6,"0"))}let dt=0;function ut(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(at,"").split(",");let i=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");i=Math.round(255*(e||1))}const o=t.map((e=>parseInt(e,10)));255!==i&&o.push(i);return"#"+et(o.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!t.match(lt))throw new Error(`invalid color input: ${e}`);return t}function gt(e){try{return ut(e),!0}catch(e){return!1}}const pt=e=>e>=0&&e<=255;function mt(e,t,i,o=1){if(!pt(e)||!pt(t)||!pt(i)||o<0||o>1)throw new Error(`Invalid RGBA values ${[e,t,i,o]}`);return{a:o,b:i,g:t,r:e}}function ft(e){let{r:t,g:i,b:o}=bt(e);t/=255,i/=255,o/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(i)+.0722*n(o)}function vt(e){let t=e.r.toString(16),i=e.g.toString(16),o=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1==t.length&&(t="0"+t),1==i.length&&(i="0"+i),1==o.length&&(o="0"+o),1==n.length&&(n="0"+n),"ff"===n&&(n=""),("#"+t+i+o+n).toUpperCase()}function bt(e){let t,i,o,n;if(7===(e=ut(e)).length)t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:i,b:o}}function St(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,i=t*(1-Math.abs(e.h/60%2-1)),o=e.l-t/2,n=0,r=0,s=0;return 0<=e.h&&e.h<60?(n=t,r=i,s=0):60<=e.h&&e.h<120?(n=i,r=t,s=0):120<=e.h&&e.h<180?(n=0,r=t,s=i):180<=e.h&&e.h<240?(n=0,r=i,s=t):240<=e.h&&e.h<300?(n=i,r=0,s=t):300<=e.h&&e.h<360&&(n=t,r=0,s=i),n=Math.round(255*(n+o)),r=Math.round(255*(r+o)),s=Math.round(255*(s+o)),{a:e.a,r:n,g:r,b:s}}function Ct(e){const t=e.r/255,i=e.g/255,o=e.b/255;let n=Math.min(t,i,o),r=Math.max(t,i,o),s=r-n,a=0,l=0,c=0;return a=0==s?0:r==t?(i-o)/s%6:r==i?(o-t)/s+2:(t-i)/s+4,a=Math.round(60*a),a<0&&(a+=360),c=(r+n)/2,l=0==s?0:s/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}const Et=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),wt=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),yt=new RegExp(/^([A-Z]{1,3})+$/,"i"),xt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Rt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),It=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[Et.source,/(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i.source,/\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i.source].join("|")+")"+/$/.source,"i");function Tt(e){return xt.test(e)}function At(e){return Rt.test(e)}function Mt(e){return yt.test(e)}function Ot(e){return wt.test(e)}function Nt(e){const t=e.split("!"),i=t.pop();return{sheetName:Ae(t.join("!"))||void 0,xc:i}}function _t(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):_t(Math.floor(e/26)-1)+_t(e%26)}function Ft(e){let t=0;const i=e.length;for(let o=0;o<i;o++){t+=(e.charCodeAt(o)-65+(o<i-1?1:0))*26**(i-o-1)}return t}function Dt(e){const t=(e=e.toUpperCase().trim()).match(Et);if(null!==t){const[i,o,n]=t;if(i===e){return{col:Ft(o),row:parseInt(n,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function kt(e,t,i={colFixed:!1,rowFixed:!1}){return(i.colFixed?"$":"")+_t(e)+(i.rowFixed?"$":"")+String(t+1)}const $t=140,Lt=20,Pt=.035;function Ut(e){return Lt+($t-Lt)*Math.exp(-Pt*(e-1))}const Vt=20,zt=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,Bt=/0/g,Ht={};function Wt(e){let t=Ht[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,i=[];for(;t<e.length;){let o;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(o=e.substring(t+1).indexOf("]")+t+2,0===o)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,o-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);i.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");o=n>-1?n+t:e.length;const r=e.substring(t,o);r.match(X)?i.push({type:"DATE",format:r}):i.push({type:"NUMBER",format:ni(r)})}t=o}return i}(e),Ht[e]=t),t}function Gt(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=ei(e));return function(e,t){if("DATE"===t[0].type)return Kt(e,t[0].format);let i=e<0?"-":"";for(let o of t)switch(o.type){case"NUMBER":i+=qt(Math.abs(e),o.format);break;case"STRING":i+=o.format}return i}(e,Wt(t));case"object":return"0"}}function qt(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:o,decimalDigits:n}=jt(e,i);let r=function(e,t,i){var o;const n="0"===e?"":e;let r=n;const s=t.length-n.length;if(s>0){const e=(t.substring(0,s).match(Bt)||[]).length;r="0".repeat(e)+r}i&&(r=(null===(o=r.match(zt))||void 0===o?void 0:o.join(","))||r);return r}(o,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(r+="."+function(e,t){let i=e;if(t.length-e.length>0){const o=(t.substring(e.length,t.length+1).match(Bt)||[]).length;i+="0".repeat(o)}return i}(n||"",t.decimalPart)),t.isPercent&&(r+="%"),r}const Zt=[];function jt(e,t=Vt){const i=e.toString();if(i.includes("e"))return function(e,t=Vt){let i=Zt[t];i||(i=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),Zt[t]=i);const[o,n]=i.format(e).split(".");return{integerDigits:o,decimalDigits:n}}(e,t);if(Number.isInteger(e))return{integerDigits:i,decimalDigits:void 0};const o=i.indexOf(".");let n=i.substring(0,o),r=i.substring(o+1);if(0===t)return Number(r[0])>=5&&(n=(Number(n)+1).toString()),{integerDigits:n,decimalDigits:void 0};if(r.length>t){const{integerDigits:e,decimalDigits:i}=function(e,t){var i;let o="0",n=e,r=e.slice(0,t);const s=t;if(Number(e[s])<5)return{integerDigits:o,decimalDigits:r};const a=(null===(i=r.match(Yt))||void 0===i?void 0:i[0])||"",l=(Number(r)+1).toString(),c=r.slice(a.length),h=l.length>c.length;h&&!a?(o="1",n=void 0):n=h?a.slice(0,-1)+l:a+l;return{integerDigits:o,decimalDigits:n}}(r,t);r=i,"0"!==e&&(n=(Number(n)+Number(e)).toString())}return{integerDigits:n,decimalDigits:Xt(r||"")}}function Xt(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Yt=/^0+/;function Kt(e,t){const i=ve(e),o=t.indexOf("h");let n="",r="";return o>0?(n=Qt(i,t.substring(0,o-1)),r=Jt(i,t.substring(o))):0===o?r=Jt(i,t):o<0&&(n=Qt(i,t)),n+(n&&r?" ":"")+r}function Qt(e,t){const i=t.match(/\/|-|\s/)[0];return t.split(i).map((i=>{switch(i){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(i)}function Jt(e,t){let i=t.split(/:|\s/);const o=e.getHours(),n="a"===i[i.length-1];let r=o,s="";return n&&(r=0===r?12:r>12?r-12:r,s=o>=12?" PM":" AM",i.pop()),i.map((i=>{switch(i){case"hhhh":return Math.floor((e.getTime()-ae)/36e5).toString();case"hh":return r.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(":")+s}function ei(e){let{decimalDigits:t}=jt(e,10);return t?"0."+"0".repeat(t.length):"0"}function ti(e,t,i){return si(Wt(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:i}]:e)).flat())}function ii(e,t){var i;const o={...e},n=Math.sign(t),r=(null===(i=o.decimalPart)||void 0===i?void 0:i.length)||0,s=Math.min(Math.max(0,r+n),Vt);return o.decimalPart="0".repeat(s),""===o.decimalPart&&delete o.decimalPart,o}const oi=/,*?$/;function ni(e){var t;if(function(e){return Boolean(e.replace(ri,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const i=e.includes("%"),o=(null===(t=e.match(oi))||void 0===t?void 0:t[0])||"",n=o?1e3**o.length:1;let r=e.slice(0,e.length-(o.length||0));const s=r.includes(",");if(r.match(/\..*,/))throw new Error("A format can't contain ',' symbol in the decimal part");r=r.replace("%","").replace(",","");const a=r.match(/[\%|,]/);if(a)throw new Error(`A format can only contain a single '${a[0]}' symbol`);const[l,c]=r.split(".");if(c&&c.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==c?{integerPart:l,isPercent:i,thousandsSeparator:s,decimalPart:c,magnitude:n}:{integerPart:l,isPercent:i,thousandsSeparator:s,magnitude:n}}const ri=/[,#0.%]/g;function si(e){let t="";for(let i of e){let e;switch(i.type){case"NUMBER":const t=i.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${i.format}]`;break;case"DATE":e=i.format}t+=e}return t}const ai=/(^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+)(?!\w|!)/,li="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",ci="(\\s*-)?",hi="(\\s*[\\$€])?",di="^(("+[ci+hi+li,ci+li+hi,hi+ci+li].join(")|(")+"))$",ui=new RegExp(di,"i");function gi(e){return!!e&&ui.test(e.trim())}const pi=/[,\$€]+/g;function mi(e){e=e.replace(pi,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function fi(e,t,i){const o=[...e].sort(((e,t)=>e-t));let n=(o.length+(i?-1:1))*t;if(i||n--,Number.isInteger(n))return o[n];const r=Math.ceil(n),s=Math.floor(n);return o[r]*(n-s)+o[s]*(r-n)}class vi{constructor(e,t){this.getSheetSize=t,this.prefixSheet=!1,this._zone=e.zone,this.parts=e.parts,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName}static fromRange(e,t){return e instanceof vi?e:new vi(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:i,right:o}=this._zone;if(void 0!==o&&void 0!==i)return{left:e,top:t,right:o,bottom:i};if(void 0===i&&void 0!==o)return{right:o,top:t,left:e,bottom:this.getSheetSize(this.sheetId).height-1};if(void 0===o&&void 0!==i)return{bottom:i,left:e,top:t,right:this.getSheetSize(this.sheetId).width-1};throw new Error(r("Bad zone format"))}static getRangeParts(e,t){const i=e.split(":").map((e=>{const t=At(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),o=void 0===t.bottom,n=void 0===t.right;return o&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed,t.left===t.right&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed)),n&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed,t.top===t.bottom&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed)),i}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){if(void 0!==this._zone.right&&this._zone.right<this._zone.left){let e=this._zone.right;this._zone.right=this._zone.left,this._zone.left=e;let t=this.parts[1].colFixed;this.parts[1].colFixed=this.parts[0].colFixed,this.parts[0].colFixed=t}if(void 0!==this._zone.bottom&&this._zone.bottom<this._zone.top){let e=this._zone.bottom;this._zone.bottom=this._zone.top,this._zone.top=e;let t=this.parts[1].rowFixed;this.parts[1].rowFixed=this.parts[0].rowFixed,this.parts[0].rowFixed=t}}clone(e){return new vi({zone:(null==e?void 0:e.zone)?e.zone:{...this._zone},sheetId:(null==e?void 0:e.sheetId)?e.sheetId:this.sheetId,invalidSheetName:e&&"invalidSheetName"in e?e.invalidSheetName:this.invalidSheetName,invalidXc:e&&"invalidXc"in e?e.invalidXc:this.invalidXc,parts:(null==e?void 0:e.parts)?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:(null==e?void 0:e.prefixSheet)?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function bi(e,t,i){const o=i.sheetId===e?t:i.sheetId;return i.clone({sheetId:o})}function Si(e,t,i){return i?e.getRangeFromSheetXC(t,i):void 0}function Ci(e){const t=[];for(let i=0;i<e;i++){const e={cells:{}};t.push(e)}return t}class Ei{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 wi(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let i,o,n,r,s=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Tt(c))n=r=Ft(c),i=o=0,s=!0;else if(At(c))i=o=parseInt(c,10)-1,n=r=0,a=!0;else{const e=Dt(c);n=r=e.col,i=o=e.row,l=!0}if(2===t.length)if(Tt(h))r=Ft(h),s=!0;else if(At(h))o=parseInt(h,10)-1,a=!0;else{const e=Dt(h);r=e.col,o=e.row,i=s?o:i,n=a?r:n,l=!0}if(s&&a)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const d={top:i,left:n,bottom:s?void 0:o,right:a?void 0:r};return l=l&&(a||s),l&&(d.hasHeader=l),d}(e);if(void 0!==t.right&&t.right<t.left){const e=t.left;t.left=t.right,t.right=e}if(void 0!==t.bottom&&t.bottom<t.top){const e=t.top;t.top=t.bottom,t.bottom=e}return t}function yi(e){const t=wi(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function xi(e){const{bottom:t,top:i,left:o,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(i)||isNaN(o)||void 0!==n&&isNaN(n))&&((void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)&&e.top>=0&&e.left>=0)}function Ri(e){const{top:t,bottom:i,left:o,right:n}=e,s="hasHeader"in e&&e.hasHeader,a=t===i&&o===n;if(void 0===i&&void 0!==n)return 0!==t||s?`${kt(o,t)}:${_t(n)}`:`${_t(o)}:${_t(n)}`;if(void 0===n&&void 0!==i)return 0!==o||s?`${kt(o,t)}:${i+1}`:`${t+1}:${i+1}`;if(void 0!==i&&void 0!==n)return a?kt(o,t):`${kt(o,t)}:${kt(n,i)}`;throw new Error(r("Bad zone format"))}function Ii(e,t,i,o,n){const r="left"===t?"columns":"rows",s="before"===o?i-1:i,a=e["left"===t?"right":"bottom"];return e[t]<=s&&a&&a>s?zi(e,r,"RESIZE",n):s<e[t]?zi(e,r,"MOVE",n):{...e}}function Ti(e,t,i,o,n){const r="left"===t?"columns":"rows",s="before"===o?i-1:i,a="left"===t?"right":"bottom";return e[t]<=s&&e[a]>s?zi(e,r,"RESIZE",n):s<e[t]?zi(e,r,"MOVE",n):{...e}}function Ai(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],r=e[o];for(let s of i.sort(((e,t)=>t-e)))e[t]>s&&(n--,r--),e[t]<s&&e[o]>=s&&r--;return{...e,[t]:n,[o]:r}}function Mi(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],r=e[o];const s=e[o];for(let o of i.sort(((e,t)=>t-e)))e[t]>o&&(n--,void 0!==r&&r--),void 0!==s&&void 0!==r&&e[t]<=o&&s>=o&&r--;if(!(void 0!==r&&n>r))return{...e,[t]:n,[o]:r}}function Oi(...e){return{top:Math.min(...e.map((e=>e.top))),left:Math.min(...e.map((e=>e.left))),bottom:Math.max(...e.map((e=>e.bottom))),right:Math.max(...e.map((e=>e.right)))}}function Ni(e,t){if(Fi(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)}}function _i(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Fi(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Di(e,t,i){const{left:o,right:n,top:r,bottom:s}=i;return e>=o&&e<=n&&t>=r&&t<=s}function ki(e,t){return _i(Oi(t,e),t)}function $i(e,t){const i=e.map(wi),o=t.map(yi),n=Math.max(...i.concat(o).map((e=>e.bottom||0))),r=Math.max(...i.concat(o).map((e=>e.right||0))),s=i.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?r+1:e.right}))),a=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?r+1:e.right}))),l=function(e,t){const i=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!i.has(`${e}-${t}`)))}(s.map(Vi).flat(),a.map(Vi).flat()),c=function(e){if(0===e.length)return[];const[t,...i]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),o=[];let n=Wi(t);for(const{col:e,row:t}of i)if(!Di(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else o.push(n),n=Wi({col:e,row:t});return[...o,n]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],i=Li(e),o=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;i.length;){const e=i.reduce(((e,t)=>o(e,t)?Oi(e,t):e),i.shift());t.push(e)}return Li(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===r+1?void 0:e.right}))).map(Ri)}function Li(e){const t=[...e].sort(((e,t)=>t.right-e.right)).sort(((e,t)=>t.bottom-e.bottom)).sort(((e,t)=>e.top-t.top)).sort(((e,t)=>e.left-t.left)).reverse(),i=[];for(;0!==t.length;){const e=t.shift();t.some((t=>ki(e,t)))||i.push(e)}return i.reverse()}function Pi(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function Ui(e){const{width:t,height:i}=Pi(e);return 1===t||1===i}function Vi(e){const t=[],[i,o]=[e.right,e.left].sort(((e,t)=>e-t)),[n,r]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ke(i,o+1))for(const i of ke(n,r+1))t.push({col:e,row:i});return t}function zi(e,t,i,o){const n="both"===t?o[0]:"columns"===t?o:0,r="both"===t?o[1]:"rows"===t?o:0,s="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||s?!(Gi(e)&&!s)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===i&&(l.left+=n,l.top+=r),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=r),l}function Bi(e,t){let i,o;const{left:n,right:r,top:s,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return i=l!=n?l:c!=r?c:l,o=h!=s?h:d!=a?d:h,{col:i,row:o}}function Hi(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 Wi(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Gi(e){return void 0===e.right}function qi(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function Zi(...e){return e.length<2||1===$i(e.map(Ri),[]).length}class ji{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)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}const Xi=new ji,Yi=new ji;class Ki extends t.Component{constructor(){super(...arguments),this.canvas=t.useRef("graphContainer")}get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{const e=this.chartRuntime;this.createChart(e.chartJsConfig)}));let e=this.chartRuntime;t.onPatched((()=>{const t=this.chartRuntime;nt(e,t)||(this.updateChartJs(t),e=t)}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){var t,i,o,n;const r=e.chartJsConfig;r.data&&r.data.datasets?(this.chart.data=r.data,(null===(t=r.options)||void 0===t?void 0:t.title)&&(this.chart.config.options.title=r.options.title),r.options&&"valueLabel"in r.options&&(null===(i=r.options)||void 0===i?void 0:i.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.legend=null===(o=r.options)||void 0===o?void 0:o.legend,this.chart.config.options.scales=null===(n=r.options)||void 0===n?void 0:n.scales,this.chart.update({duration:0})}}Ki.template="o-spreadsheet-ChartJsComponent",Yi.add("line",Ki),Yi.add("bar",Ki),Yi.add("pie",Ki),Yi.add("gauge",Ki);const Qi=new ji;var Ji;Qi.add("INCREMENT_MODIFIER",{apply:(e,t)=>{var i;e.current+=e.increment;const o=e.current.toString(),n=Gt(e.current,null===(i=t.cell)||void 0===i?void 0:i.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:o?{props:{content:n}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,i)=>{var o,n;const r=(null===(o=t.cell)||void 0===o?void 0:o.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:null===(n=t.cell)||void 0===n?void 0:n.formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,i,o)=>{e.current+=e.increment;let n=0,r=0;switch(o){case"up":n=0,r=-e.current;break;case"down":n=0,r=e.current;break;case"left":n=-e.current,r=0;break;case"right":n=e.current,r=0}if(!t.cell||!t.cell.isFormula())return{cellData:{}};const s=t.sheetId,a=i.createAdaptedRanges(t.cell.dependencies,n,r,s),l=i.buildFormulaContent(s,t.cell,a);return{cellData:{border:t.border,style:t.cell.style,format:t.cell.format,content:l},tooltip:l?{props:{content:l}}:void 0}}}),function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(Ji||(Ji={}));const eo=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),to=new Set([...eo,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),io=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),oo=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","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE"]);function no(e){return oo.has(e.type)}class ro{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new ro}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var so,ao,lo;e.CommandResult=void 0,(so=e.CommandResult||(e.CommandResult={}))[so.Success=0]="Success",so[so.CancelledForUnknownReason=1]="CancelledForUnknownReason",so[so.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",so[so.MergeIsDestructive=3]="MergeIsDestructive",so[so.CellIsMerged=4]="CellIsMerged",so[so.InvalidTarget=5]="InvalidTarget",so[so.EmptyUndoStack=6]="EmptyUndoStack",so[so.EmptyRedoStack=7]="EmptyRedoStack",so[so.NotEnoughElements=8]="NotEnoughElements",so[so.NotEnoughSheets=9]="NotEnoughSheets",so[so.MissingSheetName=10]="MissingSheetName",so[so.DuplicatedSheetName=11]="DuplicatedSheetName",so[so.DuplicatedSheetId=12]="DuplicatedSheetId",so[so.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",so[so.WrongSheetMove=14]="WrongSheetMove",so[so.WrongSheetPosition=15]="WrongSheetPosition",so[so.InvalidAnchorZone=16]="InvalidAnchorZone",so[so.SelectionOutOfBound=17]="SelectionOutOfBound",so[so.TargetOutOfSheet=18]="TargetOutOfSheet",so[so.WrongCutSelection=19]="WrongCutSelection",so[so.WrongPasteSelection=20]="WrongPasteSelection",so[so.WrongPasteOption=21]="WrongPasteOption",so[so.WrongFigurePasteOption=22]="WrongFigurePasteOption",so[so.EmptyClipboard=23]="EmptyClipboard",so[so.EmptyRange=24]="EmptyRange",so[so.InvalidRange=25]="InvalidRange",so[so.InvalidZones=26]="InvalidZones",so[so.InvalidSheetId=27]="InvalidSheetId",so[so.InputAlreadyFocused=28]="InputAlreadyFocused",so[so.MaximumRangesReached=29]="MaximumRangesReached",so[so.InvalidChartDefinition=30]="InvalidChartDefinition",so[so.InvalidDataSet=31]="InvalidDataSet",so[so.InvalidLabelRange=32]="InvalidLabelRange",so[so.InvalidScorecardKeyValue=33]="InvalidScorecardKeyValue",so[so.InvalidScorecardBaseline=34]="InvalidScorecardBaseline",so[so.InvalidGaugeDataRange=35]="InvalidGaugeDataRange",so[so.EmptyGaugeRangeMin=36]="EmptyGaugeRangeMin",so[so.GaugeRangeMinNaN=37]="GaugeRangeMinNaN",so[so.EmptyGaugeRangeMax=38]="EmptyGaugeRangeMax",so[so.GaugeRangeMaxNaN=39]="GaugeRangeMaxNaN",so[so.GaugeRangeMinBiggerThanRangeMax=40]="GaugeRangeMinBiggerThanRangeMax",so[so.GaugeLowerInflectionPointNaN=41]="GaugeLowerInflectionPointNaN",so[so.GaugeUpperInflectionPointNaN=42]="GaugeUpperInflectionPointNaN",so[so.GaugeLowerBiggerThanUpper=43]="GaugeLowerBiggerThanUpper",so[so.InvalidAutofillSelection=44]="InvalidAutofillSelection",so[so.WrongComposerSelection=45]="WrongComposerSelection",so[so.MinBiggerThanMax=46]="MinBiggerThanMax",so[so.LowerBiggerThanUpper=47]="LowerBiggerThanUpper",so[so.MidBiggerThanMax=48]="MidBiggerThanMax",so[so.MinBiggerThanMid=49]="MinBiggerThanMid",so[so.FirstArgMissing=50]="FirstArgMissing",so[so.SecondArgMissing=51]="SecondArgMissing",so[so.MinNaN=52]="MinNaN",so[so.MidNaN=53]="MidNaN",so[so.MaxNaN=54]="MaxNaN",so[so.ValueUpperInflectionNaN=55]="ValueUpperInflectionNaN",so[so.ValueLowerInflectionNaN=56]="ValueLowerInflectionNaN",so[so.MinInvalidFormula=57]="MinInvalidFormula",so[so.MidInvalidFormula=58]="MidInvalidFormula",so[so.MaxInvalidFormula=59]="MaxInvalidFormula",so[so.ValueUpperInvalidFormula=60]="ValueUpperInvalidFormula",so[so.ValueLowerInvalidFormula=61]="ValueLowerInvalidFormula",so[so.InvalidSortZone=62]="InvalidSortZone",so[so.WaitingSessionConfirmation=63]="WaitingSessionConfirmation",so[so.MergeOverlap=64]="MergeOverlap",so[so.TooManyHiddenElements=65]="TooManyHiddenElements",so[so.Readonly=66]="Readonly",so[so.InvalidViewportSize=67]="InvalidViewportSize",so[so.InvalidScrollingDirection=68]="InvalidScrollingDirection",so[so.FigureDoesNotExist=69]="FigureDoesNotExist",so[so.InvalidConditionalFormatId=70]="InvalidConditionalFormatId",so[so.InvalidCellPopover=71]="InvalidCellPopover",so[so.EmptyTarget=72]="EmptyTarget",so[so.InvalidFreezeQuantity=73]="InvalidFreezeQuantity",so[so.FrozenPaneOverlap=74]="FrozenPaneOverlap",so[so.ValuesNotChanged=75]="ValuesNotChanged",so[so.InvalidFilterZone=76]="InvalidFilterZone",so[so.FilterOverlap=77]="FilterOverlap",so[so.FilterNotFound=78]="FilterNotFound",so[so.MergeInFilter=79]="MergeInFilter",so[so.NonContinuousTargets=80]="NonContinuousTargets",so[so.DuplicatedFigureId=81]="DuplicatedFigureId",so[so.InvalidSelectionStep=82]="InvalidSelectionStep",so[so.DuplicatedChartId=83]="DuplicatedChartId",so[so.ChartDoesNotExist=84]="ChartDoesNotExist",so[so.InvalidHeaderIndex=85]="InvalidHeaderIndex",so[so.InvalidQuantity=86]="InvalidQuantity",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(ao||(ao={})),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"}(lo||(lo={}));const co=new ji;co.add("simple_value_copy",{condition:(e,t)=>{var i;return 1===t.length&&!e.isFormula()&&!(null===(i=e.format)||void 0===i?void 0:i.match(X))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("copy_text",{condition:e=>!e.isFormula()&&e.evaluated.type===Ji.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===Ji.number,generateRule:(e,t)=>{const i=function(e,t){let i=[],o=!1;for(let n of t)if(n===e&&(o=!0),(null==n?void 0:n.evaluated.type)===Ji.number)i.push(n.evaluated.value);else{if(o)return i;i=[]}return i}(e,t);let o=1;return 2==i.length?o=2*(i[1]-i[0]):i.length>2&&(o=function(e){const t=[];let i=e[0];for(let o=1;o<e.length;o++){const n=e[o];t.push(n-i),i=n}return t.reduce(((e,t)=>e+t),0)/t.length}(i)*i.length),{type:"INCREMENT_MODIFIER",increment:o,current:e.evaluated.type===Ji.number?e.evaluated.value:0}},sequence:40});const ho={};let uo=0;function go(e,...t){const i="__sheet__"+uo++;return function(e,t){const i=document.createElement("style");i.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),i=[],o=[];let n=[];function r(e,t){const o=[];for(const n of i[e]){let s=t&&t+" "+n||n;s.includes("&")&&(s=n.replace(/&/g,t||"")),e<i.length-1&&(s=r(e+1,s)),o.push(s)}return o.join(", ")}function s(){n.length&&(o.push(r(0)+" {"),o.push(...n),o.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(s(),i.pop()):("{"===t[0]&&(s(),i.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return o.join("\n")}(t),ho[e]=i}(i,String.raw(e,...t)),function(e){const t=ho[e];t.setAttribute("component",e),document.head.appendChild(t)}(i),i}function po({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function mo(e){return"\n"+Object.entries(e).map((([e,t])=>`${e}: ${t};`)).join("\n")+"\n"}go`
1
+ !function(e,t){"use strict";let i=e=>e;function o(e,...t){if(1===t.length&&"object"==typeof t[0]){const i=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>i[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const n=function(e,...t){return o(i(e),...t)},r=function(e,...t){return new s(e,t)};class s extends String{constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return o(i(e),...this.values)}toString(){return this.valueOf()}}var a,l;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(a||(a={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(l||(l={}));class c extends Error{constructor(e,t,i=l.error){super(t),this.errorType=e,this.logLevel=i}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,r("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,r("Invalid reference"))}}class g extends c{constructor(){super(a.NotAvailable,r("Data not available"),l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,r('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",v="#F8F9FA",b="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y="#CACACA",x=11982760,R="#01666b",I="#188038",T="#E6F4EA",A="#CEEAD6",O=["#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"],M=26,N=48,_=96,F=23,D=15,k=18,$=14,L=4,P=4,U=3,V=P,z=17,B=250,H=1,W="400",G=10,q="'Roboto', arial",Z=["thin","#000"],j=["thin",I],X=/[ymdhs:]/,Y=a.InvalidReference,K="START_REVISION",Q=20,J=.4,ee=["'","*","?","/","\\","[","]"],te=/'|\*|\?|\/|\\|\[|\]/,ie="|",oe=r("Invalid expression");var ne;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.ColorPicker=25]="ColorPicker",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.ChartAnchor=1e3]="ChartAnchor"}(ne||(ne={}));const re=[{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}],se={};for(let e of re)se[e.pt]=e.px;const ae=new Date(1899,11,30),le=864e5,ce=2e3,he=(new Date).getFullYear(),de=new Date(0)-ae,ue=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ge=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,pe=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function me(e){let t;const i=(e=e.trim()).match(pe);if(i){if(t=function(e){if(e=e.trim(),pe.test(e)){const t=/AM/i.test(e),i=/PM/i.test(e),o=(t||i?e.substring(0,e.length-2).trim():e).split(/:/),n=o.length>=2,r=3===o.length;let s=Number(o[0]),a=n?Number(o[1]):0,l=r?Number(o[2]):0,c=r?"hh:mm:ss":"hh:mm";if(t||i)c+=" a";else if(!n)return null;s>=12&&t?s-=12:s<12&&i&&(s+=12),a+=Math.floor(l/60),l%=60,s+=Math.floor(a/60),a%=60,s>=24&&(c="hhhh:mm:ss");return{value:s/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,s,a,l)}}return null}(i[0]),null===t)return null;e=e.replace(i[0],"").trim()}let o;const n=e.match(ue),r=e.match(ge);if(n||r){let t;if(n?(t=n[0],o=fe(t,"mdy")):(t=r[0],o=fe(t,"ymd")),null===o)return null;e=e.replace(t,"").trim()}return""!==e||!o&&!t?null:o&&t?{value:o.value+t.value,format:o.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(o.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,o.jsDate.getMonth()+t.jsDate.getMonth()-11,o.jsDate.getDate()+t.jsDate.getDate()-30,o.jsDate.getHours()+t.jsDate.getHours(),o.jsDate.getMinutes()+t.jsDate.getMinutes(),o.jsDate.getSeconds()+t.jsDate.getSeconds())}:o||t}function fe(e,t){const i="mdy"===t;if(i||"ymd"===t){const t=e.split(/\/|-|\s/),o=i?0:1,n=i?1:2,r=i?2:0,s=Number(t[o]),a=Number(t[n]),l=2===t[o].length&&s<10||2===t[n].length&&a<10,c=t[r]?function(e){const t=Number(e);switch(e.length){case 1:return ce+t;case 2:return ce+(ce+t>he+10?-100:0)+t;case 3:case 4:return t}return 0}(t[r]):he,h=new Date(c,s-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==s-1||h.getDate()!==a)return null;const u=h-ae;let g=l?`mm${d}dd`:`m${d}d`;return t[r]&&(g=i?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/le),format:g,jsDate:h}}return null}function ve(e){const t=Math.trunc(e);let i=new Date(t*le-de),o=e-t;o=o<0?1+o:o;const n=Math.round(24*o),r=Math.round(24*(o-n/24)*60),s=Math.round(24*(o-n/24-r/24/60)*60*60);return i.setHours(n),i.setMinutes(r),i.setSeconds(s),i}function be(e){const t=e.getTime()-ae.getTime();return Math.round(t/le)}function Se(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Ce(e){return Se(e)===e.getDate()}function Ee(e,t,i){const o=e.getFullYear(),n=e.getMonth(),r=e.getDate(),s=new Date(o,n+t);return i&&r===Se(e)||r>Se(s)?s.setDate(Se(s)):s.setDate(r),s}function we(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function ye(e,t,i){if(e===t)return 0;if(e>t){const i=t;t=e,e=i}const o=ve(e),n=ve(t);let r=o.getDate(),s=n.getDate();const a=o.getMonth(),l=n.getMonth(),c=o.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(i){case 0:31===r&&(r=30),30===r&&31===s&&(s=30),1===a&&r===(we(c)?29:28)&&(r=30,1===l&&s===(we(h)?29:28)&&(s=30)),d=c+(30*a+r)/360,u=h+(30*l+s)/360;break;case 1:let i=365;const o=c===h;if(!o&&!(c+1===h)||!o&&a<l||!o&&a===l&&r<s){let e=0,t=0;for(let i=c;i<=h;i++)e++,t+=we(i)?366:365;i=t/e}else o?we(c)&&(i=366):(we(c)&&a<2&&(i=366),we(h)&&(l>1||1===l&&29===s)&&(i=366));d=e/i,u=t/i;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===r&&(r=30),31===s&&(s=30),d=c+(30*a+r)/360,u=h+(30*l+s)/360}return u-d}function xe(e){return JSON.stringify(e,Object.keys(e).sort())}function Re(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Ie(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Te(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();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 i in e)t[i]=Te(e[i]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function Ae(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function Oe(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function Me(e,t,i){return e<t?t:e>i?i:e}function Ne(e,t,i){const o=Fe(i);if(_e[o]||(_e[o]={}),void 0===_e[o][t]){e.save(),e.font=o;const i=e.measureText(t).width;e.restore(),_e[o][t]=i}return _e[o][t]}const _e={};function Fe(e){return`${e.italic?"italic ":""}${e.bold?"bold":W} ${De(e)}px ${q}`}function De(e){const t=e.fontSize||G;if(!se[t])throw new Error("Size of the font is not supported");return se[t]}function ke(e,t,i=1){if(t<=e&&i>0)return[];if(0===i)throw new Error("range() step must not be zero");const o=Math.ceil(Math.abs((t-e)/i)),n=Array(o);for(let t=0;t<o;t++)n[t]=e+t*i;return n}function $e(e){return e.reduce(((e,t,i,o)=>{if(1===Math.abs(t-o[i-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Le(e,t){t.next();for(const i of e){const e=t.next();yield{...i,next:e.done?void 0:e.value}}}function Pe(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}function Ue(e){return null!==me(e)}const Ve=/^\[([^\[]+)\]\((.+)\)$/,ze=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Be(e){return Ve.test(e)}function He(e,t){return`[${e}](${t})`}function We(e){const t=e.match(Ve)||[],i=t[1],o=t[2];if(!i||!o)throw new Error(`Could not parse markdown link ${e}.`);return{label:i,url:o}}const Ge="o-spreadsheet://";function qe(e){if(!Be(e))return!1;const{url:t}=We(e);return t.startsWith(Ge)}function Ze(e){return`${Ge}${e}`}function je(e){if(e.startsWith(Ge))return e.substr(Ge.length);throw new Error(`${e} is not a valid sheet link`)}function Xe(e){return void 0!==e}function Ye(e){return void 0!==e&&""!==e}function Ke(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Ke(e):!e))}function Qe(e,t){for(let[i,o]of Object.entries(t))if(xe(o)===xe(e))return parseInt(i,10);const i=Object.keys(t),o=0===i.length?0:Math.max(...i.map((e=>parseInt(e,10))));return t[o+1]=e,o+1}function Je(e,t,i){let o;return function(){const n=this,r=arguments;const s=i&&!o;clearTimeout(o),o=setTimeout((function(){o=null,i||e.apply(n,r)}),t),s&&e.apply(n,r)}}function et(e){let t="";for(let i=0,o=e.length;i<o;i++)t+=e[i];return t}function tt(e){let t,i=!1;const o=()=>(i||(t=e instanceof Function?e():e,i=!0),t);return o.map=e=>tt((()=>e(o()))),o}function it(e,t){let i=e.slice(t).find((e=>e));return i||(i=e.slice(0,t).reverse().find((e=>e))),i||""}function ot(e,t){return"after"===e?t+1:t}function nt(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const i=new Set;Object.keys(e).forEach((e=>i.add(e))),Object.keys(t).forEach((e=>i.add(e)));for(let o of i){if(typeof e[o]!=typeof e[o])return!1;if("object"==typeof e[o]){if(!nt(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function rt(e,t){return t.every((t=>e.includes(t)))}function st(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function at(e){return e?e.toLowerCase():""}const lt=/rgba?\(|\s+|\)/gi,ct=/^#([A-F\d]{2}){3,4}$/g,ht=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function dt(e){return gt(e.toString(16).padStart(6,"0"))}let ut=0;function gt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(lt,"").split(",");let i=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");i=Math.round(255*(e||1))}const o=t.map((e=>parseInt(e,10)));255!==i&&o.push(i);return"#"+et(o.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!t.match(ct))throw new Error(`invalid color input: ${e}`);return t}function pt(e){try{return gt(e),!0}catch(e){return!1}}const mt=e=>e>=0&&e<=255;function ft(e,t,i,o=1){if(!mt(e)||!mt(t)||!mt(i)||o<0||o>1)throw new Error(`Invalid RGBA values ${[e,t,i,o]}`);return{a:o,b:i,g:t,r:e}}function vt(e){let{r:t,g:i,b:o}=St(e);t/=255,i/=255,o/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(i)+.0722*n(o)}function bt(e){let t=e.r.toString(16),i=e.g.toString(16),o=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1==t.length&&(t="0"+t),1==i.length&&(i="0"+i),1==o.length&&(o="0"+o),1==n.length&&(n="0"+n),"ff"===n&&(n=""),("#"+t+i+o+n).toUpperCase()}function St(e){let t,i,o,n;if(7===(e=gt(e)).length)t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:i,b:o}}function Ct(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,i=t*(1-Math.abs(e.h/60%2-1)),o=e.l-t/2,n=0,r=0,s=0;return 0<=e.h&&e.h<60?(n=t,r=i,s=0):60<=e.h&&e.h<120?(n=i,r=t,s=0):120<=e.h&&e.h<180?(n=0,r=t,s=i):180<=e.h&&e.h<240?(n=0,r=i,s=t):240<=e.h&&e.h<300?(n=i,r=0,s=t):300<=e.h&&e.h<360&&(n=t,r=0,s=i),n=Math.round(255*(n+o)),r=Math.round(255*(r+o)),s=Math.round(255*(s+o)),{a:e.a,r:n,g:r,b:s}}function Et(e){const t=e.r/255,i=e.g/255,o=e.b/255;let n=Math.min(t,i,o),r=Math.max(t,i,o),s=r-n,a=0,l=0,c=0;return a=0==s?0:r==t?(i-o)/s%6:r==i?(o-t)/s+2:(t-i)/s+4,a=Math.round(60*a),a<0&&(a+=360),c=(r+n)/2,l=0==s?0:s/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}const wt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),yt=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),xt=new RegExp(/^([A-Z]{1,3})+$/,"i"),Rt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),It=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Tt=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[wt.source,/(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i.source,/\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i.source].join("|")+")"+/$/.source,"i");function At(e){return Rt.test(e)}function Ot(e){return It.test(e)}function Mt(e){return xt.test(e)}function Nt(e){return yt.test(e)}function _t(e){const t=e.split("!"),i=t.pop();return{sheetName:Ae(t.join("!"))||void 0,xc:i}}function Ft(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Ft(Math.floor(e/26)-1)+Ft(e%26)}function Dt(e){let t=0;const i=e.length;for(let o=0;o<i;o++){t+=(e.charCodeAt(o)-65+(o<i-1?1:0))*26**(i-o-1)}return t}function kt(e){const t=(e=e.toUpperCase().trim()).match(wt);if(null!==t){const[i,o,n]=t;if(i===e){return{col:Dt(o),row:parseInt(n,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function $t(e,t,i={colFixed:!1,rowFixed:!1}){return(i.colFixed?"$":"")+Ft(e)+(i.rowFixed?"$":"")+String(t+1)}const Lt=140,Pt=20,Ut=.035;function Vt(e){return Pt+(Lt-Pt)*Math.exp(-Ut*(e-1))}const zt=20,Bt=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,Ht=/0/g,Wt={};function Gt(e){let t=Wt[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,i=[];for(;t<e.length;){let o;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(o=e.substring(t+1).indexOf("]")+t+2,0===o)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,o-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);i.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");o=n>-1?n+t:e.length;const r=e.substring(t,o);r.match(X)?i.push({type:"DATE",format:r}):i.push({type:"NUMBER",format:ri(r)})}t=o}return i}(e),Wt[e]=t),t}function qt(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=ti(e));return function(e,t){if("DATE"===t[0].type)return Qt(e,t[0].format);let i=e<0?"-":"";for(let o of t)switch(o.type){case"NUMBER":i+=Zt(Math.abs(e),o.format);break;case"STRING":i+=o.format}return i}(e,Gt(t));case"object":return"0"}}function Zt(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:o,decimalDigits:n}=Xt(e,i);let r=function(e,t,i){var o;const n="0"===e?"":e;let r=n;const s=t.length-n.length;if(s>0){const e=(t.substring(0,s).match(Ht)||[]).length;r="0".repeat(e)+r}i&&(r=(null===(o=r.match(Bt))||void 0===o?void 0:o.join(","))||r);return r}(o,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(r+="."+function(e,t){let i=e;if(t.length-e.length>0){const o=(t.substring(e.length,t.length+1).match(Ht)||[]).length;i+="0".repeat(o)}return i}(n||"",t.decimalPart)),t.isPercent&&(r+="%"),r}const jt=[];function Xt(e,t=zt){const i=e.toString();if(i.includes("e"))return function(e,t=zt){let i=jt[t];i||(i=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),jt[t]=i);const[o,n]=i.format(e).split(".");return{integerDigits:o,decimalDigits:n}}(e,t);if(Number.isInteger(e))return{integerDigits:i,decimalDigits:void 0};const o=i.indexOf(".");let n=i.substring(0,o),r=i.substring(o+1);if(0===t)return Number(r[0])>=5&&(n=(Number(n)+1).toString()),{integerDigits:n,decimalDigits:void 0};if(r.length>t){const{integerDigits:e,decimalDigits:i}=function(e,t){var i;let o="0",n=e,r=e.slice(0,t);const s=t;if(Number(e[s])<5)return{integerDigits:o,decimalDigits:r};const a=(null===(i=r.match(Kt))||void 0===i?void 0:i[0])||"",l=(Number(r)+1).toString(),c=r.slice(a.length),h=l.length>c.length;h&&!a?(o="1",n=void 0):n=h?a.slice(0,-1)+l:a+l;return{integerDigits:o,decimalDigits:n}}(r,t);r=i,"0"!==e&&(n=(Number(n)+Number(e)).toString())}return{integerDigits:n,decimalDigits:Yt(r||"")}}function Yt(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Kt=/^0+/;function Qt(e,t){const i=ve(e),o=t.indexOf("h");let n="",r="";return o>0?(n=Jt(i,t.substring(0,o-1)),r=ei(i,t.substring(o))):0===o?r=ei(i,t):o<0&&(n=Jt(i,t)),n+(n&&r?" ":"")+r}function Jt(e,t){const i=t.match(/\/|-|\s/)[0];return t.split(i).map((i=>{switch(i){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(i)}function ei(e,t){let i=t.split(/:|\s/);const o=e.getHours(),n="a"===i[i.length-1];let r=o,s="";return n&&(r=0===r?12:r>12?r-12:r,s=o>=12?" PM":" AM",i.pop()),i.map((i=>{switch(i){case"hhhh":return Math.floor((e.getTime()-ae)/36e5).toString();case"hh":return r.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(":")+s}function ti(e){let{decimalDigits:t}=Xt(e,10);return t?"0."+"0".repeat(t.length):"0"}function ii(e,t,i){return ai(Gt(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:i}]:e)).flat())}function oi(e,t){var i;const o={...e},n=Math.sign(t),r=(null===(i=o.decimalPart)||void 0===i?void 0:i.length)||0,s=Math.min(Math.max(0,r+n),zt);return o.decimalPart="0".repeat(s),""===o.decimalPart&&delete o.decimalPart,o}const ni=/,*?$/;function ri(e){var t;if(function(e){return Boolean(e.replace(si,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const i=e.includes("%"),o=(null===(t=e.match(ni))||void 0===t?void 0:t[0])||"",n=o?1e3**o.length:1;let r=e.slice(0,e.length-(o.length||0));const s=r.includes(",");if(r.match(/\..*,/))throw new Error("A format can't contain ',' symbol in the decimal part");r=r.replace("%","").replace(",","");const a=r.match(/[\%|,]/);if(a)throw new Error(`A format can only contain a single '${a[0]}' symbol`);const[l,c]=r.split(".");if(c&&c.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==c?{integerPart:l,isPercent:i,thousandsSeparator:s,decimalPart:c,magnitude:n}:{integerPart:l,isPercent:i,thousandsSeparator:s,magnitude:n}}const si=/[,#0.%]/g;function ai(e){let t="";for(let i of e){let e;switch(i.type){case"NUMBER":const t=i.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${i.format}]`;break;case"DATE":e=i.format}t+=e}return t}const li=/(^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+)(?!\w|!)/,ci="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",hi="(\\s*-)?",di="(\\s*[\\$€])?",ui="^(("+[hi+di+ci,hi+ci+di,di+hi+ci].join(")|(")+"))$",gi=new RegExp(ui,"i");function pi(e){return!!e&&gi.test(e.trim())}const mi=/[,\$€]+/g;function fi(e){e=e.replace(mi,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function vi(e,t,i){const o=[...e].sort(((e,t)=>e-t));let n=(o.length+(i?-1:1))*t;if(i||n--,Number.isInteger(n))return o[n];const r=Math.ceil(n),s=Math.floor(n);return o[r]*(n-s)+o[s]*(r-n)}class bi{constructor(e,t){this.getSheetSize=t,this.prefixSheet=!1,this._zone=e.zone,this.parts=e.parts,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName}static fromRange(e,t){return e instanceof bi?e:new bi(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:i,right:o}=this._zone;if(void 0!==o&&void 0!==i)return{left:e,top:t,right:o,bottom:i};if(void 0===i&&void 0!==o)return{right:o,top:t,left:e,bottom:this.getSheetSize(this.sheetId).height-1};if(void 0===o&&void 0!==i)return{bottom:i,left:e,top:t,right:this.getSheetSize(this.sheetId).width-1};throw new Error(r("Bad zone format"))}static getRangeParts(e,t){const i=e.split(":").map((e=>{const t=Ot(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),o=void 0===t.bottom,n=void 0===t.right;return o&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed,t.left===t.right&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed)),n&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed,t.top===t.bottom&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed)),i}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){if(void 0!==this._zone.right&&this._zone.right<this._zone.left){let e=this._zone.right;this._zone.right=this._zone.left,this._zone.left=e;let t=this.parts[1].colFixed;this.parts[1].colFixed=this.parts[0].colFixed,this.parts[0].colFixed=t}if(void 0!==this._zone.bottom&&this._zone.bottom<this._zone.top){let e=this._zone.bottom;this._zone.bottom=this._zone.top,this._zone.top=e;let t=this.parts[1].rowFixed;this.parts[1].rowFixed=this.parts[0].rowFixed,this.parts[0].rowFixed=t}}clone(e){return new bi({zone:(null==e?void 0:e.zone)?e.zone:{...this._zone},sheetId:(null==e?void 0:e.sheetId)?e.sheetId:this.sheetId,invalidSheetName:e&&"invalidSheetName"in e?e.invalidSheetName:this.invalidSheetName,invalidXc:e&&"invalidXc"in e?e.invalidXc:this.invalidXc,parts:(null==e?void 0:e.parts)?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:(null==e?void 0:e.prefixSheet)?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function Si(e,t,i){const o=i.sheetId===e?t:i.sheetId;return i.clone({sheetId:o})}function Ci(e,t,i){return i?e.getRangeFromSheetXC(t,i):void 0}function Ei(e){const t=[];for(let i=0;i<e;i++){const e={cells:{}};t.push(e)}return t}class wi{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 yi(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let i,o,n,r,s=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(At(c))n=r=Dt(c),i=o=0,s=!0;else if(Ot(c))i=o=parseInt(c,10)-1,n=r=0,a=!0;else{const e=kt(c);n=r=e.col,i=o=e.row,l=!0}if(2===t.length)if(At(h))r=Dt(h),s=!0;else if(Ot(h))o=parseInt(h,10)-1,a=!0;else{const e=kt(h);r=e.col,o=e.row,i=s?o:i,n=a?r:n,l=!0}if(s&&a)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const d={top:i,left:n,bottom:s?void 0:o,right:a?void 0:r};return l=l&&(a||s),l&&(d.hasHeader=l),d}(e);if(void 0!==t.right&&t.right<t.left){const e=t.left;t.left=t.right,t.right=e}if(void 0!==t.bottom&&t.bottom<t.top){const e=t.top;t.top=t.bottom,t.bottom=e}return t}function xi(e){const t=yi(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Ri(e){const{bottom:t,top:i,left:o,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(i)||isNaN(o)||void 0!==n&&isNaN(n))&&((void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)&&e.top>=0&&e.left>=0)}function Ii(e){const{top:t,bottom:i,left:o,right:n}=e,s="hasHeader"in e&&e.hasHeader,a=t===i&&o===n;if(void 0===i&&void 0!==n)return 0!==t||s?`${$t(o,t)}:${Ft(n)}`:`${Ft(o)}:${Ft(n)}`;if(void 0===n&&void 0!==i)return 0!==o||s?`${$t(o,t)}:${i+1}`:`${t+1}:${i+1}`;if(void 0!==i&&void 0!==n)return a?$t(o,t):`${$t(o,t)}:${$t(n,i)}`;throw new Error(r("Bad zone format"))}function Ti(e,t,i,o,n){const r="left"===t?"columns":"rows",s="before"===o?i-1:i,a=e["left"===t?"right":"bottom"];return e[t]<=s&&a&&a>s?Bi(e,r,"RESIZE",n):s<e[t]?Bi(e,r,"MOVE",n):{...e}}function Ai(e,t,i,o,n){const r="left"===t?"columns":"rows",s="before"===o?i-1:i,a="left"===t?"right":"bottom";return e[t]<=s&&e[a]>s?Bi(e,r,"RESIZE",n):s<e[t]?Bi(e,r,"MOVE",n):{...e}}function Oi(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],r=e[o];for(let s of i.sort(((e,t)=>t-e)))e[t]>s&&(n--,r--),e[t]<s&&e[o]>=s&&r--;return{...e,[t]:n,[o]:r}}function Mi(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],r=e[o];const s=e[o];for(let o of i.sort(((e,t)=>t-e)))e[t]>o&&(n--,void 0!==r&&r--),void 0!==s&&void 0!==r&&e[t]<=o&&s>=o&&r--;if(!(void 0!==r&&n>r))return{...e,[t]:n,[o]:r}}function Ni(...e){return{top:Math.min(...e.map((e=>e.top))),left:Math.min(...e.map((e=>e.left))),bottom:Math.max(...e.map((e=>e.bottom))),right:Math.max(...e.map((e=>e.right)))}}function _i(e,t){if(Di(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)}}function Fi(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Di(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function ki(e,t,i){const{left:o,right:n,top:r,bottom:s}=i;return e>=o&&e<=n&&t>=r&&t<=s}function $i(e,t){return Fi(Ni(t,e),t)}function Li(e,t){const i=e.map(yi),o=t.map(xi),n=Math.max(...i.concat(o).map((e=>e.bottom||0))),r=Math.max(...i.concat(o).map((e=>e.right||0))),s=i.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?r+1:e.right}))),a=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?r+1:e.right}))),l=function(e,t){const i=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!i.has(`${e}-${t}`)))}(s.map(zi).flat(),a.map(zi).flat()),c=function(e){if(0===e.length)return[];const[t,...i]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),o=[];let n=Gi(t);for(const{col:e,row:t}of i)if(!ki(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else o.push(n),n=Gi({col:e,row:t});return[...o,n]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],i=Pi(e),o=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;i.length;){const e=i.reduce(((e,t)=>o(e,t)?Ni(e,t):e),i.shift());t.push(e)}return Pi(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===r+1?void 0:e.right}))).map(Ii)}function Pi(e){const t=[...e].sort(((e,t)=>t.right-e.right)).sort(((e,t)=>t.bottom-e.bottom)).sort(((e,t)=>e.top-t.top)).sort(((e,t)=>e.left-t.left)).reverse(),i=[];for(;0!==t.length;){const e=t.shift();t.some((t=>$i(e,t)))||i.push(e)}return i.reverse()}function Ui(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function Vi(e){const{width:t,height:i}=Ui(e);return 1===t||1===i}function zi(e){const t=[],[i,o]=[e.right,e.left].sort(((e,t)=>e-t)),[n,r]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ke(i,o+1))for(const i of ke(n,r+1))t.push({col:e,row:i});return t}function Bi(e,t,i,o){const n="both"===t?o[0]:"columns"===t?o:0,r="both"===t?o[1]:"rows"===t?o:0,s="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||s?!(qi(e)&&!s)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===i&&(l.left+=n,l.top+=r),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=r),l}function Hi(e,t){let i,o;const{left:n,right:r,top:s,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return i=l!=n?l:c!=r?c:l,o=h!=s?h:d!=a?d:h,{col:i,row:o}}function Wi(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 Gi(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function qi(e){return void 0===e.right}function Zi(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function ji(...e){return e.length<2||1===Li(e.map(Ii),[]).length}class Xi{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)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}const Yi=new Xi,Ki=new Xi;class Qi extends t.Component{constructor(){super(...arguments),this.canvas=t.useRef("graphContainer")}get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{const e=this.chartRuntime;this.createChart(e.chartJsConfig)}));let e=this.chartRuntime;t.onPatched((()=>{const t=this.chartRuntime;nt(e,t)||(this.updateChartJs(t),e=t)}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){var t,i,o,n;const r=e.chartJsConfig;r.data&&r.data.datasets?(this.chart.data=r.data,(null===(t=r.options)||void 0===t?void 0:t.title)&&(this.chart.config.options.title=r.options.title),r.options&&"valueLabel"in r.options&&(null===(i=r.options)||void 0===i?void 0:i.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.legend=null===(o=r.options)||void 0===o?void 0:o.legend,this.chart.config.options.scales=null===(n=r.options)||void 0===n?void 0:n.scales,this.chart.update({duration:0})}}Qi.template="o-spreadsheet-ChartJsComponent",Ki.add("line",Qi),Ki.add("bar",Qi),Ki.add("pie",Qi),Ki.add("gauge",Qi);const Ji=new Xi;var eo;Ji.add("INCREMENT_MODIFIER",{apply:(e,t)=>{var i;e.current+=e.increment;const o=e.current.toString(),n=qt(e.current,null===(i=t.cell)||void 0===i?void 0:i.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:o?{props:{content:n}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,i)=>{var o,n;const r=(null===(o=t.cell)||void 0===o?void 0:o.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:null===(n=t.cell)||void 0===n?void 0:n.formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,i,o)=>{e.current+=e.increment;let n=0,r=0;switch(o){case"up":n=0,r=-e.current;break;case"down":n=0,r=e.current;break;case"left":n=-e.current,r=0;break;case"right":n=e.current,r=0}if(!t.cell||!t.cell.isFormula())return{cellData:{}};const s=t.sheetId,a=i.createAdaptedRanges(t.cell.dependencies,n,r,s),l=i.buildFormulaContent(s,t.cell,a);return{cellData:{border:t.border,style:t.cell.style,format:t.cell.format,content:l},tooltip:l?{props:{content:l}}:void 0}}}),function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(eo||(eo={}));const to=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),io=new Set([...to,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),oo=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),no=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","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE"]);function ro(e){return no.has(e.type)}class so{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new so}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var ao,lo,co;e.CommandResult=void 0,(ao=e.CommandResult||(e.CommandResult={}))[ao.Success=0]="Success",ao[ao.CancelledForUnknownReason=1]="CancelledForUnknownReason",ao[ao.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",ao[ao.MergeIsDestructive=3]="MergeIsDestructive",ao[ao.CellIsMerged=4]="CellIsMerged",ao[ao.InvalidTarget=5]="InvalidTarget",ao[ao.EmptyUndoStack=6]="EmptyUndoStack",ao[ao.EmptyRedoStack=7]="EmptyRedoStack",ao[ao.NotEnoughElements=8]="NotEnoughElements",ao[ao.NotEnoughSheets=9]="NotEnoughSheets",ao[ao.MissingSheetName=10]="MissingSheetName",ao[ao.DuplicatedSheetName=11]="DuplicatedSheetName",ao[ao.DuplicatedSheetId=12]="DuplicatedSheetId",ao[ao.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",ao[ao.WrongSheetMove=14]="WrongSheetMove",ao[ao.WrongSheetPosition=15]="WrongSheetPosition",ao[ao.InvalidAnchorZone=16]="InvalidAnchorZone",ao[ao.SelectionOutOfBound=17]="SelectionOutOfBound",ao[ao.TargetOutOfSheet=18]="TargetOutOfSheet",ao[ao.WrongCutSelection=19]="WrongCutSelection",ao[ao.WrongPasteSelection=20]="WrongPasteSelection",ao[ao.WrongPasteOption=21]="WrongPasteOption",ao[ao.WrongFigurePasteOption=22]="WrongFigurePasteOption",ao[ao.EmptyClipboard=23]="EmptyClipboard",ao[ao.EmptyRange=24]="EmptyRange",ao[ao.InvalidRange=25]="InvalidRange",ao[ao.InvalidZones=26]="InvalidZones",ao[ao.InvalidSheetId=27]="InvalidSheetId",ao[ao.InputAlreadyFocused=28]="InputAlreadyFocused",ao[ao.MaximumRangesReached=29]="MaximumRangesReached",ao[ao.InvalidChartDefinition=30]="InvalidChartDefinition",ao[ao.InvalidDataSet=31]="InvalidDataSet",ao[ao.InvalidLabelRange=32]="InvalidLabelRange",ao[ao.InvalidScorecardKeyValue=33]="InvalidScorecardKeyValue",ao[ao.InvalidScorecardBaseline=34]="InvalidScorecardBaseline",ao[ao.InvalidGaugeDataRange=35]="InvalidGaugeDataRange",ao[ao.EmptyGaugeRangeMin=36]="EmptyGaugeRangeMin",ao[ao.GaugeRangeMinNaN=37]="GaugeRangeMinNaN",ao[ao.EmptyGaugeRangeMax=38]="EmptyGaugeRangeMax",ao[ao.GaugeRangeMaxNaN=39]="GaugeRangeMaxNaN",ao[ao.GaugeRangeMinBiggerThanRangeMax=40]="GaugeRangeMinBiggerThanRangeMax",ao[ao.GaugeLowerInflectionPointNaN=41]="GaugeLowerInflectionPointNaN",ao[ao.GaugeUpperInflectionPointNaN=42]="GaugeUpperInflectionPointNaN",ao[ao.GaugeLowerBiggerThanUpper=43]="GaugeLowerBiggerThanUpper",ao[ao.InvalidAutofillSelection=44]="InvalidAutofillSelection",ao[ao.WrongComposerSelection=45]="WrongComposerSelection",ao[ao.MinBiggerThanMax=46]="MinBiggerThanMax",ao[ao.LowerBiggerThanUpper=47]="LowerBiggerThanUpper",ao[ao.MidBiggerThanMax=48]="MidBiggerThanMax",ao[ao.MinBiggerThanMid=49]="MinBiggerThanMid",ao[ao.FirstArgMissing=50]="FirstArgMissing",ao[ao.SecondArgMissing=51]="SecondArgMissing",ao[ao.MinNaN=52]="MinNaN",ao[ao.MidNaN=53]="MidNaN",ao[ao.MaxNaN=54]="MaxNaN",ao[ao.ValueUpperInflectionNaN=55]="ValueUpperInflectionNaN",ao[ao.ValueLowerInflectionNaN=56]="ValueLowerInflectionNaN",ao[ao.MinInvalidFormula=57]="MinInvalidFormula",ao[ao.MidInvalidFormula=58]="MidInvalidFormula",ao[ao.MaxInvalidFormula=59]="MaxInvalidFormula",ao[ao.ValueUpperInvalidFormula=60]="ValueUpperInvalidFormula",ao[ao.ValueLowerInvalidFormula=61]="ValueLowerInvalidFormula",ao[ao.InvalidSortZone=62]="InvalidSortZone",ao[ao.WaitingSessionConfirmation=63]="WaitingSessionConfirmation",ao[ao.MergeOverlap=64]="MergeOverlap",ao[ao.TooManyHiddenElements=65]="TooManyHiddenElements",ao[ao.Readonly=66]="Readonly",ao[ao.InvalidViewportSize=67]="InvalidViewportSize",ao[ao.InvalidScrollingDirection=68]="InvalidScrollingDirection",ao[ao.FigureDoesNotExist=69]="FigureDoesNotExist",ao[ao.InvalidConditionalFormatId=70]="InvalidConditionalFormatId",ao[ao.InvalidCellPopover=71]="InvalidCellPopover",ao[ao.EmptyTarget=72]="EmptyTarget",ao[ao.InvalidFreezeQuantity=73]="InvalidFreezeQuantity",ao[ao.FrozenPaneOverlap=74]="FrozenPaneOverlap",ao[ao.ValuesNotChanged=75]="ValuesNotChanged",ao[ao.InvalidFilterZone=76]="InvalidFilterZone",ao[ao.FilterOverlap=77]="FilterOverlap",ao[ao.FilterNotFound=78]="FilterNotFound",ao[ao.MergeInFilter=79]="MergeInFilter",ao[ao.NonContinuousTargets=80]="NonContinuousTargets",ao[ao.DuplicatedFigureId=81]="DuplicatedFigureId",ao[ao.InvalidSelectionStep=82]="InvalidSelectionStep",ao[ao.DuplicatedChartId=83]="DuplicatedChartId",ao[ao.ChartDoesNotExist=84]="ChartDoesNotExist",ao[ao.InvalidHeaderIndex=85]="InvalidHeaderIndex",ao[ao.InvalidQuantity=86]="InvalidQuantity",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(lo||(lo={})),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"}(co||(co={}));const ho=new Xi;ho.add("simple_value_copy",{condition:(e,t)=>{var i;return 1===t.length&&!e.isFormula()&&!(null===(i=e.format)||void 0===i?void 0:i.match(X))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("copy_text",{condition:e=>!e.isFormula()&&e.evaluated.type===eo.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===eo.number,generateRule:(e,t)=>{const i=function(e,t){let i=[],o=!1;for(let n of t)if(n===e&&(o=!0),(null==n?void 0:n.evaluated.type)===eo.number)i.push(n.evaluated.value);else{if(o)return i;i=[]}return i}(e,t);let o=1;return 2==i.length?o=2*(i[1]-i[0]):i.length>2&&(o=function(e){const t=[];let i=e[0];for(let o=1;o<e.length;o++){const n=e[o];t.push(n-i),i=n}return t.reduce(((e,t)=>e+t),0)/t.length}(i)*i.length),{type:"INCREMENT_MODIFIER",increment:o,current:e.evaluated.type===eo.number?e.evaluated.value:0}},sequence:40});const uo={};let go=0;function po(e,...t){const i="__sheet__"+go++;return function(e,t){const i=document.createElement("style");i.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),i=[],o=[];let n=[];function r(e,t){const o=[];for(const n of i[e]){let s=t&&t+" "+n||n;s.includes("&")&&(s=n.replace(/&/g,t||"")),e<i.length-1&&(s=r(e+1,s)),o.push(s)}return o.join(", ")}function s(){n.length&&(o.push(r(0)+" {"),o.push(...n),o.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(s(),i.pop()):("{"===t[0]&&(s(),i.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return o.join("\n")}(t),uo[e]=i}(i,String.raw(e,...t)),function(e){const t=uo[e];t.setAttribute("component",e),document.head.appendChild(t)}(i),i}function mo({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function fo(e){return"\n"+Object.entries(e).map((([e,t])=>`${e}: ${t};`)).join("\n")+"\n"}po`
2
2
  .o-error-tooltip {
3
3
  font-size: 13px;
4
4
  background-color: white;
5
5
  border-left: 3px solid red;
6
6
  padding: 10px;
7
+ overflow-wrap: break-word;
7
8
  }
8
- `;class fo extends t.Component{}fo.size={width:180,height:40},fo.template="o-spreadsheet-ErrorToolTip",fo.components={};const vo={onHover:(e,t)=>{const i=t.getCell(t.getActiveSheetId(),e.col,e.row);return(null==i?void 0:i.evaluated.type)===Ji.error&&i.evaluated.error.logLevel>l.silent?{isOpen:!0,props:{text:i.evaluated.error.message},Component:fo,cellCorner:"TopRight"}:{isOpen:!1}}};class bo extends t.Component{constructor(){super(...arguments),this.itemRef=t.useRef("menuValueItem")}setup(){t.onWillPatch((()=>{this.props.scrolledTo&&this.scrollListToSelectedValue()}))}scrollListToSelectedValue(){var e,t;this.itemRef.el&&(null===(t=(e=this.itemRef.el).scrollIntoView)||void 0===t||t.call(e,{block:"bottom"===this.props.scrolledTo?"end":"start"}))}}bo.template="o-spreadsheet-FilterMenuValueItem";const So=go`
9
+ `;class vo extends t.Component{}vo.size={width:180,height:40},vo.template="o-spreadsheet-ErrorToolTip",vo.components={};const bo={onHover:(e,t)=>{const i=t.getCell(t.getActiveSheetId(),e.col,e.row);return(null==i?void 0:i.evaluated.type)===eo.error&&i.evaluated.error.logLevel>l.silent?{isOpen:!0,props:{text:i.evaluated.error.message},Component:vo,cellCorner:"TopRight"}:{isOpen:!1}}};class So extends t.Component{constructor(){super(...arguments),this.itemRef=t.useRef("menuValueItem")}setup(){t.onWillPatch((()=>{this.props.scrolledTo&&this.scrollListToSelectedValue()}))}scrollListToSelectedValue(){var e,t;this.itemRef.el&&(null===(t=(e=this.itemRef.el).scrollIntoView)||void 0===t||t.call(e,{block:"bottom"===this.props.scrolledTo?"end":"start"}))}}So.template="o-spreadsheet-FilterMenuValueItem";const Co=po`
9
10
  .o-filter-menu {
10
11
  box-sizing: border-box;
11
12
  padding: 8px 16px;
@@ -107,7 +108,7 @@
107
108
  }
108
109
  }
109
110
  }
110
- `;class Co extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{nt(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getFilter(t,e.col,e.row);if(!i)return[];const o=(i.filteredZone?Vi(i.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:i})=>{var o;return null===(o=this.env.model.getters.getCell(t,e,i))||void 0===o?void 0:o.formattedValue})),n=this.env.model.getters.getFilterValues(t,e.col,e.row),r=[...o,...n],s=n.map(st);return[...new Set(r.map(st))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===s.findIndex((t=>t===e)),string:r.find((t=>st(t)===e))||""})))}checkValue(e){var t;this.state.selectedValue=e.string,e.checked=!e.checked,null===(t=this.searchBar.el)||void 0===t||t.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable(e,t.col,t.row)}get displayedValues(){return this.state.textFilter?function(e,t,i){const o=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let i=0,o=0,n=(t=t.toLocaleLowerCase()).length,r=0;for(let s=0;s<n;s++)t[s]===e[r]?(r++,o+=100+o-s/200):o=0,i+=o;return r===e.length?i:0}(e,i(t));n>0&&o.push({score:n,elem:t})})),o.sort(((e,t)=>t.score-e.score)),o.map((e=>e.elem))}(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const i=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...i,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let i;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));i=-1===e?void 0:e}switch(e.key){case"ArrowDown":i=void 0===i?0:Math.min(i+1,t.length-1),e.preventDefault();break;case"ArrowUp":i=void 0===i?t.length-1:Math.max(i-1,0),e.preventDefault();break;case"Enter":void 0!==i&&this.checkValue(t[i]),e.preventDefault()}this.state.selectedValue=void 0!==i?t[i].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){var t,i;const o=this.props.filterPosition,n=this.filterTable;if(!o||!n||!n.contentZone)return;const r=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:r,col:o.col,row:n.contentZone.top,zone:n.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(i=(t=this.props).onClosed)||void 0===i||i.call(t)}}Co.size={width:B,height:295},Co.template="o-spreadsheet-FilterMenu",Co.style=So,Co.components={FilterMenuValueItem:bo};const Eo={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:Co,cellCorner:"BottomLeft"})};function wo(e,t){const i=[];for(const o of e.children)"function"==typeof o?i.push(...o(t)):i.push(o);return i.sort(((e,t)=>e.sequence-t.sequence))}function yo(e,t){return"function"==typeof e.name?e.name(t):e.name}function xo(e,t){return!!t.target&&e.contains(t.target)}function Ro(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:i}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:i}}throw new Error("Can't find spreadsheet position")}function Io(e){const i=t.useState({x:0,y:0});function o(){const t=e.el;if(null===t)return;const{top:o,left:n}=t.getBoundingClientRect();n===i.x&&o===i.y||(i.x=n,i.y=o)}return t.onMounted(o),t.onPatched(o),i}class To extends t.Component{constructor(){super(...arguments),this.spreadsheetPosition=function(){const e=t.useState({x:0,y:0});let i=document.querySelector(".o-spreadsheet");function o(){if(i||(i=document.querySelector(".o-spreadsheet")),i){const{top:t,left:o}=i.getBoundingClientRect();e.x=o,e.y=t}}return o(),t.onMounted(o),t.onPatched(o),e}()}get style(){const e="left:"+(this.horizontalPosition()-this.spreadsheetPosition.x),t="top:"+(this.verticalPosition()-this.spreadsheetPosition.y),i=Math.max(0,this.viewportDimension.height-36-D),o=`max-height:${i}`,n=0!==i?"box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);":"";return`\n position: absolute;\n z-index: ${this.props.zIndex};\n ${t}px;\n ${e}px;\n ${o}px;\n width:${this.props.childWidth}px;\n overflow-y: auto;\n overflow-x: hidden;\n ${n}\n `}get viewportDimension(){return this.env.model.getters.getSheetViewDimensionWithHeaders()}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+this.props.childHeight<this.viewportDimension.height+(this.env.isDashboard()?0:63)}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)}}To.template="o-spreadsheet-Popover",To.defaultProps={flipHorizontalOffset:0,flipVerticalOffset:0,verticalOffset:0,marginTop:0,onMouseWheel:()=>{},zIndex:ne.Popover},go`
111
+ `;class Eo extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{nt(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getFilter(t,e.col,e.row);if(!i)return[];const o=(i.filteredZone?zi(i.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:i})=>{var o;return null===(o=this.env.model.getters.getCell(t,e,i))||void 0===o?void 0:o.formattedValue})),n=this.env.model.getters.getFilterValues(t,e.col,e.row),r=[...o,...n],s=n.map(at);return[...new Set(r.map(at))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===s.findIndex((t=>t===e)),string:r.find((t=>at(t)===e))||""})))}checkValue(e){var t;this.state.selectedValue=e.string,e.checked=!e.checked,null===(t=this.searchBar.el)||void 0===t||t.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable(e,t.col,t.row)}get displayedValues(){return this.state.textFilter?function(e,t,i){const o=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let i=0,o=0,n=(t=t.toLocaleLowerCase()).length,r=0;for(let s=0;s<n;s++)t[s]===e[r]?(r++,o+=100+o-s/200):o=0,i+=o;return r===e.length?i:0}(e,i(t));n>0&&o.push({score:n,elem:t})})),o.sort(((e,t)=>t.score-e.score)),o.map((e=>e.elem))}(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const i=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...i,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let i;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));i=-1===e?void 0:e}switch(e.key){case"ArrowDown":i=void 0===i?0:Math.min(i+1,t.length-1),e.preventDefault();break;case"ArrowUp":i=void 0===i?t.length-1:Math.max(i-1,0),e.preventDefault();break;case"Enter":void 0!==i&&this.checkValue(t[i]),e.preventDefault()}this.state.selectedValue=void 0!==i?t[i].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){var t,i;const o=this.props.filterPosition,n=this.filterTable;if(!o||!n||!n.contentZone)return;const r=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:r,col:o.col,row:n.contentZone.top,zone:n.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(i=(t=this.props).onClosed)||void 0===i||i.call(t)}}Eo.size={width:B,height:295},Eo.template="o-spreadsheet-FilterMenu",Eo.style=Co,Eo.components={FilterMenuValueItem:So};const wo={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:Eo,cellCorner:"BottomLeft"})};function yo(e,t){const i=[];for(const o of e.children)"function"==typeof o?i.push(...o(t)):i.push(o);return i.sort(((e,t)=>e.sequence-t.sequence))}function xo(e,t){return"function"==typeof e.name?e.name(t):e.name}function Ro(e,t){return!!t.target&&e.contains(t.target)}function Io(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:i}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:i}}throw new Error("Can't find spreadsheet position")}function To(e){const i=t.useState({x:0,y:0});function o(){const t=e.el;if(null===t)return;const{top:o,left:n}=t.getBoundingClientRect();n===i.x&&o===i.y||(i.x=n,i.y=o)}return t.onMounted(o),t.onPatched(o),i}class Ao extends t.Component{constructor(){super(...arguments),this.spreadsheetPosition=function(){const e=t.useState({x:0,y:0});let i=document.querySelector(".o-spreadsheet");function o(){if(i||(i=document.querySelector(".o-spreadsheet")),i){const{top:t,left:o}=i.getBoundingClientRect();e.x=o,e.y=t}}return o(),t.onMounted(o),t.onPatched(o),e}()}get style(){const e="left:"+(this.horizontalPosition()-this.spreadsheetPosition.x),t="top:"+(this.verticalPosition()-this.spreadsheetPosition.y),i=Math.max(0,this.viewportDimension.height-36-D),o=`max-height:${i}`,n=0!==i?"box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);":"";return`\n position: absolute;\n z-index: ${this.props.zIndex};\n ${t}px;\n ${e}px;\n ${o}px;\n width:${this.props.childWidth}px;\n overflow-y: auto;\n overflow-x: hidden;\n ${n}\n `}get viewportDimension(){return this.env.model.getters.getSheetViewDimensionWithHeaders()}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+this.props.childHeight<this.viewportDimension.height+(this.env.isDashboard()?0:63)}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)}}Ao.template="o-spreadsheet-Popover",Ao.defaultProps={flipHorizontalOffset:0,flipVerticalOffset:0,verticalOffset:0,marginTop:0,onMouseWheel:()=>{},zIndex:ne.Popover},po`
111
112
  .o-menu {
112
113
  background-color: white;
113
114
  padding: 5px 0px;
@@ -154,7 +155,7 @@
154
155
  }
155
156
  }
156
157
  }
157
- `;class Ao extends t.Component{constructor(){super(...arguments),this.MENU_WIDTH=B,this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=Io(this.menuRef)}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0}),t.useExternalListener(window,"contextmenu",this.onExternalClick,{capture:!0}),t.onWillUpdateProps((e=>{e.menuItems!==this.props.menuItems&&this.closeSubMenu()}))}get visibleMenuItems(){return this.props.menuItems.filter((e=>e.isVisible(this.env)))}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){return this.menuComponentHeight(this.visibleMenuItems)}get subMenuHeight(){return this.menuComponentHeight(this.subMenu.menuItems)}get popover(){const e=1===this.props.depth;let t=6;return this.env.isDashboard()||(t+=89),{marginTop:t,flipHorizontalOffset:B*(this.props.depth-1),flipVerticalOffset:e?0:28}}getColor(e){return e.textColor?`color: ${e.textColor}`:void 0}async activateMenu(e){var t,i;const o=await e.action(this.env);this.close(),null===(i=(t=this.props).onMenuClicked)||void 0===i||i.call(t,{detail:o})}close(){this.closeSubMenu(),this.props.onClose()}subMenuVerticalPosition(e){const t=this.visibleMenuItems.slice(0,e);return this.menuComponentHeight(t)+this.position.y}onExternalClick(e){this.menuRef.el&&Array.from(document.querySelectorAll(".o-spreadsheet .o-menu")).some((t=>xo(t,e)))||(e.closedMenuId=this.props.menuId,this.close())}menuComponentHeight(e){const t=e.filter((e=>e.separator));return 28*e.length+11*t.length}getName(e){return yo(e,this.env)}getDescription(e){return(t=e).description?t.description:"";var t}isRoot(e){return!e.action}isEnabled(e){return!!e.isEnabled(this.env)&&(!this.env.model.getters.isReadonly()||e.isReadonlyAllowed)}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){const i=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+B,y:i-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=wo(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var i;return(null===(i=e.parentMenu)||void 0===i?void 0:i.id)===t.id}closeSubMenu(){this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 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.closeSubMenu())}}Ao.template="o-spreadsheet-Menu",Ao.components={Menu:Ao,Popover:To},Ao.defaultProps={depth:1};go`
158
+ `;class Oo extends t.Component{constructor(){super(...arguments),this.MENU_WIDTH=B,this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=To(this.menuRef)}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0}),t.useExternalListener(window,"contextmenu",this.onExternalClick,{capture:!0}),t.onWillUpdateProps((e=>{e.menuItems!==this.props.menuItems&&this.closeSubMenu()}))}get visibleMenuItems(){return this.props.menuItems.filter((e=>e.isVisible(this.env)))}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){return this.menuComponentHeight(this.visibleMenuItems)}get subMenuHeight(){return this.menuComponentHeight(this.subMenu.menuItems)}get popover(){const e=1===this.props.depth;let t=6;return this.env.isDashboard()||(t+=89),{marginTop:t,flipHorizontalOffset:B*(this.props.depth-1),flipVerticalOffset:e?0:28}}getColor(e){return e.textColor?`color: ${e.textColor}`:void 0}async activateMenu(e){var t,i;const o=await e.action(this.env);this.close(),null===(i=(t=this.props).onMenuClicked)||void 0===i||i.call(t,{detail:o})}close(){this.closeSubMenu(),this.props.onClose()}subMenuVerticalPosition(e){const t=this.visibleMenuItems.slice(0,e);return this.menuComponentHeight(t)+this.position.y}onExternalClick(e){this.menuRef.el&&Array.from(document.querySelectorAll(".o-spreadsheet .o-menu")).some((t=>Ro(t,e)))||(e.closedMenuId=this.props.menuId,this.close())}menuComponentHeight(e){const t=e.filter((e=>e.separator));return 28*e.length+11*t.length}getName(e){return xo(e,this.env)}getDescription(e){return(t=e).description?t.description:"";var t}isRoot(e){return!e.action}isEnabled(e){return!!e.isEnabled(this.env)&&(!this.env.model.getters.isReadonly()||e.isReadonlyAllowed)}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){const i=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+B,y:i-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=yo(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var i;return(null===(i=e.parentMenu)||void 0===i?void 0:i.id)===t.id}closeSubMenu(){this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 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.closeSubMenu())}}Oo.template="o-spreadsheet-Menu",Oo.components={Menu:Oo,Popover:Ao},Oo.defaultProps={depth:1};po`
158
159
  .o-link-tool {
159
160
  font-size: 13px;
160
161
  background-color: white;
@@ -198,7 +199,7 @@
198
199
  cursor: pointer;
199
200
  color: #000;
200
201
  }
201
- `;class Mo extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getCell(i,e,t);if(null==o?void 0:o.isLink())return o;throw new Error(`LinkDisplay Component can only be used with link cells. ${kt(e,t)} is not a link.`)}openLink(){this.cell.action(this.env)}edit(){const{col:e,row:t}=this.props.cellPosition;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:e,row:t,popoverType:"LinkEditor"})}unlink(){const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.props.cellPosition,o=this.cell.style,n=(null==o?void 0:o.textColor)===R||null==o?void 0:o.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:i,sheetId:e,content:this.cell.link.label,style:{...o,textColor:n,underline:void 0}})}}Mo.components={Menu:Ao},Mo.template="o-spreadsheet-LinkDisplay",Mo.size={width:220,height:43};const Oo={onHover:(e,t)=>{const i=t.getActiveSheetId(),o=t.getCell(i,e.col,e.row);return!t.isDashboard()&&(null==o?void 0:o.isLink())&&t.isVisibleInViewport(i,e.col,e.row)?{isOpen:!0,Component:Mo,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}},No=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,description:"",action:!1,children:[],separator:!1,icon:!1,id:e});function _o(e,t){return Object.assign({},No(e),t)}function Fo(e){return"function"!=typeof e}class Do extends ji{add(e,t){return this.content[e]=_o(e,t),this}addChild(e,t,i){const o=t.splice(0,1)[0];let n=this.content[o];if(!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);for(let e of t)if(n=n.children.filter(Fo).find((t=>t.id===e)),!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);return"function"!=typeof i?n.children.push(_o(e,i)):n.children.push(i),this}getAll(){return super.getAll().sort(((e,t)=>e.sequence-t.sequence))}}const ko=new Do;ko.add("sheet",{name:r("Link sheet"),sequence:10}).addChild("sheet_list",["sheet"],(e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map(((e,t)=>_o(e.id,{name:e.name,sequence:t,action:()=>({link:{label:e.name,url:Ze(e.id)},urlRepresentation:e.name,isUrlEditable:!1})})))));go`
202
+ `;class Mo extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getCell(i,e,t);if(null==o?void 0:o.isLink())return o;throw new Error(`LinkDisplay Component can only be used with link cells. ${$t(e,t)} is not a link.`)}openLink(){this.cell.action(this.env)}edit(){const{col:e,row:t}=this.props.cellPosition;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:e,row:t,popoverType:"LinkEditor"})}unlink(){const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.props.cellPosition,o=this.cell.style,n=(null==o?void 0:o.textColor)===R||null==o?void 0:o.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:i,sheetId:e,content:this.cell.link.label,style:{...o,textColor:n,underline:void 0}})}}Mo.components={Menu:Oo},Mo.template="o-spreadsheet-LinkDisplay",Mo.size={width:220,height:43};const No={onHover:(e,t)=>{const i=t.getActiveSheetId(),o=t.getCell(i,e.col,e.row);return!t.isDashboard()&&(null==o?void 0:o.isLink())&&t.isVisibleInViewport(i,e.col,e.row)?{isOpen:!0,Component:Mo,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}},_o=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,description:"",action:!1,children:[],separator:!1,icon:!1,id:e});function Fo(e,t){return Object.assign({},_o(e),t)}function Do(e){return"function"!=typeof e}class ko extends Xi{add(e,t){return this.content[e]=Fo(e,t),this}addChild(e,t,i){const o=t.splice(0,1)[0];let n=this.content[o];if(!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);for(let e of t)if(n=n.children.filter(Do).find((t=>t.id===e)),!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);return"function"!=typeof i?n.children.push(Fo(e,i)):n.children.push(i),this}getAll(){return super.getAll().sort(((e,t)=>e.sequence-t.sequence))}}const $o=new ko;$o.add("sheet",{name:r("Link sheet"),sequence:10}).addChild("sheet_list",["sheet"],(e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map(((e,t)=>Fo(e.id,{name:e.name,sequence:t,action:()=>({link:{label:e.name,url:Ze(e.id)},urlRepresentation:e.name,isUrlEditable:!1})})))));po`
202
203
  .o-link-editor {
203
204
  font-size: 13px;
204
205
  background-color: white;
@@ -268,7 +269,7 @@
268
269
  }
269
270
  }
270
271
  }
271
- `;class $o extends t.Component{constructor(){super(...arguments),this.menuItems=ko.getAll(),this.state=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Io(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getCell(i,e,t);return(null==o?void 0:o.isLink())?{link:{url:o.link.url,label:o.formattedValue},urlRepresentation:o.urlRepresentation,isUrlEditable:o.isUrlEditable}:{link:{url:"",label:(null==o?void 0:o.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(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.state.link.label||this.state.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:He(n,this.state.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.state.link.url&&this.save();break;case"Escape":this.cancel()}}}$o.template="o-spreadsheet-LinkEditor",$o.size={width:340,height:180},$o.components={Menu:Ao};const Lo={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:$o,cellCorner:"BottomLeft"})},Po=new ji;Po.add("ErrorToolTip",vo).add("LinkCell",Oo).add("LinkEditor",Lo).add("FilterMenu",Eo);const Uo=new ji,Vo=new ji,zo=new ji,Bo=(new ji).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of $e(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}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 oo.values())Bo.contains(e)||Bo.add(e,Ho);function Ho(e){return[e]}const Wo=[Ji.number,Ji.error,Ji.text,Ji.boolean];function Go(e,t){return{index:t,type:e?e.evaluated.type:Ji.empty,value:e?e.evaluated.value:""}}function qo(e,t,i,o,n){let s=ro.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let r=o.left;r<=o.right;r++){let o=e.model.getters.getMerge(t,r,n);o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);_i(i,o)?s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(r("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{o=i,s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(s.isCancelledBecause(62)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function Zo(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(r("This operation is not allowed with multiple selections."))}const jo={filterOverlap:r("You cannot create overlapping filters."),nonContinuousTargets:r("A filter can only be created on a continuous selection."),mergeInFilter:r("You can't create a filter over a range that contains a merge.")};function Xo(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(77)?e.raiseError(jo.filterOverlap):o.isCancelledBecause(79)?e.raiseError(jo.mergeInFilter):o.isCancelledBecause(80)&&e.raiseError(jo.nonContinuousTargets)}const Yo={wrongPasteSelection:r("This operation is not allowed with multiple selections."),willRemoveExistingMerge:r("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:r("Cannot do a special paste of a figure."),frozenPaneOverlap:r("Cannot paste merged cells over a frozen pane.")};function Ko(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Yo.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Yo.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Yo.wrongFigurePasteOption):t.reasons.includes(74)&&e.raiseError(Yo.frozenPaneOverlap))}function Qo(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Ko(e,o)}function Jo(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Ko(e,o)}function en(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function tn(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function on(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function nn(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}async function rn(e){try{return await e.clipboard.readText()}catch(e){return console.warn("The OS clipboard could not be read."),void console.error(e)}}const sn=async e=>{e.model.dispatch("COPY"),await e.clipboard.writeText(e.model.getters.getClipboardContent())},an=async e=>{Zo(e),await e.clipboard.writeText(e.model.getters.getClipboardContent())},ln=async e=>{const t=e.model.getters.getClipboardContent(),i=await rn(e),o=e.model.getters.getSelectedZones();i&&i!==t?Jo(e,o,i):Qo(e,o)},cn=async e=>{const t=e.model.getters.getClipboardContent(),i=await rn(e),o=e.model.getters.getSelectedZones();i&&i!==t?e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:o,text:i}):e.model.dispatch("PASTE",{target:e.model.getters.getSelectedZones(),pasteOption:"onlyValue"})},hn=e=>Qo(e,e.model.getters.getSelectedZones(),"onlyFormat"),dn=e=>!e.model.getters.isCutOperation(),un=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},gn=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},pn=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?r("Delete column %s",_t(t)):r("Delete columns %s - %s",_t(t),_t(i))},mn=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},fn=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Ko(e,i)},vn=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Ko(e,i)},bn=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Ko(e,i)},Sn=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Ko(e,i)},Cn=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},En=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},wn=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},yn=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})},xn=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},Rn=e=>{let{col:t,row:i}=e.model.getters.getPosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},In=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},Tn=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();qo(e,o,t.cell,i[0],"ascending")},An=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();qo(e,o,t.cell,i[0],"descending")},Mn=e=>1===e.model.getters.getSelectedZones().length,On=new Do;On.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:an}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:sn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ln}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:dn}).addChild("paste_value_only",["paste_special"],{name:r("Paste values only"),sequence:10,action:cn}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:hn}).add("add_row_before",{name:e=>{const t=tn(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},sequence:70,action:Cn,isVisible:Mn}).add("add_column_before",{name:e=>{const t=en(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},sequence:90,action:wn,isVisible:Mn}).add("insert_cell",{name:r("Insert cells"),sequence:100,isVisible:Mn,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:r("Shift down"),sequence:10,action:fn}).addChild("insert_cell_right",["insert_cell"],{name:r("Shift right"),sequence:20,action:vn}).add("delete_row",{name:un,sequence:110,action:gn,isVisible:Mn}).add("delete_column",{name:pn,sequence:120,action:mn,isVisible:Mn}).add("delete_cell",{name:r("Delete cells"),sequence:130,isVisible:Mn}).addChild("delete_cell_up",["delete_cell"],{name:r("Shift up"),sequence:10,action:bn}).addChild("delete_cell_down",["delete_cell"],{name:r("Shift left"),sequence:20,action:Sn}).add("insert_link",{name:r("Insert link"),separator:!0,sequence:150,action:Rn});const Nn=new Do;Nn.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:an}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:sn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ln}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:dn}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:cn}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:hn}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,isVisible:Mn,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:Tn}).addChild("sort_descending",["sort_columns"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:An}).add("add_column_before",{name:e=>{const t=en(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},sequence:70,action:wn}).add("add_column_after",{name:e=>{const t=en(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},sequence:80,action:yn}).add("delete_column",{name:pn,sequence:90,action:mn,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("COL");return e.model.getters.canRemoveHeaders(t,"COL",i)}}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?r("Clear column %s",_t(t)):r("Clear columns %s - %s",_t(t),_t(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?r("Hide column %s",_t(i).toString()):o-i+1===t.length?r("Hide columns %s - %s",_t(i).toString(),_t(o).toString()):r("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("COL");return e.model.getters.canRemoveHeaders(t,"COL",i)},separator:!0}).add("unhide_columns",{name:r("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:110,action:xn});const _n=new Do;function Fn(e,t,i){const o=e.model.getters.getSheetName(t),n=r("Rename Sheet");e.editText(n,(i=>{if(null===i||i===o)return;""===i&&Fn(e,t,r("The sheet name cannot be empty."));const n=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:i});n.isSuccessful||(n.reasons.includes(11)&&Fn(e,t,r("A sheet with the name %s already exists. Please select another name.",i)),n.reasons.includes(13)&&Fn(e,t,r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ee.join(" "))))}),{placeholder:o,error:i})}_n.add("cut",{name:r("Cut"),sequence:10,description:"Ctrl+X",action:an}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:sn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ln}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:dn}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:cn}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:hn}).add("add_row_before",{name:e=>{const t=tn(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},sequence:50,action:Cn}).add("add_row_after",{name:e=>{const t=tn(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},sequence:60,action:En}).add("delete_row",{name:un,sequence:70,action:gn,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("ROW");return e.model.getters.canRemoveHeaders(t,"ROW",i)}}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?r("Hide row %s",(i+1).toString()):o-i+1===t.length?r("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):r("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("ROW");return e.model.getters.canRemoveHeaders(t,"ROW",i)},separator:!0}).add("unhide_rows",{name:r("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:90,action:xn});const Dn=new Do;Dn.add("delete",{name:r("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(r("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:r("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}}).add("rename",{name:r("Rename"),sequence:30,action:e=>Fn(e,e.model.getters.getActiveSheetId())}).add("move_right",{name:r("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getVisibleSheetIds();return i.indexOf(t)!==i.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"right"})}).add("move_left",{name:r("Move left"),sequence:50,isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"left"})}).add("hide_sheet",{name:r("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})});const kn={Errors:{25:r("The range is invalid"),50:r("The argument is missing. Please provide a value"),51:r("The second argument is missing. Please provide a value"),52:r("The minpoint must be a number"),53:r("The midpoint must be a number"),54:r("The maxpoint must be a number"),55:r("The first value must be a number"),56:r("The second value must be a number"),46:r("Minimum must be smaller then Maximum"),49:r("Minimum must be smaller then Midpoint"),48:r("Midpoint must be smaller then Maximum"),47:r("Lower inflection point must be smaller than upper inflection point"),57:r("Invalid Minpoint formula"),59:r("Invalid Maxpoint formula"),58:r("Invalid Midpoint formula"),60:r("Invalid upper inflection point formula"),61:r("Invalid lower inflection point formula"),24:r("A range needs to be defined"),Unexpected:r("The rule is invalid for an unknown reason")},ColorScale:r("Color scale"),IconSet:r("Icon set")},$n={IsEmpty:r("Is empty"),IsNotEmpty:r("Is not empty"),ContainsText:r("Contains"),NotContains:r("Does not contain"),BeginsWith:r("Starts with"),EndsWith:r("Ends with"),Equal:r("Is equal to"),NotEqual:r("Is not equal to"),GreaterThan:r("Is greater than"),GreaterThanOrEqual:r("Is greater than or equal to"),LessThan:r("Is less than"),LessThanOrEqual:r("Is less than or equal to"),Between:r("Is between"),NotBetween:r("Is not between")},Ln={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),31:r("The dataset is invalid"),32:r("Labels are invalid"),33:r("The key value is invalid"),34:r("The baseline value is invalid"),35:r("The data range is invalid"),36:r("A minimum range limit value is needed"),37:r("The minimum range limit value must be a number"),38:r("A maximum range limit value is needed"),39:r("The maximum range limit value must be a number"),40:r("Minimum range limit must be smaller than maximum range limit"),41:r("The lower inflection point value must be a number"),42:r("The upper inflection point value must be a number")}},Pn={Automatic:r("Automatic"),Number:r("Number"),Percent:r("Percent"),Currency:r("Currency"),CurrencyRounded:r("Currency rounded"),Date:r("Date"),Time:r("Time"),DateTime:r("Date time"),Duration:r("Duration"),CustomCurrency:r("Custom currency")},Un={Custom:r("Custom")},Vn=r("Merged cells are preventing this operation. Unmerge those cells and try again.");function zn(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(64)&&e.raiseError(Vn)}const Bn=new Do;Bn.add("file",{name:r("File"),sequence:10}).add("edit",{name:r("Edit"),sequence:20}).add("view",{name:r("View"),sequence:30}).add("insert",{name:r("Insert"),sequence:40}).add("format",{name:r("Format"),sequence:50}).add("data",{name:r("Data"),sequence:60}).addChild("save",["file"],{name:r("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:r("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:r("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:r("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:sn}).addChild("cut",["edit"],{name:r("Cut"),description:"Ctrl+X",sequence:40,action:an}).addChild("paste",["edit"],{name:r("Paste"),description:"Ctrl+V",sequence:50,action:ln}).addChild("paste_special",["edit"],{name:r("Paste special"),sequence:60,separator:!0,isVisible:dn}).addChild("paste_special_value",["edit","paste_special"],{name:r("Paste value only"),sequence:10,action:cn}).addChild("paste_special_format",["edit","paste_special"],{name:r("Paste format only"),sequence:20,action:hn}).addChild("sort_range",["data"],{name:r("Sort range"),sequence:62,isVisible:Mn,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:Tn}).addChild("sort_descending",["data","sort_range"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:An}).addChild("find_and_replace",["edit"],{name:r("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:r("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:un,sequence:80,action:gn}).addChild("edit_delete_column",["edit"],{name:pn,sequence:90,action:mn}).addChild("edit_delete_cell_shift_up",["edit"],{name:r("Delete cell and shift up"),sequence:93,action:bn}).addChild("edit_delete_cell_shift_left",["edit"],{name:r("Delete cell and shift left"),sequence:97,action:Sn}).addChild("edit_unhide_columns",["edit"],{name:r("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:r("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=tn(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())},sequence:10,action:Cn,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=tn(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())},sequence:20,action:En,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=en(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())},sequence:30,action:wn,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=en(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},sequence:40,action:yn,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:r("Insert cells and shift down"),sequence:43,action:fn}).addChild("insert_insert_cell_shift_right",["insert"],{name:r("Insert cells and shift right"),sequence:47,action:vn,separator:!0}).addChild("insert_chart",["insert"],{name:r("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=t.getSelectedZone();let o=i;const n=e.model.uuidGenerator.uuidv4();let r;i.left!==i.right&&(o={...i,left:i.left+1});const s=[Ri(o)],a=t.getActiveSheetId(),l={width:536,height:335},{x:c,y:h}=t.getMainViewportCoordinates(),{scrollX:d,scrollY:u}=t.getActiveSheetScrollInfo(),{width:g,height:p}=t.getVisibleRect(t.getActiveMainViewport()),m={x:c+d+Math.max(0,(g-l.width)/2),y:h+u+Math.max(0,(p-l.height)/2)};let f="";const v=e.model.getters.getCellsInZone(a,{...o,bottom:o.top}),b=!!v.find((e=>e&&e.evaluated.type!==Ji.number));if(b){const t=v.reduce(((t,i)=>{const o=i&&i.evaluated.type!==Ji.error&&e.model.getters.getCellText(i);return o&&t.push(o),t}),[]),i=t.splice(-1)[0];f=t.join(", "),i&&(f+=(f?" "+e._t("and")+" ":"")+i)}i.left!==i.right&&(r=Ri({...i,right:i.left,top:b?i.top+1:i.top}));const S=o.right===o.left?"none":"top";e.model.dispatch("CREATE_CHART",{sheetId:a,id:n,position:m,size:l,definition:{title:f,dataSets:s,labelRange:r,type:"bar",stacked:!1,dataSetsHaveTitle:b,verticalAxisPosition:"left",legendPosition:S}}),e.model.dispatch("SELECT_FIGURE",{id:n}),e.openSidePanel("ChartPanel")}}).addChild("insert_link",["insert"],{name:r("Link"),separator:!0,sequence:60,action:Rn}).addChild("insert_sheet",["insert"],{name:r("New sheet"),sequence:70,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:r("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:r("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:r("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:r("1 row"),action:e=>zn(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:r("2 rows"),action:e=>zn(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:r("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();zn(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:r("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:r("1 column"),action:e=>zn(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:r("2 columns"),action:e=>zn(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:r("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();zn(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:r("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Pn.Automatic,sequence:10,separator:!0,action:e=>on(e,"")}).addChild("format_number_number",["format","format_number"],{name:Pn.Number,description:"1,000.12",sequence:20,action:e=>on(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Pn.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>on(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Pn.Currency,description:"$1,000.12",sequence:37,action:e=>on(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Pn.CurrencyRounded,description:"$1,000",sequence:38,action:e=>on(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Pn.CustomCurrency,sequence:39,separator:!0,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Pn.Date,description:"9/26/2008",sequence:40,action:e=>on(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Pn.Time,description:"10:43:00 PM",sequence:50,action:e=>on(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Pn.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>on(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Pn.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>on(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:r("Bold"),sequence:20,description:"Ctrl+B",action:e=>nn(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:r("Italic"),sequence:30,description:"Ctrl+I",action:e=>nn(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:r("Underline"),description:"Ctrl+U",sequence:40,action:e=>nn(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:r("Strikethrough"),sequence:50,action:e=>nn(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:r("Font size"),sequence:60}).addChild("format_wrapping",["format"],{name:r("Wrapping"),sequence:70,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:r("Overflow"),sequence:10,action:e=>nn(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:r("Wrap"),sequence:20,action:e=>nn(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:r("Clip"),sequence:30,action:e=>nn(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:r("Conditional formatting"),sequence:80,action:xn,separator:!0}).addChild("format_clearFormat",["format"],{name:r("Clear formatting"),sequence:90,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:r("Add Filter"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;Xo(e,t,i)},isVisible:e=>!In(e),isEnabled:e=>(e=>Zi(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:r("Remove Filter"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:In});for(let e of re)Bn.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>nn(t,{fontSize:e.pt})});const Hn=new class extends ji{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},Wn=new Ei;go`
272
+ `;class Lo extends t.Component{constructor(){super(...arguments),this.menuItems=$o.getAll(),this.state=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=To(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getCell(i,e,t);return(null==o?void 0:o.isLink())?{link:{url:o.link.url,label:o.formattedValue},urlRepresentation:o.urlRepresentation,isUrlEditable:o.isUrlEditable}:{link:{url:"",label:(null==o?void 0:o.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(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.state.link.label||this.state.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:He(n,this.state.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.state.link.url&&this.save();break;case"Escape":this.cancel()}}}Lo.template="o-spreadsheet-LinkEditor",Lo.size={width:340,height:180},Lo.components={Menu:Oo};const Po={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Lo,cellCorner:"BottomLeft"})},Uo=new Xi;Uo.add("ErrorToolTip",bo).add("LinkCell",No).add("LinkEditor",Po).add("FilterMenu",wo);const Vo=new Xi,zo=new Xi,Bo=new Xi,Ho=(new Xi).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of $e(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}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 no.values())Ho.contains(e)||Ho.add(e,Wo);function Wo(e){return[e]}const Go=[eo.number,eo.error,eo.text,eo.boolean];function qo(e,t){return{index:t,type:e?e.evaluated.type:eo.empty,value:e?e.evaluated.value:""}}function Zo(e,t,i,o,n){let s=so.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let r=o.left;r<=o.right;r++){let o=e.model.getters.getMerge(t,r,n);o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);Fi(i,o)?s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(r("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{o=i,s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(s.isCancelledBecause(62)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function jo(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(r("This operation is not allowed with multiple selections."))}const Xo={filterOverlap:r("You cannot create overlapping filters."),nonContinuousTargets:r("A filter can only be created on a continuous selection."),mergeInFilter:r("You can't create a filter over a range that contains a merge.")};function Yo(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(77)?e.raiseError(Xo.filterOverlap):o.isCancelledBecause(79)?e.raiseError(Xo.mergeInFilter):o.isCancelledBecause(80)&&e.raiseError(Xo.nonContinuousTargets)}const Ko={wrongPasteSelection:r("This operation is not allowed with multiple selections."),willRemoveExistingMerge:r("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:r("Cannot do a special paste of a figure."),frozenPaneOverlap:r("Cannot paste merged cells over a frozen pane.")};function Qo(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Ko.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Ko.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Ko.wrongFigurePasteOption):t.reasons.includes(74)&&e.raiseError(Ko.frozenPaneOverlap))}function Jo(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Qo(e,o)}function en(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Qo(e,o)}function tn(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function on(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function nn(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function rn(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}async function sn(e){try{return await e.clipboard.readText()}catch(e){return console.warn("The OS clipboard could not be read."),void console.error(e)}}const an=async e=>{e.model.dispatch("COPY"),await e.clipboard.writeText(e.model.getters.getClipboardContent())},ln=async e=>{jo(e),await e.clipboard.writeText(e.model.getters.getClipboardContent())},cn=async e=>{const t=e.model.getters.getClipboardContent(),i=await sn(e),o=e.model.getters.getSelectedZones();i&&i!==t?en(e,o,i):Jo(e,o)},hn=async e=>{const t=e.model.getters.getClipboardContent(),i=await sn(e),o=e.model.getters.getSelectedZones();i&&i!==t?e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:o,text:i}):e.model.dispatch("PASTE",{target:e.model.getters.getSelectedZones(),pasteOption:"onlyValue"})},dn=e=>Jo(e,e.model.getters.getSelectedZones(),"onlyFormat"),un=e=>!e.model.getters.isCutOperation(),gn=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},pn=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},mn=(e,t)=>{const i=t.model.getters.getActiveSheetId(),o=t.model.getters.getElementsFromSelection(e),n=t.model.getters.checkElementsIncludeAllVisibleHeaders(i,e,o),r=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(i,e,o);return!n&&!r},fn=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?r("Delete column %s",Ft(t)):r("Delete columns %s - %s",Ft(t),Ft(i))},vn=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},bn=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Qo(e,i)},Sn=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Qo(e,i)},Cn=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Qo(e,i)},En=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Qo(e,i)},wn=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},yn=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},xn=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},Rn=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})},In=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},Tn=e=>{let{col:t,row:i}=e.model.getters.getPosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},An=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},On=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();Zo(e,o,t.cell,i[0],"ascending")},Mn=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();Zo(e,o,t.cell,i[0],"descending")},Nn=e=>1===e.model.getters.getSelectedZones().length,_n=new ko;_n.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:ln}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:an}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:cn}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:un}).addChild("paste_value_only",["paste_special"],{name:r("Paste values only"),sequence:10,action:hn}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:dn}).add("add_row_before",{name:e=>{const t=on(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},sequence:70,action:wn,isVisible:Nn}).add("add_column_before",{name:e=>{const t=tn(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},sequence:90,action:xn,isVisible:Nn}).add("insert_cell",{name:r("Insert cells"),sequence:100,isVisible:Nn,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:r("Shift down"),sequence:10,action:bn}).addChild("insert_cell_right",["insert_cell"],{name:r("Shift right"),sequence:20,action:Sn}).add("delete_row",{name:gn,sequence:110,action:pn,isVisible:Nn}).add("delete_column",{name:fn,sequence:120,action:vn,isVisible:Nn}).add("delete_cell",{name:r("Delete cells"),sequence:130,isVisible:Nn}).addChild("delete_cell_up",["delete_cell"],{name:r("Shift up"),sequence:10,action:Cn}).addChild("delete_cell_down",["delete_cell"],{name:r("Shift left"),sequence:20,action:En}).add("insert_link",{name:r("Insert link"),separator:!0,sequence:150,action:Tn});const Fn=new ko;Fn.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:ln}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:an}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:cn}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:un}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:hn}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:dn}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,isVisible:Nn,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:On}).addChild("sort_descending",["sort_columns"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Mn}).add("add_column_before",{name:e=>{const t=tn(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},sequence:70,action:xn}).add("add_column_after",{name:e=>{const t=tn(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},sequence:80,action:Rn}).add("delete_column",{name:fn,sequence:90,action:vn,isVisible:e=>mn("COL",e)}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?r("Clear column %s",Ft(t)):r("Clear columns %s - %s",Ft(t),Ft(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?r("Hide column %s",Ft(i).toString()):o-i+1===t.length?r("Hide columns %s - %s",Ft(i).toString(),Ft(o).toString()):r("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",i)},separator:!0}).add("unhide_columns",{name:r("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:110,action:In});const Dn=new ko;function kn(e,t,i){const o=e.model.getters.getSheetName(t),n=r("Rename Sheet");e.editText(n,(i=>{if(null===i||i===o)return;""===i&&kn(e,t,r("The sheet name cannot be empty."));const n=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:i});n.isSuccessful||(n.reasons.includes(11)&&kn(e,t,r("A sheet with the name %s already exists. Please select another name.",i)),n.reasons.includes(13)&&kn(e,t,r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ee.join(" "))))}),{placeholder:o,error:i})}Dn.add("cut",{name:r("Cut"),sequence:10,description:"Ctrl+X",action:ln}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:an}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:cn}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:un}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:hn}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:dn}).add("add_row_before",{name:e=>{const t=on(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},sequence:50,action:wn}).add("add_row_after",{name:e=>{const t=on(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},sequence:60,action:yn}).add("delete_row",{name:gn,sequence:70,action:pn,isVisible:e=>mn("ROW",e)}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?r("Hide row %s",(i+1).toString()):o-i+1===t.length?r("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):r("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",i)},separator:!0}).add("unhide_rows",{name:r("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:90,action:In});const $n=new ko;$n.add("delete",{name:r("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(r("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:r("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}}).add("rename",{name:r("Rename"),sequence:30,action:e=>kn(e,e.model.getters.getActiveSheetId())}).add("move_right",{name:r("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getVisibleSheetIds();return i.indexOf(t)!==i.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"right"})}).add("move_left",{name:r("Move left"),sequence:50,isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"left"})}).add("hide_sheet",{name:r("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})});const Ln={Errors:{25:r("The range is invalid"),50:r("The argument is missing. Please provide a value"),51:r("The second argument is missing. Please provide a value"),52:r("The minpoint must be a number"),53:r("The midpoint must be a number"),54:r("The maxpoint must be a number"),55:r("The first value must be a number"),56:r("The second value must be a number"),46:r("Minimum must be smaller then Maximum"),49:r("Minimum must be smaller then Midpoint"),48:r("Midpoint must be smaller then Maximum"),47:r("Lower inflection point must be smaller than upper inflection point"),57:r("Invalid Minpoint formula"),59:r("Invalid Maxpoint formula"),58:r("Invalid Midpoint formula"),60:r("Invalid upper inflection point formula"),61:r("Invalid lower inflection point formula"),24:r("A range needs to be defined"),Unexpected:r("The rule is invalid for an unknown reason")},ColorScale:r("Color scale"),IconSet:r("Icon set")},Pn={IsEmpty:r("Is empty"),IsNotEmpty:r("Is not empty"),ContainsText:r("Contains"),NotContains:r("Does not contain"),BeginsWith:r("Starts with"),EndsWith:r("Ends with"),Equal:r("Is equal to"),NotEqual:r("Is not equal to"),GreaterThan:r("Is greater than"),GreaterThanOrEqual:r("Is greater than or equal to"),LessThan:r("Is less than"),LessThanOrEqual:r("Is less than or equal to"),Between:r("Is between"),NotBetween:r("Is not between")},Un={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),31:r("The dataset is invalid"),32:r("Labels are invalid"),33:r("The key value is invalid"),34:r("The baseline value is invalid"),35:r("The data range is invalid"),36:r("A minimum range limit value is needed"),37:r("The minimum range limit value must be a number"),38:r("A maximum range limit value is needed"),39:r("The maximum range limit value must be a number"),40:r("Minimum range limit must be smaller than maximum range limit"),41:r("The lower inflection point value must be a number"),42:r("The upper inflection point value must be a number")}},Vn={Automatic:r("Automatic"),Number:r("Number"),Percent:r("Percent"),Currency:r("Currency"),CurrencyRounded:r("Currency rounded"),Date:r("Date"),Time:r("Time"),DateTime:r("Date time"),Duration:r("Duration"),CustomCurrency:r("Custom currency")},zn={Custom:r("Custom")},Bn=r("Merged cells are preventing this operation. Unmerge those cells and try again.");function Hn(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(64)&&e.raiseError(Bn)}const Wn=new ko;Wn.add("file",{name:r("File"),sequence:10}).add("edit",{name:r("Edit"),sequence:20}).add("view",{name:r("View"),sequence:30}).add("insert",{name:r("Insert"),sequence:40}).add("format",{name:r("Format"),sequence:50}).add("data",{name:r("Data"),sequence:60}).addChild("save",["file"],{name:r("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:r("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:r("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:r("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:an}).addChild("cut",["edit"],{name:r("Cut"),description:"Ctrl+X",sequence:40,action:ln}).addChild("paste",["edit"],{name:r("Paste"),description:"Ctrl+V",sequence:50,action:cn}).addChild("paste_special",["edit"],{name:r("Paste special"),sequence:60,separator:!0,isVisible:un}).addChild("paste_special_value",["edit","paste_special"],{name:r("Paste value only"),sequence:10,action:hn}).addChild("paste_special_format",["edit","paste_special"],{name:r("Paste format only"),sequence:20,action:dn}).addChild("sort_range",["data"],{name:r("Sort range"),sequence:62,isVisible:Nn,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:On}).addChild("sort_descending",["data","sort_range"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Mn}).addChild("find_and_replace",["edit"],{name:r("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:r("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:gn,sequence:80,action:pn,isVisible:e=>mn("ROW",e)}).addChild("edit_delete_column",["edit"],{name:fn,sequence:90,action:vn,isVisible:e=>mn("COL",e)}).addChild("edit_delete_cell_shift_up",["edit"],{name:r("Delete cell and shift up"),sequence:93,action:Cn}).addChild("edit_delete_cell_shift_left",["edit"],{name:r("Delete cell and shift left"),sequence:97,action:En}).addChild("edit_unhide_columns",["edit"],{name:r("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:r("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=on(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())},sequence:10,action:wn,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=on(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())},sequence:20,action:yn,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=tn(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())},sequence:30,action:xn,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=tn(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},sequence:40,action:Rn,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:r("Insert cells and shift down"),sequence:43,action:bn}).addChild("insert_insert_cell_shift_right",["insert"],{name:r("Insert cells and shift right"),sequence:47,action:Sn,separator:!0}).addChild("insert_chart",["insert"],{name:r("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=t.getSelectedZone();let o=i;const n=e.model.uuidGenerator.uuidv4();let r;i.left!==i.right&&(o={...i,left:i.left+1});const s=[Ii(o)],a=t.getActiveSheetId(),l={width:536,height:335},{x:c,y:h}=t.getMainViewportCoordinates(),{scrollX:d,scrollY:u}=t.getActiveSheetScrollInfo(),{width:g,height:p}=t.getVisibleRect(t.getActiveMainViewport()),m={x:c+d+Math.max(0,(g-l.width)/2),y:h+u+Math.max(0,(p-l.height)/2)};let f="";const v=e.model.getters.getCellsInZone(a,{...o,bottom:o.top}),b=!!v.find((e=>e&&e.evaluated.type!==eo.number));if(b){const t=v.reduce(((t,i)=>{const o=i&&i.evaluated.type!==eo.error&&e.model.getters.getCellText(i);return o&&t.push(o),t}),[]),i=t.splice(-1)[0];f=t.join(", "),i&&(f+=(f?" "+e._t("and")+" ":"")+i)}i.left!==i.right&&(r=Ii({...i,right:i.left,top:b?i.top+1:i.top}));const S=o.right===o.left?"none":"top";e.model.dispatch("CREATE_CHART",{sheetId:a,id:n,position:m,size:l,definition:{title:f,dataSets:s,labelRange:r,type:"bar",stacked:!1,dataSetsHaveTitle:b,verticalAxisPosition:"left",legendPosition:S}}),e.model.dispatch("SELECT_FIGURE",{id:n}),e.openSidePanel("ChartPanel")}}).addChild("insert_link",["insert"],{name:r("Link"),separator:!0,sequence:60,action:Tn}).addChild("insert_sheet",["insert"],{name:r("New sheet"),sequence:70,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:r("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:r("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:r("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:r("1 row"),action:e=>Hn(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:r("2 rows"),action:e=>Hn(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:r("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Hn(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:r("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:r("1 column"),action:e=>Hn(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:r("2 columns"),action:e=>Hn(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:r("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();Hn(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:r("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Vn.Automatic,sequence:10,separator:!0,action:e=>nn(e,"")}).addChild("format_number_number",["format","format_number"],{name:Vn.Number,description:"1,000.12",sequence:20,action:e=>nn(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Vn.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>nn(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Vn.Currency,description:"$1,000.12",sequence:37,action:e=>nn(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Vn.CurrencyRounded,description:"$1,000",sequence:38,action:e=>nn(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Vn.CustomCurrency,sequence:39,separator:!0,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Vn.Date,description:"9/26/2008",sequence:40,action:e=>nn(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Vn.Time,description:"10:43:00 PM",sequence:50,action:e=>nn(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Vn.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>nn(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Vn.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>nn(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:r("Bold"),sequence:20,description:"Ctrl+B",action:e=>rn(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:r("Italic"),sequence:30,description:"Ctrl+I",action:e=>rn(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:r("Underline"),description:"Ctrl+U",sequence:40,action:e=>rn(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:r("Strikethrough"),sequence:50,action:e=>rn(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:r("Font size"),sequence:60}).addChild("format_wrapping",["format"],{name:r("Wrapping"),sequence:70,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:r("Overflow"),sequence:10,action:e=>rn(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:r("Wrap"),sequence:20,action:e=>rn(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:r("Clip"),sequence:30,action:e=>rn(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:r("Conditional formatting"),sequence:80,action:In,separator:!0}).addChild("format_clearFormat",["format"],{name:r("Clear formatting"),sequence:90,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:r("Add Filter"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;Yo(e,t,i)},isVisible:e=>!An(e),isEnabled:e=>(e=>ji(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:r("Remove Filter"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:An});for(let e of re)Wn.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>rn(t,{fontSize:e.pt})});const Gn=new class extends Xi{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},qn=new wi;po`
272
273
  .o-selection {
273
274
  .o-selection-input {
274
275
  display: flex;
@@ -318,7 +319,7 @@
318
319
  font-size: calc(100% + 4px);
319
320
  }
320
321
  }
321
- `;class Gn extends t.Component{constructor(){super(...arguments),this.id=Wn.uuidv4(),this.previousRanges=this.props.ranges||[],this.originSheet=this.env.model.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1})}get ranges(){const e=this.env.model.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges?this.props.ranges.map(((e,t)=>({xc:e,id:t.toString(),isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.env.model.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}setup(){t.onMounted((()=>this.enableNewSelectionInput())),t.onWillUnmount((async()=>this.disableNewSelectionInput())),t.onPatched((()=>this.checkChange()))}enableNewSelectionInput(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges,hasSingleRange:this.props.hasSingleRange})}disableNewSelectionInput(){this.env.model.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}checkChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){var e,t;const i=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,i),this.previousRanges=i}extractRanges(e){return this.props.hasSingleRange?e.split(",")[0]:e}focus(e){this.state.isMissing=!1,this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){var t,i;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(i=(t=this.props).onSelectionConfirmed)||void 0===i||i.call(t)}onInputChanged(e,t){const i=t.target,o=this.extractRanges(i.value);this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:o}),i.blur(),this.triggerChange()}confirm(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const i=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===i.length&&(this.state.isMissing=!0);const o=this.env.model.getters.getActiveSheetId();this.originSheet!==o&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}Gn.template="o-spreadsheet-SelectionInput";class qn extends t.Component{constructor(){super(...arguments),this.state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0}),this.dataSeriesRanges=[]}setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}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=>Ln.Errors[e]||Ln.Errors.Unexpected))}get isDatasetInvalid(){var e;return!!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(31))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(32))}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.figureId,{dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.figureId,{labelRange:this.labelRange})}}qn.template="o-spreadsheet-LineBarPieConfigPanel",qn.components={SelectionInput:Gn};class Zn extends qn{onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}}Zn.template="o-spreadsheet-BarConfigPanel";class jn{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function Xn(e){return 8===(e=ut(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}function Yn(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Mi(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Ii(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Kn(e,t,i,o){let n=!1;const r=[];for(let o in i){let s=i[o];if(s.labelCell){const e=er(s.labelCell,t);s.labelCell!==e&&(n=!0,s={...s,labelCell:e})}const a=er(s.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Y?(n=!0,s=void 0):a!==s.dataRange&&(n=!0,s={...s,dataRange:a}),r[o]=s}let s=o;const a=er(s,t);a!==s&&(n=!0,s=a);return{isStale:n,dataSets:r.filter(Xe),labelRange:s}}function Qn(e,t,i){return i.map((i=>({dataRange:bi(e,t,i.dataRange),labelCell:i.labelCell?bi(e,t,i.labelCell):void 0})))}function Jn(e,t,i){return i?bi(e,t,i):void 0}function er(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function tr(e,t,i,o){const n=[];for(const r of t){const t=e.getRangeFromSheetXC(i,r),{unboundedZone:s,sheetId:a,invalidSheetName:l}=t;if(!l)if(s.left!==s.right&&s.top!==s.bottom){if(void 0===s.right)continue;for(let t=s.left;t<=s.right;t++){const i={...s,left:t,right:t};n.push(ir(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else s.left===s.right&&s.top===s.bottom?o||n.push(ir(e,a,s,void 0)):n.push(ir(e,a,s,o?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0))}return n}function ir(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${Ri(i)}`);if(o){const n=Ri(i),r=Ri(o);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Ri(i))}}function or(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{height:e,width:t}=Pi(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const r=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(r,"forceSheetReference")}}function nr(e,t){let i;if(e.labelRange){const o=Yn(wi(e.labelRange),t);i=o?Ri(o):void 0}const o=e.dataSets.map(wi).map((e=>Yn(e,t))).filter(Xe).map(Ri);return{...e,labelRange:i,dataSets:o}}const rr=["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 sr{constructor(){this.graphColorIndex=0}next(){return rr[this.graphColorIndex++%rr.length]}}function ar(e){return e&&ft(e)<.3?"#FFFFFF":"#000000"}function lr(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!It.test(e)));if(t)return 31;if(e.dataSets.map(wi).some((e=>e.top!==e.bottom&&Gi(e))))return 31}return 0}function cr(e){if(e.labelRange){if(!It.test(e.labelRange||""))return 32}return 0}function hr(e,t,i){const o=null==e?void 0:e.evaluated;if(e&&void 0!==o){if("text"===i||(null==t?void 0:t.type)!==Ji.number||o.type!==Ji.number)return e.formattedValue;{let e=t.value-o.value;if("percentage"===i&&0!==e&&(e=e/o.value*100),"percentage"!==i&&o.format)return Gt(e,o.format);const n=Math.abs(parseFloat(e.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function dr(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==Ji.number||(null==i?void 0:i.type)!==Ji.number)return;const r=i.value-e.value;return r>0?o:r<0?n:void 0}function ur(e,t,i){if("text"===i||(null==e?void 0:e.type)!==Ji.number||(null==t?void 0:t.type)!==Ji.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}function gr(e,t){if(t.dataRange){const i=t.labelCell?[Ri(t.labelCell.zone)]:[],o=$i([Ri(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n)}return[]}function pr(e,t){const i=ke(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function mr(e){return e?e.length>Q?e.substring(0,Q)+"…":e:""}function fr(e,t,i){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:i},legend:{onClick:void 0}},data:{labels:t.map(mr),datasets:[]}}}function vr(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>null!=e?String(e):""))});else if(1===t.length)for(let i=0;i<gr(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:ke(0,gr(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function br(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,r=i?e.getCell(i.sheetId,i.zone.left,i.zone.top):void 0;t=r&&i?mr(r.formattedValue):t=`${Ln.Series} ${parseInt(o)+1}`}else t=t=`${Ln.Series} ${parseInt(o)+1}`;let r=n.dataRange?gr(e,n):[];i.push({data:r,label:t})}return i}function Sr(e){return 0===e?"origin":e-1}Xi.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new Cr(e,t,i),getChartRuntime:function(e,t){let i=vr(t,e.dataSets,e.labelRange).formattedValues,o=br(t,e.dataSets);({labels:i,dataSetsValues:o}=pr(i,o));const n=function(e,t){var i;const o=ar(e.background),n=fr(e,t,o),r={labels:{fontColor:o}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;n.options.legend={...null===(i=n.options)||void 0===i?void 0:i.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:o}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:o,beginAtZero:!0}}]},e.stacked&&(n.options.scales.xAxes[0].stacked=!0,n.options.scales.yAxes[0].stacked=!0);return n}(e,i),r=new sr;for(let{label:e,data:t}of o){const i=r.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>Cr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Cr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Cr.getDefinitionFromContextCreation(e),name:r("Bar")});class Cr extends jn{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=tr(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Si(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked}static transformDefinition(e,t){return nr(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,lr,cr)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=Qn(this.sheetId,e,this.dataSets),i=Jn(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Cr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Cr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked}}getDefinitionForExcel(){const e=this.dataSets.map((e=>or(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Xn(this.background||w),fontColor:Xn(ar(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Kn(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Cr(n,this.sheetId,this.getters)}}function Er(e,t){const i=Xi.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function wr(e){return e.dataRange&&!It.test(e.dataRange)?35:0}function yr(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function xr(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?40:0}function Rr(e,t){if(""===e)switch(t){case"rangeMin":return 36;case"rangeMax":return 38}return 0}function Ir(e,t){if(isNaN(e))switch(t){case"rangeMin":return 37;case"rangeMax":return 39;case"lowerInflectionPointValue":return 41;case"upperInflectionPointValue":return 42}return 0}Xi.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new Tr(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=ar(e.background),i=fr(e,[],t);return i.options.hover=void 0,i.options.events=[],i.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},i.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},i.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},i}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,s=Number(n.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?s:l+h*s/100;d.push({value:Oe(e,l,c),color:o.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:Oe(e,l,c),color:o.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getCell(p.sheetId,p.zone.left,p.zone.top);(null==e?void 0:e.evaluated.type)===Ji.number&&(f=Oe(null==e?void 0:e.evaluated.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>Tr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Tr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Tr.getDefinitionFromContextCreation(e),name:r("Gauge")});class Tr extends jn{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=Si(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,wr,e.chainValidations(yr(Rr,e.batchValidations),yr(Ir,e.batchValidations),xr),e.chainValidations((i=Ir,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=Yn(wi(e.dataRange),t)),{...e,dataRange:i?Ri(i):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=Jn(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new Tr(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Tr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=er(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new Tr(i,this.sheetId,this.getters)}}const Ar={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Mr={inSeconds:function(e){return Math.floor(e/Ar.second)},inMinutes:function(e){return Math.floor(e/Ar.minute)},inHours:function(e){return Math.floor(e/Ar.hour)},inDays:function(e){return Math.floor(e/Ar.day)},inMonths:function(e){return Math.floor(e/Ar.month)},inYears:function(e){return Math.floor(e/Ar.year)}},Or=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Nr(e,t){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),o=function(e,t){const i=e.map((e=>{var t;return null===(t=me(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),r=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(Ar.second>=Ar[r]&&Mr.inSeconds(n)<180)return"second";if(Ar.minute>=Ar[r]&&Mr.inMinutes(n)<180)return"minute";if(Ar.hour>=Ar[r]&&Mr.inHours(n)<96)return"hour";if(Ar.day>=Ar[r]&&Mr.inDays(n)<90)return"day";if(Ar.month>=Ar[r]&&Mr.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}Xi.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new _r(e,t,i),getChartRuntime:function(e,t){const i=function(e,t){if(function(e,t){return!e.labelsAsText&&Fr(e,t)}(e,t))return"time";if(function(e,t){return!e.labelsAsText&&Dr(e,t)}(e,t))return"linear";return"category"}(e,t),o=vr(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,r=br(t,e.dataSets);({labels:n,dataSetsValues:r}=pr(n,r)),"time"===i&&({labels:n,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=Te(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=it(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,r));const s=function(e,t){var i;const o=ar(e.background),n=fr(e,t,o),r={labels:{fontColor:o,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;n.options.legend={...null===(i=n.options)||void 0===i?void 0:i.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:o}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:o,beginAtZero:!0}}]},e.stacked&&(n.options.scales.yAxes[0].stacked=!0);return n}(e,n),a=function(e,t){var i;if(t)return null===(i=e.getCell(t.sheetId,t.zone.left,t.zone.top))||void 0===i?void 0:i.evaluated.format}(t,e.labelRange);"time"===i?(s.options.scales.xAxes[0].type="time",s.options.scales.xAxes[0].time=Nr(n,a),s.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(s.options.scales.xAxes[0].type="linear",s.options.scales.xAxes[0].ticks.callback=e=>Gt(e,a));const l=new sr;for(let[t,{label:o,data:a}]of r.entries()){["linear","time"].includes(i)&&(a=a.map(((e,t)=>({x:n[t]||void 0,y:e}))));const r=l.next();let c=bt(r);e.stacked&&(c.a=J);const h={label:o,data:a,lineTension:0,borderColor:r,backgroundColor:vt(c),pointBackgroundColor:r,fill:!!e.stacked&&Sr(t)};s.data.datasets.push(h)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>_r.validateChartDefinition(e,t),transformDefinition:(e,t)=>_r.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>_r.getDefinitionFromContextCreation(e),name:r("Line")});class _r extends jn{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=tr(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Si(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked}static validateChartDefinition(e,t){return e.checkValidations(t,lr,cr)}static transformDefinition(e,t){return nr(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Kn(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new _r(n,this.sheetId,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>or(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Xn(this.background||w),fontColor:Xn(ar(this.background)),dataSets:e}}copyForSheetId(e){const t=Qn(this.sheetId,e,this.dataSets),i=Jn(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new _r(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new _r(t,e,this.getters)}}function Fr(e,t){var i;if(!e.labelRange||!e.dataSets||!Dr(e,t))return!1;const o=null===(i=t.getCell(e.labelRange.sheetId,e.labelRange.zone.left,e.labelRange.zone.top))||void 0===i?void 0:i.evaluated.format;return Boolean(o&&Or.test(o))}function Dr(e,t){if(!e.labelRange||!e.dataSets)return!1;const i=t.getRangeValues(e.labelRange);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}Xi.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new kr(e,t,i),getChartRuntime:function(e,t){let i=vr(t,e.dataSets,e.labelRange).formattedValues,o=br(t,e.dataSets);({labels:i,dataSetsValues:o}=pr(i,o));const n=function(e,t){var i;const o=ar(e.background),n=fr(e,t,o),r={labels:{fontColor:o}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;return n.options.legend={...null===(i=n.options)||void 0===i?void 0:i.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},n}(e,i),r=new sr;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:$r(r,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>kr.validateChartDefinition(e,t),transformDefinition:(e,t)=>kr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>kr.getDefinitionFromContextCreation(e),name:r("Pie")});class kr extends jn{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=tr(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Si(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition}static transformDefinition(e,t){return nr(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,lr,cr)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title}}copyForSheetId(e){const t=Qn(this.sheetId,e,this.dataSets),i=Jn(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new kr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new kr(t,e,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>or(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Xn(this.background||w),fontColor:Xn(ar(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Kn(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new kr(n,this.sheetId,this.getters)}}function $r(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function Lr(e){return e.keyValue&&!It.test(e.keyValue)?33:0}function Pr(e){return e.baseline&&!It.test(e.baseline)?34:0}Xi.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new Ur(e,t,i),getChartRuntime:function(e,t){let i,o,r="",s="";if(e.keyValue){const o=e.keyValue.zone;i=t.getCell(e.keyValue.sheetId,o.left,o.top),r=(null==i?void 0:i.evaluated.value)?String(null==i?void 0:i.evaluated.value):"",s=(null==i?void 0:i.formattedValue)||""}if(e.baseline){const i=e.baseline.zone;o=t.getCell(e.baseline.sheetId,i.left,i.top)}const a=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:s||r,baselineDisplay:hr(o,null==i?void 0:i.evaluated,e.baselineMode),baselineArrow:ur(null==o?void 0:o.evaluated,null==i?void 0:i.evaluated,e.baselineMode),baselineColor:dr(null==o?void 0:o.evaluated,e.baselineMode,null==i?void 0:i.evaluated,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:ar(a),background:a,baselineStyle:"percentage"!==e.baselineMode?null==o?void 0:o.style:void 0,keyValueStyle:null==i?void 0:i.style}},validateChartDefinition:(e,t)=>Ur.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ur.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ur.getDefinitionFromContextCreation(e),name:r("Scorecard")});class Ur extends jn{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=Si(i,t,e.keyValue),this.baseline=Si(i,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Lr,Pr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:"difference",baselineColorUp:"#00A04A",baselineColorDown:"#DC6965",baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=Yn(wi(e.baseline),t)),e.keyValue&&(o=Yn(wi(e.keyValue),t)),{...e,baseline:i?Ri(i):void 0,keyValue:o?Ri(o):void 0}}copyForSheetId(e){const t=Jn(this.sheetId,e,this.baseline),i=Jn(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new Ur(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new Ur(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=er(this.baseline,e),i=er(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new Ur(o,this.sheetId,this.getters)}}const Vr=218,zr=182;function Br(e){return vt(St({h:360*e.offsetX/Vr,s:100,l:100*e.offsetY/zr,a:1}))}go`
322
+ `;class Zn extends t.Component{constructor(){super(...arguments),this.id=qn.uuidv4(),this.previousRanges=this.props.ranges||[],this.originSheet=this.env.model.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1})}get ranges(){const e=this.env.model.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges?this.props.ranges.map(((e,t)=>({xc:e,id:t.toString(),isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.env.model.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}setup(){t.onMounted((()=>this.enableNewSelectionInput())),t.onWillUnmount((async()=>this.disableNewSelectionInput())),t.onPatched((()=>this.checkChange()))}enableNewSelectionInput(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges,hasSingleRange:this.props.hasSingleRange})}disableNewSelectionInput(){this.env.model.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}checkChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){var e,t;const i=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,i),this.previousRanges=i}extractRanges(e){return this.props.hasSingleRange?e.split(",")[0]:e}focus(e){this.state.isMissing=!1,this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){var t,i;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(i=(t=this.props).onSelectionConfirmed)||void 0===i||i.call(t)}onInputChanged(e,t){const i=t.target,o=this.extractRanges(i.value);this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:o}),i.blur(),this.triggerChange()}confirm(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const i=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===i.length&&(this.state.isMissing=!0);const o=this.env.model.getters.getActiveSheetId();this.originSheet!==o&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}Zn.template="o-spreadsheet-SelectionInput";class jn extends t.Component{constructor(){super(...arguments),this.state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0}),this.dataSeriesRanges=[]}setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}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=>Un.Errors[e]||Un.Errors.Unexpected))}get isDatasetInvalid(){var e;return!!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(31))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(32))}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.figureId,{dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.figureId,{labelRange:this.labelRange})}}jn.template="o-spreadsheet-LineBarPieConfigPanel",jn.components={SelectionInput:Zn};class Xn extends jn{onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}}Xn.template="o-spreadsheet-BarConfigPanel";class Yn{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function Kn(e){return 8===(e=gt(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}function Qn(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Mi(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Ti(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Jn(e,t,i,o){let n=!1;const r=[];for(let o in i){let s=i[o];if(s.labelCell){const e=ir(s.labelCell,t);s.labelCell!==e&&(n=!0,s={...s,labelCell:e})}const a=ir(s.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Y?(n=!0,s=void 0):a!==s.dataRange&&(n=!0,s={...s,dataRange:a}),r[o]=s}let s=o;const a=ir(s,t);a!==s&&(n=!0,s=a);return{isStale:n,dataSets:r.filter(Xe),labelRange:s}}function er(e,t,i){return i.map((i=>({dataRange:Si(e,t,i.dataRange),labelCell:i.labelCell?Si(e,t,i.labelCell):void 0})))}function tr(e,t,i){return i?Si(e,t,i):void 0}function ir(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function or(e,t,i,o){const n=[];for(const r of t){const t=e.getRangeFromSheetXC(i,r),{unboundedZone:s,sheetId:a,invalidSheetName:l}=t;if(!l)if(s.left!==s.right&&s.top!==s.bottom){if(void 0===s.right)continue;for(let t=s.left;t<=s.right;t++){const i={...s,left:t,right:t};n.push(nr(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else s.left===s.right&&s.top===s.bottom?o||n.push(nr(e,a,s,void 0)):n.push(nr(e,a,s,o?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0))}return n}function nr(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${Ii(i)}`);if(o){const n=Ii(i),r=Ii(o);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Ii(i))}}function rr(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{height:e,width:t}=Ui(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const r=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(r,"forceSheetReference")}}function sr(e,t){let i;if(e.labelRange){const o=Qn(yi(e.labelRange),t);i=o?Ii(o):void 0}const o=e.dataSets.map(yi).map((e=>Qn(e,t))).filter(Xe).map(Ii);return{...e,labelRange:i,dataSets:o}}const ar=["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 lr{constructor(){this.graphColorIndex=0}next(){return ar[this.graphColorIndex++%ar.length]}}function cr(e){return e&&vt(e)<.3?"#FFFFFF":"#000000"}function hr(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Tt.test(e)));if(t)return 31;if(e.dataSets.map(yi).some((e=>e.top!==e.bottom&&qi(e))))return 31}return 0}function dr(e){if(e.labelRange){if(!Tt.test(e.labelRange||""))return 32}return 0}function ur(e,t,i){const o=null==e?void 0:e.evaluated;if(e&&void 0!==o){if("text"===i||(null==t?void 0:t.type)!==eo.number||o.type!==eo.number)return e.formattedValue;{let e=t.value-o.value;if("percentage"===i&&0!==e&&(e=e/o.value*100),"percentage"!==i&&o.format)return qt(e,o.format);const n=Math.abs(parseFloat(e.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function gr(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==eo.number||(null==i?void 0:i.type)!==eo.number)return;const r=i.value-e.value;return r>0?o:r<0?n:void 0}function pr(e,t,i){if("text"===i||(null==e?void 0:e.type)!==eo.number||(null==t?void 0:t.type)!==eo.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}function mr(e,t){if(t.dataRange){const i=t.labelCell?[Ii(t.labelCell.zone)]:[],o=Li([Ii(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n)}return[]}function fr(e,t){const i=ke(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function vr(e){return e?e.length>Q?e.substring(0,Q)+"…":e:""}function br(e,t,i){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:i},legend:{onClick:void 0}},data:{labels:t.map(vr),datasets:[]}}}function Sr(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>null!=e?String(e):""))});else if(1===t.length)for(let i=0;i<mr(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:ke(0,mr(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function Cr(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,r=i?e.getCell(i.sheetId,i.zone.left,i.zone.top):void 0;t=r&&i?vr(r.formattedValue):t=`${Un.Series} ${parseInt(o)+1}`}else t=t=`${Un.Series} ${parseInt(o)+1}`;let r=n.dataRange?mr(e,n):[];i.push({data:r,label:t})}return i}function Er(e){return 0===e?"origin":e-1}Yi.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new wr(e,t,i),getChartRuntime:function(e,t){let i=Sr(t,e.dataSets,e.labelRange).formattedValues,o=Cr(t,e.dataSets);({labels:i,dataSetsValues:o}=fr(i,o));const n=function(e,t){var i;const o=cr(e.background),n=br(e,t,o),r={labels:{fontColor:o}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;n.options.legend={...null===(i=n.options)||void 0===i?void 0:i.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:o}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:o,beginAtZero:!0}}]},e.stacked&&(n.options.scales.xAxes[0].stacked=!0,n.options.scales.yAxes[0].stacked=!0);return n}(e,i),r=new lr;for(let{label:e,data:t}of o){const i=r.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>wr.validateChartDefinition(e,t),transformDefinition:(e,t)=>wr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>wr.getDefinitionFromContextCreation(e),name:r("Bar")});class wr extends Yn{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=or(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ci(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked}static transformDefinition(e,t){return sr(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,hr,dr)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=er(this.sheetId,e,this.dataSets),i=tr(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new wr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new wr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked}}getDefinitionForExcel(){const e=this.dataSets.map((e=>rr(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Kn(this.background||w),fontColor:Kn(cr(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Jn(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new wr(n,this.sheetId,this.getters)}}function yr(e,t){const i=Yi.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function xr(e){return e.dataRange&&!Tt.test(e.dataRange)?35:0}function Rr(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function Ir(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?40:0}function Tr(e,t){if(""===e)switch(t){case"rangeMin":return 36;case"rangeMax":return 38}return 0}function Ar(e,t){if(isNaN(e))switch(t){case"rangeMin":return 37;case"rangeMax":return 39;case"lowerInflectionPointValue":return 41;case"upperInflectionPointValue":return 42}return 0}Yi.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new Or(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=cr(e.background),i=br(e,[],t);return i.options.hover=void 0,i.options.events=[],i.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},i.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},i.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},i}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,s=Number(n.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?s:l+h*s/100;d.push({value:Me(e,l,c),color:o.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:Me(e,l,c),color:o.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getCell(p.sheetId,p.zone.left,p.zone.top);(null==e?void 0:e.evaluated.type)===eo.number&&(f=Me(null==e?void 0:e.evaluated.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>Or.validateChartDefinition(e,t),transformDefinition:(e,t)=>Or.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Or.getDefinitionFromContextCreation(e),name:r("Gauge")});class Or extends Yn{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=Ci(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,xr,e.chainValidations(Rr(Tr,e.batchValidations),Rr(Ar,e.batchValidations),Ir),e.chainValidations((i=Ar,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=Qn(yi(e.dataRange),t)),{...e,dataRange:i?Ii(i):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=tr(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new Or(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Or(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=ir(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new Or(i,this.sheetId,this.getters)}}const Mr={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Nr={inSeconds:function(e){return Math.floor(e/Mr.second)},inMinutes:function(e){return Math.floor(e/Mr.minute)},inHours:function(e){return Math.floor(e/Mr.hour)},inDays:function(e){return Math.floor(e/Mr.day)},inMonths:function(e){return Math.floor(e/Mr.month)},inYears:function(e){return Math.floor(e/Mr.year)}},_r=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Fr(e,t){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),o=function(e,t){const i=e.map((e=>{var t;return null===(t=me(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),r=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(Mr.second>=Mr[r]&&Nr.inSeconds(n)<180)return"second";if(Mr.minute>=Mr[r]&&Nr.inMinutes(n)<180)return"minute";if(Mr.hour>=Mr[r]&&Nr.inHours(n)<96)return"hour";if(Mr.day>=Mr[r]&&Nr.inDays(n)<90)return"day";if(Mr.month>=Mr[r]&&Nr.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}Yi.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new Dr(e,t,i),getChartRuntime:function(e,t){const i=function(e,t){if(function(e,t){return!e.labelsAsText&&kr(e,t)}(e,t))return"time";if(function(e,t){return!e.labelsAsText&&$r(e,t)}(e,t))return"linear";return"category"}(e,t),o=Sr(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,r=Cr(t,e.dataSets);({labels:n,dataSetsValues:r}=fr(n,r)),"time"===i&&({labels:n,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=Te(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=it(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,r));const s=function(e,t){var i;const o=cr(e.background),n=br(e,t,o),r={labels:{fontColor:o,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;n.options.legend={...null===(i=n.options)||void 0===i?void 0:i.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:o}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:o,beginAtZero:!0}}]},e.stacked&&(n.options.scales.yAxes[0].stacked=!0);return n}(e,n),a=function(e,t){var i;if(t)return null===(i=e.getCell(t.sheetId,t.zone.left,t.zone.top))||void 0===i?void 0:i.evaluated.format}(t,e.labelRange);"time"===i?(s.options.scales.xAxes[0].type="time",s.options.scales.xAxes[0].time=Fr(n,a),s.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(s.options.scales.xAxes[0].type="linear",s.options.scales.xAxes[0].ticks.callback=e=>qt(e,a));const l=new lr;for(let[t,{label:o,data:a}]of r.entries()){["linear","time"].includes(i)&&(a=a.map(((e,t)=>({x:n[t]||void 0,y:e}))));const r=l.next();let c=St(r);if(e.stacked&&(c.a=J),e.cumulative){let e=0;a=a.map((t=>isNaN(t)?t:(e+=parseFloat(t),e)))}const h={label:o,data:a,lineTension:0,borderColor:r,backgroundColor:bt(c),pointBackgroundColor:r,fill:!!e.stacked&&Er(t)};s.data.datasets.push(h)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>Dr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Dr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Dr.getDefinitionFromContextCreation(e),name:r("Line")});class Dr extends Yn{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=or(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ci(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,hr,dr)}static transformDefinition(e,t){return sr(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,cumulative:this.cumulative}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Jn(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Dr(n,this.sheetId,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>rr(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Kn(this.background||w),fontColor:Kn(cr(this.background)),dataSets:e}}copyForSheetId(e){const t=er(this.sheetId,e,this.dataSets),i=tr(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Dr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Dr(t,e,this.getters)}}function kr(e,t){var i;if(!e.labelRange||!e.dataSets||!$r(e,t))return!1;const o=null===(i=t.getCell(e.labelRange.sheetId,e.labelRange.zone.left,e.labelRange.zone.top))||void 0===i?void 0:i.evaluated.format;return Boolean(o&&_r.test(o))}function $r(e,t){if(!e.labelRange||!e.dataSets)return!1;const i=t.getRangeValues(e.labelRange);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}Yi.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new Lr(e,t,i),getChartRuntime:function(e,t){let i=Sr(t,e.dataSets,e.labelRange).formattedValues,o=Cr(t,e.dataSets);({labels:i,dataSetsValues:o}=fr(i,o));const n=function(e,t){var i;const o=cr(e.background),n=br(e,t,o),r={labels:{fontColor:o}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;return n.options.legend={...null===(i=n.options)||void 0===i?void 0:i.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},n}(e,i),r=new lr;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Pr(r,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>Lr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Lr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Lr.getDefinitionFromContextCreation(e),name:r("Pie")});class Lr extends Yn{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=or(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ci(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition}static transformDefinition(e,t){return sr(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,hr,dr)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title}}copyForSheetId(e){const t=er(this.sheetId,e,this.dataSets),i=tr(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Lr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Lr(t,e,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>rr(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Kn(this.background||w),fontColor:Kn(cr(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Jn(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Lr(n,this.sheetId,this.getters)}}function Pr(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function Ur(e){return e.keyValue&&!Tt.test(e.keyValue)?33:0}function Vr(e){return e.baseline&&!Tt.test(e.baseline)?34:0}Yi.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new zr(e,t,i),getChartRuntime:function(e,t){let i,o,r="",s="";if(e.keyValue){const o=e.keyValue.zone;i=t.getCell(e.keyValue.sheetId,o.left,o.top),r=(null==i?void 0:i.evaluated.value)?String(null==i?void 0:i.evaluated.value):"",s=(null==i?void 0:i.formattedValue)||""}if(e.baseline){const i=e.baseline.zone;o=t.getCell(e.baseline.sheetId,i.left,i.top)}const a=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:s||r,baselineDisplay:ur(o,null==i?void 0:i.evaluated,e.baselineMode),baselineArrow:pr(null==o?void 0:o.evaluated,null==i?void 0:i.evaluated,e.baselineMode),baselineColor:gr(null==o?void 0:o.evaluated,e.baselineMode,null==i?void 0:i.evaluated,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:cr(a),background:a,baselineStyle:"percentage"!==e.baselineMode?null==o?void 0:o.style:void 0,keyValueStyle:null==i?void 0:i.style}},validateChartDefinition:(e,t)=>zr.validateChartDefinition(e,t),transformDefinition:(e,t)=>zr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>zr.getDefinitionFromContextCreation(e),name:r("Scorecard")});class zr extends Yn{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=Ci(i,t,e.keyValue),this.baseline=Ci(i,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Ur,Vr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:"difference",baselineColorUp:"#00A04A",baselineColorDown:"#DC6965",baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=Qn(yi(e.baseline),t)),e.keyValue&&(o=Qn(yi(e.keyValue),t)),{...e,baseline:i?Ii(i):void 0,keyValue:o?Ii(o):void 0}}copyForSheetId(e){const t=tr(this.sheetId,e,this.baseline),i=tr(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new zr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new zr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=ir(this.baseline,e),i=ir(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new zr(o,this.sheetId,this.getters)}}const Br=218,Hr=182;function Wr(e){return bt(Ct({h:360*e.offsetX/Br,s:100,l:100*e.offsetY/Hr,a:1}))}po`
322
323
  .o-color-picker {
323
324
  position: absolute;
324
325
  top: calc(100% + 5px);
@@ -329,7 +330,7 @@
329
330
  line-height: 1.2;
330
331
  overflow-y: auto;
331
332
  overflow-x: hidden;
332
- width: ${Vr+12}px;
333
+ width: ${Br+12}px;
333
334
 
334
335
  .o-color-picker-section-name {
335
336
  margin: 0px ${1}px;
@@ -430,8 +431,8 @@
430
431
  hsl(1turn 100% 50%) 100%
431
432
  );
432
433
  border: ${1}px solid #c0c0c0;
433
- width: ${Vr}px;
434
- height: ${zr}px;
434
+ width: ${Br}px;
435
+ height: ${Hr}px;
435
436
  &:hover {
436
437
  cursor: crosshair;
437
438
  }
@@ -467,7 +468,7 @@
467
468
  width: 30px;
468
469
  height: 30px;
469
470
  }
470
- `;class Hr extends t.Component{constructor(){super(...arguments),this.COLORS=M,this.state=t.useState({showGradient:!1,currentColor:gt(this.props.currentColor)?this.props.currentColor:"",isCurrentColorInvalid:!1,style:{display:"none",background:"#ffffff",left:"0",top:"0"}})}get colorPickerStyle(){return void 0===this.props.maxHeight?"":this.props.maxHeight<=0?mo({display:"none"}):mo({"max-height":`${this.props.maxHeight}px`})}onColorClick(e){e&&this.props.onColorPicked(ut(e))}getCheckMarkColor(){return ar(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!gt(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);const t=ut(this.state.currentColor);this.state.isCurrentColorInvalid=!1,this.props.onColorPicked(t),this.state.currentColor=t}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}computeCustomColor(e){this.state.isCurrentColorInvalid=!1,this.state.currentColor=Br(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=Br(e);this.state.style.left=`${e.offsetX+10}px`,this.state.style.top=`${e.offsetY+10}px`}get magnifyingGlassStyle(){const{display:e,background:t,left:i,top:o}=this.state.style;return`display:${e};${"block"===e?`background-color:${t};left:${i};top:${o};`:""}`}isSameColor(e,t){return function(e,t){return gt(e)&&gt(t)&&ut(e)===ut(t)}(e,t)}}Hr.template="o-spreadsheet-ColorPicker";class Wr extends t.Component{constructor(){super(...arguments),this.state=t.useState({fillColorTool:!1})}onClick(e){this.state.fillColorTool=!1}setup(){t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateSelect(e,t){this.props.updateChart(this.props.figureId,{[e]:t.target.value})}}Wr.template="o-spreadsheet-LineBarPieDesignPanel",Wr.components={ColorPicker:Hr};class Gr extends Wr{}Gr.template="o-spreadsheet-BarChartDesignPanel";class qr extends t.Component{constructor(){super(...arguments),this.state=t.useState({dataRangeDispatchResult:void 0}),this.dataRange=this.props.definition.dataRange}get configurationErrorMessages(){var e;return[...(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Ln.Errors[e]||Ln.Errors.Unexpected))}get isDataRangeInvalid(){var e;return!!(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.isCancelledBecause(35))}onDataRangeChanged(e){this.dataRange=e[0]}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart(this.props.figureId,{dataRange:this.dataRange})}}qr.template="o-spreadsheet-GaugeChartConfigPanel",qr.components={SelectionInput:Gn},go`
471
+ `;class Gr extends t.Component{constructor(){super(...arguments),this.COLORS=O,this.state=t.useState({showGradient:!1,currentColor:pt(this.props.currentColor)?this.props.currentColor:"",isCurrentColorInvalid:!1,style:{display:"none",background:"#ffffff",left:"0",top:"0"}})}get colorPickerStyle(){return void 0===this.props.maxHeight?"":this.props.maxHeight<=0?fo({display:"none"}):fo({"max-height":`${this.props.maxHeight}px`})}onColorClick(e){e&&this.props.onColorPicked(gt(e))}getCheckMarkColor(){return cr(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!pt(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);const t=gt(this.state.currentColor);this.state.isCurrentColorInvalid=!1,this.props.onColorPicked(t),this.state.currentColor=t}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}computeCustomColor(e){this.state.isCurrentColorInvalid=!1,this.state.currentColor=Wr(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=Wr(e);this.state.style.left=`${e.offsetX+10}px`,this.state.style.top=`${e.offsetY+10}px`}get magnifyingGlassStyle(){const{display:e,background:t,left:i,top:o}=this.state.style;return`display:${e};${"block"===e?`background-color:${t};left:${i};top:${o};`:""}`}isSameColor(e,t){return function(e,t){return pt(e)&&pt(t)&&gt(e)===gt(t)}(e,t)}}Gr.template="o-spreadsheet-ColorPicker";class qr extends t.Component{constructor(){super(...arguments),this.state=t.useState({fillColorTool:!1})}onClick(e){this.state.fillColorTool=!1}setup(){t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateSelect(e,t){this.props.updateChart(this.props.figureId,{[e]:t.target.value})}}qr.template="o-spreadsheet-LineBarPieDesignPanel",qr.components={ColorPicker:Gr};class Zr extends qr{}Zr.template="o-spreadsheet-BarChartDesignPanel";class jr extends t.Component{constructor(){super(...arguments),this.state=t.useState({dataRangeDispatchResult:void 0}),this.dataRange=this.props.definition.dataRange}get configurationErrorMessages(){var e;return[...(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Un.Errors[e]||Un.Errors.Unexpected))}get isDataRangeInvalid(){var e;return!!(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.isCancelledBecause(35))}onDataRangeChanged(e){this.dataRange=e[0]}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart(this.props.figureId,{dataRange:this.dataRange})}}jr.template="o-spreadsheet-GaugeChartConfigPanel",jr.components={SelectionInput:Zn},po`
471
472
  .o-gauge-color-set {
472
473
  .o-gauge-color-set-color-button {
473
474
  display: inline-block;
@@ -507,7 +508,7 @@
507
508
  box-sizing: border-box;
508
509
  }
509
510
  }
510
- `;class Zr extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedMenu:void 0,sectionRuleDispatchResult:void 0})}get designErrorMessages(){var e;return[...(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Ln.Errors[e]||Ln.Errors.Unexpected))}onClick(e){this.state.openedMenu=void 0}setup(){t.useExternalListener(window,"click",this.onClick)}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}isRangeMinInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(36))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(37))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(40)))}isRangeMaxInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(38))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(39))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(40)))}get isLowerInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(41))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(43)))}get isUpperInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(42))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(43)))}updateInflectionPointValue(e,t){const i=Te(this.props.definition.sectionRule);i[e].value=t.target.value,this.updateSectionRule(i)}updateInflectionPointType(e,t){const i=Te(this.props.definition.sectionRule);i[e].type=t.target.value,this.updateSectionRule(i)}updateSectionColor(e,t){const i=Te(this.props.definition.sectionRule);i.colors[e]=t,this.updateSectionRule(i),this.closeMenus()}updateRangeMin(e){let t=Te(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=Te(this.props.definition.sectionRule);t={...t,rangeMax:e.target.value},this.updateSectionRule(t)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart(this.props.figureId,{sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}Zr.template="o-spreadsheet-GaugeChartDesignPanel",Zr.components={ColorPicker:Hr};class jr extends qn{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof _r)&&function(e,t){return Fr(e,t)||Dr(e,t)}(e,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart(this.props.figureId,{labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}}jr.template="o-spreadsheet-LineConfigPanel";class Xr extends Wr{}Xr.template="o-spreadsheet-LineChartDesignPanel";class Yr extends t.Component{constructor(){super(...arguments),this.state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0}),this.keyValue=this.props.definition.keyValue,this.baseline=this.props.definition.baseline}get errorMessages(){var e,t;return[...(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.baselineDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>Ln.Errors[e]||Ln.Errors.Unexpected))}get isKeyValueInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(33))}get isBaselineInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(34))}onKeyValueRangeChanged(e){this.keyValue=e[0]}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart(this.props.figureId,{keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart(this.props.figureId,{baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart(this.props.figureId,{baselineMode:e.target.value})}}Yr.template="o-spreadsheet-ScorecardChartConfigPanel",Yr.components={SelectionInput:Gn};class Kr extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedColorPicker:void 0})}onClick(e){this.state.openedColorPicker=void 0}setup(){t.useExternalListener(window,"click",this.onClick)}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateBaselineDescr(e){this.props.updateChart(this.props.figureId,{baselineDescr:e.target.value})}openColorPicker(e){this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart(this.props.figureId,{background:e});break;case"baselineColorDown":this.props.updateChart(this.props.figureId,{baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart(this.props.figureId,{baselineColorUp:e})}this.state.openedColorPicker=void 0}}Kr.template="o-spreadsheet-ScorecardChartDesignPanel",Kr.components={ColorPicker:Hr};const Qr=new ji;Qr.add("line",{configuration:jr,design:Xr}).add("bar",{configuration:Zn,design:Gr}).add("pie",{configuration:qn,design:Wr}).add("gauge",{configuration:qr,design:Zr}).add("scorecard",{configuration:Yr,design:Kr}),go`
511
+ `;class Xr extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedMenu:void 0,sectionRuleDispatchResult:void 0})}get designErrorMessages(){var e;return[...(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Un.Errors[e]||Un.Errors.Unexpected))}onClick(e){this.state.openedMenu=void 0}setup(){t.useExternalListener(window,"click",this.onClick)}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}isRangeMinInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(36))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(37))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(40)))}isRangeMaxInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(38))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(39))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(40)))}get isLowerInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(41))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(43)))}get isUpperInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(42))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(43)))}updateInflectionPointValue(e,t){const i=Te(this.props.definition.sectionRule);i[e].value=t.target.value,this.updateSectionRule(i)}updateInflectionPointType(e,t){const i=Te(this.props.definition.sectionRule);i[e].type=t.target.value,this.updateSectionRule(i)}updateSectionColor(e,t){const i=Te(this.props.definition.sectionRule);i.colors[e]=t,this.updateSectionRule(i),this.closeMenus()}updateRangeMin(e){let t=Te(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=Te(this.props.definition.sectionRule);t={...t,rangeMax:e.target.value},this.updateSectionRule(t)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart(this.props.figureId,{sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}Xr.template="o-spreadsheet-GaugeChartDesignPanel",Xr.components={ColorPicker:Gr};class Yr extends jn{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof Dr)&&function(e,t){return kr(e,t)||$r(e,t)}(e,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart(this.props.figureId,{labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateCumulative(e){this.props.updateChart(this.props.figureId,{cumulative:e.target.checked})}}Yr.template="o-spreadsheet-LineConfigPanel";class Kr extends qr{}Kr.template="o-spreadsheet-LineChartDesignPanel";class Qr extends t.Component{constructor(){super(...arguments),this.state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0}),this.keyValue=this.props.definition.keyValue,this.baseline=this.props.definition.baseline}get errorMessages(){var e,t;return[...(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.baselineDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>Un.Errors[e]||Un.Errors.Unexpected))}get isKeyValueInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(33))}get isBaselineInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(34))}onKeyValueRangeChanged(e){this.keyValue=e[0]}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart(this.props.figureId,{keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart(this.props.figureId,{baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart(this.props.figureId,{baselineMode:e.target.value})}}Qr.template="o-spreadsheet-ScorecardChartConfigPanel",Qr.components={SelectionInput:Zn};class Jr extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedColorPicker:void 0})}onClick(e){this.state.openedColorPicker=void 0}setup(){t.useExternalListener(window,"click",this.onClick)}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateBaselineDescr(e){this.props.updateChart(this.props.figureId,{baselineDescr:e.target.value})}openColorPicker(e){this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart(this.props.figureId,{background:e});break;case"baselineColorDown":this.props.updateChart(this.props.figureId,{baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart(this.props.figureId,{baselineColorUp:e})}this.state.openedColorPicker=void 0}}Jr.template="o-spreadsheet-ScorecardChartDesignPanel",Jr.components={ColorPicker:Gr};const es=new Xi;es.add("line",{configuration:Yr,design:Kr}).add("bar",{configuration:Xn,design:Zr}).add("pie",{configuration:jn,design:qr}).add("gauge",{configuration:jr,design:Xr}).add("scorecard",{configuration:Qr,design:Jr}),po`
511
512
  .o-chart {
512
513
  .o-panel {
513
514
  display: flex;
@@ -537,7 +538,7 @@
537
538
  border-bottom: 4px solid;
538
539
  }
539
540
  }
540
- `;class Jr extends t.Component{get figureId(){return this.state.figureId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(r("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId&&(this.state.figureId=e),this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e,t){if(e!==this.figureId)return;const i={...this.getChartDefinition(),...t};return this.env.model.dispatch("UPDATE_CHART",{definition:i,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const i=function(e,t){return Xi.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:i,id:this.figureId,sheetId:this.env.model.getters.getFigureSheetId(this.figureId)})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=Qr.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}getChartDefinition(e=this.figureId){return this.env.model.getters.getChartDefinition(e)}get chartTypes(){return function(){const e={};for(const t of Xi.getKeys())e[t]=Xi.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}Jr.template="o-spreadsheet-ChartPanel";function es(e){e=`<svg xmlns="http://www.w3.org/2000/svg" ${e.slice(4)}`;const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const ts={arrowGood:{template:"ARROW_UP",img:es('<svg class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>')},arrowNeutral:{template:"ARROW_RIGHT",img:es('<svg class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>')},arrowBad:{template:"ARROW_DOWN",img:es('<svg class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>')},smileyGood:{template:"SMILE",img:es('<svg class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>')},smileyNeutral:{template:"MEH",img:es('<svg class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>')},smileyBad:{template:"FROWN",img:es('<svg class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>')},dotGood:{template:"GREEN_DOT",img:es('<svg class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotNeutral:{template:"YELLOW_DOT",img:es('<svg class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotBad:{template:"RED_DOT",img:es('<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>')}},is={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};go`
541
+ `;class ts extends t.Component{get figureId(){return this.state.figureId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(r("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId&&(this.state.figureId=e),this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e,t){if(e!==this.figureId)return;const i={...this.getChartDefinition(),...t};return this.env.model.dispatch("UPDATE_CHART",{definition:i,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const i=function(e,t){return Yi.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:i,id:this.figureId,sheetId:this.env.model.getters.getFigureSheetId(this.figureId)})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=es.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}getChartDefinition(e=this.figureId){return this.env.model.getters.getChartDefinition(e)}get chartTypes(){return function(){const e={};for(const t of Yi.getKeys())e[t]=Yi.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}ts.template="o-spreadsheet-ChartPanel";function is(e){e=`<svg xmlns="http://www.w3.org/2000/svg" ${e.slice(4)}`;const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const os={arrowGood:{template:"ARROW_UP",img:is('<svg class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>')},arrowNeutral:{template:"ARROW_RIGHT",img:is('<svg class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>')},arrowBad:{template:"ARROW_DOWN",img:is('<svg class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>')},smileyGood:{template:"SMILE",img:is('<svg class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>')},smileyNeutral:{template:"MEH",img:is('<svg class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>')},smileyBad:{template:"FROWN",img:is('<svg class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>')},dotGood:{template:"GREEN_DOT",img:is('<svg class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotNeutral:{template:"YELLOW_DOT",img:is('<svg class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotBad:{template:"RED_DOT",img:is('<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>')}},ns={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};po`
541
542
  .o-icon-picker {
542
543
  position: absolute;
543
544
  z-index: ${ne.IconPicker};
@@ -556,7 +557,7 @@
556
557
  outline: 1px solid gray;
557
558
  }
558
559
  }
559
- `;class os extends t.Component{constructor(){super(...arguments),this.icons=ts,this.iconSets=is}onIconClick(e){e&&this.props.onIconPicked(e)}}os.template="o-spreadsheet-IconPicker",go`
560
+ `;class rs extends t.Component{constructor(){super(...arguments),this.icons=os,this.iconSets=ns}onIconClick(e){e&&this.props.onIconPicked(e)}}rs.template="o-spreadsheet-IconPicker",po`
560
561
  label {
561
562
  vertical-align: middle;
562
563
  }
@@ -823,13 +824,13 @@
823
824
  }
824
825
  }
825
826
  }
826
- `;class ns extends t.Component{constructor(){super(...arguments),this.icons=ts,this.cellIsOperators=$n,this.iconSets=is,this.getTextDecoration=po,this.colorNumberString=ht}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return kn.Errors[e]||kn.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type){return`font-weight:${e.style.bold?"bold":"normal"};\n text-decoration:${po(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=ht(e.minimum.color),i=e.midpoint?ht(e.midpoint.color):null,o=ht(e.maximum.color),n="background-image: linear-gradient(to right, ";return i?n+t+", "+i+", "+o+")":n+t+", "+o+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=$n[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?n("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return kn.ColorScale;case"IconSetRule":return kn.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(It))))return void(this.state.errors=[25]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});t.isSuccessful?this.switchToList():this.state.errors=t.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(50))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(51))}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(57)||this.state.errors.includes(49)||this.state.errors.includes(46)||this.state.errors.includes(52);case"midpoint":return this.state.errors.includes(58)||this.state.errors.includes(53)||this.state.errors.includes(48);case"maximum":return this.state.errors.includes(59)||this.state.errors.includes(54);default:return!1}}setColorScaleColor(e,t){const i=this.state.rules.colorScale[e];i&&(i.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,i=ht(t.minimum.color),o=ht((null===(e=t.midpoint)||void 0===e?void 0:e.color)||x),n=ht(t.maximum.color),r="background-image: linear-gradient(to right, ";return void 0===t.midpoint?r+i+", "+n+")":r+i+", "+o+", "+n+")"}getThresholdColor(e){return ht(e?e.color:x)}onMidpointChange(e){const t=e.target.value,i=this.state.rules.colorScale;i.midpoint="none"===t?void 0:{color:x,value:"",...i.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(47);case"upperInflectionPoint":return this.state.errors.includes(55)||this.state.errors.includes(60)||this.state.errors.includes(47);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}ns.template="o-spreadsheet-ConditionalFormattingPanel",ns.components={SelectionInput:Gn,IconPicker:os,ColorPicker:Hr},go`
827
+ `;class ss extends t.Component{constructor(){super(...arguments),this.icons=os,this.cellIsOperators=Pn,this.iconSets=ns,this.getTextDecoration=mo,this.colorNumberString=dt}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return Ln.Errors[e]||Ln.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type){return`font-weight:${e.style.bold?"bold":"normal"};\n text-decoration:${mo(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=dt(e.minimum.color),i=e.midpoint?dt(e.midpoint.color):null,o=dt(e.maximum.color),n="background-image: linear-gradient(to right, ";return i?n+t+", "+i+", "+o+")":n+t+", "+o+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Pn[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?n("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Ln.ColorScale;case"IconSetRule":return Ln.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Tt))))return void(this.state.errors=[25]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});t.isSuccessful?this.switchToList():this.state.errors=t.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(50))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(51))}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(57)||this.state.errors.includes(49)||this.state.errors.includes(46)||this.state.errors.includes(52);case"midpoint":return this.state.errors.includes(58)||this.state.errors.includes(53)||this.state.errors.includes(48);case"maximum":return this.state.errors.includes(59)||this.state.errors.includes(54);default:return!1}}setColorScaleColor(e,t){const i=this.state.rules.colorScale[e];i&&(i.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,i=dt(t.minimum.color),o=dt((null===(e=t.midpoint)||void 0===e?void 0:e.color)||x),n=dt(t.maximum.color),r="background-image: linear-gradient(to right, ";return void 0===t.midpoint?r+i+", "+n+")":r+i+", "+o+", "+n+")"}getThresholdColor(e){return dt(e?e.color:x)}onMidpointChange(e){const t=e.target.value,i=this.state.rules.colorScale;i.midpoint="none"===t?void 0:{color:x,value:"",...i.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(47);case"upperInflectionPoint":return this.state.errors.includes(55)||this.state.errors.includes(60)||this.state.errors.includes(47);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}ss.template="o-spreadsheet-ConditionalFormattingPanel",ss.components={SelectionInput:Zn,IconPicker:rs,ColorPicker:Gr},po`
827
828
  .o-custom-currency {
828
829
  .o-format-proposals {
829
830
  color: black;
830
831
  }
831
832
  }
832
- `;class rs extends t.Component{setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),i=e.position,o="before"===e.position?"after":"before",n=this.state.currencySymbol.trim()?this.state.currencySymbol:"",r=this.state.currencyCode.trim()?this.state.currencyCode:"";return r||n?[...this.createFormatProposals(t,n,r,i),...this.createFormatProposals(t,n,r,o)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===Vo.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{Vo.add(t.toString(),e)}))}const i={name:this.env._t(Un.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[i,...Vo.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const i=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=i.code,this.state.currencySymbol=i.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],i=e?"."+"0".repeat(e):"";return i&&t.push({format:"#,##0"+i,example:"1,000"+i}),t}createFormatProposals(e,t,i,o){let n=[];if(t)for(let i of e)n.push(this.createFormatProposal(o,i.example,i.format,t));if(i)for(let r of e){const e=("after"===o?" ":"")+i+" "+t;n.push(this.createFormatProposal(o,r.example,r.format,e))}return n}createFormatProposal(e,t,i,o){const n="[$"+o+"]";return{example:"before"===e?o+t:t+o,format:"before"===e?n+i:i+n}}getCommonFormat(){var e;const t=this.env.model.getters.getSelectedZones(),i=this.env.model.getters.getActiveSheetId(),o=t.map((e=>this.env.model.getters.getCellsInZone(i,e))).flat(),n=null===(e=o[0])||void 0===e?void 0:e.format;return o.every((e=>(null==e?void 0:e.format)===n))?n:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}rs.template="o-spreadsheet-CustomCurrencyPanel",go`
833
+ `;class as extends t.Component{setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),i=e.position,o="before"===e.position?"after":"before",n=this.state.currencySymbol.trim()?this.state.currencySymbol:"",r=this.state.currencyCode.trim()?this.state.currencyCode:"";return r||n?[...this.createFormatProposals(t,n,r,i),...this.createFormatProposals(t,n,r,o)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===zo.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{zo.add(t.toString(),e)}))}const i={name:this.env._t(zn.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[i,...zo.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const i=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=i.code,this.state.currencySymbol=i.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],i=e?"."+"0".repeat(e):"";return i&&t.push({format:"#,##0"+i,example:"1,000"+i}),t}createFormatProposals(e,t,i,o){let n=[];if(t)for(let i of e)n.push(this.createFormatProposal(o,i.example,i.format,t));if(i)for(let r of e){const e=("after"===o?" ":"")+i+" "+t;n.push(this.createFormatProposal(o,r.example,r.format,e))}return n}createFormatProposal(e,t,i,o){const n="[$"+o+"]";return{example:"before"===e?o+t:t+o,format:"before"===e?n+i:i+n}}getCommonFormat(){var e;const t=this.env.model.getters.getSelectedZones(),i=this.env.model.getters.getActiveSheetId(),o=t.map((e=>this.env.model.getters.getCellsInZone(i,e))).flat(),n=null===(e=o[0])||void 0===e?void 0:e.format;return o.every((e=>(null==e?void 0:e.format)===n))?n:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}as.template="o-spreadsheet-CustomCurrencyPanel",po`
833
834
  .o-find-and-replace {
834
835
  .o-far-item {
835
836
  display: block;
@@ -862,7 +863,7 @@
862
863
  }
863
864
  }
864
865
  }
865
- `;class ss extends t.Component{constructor(){super(...arguments),this.state=t.useState(this.initialState()),this.showFormulaState=!1,this.findAndReplaceRef=t.useRef("findAndReplace")}get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),this.debouncedUpdateSearch=Je(this.updateSearch.bind(this),200),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})})),t.useEffect((()=>{this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.searchFormulas()}),(()=>[this.env.model.getters.shouldShowFormulas()]))}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())}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}ss.template="o-spreadsheet-FindAndReplacePanel";const as=new ji;as.add("ConditionalFormatting",{title:r("Conditional formatting"),Body:ns}),as.add("ChartPanel",{title:r("Chart"),Body:Jr}),as.add("FindAndReplace",{title:r("Find and Replace"),Body:ss}),as.add("CustomCurrency",{title:r("Custom currency format"),Body:rs});const ls=new class extends ji{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new Ei}add(e,t){const i={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,i)}},cs=1.2;go`
866
+ `;class ls extends t.Component{constructor(){super(...arguments),this.state=t.useState(this.initialState()),this.showFormulaState=!1,this.findAndReplaceRef=t.useRef("findAndReplace")}get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),this.debouncedUpdateSearch=Je(this.updateSearch.bind(this),200),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})})),t.useEffect((()=>{this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.searchFormulas()}),(()=>[this.env.model.getters.shouldShowFormulas()]))}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())}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}ls.template="o-spreadsheet-FindAndReplacePanel";const cs=new Xi;cs.add("ConditionalFormatting",{title:r("Conditional formatting"),Body:ss}),cs.add("ChartPanel",{title:r("Chart"),Body:ts}),cs.add("FindAndReplace",{title:r("Find and Replace"),Body:ls}),cs.add("CustomCurrency",{title:r("Custom currency format"),Body:as});const hs=new class extends Xi{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new wi}add(e,t){const i={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,i)}},ds=1.2;po`
866
867
  div.o-scorecard {
867
868
  font-family: ${q};
868
869
  user-select: none;
@@ -881,15 +882,15 @@
881
882
 
882
883
  .o-title-text {
883
884
  text-align: left;
884
- height: ${cs+"em"};
885
- line-height: ${cs+"em"};
885
+ height: ${ds+"em"};
886
+ line-height: ${ds+"em"};
886
887
  overflow: hidden;
887
888
  white-space: nowrap;
888
889
  }
889
890
 
890
891
  .o-key-text {
891
- line-height: ${cs+"em"};
892
- height: ${cs+"em"};
892
+ line-height: ${ds+"em"};
893
+ height: ${ds+"em"};
893
894
  overflow: hidden;
894
895
  white-space: nowrap;
895
896
  }
@@ -904,8 +905,8 @@
904
905
  }
905
906
 
906
907
  .o-baseline-text {
907
- line-height: ${cs+"em"};
908
- height: ${cs+"em"};
908
+ line-height: ${ds+"em"};
909
+ height: ${ds+"em"};
909
910
  overflow: hidden;
910
911
  white-space: nowrap;
911
912
 
@@ -914,7 +915,7 @@
914
915
  }
915
916
  }
916
917
  }
917
- `;class hs extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return ft(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get figure(){return this.props.figure}get chartStyle(){return`\n padding:${this.chartPadding}px;\n background:${this.backgroundColor};\n `}get chartContentStyle(){return`\n height:${this.getDrawableHeight()}px;\n `}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){var e,t,i;const o=.96*this.props.figure.width,n=this.getWidestElement(),r=n.getElementMaxFontSize(this.getDrawableHeight(),this);let s=function(e,t,i,o=.25){let n=1;if(i(n)>e)return n;if(i(t)<e)return t;let r=(n+t)/2,s=i(r),a=0;for(;Math.abs(s-e)>o&&a<20;)s>=e?t=(n+t)/2:n=(n+t)/2,r=(n+t)/2,s=i(r),a++;return r}(o,r,(e=>n.getElementWidth(e,this.ctx,this)))/r;const a=(new us).getElementMaxFontSize(this.getDrawableHeight(),this)*s,l=(new ds).getElementMaxFontSize(this.getDrawableHeight(),this)*s;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:a,cellStyle:null===(e=this.runtime)||void 0===e?void 0:e.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:l}),baselineValueStyle:this.getTextStyle({fontSize:l,cellStyle:null===(t=this.runtime)||void 0===t?void 0:t.baselineStyle,color:(null===(i=this.runtime)||void 0===i?void 0:i.baselineColor)||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*l,color:this.secondaryFontColor})}}getTextStyle(e){const t=function(e){const t={};if(!e)return t;if(e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.strikethrough||e.underline){let i=e.strikethrough?"line-through":"";i=e.underline?i+" underline":i,t["text-decoration"]=i}return e.textColor&&(t.color=e.textColor),t}(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),mo(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*cs:0,t}getWidestElement(){const e=new ds,t=new us;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}hs.template="o-spreadsheet-ScorecardChart";class ds{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.baseline,n="neutral"!==i.baselineArrowDirection?"A "+o:o;t.font=`${e}px ${q}`;let r=t.measureText(n).width;return t.font=`${.9*e}px ${q}`,r+=t.measureText(i.baselineDescr).width,r}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/cs}}class us{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.keyValue||"";return t.font=`${e}px ${q}`,t.measureText(o).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/cs}}Yi.add("scorecard",hs),go`
918
+ `;class us extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return vt(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get figure(){return this.props.figure}get chartStyle(){return`\n padding:${this.chartPadding}px;\n background:${this.backgroundColor};\n `}get chartContentStyle(){return`\n height:${this.getDrawableHeight()}px;\n `}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){var e,t,i;const o=.96*this.props.figure.width,n=this.getWidestElement(),r=n.getElementMaxFontSize(this.getDrawableHeight(),this);let s=function(e,t,i,o=.25){let n=1;if(i(n)>e)return n;if(i(t)<e)return t;let r=(n+t)/2,s=i(r),a=0;for(;Math.abs(s-e)>o&&a<20;)s>=e?t=(n+t)/2:n=(n+t)/2,r=(n+t)/2,s=i(r),a++;return r}(o,r,(e=>n.getElementWidth(e,this.ctx,this)))/r;const a=(new ps).getElementMaxFontSize(this.getDrawableHeight(),this)*s,l=(new gs).getElementMaxFontSize(this.getDrawableHeight(),this)*s;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:a,cellStyle:null===(e=this.runtime)||void 0===e?void 0:e.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:l}),baselineValueStyle:this.getTextStyle({fontSize:l,cellStyle:null===(t=this.runtime)||void 0===t?void 0:t.baselineStyle,color:(null===(i=this.runtime)||void 0===i?void 0:i.baselineColor)||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*l,color:this.secondaryFontColor})}}getTextStyle(e){const t=function(e){const t={};if(!e)return t;if(e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.strikethrough||e.underline){let i=e.strikethrough?"line-through":"";i=e.underline?i+" underline":i,t["text-decoration"]=i}return e.textColor&&(t.color=e.textColor),t}(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),fo(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*ds:0,t}getWidestElement(){const e=new gs,t=new ps;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}us.template="o-spreadsheet-ScorecardChart";class gs{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.baseline,n="neutral"!==i.baselineArrowDirection?"A "+o:o;t.font=`${e}px ${q}`;let r=t.measureText(n).width;return t.font=`${.9*e}px ${q}`,r+=t.measureText(i.baselineDescr).width,r}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/ds}}class ps{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.keyValue||"";return t.font=`${e}px ${q}`,t.measureText(o).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/ds}}Ki.add("scorecard",us),po`
918
919
  .o-chart-container {
919
920
  width: 100%;
920
921
  height: 100%;
@@ -939,7 +940,7 @@
939
940
  }
940
941
  }
941
942
  }
942
- `;class gs extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonPosition=Io(this.menuButtonRef),this.position=Io(this.chartContainerRef)}getMenuItemRegistry(){const e=new Do;return e.add("edit",{name:r("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:r("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.writeText(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:r("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.writeText(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:r("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.sidePanelIsOpen&&this.env.toggleSidePanel("ChartPanel"),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const e={x:this.menuButtonPosition.x-B,y:this.menuButtonPosition.y};this.openContextMenu(e)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll(),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=Yi.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function ps(e,t,i=(()=>{})){const o=r=>{t(r),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",o),window.removeEventListener("dragstart",n),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function n(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",o),window.addEventListener("dragstart",n),window.addEventListener("mousemove",e),window.addEventListener("wheel",e)}function ms(e,t,i,o=!1){let n,r,s,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Ro();let g,p;const m=i=>{if(n=i,c)return;const{x:s,y:f}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let R=!1,I=$t;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==o){const t=r.clientX-u.left,i=h.getEdgeScrollCol(T,t,a);if(i.canEdgeScroll){let t;switch(R=!0,I=Math.min(I,i.delay),i.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-s}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==o){const t=r.clientY-u.top,i=h.getEdgeScrollRow(A,t,l);if(i.canEdgeScroll){let t;switch(R=!0,I=Math.min(I,i.delay),i.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+i.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}R||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,n),R&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(I))),r=n};ps(m,(()=>{clearTimeout(c),i()}),(e=>{r=e,s=e,a=s.clientX-u.left,l=s.clientY-u.top}))}gs.template="o-spreadsheet-ChartFigure",gs.components={Menu:Ao},go`
943
+ `;class ms extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonPosition=To(this.menuButtonRef),this.position=To(this.chartContainerRef)}getMenuItemRegistry(){const e=new ko;return e.add("edit",{name:r("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:r("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.writeText(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:r("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.writeText(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:r("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.sidePanelIsOpen&&this.env.toggleSidePanel("ChartPanel"),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const e={x:this.menuButtonPosition.x-B,y:this.menuButtonPosition.y};this.openContextMenu(e)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll(),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=Ki.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function fs(e,t,i=(()=>{})){const o=r=>{t(r),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",o),window.removeEventListener("dragstart",n),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function n(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",o),window.addEventListener("dragstart",n),window.addEventListener("mousemove",e),window.addEventListener("wheel",e)}function vs(e,t,i,o=!1){let n,r,s,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Io();let g,p;const m=i=>{if(n=i,c)return;const{x:s,y:f}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let R=!1,I=Lt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==o){const t=r.clientX-u.left,i=h.getEdgeScrollCol(T,t,a);if(i.canEdgeScroll){let t;switch(R=!0,I=Math.min(I,i.delay),i.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-s}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==o){const t=r.clientY-u.top,i=h.getEdgeScrollRow(A,t,l);if(i.canEdgeScroll){let t;switch(R=!0,I=Math.min(I,i.delay),i.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+i.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}R||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,n),R&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(I))),r=n};fs(m,(()=>{clearTimeout(c),i()}),(e=>{r=e,s=e,a=s.clientX-u.left,l=s.clientY-u.top}))}ms.template="o-spreadsheet-ChartFigure",ms.components={Menu:Oo},po`
943
944
  .o-autofill {
944
945
  height: 6px;
945
946
  width: 6px;
@@ -967,9 +968,9 @@
967
968
  white-space: nowrap;
968
969
  }
969
970
  }
970
- `;class fs extends t.Component{constructor(){super(...arguments),this.state=t.useState({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.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=vs),e}onMouseDown(e){this.state.handler=!0,this.state.position={left:0,top:0};const{scrollY:t,scrollX:i}=this.env.model.getters.getActiveSheetScrollInfo(),o=e.clientX+i,n=e.clientY+t;let r,s;ps((e=>{const t=Ro(),{scrollY:i,scrollX:a}=this.env.model.getters.getActiveSheetScrollInfo();this.state.position={left:e.clientX-o+a,top:e.clientY-n+i};const l=this.env.model.getters.getColIndex(e.clientX-t.left),c=this.env.model.getters.getRowIndex(e.clientY-t.top);if(r!==l||s!==c){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getNumberCols(e),i=this.env.model.getters.getNumberRows(e);r=-1===l?r:Oe(l,0,t),s=-1===c?s:Oe(c,0,i),void 0!==r&&void 0!==s&&this.env.model.dispatch("AUTOFILL_SELECT",{col:r,row:s})}}),(()=>{this.state.handler=!1,this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}fs.template="o-spreadsheet-Autofill";class vs extends t.Component{}vs.template=t.xml`
971
+ `;class bs extends t.Component{constructor(){super(...arguments),this.state=t.useState({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.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=Ss),e}onMouseDown(e){this.state.handler=!0,this.state.position={left:0,top:0};const{scrollY:t,scrollX:i}=this.env.model.getters.getActiveSheetScrollInfo(),o=e.clientX+i,n=e.clientY+t;let r,s;fs((e=>{const t=Io(),{scrollY:i,scrollX:a}=this.env.model.getters.getActiveSheetScrollInfo();this.state.position={left:e.clientX-o+a,top:e.clientY-n+i};const l=this.env.model.getters.getColIndex(e.clientX-t.left),c=this.env.model.getters.getRowIndex(e.clientY-t.top);if(r!==l||s!==c){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getNumberCols(e),i=this.env.model.getters.getNumberRows(e);r=-1===l?r:Me(l,0,t),s=-1===c?s:Me(c,0,i),void 0!==r&&void 0!==s&&this.env.model.dispatch("AUTOFILL_SELECT",{col:r,row:s})}}),(()=>{this.state.handler=!1,this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}bs.template="o-spreadsheet-Autofill";class Ss extends t.Component{}Ss.template=t.xml`
971
972
  <div t-esc="props.content"/>
972
- `,go`
973
+ `,po`
973
974
  .o-client-tag {
974
975
  position: absolute;
975
976
  border-top-left-radius: 4px;
@@ -979,7 +980,7 @@
979
980
  opacity: 0;
980
981
  pointer-events: none;
981
982
  }
982
- `;class bs extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:o}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:n,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return`bottom: ${o-r+15}px;left: ${n-1}px;border: 1px solid ${i};background-color: ${i};${this.props.active?"opacity:1 !important":""}`}}bs.template="o-spreadsheet-ClientTag";const Ss=/(.*?)\((.*?)\)(.*)/,Cs=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function Es(e){let t=e.split("\n");const i=[];for(let e of t)e=e.trim(),e&&i.push(ws(e));return i}function ws(e){let t,i=e.match(Ss),o=i[1].trim(),n=[],r=!1,s=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let o=Cs.find((e=>i===e));o?n.push(o):"RANGE<ANY>"===i?n.push("RANGE"):"OPTIONAL"===i?r=!0:"REPEATING"===i?s=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:o,description:i[3].trim(),type:n};return r&&(l.optional=!0),s&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function ys(e){let t=0,i=0,o=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||i++,n.repeating&&o++;const n=e;return n.minArgRequired=i,n.maxArgPossible=o?1/0:t,n.nbrArgRepeating=o,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,o),n}const xs=["number","string","boolean","undefined"];function Rs(e,t){if(!e())throw new Error(t)}const Is=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Ts(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(gi(e)||""===e)return mi(e);const t=me(e);if(t)return t.value;throw new Error(Is(e));default:return 0}}function As(e){if(""===e)throw new Error(Is(e));return Ts(e)}function Ms(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function Os(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const Ns=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function _s(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(Ns(e))}return!1;case"number":return!!e;default:return!1}}function Fs(e){return ve(Ts(e))}function Ds(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)t(o[i][n])}else i(o)}function ks(e,t){Ds(e,t,t)}function $s(e,t){Ds(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(As(e))}))}function Ls(e,t,i,o){let n=o;for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let r=0;r<i;r++)for(let i=0;i<e;i++)n=t(n,o[i][r])}else n=i(n,o);return n}function Ps(e,t,i){return Ls(e,t,t,i)}function Us(e,t,i){return Ls(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,As(i))),i)}function Vs(e,t,i){return Ls(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Ts(i):0):e),((e,i)=>t(e,Ts(i))),i)}function zs(e,t){return function(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)if(!t(o[i][n]))return}else if(!i(o))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(Ns(e));return _s(e)}(e))))}function Bs(e,t){let i,o,n=e.substring(0,2);"<="===n||">="===n||"<>"===n?(i=n,o=e.substring(2)):(n=e.substring(0,1),"<"===n||">"===n||"="===n?(i=n,o=e.substring(1)):(i="=",o=e)),gi(o)?o=Ts(o):"TRUE"!==o&&"FALSE"!==o||(o=_s(o));const r={operator:i,operand:o};return"string"==typeof o&&(t&&(o+="*"),r.regexp=function(e){let t="",i="";for(let o of e)"?"===o&&"~"!==i?t+=".":"*"===o&&"~"!==i?t+=".*":("*"!==o&&"?"!==o||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(o)&&(t+="\\"),t+=o),i=o;return new RegExp("^"+t+"$","i")}(o)),r}function Hs(e,t){const{operator:i,operand:o}=t;if(void 0===e||void 0===o)return!1;if("number"==typeof o&&"="===i)return Ms(e)===Ms(o);if("<>"===i||"="===i){let n;return n=typeof e==typeof o&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===o),"="===i?n:!n}if(typeof e==typeof o)switch(i){case"<":return e<o;case">":return e>o;case"<=":return e<=o;case">=":return e>=o}return!1}function Ws(e,t,i=!1){const o=e.length;if(o%2==1)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=e[0].length,s=e[0][0].length;let a=[];for(let t=0;t<o-1;t+=2){const o=e[t];if(!Array.isArray(o)||o.length!==n||o[0].length!==s)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Ms(e[t+1]);a.push(Bs(l,i))}for(let i=0;i<n;i++)for(let n=0;n<s;n++){let r=!0;for(let t=0;t<o-1;t+=2){if(r=Hs(e[t][i][n],a[t/2]),!r)break}r&&t(i,n)}}function Gs(e,t){return Os(e[0][t])}function qs(e,t){return Os(e[t][0])}function Zs(e,t,i,o,n,r){if(null==t)return-1;const s=typeof t;let a,l,c,h,d,u,g=0,p=n-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=r(e,h),u=typeof d;g<h&&s!==u;)h--,d=r(e,h),u=typeof d;u===s&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h),"asc"===o&&d>t||"desc"===o&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function js(e,t,i,o,n,r=!1){if(null==t)return-1;const s=r?(e,t)=>n(e,o-t-1):n;let a,l=-1;for(let n=0;n<o;n++){const c=s(e,n);if(c===t)return r?o-n-1:n;"nextSmaller"===i?(!a&&Xs(t,c)>=0||Xs(t,c)>=0&&Xs(c,a)>0)&&(a=c,l=n):"nextGreater"===i&&(!a&&Xs(t,c)<=0||Xs(t,c)<=0&&Xs(c,a)<0)&&(a=c,l=n)}return r?o-l-1:l}function Xs(e,t){let i=xs.indexOf(typeof e)-xs.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}const Ys={description:r("Apply a large number format"),args:Es(`\n value (number) ${r("The number.")}\n unit (string, optional) ${r("The formatting unit. Use 'k', 'm', or 'b' to force the unit")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Ts(e.value)),o=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return ti(o,1e3,"k");case"m":return ti(o,1e6,"m");case"b":return ti(o,1e9,"b");default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?ti(o,0,""):i<1e8?ti(o,1e3,"k"):i<1e11?ti(o,1e6,"m"):ti(o,1e9,"b")},compute:function(e){return Ts(e)}};var Ks=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Ys});const Qs={description:r("Absolute value of a number."),args:Es(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Ts(e))},isExported:!0},Js={description:r("Inverse cosine of a value, in radians."),args:Es(`\n value (number) ${r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},ea={description:r("Inverse hyperbolic cosine of a number."),args:Es(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},ta={description:r("Inverse cotangent of a value."),args:Es(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},ia={description:r("Inverse hyperbolic cotangent of a value."),args:Es(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>Math.abs(t)>1),r("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},oa={description:r("Inverse sine of a value, in radians."),args:Es(`\n value (number) ${r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},na={description:r("Inverse hyperbolic sine of a number."),args:Es(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Ts(e))},isExported:!0},ra={description:r("Inverse tangent of a value, in radians."),args:Es(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Ts(e))},isExported:!0},sa={description:r("Angle from the X axis to a point (x,y), in radians."),args:Es(`\n x (number) ${r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ts(e),o=Ts(t);return Rs((()=>0!==i||0!==o),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(o,i)},isExported:!0},aa={description:r("Inverse hyperbolic tangent of a number."),args:Es(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},la={description:r("Rounds number up to nearest multiple of factor."),args:Es(`\n value (number) ${r("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Ts(e),o=Ts(t);return Rs((()=>o>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.ceil(i/o)*o:0},isExported:!0},ca={description:r("Rounds number up to nearest multiple of factor."),args:Es(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Ts(t);if(0===o)return 0;const n=Ts(e);if(o=Math.abs(o),n>=0)return Math.ceil(n/o)*o;return 0===Ts(i)?-Math.floor(Math.abs(n)/o)*o:-Math.ceil(Math.abs(n)/o)*o},isExported:!0},ha={description:r("Rounds number up to nearest multiple of factor."),args:Es(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return ca.compute(e,t,0)},isExported:!0},da={description:r("Cosine of an angle provided in radians."),args:Es(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Ts(e))},isExported:!0},ua={description:r("Hyperbolic cosine of any real number."),args:Es(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Ts(e))},isExported:!0},ga={description:r("Cotangent of an angle provided in radians."),args:Es(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},pa={description:r("Hyperbolic cotangent of any real number."),args:Es(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},ma={description:r("Number of empty values."),args:Es(`\n value1 (any, range) ${r("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${r("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return Ps(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},fa={description:r("A conditional count across a range."),args:Es(`\n range (range) ${r("The range that is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return Ws(e,((e,i)=>{t+=1})),t},isExported:!0},va={description:r("Count values depending on multiple criteria."),args:Es(`\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return Ws(e,((e,i)=>{t+=1})),t},isExported:!0};function ba(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Sa={description:r("Counts number of unique values in a range."),args:Es(`\n value1 (any, range) ${r("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return Ps(e,((e,t)=>ba(t)?e.add(t):e),new Set).size}},Ca={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:Es(`\n range (range) ${r("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=new Set;return Ws(t,((t,o)=>{const n=e[t][o];ba(n)&&i.add(n)})),i.size}},Ea={description:r("Cosecant of an angle provided in radians."),args:Es(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},wa={description:r("Hyperbolic cosecant of any real number."),args:Es(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},ya={description:r("Converts from another base to decimal."),args:Es(`\n value (string) ${r("The number to convert.")},\n base (number) ${r("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let i=Ts(t);i=Math.floor(i),Rs((()=>2<=i&&i<=36),r("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const o=Ms(e);if(""===o)return 0;Rs((()=>!!o.match(/^-?[a-z0-9]+$/i)),r("The value (%s) must be a valid base %s representation.",o,i.toString()));const n=parseInt(o,i);return Rs((()=>!isNaN(n)),r("The value (%s) must be a valid base %s representation.",o,i.toString())),n},isExported:!0},xa={description:r("Converts an angle value in radians to degrees."),args:Es(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Ts(e)/Math.PI},isExported:!0},Ra={description:r("Euler's number, e (~2.718) raised to a power."),args:Es(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Ts(e))},isExported:!0},Ia={description:r("Rounds number down to nearest multiple of factor."),args:Es(`\n value (number) ${r("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Ts(e),o=Ts(t);return Rs((()=>o>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.floor(i/o)*o:0},isExported:!0},Ta={description:r("Rounds number down to nearest multiple of factor."),args:Es(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Ts(t);if(0===o)return 0;const n=Ts(e);if(o=Math.abs(o),n>=0)return Math.floor(n/o)*o;return 0===Ts(i)?-Math.ceil(Math.abs(n)/o)*o:-Math.floor(Math.abs(n)/o)*o},isExported:!0},Aa={description:r("Rounds number down to nearest multiple of factor."),args:Es(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ta.compute(e,t,0)},isExported:!0},Ma={description:r("Whether the provided value is even."),args:Es(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=As(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Oa={description:r("Rounds number up to nearest multiple of factor."),args:Es(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return ca.compute(e,t,0)},isExported:!0},Na={description:r("Whether the provided value is even."),args:Es(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=As(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},_a={description:r("The logarithm of a number, base e (euler's number)."),args:Es(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ts(e);return Rs((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Fa={description:r("Modulo (remainder) operator."),args:Es(`\n dividend (number) ${r("The number to be divided to find the remainder.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Ts(t);Rs((()=>0!==i),r("The divisor must be different from 0."));const o=Ts(e)%i;return o>0&&i<0||o<0&&i>0?o+i:o},isExported:!0},Da={description:r("Rounds a number up to the nearest odd integer."),args:Es(`\n value (number) ${r("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Ts(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},ka={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},$a={description:r("A number raised to a power."),args:Es(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Ts(e),o=Ts(t);return Rs((()=>i>=0||Number.isInteger(o)),r("The exponent (%s) must be an integer when the base is negative.",o.toString())),Math.pow(i,o)},isExported:!0},La={description:r("Result of multiplying a series of numbers together."),args:Es(`\n factor1 (number, range<number>) ${r("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${r("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(i*=o,t+=1);else null!=o&&(i*=As(o),t+=1);return 0===t?0:i},isExported:!0},Pa={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ua={description:r("Random integer between two values, inclusive."),args:Es(`\n low (number) ${r("The low end of the random range.")}\n high (number) ${r("The high end of the random range.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Ts(e);Number.isInteger(i)||(i=Math.ceil(i));let o=Ts(t);return Number.isInteger(o)||(o=Math.floor(o)),Rs((()=>i<=o),r("The high (%s) must be greater than or equal to the low (%s).",o.toString(),i.toString())),i+Math.ceil((o-i+1)*Math.random())-1},isExported:!0},Va={description:r("Rounds a number according to standard rules."),args:Es(`\n value (number) ${r("The value to round to places number of places.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ts(e);let o=Ts(t);const n=Math.abs(i);let r;return 0===o?r=Math.round(n):(Number.isInteger(o)||(o=Math.trunc(o)),r=Math.round(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?r:-r},isExported:!0},za={description:r("Rounds down a number."),args:Es(`\n value (number) ${r("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ts(e);let o=Ts(t);const n=Math.abs(i);let r;return 0===o?r=Math.floor(n):(Number.isInteger(o)||(o=Math.trunc(o)),r=Math.floor(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?r:-r},isExported:!0},Ba={description:r("Rounds up a number."),args:Es(`\n value (number) ${r("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ts(e);let o=Ts(t);const n=Math.abs(i);let r;return 0===o?r=Math.ceil(n):(Number.isInteger(o)||(o=Math.trunc(o)),r=Math.ceil(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?r:-r},isExported:!0},Ha={description:r("Secant of an angle provided in radians."),args:Es(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Ts(e))},isExported:!0},Wa={description:r("Hyperbolic secant of any real number."),args:Es(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Ts(e))},isExported:!0},Ga={description:r("Sine of an angle provided in radians."),args:Es(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Ts(e))},isExported:!0},qa={description:r("Hyperbolic sine of any real number."),args:Es(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Ts(e))},isExported:!0},Za={description:r("Positive square root of a positive number."),args:Es(`\n value (number) ${r("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Ts(e);return Rs((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},ja={description:r("Sum of a series of numbers and/or cells."),args:Es(`\n value1 (number, range<number>) ${r("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${r("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return Us(e,((e,t)=>e+t),0)},isExported:!0},Xa={description:r("A conditional sum across a range."),args:Es(`\n criteria_range (range) ${r("The range which is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${r("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let o=0;return Ws([e,t],((e,t)=>{const n=i[e][t];"number"==typeof n&&(o+=n)})),o},isExported:!0},Ya={description:r("Sums a range depending on multiple criteria."),args:Es(`\n sum_range (range) ${r("The range to sum.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges to check.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0;return Ws(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i+=n)})),i},isExported:!0},Ka={description:r("Tangent of an angle provided in radians."),args:Es(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Ts(e))},isExported:!0},Qa={description:r("Hyperbolic tangent of any real number."),args:Es(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Ts(e))},isExported:!0},Ja={description:r("Truncates a number."),args:Es(`\n value (number) ${r("The value to be truncated.")}\n places (number, default=0) ${r("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ts(e);let o=Ts(t);return 0===o?Math.trunc(i):(Number.isInteger(o)||(o=Math.trunc(o)),Math.trunc(i*Math.pow(10,o))/Math.pow(10,o))},isExported:!0};var el=Object.freeze({__proto__:null,ABS:Qs,ACOS:Js,ACOSH:ea,ACOT:ta,ACOTH:ia,ASIN:oa,ASINH:na,ATAN:ra,ATAN2:sa,ATANH:aa,CEILING:la,CEILING_MATH:ca,CEILING_PRECISE:ha,COS:da,COSH:ua,COT:ga,COTH:pa,COUNTBLANK:ma,COUNTIF:fa,COUNTIFS:va,COUNTUNIQUE:Sa,COUNTUNIQUEIFS:Ca,CSC:Ea,CSCH:wa,DECIMAL:ya,DEGREES:xa,EXP:Ra,FLOOR:Ia,FLOOR_MATH:Ta,FLOOR_PRECISE:Aa,ISEVEN:Ma,ISO_CEILING:Oa,ISODD:Na,LN:_a,MOD:Fa,ODD:Da,PI:ka,POWER:$a,PRODUCT:La,RAND:Pa,RANDBETWEEN:Ua,ROUND:Va,ROUNDDOWN:za,ROUNDUP:Ba,SEC:Ha,SECH:Wa,SIN:Ga,SINH:qa,SQRT:Za,SUM:ja,SUMIF:Xa,SUMIFS:Ya,TAN:Ka,TANH:Qa,TRUNC:Ja});function tl(e,t,i){let o=[],n=[],s=0,a=0;ks([e],(e=>{o.push(e),s+=1})),ks([t],(e=>{n.push(e),a+=1})),Rs((()=>s===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",s.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<s;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}Rs((()=>0!==l&&(!i||1!==l)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<s;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function il(e,t,i){let o=0,n=0;const s=i?Vs:Us;n=s(e,((e,t)=>(o+=1,e+t)),0),Rs((()=>0!==o&&(!t||1!==o)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/o;return s(e,((e,t)=>e+Math.pow(t-a,2)),0)/(o-(t?1:0))}function ol(e,t,i){const o=Ts(t);Rs((()=>i?0<=o&&o<=1:0<o&&o<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,s=[],a=0;return ks(e,(e=>{"number"==typeof e&&(n=Zs(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(n+1,0,e),a++)})),Rs((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),i||Rs((()=>1/(a+1)<=o&&o<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),fi(s,o,i)}const nl={description:r("Average magnitude of deviations from mean."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const i=Us(e,((e,i)=>(t+=1,e+i)),0);Rs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const o=i/t;return Us(e,((e,t)=>e+Math.abs(o-t)),0)/t},isExported:!0},rl={description:r("Numerical average value in a dataset, ignoring text."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Us(e,((e,i)=>(t+=1,e+i)),0);return Rs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},sl=r("[[FUNCTION_NAME]] has mismatched range sizes."),al=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),ll={description:r("Weighted average."),args:Es(`\n values (number, range<number>) ${r("Values to average.")}\n weights (number, range<number>) ${r("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${r("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${r("Additional weights.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,o=0,n=0;Rs((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let s=0;s<e.length-1;s+=2)if(t=e[s],i=e[s+1],Array.isArray(t)){Rs((()=>Array.isArray(i)),sl);let e=t.length,s=t[0].length;Rs((()=>e===i.length&&s===i[0].length),sl);for(let a=0;a<e;a++)for(let e=0;e<s;e++){let s=t[a][e],l=i[a][e],c="number"==typeof s,h="number"==typeof l;Rs((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(Rs((()=>l>=0),al),o+=s*l,n+=l)}}else i=Ts(i),t=Ts(t),Rs((()=>i>=0),al),o+=t*i,n+=i;return Rs((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n}},cl={description:r("Numerical average value in a dataset."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Vs(e,((e,i)=>(t+=1,e+i)),0);return Rs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},hl={description:r("Average of values depending on criteria."),args:Es(`\n criteria_range (range) ${r("The range to check against criterion.")}\n criterion (string) ${r("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${r("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let o=0,n=0;return Ws([e,t],((t,r)=>{const s=(i||e)[t][r];"number"==typeof s&&(o+=1,n+=s)})),Rs((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},dl={description:r("Average of values depending on multiple criteria."),args:Es(`\n average_range (range) ${r("The range to average.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0,o=0;return Ws(t,((t,n)=>{const r=e[t][n];"number"==typeof r&&(i+=1,o+=r)})),Rs((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},ul={description:r("The number of numeric values in dataset."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||gi(i)||me(i))&&(t+=1);return t},isExported:!0},gl={description:r("The number of values in a dataset."),args:Es(`\n value1 (any, range) ${r("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return Ps(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},pl={description:r("The covariance of a dataset."),args:Es(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return tl(e,t,!1)},isExported:!0},ml={description:r("The covariance of a dataset."),args:Es(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return tl(e,t,!1)},isExported:!0},fl={description:r("The sample covariance of a dataset."),args:Es(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return tl(e,t,!0)},isExported:!0},vl={description:r("Nth largest element from a data set."),args:Es(`\n data (any, range) ${r("Array or range containing the dataset to consider.")}\n n (number) ${r("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Ts(t));let o,n=[],s=0;ks([e],(e=>{"number"==typeof e&&(o=Zs(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),s++,s>i&&(n.shift(),s--))}));const a=n.shift();return Rs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Rs((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},bl={description:r("Maximum value in a numeric dataset."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Us(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Sl={description:r("Maximum numeric value in a dataset."),args:Es(`\n value1 (any, range) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Vs(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Cl={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:Es(`\n range (range) ${r("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return Ws(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i<n?n:i)})),i===-1/0?0:i},isExported:!0},El={description:r("Median value in a numeric dataset."),args:Es(`\n value1 (any, range) ${r("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return $s(e,(e=>{t.push(e)})),ol(t,.5,!0)},isExported:!0},wl={description:r("Minimum value in a numeric dataset."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Us(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},yl={description:r("Minimum numeric value in a dataset."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Vs(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},xl={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:Es(`\n range (range) ${r("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=1/0;return Ws(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i>n?n:i)})),i===1/0?0:i},isExported:!0},Rl={description:r("Value at a given percentile of a dataset."),args:Es(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Tl.compute(e,t)},isExported:!0},Il={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:Es(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ol([e],t,!1)},isExported:!0},Tl={description:r("Value at a given percentile of a dataset."),args:Es(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ol([e],t,!0)},isExported:!0},Al={description:r("Value nearest to a specific quartile of a dataset."),args:Es(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Ol.compute(e,t)},isExported:!0},Ml={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:Es(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ol([e],.25*Math.trunc(Ts(t)),!1)},isExported:!0},Ol={description:r("Value nearest to a specific quartile of a dataset."),args:Es(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ol([e],.25*Math.trunc(Ts(t)),!0)},isExported:!0},Nl={description:r("Nth smallest element in a data set."),args:Es(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n n (number) ${r("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Ts(t));let o,n=[],s=0;ks([e],(e=>{"number"==typeof e&&(o=Zs(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),s++,s>i&&(n.pop(),s--))}));const a=n.pop();return Rs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Rs((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},_l={description:r("Standard deviation."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Pl.compute(...e))},isExported:!0},Fl={description:r("Standard deviation of entire population."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ul.compute(...e))},isExported:!0},Dl={description:r("Standard deviation."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Vl.compute(...e))},isExported:!0},kl={description:r("Standard deviation of sample (text as 0)."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(zl.compute(...e))},isExported:!0},$l={description:r("Standard deviation of entire population."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Bl.compute(...e))},isExported:!0},Ll={description:r("Standard deviation of entire population (text as 0)."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Hl.compute(...e))},isExported:!0},Pl={description:r("Variance."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return il(e,!0,!1)},isExported:!0},Ul={description:r("Variance of entire population."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return il(e,!1,!1)},isExported:!0},Vl={description:r("Variance."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return il(e,!0,!1)},isExported:!0},zl={description:r("Variance of sample (text as 0)."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return il(e,!0,!0)},isExported:!0},Bl={description:r("Variance of entire population."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return il(e,!1,!1)},isExported:!0},Hl={description:r("Variance of entire population (text as 0)."),args:Es(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return il(e,!1,!0)},isExported:!0};var Wl=Object.freeze({__proto__:null,AVEDEV:nl,AVERAGE:rl,AVERAGE_WEIGHTED:ll,AVERAGEA:cl,AVERAGEIF:hl,AVERAGEIFS:dl,COUNT:ul,COUNTA:gl,COVAR:pl,COVARIANCE_P:ml,COVARIANCE_S:fl,LARGE:vl,MAX:bl,MAXA:Sl,MAXIFS:Cl,MEDIAN:El,MIN:wl,MINA:yl,MINIFS:xl,PERCENTILE:Rl,PERCENTILE_EXC:Il,PERCENTILE_INC:Tl,QUARTILE:Al,QUARTILE_EXC:Ml,QUARTILE_INC:Ol,SMALL:Nl,STDEV:_l,STDEV_P:Fl,STDEV_S:Dl,STDEVA:kl,STDEVP:$l,STDEVPA:Ll,VAR:Pl,VAR_P:Ul,VAR_S:Vl,VARA:zl,VARP:Bl,VARPA:Hl});function Gl(e,t,i){var o;const n=new Map,s=e.length;for(let t=s-1;t>=0;t--)n.set(Ms(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(r("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||s-1<a)throw new Error(r("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),s.toString()))}else{const e=Ms(t).toUpperCase();if(a=null!==(o=n.get(e))&&void 0!==o?o:-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Ms(t),[...n.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(r("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let o=[],r=!0;for(let s=0;s<i.length;s++){const a=Ms(i[s][0]).toUpperCase(),l=n.get(a),c=i[s][t];if(void 0!==c){if(void 0===l){r=!1;break}o.push([e[l].slice(1,h)]),o.push(c)}}if(r){if(!(o.length>0)){c=new Set(Array(h-1).keys());break}Ws(o,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const ql=Es(`\n database (range) ${r("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")}\n field (any) ${r("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${r("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),Zl={description:r("Average of a set of values from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return rl.compute([o])},isExported:!0},jl={description:r("Counts values from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return ul.compute([o])},isExported:!0},Xl={description:r("Counts values and text from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return gl.compute([o])},isExported:!0},Yl={description:r("Single value from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return Rs((()=>1===o.length),r("More than one match found in DGET evaluation.")),o[0]},isExported:!0},Kl={description:r("Maximum of values from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return bl.compute([o])},isExported:!0},Ql={description:r("Minimum of values from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return wl.compute([o])},isExported:!0},Jl={description:r("Product of values from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return La.compute([o])},isExported:!0},ec={description:r("Standard deviation of population sample from table."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return _l.compute([o])},isExported:!0},tc={description:r("Standard deviation of entire population from table."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return $l.compute([o])},isExported:!0},ic={description:r("Sum of values from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return ja.compute([o])},isExported:!0},oc={description:r("Variance of population sample from table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return Pl.compute([o])},isExported:!0},nc={description:r("Variance of a population from a table-like range."),args:ql,returns:["NUMBER"],compute:function(e,t,i){const o=Gl(e,t,i);return Bl.compute([o])},isExported:!0};var rc=Object.freeze({__proto__:null,DAVERAGE:Zl,DCOUNT:jl,DCOUNTA:Xl,DGET:Yl,DMAX:Kl,DMIN:Ql,DPRODUCT:Jl,DSTDEV:ec,DSTDEVP:tc,DSUM:ic,DVAR:oc,DVARP:nc});const sc={description:r("Converts year/month/day into a date."),args:Es(`\n year (number) ${r("The year component of the date.")}\n month (number) ${r("The month component of the date.")}\n day (number) ${r("The day component of the date.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let o=Math.trunc(Ts(e));const n=Math.trunc(Ts(t)),s=Math.trunc(Ts(i));Rs((()=>0<=o&&o<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",o.toString())),o<1900&&(o+=1900);const a=be(new Date(o,n-1,s));return Rs((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},ac={description:r("Converts a date string to a date value."),args:Es(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ms(e),i=me(t);return Rs((()=>null!==i),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},lc={description:r("Day of the month that a specific date falls on."),args:Es(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Fs(e).getDate()},isExported:!0},cc={description:r("Number of days between two dates."),args:Es(`\n end_date (date) ${r("The end of the date range.")}\n start_date (date) ${r("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Fs(e),o=Fs(t),n=i.getTime()-o.getTime();return Math.round(n/le)},isExported:!0},hc={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:Es(`\n start_date (date) ${r("The start date to consider in the calculation.")}\n end_date (date) ${r("The end date to consider in the calculation.")}\n method (number, default=0) ${r("An indicator of what day count method to use. (0) US NASD method (1) European method")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){const o=Ts(e),n=Ts(t),r=_s(i)?4:0,s=Oc.compute(e,t,r);return Math.sign(n-o)*Math.round(360*s)},isExported:!0},dc={description:r("Date a number of months before/after another date."),args:Es(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return be(Ee(Fs(e),Math.trunc(Ts(t)),!1))},isExported:!0},uc={description:r("Last day of a month before or after a date."),args:Es(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Fs(e),o=Math.trunc(Ts(t)),n=i.getFullYear(),r=i.getMonth();return be(new Date(n,r+o+1,0))},isExported:!0},gc={description:r("Hour component of a specific time."),args:Es(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Fs(e).getHours()},isExported:!0},pc={description:r("ISO week number of the year."),args:Es(`\n date (date) ${r("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n `),returns:["NUMBER"],compute:function(e){const t=Fs(e),i=t.getFullYear();let o=1;for(;4!==new Date(i,0,o).getDay();)o+=1;const n=new Date(i,0,o-3);let r=31;for(;4!==new Date(i,11,r).getDay();)r-=1;const s=new Date(i,11,r+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=s.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Date(i,11,r+3+1);break;case-1:let e=1;for(;4!==new Date(i-1,0,e).getDay();)e+=1;l=new Date(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/le;return Math.floor(c/7)+1},isExported:!0},mc={description:r("Minute component of a specific time."),args:Es(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Fs(e).getMinutes()},isExported:!0},fc={description:r("Month of the year a specific date falls in"),args:Es(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Fs(e).getMonth()+1},isExported:!0},vc={description:r("Net working days between two provided days."),args:Es(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i){return Sc.compute(e,t,1,i)},isExported:!0};function bc(e){if("string"==typeof e){Rs((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),r('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return Rs((()=>1<=e&&e<=7||11<=e&&e<=17),r("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(r("The weekend must be a number or a string."))}const Sc={description:r("Net working days between two dates (specifying weekends)."),args:Es(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1,o){const n=Fs(e),r=Fs(t),s=bc(i);let a=new Set;void 0!==o&&ks([o],(e=>{const t=Fs(e);a.add(t.getTime())}));const l=n.getTime()>r.getTime(),c=new Date((l?n:r).getTime());let h=new Date((l?r:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)s.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Cc={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-ae.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/le)+i},isExported:!0},Ec={description:r("Minute component of a specific time."),args:Es(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Fs(e).getSeconds()},isExported:!0},wc={description:r("Converts hour/minute/second into a time."),args:Es(`\n hour (number) ${r("The hour component of the time.")}\n minute (number) ${r("The minute component of the time.")}\n second (number) ${r("The second component of the time.")}\n `),returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let o=Math.trunc(Ts(e)),n=Math.trunc(Ts(t)),s=Math.trunc(Ts(i));return n+=Math.floor(s/60),s=s%60+(s<0?60:0),o+=Math.floor(n/60),n=n%60+(n<0?60:0),o%=24,Rs((()=>o>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),o/24+n/1440+s/86400},isExported:!0},yc={description:r("Converts a time string into its serial number representation."),args:Es(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ms(e),i=me(t);Rs((()=>null!==i),r("The time_string (%s) cannot be parsed to date/time.",t));const o=i.value-Math.trunc(i.value);return o<0?1+o:o},isExported:!0},xc={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return be(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Rc={description:r("Day of the week of the date provided (as number)."),args:Es(`\n date (date) ${r("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n type (number, default=1) ${r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Fs(e),o=Math.round(Ts(t)),n=i.getDay();return Rs((()=>[1,2,3].includes(o)),r("The type (%s) must be 1, 2 or 3.",o.toString())),1===o?n+1:2===o?0===n?7:n:0===n?6:n-1},isExported:!0},Ic={description:r("Week number of the year."),args:Es(`\n date (date) ${r("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n type (number, default=1) ${r("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Fs(e),o=Math.round(Ts(t));if(Rs((()=>1===o||2===o||11<=o&&o<=17||21===o),r("The type (%s) is out of range.",o.toString())),21===o)return pc.compute(e);let n;n=1===o||2===o?o-1:o-10==7?0:o-10;const s=i.getFullYear();let a=1,l=new Date(s,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(s,0,a);const c=(i.getTime()-l.getTime())/le;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Tc={description:r("Date after a number of workdays."),args:Es(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Ac.compute(e,t,1,i)},isExported:!0},Ac={description:r("Date after a number of workdays (specifying weekends)."),args:Es(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,o){let n=Fs(e),s=Math.trunc(Ts(t));"string"==typeof i&&Rs((()=>"1111111"!==i),r("The weekend (%s) must be different from '1111111'.",i));const a=bc(i);let l=new Set;void 0!==o&&ks([o],(e=>{const t=Fs(e);l.add(t.getTime())}));let c=new Date(n.getTime()),h=c.getTime();const d=Math.sign(s);let u=Math.abs(s);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-ae.getTime();return Math.round(g/le)},isExported:!0},Mc={description:r("Year specified by a given date."),args:Es(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Fs(e).getFullYear()},isExported:!0},Oc={description:r("Exact number of years between two dates."),args:Es(`\n start_date (date) ${r("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n end_date (date) ${r("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n day_count_convention (number, default=0) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){let o=Math.trunc(Ts(e)),n=Math.trunc(Ts(t));const s=Math.trunc(Ts(i));return Rs((()=>o>=0),r("The start_date (%s) must be positive or null.",o.toString())),Rs((()=>n>=0),r("The end_date (%s) must be positive or null.",n.toString())),Rs((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),ye(o,n,s)}},Nc={description:r("First day of the month preceding a date."),args:Es(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Fs(e),i=t.getFullYear(),o=t.getMonth();return be(new Date(i,o,1))}},_c={description:r("Last day of the month following a date."),args:Es(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return uc.compute(e,0)}},Fc={description:r("Quarter of the year a specific date falls in"),args:Es(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Fs(e).getMonth()+1)/3)}},Dc={description:r("First day of the quarter of the year a specific date falls in."),args:Es(`\n date (date) ${r("The date from which to calculate the start of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Fc.compute(e),i=Mc.compute(e);return be(new Date(i,3*(t-1),1))}},kc={description:r("Last day of the quarter of the year a specific date falls in."),args:Es(`\n date (date) ${r("The date from which to calculate the end of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Fc.compute(e),i=Mc.compute(e);return be(new Date(i,3*t,0))}},$c={description:r("First day of the year a specific date falls in."),args:Es(`\n date (date) ${r("The date from which to calculate the start of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Mc.compute(e);return be(new Date(t,0,1))}},Lc={description:r("Last day of the year a specific date falls in."),args:Es(`\n date (date) ${r("The date from which to calculate the end of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Mc.compute(e);return be(new Date(t+1,0,0))}};var Pc=Object.freeze({__proto__:null,DATE:sc,DATEVALUE:ac,DAY:lc,DAYS:cc,DAYS360:hc,EDATE:dc,EOMONTH:uc,HOUR:gc,ISOWEEKNUM:pc,MINUTE:mc,MONTH:fc,NETWORKDAYS:vc,NETWORKDAYS_INTL:Sc,NOW:Cc,SECOND:Ec,TIME:wc,TIMEVALUE:yc,TODAY:xc,WEEKDAY:Rc,WEEKNUM:Ic,WORKDAY:Tc,WORKDAY_INTL:Ac,YEAR:Mc,YEARFRAC:Oc,MONTH_START:Nc,MONTH_END:_c,QUARTER:Fc,QUARTER_START:Dc,QUARTER_END:kc,YEAR_START:$c,YEAR_END:Lc});const Uc={description:r("Compare two numeric values, returning 1 if they're equal."),args:Es(`\n number1 (number) ${r("The first number to compare.")}\n number2 (number, default=0) ${r("The second number to compare.")}\n `),returns:["NUMBER"],compute:function(e,t=0){return Ts(e)===Ts(t)?1:0},isExported:!0};var Vc=Object.freeze({__proto__:null,DELTA:Uc});function zc(e,t){Rs((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function Bc(e,t){Rs((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function Hc(e){Rs((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function Wc(e){Rs((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function Gc(e){Rs((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function qc(e){Rs((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function Zc(e){Rs((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function jc(e){Rs((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function Xc(e){Rs((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function Yc(e){Rs((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function Kc(e){Rs((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function Qc(e){Rs((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function Jc(e){Rs((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function eh(e,t){Rs((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function th(e){Rs((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function ih(e){Rs((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function oh(e){Rs((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function nh(e){Rs((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function rh(e,t){const i=Fs(e),o=Fs(t),n=new Date(i);n.setFullYear(i.getFullYear()+1),Rs((()=>o.getTime()<=n.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function sh(e,t,i){Zc(i),Rs((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),Rs((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),Rs((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Rs((()=>t<=i),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function ah(e){Rs((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function lh(e,t){Rs((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function ch(e){Rs((()=>e.every((t=>t>=e[0]))),r("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const hh=Es(`\nsettlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\nmaturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\nfrequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\nday_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n`);function dh(e,t,i,o,n=1e-10,s){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(Rs((()=>g<o&&void 0!==s),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=s(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<n||Math.abs(c)<n,Rs((()=>g<o),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const uh={description:r("Accrued interest of security paying at maturity."),args:Es(`\n issue (date) ${r("The date the security was initially issued.")}\n maturity (date) ${r("The maturity date of the security.")}\n rate (number) ${r("The annualized rate of interest.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Ts(e)),s=Math.trunc(Ts(t)),a=Ts(o),l=Ts(i),c=Math.trunc(Ts(n));Bc(s,r),Wc(c),Gc(a),jc(l);return a*l*Oc.compute(r,s,n)},isExported:!0},gh={description:r("Depreciation for an accounting period."),args:Es(`\n cost (number) ${r("The initial cost of the asset.")}\n purchase_date (date) ${r("The date the asset was purchased.")}\n first_period_end (date) ${r("The date the first period ended.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n rate (number) ${r("The deprecation rate.")}\n day_count_convention (number, optional) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s,a=0){a=a||0;const l=Ts(e),c=Math.trunc(Ts(t)),h=Math.trunc(Ts(i)),d=Ts(o),u=Ts(n),g=Ts(s),p=Math.trunc(Ts(a));!function(e){Rs((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),Qc(d),function(e,t){Rs((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Rs((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),jc(g),Wc(p),Rs((()=>c<=h),r("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=Oc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},ph={description:r("Days in coupon period containing settlement date."),args:hh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Ts(e)),r=Math.trunc(Ts(t)),s=Math.trunc(Ts(i)),a=Math.trunc(Ts(o));if(zc(n,r),Hc(s),Wc(a),1===a){const n=Sh.compute(e,t,i,o);return vh.compute(e,t,i,o)-n}return(3===a?365:360)/s},isExported:!0},mh={description:r("Days from settlement until next coupon."),args:hh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Ts(e)),r=Math.trunc(Ts(t)),s=Math.trunc(Ts(i)),a=Math.trunc(Ts(o));zc(n,r),Hc(s),Wc(a);const l=Sh.compute(n,r,i,o);if([1,2,3].includes(a))return n-l;if(4===a){const e=ye(l,n,a);return Math.round(360*e)}const c=Fs(n),h=Fs(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Ce(h)&&Ce(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Ce(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},fh={description:r("Days from settlement until next coupon."),args:hh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Ts(e)),r=Math.trunc(Ts(t)),s=Math.trunc(Ts(i)),a=Math.trunc(Ts(o));zc(n,r),Hc(s),Wc(a);const l=vh.compute(n,r,i,o);if([1,2,3].includes(a))return l-n;if(4===a){const e=ye(n,l,a);return Math.round(360*e)}const c=mh.compute(e,t,i,a);return ph.compute(e,t,i,a)-c},isExported:!0},vh={description:r("Next coupon date after the settlement date."),args:hh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Ts(e)),r=Math.trunc(Ts(t)),s=Math.trunc(Ts(i)),a=Math.trunc(Ts(o));zc(n,r),Hc(s),Wc(a);const l=12/s,c=bh.compute(e,t,i,o);return be(Ee(Fs(r),-(c-1)*l,!0))},isExported:!0},bh={description:r("Number of coupons between settlement and maturity."),args:hh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Ts(e)),r=Math.trunc(Ts(t)),s=Math.trunc(Ts(i)),a=Math.trunc(Ts(o));zc(n,r),Hc(s),Wc(a);let l=1,c=r;const h=12/s;for(;c>n;)c=be(Ee(Fs(c),-h,!1)),l++;return l-1},isExported:!0},Sh={description:r("Last coupon date prior to or on the settlement date."),args:hh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Ts(e)),r=Math.trunc(Ts(t)),s=Math.trunc(Ts(i)),a=Math.trunc(Ts(o));zc(n,r),Hc(s),Wc(a);const l=12/s,c=bh.compute(e,t,i,o);return be(Ee(Fs(r),-c*l,!0))},isExported:!0},Ch={description:r("Cumulative interest paid over a set of periods."),args:Es(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){const s=Ts(o),a=Ts(n),l=Ts(e),c=Ts(i),h=Ts(t);sh(s,a,h),jc(l),Jc(c);let d=0;for(let t=s;t<=a;t++){d+=_h.compute(e,t,h,i,0,r)}return d},isExported:!0},Eh={description:r("Cumulative principal paid over a set of periods."),args:Es(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){const s=Ts(o),a=Ts(n),l=Ts(e),c=Ts(i),h=Ts(t);sh(s,a,h),jc(l),Jc(c);let d=0;for(let t=s;t<=a;t++){d+=Bh.compute(e,t,h,i,0,r)}return d},isExported:!0},wh={description:r("Depreciation via declining balance method."),args:Es(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${r("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,...n){const s=Ts(e),a=Ts(t),l=Ts(i),c=Math.trunc(Ts(o)),h=n.length?Math.trunc(Ts(n[0])):12,d=l+(12===h?0:1);Yc(s),Qc(a),Kc(c),Xc(l),Rs((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Rs((()=>c<=d),r("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/s,1/l);g=Math.round(1e3*g)/1e3;let p=s,m=s*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},yh={description:r("Depreciation via double-declining balance method."),args:Es(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n factor (number, default=2) ${r("The factor by which depreciation decreases.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=2){n=n||0;const r=Ts(e),s=Ts(t),a=Ts(i),l=Ts(o),c=Ts(n);if(Yc(r),Qc(s),Kc(l),Xc(a),eh(l,a),nh(c),0===r||s>=r)return 0;const h=c/a;if(h>1)return 1===o?r-s:0;if(l<=1)return r*h;const d=r*Math.pow(1-h,l-1),u=r*Math.pow(1-h,l),g=u<s?d-s:d-u;return Math.max(g,0)},isExported:!0},xh={description:r("Discount rate of a security based on price."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Ts(e)),s=Math.trunc(Ts(t)),a=Ts(i),l=Ts(o),c=Math.trunc(Ts(n));zc(r,s),Wc(c),qc(a),Gc(l);return(l-a)/l/Oc.compute(r,s,c)},isExported:!0},Rh={description:r("Convert a decimal fraction to decimal value."),args:Es(`\n fractional_price (number) ${r("The price quotation given using fractional decimal conventions.")}\n unit (number) ${r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ts(e),o=Math.trunc(Ts(t));Rs((()=>o>0),r("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(10**Math.ceil(Math.log10(o))/o)},isExported:!0},Ih={description:r("Convert a decimal value to decimal fraction."),args:Es(`\n decimal_price (number) ${r("The price quotation given as a decimal value.")}\n unit (number) ${r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ts(e),o=Math.trunc(Ts(t));Rs((()=>o>0),r("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(o/10**Math.ceil(Math.log10(o)))},isExported:!0},Th={description:r("Number of periods for an investment to reach a value."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){s=s||0;const a=Math.trunc(Ts(e)),l=Math.trunc(Ts(t)),c=Ts(i),h=Ts(o),d=Math.trunc(Ts(n)),u=Math.trunc(Ts(s));zc(a,l),Hc(d),Wc(u),Rs((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),Rs((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=Oc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Ah={description:r("Annual effective interest rate."),args:Es(`\n nominal_rate (number) ${r("The nominal interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ts(e),o=Math.trunc(Ts(t));return Rs((()=>i>0),r("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Rs((()=>o>0),r("The number of periods by year (%s) must strictly greater than 0.",o.toString())),Math.pow(1+i/o,o)-1},isExported:!0},Mh={description:r("Future value of an annuity investment."),args:Es(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n present_value (number, default=0) ${r("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const r=Ts(e),s=Ts(t),a=Ts(i),l=Ts(o),c=_s(n)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},Oh={description:r("Future value of principal from series of rates."),args:Es(`\n principal (number) ${r("The amount of initial capital or value to compound against.")}\n rate_schedule (number, range<number>) ${r("A series of interest rates to compound against the principal.")}\n `),returns:["NUMBER"],compute:function(e,t){return Ps([t],((e,t)=>e*(1+Ts(t))),Ts(e))},isExported:!0},Nh={description:r("Calculates effective interest rate."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested in the security.")}\n redemption (number) ${r("The amount to be received at maturity.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){const r=Math.trunc(Ts(e)),s=Math.trunc(Ts(t)),a=Ts(o),l=Ts(i);zc(r,s),th(l),Gc(a);return(a-l)/l/Oc.compute(r,s,n)},isExported:!0},_h={description:r("Payment on the principal of an investment."),args:Es(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,r=0){return zh.compute(e,i,o,n,r)-Bh.compute(e,t,i,o,n,r)},isExported:!0},Fh={description:r("Internal rate of return given periodic cashflows."),args:Es(`\n cashflow_amounts (number, range<number>) ${r("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Ts(t);ah(i);let o=!1,n=!1,s=[];$s([e],(e=>{e>0&&(o=!0),e<0&&(n=!0),s.push(e)})),Rs((()=>o&&n),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return dh((function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*e**(o-n))),t*e**o)}(e,a,s)}),(function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*(o-n)*e**(o-n-1))),t*o*e**(o-1))}(e,a,s)}),i+1,20,1e-5)-1},isExported:!0},Dh={description:r("Returns the interest paid at a particular period of an investment."),args:Es(`\n rate (number) ${r("The interest rate.")}\n period (number) ${r("The period for which you want to view the interest payment.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o){const n=Ts(e),s=Ts(t),a=Ts(i),l=Ts(o);Rs((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*n},isExported:!0},kh={description:r("Modified Macaulay duration."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){return Th.compute(e,t,i,o,n,r)/(1+Ts(o)/Math.trunc(Ts(n)))},isExported:!0},$h={description:r("Modified internal rate of return."),args:Es(`\n cashflow_amounts (range<number>) ${r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")}\n financing_rate (number) ${r("The interest rate paid on funds invested.")}\n reinvestment_return_rate (number) ${r("The return (as a percentage) earned on reinvestment of income received from the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Ts(t),n=Ts(i),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Xe).map(Ts);var a;const l=s.length;let c=0,h=0;for(const e of ke(0,l)){const t=s[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(o+1)**e}Rs((()=>0!==h&&0!==c),r("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},Lh={description:r("Annual nominal interest rate."),args:Es(`\n effective_rate (number) ${r("The effective interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ts(e),o=Math.trunc(Ts(t));return Rs((()=>i>0),r("The effective rate (%s) must must strictly greater than 0.",i.toString())),Rs((()=>o>0),r("The number of periods by year (%s) must strictly greater than 0.",o.toString())),(Math.pow(i+1,1/o)-1)*o},isExported:!0},Ph={description:r("Number of payment periods for an investment."),args:Es(`\n rate (number) ${r("The interest rate.")}\n payment_amount (number) ${r("The amount of each payment made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const r=Ts(e),s=Ts(t),a=Ts(i),l=Ts(o),c=_s(n)?1:0;if(0===r)return-(l+a)/s;const h=s*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const Uh={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:Es(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${r("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${r("Additional future cash flows.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Ts(e);return Rs((()=>-1!==i),r("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let o=0;return Us(i,((t,i)=>(o++,t+i/(1+e)**o)),t)}(i,0,t)},isExported:!0},Vh={description:r("Computes the number of periods needed for an investment to reach a value."),args:Es(`\n rate (number) ${r("The rate at which the investment grows each period.")}\n present_value (number) ${r("The investment's current value.")}\n future_value (number) ${r("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Ts(e),n=Ts(t),s=Ts(i);return jc(o),Rs((()=>n>0),r("The present_value (%s) must be strictly positive.",n.toString())),Rs((()=>s>0),r("The future_value (%s) must be strictly positive.",s.toString())),(Math.log(s)-Math.log(n))/Math.log(1+o)},isExported:!0},zh={description:r("Periodic payment for an annuity investment."),args:Es(`\n rate (number) ${r("The annualized rate of interest.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const r=Ts(t),s=Ts(e),a=_s(n)?1:0;let l=Ts(o),c=Ts(i);if(Zc(r),0===s)return-(l+c)/r;let h=-(c*(1+s)**r+l);return h=h*s/((1+s*a)*((1+s)**r-1)),h},isExported:!0},Bh={description:r("Payment on the principal of an investment."),args:Es(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,s=0){n=n||0,s=s||0;const a=Ts(i),l=Ts(e),c=Ts(t),h=_s(s)?1:0,d=Ts(n),u=Ts(o);Zc(a),Rs((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=zh.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-Mh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},Hh={description:r("Present value of an annuity investment."),args:Es(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const r=Ts(e),s=Ts(t),a=Ts(i),l=Ts(o),c=_s(n)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},Wh={description:r("Price of a security paying periodic interest."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s,a=0){a=a||0;const l=Math.trunc(Ts(e)),c=Math.trunc(Ts(t)),h=Ts(i),d=Ts(o),u=Ts(n),g=Math.trunc(Ts(s)),p=Math.trunc(Ts(a));zc(l,c),Hc(g),Wc(p),Rs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Rs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),Gc(u);const m=Oc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},Gh={description:r("Price of a discount security."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the security at time of purchase.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Ts(e)),s=Math.trunc(Ts(t)),a=Ts(i),l=Ts(o),c=Math.trunc(Ts(n));zc(r,s),Wc(c),ih(a),Gc(l);return l-a*l*Oc.compute(r,s,c)},isExported:!0},qh={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){s=s||0;const a=Math.trunc(Ts(e)),l=Math.trunc(Ts(t)),c=Math.trunc(Ts(i)),h=Ts(o),d=Ts(n),u=Math.trunc(Ts(s));Bc(a,c),zc(a,l),Wc(u),Rs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Rs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=Oc.compute(a,l,u),p=Oc.compute(a,c,u);return(100+Oc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},Zh=.1,jh={description:r("Interest rate of an annuity investment."),args:Es(`\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_per_period (number) ${r("The amount per period to be paid.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the interest rate will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,o=0,n=0,s=.1){o=o||0,n=n||0,s=s||Zh;const a=Ts(e),l=Ts(t),c=_s(n)?1:0,h=Ts(s);let d=Ts(o),u=Ts(i);Zc(a),Rs((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),r("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),ah(h),d-=l*c,u+=l*c;return dh((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},Xh={description:r("Amount received at maturity for a security."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested (irrespective of face value of each security).")}\n discount (number) ${r("The discount rate of the security invested in.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Ts(e)),s=Math.trunc(Ts(t)),a=Ts(i),l=Ts(o),c=Math.trunc(Ts(n));zc(r,s),Wc(c),th(a),ih(l);return a/(1-l*Oc.compute(r,s,c))},isExported:!0},Yh={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:Es(`\n number_of_periods (number) ${r("The number of periods.")}\n present_value (number) ${r("The present value of the investment.")}\n future_value (number) ${r("The future value of the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Ts(e),n=Ts(t),r=Ts(i);return Zc(o),(r/n)**(1/o)-1},isExported:!0},Kh={description:r("Depreciation of an asset using the straight-line method."),args:Es(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Ts(e)-Ts(t))/Ts(i)},isExported:!0},Qh={description:r("Depreciation via sum of years digit method."),args:Es(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o){const n=Ts(e),r=Ts(t),s=Ts(i),a=Ts(o);Kc(a),Xc(s),eh(a,s);return(s-a+1)/(s*(s+1)/2)*(n-r)},isExported:!0},Jh={description:r("Price of a US Treasury bill."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Ts(e)),n=Math.trunc(Ts(t)),r=Ts(i);zc(o,n),rh(o,n),ih(r),oh(r);return 100*(1-r*Oc.compute(o,n,2))},isExported:!0},ed={description:r("Equivalent rate of return for a US Treasury bill."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Ts(e)),n=Math.trunc(Ts(t)),r=Ts(i);zc(o,n),rh(o,n),ih(r),oh(r);const s=cc.compute(n,o);if(s<=182)return 365*r/(360-r*s);const a=Jh.compute(o,n,r)/100,l=s/(366===s?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},td={description:r("The yield of a US Treasury bill based on price."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Ts(e)),n=Math.trunc(Ts(t)),r=Ts(i);zc(o,n),rh(o,n),qc(r);return(100-r)/r*(1/Oc.compute(o,n,2))},isExported:!0},id={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:Es(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n start (number) ${r("Starting period to calculate depreciation.")}\n end (number) ${r("Ending period to calculate depreciation.")}\n factor (number, default=2) ${r("The number of months in the first year of depreciation.")}\n no_switch (number, default=false) ${r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s=2,a=false){s=s||0;const l=Ts(e),c=Ts(t),h=Ts(i),d=Math.trunc(Ts(o)),u=Math.trunc(Ts(n)),g=Ts(s),p=_s(a);if(Yc(l),Qc(c),function(e,t,i){Xc(i),Rs((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),Rs((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),Rs((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Rs((()=>t<=i),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),nh(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},od={description:r("Internal rate of return given non-periodic cash flows."),args:Es(`\n cashflow_amounts (range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],compute:function(e,t,i=.1){const o=Ts(i=i||0),n=e.flat().map(Ts),s=t.flat().map(Ts);var a;lh(e,t),a=n,Rs((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),ch(s),ah(o);const l=new Map;for(const e of ke(0,s.length)){const t=s[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return dh((e=>{let t=h[0];for(const i of ke(1,h.length)){const o=(c[0]-c[i])/365;t+=h[i]*(1+e)**o}return t}),(e=>{let t=0;for(const i of ke(1,h.length)){const o=(c[0]-c[i])/365;t+=o*h[i]*(1+e)**(o-1)}return t}),o,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},nd={description:r("Net present value given to non-periodic cash flows.."),args:Es(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow_amounts (number, range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (number, range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Ts(e),n=Array.isArray(t)?t.flat().map(As):[As(t)],s=Array.isArray(i)?i.flat().map(As):[As(i)];if(Array.isArray(i)&&Array.isArray(t)?lh(t,i):Rs((()=>n.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),ch(s),jc(o),1===n.length)return n[0];const a=new Map;for(const e of ke(0,s.length)){const t=s[e];a.has(t)?a.set(t,a.get(t)+n[e]):a.set(t,n[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of ke(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+o)**t}return h},isExported:!0},rd={description:r("Annual yield of a security paying periodic interest."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s,a=0){a=a||0;const l=Math.trunc(Ts(e)),c=Math.trunc(Ts(t)),h=Ts(i),d=Ts(o),u=Ts(n),g=Math.trunc(Ts(s)),p=Math.trunc(Ts(a));zc(l,c),Hc(g),Wc(p),Rs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),qc(d),Gc(u);const m=Oc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=dh((function(e){return function(e,t,i,o,n,r){let s=r-(e+n*(1-t))*o**(i-1+t);for(let e=1;e<=i;e++)s+=n*o**(e-1);return s}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,o,n){let r=-(e+n*(1-t))*(i-1+t)*o**(i-2+t);for(let e=1;e<=i;e++)r+=n*(e-1)*o**(e-2);return r}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},sd={description:r("Annual yield of a discount security."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Ts(e)),s=Math.trunc(Ts(t)),a=Ts(i),l=Ts(o),c=Math.trunc(Ts(n));zc(r,s),Wc(c),qc(a),Gc(l);return(l/a-1)/Oc.compute(e,t,n)},isExported:!0},ad={description:r("Annual yield of a security paying interest at maturity."),args:Es(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){s=s||0;const a=Math.trunc(Ts(e)),l=Math.trunc(Ts(t)),c=Math.trunc(Ts(i)),h=Ts(o),d=Ts(n),u=Math.trunc(Ts(s));zc(a,l),Wc(u),Rs((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Rs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),qc(d);const g=Oc.compute(c,l,u),p=Oc.compute(c,a,u),m=Oc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var ld=Object.freeze({__proto__:null,ACCRINTM:uh,AMORLINC:gh,COUPDAYS:ph,COUPDAYBS:mh,COUPDAYSNC:fh,COUPNCD:vh,COUPNUM:bh,COUPPCD:Sh,CUMIPMT:Ch,CUMPRINC:Eh,DB:wh,DDB:yh,DISC:xh,DOLLARDE:Rh,DOLLARFR:Ih,DURATION:Th,EFFECT:Ah,FV:Mh,FVSCHEDULE:Oh,INTRATE:Nh,IPMT:_h,IRR:Fh,ISPMT:Dh,MDURATION:kh,MIRR:$h,NOMINAL:Lh,NPER:Ph,NPV:Uh,PDURATION:Vh,PMT:zh,PPMT:Bh,PV:Hh,PRICE:Wh,PRICEDISC:Gh,PRICEMAT:qh,RATE:jh,RECEIVED:Xh,RRI:Yh,SLN:Kh,SYD:Qh,TBILLPRICE:Jh,TBILLEQ:ed,TBILLYIELD:td,VDB:id,XIRR:od,XNPV:nd,YIELD:rd,YIELDDISC:sd,YIELDMAT:ad});const cd={description:r("Whether a value is an error other than #N/A."),args:Es(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},hd={description:r("Whether a value is an error."),args:Es(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},dd={description:r("Whether a value is `true` or `false`."),args:Es(`value (any, lazy) ${r("The value to be verified as a logical TRUE or FALSE.")}`),returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},ud={description:r("Whether a value is the error #N/A."),args:Es(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},gd={description:r("Whether a value is non-textual."),args:Es(`value (any, lazy) ${r("The value to be checked.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},pd={description:r("Whether a value is a number."),args:Es(`value (any, lazy) ${r("The value to be verified as a number.")}`),returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},md={description:r("Whether a value is text."),args:Es(`value (any, lazy) ${r("The value to be verified as text.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},fd={description:r("Whether the referenced cell is empty"),args:Es(`value (any, lazy) ${r("Reference to the cell that will be checked for emptiness.")}`),returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},vd={description:r("Returns the error value #N/A."),args:Es(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var bd=Object.freeze({__proto__:null,ISERR:cd,ISERROR:hd,ISLOGICAL:dd,ISNA:ud,ISNONTEXT:gd,ISNUMBER:pd,ISTEXT:md,ISBLANK:fd,NA:vd});const Sd={description:r("Logical `and` operator."),args:Es(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return zs(e,(e=>(t=!0,i=i&&e,i))),Rs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Cd={description:r("Returns value depending on logical expression."),args:Es(`\n logical_expression (boolean) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")}\n value_if_true (any, lazy) ${r("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${r("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,i=(()=>!1)){const o=_s(e)?t():i();return null==o?"":o},isExported:!0},Ed={description:r("Value if it is not an error, otherwise 2nd argument."),args:Es(`\n value (any, lazy) ${r("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an error.")}\n `),returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},wd={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:Es(`\n value (any, lazy) ${r("The value to return if value itself is not #N/A an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an #N/A error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(o){i=o.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},yd={description:r("Returns a value depending on multiple logical expressions."),args:Es(`\n condition1 (boolean, lazy) ${r("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")}\n value1 (any, lazy) ${r("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${r("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${r("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){Rs((()=>e.length%2==0),r("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(_s(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(r("No match."))},isExported:!0},xd={description:r("Returns opposite of provided logical value."),args:Es(`logical_expression (boolean) ${r("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!_s(e)},isExported:!0},Rd={description:r("Logical `or` operator."),args:Es(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return zs(e,(e=>(t=!0,i=i||e,!i))),Rs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Id={description:r("Logical `xor` operator."),args:Es(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return zs(e,(e=>(t=!0,i=i?!e:e,!0))),Rs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Td=Object.freeze({__proto__:null,AND:Sd,IF:Cd,IFERROR:Ed,IFNA:wd,IFS:yd,NOT:xd,OR:Rd,XOR:Id});const Ad={description:r("Column number of a specified cell."),args:Es(`cell_reference (meta, default=${r("The cell in which the formula is entered")}) ${r("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Rs((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return yi(i).left+1},isExported:!0},Md={description:r("Number of columns in a specified array or range."),args:Es(`range (meta) ${r("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=yi(e);return t.right-t.left+1},isExported:!0},Od={description:r("Horizontal lookup"),args:Es(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (range) ${r("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")}\n index (number) ${r("The row index of the value to be returned, where the first row in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.")}\n `),returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Ts(i)),s=Os(e);Rs((()=>1<=n&&n<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=_s(o);let l;return l=a?Zs(t,s,"nextSmaller","asc",t.length,qs):js(t,s,"strict",t.length,qs),Rs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ms(e))),t[l][n-1]},isExported:!0},Nd={description:r("Look up a value."),args:Es(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n search_array (range) ${r("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")}\n result_range (range, optional) ${r("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.")}\n `),returns:["ANY"],compute:function(e,t,i){let o=t.length,n=t[0].length;const s=Os(e),a=n>=o,l=Zs(t,s,"nextSmaller","asc",a?n:o,a?Gs:qs);return Rs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ms(e))),void 0===i?a?t[o-1][l]:t[l][n-1]:(o=i.length,n=i[0].length,Rs((()=>1===o||1===n),r("The result_range must be a single row or a single column.")),o>1?(Rs((()=>l<=o-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Rs((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},_d={description:r("Position of item in range that matches value."),args:Es(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The one-dimensional array to be searched.")}\n search_type (number, default=1) ${r("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){let o=Ts(i);const n=Os(e),s=t.length,a=t[0].length;Rs((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?Gs:qs,h=1===s?t[0].length:t.length;switch(o=Math.sign(o),o){case 1:l=Zs(t,n,"nextSmaller","asc",h,c);break;case 0:l=js(t,n,"strict",h,c);break;case-1:l=Zs(t,n,"nextGreater","desc",h,c)}return Rs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ms(e))),l+1},isExported:!0},Fd={description:r("Row number of a specified cell."),args:Es(`cell_reference (meta, default=${r("The cell in which the formula is entered by default")}) ${r("The cell whose row number will be returned.")}`),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),Rs((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return yi(e).top+1},isExported:!0},Dd={description:r("Number of rows in a specified array or range."),args:Es(`range (meta) ${r("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=yi(e);return t.bottom-t.top+1},isExported:!0},kd={description:r("Vertical lookup."),args:Es(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")}\n index (number) ${r("The column index of the value to be returned, where the first column in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.")}\n `),returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Ts(i)),s=Os(e);Rs((()=>1<=n&&n<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=_s(o);let l;return l=a?Zs(t,s,"nextSmaller","asc",t[0].length,Gs):js(t,s,"strict",t[0].length,Gs),Rs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ms(e))),t[n-1][l]},isExported:!0},$d={description:r("Search a range for a match and return the corresponding item from a second range."),args:Es(`\n search_key (any) ${r("The value to search for.")}\n lookup_range (any, range) ${r("The range to consider for the search. Should be a single column or a single row.")}\n return_range (any, range) ${r("The range containing the return value. Should have the same dimensions as lookup_range.")}\n if_not_found (any, lazy, optional) ${r("If a valid match is not found, return this value.")}\n match_mode (any, default=0) ${r("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")}\n search_mode (any, default=1) ${r("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. ")}\n\n `),returns:["ANY"],compute:function(e,t,i,o,n=0,s=1){const a=Math.trunc(Ts(n)),l=Math.trunc(Ts(s)),c=Os(e);Rs((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),Rs((()=>1===i.length||1===i[0].length),r("return_range should be either a single row or single column.")),Rs((()=>i.length===t.length&&i[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),Rs((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),Rs((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?Gs:qs,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=Zs(t,c,u,2===l?"asc":"desc",d,h)}else p=js(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==o?void 0:o();return Rs((()=>!!m),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ms(e))),m},isExported:!0};var Ld=Object.freeze({__proto__:null,COLUMN:Ad,COLUMNS:Md,HLOOKUP:Od,LOOKUP:Nd,MATCH:_d,ROW:Fd,ROWS:Dd,VLOOKUP:kd,XLOOKUP:$d});const Pd={description:r("Sum of two numbers."),args:Es(`\n value1 (number) ${r("The first addend.")}\n value2 (number) ${r("The second addend.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ts(e)+Ts(t)}},Ud={description:r("Concatenation of two values."),args:Es(`\n value1 (string) ${r("The value to which value2 will be appended.")}\n value2 (string) ${r("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return Ms(e)+Ms(t)},isExported:!0},Vd={description:r("One number divided by another."),args:Es(`\n dividend (number) ${r("The number to be divided.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Ts(t);return Rs((()=>0!==i),r("The divisor must be different from zero.")),Ts(e)/i}};function zd(e){return null==e}const Bd={number:0,string:"",boolean:!1},Hd={description:r("Equal."),args:Es(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=zd(e)?Bd[typeof t]:e,t=zd(t)?Bd[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function Wd(e,t,i){e=zd(e)?Bd[typeof t]:e,t=zd(t)?Bd[typeof e]:t,"number"!=typeof e&&(e=Ms(e).toUpperCase()),"number"!=typeof t&&(t=Ms(t).toUpperCase());const o=typeof e,n=typeof t;return"string"===o&&"number"===n||("string"!==n||"number"!==o)&&i(e,t)}const Gd={description:r("Strictly greater than."),args:Es(`\n value1 (any) ${r("The value to test as being greater than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Wd(e,t,((e,t)=>e>t))}},qd={description:r("Greater than or equal to."),args:Es(`\n value1 (any) ${r("The value to test as being greater than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Wd(e,t,((e,t)=>e>=t))}},Zd={description:r("Less than."),args:Es(`\n value1 (any) ${r("The value to test as being less than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!qd.compute(e,t)}},jd={description:r("Less than or equal to."),args:Es(`\n value1 (any) ${r("The value to test as being less than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Gd.compute(e,t)}},Xd={description:r("Difference of two numbers."),args:Es(`\n value1 (number) ${r("The minuend, or number to be subtracted from.")}\n value2 (number) ${r("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ts(e)-Ts(t)}},Yd={description:r("Product of two numbers"),args:Es(`\n factor1 (number) ${r("The first multiplicand.")}\n factor2 (number) ${r("The second multiplicand.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ts(e)*Ts(t)}},Kd={description:r("Not equal."),args:Es(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Hd.compute(e,t)}},Qd={description:r("A number raised to a power."),args:Es(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],compute:function(e,t){return $a.compute(e,t)}},Jd={description:r("A number with the sign reversed."),args:Es(`\n value (number) ${r("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Ts(e)}},eu={description:r("Value interpreted as a percentage."),args:Es(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Ts(e)/100}},tu={description:r("A specified number, unchanged."),args:Es(`\n value (any) ${r("The number to return.")}\n `),returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var iu=Object.freeze({__proto__:null,ADD:Pd,CONCAT:Ud,DIVIDE:Vd,EQ:Hd,GT:Gd,GTE:qd,LT:Zd,LTE:jd,MINUS:Xd,MULTIPLY:Yd,NE:Kd,POW:Qd,UMINUS:Jd,UNARY_PERCENT:eu,UPLUS:tu});const ou=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,nu={description:r("Gets character associated with number."),args:Es(`\n table_number (number) ${r("The number of the character to look up from the current Unicode table in decimal format.")}\n `),returns:["STRING"],compute:function(e){const t=Math.trunc(Ts(e));return Rs((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},ru={description:r("Remove non-printable characters from a piece of text."),args:Es(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Ms(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},su={description:r("Appends strings to one another."),args:Es(`\n string1 (string, range<string>) ${r("The initial string.")}\n string2 (string, range<string>, repeating) ${r("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return Ps(e,((e,t)=>e+Ms(t)),"")},isExported:!0},au={description:r("Tests whether two strings are identical."),args:Es(`\n string1 (string) ${r("The first string to compare.")}\n string2 (string) ${r("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Ms(e)===Ms(t)},isExported:!0},lu={description:r("First position of string found in text, case-sensitive."),args:Es(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const o=Ms(e),n=Ms(t),s=Ts(i);Rs((()=>""!==n),r("The text_to_search must be non-empty.")),Rs((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=n.indexOf(o,s-1);return Rs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o.toString(),n)),a+1},isExported:!0},cu={description:r("Concatenates elements of arrays with delimiter."),args:Es(`\n delimiter (string) ${r("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${r("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${r("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const i=Ms(e);return Ps(t,((e,t)=>(e?e+i:"")+Ms(t)),"")}},hu={description:r("Substring from beginning of specified string."),args:Es(`\n text (string) ${r("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Ts(t[0]):1;return Rs((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString())),Ms(e).substring(0,i)},isExported:!0},du={description:r("Length of a string."),args:Es(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Ms(e).length},isExported:!0},uu={description:r("Converts a specified string to lowercase."),args:Es(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Ms(e).toLowerCase()},isExported:!0},gu={description:r("A segment of a string."),args:Es(`\n text (string) ${r("The string to extract a segment from.")}\n starting_at (number) ${r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")}\n extract_length (number) ${r("The length of the segment to extract.")}\n `),returns:["STRING"],compute:function(e,t,i){const o=Ms(e),n=Ts(t),s=Ts(i);return Rs((()=>n>=1),r("The starting_at argument (%s) must be positive greater than one.",n.toString())),Rs((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),o.slice(n-1,n+s-1)},isExported:!0},pu={description:r("Capitalizes each word in a specified string."),args:Es(`\n text_to_capitalize (string) ${r("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.")}\n `),returns:["STRING"],compute:function(e){return Ms(e).replace(ou,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},mu={description:r("Replaces part of a text string with different text."),args:Es(`\n text (string) ${r("The text, a part of which will be replaced.")}\n position (number) ${r("The position where the replacement will begin (starting from 1).")}\n length (number) ${r("The number of characters in the text to be replaced.")}\n new_text (string) ${r("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,i,o){const n=Ts(t);Rs((()=>n>=1),r("The position (%s) must be greater than or equal to 1.",n.toString()));const s=Ms(e),a=Ts(i),l=Ms(o);return s.substring(0,n-1)+l+s.substring(n-1+a)},isExported:!0},fu={description:r("A substring from the end of a specified string."),args:Es(`\n text (string) ${r("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Ts(t[0]):1;Rs((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString()));const o=Ms(e),n=o.length;return o.substring(n-i,n)},isExported:!0},vu={description:r("First position of string found in text, ignoring case."),args:Es(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const o=Ms(e).toLowerCase(),n=Ms(t).toLowerCase(),s=Ts(i);Rs((()=>""!==n),r("The text_to_search must be non-empty.")),Rs((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=n.indexOf(o,s-1);return Rs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o,n)),a+1},isExported:!0},bu={description:r("Replaces existing text with new text in a string."),args:Es(`\n text_to_search (string) ${r("The text within which to search and replace.")}\n search_for (string) ${r("The string to search for within text_to_search.")}\n replace_with (string) ${r("The string that will replace search_for.")}\n occurrence_number (number, optional) ${r("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o){const n=Ts(o);Rs((()=>n>=0),r("The occurrenceNumber (%s) must be positive or null.",n.toString()));const s=Ms(e),a=Ms(t);if(""===a)return s;const l=Ms(i),c=new RegExp(Ie(a),"g");if(0===n)return s.replace(c,l);let h=0;return s.replace(c,(e=>++h===n?l:e))},isExported:!0},Su={description:r("Combines text from multiple strings and/or arrays."),args:Es(`\n delimiter (string) ${r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${r("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${r("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...i){const o=Ms(e),n=_s(t);let r=0;return Ps(i,((e,t)=>n&&""===Ms(t)?e:(r++?e+o:"")+Ms(t)),"")},isExported:!0},Cu={description:r("Removes space characters."),args:Es(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Ms(e).trim()},isExported:!0},Eu={description:r("Converts a specified string to uppercase."),args:Es(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Ms(e).toUpperCase()},isExported:!0},wu={description:r("Converts a number to text according to a specified format."),args:Es(`\n number (number) ${r("The number, date or time to format.")}\n format (string) ${r("The pattern by which to format the number, enclosed in quotation marks.")}\n `),returns:["STRING"],compute:function(e,t){return Gt(Ts(e),Ms(t))},isExported:!0};const yu={database:rc,date:Pc,financial:ld,info:bd,lookup:Ld,logical:Td,math:el,misc:Ks,operators:iu,statistical:Wl,text:Object.freeze({__proto__:null,CHAR:nu,CLEAN:ru,CONCATENATE:su,EXACT:au,FIND:lu,JOIN:cu,LEFT:hu,LEN:du,LOWER:uu,MID:gu,PROPER:pu,REPLACE:mu,RIGHT:fu,SEARCH:vu,SUBSTITUTE:bu,TEXTJOIN:Su,TRIM:Cu,UPPER:Eu,TEXT:wu}),engineering:Vc},xu=/^[A-Z0-9\_\.]+$/;function Ru(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Iu(e()):Iu(e)}))}function Iu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Tu=new class extends ji{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(xu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=ys(t);return function(e){let t=!1,i=!1,o=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(r("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!n.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||o,s=!(n.optional||n.repeating||n.default);if(e&&s)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,i=n.optional,o=n.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),o=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Ru(e)),format:o(...e)}},super.add(e,i),this}};for(let e in yu){const t=yu[e];for(let i in t){const o=t[i];o.category=e,i=i.replace(/_/g,"."),Tu.add(i,{isExported:!1,...o})}}const Au=Tu.content,Mu=["%"],Ou="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Mu);function Nu(e){const t=e.split(""),i=[];for(;t.length;){let e=Bu(t)||Du(t)||$u(t)||Pu(t)||_u(t)||Hu(t)||Lu(t)||Vu(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function _u(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Fu={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Du(e){if(e[0]in Fu){const t=e.shift();return{type:Fu[t],value:t}}return null}function ku(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function $u(e){for(let t of Ou)if(ku(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Lu(e){const t=et(e).match(ai);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Pu(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const Uu=/\w|\.|!|\$/;function Vu(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Uu);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Au)return{type:"FUNCTION",value:e};return e.match(It)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const zu=/\s/;function Bu(e){let t=0;for(;e[0]&&e[0].match(zu);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function Hu(e){return ku(e,Y)?(e.splice(0,Y.length),{type:"INVALID_REFERENCE",value:Y}):null}const Wu=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Gu=["-","+"],qu=["%"],Zu=["*","+","&"],ju={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},Xu=6;function Yu(e){switch(e.type){case"NUMBER":case"SYMBOL":case"REFERENCE":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return ju[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function Ku(e,t,i){if("OPERATOR"===t.type){const o=Yu(t);if(qu.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const n=Qu(i,o);return{type:"BIN_OPERATION",value:t.value,left:e,right:n}}}throw new Error(oe)}function Qu(e,t){const i=e.shift();if(!i)throw new Error(oe);let o=function(e,t){var i,o,n,s;switch(e.type){case"DEBUGGER":const a=Qu(t,1e3);return a.debug=!0,a;case"NUMBER":return{type:"NUMBER",value:mi(e.value)};case"STRING":return{type:"STRING",value:Re(e.value)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(r("Wrong function call"));{const o=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?o.push({type:"UNKNOWN",value:""}):o.push(Qu(t,Xu));"COMMA"===(null===(i=t[0])||void 0===i?void 0:i.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){o.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?o.push({type:"UNKNOWN",value:""}):o.push(Qu(t,Xu))}const n=t.shift();if(!n||"RIGHT_PAREN"!==n.type)throw new Error(r("Wrong function call"));return{type:"FUNCALL",value:e.value,args:o}}case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(o=t[0])||void 0===o?void 0:o.value)&&"REFERENCE"===(null===(n=t[1])||void 0===n?void 0:n.type)){t.shift();const i=t.shift();return{type:"REFERENCE",value:`${e.value}:${null==i?void 0:i.value}`}}return{type:"REFERENCE",value:e.value};case"SYMBOL":if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value){if(Wu.test(e.value)&&"LEFT_PAREN"===(null===(s=t[0])||void 0===s?void 0:s.type))throw new p(e.value);throw new Error(r("Invalid formula"))}return{type:"STRING",value:e.value};case"LEFT_PAREN":const l=Qu(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),l;default:if("OPERATOR"===e.type&&Gu.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:Qu(t,ju[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(i,e);for(;e[0]&&Yu(e[0])>t;)o=Ku(o,e.shift(),e);return o}function Ju(e){return eg(Nu(e))}function eg(e){"OPERATOR"===(e=e.filter((e=>"SPACE"!==e.type)))[0].type&&"="===e[0].value&&e.splice(0,1);const t=Qu(e,0);if(e.length)throw new Error(oe);return t}function tg(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>tg(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:tg(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:tg(e.right,t,i),left:tg(e.left,t,i)};default:return e}}function ig(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>ig(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?og(e)+e.value:e.value+ng(e);case"BIN_OPERATION":return og(e)+e.value+ng(e)}}function og(e){const t=e.value,i="left"in e?e.left:e.operand,o=i.value;return"BIN_OPERATION"===i.type&&ju[o]<ju[t]?`(${ig(i)})`:ig(i)}function ng(e){const t=e.value,i="right"in e?e.right:e.operand,o=ju[i.value],n=ju[t];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:o<n?r=!0:o!==n||Zu.includes(t)||(r=!0),r?`(${ig(i)})`:ig(i)}var rg;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(rg||(rg={}));const sg=(e,t=(()=>!0))=>[{goTo:e,guard:t}],ag=(e,t=(()=>!0))=>({goTo:e,guard:t}),lg={[rg.LeftRef]:{REFERENCE:sg(rg.Separator),NUMBER:sg(rg.FullRowSeparator),SYMBOL:[ag(rg.FullColumnSeparator,(e=>Tt(e.value))),ag(rg.FullRowSeparator,(e=>At(e.value)))]},[rg.FullColumnSeparator]:{SPACE:sg(rg.FullColumnSeparator),OPERATOR:sg(rg.RightColumnRef,(e=>":"===e.value))},[rg.FullRowSeparator]:{SPACE:sg(rg.FullRowSeparator),OPERATOR:sg(rg.RightRowRef,(e=>":"===e.value))},[rg.Separator]:{SPACE:sg(rg.Separator),OPERATOR:sg(rg.RightRef,(e=>":"===e.value))},[rg.RightRef]:{SPACE:sg(rg.RightRef),NUMBER:sg(rg.Found),REFERENCE:sg(rg.Found,(e=>Ot(e.value))),SYMBOL:sg(rg.Found,(e=>Mt(e.value)))},[rg.RightColumnRef]:{SPACE:sg(rg.RightColumnRef),SYMBOL:sg(rg.Found,(e=>Mt(e.value))),REFERENCE:sg(rg.Found,(e=>Ot(e.value)))},[rg.RightRowRef]:{SPACE:sg(rg.RightRowRef),NUMBER:sg(rg.Found),REFERENCE:sg(rg.Found,(e=>Ot(e.value)))},[rg.Found]:{}};function cg(e){var t;let i=0,o=lg[rg.LeftRef];const n=[];for(;void 0!==o;){const r=e[i++];if(!r)return null;const s=null===(t=o[r.type])||void 0===t?void 0:t.find((e=>e.guard(r))),a=s?s.goTo:void 0;switch(a){case void 0:return null;case rg.Found:return n.push(r),e.splice(0,i),{type:"REFERENCE",value:et(n.map((e=>e.value)))};default:o=lg[a],n.push(r)}}return null}function hg(e){const t=Nu(e),i=[];for(;t.length;)i.push(cg(t)||t.shift());return i}const dg=Tu.content,ug={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},gg={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function pg(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const mg={};function fg(e){const t=hg(e),{dependencies:i,constantValues:o}=function(e){const t={numbers:[],strings:[]},i=[];for(const o of e)switch(o.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(o.value);break;case"STRING":const e=Re(o.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=mi(o.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),n=function(e,t,i){return et(e.map((e=>{switch(e.type){case"STRING":const o=Re(e.value);return`|S${i.strings.indexOf(o)}|`;case"NUMBER":return`|N${i.numbers.indexOf(mi(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,o);if(!mg[n]){const s=eg([...t]);let a=1;if("BIN_OPERATION"===s.type&&":"===s.value)throw new Error(r("Invalid formula"));if("UNKNOWN"===s.type)throw new Error(r("Invalid formula"));const l=u(s),c=pg([`// ${n}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=dg[e.value.toUpperCase()],i=e.args,o=i.length;if(o<t.minArgRequired)throw new Error(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),o.toString()));if(o>t.maxArgPossible)throw new Error(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),o.toString()));const n=t.nbrArgRepeating;if(n>1){const i=t.args.length-n;if((o-i)%n!=0)throw new Error(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),n.toString()))}let s=[];for(let n=0;n<o;n++){const o=t.getArgToFocus(n+1)-1;if(0<=o&&o<t.args.length){const a=i[n],l=t.args[o],c=l.type||[],h=c.includes("META"),d=l.lazy,g=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),p=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(p&&"REFERENCE"!==a.type)throw new Error(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(n+1).toString(),a.type.toLowerCase()));const m=u(a,d,h,g,{functionName:e.value.toUpperCase(),paramIndex:n+1});s.push(m)}}return s}function u(e,t=!1,n=!1,s=!1,l={}){const c=[];let h,g,p;if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&n)throw new Error(r("Argument must be a reference to a cell or range."));switch(e.debug&&c.push("debugger;"),e.type){case"BOOLEAN":if(!t)return{id:`{ value: ${e.value} }`,code:""};h=a++,p=`{ value: ${e.value} }`;break;case"NUMBER":h=a++,p=`{ value: this.constantValues.numbers[${o.numbers.indexOf(e.value)}] }`;break;case"STRING":h=a++,p=`{ value: this.constantValues.strings[${o.strings.indexOf(e.value)}] }`;break;case"REFERENCE":const r=i.indexOf(e.value);h=a++,p=s?`range(deps[${r}])`:`ref(deps[${r}], ${n?"true":"false"}, "${l.functionName||ug["="]}", ${l.paramIndex})`;break;case"FUNCALL":h=a++;const m=d(e);c.push(m.map((e=>e.code)).join("\n")),g=e.value.toUpperCase(),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${m.map((e=>e.id))})`;break;case"UNARY_OPERATION":{h=a++,g=gg[e.value];const t=u(e.operand,!1,!1,!1,{functionName:g});c.push(t.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id})`;break}case"BIN_OPERATION":{h=a++,g=ug[e.value];const t=u(e.left,!1,!1,!1,{functionName:g}),i=u(e.right,!1,!1,!1,{functionName:g});c.push(t.code),c.push(i.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id}, ${i.id})`;break}case"UNKNOWN":if(!t)return{id:"undefined",code:""};h=a++,p="undefined"}if(t){return{id:`_${h}`,code:`const _${h} = () => {\n\t${pg(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}mg[n]={execute:h}}return{execute:mg[n].execute,dependencies:i,constantValues:o,tokens:t}}function vg(e){return function(e){let t=[],i="";return e.map(((e,o)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,o=Object.assign({},e,{start:t,end:t+i,length:i});return t=o.end,o}))}(hg(e))))}function bg(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=Nt(e.value),[o,n]=t.split(":"),r=i?`${Me(i)}!`:"",s=Sg(o),a=n?`:${Sg(n)}`:"";return{...e,value:r+s+a}}function Sg(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=Cg(e,"colrow");break;case"colrow":e=Cg(e,"row");break;case"row":e=Cg(e,"col");break;case"col":e=Cg(e,"none")}return e}function Cg(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}class Eg{constructor(e,t,i){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const o=e.filter((e=>0!==e));if(o.length)return o}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}Eg.getters=[];class wg extends Eg{constructor(e,t,i,o,n){super(t,i,o),this.getters=e,this.ui=o,this.selection=n}drawGrid(e,t){}}wg.layers=[];const yg=r("The cell you are trying to edit has been deleted.");class xg extends wg{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),i=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(i.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:o}=Nt(e.value),n=o||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==n)return!1;const s=this.getters.getRangeFromSheetXC(r,i);return _i(this.getters.expandZone(r,s.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const o=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(o,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(n),this.previousRef=n,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),o=this.getters.expandZone(e.sheetIdTo,Wi({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:yg}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}unsubscribe(){this.mode="inactive"}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(bg).map((e=>e.value)).join(""),o=this.currentContent,n=e[0].start,r=e[e.length-1].end,s=o.slice(0,n)+i+o.slice(r),a=s.length-o.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:45}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:yg});const{top:t,left:i}=Ai({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:yg});const{top:t,left:i}=Ai({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Ti({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Wi({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var i;const o=this.getters.getActiveCell();e&&(null===(i=null==o?void 0:o.format)||void 0===i?void 0:i.includes("%"))&&gi(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`),this.initialContent=(null==o?void 0:o.composerContent)||"",this.mode="editing";const{col:n,row:r}=this.getters.getPosition();this.col=n,this.row=r,this.sheetId=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const s=Wi({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){const e=this.getters.getActiveSheetId();this.cancelEditionAndActivateSheet();const{col:t,row:i}=this.getters.getMainCellPosition(this.sheetId,this.col,this.row);let o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const n=this.getters.getCell(e,t,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,i=e-t;i>0&&(o+=et(new Array(i).fill(")")))}else(null==n?void 0:n.isLink())&&(o=He(o,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:t,row:i,content:o})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:t,row:i});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){e=e.replace(/[\r\n]/g,"");const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?vg(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:r("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${Me(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){1===t.length&&qi(e.zone)>1?t.push({...t[0]}):2===t.length&&1===qi(e.zone)&&t.pop();const i=e.clone({parts:this.previousRange.parts});return this.getters.getSelectionRangeString(i,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:o,end:o}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const o=new Set(Object.values(i));let n=0;const r=()=>{for(;o.has(n);)n++;return o.add(n),n};for(const e of t){const t=e in i?i[e]:r();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return ct[t%ct.length]};return this.getReferencedRanges().map((i=>{const o=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(o),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let i=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type)||Mu.includes(o.value);){if("SPACE"!==o.type||i<1)return!1;i--,o=this.currentTokens[i]}for(i=t+1,o=this.currentTokens[i];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;i++,o=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}xg.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const Rg=Tu.content,Ig=new ji;Ig.add("functions",(()=>Object.keys(Rg).map((e=>({text:e,description:Rg[e].description}))))),go`
983
+ `;class Cs extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:o}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:n,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return`bottom: ${o-r+15}px;left: ${n-1}px;border: 1px solid ${i};background-color: ${i};${this.props.active?"opacity:1 !important":""}`}}Cs.template="o-spreadsheet-ClientTag";const Es=/(.*?)\((.*?)\)(.*)/,ws=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function ys(e){let t=e.split("\n");const i=[];for(let e of t)e=e.trim(),e&&i.push(xs(e));return i}function xs(e){let t,i=e.match(Es),o=i[1].trim(),n=[],r=!1,s=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let o=ws.find((e=>i===e));o?n.push(o):"RANGE<ANY>"===i?n.push("RANGE"):"OPTIONAL"===i?r=!0:"REPEATING"===i?s=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:o,description:i[3].trim(),type:n};return r&&(l.optional=!0),s&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function Rs(e){let t=0,i=0,o=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||i++,n.repeating&&o++;const n=e;return n.minArgRequired=i,n.maxArgPossible=o?1/0:t,n.nbrArgRepeating=o,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,o),n}const Is=["number","string","boolean","undefined"];function Ts(e,t){if(!e())throw new Error(t)}const As=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Os(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(pi(e)||""===e)return fi(e);const t=me(e);if(t)return t.value;throw new Error(As(e));default:return 0}}function Ms(e){if(""===e)throw new Error(As(e));return Os(e)}function Ns(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function _s(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const Fs=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function Ds(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(Fs(e))}return!1;case"number":return!!e;default:return!1}}function ks(e){return ve(Os(e))}function $s(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)t(o[i][n])}else i(o)}function Ls(e,t){$s(e,t,t)}function Ps(e,t){$s(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Ms(e))}))}function Us(e,t,i,o){let n=o;for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let r=0;r<i;r++)for(let i=0;i<e;i++)n=t(n,o[i][r])}else n=i(n,o);return n}function Vs(e,t,i){return Us(e,t,t,i)}function zs(e,t,i){return Us(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,Ms(i))),i)}function Bs(e,t,i){return Us(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Os(i):0):e),((e,i)=>t(e,Os(i))),i)}function Hs(e,t){return function(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)if(!t(o[i][n]))return}else if(!i(o))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(Fs(e));return Ds(e)}(e))))}function Ws(e,t){let i,o,n=e.substring(0,2);"<="===n||">="===n||"<>"===n?(i=n,o=e.substring(2)):(n=e.substring(0,1),"<"===n||">"===n||"="===n?(i=n,o=e.substring(1)):(i="=",o=e)),pi(o)?o=Os(o):"TRUE"!==o&&"FALSE"!==o||(o=Ds(o));const r={operator:i,operand:o};return"string"==typeof o&&(t&&(o+="*"),r.regexp=function(e){let t="",i="";for(let o of e)"?"===o&&"~"!==i?t+=".":"*"===o&&"~"!==i?t+=".*":("*"!==o&&"?"!==o||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(o)&&(t+="\\"),t+=o),i=o;return new RegExp("^"+t+"$","i")}(o)),r}function Gs(e,t){const{operator:i,operand:o}=t;if(void 0===e||void 0===o)return!1;if("number"==typeof o&&"="===i)return Ns(e)===Ns(o);if("<>"===i||"="===i){let n;return n=typeof e==typeof o&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===o),"="===i?n:!n}if(typeof e==typeof o)switch(i){case"<":return e<o;case">":return e>o;case"<=":return e<=o;case">=":return e>=o}return!1}function qs(e,t,i=!1){const o=e.length;if(o%2==1)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=e[0].length,s=e[0][0].length;let a=[];for(let t=0;t<o-1;t+=2){const o=e[t];if(!Array.isArray(o)||o.length!==n||o[0].length!==s)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Ns(e[t+1]);a.push(Ws(l,i))}for(let i=0;i<n;i++)for(let n=0;n<s;n++){let r=!0;for(let t=0;t<o-1;t+=2){if(r=Gs(e[t][i][n],a[t/2]),!r)break}r&&t(i,n)}}function Zs(e,t){return _s(e[0][t])}function js(e,t){return _s(e[t][0])}function Xs(e,t,i,o,n,r){if(null==t)return-1;const s=typeof t;let a,l,c,h,d,u,g=0,p=n-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=r(e,h),u=typeof d;g<h&&s!==u;)h--,d=r(e,h),u=typeof d;u===s&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h),"asc"===o&&d>t||"desc"===o&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function Ys(e,t,i,o,n,r=!1){if(null==t)return-1;const s=r?(e,t)=>n(e,o-t-1):n;let a,l=-1;for(let n=0;n<o;n++){const c=s(e,n);if(c===t)return r?o-n-1:n;"nextSmaller"===i?(!a&&Ks(t,c)>=0||Ks(t,c)>=0&&Ks(c,a)>0)&&(a=c,l=n):"nextGreater"===i&&(!a&&Ks(t,c)<=0||Ks(t,c)<=0&&Ks(c,a)<0)&&(a=c,l=n)}return r?o-l-1:l}function Ks(e,t){let i=Is.indexOf(typeof e)-Is.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}const Qs={description:r("Apply a large number format"),args:ys(`\n value (number) ${r("The number.")}\n unit (string, optional) ${r("The formatting unit. Use 'k', 'm', or 'b' to force the unit")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Os(e.value)),o=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return ii(o,1e3,"k");case"m":return ii(o,1e6,"m");case"b":return ii(o,1e9,"b");default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?ii(o,0,""):i<1e8?ii(o,1e3,"k"):i<1e11?ii(o,1e6,"m"):ii(o,1e9,"b")},compute:function(e){return Os(e)}};var Js=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Qs});const ea={description:r("Absolute value of a number."),args:ys(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Os(e))},isExported:!0},ta={description:r("Inverse cosine of a value, in radians."),args:ys(`\n value (number) ${r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},ia={description:r("Inverse hyperbolic cosine of a number."),args:ys(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},oa={description:r("Inverse cotangent of a value."),args:ys(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},na={description:r("Inverse hyperbolic cotangent of a value."),args:ys(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>Math.abs(t)>1),r("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},ra={description:r("Inverse sine of a value, in radians."),args:ys(`\n value (number) ${r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},sa={description:r("Inverse hyperbolic sine of a number."),args:ys(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Os(e))},isExported:!0},aa={description:r("Inverse tangent of a value, in radians."),args:ys(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Os(e))},isExported:!0},la={description:r("Angle from the X axis to a point (x,y), in radians."),args:ys(`\n x (number) ${r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Os(e),o=Os(t);return Ts((()=>0!==i||0!==o),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(o,i)},isExported:!0},ca={description:r("Inverse hyperbolic tangent of a number."),args:ys(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},ha={description:r("Rounds number up to nearest multiple of factor."),args:ys(`\n value (number) ${r("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Os(e),o=Os(t);return Ts((()=>o>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.ceil(i/o)*o:0},isExported:!0},da={description:r("Rounds number up to nearest multiple of factor."),args:ys(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Os(t);if(0===o)return 0;const n=Os(e);if(o=Math.abs(o),n>=0)return Math.ceil(n/o)*o;return 0===Os(i)?-Math.floor(Math.abs(n)/o)*o:-Math.ceil(Math.abs(n)/o)*o},isExported:!0},ua={description:r("Rounds number up to nearest multiple of factor."),args:ys(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return da.compute(e,t,0)},isExported:!0},ga={description:r("Cosine of an angle provided in radians."),args:ys(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Os(e))},isExported:!0},pa={description:r("Hyperbolic cosine of any real number."),args:ys(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Os(e))},isExported:!0},ma={description:r("Cotangent of an angle provided in radians."),args:ys(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},fa={description:r("Hyperbolic cotangent of any real number."),args:ys(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},va={description:r("Number of empty values."),args:ys(`\n value1 (any, range) ${r("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${r("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return Vs(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},ba={description:r("A conditional count across a range."),args:ys(`\n range (range) ${r("The range that is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return qs(e,((e,i)=>{t+=1})),t},isExported:!0},Sa={description:r("Count values depending on multiple criteria."),args:ys(`\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return qs(e,((e,i)=>{t+=1})),t},isExported:!0};function Ca(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Ea={description:r("Counts number of unique values in a range."),args:ys(`\n value1 (any, range) ${r("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return Vs(e,((e,t)=>Ca(t)?e.add(t):e),new Set).size}},wa={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:ys(`\n range (range) ${r("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=new Set;return qs(t,((t,o)=>{const n=e[t][o];Ca(n)&&i.add(n)})),i.size}},ya={description:r("Cosecant of an angle provided in radians."),args:ys(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},xa={description:r("Hyperbolic cosecant of any real number."),args:ys(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Ra={description:r("Converts from another base to decimal."),args:ys(`\n value (string) ${r("The number to convert.")},\n base (number) ${r("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let i=Os(t);i=Math.floor(i),Ts((()=>2<=i&&i<=36),r("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const o=Ns(e);if(""===o)return 0;Ts((()=>!!o.match(/^-?[a-z0-9]+$/i)),r("The value (%s) must be a valid base %s representation.",o,i.toString()));const n=parseInt(o,i);return Ts((()=>!isNaN(n)),r("The value (%s) must be a valid base %s representation.",o,i.toString())),n},isExported:!0},Ia={description:r("Converts an angle value in radians to degrees."),args:ys(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Os(e)/Math.PI},isExported:!0},Ta={description:r("Euler's number, e (~2.718) raised to a power."),args:ys(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Os(e))},isExported:!0},Aa={description:r("Rounds number down to nearest multiple of factor."),args:ys(`\n value (number) ${r("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Os(e),o=Os(t);return Ts((()=>o>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.floor(i/o)*o:0},isExported:!0},Oa={description:r("Rounds number down to nearest multiple of factor."),args:ys(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Os(t);if(0===o)return 0;const n=Os(e);if(o=Math.abs(o),n>=0)return Math.floor(n/o)*o;return 0===Os(i)?-Math.ceil(Math.abs(n)/o)*o:-Math.floor(Math.abs(n)/o)*o},isExported:!0},Ma={description:r("Rounds number down to nearest multiple of factor."),args:ys(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Oa.compute(e,t,0)},isExported:!0},Na={description:r("Whether the provided value is even."),args:ys(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Ms(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},_a={description:r("Rounds number up to nearest multiple of factor."),args:ys(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return da.compute(e,t,0)},isExported:!0},Fa={description:r("Whether the provided value is even."),args:ys(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Ms(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Da={description:r("The logarithm of a number, base e (euler's number)."),args:ys(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Os(e);return Ts((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},ka={description:r("Modulo (remainder) operator."),args:ys(`\n dividend (number) ${r("The number to be divided to find the remainder.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Os(t);Ts((()=>0!==i),r("The divisor must be different from 0."));const o=Os(e)%i;return o>0&&i<0||o<0&&i>0?o+i:o},isExported:!0},$a={description:r("Rounds a number up to the nearest odd integer."),args:ys(`\n value (number) ${r("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Os(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},La={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Pa={description:r("A number raised to a power."),args:ys(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Os(e),o=Os(t);return Ts((()=>i>=0||Number.isInteger(o)),r("The exponent (%s) must be an integer when the base is negative.",o.toString())),Math.pow(i,o)},isExported:!0},Ua={description:r("Result of multiplying a series of numbers together."),args:ys(`\n factor1 (number, range<number>) ${r("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${r("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(i*=o,t+=1);else null!=o&&(i*=Ms(o),t+=1);return 0===t?0:i},isExported:!0},Va={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},za={description:r("Random integer between two values, inclusive."),args:ys(`\n low (number) ${r("The low end of the random range.")}\n high (number) ${r("The high end of the random range.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Os(e);Number.isInteger(i)||(i=Math.ceil(i));let o=Os(t);return Number.isInteger(o)||(o=Math.floor(o)),Ts((()=>i<=o),r("The high (%s) must be greater than or equal to the low (%s).",o.toString(),i.toString())),i+Math.ceil((o-i+1)*Math.random())-1},isExported:!0},Ba={description:r("Rounds a number according to standard rules."),args:ys(`\n value (number) ${r("The value to round to places number of places.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Os(e);let o=Os(t);const n=Math.abs(i);let r;return 0===o?r=Math.round(n):(Number.isInteger(o)||(o=Math.trunc(o)),r=Math.round(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?r:-r},isExported:!0},Ha={description:r("Rounds down a number."),args:ys(`\n value (number) ${r("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Os(e);let o=Os(t);const n=Math.abs(i);let r;return 0===o?r=Math.floor(n):(Number.isInteger(o)||(o=Math.trunc(o)),r=Math.floor(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?r:-r},isExported:!0},Wa={description:r("Rounds up a number."),args:ys(`\n value (number) ${r("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Os(e);let o=Os(t);const n=Math.abs(i);let r;return 0===o?r=Math.ceil(n):(Number.isInteger(o)||(o=Math.trunc(o)),r=Math.ceil(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?r:-r},isExported:!0},Ga={description:r("Secant of an angle provided in radians."),args:ys(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Os(e))},isExported:!0},qa={description:r("Hyperbolic secant of any real number."),args:ys(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Os(e))},isExported:!0},Za={description:r("Sine of an angle provided in radians."),args:ys(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Os(e))},isExported:!0},ja={description:r("Hyperbolic sine of any real number."),args:ys(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Os(e))},isExported:!0},Xa={description:r("Positive square root of a positive number."),args:ys(`\n value (number) ${r("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Os(e);return Ts((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},Ya={description:r("Sum of a series of numbers and/or cells."),args:ys(`\n value1 (number, range<number>) ${r("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${r("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return zs(e,((e,t)=>e+t),0)},isExported:!0},Ka={description:r("A conditional sum across a range."),args:ys(`\n criteria_range (range) ${r("The range which is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${r("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let o=0;return qs([e,t],((e,t)=>{const n=i[e][t];"number"==typeof n&&(o+=n)})),o},isExported:!0},Qa={description:r("Sums a range depending on multiple criteria."),args:ys(`\n sum_range (range) ${r("The range to sum.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges to check.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0;return qs(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i+=n)})),i},isExported:!0},Ja={description:r("Tangent of an angle provided in radians."),args:ys(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Os(e))},isExported:!0},el={description:r("Hyperbolic tangent of any real number."),args:ys(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Os(e))},isExported:!0},tl={description:r("Truncates a number."),args:ys(`\n value (number) ${r("The value to be truncated.")}\n places (number, default=0) ${r("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Os(e);let o=Os(t);return 0===o?Math.trunc(i):(Number.isInteger(o)||(o=Math.trunc(o)),Math.trunc(i*Math.pow(10,o))/Math.pow(10,o))},isExported:!0};var il=Object.freeze({__proto__:null,ABS:ea,ACOS:ta,ACOSH:ia,ACOT:oa,ACOTH:na,ASIN:ra,ASINH:sa,ATAN:aa,ATAN2:la,ATANH:ca,CEILING:ha,CEILING_MATH:da,CEILING_PRECISE:ua,COS:ga,COSH:pa,COT:ma,COTH:fa,COUNTBLANK:va,COUNTIF:ba,COUNTIFS:Sa,COUNTUNIQUE:Ea,COUNTUNIQUEIFS:wa,CSC:ya,CSCH:xa,DECIMAL:Ra,DEGREES:Ia,EXP:Ta,FLOOR:Aa,FLOOR_MATH:Oa,FLOOR_PRECISE:Ma,ISEVEN:Na,ISO_CEILING:_a,ISODD:Fa,LN:Da,MOD:ka,ODD:$a,PI:La,POWER:Pa,PRODUCT:Ua,RAND:Va,RANDBETWEEN:za,ROUND:Ba,ROUNDDOWN:Ha,ROUNDUP:Wa,SEC:Ga,SECH:qa,SIN:Za,SINH:ja,SQRT:Xa,SUM:Ya,SUMIF:Ka,SUMIFS:Qa,TAN:Ja,TANH:el,TRUNC:tl});function ol(e,t,i){let o=[],n=[],s=0,a=0;Ls([e],(e=>{o.push(e),s+=1})),Ls([t],(e=>{n.push(e),a+=1})),Ts((()=>s===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",s.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<s;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}Ts((()=>0!==l&&(!i||1!==l)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<s;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function nl(e,t,i){let o=0,n=0;const s=i?Bs:zs;n=s(e,((e,t)=>(o+=1,e+t)),0),Ts((()=>0!==o&&(!t||1!==o)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/o;return s(e,((e,t)=>e+Math.pow(t-a,2)),0)/(o-(t?1:0))}function rl(e,t,i){const o=Os(t);Ts((()=>i?0<=o&&o<=1:0<o&&o<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,s=[],a=0;return Ls(e,(e=>{"number"==typeof e&&(n=Xs(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(n+1,0,e),a++)})),Ts((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),i||Ts((()=>1/(a+1)<=o&&o<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),vi(s,o,i)}const sl={description:r("Average magnitude of deviations from mean."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const i=zs(e,((e,i)=>(t+=1,e+i)),0);Ts((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const o=i/t;return zs(e,((e,t)=>e+Math.abs(o-t)),0)/t},isExported:!0},al={description:r("Numerical average value in a dataset, ignoring text."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=zs(e,((e,i)=>(t+=1,e+i)),0);return Ts((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},ll=r("[[FUNCTION_NAME]] has mismatched range sizes."),cl=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),hl={description:r("Weighted average."),args:ys(`\n values (number, range<number>) ${r("Values to average.")}\n weights (number, range<number>) ${r("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${r("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${r("Additional weights.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,o=0,n=0;Ts((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let s=0;s<e.length-1;s+=2)if(t=e[s],i=e[s+1],Array.isArray(t)){Ts((()=>Array.isArray(i)),ll);let e=t.length,s=t[0].length;Ts((()=>e===i.length&&s===i[0].length),ll);for(let a=0;a<e;a++)for(let e=0;e<s;e++){let s=t[a][e],l=i[a][e],c="number"==typeof s,h="number"==typeof l;Ts((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(Ts((()=>l>=0),cl),o+=s*l,n+=l)}}else i=Os(i),t=Os(t),Ts((()=>i>=0),cl),o+=t*i,n+=i;return Ts((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n}},dl={description:r("Numerical average value in a dataset."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Bs(e,((e,i)=>(t+=1,e+i)),0);return Ts((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},ul={description:r("Average of values depending on criteria."),args:ys(`\n criteria_range (range) ${r("The range to check against criterion.")}\n criterion (string) ${r("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${r("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let o=0,n=0;return qs([e,t],((t,r)=>{const s=(i||e)[t][r];"number"==typeof s&&(o+=1,n+=s)})),Ts((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},gl={description:r("Average of values depending on multiple criteria."),args:ys(`\n average_range (range) ${r("The range to average.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0,o=0;return qs(t,((t,n)=>{const r=e[t][n];"number"==typeof r&&(i+=1,o+=r)})),Ts((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},pl={description:r("The number of numeric values in dataset."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||pi(i)||me(i))&&(t+=1);return t},isExported:!0},ml={description:r("The number of values in a dataset."),args:ys(`\n value1 (any, range) ${r("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return Vs(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},fl={description:r("The covariance of a dataset."),args:ys(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ol(e,t,!1)},isExported:!0},vl={description:r("The covariance of a dataset."),args:ys(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ol(e,t,!1)},isExported:!0},bl={description:r("The sample covariance of a dataset."),args:ys(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ol(e,t,!0)},isExported:!0},Sl={description:r("Nth largest element from a data set."),args:ys(`\n data (any, range) ${r("Array or range containing the dataset to consider.")}\n n (number) ${r("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Os(t));let o,n=[],s=0;Ls([e],(e=>{"number"==typeof e&&(o=Xs(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),s++,s>i&&(n.shift(),s--))}));const a=n.shift();return Ts((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Ts((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Cl={description:r("Maximum value in a numeric dataset."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=zs(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},El={description:r("Maximum numeric value in a dataset."),args:ys(`\n value1 (any, range) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Bs(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},wl={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:ys(`\n range (range) ${r("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return qs(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i<n?n:i)})),i===-1/0?0:i},isExported:!0},yl={description:r("Median value in a numeric dataset."),args:ys(`\n value1 (any, range) ${r("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return Ps(e,(e=>{t.push(e)})),rl(t,.5,!0)},isExported:!0},xl={description:r("Minimum value in a numeric dataset."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=zs(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Rl={description:r("Minimum numeric value in a dataset."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Bs(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Il={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:ys(`\n range (range) ${r("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=1/0;return qs(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i>n?n:i)})),i===1/0?0:i},isExported:!0},Tl={description:r("Value at a given percentile of a dataset."),args:ys(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Ol.compute(e,t)},isExported:!0},Al={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:ys(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return rl([e],t,!1)},isExported:!0},Ol={description:r("Value at a given percentile of a dataset."),args:ys(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return rl([e],t,!0)},isExported:!0},Ml={description:r("Value nearest to a specific quartile of a dataset."),args:ys(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return _l.compute(e,t)},isExported:!0},Nl={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:ys(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return rl([e],.25*Math.trunc(Os(t)),!1)},isExported:!0},_l={description:r("Value nearest to a specific quartile of a dataset."),args:ys(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return rl([e],.25*Math.trunc(Os(t)),!0)},isExported:!0},Fl={description:r("Nth smallest element in a data set."),args:ys(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n n (number) ${r("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Os(t));let o,n=[],s=0;Ls([e],(e=>{"number"==typeof e&&(o=Xs(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),s++,s>i&&(n.pop(),s--))}));const a=n.pop();return Ts((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),Ts((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Dl={description:r("Standard deviation."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Vl.compute(...e))},isExported:!0},kl={description:r("Standard deviation of entire population."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(zl.compute(...e))},isExported:!0},$l={description:r("Standard deviation."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Bl.compute(...e))},isExported:!0},Ll={description:r("Standard deviation of sample (text as 0)."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Hl.compute(...e))},isExported:!0},Pl={description:r("Standard deviation of entire population."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Wl.compute(...e))},isExported:!0},Ul={description:r("Standard deviation of entire population (text as 0)."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Gl.compute(...e))},isExported:!0},Vl={description:r("Variance."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return nl(e,!0,!1)},isExported:!0},zl={description:r("Variance of entire population."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return nl(e,!1,!1)},isExported:!0},Bl={description:r("Variance."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return nl(e,!0,!1)},isExported:!0},Hl={description:r("Variance of sample (text as 0)."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return nl(e,!0,!0)},isExported:!0},Wl={description:r("Variance of entire population."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return nl(e,!1,!1)},isExported:!0},Gl={description:r("Variance of entire population (text as 0)."),args:ys(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return nl(e,!1,!0)},isExported:!0};var ql=Object.freeze({__proto__:null,AVEDEV:sl,AVERAGE:al,AVERAGE_WEIGHTED:hl,AVERAGEA:dl,AVERAGEIF:ul,AVERAGEIFS:gl,COUNT:pl,COUNTA:ml,COVAR:fl,COVARIANCE_P:vl,COVARIANCE_S:bl,LARGE:Sl,MAX:Cl,MAXA:El,MAXIFS:wl,MEDIAN:yl,MIN:xl,MINA:Rl,MINIFS:Il,PERCENTILE:Tl,PERCENTILE_EXC:Al,PERCENTILE_INC:Ol,QUARTILE:Ml,QUARTILE_EXC:Nl,QUARTILE_INC:_l,SMALL:Fl,STDEV:Dl,STDEV_P:kl,STDEV_S:$l,STDEVA:Ll,STDEVP:Pl,STDEVPA:Ul,VAR:Vl,VAR_P:zl,VAR_S:Bl,VARA:Hl,VARP:Wl,VARPA:Gl});function Zl(e,t,i){var o;const n=new Map,s=e.length;for(let t=s-1;t>=0;t--)n.set(Ns(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(r("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||s-1<a)throw new Error(r("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),s.toString()))}else{const e=Ns(t).toUpperCase();if(a=null!==(o=n.get(e))&&void 0!==o?o:-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Ns(t),[...n.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(r("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let o=[],r=!0;for(let s=0;s<i.length;s++){const a=Ns(i[s][0]).toUpperCase(),l=n.get(a),c=i[s][t];if(void 0!==c){if(void 0===l){r=!1;break}o.push([e[l].slice(1,h)]),o.push(c)}}if(r){if(!(o.length>0)){c=new Set(Array(h-1).keys());break}qs(o,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const jl=ys(`\n database (range) ${r("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")}\n field (any) ${r("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${r("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),Xl={description:r("Average of a set of values from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return al.compute([o])},isExported:!0},Yl={description:r("Counts values from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return pl.compute([o])},isExported:!0},Kl={description:r("Counts values and text from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return ml.compute([o])},isExported:!0},Ql={description:r("Single value from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return Ts((()=>1===o.length),r("More than one match found in DGET evaluation.")),o[0]},isExported:!0},Jl={description:r("Maximum of values from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return Cl.compute([o])},isExported:!0},ec={description:r("Minimum of values from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return xl.compute([o])},isExported:!0},tc={description:r("Product of values from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return Ua.compute([o])},isExported:!0},ic={description:r("Standard deviation of population sample from table."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return Dl.compute([o])},isExported:!0},oc={description:r("Standard deviation of entire population from table."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return Pl.compute([o])},isExported:!0},nc={description:r("Sum of values from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return Ya.compute([o])},isExported:!0},rc={description:r("Variance of population sample from table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return Vl.compute([o])},isExported:!0},sc={description:r("Variance of a population from a table-like range."),args:jl,returns:["NUMBER"],compute:function(e,t,i){const o=Zl(e,t,i);return Wl.compute([o])},isExported:!0};var ac=Object.freeze({__proto__:null,DAVERAGE:Xl,DCOUNT:Yl,DCOUNTA:Kl,DGET:Ql,DMAX:Jl,DMIN:ec,DPRODUCT:tc,DSTDEV:ic,DSTDEVP:oc,DSUM:nc,DVAR:rc,DVARP:sc});const lc={description:r("Converts year/month/day into a date."),args:ys(`\n year (number) ${r("The year component of the date.")}\n month (number) ${r("The month component of the date.")}\n day (number) ${r("The day component of the date.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let o=Math.trunc(Os(e));const n=Math.trunc(Os(t)),s=Math.trunc(Os(i));Ts((()=>0<=o&&o<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",o.toString())),o<1900&&(o+=1900);const a=be(new Date(o,n-1,s));return Ts((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},cc={description:r("Converts a date string to a date value."),args:ys(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ns(e),i=me(t);return Ts((()=>null!==i),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},hc={description:r("Day of the month that a specific date falls on."),args:ys(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return ks(e).getDate()},isExported:!0},dc={description:r("Number of days between two dates."),args:ys(`\n end_date (date) ${r("The end of the date range.")}\n start_date (date) ${r("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=ks(e),o=ks(t),n=i.getTime()-o.getTime();return Math.round(n/le)},isExported:!0},uc={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:ys(`\n start_date (date) ${r("The start date to consider in the calculation.")}\n end_date (date) ${r("The end date to consider in the calculation.")}\n method (number, default=0) ${r("An indicator of what day count method to use. (0) US NASD method (1) European method")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){const o=Os(e),n=Os(t),r=Ds(i)?4:0,s=_c.compute(e,t,r);return Math.sign(n-o)*Math.round(360*s)},isExported:!0},gc={description:r("Date a number of months before/after another date."),args:ys(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return be(Ee(ks(e),Math.trunc(Os(t)),!1))},isExported:!0},pc={description:r("Last day of a month before or after a date."),args:ys(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=ks(e),o=Math.trunc(Os(t)),n=i.getFullYear(),r=i.getMonth();return be(new Date(n,r+o+1,0))},isExported:!0},mc={description:r("Hour component of a specific time."),args:ys(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return ks(e).getHours()},isExported:!0},fc={description:r("ISO week number of the year."),args:ys(`\n date (date) ${r("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n `),returns:["NUMBER"],compute:function(e){const t=ks(e),i=t.getFullYear();let o=1;for(;4!==new Date(i,0,o).getDay();)o+=1;const n=new Date(i,0,o-3);let r=31;for(;4!==new Date(i,11,r).getDay();)r-=1;const s=new Date(i,11,r+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=s.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Date(i,11,r+3+1);break;case-1:let e=1;for(;4!==new Date(i-1,0,e).getDay();)e+=1;l=new Date(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/le;return Math.floor(c/7)+1},isExported:!0},vc={description:r("Minute component of a specific time."),args:ys(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return ks(e).getMinutes()},isExported:!0},bc={description:r("Month of the year a specific date falls in"),args:ys(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return ks(e).getMonth()+1},isExported:!0},Sc={description:r("Net working days between two provided days."),args:ys(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i){return Ec.compute(e,t,1,i)},isExported:!0};function Cc(e){if("string"==typeof e){Ts((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),r('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return Ts((()=>1<=e&&e<=7||11<=e&&e<=17),r("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(r("The weekend must be a number or a string."))}const Ec={description:r("Net working days between two dates (specifying weekends)."),args:ys(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1,o){const n=ks(e),r=ks(t),s=Cc(i);let a=new Set;void 0!==o&&Ls([o],(e=>{const t=ks(e);a.add(t.getTime())}));const l=n.getTime()>r.getTime(),c=new Date((l?n:r).getTime());let h=new Date((l?r:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)s.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},wc={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-ae.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/le)+i},isExported:!0},yc={description:r("Minute component of a specific time."),args:ys(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return ks(e).getSeconds()},isExported:!0},xc={description:r("Converts hour/minute/second into a time."),args:ys(`\n hour (number) ${r("The hour component of the time.")}\n minute (number) ${r("The minute component of the time.")}\n second (number) ${r("The second component of the time.")}\n `),returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let o=Math.trunc(Os(e)),n=Math.trunc(Os(t)),s=Math.trunc(Os(i));return n+=Math.floor(s/60),s=s%60+(s<0?60:0),o+=Math.floor(n/60),n=n%60+(n<0?60:0),o%=24,Ts((()=>o>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),o/24+n/1440+s/86400},isExported:!0},Rc={description:r("Converts a time string into its serial number representation."),args:ys(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ns(e),i=me(t);Ts((()=>null!==i),r("The time_string (%s) cannot be parsed to date/time.",t));const o=i.value-Math.trunc(i.value);return o<0?1+o:o},isExported:!0},Ic={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return be(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Tc={description:r("Day of the week of the date provided (as number)."),args:ys(`\n date (date) ${r("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n type (number, default=1) ${r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=ks(e),o=Math.round(Os(t)),n=i.getDay();return Ts((()=>[1,2,3].includes(o)),r("The type (%s) must be 1, 2 or 3.",o.toString())),1===o?n+1:2===o?0===n?7:n:0===n?6:n-1},isExported:!0},Ac={description:r("Week number of the year."),args:ys(`\n date (date) ${r("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n type (number, default=1) ${r("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=ks(e),o=Math.round(Os(t));if(Ts((()=>1===o||2===o||11<=o&&o<=17||21===o),r("The type (%s) is out of range.",o.toString())),21===o)return fc.compute(e);let n;n=1===o||2===o?o-1:o-10==7?0:o-10;const s=i.getFullYear();let a=1,l=new Date(s,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(s,0,a);const c=(i.getTime()-l.getTime())/le;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Oc={description:r("Date after a number of workdays."),args:ys(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Mc.compute(e,t,1,i)},isExported:!0},Mc={description:r("Date after a number of workdays (specifying weekends)."),args:ys(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,o){let n=ks(e),s=Math.trunc(Os(t));"string"==typeof i&&Ts((()=>"1111111"!==i),r("The weekend (%s) must be different from '1111111'.",i));const a=Cc(i);let l=new Set;void 0!==o&&Ls([o],(e=>{const t=ks(e);l.add(t.getTime())}));let c=new Date(n.getTime()),h=c.getTime();const d=Math.sign(s);let u=Math.abs(s);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-ae.getTime();return Math.round(g/le)},isExported:!0},Nc={description:r("Year specified by a given date."),args:ys(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return ks(e).getFullYear()},isExported:!0},_c={description:r("Exact number of years between two dates."),args:ys(`\n start_date (date) ${r("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n end_date (date) ${r("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n day_count_convention (number, default=0) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){let o=Math.trunc(Os(e)),n=Math.trunc(Os(t));const s=Math.trunc(Os(i));return Ts((()=>o>=0),r("The start_date (%s) must be positive or null.",o.toString())),Ts((()=>n>=0),r("The end_date (%s) must be positive or null.",n.toString())),Ts((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),ye(o,n,s)}},Fc={description:r("First day of the month preceding a date."),args:ys(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=ks(e),i=t.getFullYear(),o=t.getMonth();return be(new Date(i,o,1))}},Dc={description:r("Last day of the month following a date."),args:ys(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return pc.compute(e,0)}},kc={description:r("Quarter of the year a specific date falls in"),args:ys(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((ks(e).getMonth()+1)/3)}},$c={description:r("First day of the quarter of the year a specific date falls in."),args:ys(`\n date (date) ${r("The date from which to calculate the start of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=kc.compute(e),i=Nc.compute(e);return be(new Date(i,3*(t-1),1))}},Lc={description:r("Last day of the quarter of the year a specific date falls in."),args:ys(`\n date (date) ${r("The date from which to calculate the end of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=kc.compute(e),i=Nc.compute(e);return be(new Date(i,3*t,0))}},Pc={description:r("First day of the year a specific date falls in."),args:ys(`\n date (date) ${r("The date from which to calculate the start of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Nc.compute(e);return be(new Date(t,0,1))}},Uc={description:r("Last day of the year a specific date falls in."),args:ys(`\n date (date) ${r("The date from which to calculate the end of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Nc.compute(e);return be(new Date(t+1,0,0))}};var Vc=Object.freeze({__proto__:null,DATE:lc,DATEVALUE:cc,DAY:hc,DAYS:dc,DAYS360:uc,EDATE:gc,EOMONTH:pc,HOUR:mc,ISOWEEKNUM:fc,MINUTE:vc,MONTH:bc,NETWORKDAYS:Sc,NETWORKDAYS_INTL:Ec,NOW:wc,SECOND:yc,TIME:xc,TIMEVALUE:Rc,TODAY:Ic,WEEKDAY:Tc,WEEKNUM:Ac,WORKDAY:Oc,WORKDAY_INTL:Mc,YEAR:Nc,YEARFRAC:_c,MONTH_START:Fc,MONTH_END:Dc,QUARTER:kc,QUARTER_START:$c,QUARTER_END:Lc,YEAR_START:Pc,YEAR_END:Uc});const zc={description:r("Compare two numeric values, returning 1 if they're equal."),args:ys(`\n number1 (number) ${r("The first number to compare.")}\n number2 (number, default=0) ${r("The second number to compare.")}\n `),returns:["NUMBER"],compute:function(e,t=0){return Os(e)===Os(t)?1:0},isExported:!0};var Bc=Object.freeze({__proto__:null,DELTA:zc});function Hc(e,t){Ts((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function Wc(e,t){Ts((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function Gc(e){Ts((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function qc(e){Ts((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function Zc(e){Ts((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function jc(e){Ts((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function Xc(e){Ts((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Yc(e){Ts((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function Kc(e){Ts((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function Qc(e){Ts((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function Jc(e){Ts((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function eh(e){Ts((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function th(e){Ts((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function ih(e,t){Ts((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function oh(e){Ts((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function nh(e){Ts((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function rh(e){Ts((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function sh(e){Ts((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function ah(e,t){const i=ks(e),o=ks(t),n=new Date(i);n.setFullYear(i.getFullYear()+1),Ts((()=>o.getTime()<=n.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function lh(e,t,i){Xc(i),Ts((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),Ts((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),Ts((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Ts((()=>t<=i),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function ch(e){Ts((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function hh(e,t){Ts((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function dh(e){Ts((()=>e.every((t=>t>=e[0]))),r("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const uh=ys(`\nsettlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\nmaturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\nfrequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\nday_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n`);function gh(e,t,i,o,n=1e-10,s){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(Ts((()=>g<o&&void 0!==s),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=s(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<n||Math.abs(c)<n,Ts((()=>g<o),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const ph={description:r("Accrued interest of security paying at maturity."),args:ys(`\n issue (date) ${r("The date the security was initially issued.")}\n maturity (date) ${r("The maturity date of the security.")}\n rate (number) ${r("The annualized rate of interest.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Os(e)),s=Math.trunc(Os(t)),a=Os(o),l=Os(i),c=Math.trunc(Os(n));Wc(s,r),qc(c),Zc(a),Yc(l);return a*l*_c.compute(r,s,n)},isExported:!0},mh={description:r("Depreciation for an accounting period."),args:ys(`\n cost (number) ${r("The initial cost of the asset.")}\n purchase_date (date) ${r("The date the asset was purchased.")}\n first_period_end (date) ${r("The date the first period ended.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n rate (number) ${r("The deprecation rate.")}\n day_count_convention (number, optional) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s,a=0){a=a||0;const l=Os(e),c=Math.trunc(Os(t)),h=Math.trunc(Os(i)),d=Os(o),u=Os(n),g=Os(s),p=Math.trunc(Os(a));!function(e){Ts((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),eh(d),function(e,t){Ts((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Ts((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),Yc(g),qc(p),Ts((()=>c<=h),r("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=_c.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},fh={description:r("Days in coupon period containing settlement date."),args:uh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Os(e)),r=Math.trunc(Os(t)),s=Math.trunc(Os(i)),a=Math.trunc(Os(o));if(Hc(n,r),Gc(s),qc(a),1===a){const n=Eh.compute(e,t,i,o);return Sh.compute(e,t,i,o)-n}return(3===a?365:360)/s},isExported:!0},vh={description:r("Days from settlement until next coupon."),args:uh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Os(e)),r=Math.trunc(Os(t)),s=Math.trunc(Os(i)),a=Math.trunc(Os(o));Hc(n,r),Gc(s),qc(a);const l=Eh.compute(n,r,i,o);if([1,2,3].includes(a))return n-l;if(4===a){const e=ye(l,n,a);return Math.round(360*e)}const c=ks(n),h=ks(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Ce(h)&&Ce(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Ce(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},bh={description:r("Days from settlement until next coupon."),args:uh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Os(e)),r=Math.trunc(Os(t)),s=Math.trunc(Os(i)),a=Math.trunc(Os(o));Hc(n,r),Gc(s),qc(a);const l=Sh.compute(n,r,i,o);if([1,2,3].includes(a))return l-n;if(4===a){const e=ye(n,l,a);return Math.round(360*e)}const c=vh.compute(e,t,i,a);return fh.compute(e,t,i,a)-c},isExported:!0},Sh={description:r("Next coupon date after the settlement date."),args:uh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Os(e)),r=Math.trunc(Os(t)),s=Math.trunc(Os(i)),a=Math.trunc(Os(o));Hc(n,r),Gc(s),qc(a);const l=12/s,c=Ch.compute(e,t,i,o);return be(Ee(ks(r),-(c-1)*l,!0))},isExported:!0},Ch={description:r("Number of coupons between settlement and maturity."),args:uh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Os(e)),r=Math.trunc(Os(t)),s=Math.trunc(Os(i)),a=Math.trunc(Os(o));Hc(n,r),Gc(s),qc(a);let l=1,c=r;const h=12/s;for(;c>n;)c=be(Ee(ks(c),-h,!1)),l++;return l-1},isExported:!0},Eh={description:r("Last coupon date prior to or on the settlement date."),args:uh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Os(e)),r=Math.trunc(Os(t)),s=Math.trunc(Os(i)),a=Math.trunc(Os(o));Hc(n,r),Gc(s),qc(a);const l=12/s,c=Ch.compute(e,t,i,o);return be(Ee(ks(r),-c*l,!0))},isExported:!0},wh={description:r("Cumulative interest paid over a set of periods."),args:ys(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){const s=Os(o),a=Os(n),l=Os(e),c=Os(i),h=Os(t);lh(s,a,h),Yc(l),th(c);let d=0;for(let t=s;t<=a;t++){d+=Dh.compute(e,t,h,i,0,r)}return d},isExported:!0},yh={description:r("Cumulative principal paid over a set of periods."),args:ys(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){const s=Os(o),a=Os(n),l=Os(e),c=Os(i),h=Os(t);lh(s,a,h),Yc(l),th(c);let d=0;for(let t=s;t<=a;t++){d+=Wh.compute(e,t,h,i,0,r)}return d},isExported:!0},xh={description:r("Depreciation via declining balance method."),args:ys(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${r("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,...n){const s=Os(e),a=Os(t),l=Os(i),c=Math.trunc(Os(o)),h=n.length?Math.trunc(Os(n[0])):12,d=l+(12===h?0:1);Qc(s),eh(a),Jc(c),Kc(l),Ts((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Ts((()=>c<=d),r("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/s,1/l);g=Math.round(1e3*g)/1e3;let p=s,m=s*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},Rh={description:r("Depreciation via double-declining balance method."),args:ys(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n factor (number, default=2) ${r("The factor by which depreciation decreases.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=2){n=n||0;const r=Os(e),s=Os(t),a=Os(i),l=Os(o),c=Os(n);if(Qc(r),eh(s),Jc(l),Kc(a),ih(l,a),sh(c),0===r||s>=r)return 0;const h=c/a;if(h>1)return 1===o?r-s:0;if(l<=1)return r*h;const d=r*Math.pow(1-h,l-1),u=r*Math.pow(1-h,l),g=u<s?d-s:d-u;return Math.max(g,0)},isExported:!0},Ih={description:r("Discount rate of a security based on price."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Os(e)),s=Math.trunc(Os(t)),a=Os(i),l=Os(o),c=Math.trunc(Os(n));Hc(r,s),qc(c),jc(a),Zc(l);return(l-a)/l/_c.compute(r,s,c)},isExported:!0},Th={description:r("Convert a decimal fraction to decimal value."),args:ys(`\n fractional_price (number) ${r("The price quotation given using fractional decimal conventions.")}\n unit (number) ${r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Os(e),o=Math.trunc(Os(t));Ts((()=>o>0),r("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(10**Math.ceil(Math.log10(o))/o)},isExported:!0},Ah={description:r("Convert a decimal value to decimal fraction."),args:ys(`\n decimal_price (number) ${r("The price quotation given as a decimal value.")}\n unit (number) ${r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Os(e),o=Math.trunc(Os(t));Ts((()=>o>0),r("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(o/10**Math.ceil(Math.log10(o)))},isExported:!0},Oh={description:r("Number of periods for an investment to reach a value."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){s=s||0;const a=Math.trunc(Os(e)),l=Math.trunc(Os(t)),c=Os(i),h=Os(o),d=Math.trunc(Os(n)),u=Math.trunc(Os(s));Hc(a,l),Gc(d),qc(u),Ts((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),Ts((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=_c.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Mh={description:r("Annual effective interest rate."),args:ys(`\n nominal_rate (number) ${r("The nominal interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Os(e),o=Math.trunc(Os(t));return Ts((()=>i>0),r("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Ts((()=>o>0),r("The number of periods by year (%s) must strictly greater than 0.",o.toString())),Math.pow(1+i/o,o)-1},isExported:!0},Nh={description:r("Future value of an annuity investment."),args:ys(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n present_value (number, default=0) ${r("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const r=Os(e),s=Os(t),a=Os(i),l=Os(o),c=Ds(n)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},_h={description:r("Future value of principal from series of rates."),args:ys(`\n principal (number) ${r("The amount of initial capital or value to compound against.")}\n rate_schedule (number, range<number>) ${r("A series of interest rates to compound against the principal.")}\n `),returns:["NUMBER"],compute:function(e,t){return Vs([t],((e,t)=>e*(1+Os(t))),Os(e))},isExported:!0},Fh={description:r("Calculates effective interest rate."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested in the security.")}\n redemption (number) ${r("The amount to be received at maturity.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){const r=Math.trunc(Os(e)),s=Math.trunc(Os(t)),a=Os(o),l=Os(i);Hc(r,s),oh(l),Zc(a);return(a-l)/l/_c.compute(r,s,n)},isExported:!0},Dh={description:r("Payment on the principal of an investment."),args:ys(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,r=0){return Hh.compute(e,i,o,n,r)-Wh.compute(e,t,i,o,n,r)},isExported:!0},kh={description:r("Internal rate of return given periodic cashflows."),args:ys(`\n cashflow_amounts (number, range<number>) ${r("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Os(t);ch(i);let o=!1,n=!1,s=[];Ps([e],(e=>{e>0&&(o=!0),e<0&&(n=!0),s.push(e)})),Ts((()=>o&&n),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return gh((function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*e**(o-n))),t*e**o)}(e,a,s)}),(function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*(o-n)*e**(o-n-1))),t*o*e**(o-1))}(e,a,s)}),i+1,20,1e-5)-1},isExported:!0},$h={description:r("Returns the interest paid at a particular period of an investment."),args:ys(`\n rate (number) ${r("The interest rate.")}\n period (number) ${r("The period for which you want to view the interest payment.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o){const n=Os(e),s=Os(t),a=Os(i),l=Os(o);Ts((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*n},isExported:!0},Lh={description:r("Modified Macaulay duration."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){return Oh.compute(e,t,i,o,n,r)/(1+Os(o)/Math.trunc(Os(n)))},isExported:!0},Ph={description:r("Modified internal rate of return."),args:ys(`\n cashflow_amounts (range<number>) ${r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")}\n financing_rate (number) ${r("The interest rate paid on funds invested.")}\n reinvestment_return_rate (number) ${r("The return (as a percentage) earned on reinvestment of income received from the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Os(t),n=Os(i),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Xe).map(Os);var a;const l=s.length;let c=0,h=0;for(const e of ke(0,l)){const t=s[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(o+1)**e}Ts((()=>0!==h&&0!==c),r("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},Uh={description:r("Annual nominal interest rate."),args:ys(`\n effective_rate (number) ${r("The effective interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Os(e),o=Math.trunc(Os(t));return Ts((()=>i>0),r("The effective rate (%s) must must strictly greater than 0.",i.toString())),Ts((()=>o>0),r("The number of periods by year (%s) must strictly greater than 0.",o.toString())),(Math.pow(i+1,1/o)-1)*o},isExported:!0},Vh={description:r("Number of payment periods for an investment."),args:ys(`\n rate (number) ${r("The interest rate.")}\n payment_amount (number) ${r("The amount of each payment made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const r=Os(e),s=Os(t),a=Os(i),l=Os(o),c=Ds(n)?1:0;if(0===r)return-(l+a)/s;const h=s*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const zh={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:ys(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${r("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${r("Additional future cash flows.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Os(e);return Ts((()=>-1!==i),r("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let o=0;return zs(i,((t,i)=>(o++,t+i/(1+e)**o)),t)}(i,0,t)},isExported:!0},Bh={description:r("Computes the number of periods needed for an investment to reach a value."),args:ys(`\n rate (number) ${r("The rate at which the investment grows each period.")}\n present_value (number) ${r("The investment's current value.")}\n future_value (number) ${r("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Os(e),n=Os(t),s=Os(i);return Yc(o),Ts((()=>n>0),r("The present_value (%s) must be strictly positive.",n.toString())),Ts((()=>s>0),r("The future_value (%s) must be strictly positive.",s.toString())),(Math.log(s)-Math.log(n))/Math.log(1+o)},isExported:!0},Hh={description:r("Periodic payment for an annuity investment."),args:ys(`\n rate (number) ${r("The annualized rate of interest.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const r=Os(t),s=Os(e),a=Ds(n)?1:0;let l=Os(o),c=Os(i);if(Xc(r),0===s)return-(l+c)/r;let h=-(c*(1+s)**r+l);return h=h*s/((1+s*a)*((1+s)**r-1)),h},isExported:!0},Wh={description:r("Payment on the principal of an investment."),args:ys(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,s=0){n=n||0,s=s||0;const a=Os(i),l=Os(e),c=Os(t),h=Ds(s)?1:0,d=Os(n),u=Os(o);Xc(a),Ts((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=Hh.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-Nh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},Gh={description:r("Present value of an annuity investment."),args:ys(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const r=Os(e),s=Os(t),a=Os(i),l=Os(o),c=Ds(n)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},qh={description:r("Price of a security paying periodic interest."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s,a=0){a=a||0;const l=Math.trunc(Os(e)),c=Math.trunc(Os(t)),h=Os(i),d=Os(o),u=Os(n),g=Math.trunc(Os(s)),p=Math.trunc(Os(a));Hc(l,c),Gc(g),qc(p),Ts((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Ts((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),Zc(u);const m=_c.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},Zh={description:r("Price of a discount security."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the security at time of purchase.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Os(e)),s=Math.trunc(Os(t)),a=Os(i),l=Os(o),c=Math.trunc(Os(n));Hc(r,s),qc(c),nh(a),Zc(l);return l-a*l*_c.compute(r,s,c)},isExported:!0},jh={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){s=s||0;const a=Math.trunc(Os(e)),l=Math.trunc(Os(t)),c=Math.trunc(Os(i)),h=Os(o),d=Os(n),u=Math.trunc(Os(s));Wc(a,c),Hc(a,l),qc(u),Ts((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Ts((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=_c.compute(a,l,u),p=_c.compute(a,c,u);return(100+_c.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},Xh=.1,Yh={description:r("Interest rate of an annuity investment."),args:ys(`\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_per_period (number) ${r("The amount per period to be paid.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the interest rate will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,o=0,n=0,s=.1){o=o||0,n=n||0,s=s||Xh;const a=Os(e),l=Os(t),c=Ds(n)?1:0,h=Os(s);let d=Os(o),u=Os(i);Xc(a),Ts((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),r("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),ch(h),d-=l*c,u+=l*c;return gh((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},Kh={description:r("Amount received at maturity for a security."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested (irrespective of face value of each security).")}\n discount (number) ${r("The discount rate of the security invested in.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Os(e)),s=Math.trunc(Os(t)),a=Os(i),l=Os(o),c=Math.trunc(Os(n));Hc(r,s),qc(c),oh(a),nh(l);return a/(1-l*_c.compute(r,s,c))},isExported:!0},Qh={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:ys(`\n number_of_periods (number) ${r("The number of periods.")}\n present_value (number) ${r("The present value of the investment.")}\n future_value (number) ${r("The future value of the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Os(e),n=Os(t),r=Os(i);return Xc(o),(r/n)**(1/o)-1},isExported:!0},Jh={description:r("Depreciation of an asset using the straight-line method."),args:ys(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Os(e)-Os(t))/Os(i)},isExported:!0},ed={description:r("Depreciation via sum of years digit method."),args:ys(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o){const n=Os(e),r=Os(t),s=Os(i),a=Os(o);Jc(a),Kc(s),ih(a,s);return(s-a+1)/(s*(s+1)/2)*(n-r)},isExported:!0},td={description:r("Price of a US Treasury bill."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Os(e)),n=Math.trunc(Os(t)),r=Os(i);Hc(o,n),ah(o,n),nh(r),rh(r);return 100*(1-r*_c.compute(o,n,2))},isExported:!0},id={description:r("Equivalent rate of return for a US Treasury bill."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Os(e)),n=Math.trunc(Os(t)),r=Os(i);Hc(o,n),ah(o,n),nh(r),rh(r);const s=dc.compute(n,o);if(s<=182)return 365*r/(360-r*s);const a=td.compute(o,n,r)/100,l=s/(366===s?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},od={description:r("The yield of a US Treasury bill based on price."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Os(e)),n=Math.trunc(Os(t)),r=Os(i);Hc(o,n),ah(o,n),jc(r);return(100-r)/r*(1/_c.compute(o,n,2))},isExported:!0},nd={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:ys(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n start (number) ${r("Starting period to calculate depreciation.")}\n end (number) ${r("Ending period to calculate depreciation.")}\n factor (number, default=2) ${r("The number of months in the first year of depreciation.")}\n no_switch (number, default=false) ${r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s=2,a=false){s=s||0;const l=Os(e),c=Os(t),h=Os(i),d=Math.trunc(Os(o)),u=Math.trunc(Os(n)),g=Os(s),p=Ds(a);if(Qc(l),eh(c),function(e,t,i){Kc(i),Ts((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),Ts((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),Ts((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Ts((()=>t<=i),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),sh(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},rd={description:r("Internal rate of return given non-periodic cash flows."),args:ys(`\n cashflow_amounts (range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],compute:function(e,t,i=.1){const o=Os(i=i||0),n=e.flat().map(Os),s=t.flat().map(Os);var a;hh(e,t),a=n,Ts((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),dh(s),ch(o);const l=new Map;for(const e of ke(0,s.length)){const t=s[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return gh((e=>{let t=h[0];for(const i of ke(1,h.length)){const o=(c[0]-c[i])/365;t+=h[i]*(1+e)**o}return t}),(e=>{let t=0;for(const i of ke(1,h.length)){const o=(c[0]-c[i])/365;t+=o*h[i]*(1+e)**(o-1)}return t}),o,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},sd={description:r("Net present value given to non-periodic cash flows.."),args:ys(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow_amounts (number, range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (number, range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const o=Os(e),n=Array.isArray(t)?t.flat().map(Ms):[Ms(t)],s=Array.isArray(i)?i.flat().map(Ms):[Ms(i)];if(Array.isArray(i)&&Array.isArray(t)?hh(t,i):Ts((()=>n.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),dh(s),Yc(o),1===n.length)return n[0];const a=new Map;for(const e of ke(0,s.length)){const t=s[e];a.has(t)?a.set(t,a.get(t)+n[e]):a.set(t,n[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of ke(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+o)**t}return h},isExported:!0},ad={description:r("Annual yield of a security paying periodic interest."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s,a=0){a=a||0;const l=Math.trunc(Os(e)),c=Math.trunc(Os(t)),h=Os(i),d=Os(o),u=Os(n),g=Math.trunc(Os(s)),p=Math.trunc(Os(a));Hc(l,c),Gc(g),qc(p),Ts((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),jc(d),Zc(u);const m=_c.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=gh((function(e){return function(e,t,i,o,n,r){let s=r-(e+n*(1-t))*o**(i-1+t);for(let e=1;e<=i;e++)s+=n*o**(e-1);return s}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,o,n){let r=-(e+n*(1-t))*(i-1+t)*o**(i-2+t);for(let e=1;e<=i;e++)r+=n*(e-1)*o**(e-2);return r}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},ld={description:r("Annual yield of a discount security."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const r=Math.trunc(Os(e)),s=Math.trunc(Os(t)),a=Os(i),l=Os(o),c=Math.trunc(Os(n));Hc(r,s),qc(c),jc(a),Zc(l);return(l/a-1)/_c.compute(e,t,n)},isExported:!0},cd={description:r("Annual yield of a security paying interest at maturity."),args:ys(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){s=s||0;const a=Math.trunc(Os(e)),l=Math.trunc(Os(t)),c=Math.trunc(Os(i)),h=Os(o),d=Os(n),u=Math.trunc(Os(s));Hc(a,l),qc(u),Ts((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Ts((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),jc(d);const g=_c.compute(c,l,u),p=_c.compute(c,a,u),m=_c.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var hd=Object.freeze({__proto__:null,ACCRINTM:ph,AMORLINC:mh,COUPDAYS:fh,COUPDAYBS:vh,COUPDAYSNC:bh,COUPNCD:Sh,COUPNUM:Ch,COUPPCD:Eh,CUMIPMT:wh,CUMPRINC:yh,DB:xh,DDB:Rh,DISC:Ih,DOLLARDE:Th,DOLLARFR:Ah,DURATION:Oh,EFFECT:Mh,FV:Nh,FVSCHEDULE:_h,INTRATE:Fh,IPMT:Dh,IRR:kh,ISPMT:$h,MDURATION:Lh,MIRR:Ph,NOMINAL:Uh,NPER:Vh,NPV:zh,PDURATION:Bh,PMT:Hh,PPMT:Wh,PV:Gh,PRICE:qh,PRICEDISC:Zh,PRICEMAT:jh,RATE:Yh,RECEIVED:Kh,RRI:Qh,SLN:Jh,SYD:ed,TBILLPRICE:td,TBILLEQ:id,TBILLYIELD:od,VDB:nd,XIRR:rd,XNPV:sd,YIELD:ad,YIELDDISC:ld,YIELDMAT:cd});const dd={description:r("Whether a value is an error other than #N/A."),args:ys(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},ud={description:r("Whether a value is an error."),args:ys(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},gd={description:r("Whether a value is `true` or `false`."),args:ys(`value (any, lazy) ${r("The value to be verified as a logical TRUE or FALSE.")}`),returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},pd={description:r("Whether a value is the error #N/A."),args:ys(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},md={description:r("Whether a value is non-textual."),args:ys(`value (any, lazy) ${r("The value to be checked.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},fd={description:r("Whether a value is a number."),args:ys(`value (any, lazy) ${r("The value to be verified as a number.")}`),returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},vd={description:r("Whether a value is text."),args:ys(`value (any, lazy) ${r("The value to be verified as text.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},bd={description:r("Whether the referenced cell is empty"),args:ys(`value (any, lazy) ${r("Reference to the cell that will be checked for emptiness.")}`),returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Sd={description:r("Returns the error value #N/A."),args:ys(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Cd=Object.freeze({__proto__:null,ISERR:dd,ISERROR:ud,ISLOGICAL:gd,ISNA:pd,ISNONTEXT:md,ISNUMBER:fd,ISTEXT:vd,ISBLANK:bd,NA:Sd});const Ed={description:r("Logical `and` operator."),args:ys(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return Hs(e,(e=>(t=!0,i=i&&e,i))),Ts((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},wd={description:r("Returns value depending on logical expression."),args:ys(`\n logical_expression (boolean) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")}\n value_if_true (any, lazy) ${r("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${r("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,i=(()=>!1)){const o=Ds(e)?t():i();return null==o?"":o},isExported:!0},yd={description:r("Value if it is not an error, otherwise 2nd argument."),args:ys(`\n value (any, lazy) ${r("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an error.")}\n `),returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},xd={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:ys(`\n value (any, lazy) ${r("The value to return if value itself is not #N/A an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an #N/A error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(o){i=o.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},Rd={description:r("Returns a value depending on multiple logical expressions."),args:ys(`\n condition1 (boolean, lazy) ${r("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")}\n value1 (any, lazy) ${r("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${r("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${r("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){Ts((()=>e.length%2==0),r("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Ds(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(r("No match."))},isExported:!0},Id={description:r("Returns opposite of provided logical value."),args:ys(`logical_expression (boolean) ${r("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!Ds(e)},isExported:!0},Td={description:r("Logical `or` operator."),args:ys(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Hs(e,(e=>(t=!0,i=i||e,!i))),Ts((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Ad={description:r("Logical `xor` operator."),args:ys(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Hs(e,(e=>(t=!0,i=i?!e:e,!0))),Ts((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Od=Object.freeze({__proto__:null,AND:Ed,IF:wd,IFERROR:yd,IFNA:xd,IFS:Rd,NOT:Id,OR:Td,XOR:Ad});const Md={description:r("Column number of a specified cell."),args:ys(`cell_reference (meta, default=${r("The cell in which the formula is entered")}) ${r("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Ts((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return xi(i).left+1},isExported:!0},Nd={description:r("Number of columns in a specified array or range."),args:ys(`range (meta) ${r("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=xi(e);return t.right-t.left+1},isExported:!0},_d={description:r("Horizontal lookup"),args:ys(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (range) ${r("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")}\n index (number) ${r("The row index of the value to be returned, where the first row in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.")}\n `),returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Os(i)),s=_s(e);Ts((()=>1<=n&&n<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=Ds(o);let l;return l=a?Xs(t,s,"nextSmaller","asc",t.length,js):Ys(t,s,"strict",t.length,js),Ts((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ns(e))),t[l][n-1]},isExported:!0},Fd={description:r("Look up a value."),args:ys(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n search_array (range) ${r("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")}\n result_range (range, optional) ${r("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.")}\n `),returns:["ANY"],compute:function(e,t,i){let o=t.length,n=t[0].length;const s=_s(e),a=n>=o,l=Xs(t,s,"nextSmaller","asc",a?n:o,a?Zs:js);return Ts((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ns(e))),void 0===i?a?t[o-1][l]:t[l][n-1]:(o=i.length,n=i[0].length,Ts((()=>1===o||1===n),r("The result_range must be a single row or a single column.")),o>1?(Ts((()=>l<=o-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Ts((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Dd={description:r("Position of item in range that matches value."),args:ys(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The one-dimensional array to be searched.")}\n search_type (number, default=1) ${r("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){let o=Os(i);const n=_s(e),s=t.length,a=t[0].length;Ts((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?Zs:js,h=1===s?t[0].length:t.length;switch(o=Math.sign(o),o){case 1:l=Xs(t,n,"nextSmaller","asc",h,c);break;case 0:l=Ys(t,n,"strict",h,c);break;case-1:l=Xs(t,n,"nextGreater","desc",h,c)}return Ts((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ns(e))),l+1},isExported:!0},kd={description:r("Row number of a specified cell."),args:ys(`cell_reference (meta, default=${r("The cell in which the formula is entered by default")}) ${r("The cell whose row number will be returned.")}`),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),Ts((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return xi(e).top+1},isExported:!0},$d={description:r("Number of rows in a specified array or range."),args:ys(`range (meta) ${r("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=xi(e);return t.bottom-t.top+1},isExported:!0},Ld={description:r("Vertical lookup."),args:ys(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")}\n index (number) ${r("The column index of the value to be returned, where the first column in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.")}\n `),returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Os(i)),s=_s(e);Ts((()=>1<=n&&n<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=Ds(o);let l;return l=a?Xs(t,s,"nextSmaller","asc",t[0].length,Zs):Ys(t,s,"strict",t[0].length,Zs),Ts((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ns(e))),t[n-1][l]},isExported:!0},Pd={description:r("Search a range for a match and return the corresponding item from a second range."),args:ys(`\n search_key (any) ${r("The value to search for.")}\n lookup_range (any, range) ${r("The range to consider for the search. Should be a single column or a single row.")}\n return_range (any, range) ${r("The range containing the return value. Should have the same dimensions as lookup_range.")}\n if_not_found (any, lazy, optional) ${r("If a valid match is not found, return this value.")}\n match_mode (any, default=0) ${r("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")}\n search_mode (any, default=1) ${r("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. ")}\n\n `),returns:["ANY"],compute:function(e,t,i,o,n=0,s=1){const a=Math.trunc(Os(n)),l=Math.trunc(Os(s)),c=_s(e);Ts((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),Ts((()=>1===i.length||1===i[0].length),r("return_range should be either a single row or single column.")),Ts((()=>i.length===t.length&&i[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),Ts((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),Ts((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?Zs:js,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=Xs(t,c,u,2===l?"asc":"desc",d,h)}else p=Ys(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==o?void 0:o();return Ts((()=>!!m),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Ns(e))),m},isExported:!0};var Ud=Object.freeze({__proto__:null,COLUMN:Md,COLUMNS:Nd,HLOOKUP:_d,LOOKUP:Fd,MATCH:Dd,ROW:kd,ROWS:$d,VLOOKUP:Ld,XLOOKUP:Pd});const Vd={description:r("Sum of two numbers."),args:ys(`\n value1 (number) ${r("The first addend.")}\n value2 (number) ${r("The second addend.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Os(e)+Os(t)}},zd={description:r("Concatenation of two values."),args:ys(`\n value1 (string) ${r("The value to which value2 will be appended.")}\n value2 (string) ${r("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return Ns(e)+Ns(t)},isExported:!0},Bd={description:r("One number divided by another."),args:ys(`\n dividend (number) ${r("The number to be divided.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Os(t);return Ts((()=>0!==i),r("The divisor must be different from zero.")),Os(e)/i}};function Hd(e){return null==e}const Wd={number:0,string:"",boolean:!1},Gd={description:r("Equal."),args:ys(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=Hd(e)?Wd[typeof t]:e,t=Hd(t)?Wd[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function qd(e,t,i){e=Hd(e)?Wd[typeof t]:e,t=Hd(t)?Wd[typeof e]:t,"number"!=typeof e&&(e=Ns(e).toUpperCase()),"number"!=typeof t&&(t=Ns(t).toUpperCase());const o=typeof e,n=typeof t;return"string"===o&&"number"===n||("string"!==n||"number"!==o)&&i(e,t)}const Zd={description:r("Strictly greater than."),args:ys(`\n value1 (any) ${r("The value to test as being greater than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return qd(e,t,((e,t)=>e>t))}},jd={description:r("Greater than or equal to."),args:ys(`\n value1 (any) ${r("The value to test as being greater than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return qd(e,t,((e,t)=>e>=t))}},Xd={description:r("Less than."),args:ys(`\n value1 (any) ${r("The value to test as being less than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!jd.compute(e,t)}},Yd={description:r("Less than or equal to."),args:ys(`\n value1 (any) ${r("The value to test as being less than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Zd.compute(e,t)}},Kd={description:r("Difference of two numbers."),args:ys(`\n value1 (number) ${r("The minuend, or number to be subtracted from.")}\n value2 (number) ${r("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Os(e)-Os(t)}},Qd={description:r("Product of two numbers"),args:ys(`\n factor1 (number) ${r("The first multiplicand.")}\n factor2 (number) ${r("The second multiplicand.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Os(e)*Os(t)}},Jd={description:r("Not equal."),args:ys(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Gd.compute(e,t)}},eu={description:r("A number raised to a power."),args:ys(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],compute:function(e,t){return Pa.compute(e,t)}},tu={description:r("A number with the sign reversed."),args:ys(`\n value (number) ${r("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Os(e)}},iu={description:r("Value interpreted as a percentage."),args:ys(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Os(e)/100}},ou={description:r("A specified number, unchanged."),args:ys(`\n value (any) ${r("The number to return.")}\n `),returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var nu=Object.freeze({__proto__:null,ADD:Vd,CONCAT:zd,DIVIDE:Bd,EQ:Gd,GT:Zd,GTE:jd,LT:Xd,LTE:Yd,MINUS:Kd,MULTIPLY:Qd,NE:Jd,POW:eu,UMINUS:tu,UNARY_PERCENT:iu,UPLUS:ou});const ru=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,su={description:r("Gets character associated with number."),args:ys(`\n table_number (number) ${r("The number of the character to look up from the current Unicode table in decimal format.")}\n `),returns:["STRING"],compute:function(e){const t=Math.trunc(Os(e));return Ts((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},au={description:r("Remove non-printable characters from a piece of text."),args:ys(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Ns(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},lu={description:r("Appends strings to one another."),args:ys(`\n string1 (string, range<string>) ${r("The initial string.")}\n string2 (string, range<string>, repeating) ${r("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return Vs(e,((e,t)=>e+Ns(t)),"")},isExported:!0},cu={description:r("Tests whether two strings are identical."),args:ys(`\n string1 (string) ${r("The first string to compare.")}\n string2 (string) ${r("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Ns(e)===Ns(t)},isExported:!0},hu={description:r("First position of string found in text, case-sensitive."),args:ys(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const o=Ns(e),n=Ns(t),s=Os(i);Ts((()=>""!==n),r("The text_to_search must be non-empty.")),Ts((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=n.indexOf(o,s-1);return Ts((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o.toString(),n)),a+1},isExported:!0},du={description:r("Concatenates elements of arrays with delimiter."),args:ys(`\n delimiter (string) ${r("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${r("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${r("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const i=Ns(e);return Vs(t,((e,t)=>(e?e+i:"")+Ns(t)),"")}},uu={description:r("Substring from beginning of specified string."),args:ys(`\n text (string) ${r("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Os(t[0]):1;return Ts((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString())),Ns(e).substring(0,i)},isExported:!0},gu={description:r("Length of a string."),args:ys(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Ns(e).length},isExported:!0},pu={description:r("Converts a specified string to lowercase."),args:ys(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Ns(e).toLowerCase()},isExported:!0},mu={description:r("A segment of a string."),args:ys(`\n text (string) ${r("The string to extract a segment from.")}\n starting_at (number) ${r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")}\n extract_length (number) ${r("The length of the segment to extract.")}\n `),returns:["STRING"],compute:function(e,t,i){const o=Ns(e),n=Os(t),s=Os(i);return Ts((()=>n>=1),r("The starting_at argument (%s) must be positive greater than one.",n.toString())),Ts((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),o.slice(n-1,n+s-1)},isExported:!0},fu={description:r("Capitalizes each word in a specified string."),args:ys(`\n text_to_capitalize (string) ${r("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.")}\n `),returns:["STRING"],compute:function(e){return Ns(e).replace(ru,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},vu={description:r("Replaces part of a text string with different text."),args:ys(`\n text (string) ${r("The text, a part of which will be replaced.")}\n position (number) ${r("The position where the replacement will begin (starting from 1).")}\n length (number) ${r("The number of characters in the text to be replaced.")}\n new_text (string) ${r("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,i,o){const n=Os(t);Ts((()=>n>=1),r("The position (%s) must be greater than or equal to 1.",n.toString()));const s=Ns(e),a=Os(i),l=Ns(o);return s.substring(0,n-1)+l+s.substring(n-1+a)},isExported:!0},bu={description:r("A substring from the end of a specified string."),args:ys(`\n text (string) ${r("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Os(t[0]):1;Ts((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString()));const o=Ns(e),n=o.length;return o.substring(n-i,n)},isExported:!0},Su={description:r("First position of string found in text, ignoring case."),args:ys(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const o=Ns(e).toLowerCase(),n=Ns(t).toLowerCase(),s=Os(i);Ts((()=>""!==n),r("The text_to_search must be non-empty.")),Ts((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=n.indexOf(o,s-1);return Ts((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o,n)),a+1},isExported:!0},Cu={description:r("Replaces existing text with new text in a string."),args:ys(`\n text_to_search (string) ${r("The text within which to search and replace.")}\n search_for (string) ${r("The string to search for within text_to_search.")}\n replace_with (string) ${r("The string that will replace search_for.")}\n occurrence_number (number, optional) ${r("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.")}\n `),returns:["NUMBER"],compute:function(e,t,i,o){const n=Os(o);Ts((()=>n>=0),r("The occurrenceNumber (%s) must be positive or null.",n.toString()));const s=Ns(e),a=Ns(t);if(""===a)return s;const l=Ns(i),c=new RegExp(Ie(a),"g");if(0===n)return s.replace(c,l);let h=0;return s.replace(c,(e=>++h===n?l:e))},isExported:!0},Eu={description:r("Combines text from multiple strings and/or arrays."),args:ys(`\n delimiter (string) ${r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${r("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${r("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...i){const o=Ns(e),n=Ds(t);let r=0;return Vs(i,((e,t)=>n&&""===Ns(t)?e:(r++?e+o:"")+Ns(t)),"")},isExported:!0},wu={description:r("Removes space characters."),args:ys(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Ns(e).trim()},isExported:!0},yu={description:r("Converts a specified string to uppercase."),args:ys(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Ns(e).toUpperCase()},isExported:!0},xu={description:r("Converts a number to text according to a specified format."),args:ys(`\n number (number) ${r("The number, date or time to format.")}\n format (string) ${r("The pattern by which to format the number, enclosed in quotation marks.")}\n `),returns:["STRING"],compute:function(e,t){return qt(Os(e),Ns(t))},isExported:!0};const Ru={database:ac,date:Vc,financial:hd,info:Cd,lookup:Ud,logical:Od,math:il,misc:Js,operators:nu,statistical:ql,text:Object.freeze({__proto__:null,CHAR:su,CLEAN:au,CONCATENATE:lu,EXACT:cu,FIND:hu,JOIN:du,LEFT:uu,LEN:gu,LOWER:pu,MID:mu,PROPER:fu,REPLACE:vu,RIGHT:bu,SEARCH:Su,SUBSTITUTE:Cu,TEXTJOIN:Eu,TRIM:wu,UPPER:yu,TEXT:xu}),engineering:Bc},Iu=/^[A-Z0-9\_\.]+$/;function Tu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Au(e()):Au(e)}))}function Au(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Ou=new class extends Xi{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Iu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=Rs(t);return function(e){let t=!1,i=!1,o=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(r("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!n.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||o,s=!(n.optional||n.repeating||n.default);if(e&&s)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,i=n.optional,o=n.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),o=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Tu(e)),format:o(...e)}},super.add(e,i),this}};for(let e in Ru){const t=Ru[e];for(let i in t){const o=t[i];o.category=e,i=i.replace(/_/g,"."),Ou.add(i,{isExported:!1,...o})}}const Mu=Ou.content,Nu=["%"],_u="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Nu);function Fu(e){const t=e.split(""),i=[];for(;t.length;){let e=Wu(t)||$u(t)||Pu(t)||Vu(t)||Du(t)||Gu(t)||Uu(t)||Bu(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Du(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const ku={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function $u(e){if(e[0]in ku){const t=e.shift();return{type:ku[t],value:t}}return null}function Lu(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Pu(e){for(let t of _u)if(Lu(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Uu(e){const t=et(e).match(li);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Vu(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const zu=/\w|\.|!|\$/;function Bu(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(zu);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Mu)return{type:"FUNCTION",value:e};return e.match(Tt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const Hu=/\s/;function Wu(e){let t=0;for(;e[0]&&e[0].match(Hu);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function Gu(e){return Lu(e,Y)?(e.splice(0,Y.length),{type:"INVALID_REFERENCE",value:Y}):null}const qu=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Zu=["-","+"],ju=["%"],Xu=["*","+","&"],Yu={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},Ku=6;function Qu(e){switch(e.type){case"NUMBER":case"SYMBOL":case"REFERENCE":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return Yu[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function Ju(e,t,i){if("OPERATOR"===t.type){const o=Qu(t);if(ju.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const n=eg(i,o);return{type:"BIN_OPERATION",value:t.value,left:e,right:n}}}throw new Error(oe)}function eg(e,t){const i=e.shift();if(!i)throw new Error(oe);let o=function(e,t){var i,o,n,s;switch(e.type){case"DEBUGGER":const a=eg(t,1e3);return a.debug=!0,a;case"NUMBER":return{type:"NUMBER",value:fi(e.value)};case"STRING":return{type:"STRING",value:Re(e.value)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(r("Wrong function call"));{const o=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?o.push({type:"UNKNOWN",value:""}):o.push(eg(t,Ku));"COMMA"===(null===(i=t[0])||void 0===i?void 0:i.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){o.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?o.push({type:"UNKNOWN",value:""}):o.push(eg(t,Ku))}const n=t.shift();if(!n||"RIGHT_PAREN"!==n.type)throw new Error(r("Wrong function call"));return{type:"FUNCALL",value:e.value,args:o}}case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(o=t[0])||void 0===o?void 0:o.value)&&"REFERENCE"===(null===(n=t[1])||void 0===n?void 0:n.type)){t.shift();const i=t.shift();return{type:"REFERENCE",value:`${e.value}:${null==i?void 0:i.value}`}}return{type:"REFERENCE",value:e.value};case"SYMBOL":if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value){if(qu.test(e.value)&&"LEFT_PAREN"===(null===(s=t[0])||void 0===s?void 0:s.type))throw new p(e.value);throw new Error(r("Invalid formula"))}return{type:"STRING",value:e.value};case"LEFT_PAREN":const l=eg(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),l;default:if("OPERATOR"===e.type&&Zu.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:eg(t,Yu[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(i,e);for(;e[0]&&Qu(e[0])>t;)o=Ju(o,e.shift(),e);return o}function tg(e){return ig(Fu(e))}function ig(e){"OPERATOR"===(e=e.filter((e=>"SPACE"!==e.type)))[0].type&&"="===e[0].value&&e.splice(0,1);const t=eg(e,0);if(e.length)throw new Error(oe);return t}function og(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>og(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:og(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:og(e.right,t,i),left:og(e.left,t,i)};default:return e}}function ng(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>ng(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?rg(e)+e.value:e.value+sg(e);case"BIN_OPERATION":return rg(e)+e.value+sg(e)}}function rg(e){const t=e.value,i="left"in e?e.left:e.operand,o=i.value;return"BIN_OPERATION"===i.type&&Yu[o]<Yu[t]?`(${ng(i)})`:ng(i)}function sg(e){const t=e.value,i="right"in e?e.right:e.operand,o=Yu[i.value],n=Yu[t];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:o<n?r=!0:o!==n||Xu.includes(t)||(r=!0),r?`(${ng(i)})`:ng(i)}var ag;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(ag||(ag={}));const lg=(e,t=(()=>!0))=>[{goTo:e,guard:t}],cg=(e,t=(()=>!0))=>({goTo:e,guard:t}),hg={[ag.LeftRef]:{REFERENCE:lg(ag.Separator),NUMBER:lg(ag.FullRowSeparator),SYMBOL:[cg(ag.FullColumnSeparator,(e=>At(e.value))),cg(ag.FullRowSeparator,(e=>Ot(e.value)))]},[ag.FullColumnSeparator]:{SPACE:lg(ag.FullColumnSeparator),OPERATOR:lg(ag.RightColumnRef,(e=>":"===e.value))},[ag.FullRowSeparator]:{SPACE:lg(ag.FullRowSeparator),OPERATOR:lg(ag.RightRowRef,(e=>":"===e.value))},[ag.Separator]:{SPACE:lg(ag.Separator),OPERATOR:lg(ag.RightRef,(e=>":"===e.value))},[ag.RightRef]:{SPACE:lg(ag.RightRef),NUMBER:lg(ag.Found),REFERENCE:lg(ag.Found,(e=>Nt(e.value))),SYMBOL:lg(ag.Found,(e=>Mt(e.value)))},[ag.RightColumnRef]:{SPACE:lg(ag.RightColumnRef),SYMBOL:lg(ag.Found,(e=>Mt(e.value))),REFERENCE:lg(ag.Found,(e=>Nt(e.value)))},[ag.RightRowRef]:{SPACE:lg(ag.RightRowRef),NUMBER:lg(ag.Found),REFERENCE:lg(ag.Found,(e=>Nt(e.value)))},[ag.Found]:{}};function dg(e){var t;let i=0,o=hg[ag.LeftRef];const n=[];for(;void 0!==o;){const r=e[i++];if(!r)return null;const s=null===(t=o[r.type])||void 0===t?void 0:t.find((e=>e.guard(r))),a=s?s.goTo:void 0;switch(a){case void 0:return null;case ag.Found:return n.push(r),e.splice(0,i),{type:"REFERENCE",value:et(n.map((e=>e.value)))};default:o=hg[a],n.push(r)}}return null}function ug(e){const t=Fu(e),i=[];for(;t.length;)i.push(dg(t)||t.shift());return i}const gg=Ou.content,pg={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},mg={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function fg(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const vg={};function bg(e){const t=ug(e),{dependencies:i,constantValues:o}=function(e){const t={numbers:[],strings:[]},i=[];for(const o of e)switch(o.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(o.value);break;case"STRING":const e=Re(o.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=fi(o.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),n=function(e,t,i){return et(e.map((e=>{switch(e.type){case"STRING":const o=Re(e.value);return`|S${i.strings.indexOf(o)}|`;case"NUMBER":return`|N${i.numbers.indexOf(fi(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,o);if(!vg[n]){const s=ig([...t]);let a=1;if("BIN_OPERATION"===s.type&&":"===s.value)throw new Error(r("Invalid formula"));if("UNKNOWN"===s.type)throw new Error(r("Invalid formula"));const l=u(s),c=fg([`// ${n}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=gg[e.value.toUpperCase()],i=e.args,o=i.length;if(o<t.minArgRequired)throw new Error(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),o.toString()));if(o>t.maxArgPossible)throw new Error(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),o.toString()));const n=t.nbrArgRepeating;if(n>1){const i=t.args.length-n;if((o-i)%n!=0)throw new Error(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),n.toString()))}let s=[];for(let n=0;n<o;n++){const o=t.getArgToFocus(n+1)-1;if(0<=o&&o<t.args.length){const a=i[n],l=t.args[o],c=l.type||[],h=c.includes("META"),d=l.lazy,g=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),p=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(p&&"REFERENCE"!==a.type)throw new Error(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(n+1).toString(),a.type.toLowerCase()));const m=u(a,d,h,g,{functionName:e.value.toUpperCase(),paramIndex:n+1});s.push(m)}}return s}function u(e,t=!1,n=!1,s=!1,l={}){const c=[];let h,g,p;if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&n)throw new Error(r("Argument must be a reference to a cell or range."));switch(e.debug&&c.push("debugger;"),e.type){case"BOOLEAN":if(!t)return{id:`{ value: ${e.value} }`,code:""};h=a++,p=`{ value: ${e.value} }`;break;case"NUMBER":h=a++,p=`{ value: this.constantValues.numbers[${o.numbers.indexOf(e.value)}] }`;break;case"STRING":h=a++,p=`{ value: this.constantValues.strings[${o.strings.indexOf(e.value)}] }`;break;case"REFERENCE":const r=i.indexOf(e.value);h=a++,p=s?`range(deps[${r}])`:`ref(deps[${r}], ${n?"true":"false"}, "${l.functionName||pg["="]}", ${l.paramIndex})`;break;case"FUNCALL":h=a++;const m=d(e);c.push(m.map((e=>e.code)).join("\n")),g=e.value.toUpperCase(),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${m.map((e=>e.id))})`;break;case"UNARY_OPERATION":{h=a++,g=mg[e.value];const t=u(e.operand,!1,!1,!1,{functionName:g});c.push(t.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id})`;break}case"BIN_OPERATION":{h=a++,g=pg[e.value];const t=u(e.left,!1,!1,!1,{functionName:g}),i=u(e.right,!1,!1,!1,{functionName:g});c.push(t.code),c.push(i.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id}, ${i.id})`;break}case"UNKNOWN":if(!t)return{id:"undefined",code:""};h=a++,p="undefined"}if(t){return{id:`_${h}`,code:`const _${h} = () => {\n\t${fg(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}vg[n]={execute:h}}return{execute:vg[n].execute,dependencies:i,constantValues:o,tokens:t}}function Sg(e){return function(e){let t=[],i="";return e.map(((e,o)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,o=Object.assign({},e,{start:t,end:t+i,length:i});return t=o.end,o}))}(ug(e))))}function Cg(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=_t(e.value),[o,n]=t.split(":"),r=i?`${Oe(i)}!`:"",s=Eg(o),a=n?`:${Eg(n)}`:"";return{...e,value:r+s+a}}function Eg(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=wg(e,"colrow");break;case"colrow":e=wg(e,"row");break;case"row":e=wg(e,"col");break;case"col":e=wg(e,"none")}return e}function wg(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}class yg{constructor(e,t,i){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const o=e.filter((e=>0!==e));if(o.length)return o}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}yg.getters=[];class xg extends yg{constructor(e,t,i,o,n){super(t,i,o),this.getters=e,this.ui=o,this.selection=n}drawGrid(e,t){}}xg.layers=[];const Rg=r("The cell you are trying to edit has been deleted.");class Ig extends xg{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),i=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(i.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:o}=_t(e.value),n=o||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==n)return!1;const s=this.getters.getRangeFromSheetXC(r,i);return Fi(this.getters.expandZone(r,s.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const o=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(o,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(n),this.previousRef=n,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),o=this.getters.expandZone(e.sheetIdTo,Gi({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:Rg}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}unsubscribe(){this.mode="inactive"}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(Cg).map((e=>e.value)).join(""),o=this.currentContent,n=e[0].start,r=e[e.length-1].end,s=o.slice(0,n)+i+o.slice(r),a=s.length-o.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:45}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Rg});const{top:t,left:i}=Oi({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Rg});const{top:t,left:i}=Oi({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Ai({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Gi({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var i;const o=this.getters.getActiveCell();e&&(null===(i=null==o?void 0:o.format)||void 0===i?void 0:i.includes("%"))&&pi(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`),this.initialContent=(null==o?void 0:o.composerContent)||"",this.mode="editing";const{col:n,row:r}=this.getters.getPosition();this.col=n,this.row=r,this.sheetId=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const s=Gi({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){const e=this.getters.getActiveSheetId();this.cancelEditionAndActivateSheet();const{col:t,row:i}=this.getters.getMainCellPosition(this.sheetId,this.col,this.row);let o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const n=this.getters.getCell(e,t,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,i=e-t;i>0&&(o+=et(new Array(i).fill(")")))}else(null==n?void 0:n.isLink())&&(o=He(o,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:t,row:i,content:o})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:t,row:i});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){e=e.replace(/[\r\n]/g,"");const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?Sg(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:r("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${Oe(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){1===t.length&&Zi(e.zone)>1?t.push({...t[0]}):2===t.length&&1===Zi(e.zone)&&t.pop();const i=e.clone({parts:this.previousRange.parts});return this.getters.getSelectionRangeString(i,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:o,end:o}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const o=new Set(Object.values(i));let n=0;const r=()=>{for(;o.has(n);)n++;return o.add(n),n};for(const e of t){const t=e in i?i[e]:r();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return ht[t%ht.length]};return this.getReferencedRanges().map((i=>{const o=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(o),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let i=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type)||Nu.includes(o.value);){if("SPACE"!==o.type||i<1)return!1;i--,o=this.currentTokens[i]}for(i=t+1,o=this.currentTokens[i];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;i++,o=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Ig.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const Tg=Ou.content,Ag=new Xi;Ag.add("functions",(()=>Object.keys(Tg).map((e=>({text:e,description:Tg[e].description}))))),po`
983
984
  .o-autocomplete-dropdown {
984
985
  pointer-events: auto;
985
986
  background-color: #fff;
@@ -1003,7 +1004,7 @@
1003
1004
  }
1004
1005
  }
1005
1006
  }
1006
- `;class Tg extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],selectedIndex:0})}setup(){t.onMounted((()=>this.filter(this.props.search))),t.onWillUpdateProps((e=>this.checkUpdateProps(e))),this.props.exposeAPI({getValueToFill:()=>this.getValueToFill(),moveDown:()=>this.moveDown(),moveUp:()=>this.moveUp()})}checkUpdateProps(e){e.search!==this.props.search&&this.filter(e.search)}async filter(e){let t=Ig.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.props.onCompleted(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}}Tg.template="o-spreadsheet-TextValueProvider";class Ag{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let i=window.getSelection();this.removeSelection();let o=document.createRange();if(e==t&&0===e)o.setStart(this.el,0),o.setEnd(this.el,0),i.addRange(o);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 n=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);o.setStart(n.node,n.offset),i.addRange(o),i.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,i,o=this.iterateChildren(this.el),n=e;do{t=o.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<n?n-=t.value.textContent.length:o.return(t.value),i=t.value)}while(!t.done);return t.value?{node:t.value,offset:n}:{node:i,offset:n}}*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:i,endSelectionOffset:o}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,i),end:this.findSelectionIndex(t,o)}}findSelectionIndex(e,t){let i=this.iterateChildren(this.el),o=0,n=i.next();for(;!n.done&&n.value!==e;)n.value.hasChildNodes()||n.value.textContent&&(o+=n.value.textContent.length),n=i.next();if(n.value===e)if(n.value.hasChildNodes()){const e=[...n.value.childNodes].slice(0,t);for(const t of e)t.textContent&&(o+=t.textContent.length)}else o+=t;return o}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}}go`
1007
+ `;class Og extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],selectedIndex:0})}setup(){t.onMounted((()=>this.filter(this.props.search))),t.onWillUpdateProps((e=>this.checkUpdateProps(e))),this.props.exposeAPI({getValueToFill:()=>this.getValueToFill(),moveDown:()=>this.moveDown(),moveUp:()=>this.moveUp()})}checkUpdateProps(e){e.search!==this.props.search&&this.filter(e.search)}async filter(e){let t=Ag.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.props.onCompleted(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}}Og.template="o-spreadsheet-TextValueProvider";class Mg{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let i=window.getSelection();this.removeSelection();let o=document.createRange();if(e==t&&0===e)o.setStart(this.el,0),o.setEnd(this.el,0),i.addRange(o);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 n=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);o.setStart(n.node,n.offset),i.addRange(o),i.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,i,o=this.iterateChildren(this.el),n=e;do{t=o.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<n?n-=t.value.textContent.length:o.return(t.value),i=t.value)}while(!t.done);return t.value?{node:t.value,offset:n}:{node:i,offset:n}}*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:i,endSelectionOffset:o}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,i),end:this.findSelectionIndex(t,o)}}findSelectionIndex(e,t){let i=this.iterateChildren(this.el),o=0,n=i.next();for(;!n.done&&n.value!==e;)n.value.hasChildNodes()||n.value.textContent&&(o+=n.value.textContent.length),n=i.next();if(n.value===e)if(n.value.hasChildNodes()){const e=[...n.value.childNodes].slice(0,t);for(const t of e)t.textContent&&(o+=t.textContent.length)}else o+=t;return o}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}}po`
1007
1008
  .o-formula-assistant {
1008
1009
  white-space: normal;
1009
1010
  background-color: #fff;
@@ -1050,7 +1051,7 @@
1050
1051
  .o-formula-assistant-transparency {
1051
1052
  opacity: 0.3;
1052
1053
  }
1053
- `;class Mg extends t.Component{constructor(){super(...arguments),this.assistantState=t.useState({allowCellSelectionBehind:!1}),this.timeOutId=0}setup(){t.onWillUnmount((()=>{this.timeOutId&&clearTimeout(this.timeOutId)}))}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}Mg.template="o-spreadsheet-FunctionDescriptionProvider";const Og=Tu.content,Ng="#4a4e4d",_g="#3da4ab",Fg="#02c39a",Dg="selector-flag",kg={OPERATOR:_g,NUMBER:Fg,STRING:"#00a82d",FUNCTION:Ng,DEBUGGER:_g,LEFT_PAREN:Ng,RIGHT_PAREN:Ng,COMMA:Ng};go`
1054
+ `;class Ng extends t.Component{constructor(){super(...arguments),this.assistantState=t.useState({allowCellSelectionBehind:!1}),this.timeOutId=0}setup(){t.onWillUnmount((()=>{this.timeOutId&&clearTimeout(this.timeOutId)}))}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}Ng.template="o-spreadsheet-FunctionDescriptionProvider";const _g=Ou.content,Fg="#4a4e4d",Dg="#3da4ab",kg="#02c39a",$g="selector-flag",Lg={OPERATOR:Dg,NUMBER:kg,STRING:"#00a82d",FUNCTION:Fg,DEBUGGER:Dg,LEFT_PAREN:Fg,RIGHT_PAREN:Fg,COMMA:Fg};po`
1054
1055
  .o-composer-container {
1055
1056
  padding: 0;
1056
1057
  margin: 0;
@@ -1071,7 +1072,7 @@
1071
1072
  }
1072
1073
  span {
1073
1074
  white-space: pre;
1074
- &.${Dg}:after {
1075
+ &.${$g}:after {
1075
1076
  content: "${"␣"}";
1076
1077
  color: ${"darkgrey"};
1077
1078
  }
@@ -1092,14 +1093,14 @@
1092
1093
  .o-topbar-toolbar .o-composer-container {
1093
1094
  z-index: ${ne.TopBarComposer};
1094
1095
  }
1095
- `;class $g extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Ag(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,provider:"functions",search:""}),this.functionDescriptionState=t.useState({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:this.processF4Key,Tab:e=>this.processTabKey(e)}}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:i}=this.props.rect;let o="";return t>this.props.delimitation.height-(t+i)&&(o+="\n top: -8px;\n transform: translate(0, -100%);\n "),e+300>this.props.delimitation.width&&(o+="right:0px;"),o+="width:300px;"}return"width:300px;"}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent()})),t.onWillUnmount((()=>{var e,t;null===(t=(e=this.props).onComposerUnmounted)||void 0===t||t.call(e)})),t.onPatched((()=>{this.isKeyStillDown||this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,void e.preventDefault();const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&this.autocompleteAPI&&(e.preventDefault(),"ArrowUp"===e.key?this.autocompleteAPI.moveUp():this.autocompleteAPI.moveDown()),this.updateCursorIfNeeded()):this.env.model.dispatch("STOP_EDITION")}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider&&this.autocompleteAPI){const e=this.autocompleteAPI.getValueToFill();if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(t,1)}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),this.isKeyStillDown=!1,this.autoCompleteState.showProvider&&this.autocompleteAPI){const e=this.autocompleteAPI.getValueToFill();if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const t=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(t,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}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.env.model.getters.isSelectingForComposer()){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onInput(){if("inactive"===this.props.focus||!this.shouldProcessInputEvents)return;this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const e=this.composerRef.el;this.env.model.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","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.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.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:i}=this.env.model.getters.getComposerSelection(),{start:o,end:n}=this.contentHelper.getCurrentSelection();o===t&&n===i||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}onCompleted(e){e&&this.autoComplete(e)}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:i}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,i)}this.shouldProcessInputEvents=!0}getContent(){let e;const t=this.env.model.getters.getCurrentContent(),i=t.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return e=""===t?[]:i&&"inactive"!==this.props.focus?this.getColoredTokens():[{value:t}],e}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),i=[],{start:o,end:n}=this.env.model.getters.getComposerSelection();for(const r of e){switch(r.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":i.push({value:r.value,color:kg[r.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:o}=Nt(r.value);i.push({value:r.value,color:this.rangeColor(e,o)||"#000"});break;case"SYMBOL":let n=r.value;["TRUE","FALSE"].includes(n.toUpperCase())?i.push({value:r.value,color:Fg}):i.push({value:r.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===r.parenIndex?i.push({value:r.value,color:"black"}):i.push({value:r.value,color:kg[r.type]||"#000"});break;default:i.push({value:r.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&n===o&&n===r.end&&(i[i.length-1].class=Dg)}return i}rangeColor(e,t){if("inactive"===this.props.focus)return;const i=this.env.model.getters.getHighlights(),o=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=i.find((t=>{if(t.sheetId!==o)return!1;let i=this.env.model.getters.getRangeFromSheetXC(o,e).zone;const{height:n,width:r}=Pi(i);return i=n*r==1?this.env.model.getters.expandZone(o,i):i,_i(i,t.zone)}));return n&&n.color?n.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=Nt(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!It.test(t))this.autoCompleteState.search=e.value,this.autoCompleteState.showProvider=!0;else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,i=t.parent.toUpperCase(),o=Og[i],n=t.argPosition;this.functionDescriptionState.functionName=i,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let i=t.end,o=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(i=t.start);const n=this.env.model.getters.getCurrentTokens();if(this.autoCompleteState.provider&&n.length){e+="(";const i=n.map((e=>e.start)).indexOf(t.start);if(i+1<n.length){"LEFT_PAREN"===n[i+1].type&&o++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:o})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}$g.template="o-spreadsheet-Composer",$g.components={TextValueProvider:Tg,FunctionDescriptionProvider:Mg},$g.defaultProps={inputStyle:"",focus:"inactive"};const Lg=3*.4*window.devicePixelRatio||1;go`
1096
+ `;class Pg extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Mg(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,provider:"functions",search:""}),this.functionDescriptionState=t.useState({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:this.processF4Key,Tab:e=>this.processTabKey(e)}}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:i}=this.props.rect;let o="";return t>this.props.delimitation.height-(t+i)&&(o+="\n top: -8px;\n transform: translate(0, -100%);\n "),e+300>this.props.delimitation.width&&(o+="right:0px;"),o+="width:300px;"}return"width:300px;"}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent()})),t.onWillUnmount((()=>{var e,t;null===(t=(e=this.props).onComposerUnmounted)||void 0===t||t.call(e)})),t.onPatched((()=>{this.isKeyStillDown||this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,void e.preventDefault();const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&this.autocompleteAPI&&(e.preventDefault(),"ArrowUp"===e.key?this.autocompleteAPI.moveUp():this.autocompleteAPI.moveDown()),this.updateCursorIfNeeded()):this.env.model.dispatch("STOP_EDITION")}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider&&this.autocompleteAPI){const e=this.autocompleteAPI.getValueToFill();if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(t,1)}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),this.isKeyStillDown=!1,this.autoCompleteState.showProvider&&this.autocompleteAPI){const e=this.autocompleteAPI.getValueToFill();if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const t=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(t,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}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.env.model.getters.isSelectingForComposer()){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onInput(){if("inactive"===this.props.focus||!this.shouldProcessInputEvents)return;this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const e=this.composerRef.el;this.env.model.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","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.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.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:i}=this.env.model.getters.getComposerSelection(),{start:o,end:n}=this.contentHelper.getCurrentSelection();o===t&&n===i||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}onCompleted(e){e&&this.autoComplete(e)}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:i}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,i)}this.shouldProcessInputEvents=!0}getContent(){let e;const t=this.env.model.getters.getCurrentContent(),i=t.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return e=""===t?[]:i&&"inactive"!==this.props.focus?this.getColoredTokens():[{value:t}],e}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),i=[],{start:o,end:n}=this.env.model.getters.getComposerSelection();for(const r of e){switch(r.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":i.push({value:r.value,color:Lg[r.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:o}=_t(r.value);i.push({value:r.value,color:this.rangeColor(e,o)||"#000"});break;case"SYMBOL":let n=r.value;["TRUE","FALSE"].includes(n.toUpperCase())?i.push({value:r.value,color:kg}):i.push({value:r.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===r.parenIndex?i.push({value:r.value,color:"black"}):i.push({value:r.value,color:Lg[r.type]||"#000"});break;default:i.push({value:r.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&n===o&&n===r.end&&(i[i.length-1].class=$g)}return i}rangeColor(e,t){if("inactive"===this.props.focus)return;const i=this.env.model.getters.getHighlights(),o=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=i.find((t=>{if(t.sheetId!==o)return!1;let i=this.env.model.getters.getRangeFromSheetXC(o,e).zone;const{height:n,width:r}=Ui(i);return i=n*r==1?this.env.model.getters.expandZone(o,i):i,Fi(i,t.zone)}));return n&&n.color?n.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=_t(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Tt.test(t))this.autoCompleteState.search=e.value,this.autoCompleteState.showProvider=!0;else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,i=t.parent.toUpperCase(),o=_g[i],n=t.argPosition;this.functionDescriptionState.functionName=i,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let i=t.end,o=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(i=t.start);const n=this.env.model.getters.getCurrentTokens();if(this.autoCompleteState.provider&&n.length){e+="(";const i=n.map((e=>e.start)).indexOf(t.start);if(i+1<n.length){"LEFT_PAREN"===n[i+1].type&&o++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:o})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Pg.template="o-spreadsheet-Composer",Pg.components={TextValueProvider:Og,FunctionDescriptionProvider:Ng},Pg.defaultProps={inputStyle:"",focus:"inactive"};const Ug=3*.4*window.devicePixelRatio||1;po`
1096
1097
  div.o-grid-composer {
1097
1098
  z-index: ${ne.GridComposer};
1098
1099
  box-sizing: border-box;
1099
1100
  position: absolute;
1100
- border: ${Lg}px solid ${E};
1101
+ border: ${Ug}px solid ${E};
1101
1102
  }
1102
- `;class Pg extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:null,delimitation:null});const{col:e,row:i}=this.env.model.getters.getPosition();this.zone=this.env.model.getters.expandZone(this.env.model.getters.getActiveSheetId(),{left:e,right:e,top:i,bottom:i}),this.rect=this.env.model.getters.getVisibleRect(this.zone),t.onMounted((()=>{const e=this.gridComposerRef.el,t=e.parentElement.clientHeight-this.rect.y-15;e.style.maxHeight=t+"px";const i=e.parentElement.clientWidth-this.rect.x-14;e.style.maxWidth=i+"px",this.composerState.rect={x:this.rect.x,y:this.rect.y,width:e.clientWidth,height:e.clientHeight},this.composerState.delimitation={width:e.parentElement.clientWidth,height:e.parentElement.clientHeight}}))}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell();let i={};if(t){const e=this.env.model.getters.getCellPosition(t.id);i=this.env.model.getters.getCellComputedStyle(e.sheetId,e.col,e.row)}const{x:o,y:n,width:r,height:s}=this.rect,a=!e&&i.fillColor||"#ffffff",l=!e&&i.textColor||"#000000",c=!e&&i.fontSize||10,h=!e&&i.bold?"bold":500,d=!e&&i.italic?"italic":"normal",u=e?"none":po(i);let g="left";return e||(g=i.align||(null==t?void 0:t.defaultAlign)||"left"),`\n left: ${o-1}px;\n top: ${n}px;\n min-width: ${r+2}px;\n min-height: ${s+1}px;\n\n background: ${a};\n color: ${l};\n\n font-size: ${se[c]}px;\n font-weight: ${h};\n font-style: ${d};\n text-decoration: ${u};\n\n text-align: ${g};\n `}get composerStyle(){return`\n line-height: ${F}px;\n max-height: inherit;\n overflow: hidden;\n `}}Pg.template="o-spreadsheet-GridComposer",Pg.components={Composer:$g};const Ug=go`
1103
+ `;class Vg extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:null,delimitation:null});const{col:e,row:i}=this.env.model.getters.getPosition();this.zone=this.env.model.getters.expandZone(this.env.model.getters.getActiveSheetId(),{left:e,right:e,top:i,bottom:i}),this.rect=this.env.model.getters.getVisibleRect(this.zone),t.onMounted((()=>{const e=this.gridComposerRef.el,t=e.parentElement.clientHeight-this.rect.y-15;e.style.maxHeight=t+"px";const i=e.parentElement.clientWidth-this.rect.x-14;e.style.maxWidth=i+"px",this.composerState.rect={x:this.rect.x,y:this.rect.y,width:e.clientWidth,height:e.clientHeight},this.composerState.delimitation={width:e.parentElement.clientWidth,height:e.parentElement.clientHeight}}))}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell();let i={};if(t){const e=this.env.model.getters.getCellPosition(t.id);i=this.env.model.getters.getCellComputedStyle(e.sheetId,e.col,e.row)}const{x:o,y:n,width:r,height:s}=this.rect,a=!e&&i.fillColor||"#ffffff",l=!e&&i.textColor||"#000000",c=!e&&i.fontSize||10,h=!e&&i.bold?"bold":500,d=!e&&i.italic?"italic":"normal",u=e?"none":mo(i);let g="left";return e||(g=i.align||(null==t?void 0:t.defaultAlign)||"left"),`\n left: ${o-1}px;\n top: ${n}px;\n min-width: ${r+2}px;\n min-height: ${s+1}px;\n\n background: ${a};\n color: ${l};\n\n font-size: ${se[c]}px;\n font-weight: ${h};\n font-style: ${d};\n text-decoration: ${u};\n\n text-align: ${g};\n `}get composerStyle(){return`\n line-height: ${F}px;\n max-height: inherit;\n overflow: hidden;\n `}}Vg.template="o-spreadsheet-GridComposer",Vg.components={Composer:Pg};const zg=po`
1103
1104
  .o-filter-icon {
1104
1105
  color: ${I};
1105
1106
  position: absolute;
@@ -1123,7 +1124,7 @@
1123
1124
  }
1124
1125
  }
1125
1126
  }
1126
- `;class Vg extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Vg.style=Ug,Vg.template="o-spreadsheet-FilterIcon";const zg=go``;class Bg extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRowDimensionsInViewport(t,e.row),o=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((i.size-z)/2);return{x:o.end-z+this.props.gridPosition.x-2-1,y:i.end-z+this.props.gridPosition.y-n}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive(t,e.col,e.row)}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:i,row:o}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:i,row:o,popoverType:"FilterMenu"})}isPositionVisible(e,t){const i=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===i.width||0===i.height)}}Bg.style=zg,Bg.template="o-spreadsheet-FilterIconsOverlay",Bg.components={FilterIcon:Vg},Bg.defaultProps={gridPosition:{x:0,y:0}};go`
1127
+ `;class Bg extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Bg.style=zg,Bg.template="o-spreadsheet-FilterIcon";const Hg=po``;class Wg extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRowDimensionsInViewport(t,e.row),o=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((i.size-z)/2);return{x:o.end-z+this.props.gridPosition.x-2-1,y:i.end-z+this.props.gridPosition.y-n}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive(t,e.col,e.row)}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:i,row:o}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:i,row:o,popoverType:"FilterMenu"})}isPositionVisible(e,t){const i=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===i.width||0===i.height)}}Wg.style=Hg,Wg.template="o-spreadsheet-FilterIconsOverlay",Wg.components={FilterIcon:Bg},Wg.defaultProps={gridPosition:{x:0,y:0}};po`
1127
1128
  div.o-figure {
1128
1129
  box-sizing: border-box;
1129
1130
  position: absolute;
@@ -1178,13 +1179,13 @@
1178
1179
  }
1179
1180
  }
1180
1181
  }
1181
- `;class Hg extends t.Component{constructor(){super(...arguments),this.figureRegistry=zo,this.figureRef=t.useRef("figure")}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:1}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:i,height:o}=this.props.figure;return mo({left:`${e}px`,top:`${t}px`,width:`${i}px`,height:`${o}px`,"z-index":String(ne.Figure+(this.isSelected?1:0))})}getResizerPosition(e){let t="";return e.includes("top")?t+="top: -3px;":e.includes("bottom")?t+="bottom: -3px;":t+=" bottom: calc(50% - 3px);",e.includes("left")?t+="left: -3px;":e.includes("right")?t+="right: -3px;":t+=" right: calc(50% - 3px);",t}setup(){t.useEffect(((e,t,i)=>{e===t&&(null==i||i.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,i){this.props.onClickAnchor(e,t,i)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const i={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+i[0],y:t.y+i[1]}),e.preventDefault()}}}Hg.template="o-spreadsheet-FigureComponent",Hg.components={},Hg.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},Hg.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};class Wg extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const i of["topLeft","topRight","bottomLeft","bottomRight"]){const o=e.filter((e=>this.getFigureContainer(e)===i));o.length>0&&t.push({type:i,figures:o,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:i}=this.env.model.getters.getMainViewportRect(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?o:0,s=t-r,a=["bottomRight","bottomLeft"].includes(e)?n:0;return mo({left:`${r}px`,top:`${a}px`,width:`${s}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates();return mo({left:`${["bottomRight","topRight"].includes(e)?-(o+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const i=this.env.model.getters.getActiveSheetId(),o=t.clientX,n=t.clientY,{x:r,y:s}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=s,this.dnd.width=e.width,this.dnd.height=e.height;ps((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-o;this.dnd.x=Math.max(r+u,h);let g=t.clientY-n;this.dnd.y=Math.max(s+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:o,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:o,y:n})}))}startResize(e,t,i,o){o.stopPropagation();const n=o.clientX,r=o.clientY,{x:s,y:a}=this.internalToScreenCoordinates(e);let l;this.dnd.x=s,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height,l=o=>{this.dnd.figId=e.id;const l=Math.max(t*(o.clientX-n),80-e.width),c=Math.max(i*(o.clientY-r),80-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+c,t<0&&(this.dnd.x=s-l),i<0&&(this.dnd.y=a-c),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)};ps(l,(o=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:n,y:r}=this.screenCoordinatesToInternal(this.dnd);const s={x:n,y:r};t&&(s.width=this.dnd.width),i&&(s.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...s})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":mo({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-n,y:t=t<o?t:t-r}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+n,y:t=o&&t<o?t:t+r}}}function Gg(e,i,o){let n={col:void 0,row:void 0};const{Date:r}=window;let s=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(s),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let o;const{setInterval:n,clearInterval:r}=window;return t.useEffect((()=>(o=n(e,i),()=>r(o))),(()=>[i])),{pause:()=>{r(o),o=void 0},resume:()=>{void 0===o&&(o=n(e,i))}}}((function(){const{col:e,row:t}=c(),i=r.now()-l;i>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){s=e.offsetX,a=e.offsetY,l=r.now()}function g(){const{col:e,row:t}=c();e===n.col&&t===n.row||p(void 0,void 0)}function p(e,t){e===n.col&&t===n.row||(n.col=e,n.row=t,o({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}Wg.template="o-spreadsheet-FiguresContainer",Wg.components={FigureComponent:Hg},zo.add("chart",{Component:gs,SidePanelComponent:"ChartPanel"});class qg extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),Gg(this.env,this.gridOverlay,this.props.onCellHovered),t.useEffect((()=>this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})),(()=>[this.gridOverlayEl.clientHeight,this.gridOverlayEl.clientWidth])),function(e,i,o){let n=null,r=null;function s(e){1===e.touches.length&&(n=e.touches[0].clientX,r=e.touches[0].clientY)}function a(){n=null,r=null}function l(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,s=e.touches[0].clientY;i(n-t,r-s),n=t,r=s}t.onMounted((()=>{e.el.addEventListener("touchstart",s),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",s),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}qg.template="o-spreadsheet-GridOverlay",qg.components={FiguresContainer:Wg},qg.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{},sidePanelIsOpen:!1};class Zg extends t.Component{constructor(){super(...arguments),this.zIndex=ne.GridPopover}get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.coordinates;return{...e,coordinates:{x:t.x+this.props.gridPosition.x,y:t.y+this.props.gridPosition.y}}}}Zg.template="o-spreadsheet-GridPopover",Zg.components={Popover:To};class jg extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),i=this._getElementIndex(t);if(i<0)return;const o=this._getDimensionsInViewport(i);t-o.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.start,this.state.activeElement=this._getPreviousVisibleElement(i)):o.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),o=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();i.has(o)&&o<=t&&t<=n?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),i=this.state.draggerLinePosition,o=this._getElementSize(this.state.activeElement),n=i-o+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();ps((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-o),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-i)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),o=t.start;this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=i.end-t.start;ms(this.env,((e,i)=>{let o="COL"===this._getType()?e:i;if(o>=0){const e=this._getDimensionsInViewport(o);o<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=o):this._getSelectedZoneEnd()<o?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=o+1):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;ms(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}go`
1182
+ `;class Gg extends t.Component{constructor(){super(...arguments),this.figureRegistry=Bo,this.figureRef=t.useRef("figure")}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:1}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:i,height:o}=this.props.figure;return fo({left:`${e}px`,top:`${t}px`,width:`${i}px`,height:`${o}px`,"z-index":String(ne.Figure+(this.isSelected?1:0))})}getResizerPosition(e){let t="";return e.includes("top")?t+="top: -3px;":e.includes("bottom")?t+="bottom: -3px;":t+=" bottom: calc(50% - 3px);",e.includes("left")?t+="left: -3px;":e.includes("right")?t+="right: -3px;":t+=" right: calc(50% - 3px);",t}setup(){t.useEffect(((e,t,i)=>{e===t&&(null==i||i.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,i){this.props.onClickAnchor(e,t,i)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const i={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+i[0],y:t.y+i[1]}),e.preventDefault()}}}Gg.template="o-spreadsheet-FigureComponent",Gg.components={},Gg.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},Gg.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};class qg extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const i of["topLeft","topRight","bottomLeft","bottomRight"]){const o=e.filter((e=>this.getFigureContainer(e)===i));o.length>0&&t.push({type:i,figures:o,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:i}=this.env.model.getters.getMainViewportRect(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?o:0,s=t-r,a=["bottomRight","bottomLeft"].includes(e)?n:0;return fo({left:`${r}px`,top:`${a}px`,width:`${s}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates();return fo({left:`${["bottomRight","topRight"].includes(e)?-(o+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const i=this.env.model.getters.getActiveSheetId(),o=t.clientX,n=t.clientY,{x:r,y:s}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=s,this.dnd.width=e.width,this.dnd.height=e.height;fs((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-o;this.dnd.x=Math.max(r+u,h);let g=t.clientY-n;this.dnd.y=Math.max(s+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:o,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:o,y:n})}))}startResize(e,t,i,o){o.stopPropagation();const n=o.clientX,r=o.clientY,{x:s,y:a}=this.internalToScreenCoordinates(e);let l;this.dnd.x=s,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height,l=o=>{this.dnd.figId=e.id;const l=Math.max(t*(o.clientX-n),80-e.width),c=Math.max(i*(o.clientY-r),80-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+c,t<0&&(this.dnd.x=s-l),i<0&&(this.dnd.y=a-c),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)};fs(l,(o=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:n,y:r}=this.screenCoordinatesToInternal(this.dnd);const s={x:n,y:r};t&&(s.width=this.dnd.width),i&&(s.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...s})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":fo({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-n,y:t=t<o?t:t-r}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+n,y:t=o&&t<o?t:t+r}}}function Zg(e,i,o){let n={col:void 0,row:void 0};const{Date:r}=window;let s=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(s),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let o;const{setInterval:n,clearInterval:r}=window;return t.useEffect((()=>(o=n(e,i),()=>r(o))),(()=>[i])),{pause:()=>{r(o),o=void 0},resume:()=>{void 0===o&&(o=n(e,i))}}}((function(){const{col:e,row:t}=c(),i=r.now()-l;i>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){s=e.offsetX,a=e.offsetY,l=r.now()}function g(){const{col:e,row:t}=c();e===n.col&&t===n.row||p(void 0,void 0)}function p(e,t){e===n.col&&t===n.row||(n.col=e,n.row=t,o({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}qg.template="o-spreadsheet-FiguresContainer",qg.components={FigureComponent:Gg},Bo.add("chart",{Component:ms,SidePanelComponent:"ChartPanel"});class jg extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),Zg(this.env,this.gridOverlay,this.props.onCellHovered),t.useEffect((()=>this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})),(()=>[this.gridOverlayEl.clientHeight,this.gridOverlayEl.clientWidth])),function(e,i,o){let n=null,r=null;function s(e){1===e.touches.length&&(n=e.touches[0].clientX,r=e.touches[0].clientY)}function a(){n=null,r=null}function l(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,s=e.touches[0].clientY;i(n-t,r-s),n=t,r=s}t.onMounted((()=>{e.el.addEventListener("touchstart",s),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",s),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}jg.template="o-spreadsheet-GridOverlay",jg.components={FiguresContainer:qg},jg.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{},sidePanelIsOpen:!1};class Xg extends t.Component{constructor(){super(...arguments),this.zIndex=ne.GridPopover}get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.coordinates;return{...e,coordinates:{x:t.x+this.props.gridPosition.x,y:t.y+this.props.gridPosition.y}}}}Xg.template="o-spreadsheet-GridPopover",Xg.components={Popover:Ao};class Yg extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),i=this._getElementIndex(t);if(i<0)return;const o=this._getDimensionsInViewport(i);t-o.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.start,this.state.activeElement=this._getPreviousVisibleElement(i)):o.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),o=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();i.has(o)&&o<=t&&t<=n?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),i=this.state.draggerLinePosition,o=this._getElementSize(this.state.activeElement),n=i-o+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();fs((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-o),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-i)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),o=t.start;this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=i.end-t.start;vs(this.env,((e,i)=>{let o="COL"===this._getType()?e:i;if(o>=0){const e=this._getDimensionsInViewport(o);o<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=o):this._getSelectedZoneEnd()<o?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=o+1):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;vs(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}po`
1182
1183
  .o-col-resizer {
1183
1184
  position: absolute;
1184
1185
  top: 0;
1185
1186
  left: ${N}px;
1186
1187
  right: 0;
1187
- height: ${O}px;
1188
+ height: ${M}px;
1188
1189
  &.o-dragging {
1189
1190
  cursor: grabbing;
1190
1191
  }
@@ -1192,14 +1193,14 @@
1192
1193
  cursor: grab;
1193
1194
  }
1194
1195
  .dragging-col-line {
1195
- top: ${O}px;
1196
+ top: ${M}px;
1196
1197
  position: absolute;
1197
1198
  width: 2px;
1198
1199
  height: 10000px;
1199
1200
  background-color: black;
1200
1201
  }
1201
1202
  .dragging-col-shadow {
1202
- top: ${O}px;
1203
+ top: ${M}px;
1203
1204
  position: absolute;
1204
1205
  height: 10000px;
1205
1206
  background-color: black;
@@ -1207,13 +1208,13 @@
1207
1208
  }
1208
1209
  .o-handle {
1209
1210
  position: absolute;
1210
- height: ${O}px;
1211
+ height: ${M}px;
1211
1212
  width: 4px;
1212
1213
  cursor: e-resize;
1213
1214
  background-color: ${E};
1214
1215
  }
1215
1216
  .dragging-resizer {
1216
- top: ${O}px;
1217
+ top: ${M}px;
1217
1218
  position: absolute;
1218
1219
  margin-left: 2px;
1219
1220
  width: 1px;
@@ -1226,7 +1227,7 @@
1226
1227
  position: absolute;
1227
1228
  overflow: hidden;
1228
1229
  border-radius: 2px;
1229
- top: calc(${O}px / 2 - ${$}px / 2);
1230
+ top: calc(${M}px / 2 - ${$}px / 2);
1230
1231
  }
1231
1232
  .o-unhide:hover {
1232
1233
  z-index: ${ne.Grid+1};
@@ -1237,10 +1238,10 @@
1237
1238
  top: calc(${$}px / 2 - ${k}px / 2);
1238
1239
  }
1239
1240
  }
1240
- `;class Xg extends jg{setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),i=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Vn)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let i;for(i=e-1;i>=0&&this.env.model.getters.isColHidden(t,i);i--);return i}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Xg.template="o-spreadsheet-ColResizer",go`
1241
+ `;class Kg extends Yg{setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),i=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Bn)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let i;for(i=e-1;i>=0&&this.env.model.getters.isColHidden(t,i);i--);return i}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Kg.template="o-spreadsheet-ColResizer",po`
1241
1242
  .o-row-resizer {
1242
1243
  position: absolute;
1243
- top: ${O}px;
1244
+ top: ${M}px;
1244
1245
  left: 0;
1245
1246
  right: 0;
1246
1247
  width: ${N}px;
@@ -1298,7 +1299,7 @@
1298
1299
  background-color: lightgrey;
1299
1300
  }
1300
1301
  }
1301
- `;class Yg extends jg{setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),i=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Vn)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let i;for(i=e-1;i>=0&&this.env.model.getters.isRowHidden(t,i);i--);return i}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Yg.template="o-spreadsheet-RowResizer",go`
1302
+ `;class Qg extends Yg{setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),i=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Bn)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let i;for(i=e-1;i>=0&&this.env.model.getters.isRowHidden(t,i);i--);return i}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Qg.template="o-spreadsheet-RowResizer",po`
1302
1303
  .o-overlay {
1303
1304
  .all {
1304
1305
  position: absolute;
@@ -1306,10 +1307,10 @@
1306
1307
  left: 0;
1307
1308
  right: 0;
1308
1309
  width: ${N}px;
1309
- height: ${O}px;
1310
+ height: ${M}px;
1310
1311
  }
1311
1312
  }
1312
- `;class Kg extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function Qg(e,i,o){const n=t.useRef(e);t.useEffect((function(){const e=n.el,t=window.devicePixelRatio||1,r=e.getContext("2d",{alpha:!1}),s={ctx:r,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=o();e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),r.translate(-m,-m),r.scale(t,t),i.drawGrid(s)}))}function Jg(e){function t(e,t){return e*(0===t?1:F)}return i=>{const o=t(i.shiftKey?i.deltaY:i.deltaX,i.deltaMode),n=t(i.shiftKey?i.deltaX:i.deltaY,i.deltaMode);e(o,n)}}Kg.template="o-spreadsheet-HeadersOverlay",Kg.components={ColResizer:Xg,RowResizer:Yg},go`
1313
+ `;class Jg extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function ep(e,i,o){const n=t.useRef(e);t.useEffect((function(){const e=n.el,t=window.devicePixelRatio||1,r=e.getContext("2d",{alpha:!1}),s={ctx:r,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=o();e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),r.translate(-m,-m),r.scale(t,t),i.drawGrid(s)}))}function tp(e){function t(e,t){return e*(0===t?1:F)}return i=>{const o=t(i.shiftKey?i.deltaY:i.deltaX,i.deltaMode),n=t(i.shiftKey?i.deltaX:i.deltaY,i.deltaMode);e(o,n)}}Jg.template="o-spreadsheet-HeadersOverlay",Jg.components={ColResizer:Kg,RowResizer:Qg},po`
1313
1314
  .o-border {
1314
1315
  position: absolute;
1315
1316
  &:hover {
@@ -1319,7 +1320,7 @@
1319
1320
  .o-moving {
1320
1321
  cursor: grabbing;
1321
1322
  }
1322
- `;class ep extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),i=["n","s"].includes(this.props.orientation),o=["w","e"].includes(this.props.orientation),n=this.props.zone,r=this.env.model.getters.getVisibleRect(n),s=r.x,a=r.x+r.width-4,l=r.y,c=r.y+r.height-4;return`\n left:${t?s:a}px;\n top:${e?l:c}px;\n width:${i?a-s:4}px;\n height:${o?c-l:4}px;\n `}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}ep.template="o-spreadsheet-Border",go`
1323
+ `;class ip extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),i=["n","s"].includes(this.props.orientation),o=["w","e"].includes(this.props.orientation),n=this.props.zone,r=this.env.model.getters.getVisibleRect(n),s=r.x,a=r.x+r.width-4,l=r.y,c=r.y+r.height-4;return`\n left:${t?s:a}px;\n top:${e?l:c}px;\n width:${i?a-s:4}px;\n height:${o?c-l:4}px;\n `}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}ip.template="o-spreadsheet-Border",po`
1323
1324
  .o-corner {
1324
1325
  position: absolute;
1325
1326
  height: 6px;
@@ -1341,11 +1342,11 @@
1341
1342
  .o-resizing {
1342
1343
  cursor: grabbing;
1343
1344
  }
1344
- `;class tp extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,i=this.isTop?e.top:e.bottom,o=this.env.model.getters.getVisibleRect({left:t,right:t,top:i,bottom:i});if(o.width*o.height==0)return"display:none";return`\n left:${(this.isLeft?o.x:o.x+o.width)-4}px;\n top:${(this.isTop?o.y:o.y+o.height)-4}px;\n background-color:${this.props.color};\n `}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}tp.template="o-spreadsheet-Corner",go`
1345
+ `;class op extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,i=this.isTop?e.top:e.bottom,o=this.env.model.getters.getVisibleRect({left:t,right:t,top:i,bottom:i});if(o.width*o.height==0)return"display:none";return`\n left:${(this.isLeft?o.x:o.x+o.width)-4}px;\n top:${(this.isTop?o.y:o.y+o.height)-4}px;\n background-color:${this.props.color};\n `}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}op.template="o-spreadsheet-Corner",po`
1345
1346
  .o-highlight {
1346
1347
  z-index: ${ne.Highlight};
1347
1348
  }
1348
- `;class ip extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const i=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const o=this.props.zone,n=e?o.right:o.left,r=t?o.bottom:o.top;let s=e?o.left:o.right,a=t?o.top:o.bottom,l=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,l)});ms(this.env,((e,t)=>{if(s!==e||a!==t){const o=this.env.model.getters.getActiveSheetId();s=Oe(-1===e?s:e,0,this.env.model.getters.getNumberCols(o)-1),a=Oe(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let c={left:Math.min(n,s),top:Math.min(r,a),right:Math.max(n,s),bottom:Math.max(r,a)};c=this.env.model.getters.expandZone(o,c),_i(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const i=this.props.zone,o=Ro(),n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getColIndex(e-o.left),s=this.env.model.getters.getRowIndex(t-o.top),a=-i.left,l=this.env.model.getters.getNumberCols(n)-i.right-1,c=-i.top,h=this.env.model.getters.getNumberRows(n)-i.bottom-1;let d=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,d)});let u=r,g=s;ms(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const o=Oe(u-r,a,l),p=Oe(g-s,c,h);let m={left:i.left+o,top:i.top+p,right:i.right+o,bottom:i.bottom+p};m=this.env.model.getters.expandZone(n,m),_i(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,m)}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}ip.template="o-spreadsheet-Highlight",ip.components={Corner:tp,Border:ep};class op{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}}go`
1349
+ `;class np extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const i=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const o=this.props.zone,n=e?o.right:o.left,r=t?o.bottom:o.top;let s=e?o.left:o.right,a=t?o.top:o.bottom,l=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,l)});vs(this.env,((e,t)=>{if(s!==e||a!==t){const o=this.env.model.getters.getActiveSheetId();s=Me(-1===e?s:e,0,this.env.model.getters.getNumberCols(o)-1),a=Me(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let c={left:Math.min(n,s),top:Math.min(r,a),right:Math.max(n,s),bottom:Math.max(r,a)};c=this.env.model.getters.expandZone(o,c),Fi(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const i=this.props.zone,o=Io(),n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getColIndex(e-o.left),s=this.env.model.getters.getRowIndex(t-o.top),a=-i.left,l=this.env.model.getters.getNumberCols(n)-i.right-1,c=-i.top,h=this.env.model.getters.getNumberRows(n)-i.bottom-1;let d=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,d)});let u=r,g=s;vs(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const o=Me(u-r,a,l),p=Me(g-s,c,h);let m={left:i.left+o,top:i.top+p,right:i.right+o,bottom:i.bottom+p};m=this.env.model.getters.expandZone(n,m),Fi(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,m)}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}np.template="o-spreadsheet-Highlight",np.components={Corner:op,Border:ip};class rp{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}}po`
1349
1350
  .o-scrollbar {
1350
1351
  position: absolute;
1351
1352
  overflow: auto;
@@ -1361,7 +1362,7 @@
1361
1362
  border-left: 1px solid #e2e3e3;
1362
1363
  }
1363
1364
  }
1364
- `;class np extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new op(this.scrollbarRef.el,this.props.direction),t.onMounted((()=>{this.scrollbar.el=this.scrollbarRef.el})),t.useEffect((()=>{this.scrollbar.scroll!==this.props.offset&&(this.scrollbar.scroll=this.props.offset)}),(()=>[this.scrollbar.scroll,this.props.offset]))}get sizeCss(){return mo({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return mo(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}np.template=t.xml`
1365
+ `;class sp extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new rp(this.scrollbarRef.el,this.props.direction),t.onMounted((()=>{this.scrollbar.el=this.scrollbarRef.el})),t.useEffect((()=>{this.scrollbar.scroll!==this.props.offset&&(this.scrollbar.scroll=this.props.offset)}),(()=>[this.scrollbar.scroll,this.props.offset]))}get sizeCss(){return fo({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return fo(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}sp.template=t.xml`
1365
1366
  <div
1366
1367
  t-attf-class="o-scrollbar {{props.direction}}"
1367
1368
  t-on-scroll="onScroll"
@@ -1369,7 +1370,7 @@
1369
1370
  t-att-style="positionCss">
1370
1371
  <div t-att-style="sizeCss"/>
1371
1372
  </div>
1372
- `,np.defaultProps={width:1,height:1};class rp extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollX}get width(){return this.env.model.getters.getMainViewportRect().width}get isDisplayed(){const{xRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{x:e}=this.env.model.getters.getMainViewportRect();return{left:`${this.props.position.left+e}px`,bottom:"0px",height:"15px",right:"0px"}}onScroll(e){const{scrollY:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t})}}rp.components={ScrollBar:np},rp.template=t.xml`
1373
+ `,sp.defaultProps={width:1,height:1};class ap extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollX}get width(){return this.env.model.getters.getMainViewportRect().width}get isDisplayed(){const{xRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{x:e}=this.env.model.getters.getMainViewportRect();return{left:`${this.props.position.left+e}px`,bottom:"0px",height:"15px",right:"0px"}}onScroll(e){const{scrollY:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t})}}ap.components={ScrollBar:sp},ap.template=t.xml`
1373
1374
  <ScrollBar
1374
1375
  t-if="isDisplayed"
1375
1376
  width="width"
@@ -1377,7 +1378,7 @@
1377
1378
  offset="offset"
1378
1379
  direction="'horizontal'"
1379
1380
  onScroll.bind="onScroll"
1380
- />`,rp.defaultProps={position:{left:0}};class sp extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.position.top+e}px`,right:"0px",width:"15px",bottom:"0px"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}sp.components={ScrollBar:np},sp.template=t.xml`
1381
+ />`,ap.defaultProps={position:{left:0}};class lp extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.position.top+e}px`,right:"0px",width:"15px",bottom:"0px"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}lp.components={ScrollBar:sp},lp.template=t.xml`
1381
1382
  <ScrollBar
1382
1383
  t-if="isDisplayed"
1383
1384
  height="height"
@@ -1385,9 +1386,9 @@
1385
1386
  offset="offset"
1386
1387
  direction="'vertical'"
1387
1388
  onScroll.bind="onScroll"
1388
- />`,sp.defaultProps={position:{top:0}};const ap={ROW:_n,COL:Nn,CELL:On};class lp extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=O,this.HEADER_WIDTH=N,this.keyDownMapping={ENTER:()=>{const e=this.env.model.getters.getActiveCell();!e||e.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{const e=this.env.model.getters.getActiveCell();!e||e.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+S":()=>{var e,t;null===(t=(e=this.props).onSaveRequested)||void 0===t||t.call(e)},"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"ALT+=":()=>{var e;const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,i,o.cell);if(this.env.model.getters.isSingleCellOrMerge(t,i)||this.env.model.getters.isEmpty(t,i)&&n.length<=1){const i=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",o=`=SUM(${i})`;this.props.onGridComposerCellFocused(o,{start:5,end:5+i.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.env.model.getters.getNextVisibleCellPosition(e,0,0);this.env.model.selection.selectCell(t,i)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),i=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,i)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},i=this.env.model.getters.getPosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},i=this.env.model.getters.getPosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP")}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=Io(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),Qg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=Jg(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return"\n top: 26px;\n left: 48px;\n height: calc(100% - 41px);\n width: calc(100% - 63px);\n "}onClosePopover(){this.closeOpenedPopover(),this.focus()}focus(){var e;this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||null===(e=this.hiddenInput.el)||void 0===e||e.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}isAutoFillActive(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:N,gridOffsetY:O})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:Math.max(i+e,0),offsetY:Math.max(o+t,0)})}getClientPositionKey(e){var t,i,o;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(i=e.position)||void 0===i?void 0:i.col}-${null===(o=e.position)||void 0===o?void 0:o.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}onCellClicked(e,t,{ctrlKey:i,shiftKey:o}){i&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),o?this.env.model.selection.setAnchorCorner(e,t):i?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,r=t;ms(this.env,((e,t)=>{(e!==n&&-1!=e||t!==r&&-1!=t)&&(n=-1===e?n:e,r=-1===t?r:t,this.env.model.selection.setAnchorCorner(n,r))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const i=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition(i,e,t));const o=this.env.model.getters.getCell(i,e,t);!o||o.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.closeOpenedPopover();const t={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"}[e.key];e.shiftKey?this.env.model.selection.resizeAnchorZone(t,e.ctrlKey?"end":1):this.env.model.selection.moveAnchorCell(t,e.ctrlKey?"end":1),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];return i?(e.preventDefault(),e.stopPropagation(),void i()):void 0}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:i,top:o}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(i)?n="COL":this.env.model.getters.getActiveRows().has(o)&&(n="ROW");const{x:r,y:s,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(n,r+a,s+l)}onCellRightClicked(e,t,{x:i,y:o}){const n=this.env.model.getters.getSelectedZones();let r="CELL";Di(e,t,n[n.length-1])?this.env.model.getters.getActiveCols().has(e)?r="COL":this.env.model.getters.getActiveRows().has(t)&&(r="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(r,i,o)}toggleContextMenu(e,t,i){this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:i},this.menuState.menuItems=ap[e].getAll()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;if("inactive"!==this.env.model.getters.getEditionMode())return;e?Zo(this.env):this.env.model.dispatch("COPY");const i=this.env.model.getters.getClipboardContent();t.clipboardData.setData("text/plain",i),t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t.types.indexOf("text/plain")>-1){const e=t.getData("text/plain"),i=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardContent()===e?Qo(this.env,i):Jo(this.env,i,e)}}closeMenu(){this.menuState.isOpen=!1,this.focus()}}lp.template="o-spreadsheet-Grid",lp.components={GridComposer:Pg,GridOverlay:qg,GridPopover:Zg,HeadersOverlay:Kg,Menu:Ao,Autofill:fs,ClientTag:bs,Highlight:ip,Popover:To,VerticalScrollBar:sp,HorizontalScrollBar:rp,FilterIconsOverlay:Bg};class cp{constructor(e,t,i){this.id=e,this.style=i.style,this.format=i.format,this.lazyEvaluated=t.map((e=>({...e,format:i.format||e.format})))}isFormula(){return!1}isLink(){return!1}isEmpty(){return!1}get evaluated(){return this.lazyEvaluated()}get formattedValue(){return Gt(this.evaluated.value,this.evaluated.format)}get composerContent(){return this.content}get defaultAlign(){switch(this.evaluated.type){case Ji.number:case Ji.empty:return"right";case Ji.boolean:case Ji.error:return"center";case Ji.text:return"left"}}get isAutoSummable(){var e;switch(this.evaluated.type){case Ji.empty:case Ji.text:return!0;case Ji.number:return!(null===(e=this.evaluated.format)||void 0===e?void 0:e.match(X));case Ji.error:case Ji.boolean:return!1}}}class hp extends cp{constructor(e,t={}){super(e,tt({value:"",type:Ji.empty}),t),this.content=""}isEmpty(){return!0}}class dp extends cp{constructor(e,t,i={}){super(e,tt({value:t,type:Ji.number}),i),this.content=Gt(this.evaluated.value)}get composerContent(){var e;return(null===(e=this.format)||void 0===e?void 0:e.includes("%"))?100*this.evaluated.value+"%":super.composerContent}}class up extends cp{constructor(e,t,i={}){super(e,tt({value:t,type:Ji.boolean}),i),this.content=this.evaluated.value?"TRUE":"FALSE"}}class gp extends cp{constructor(e,t,i={}){super(e,tt({value:t,type:Ji.text}),i),this.content=this.evaluated.value}}class pp extends dp{constructor(e,t,i){super(e,t,i),this.format=i.format}get composerContent(){return Gt(this.evaluated.value,this.format)}}class mp extends cp{constructor(e,t,i={}){var o;const r=We(t);i={...i,style:{...i.style,textColor:(null===(o=i.style)||void 0===o?void 0:o.textColor)||R}},r.label=n(r.label),super(e,tt({value:r.label,type:Ji.text}),i),this.link=r,this.content=t}isLink(){return!0}get composerContent(){return this.link.label}}class fp extends mp{constructor(e,t,i={}){super(e,t,i),this.link.url=this.withHttp(this.link.url),this.link.isExternal=!0,this.content=He(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 vp extends mp{constructor(e,t,i={},o){super(e,t,i),this.sheetName=o,this.sheetId=je(this.link.url),this.isUrlEditable=!1}action(e){e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.model.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}get urlRepresentation(){return this.sheetName(this.sheetId)||r("Invalid sheet")}}class bp extends cp{constructor(e,t,i,o,n){super(t,tt({value:"Loading...",type:Ji.text}),n),this.buildFormulaString=e,this.compiledFormula=i,this.dependencies=o}get content(){return this.buildFormulaString(this)}isFormula(){return!0}assignEvaluation(e){this.lazyEvaluated=e.map((e=>{if(e instanceof c)return{value:e.errorType,type:Ji.error,error:e};const{value:t,format:i}=e;switch(typeof t){case"number":return{value:t||0,format:i,type:Ji.number};case"boolean":return{value:t,format:i,type:Ji.boolean};case"string":return{value:t,format:i,type:Ji.text};case"object":return{value:0,format:i,type:Ji.number};default:return{value:"",type:Ji.empty}}}))}}class Sp extends cp{constructor(e,t,i,o){super(e,tt({value:i.errorType,type:Ji.error,error:i}),o),this.content=t}}function Cp(e){return""===e?"":gi(e)?mi(e):Pe(e)?"TRUE"===e.toUpperCase():Ue(e)?me(e).value:e}Uo.add("Formula",{sequence:10,match:e=>e.startsWith("="),createCell:(e,t,i,o,n)=>{const r=fg(t),s=r.dependencies.map((e=>n.getRangeFromSheetXC(o,e)));return new bp((e=>n.buildFormulaContent(o,e)),e,r,s,i)}}).add("Empty",{sequence:20,match:e=>""===e,createCell:(e,t,i)=>new hp(e,i)}).add("NumberWithDateTimeFormat",{sequence:25,match:(e,t)=>!!t&&gi(e)&&function(e){try{return Kt(1,e),!0}catch(e){return!1}}(t),createCell:(e,t,i)=>{const o=i.format;return new pp(e,mi(t),{...i,format:o})}}).add("Number",{sequence:30,match:e=>gi(e),createCell:(e,t,i)=>(i.format||(i.format=function(e){const t=e.includes(".")?"0.00":"0",i=e.match(/[\$€]/);if(i){const o=e.match(/[\d]/),n="[$"+i.values().next().value+"]";return o.index<i.index?"#,##"+t+n:n+"#,##"+t}if(e.includes("%"))return t+"%";return}(t)),new dp(e,mi(t),i))}).add("Boolean",{sequence:40,match:e=>Pe(e),createCell:(e,t,i)=>new up(e,"TRUE"===t.toUpperCase(),i)}).add("DateTime",{sequence:50,match:e=>Ue(e),createCell:(e,t,i)=>{const o=me(t),n=i.format||o.format;return new pp(e,o.value,{...i,format:n})}}).add("MarkdownSheetLink",{sequence:60,match:e=>qe(e),createCell:(e,t,i,o,n)=>new vp(e,t,i,(e=>n.tryGetSheetName(e)))}).add("MarkdownLink",{sequence:70,match:e=>Be(e),createCell:(e,t,i)=>new fp(e,t,i)}).add("WebLink",{sequence:80,match:e=>{return t=e,ze.test(t);var t},createCell:(e,t,i)=>new fp(e,He(t,t),i)});class Ep{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const wp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],yp="000000",xp={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},Rp={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",table:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",revision:"http://schemas.microsoft.com/office/spreadsheetml/2014/revision",revision3:"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3",markupCompatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006"},Ip="http://schemas.openxmlformats.org/drawingml/2006/main",Tp="http://schemas.openxmlformats.org/drawingml/2006/chart",Ap={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",themes:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",pivot:"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",externalLink:"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"},Mp={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",sharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",drawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"},Op="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Np=.75,_p=.1317,Fp=8.43,Dp=12.75,kp=30,$p=100,Lp=164,Pp={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}]},Up=["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"],Vp="[Content_Types].xml";var zp;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(zp||(zp={}));class Bp{constructor(){this._parsingWarnings=new Set,this._conversionWarnings=new Set}addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,i){let o=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;i&&(o+=`Only ${i.join(", ")} are currently supported.`),this._conversionWarnings.has(o)||this._conversionWarnings.add(o)}}const Hp=["thin"],Wp=["general","left","center","right"],Gp=["Arial"],qp=["solid"],Zp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],jp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},Xp={dashDot:"thin",dashDotDot:"thin",dashed:"thin",dotted:"thin",double:"thin",hair:"thin",medium:"thin",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thin",thin:"thin"},Yp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Kp={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},Qp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},Jp={NoIcons:void 0,"3Arrows":"arrows","3ArrowsGray":"arrows","3Symbols":"smiley","3Symbols2":"smiley","3Signs":"dots","3Flags":"dots","3TrafficLights1":"dots","3TrafficLights2":"dots","4Arrows":"arrows","4ArrowsGray":"arrows","4RedToBlack":"dots","4Rating":"smiley","4TrafficLights":"dots","5Arrows":"arrows","5ArrowsGray":"arrows","5Rating":"smiley","5Quarters":"dots","3Stars":"smiley","3Triangles":"arrows","5Boxes":"dots"},em={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},tm={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},im={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV",8:"STDEVP",9:"SUM",10:"VAR",11:"VARP",101:"AVERAGE",102:"COUNT",103:"COUNTA",104:"MAX",105:"MIN",106:"PRODUCT",107:"STDEV",108:"STDEVP",109:"SUM",110:"VAR",111:"VARP"},om={0:"",1:"0",2:"0.00",3:"#,#00",4:"#,##0.00",9:"0%",10:"0.00%",11:void 0,12:void 0,13:void 0,14:"m/d/yyyy",15:"m/d/yyyy",16:"m/d/yyyy",17:"m/d/yyyy",18:"hh:mm:ss a",19:"hh:mm:ss a",20:"hhhh:mm:ss",21:"hhhh:mm:ss",22:"m/d/yy h:mm",37:void 0,38:void 0,39:void 0,40:void 0,45:"hhhh:mm:ss",46:"hhhh:mm:ss",47:"hhhh:mm:ss",48:void 0,49:void 0},nm={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},rm={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF",16:"800000",17:"008000",18:"000080",19:"808000",20:"800080",21:"008080",22:"C0C0C0",23:"808080",24:"9999FF",25:"993366",26:"FFFFCC",27:"CCFFFF",28:"660066",29:"FF8080",30:"0066CC",31:"CCCCFF",32:"000080",33:"FF00FF",34:"FFFF00",35:"00FFFF",36:"800080",37:"800000",38:"008080",39:"0000FF",40:"00CCFF",41:"CCFFFF",42:"CCFFCC",43:"FFFF99",44:"99CCFF",45:"FF99CC",46:"CC99FF",47:"FFCC99",48:"3366FF",49:"33CCCC",50:"99CC00",51:"FFCC00",52:"FF9900",53:"FF6600",54:"666699",55:"969696",56:"003366",57:"339966",58:"003300",59:"333300",60:"993300",61:"993366",62:"333399",63:"333333",64:"000000",65:"FFFFFF"};function sm(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=yp;else{if(!e.indexed)return;t=rm[e.indexed]}var i;return t=6===(i=t).length?"#"+i+"FF":"#"+i.slice(2)+i.slice(0,2),e.tint&&(t=function(e,t){const i=bt(e),o=Ct(i);t<0&&(o.l=o.l*(1+t));t>0&&(o.l=o.l*(1-t)+(100-100*(1-t)));return vt(St(o))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function am(e,t){const i=e.split("/"),o=t.split("/");let n="",r=0;for(let e=0;e<i.length-1;e++)i[e]===o[e]?r++:n+="../";return n+=o.slice(r).join("/"),n}function lm(e,t=0){const i={};for(let o=0;o<e.length;o++)e[o]&&(i[o+t]=e[o]);return i}function cm(e){const t=[];for(let i of Object.keys(e).map(Number))t[i]=e[i];return t}function hm(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const dm=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function um(e,t,i){var o,n,r;if(0===e)return;let s=om[e]||(null===(o=t.find((t=>t.id===e)))||void 0===o?void 0:o.format);if(s)try{let e=s.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(n=e.match(/"/g))||void 0===n?void 0:n.length)||0;if(t/2+((null===(r=e.match(/\[/g))||void 0===r?void 0:r.length)||0)>1)throw new Error("Multiple escaped blocks in format");if(e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),e=e.replace(/\\./g,(e=>e[1])),function(e){return null!==e.match(dm)}(e)&&(e=function(e){return e=e.toLowerCase(),e=e.replace(/mmmmm|mmmm|mmm/g,"mm"),e=e.replace(/dddd|ddd/g,"dd"),e=e.replace(/am\/pm|a\/m/g,"a"),e=e.replace(/\byy\b/g,"yyyy"),e=e.replace(/hhhh/g,"hh"),e=e.replace(/\bh\b/g,"hh"),e}(e)),function(e){try{return Gt(0,e),!0}catch(e){return!1}}(e))return e}catch(e){}i.generateNotSupportedWarning(zp.NumFmtIdNotSupported,s||`nmFmtId ${e}`)}function gm(e,t){const i=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(zp.DiagonalBorderNotSupported)}(e,t);const i={top:pm(e.top,t),bottom:pm(e.bottom,t),left:pm(e.left,t),right:pm(e.right,t)};return Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e])),i}));return lm(i,1)}function pm(e,t){if(!e)return;!function(e,t){Hp.includes(e.style)||t.generateNotSupportedWarning(zp.BorderStyleNotSupported,e.style,Hp)}(e,t);const i=Xp[e.style];return i?[i,sm(e.color)]:void 0}function mm(e,t){return lm(e.styles.map((i=>fm({fontStyle:e.fonts[i.fontId],fillStyle:e.fills[i.fillId],alignment:i.alignment},t))),1)}function fm(e,t){var i,o,n,r,s,a,l,c,h,d,u,g;return function(e,t,i){e&&e.name&&!Gp.includes(e.name)&&i.generateNotSupportedWarning(zp.FontNotSupported,e.name,Gp);t&&t.patternType&&!qp.includes(t.patternType)&&i.generateNotSupportedWarning(zp.FillStyleNotSupported,t.patternType,qp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!Wp.includes(e)&&t.generateNotSupportedWarning(zp.HorizontalAlignmentNotSupported,e,Wp)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(zp.VerticalAlignmentNotSupported)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.vertical,t),{bold:null===(n=e.fontStyle)||void 0===n?void 0:n.bold,italic:null===(r=e.fontStyle)||void 0===r?void 0:r.italic,strikethrough:null===(s=e.fontStyle)||void 0===s?void 0:s.strike,underline:null===(a=e.fontStyle)||void 0===a?void 0:a.underline,align:(null===(l=e.alignment)||void 0===l?void 0:l.horizontal)?Yp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?sm(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):sm(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:sm(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:(null===(g=e.fontStyle)||void 0===g?void 0:g.size)?bm(e.fontStyle.size):void 0}}function vm(e,t){const i=[];for(let o of e.styles){const n=um(o.numFmtId,e.numFmts,t);n&&(i[o.numFmtId]=n)}return lm(i,1)}function bm(e){return Object.keys(se).map(Number).reduce(((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t))}function Sm(e,t,i){const o=[];let n=1;for(let s of e){if(0===s.cfRules.length)continue;ym(s,t,i);const e=s.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=Cm(n++,s);t&&o.push(t);continue;case"iconSet":const c=Em(n++,s,i);c&&o.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Kp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Kp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(r=e.operator).slice(0,1).toUpperCase()+r.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&o.push({id:(n++).toString(),ranges:s.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:fm({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},i)}})}}var r;return o}function Cm(e,t){const i=t.cfRules[0].colorScale;if(!i||i.cfvos.length!==i.colors.length||i.cfvos.length<2||i.cfvos.length>3)return;const o=[];for(let e=0;e<i.cfvos.length;e++)o.push({color:(n=sm(i.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:Qp[i.cfvos[e].type],value:i.cfvos[e].value});var n;const r=o[0],s=2===o.length?o[1]:o[2],a=3===o.length?o[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:r,midpoint:a,maximum:s}}}function Em(e,t,i){const o=t.cfRules[0].iconSet;if(!o)return;let n=o.cfvos,r=o.cfIcons;if(n.length<3||r&&r.length<3)return;n.length>3&&(n=[n[0],n[Math.floor(n.length/2)],n[n.length-1]]),r&&r.length>3&&(r=[r[0],r[Math.floor(r.length/2)],r[r.length-1]]);const s=[];for(let e=1;e<=2;e++){const t=Qp[n[e].type];if("value"===t)return;s.push({value:n[e].value||"",operator:n[e].gte?"ge":"gt",type:t})}let a={lower:r?wm(r[0].iconSet,r[0].iconId):wm(o.iconSet,0),middle:r?wm(r[1].iconSet,r[1].iconId):wm(o.iconSet,1),upper:r?wm(r[2].iconSet,r[2].iconId):wm(o.iconSet,2)};o.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(i.generateNotSupportedWarning(zp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=is.dots.good;break;case"middle":a[e]=is.dots.neutral;break;case"lower":a[e]=is.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:s[1],lowerInflectionPoint:s[0]}}}function wm(e,t){const i=Jp[e];return i?0===t?is[i].bad:1===t?is[i].neutral:is[i].good:""}function ym(e,t,i){if(e.cfRules.length>1&&i.generateNotSupportedWarning(zp.MultipleRulesCfNotSupported),Zp.includes(e.cfRules[0].type)||i.generateNotSupportedWarning(zp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const o=t[e.cfRules[0].dxfId];o.border&&i.generateNotSupportedWarning(zp.CfFormatBorderNotSupported),o.alignment&&i.generateNotSupportedWarning(zp.CfFormatAlignmentNotSupported),o.numFmt&&i.generateNotSupportedWarning(zp.CfFormatNumFmtNotSupported)}}function xm(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function Rm(e){return Math.round(Np*e*window.devicePixelRatio*100)/100}function Im(e){return Math.round(_p*e*100)/100}function Tm(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function Am(e,t){let i={};e.style&&(i=t.styles[e.style]);const o=function(e,t){if(e.format)return t.formats[e.format];if(e.isFormula){const t=Nu(e.content||""),i=Tu.content;if(!t.filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported)))return e.computedFormat}return}(e,t),n={};if(e.border){const i=t.borders[e.border];n.left=Tm(i.left),n.right=Tm(i.right),n.bottom=Tm(i.bottom),n.top=Tm(i.top)}const r={font:{size:(null==i?void 0:i.fontSize)||G,color:{rgb:(null==i?void 0:i.textColor)?i.textColor:"000000"},family:2,name:"Arial"},fill:(null==i?void 0:i.fillColor)?{fgColor:{rgb:i.fillColor}}:{reservedAttribute:"none"},numFmt:o?{format:o,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:i.align}};return r.font.strike=!!(null==i?void 0:i.strikethrough)||void 0,r.font.underline=!!(null==i?void 0:i.underline)||void 0,r.font.bold=!!(null==i?void 0:i.bold)||void 0,r.font.italic=!!(null==i?void 0:i.italic)||void 0,r}function Mm(e,t){const{id:i}=Nm(t.font,e.fonts),{id:o}=Nm(t.fill,e.fills),{id:n}=Nm(t.border,e.borders),r=function(e,t){if(!e)return 0;let i=nm[e.format];if(!i){const{id:o}=Nm(e,t);i=o+Lp}return i}(t.numFmt,e.numFmts),s={fontId:i,fillId:o,borderId:n,numFmtId:r,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=Nm(s,e.styles);return a}function Om(e,t,i){let o,n=e.find((e=>e.path===t));return n?(o=`rId${(n.rels.length+1).toString()}`,n.rels.push({...i,id:o})):(o="rId1",e.push({path:t,rels:[{...i,id:o}]})),o}function Nm(e,t){for(let[i,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(i,10),list:t};let i=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===i&&(t.push(e),i=t.length-1),{id:i,list:t}}const _m=[];function Fm(e){const t=_m.findIndex((t=>t===e));return-1===t?(_m.push(e),_m.length):t+1}function Dm(e){return Math.round(914400*e/96)}function km(e,t,i){let o,n,r=e;if(({xc:r,sheetName:o}=Nt(e)),o){const e=i.sheets.findIndex((e=>e.name===o));if(e<0)throw new Error("Unable to find a sheet with the name "+o);n=e}else n=Number(t);const s=wi(r);return void 0===s.right&&(s.right=i.sheets[n].colNumber),void 0===s.bottom&&(s.bottom=i.sheets[n].rowNumber),(s.right-s.left+1)*(s.bottom-s.top+1)}function $m(e){return Math.round(96*e/914400)}function Lm(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.cols.find((e=>n>=e.min&&n<=e.max));(null==e?void 0:e.width)?o+=e.width:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?o+=t.sheetFormat.defaultColWidth:o+=Fp}return o/_p}function Pm(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?o+=e.height:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?o+=t.sheetFormat.defaultRowHeight:o+=Dp}return o/Np}function Um(e){let t=1;return e.figures.map((i=>function(e,t,i){const o=Lm(e.anchors[0].col,i)+$m(e.anchors[0].colOffset),n=Lm(e.anchors[1].col,i)+$m(e.anchors[1].colOffset),r=Pm(e.anchors[0].row,i)+$m(e.anchors[0].rowOffset),s=Pm(e.anchors[1].row,i)+$m(e.anchors[1].rowOffset),a=n-o,l=s-r,c=Vm(e.data);return c?{id:t,x:o,y:r,width:a,height:l,tag:"chart",data:Vm(e.data)}:void 0}(i,(t++).toString(),e))).filter(Xe)}function Vm(e){var t;const i=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let o=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&o.reverse(),{dataSets:o,dataSetsHaveTitle:!1,labelRange:i,title:e.title||"",type:e.type,background:sm({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,labelsAsText:!1}}const zm=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),Bm=new RegExp(/SUBTOTAL\(([0-9]*),/g),Hm=new RegExp(Et.source,"ig");function Wm(e,t){const i=function(e){const t={};for(let i of e.rows)for(let e of i.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let o of e.rows.map((e=>e.cells)).flat())(null==o?void 0:o.formula)&&(o.formula.content=void 0===o.formula.sharedIndex||o.formula.content?"="+o.formula.content:"="+qm(o.xc,i[o.formula.sharedIndex]),o.formula.content=Gm(o.formula.content,t))}function Gm(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(Bm,((e,t)=>{const i=im[t];return i?i+"(":e}))).replace(zm,((e,i,o,n)=>{var r;i=Number(i)-1,n=n.replace(/\$/g,"");const s=t.externalBooks[i].sheetNames.findIndex((e=>e===o));if(-1===s)return e;const a=null===(r=t.externalBooks[i].datasets.find((e=>e.sheetId===s)))||void 0===r?void 0:r.data;if(!a)return e;const l=a&&a[n];return(Number(l)?l:`"${l}"`)||e}))}function qm(e,t){const i=Dt(t.refCellXc);let o,n=t.formula.slice();do{if(o=Hm.exec(n),o){const t=Dt(o[0].replace("$","")),r=Dt(e),s={colFixed:o[0].startsWith("$"),rowFixed:o[0].includes("$",1)},a={col:r.col-i.col,row:r.row-i.row},l={col:s.colFixed?t.col:t.col+a.col,row:s.rowFixed?t.row:t.row+a.row};n=n.slice(0,o.index)+kt(l.col,l.row,s)+n.slice(o.index+o[0].length)}}while(o);return n}function Zm(e,t){return e.sheets.map((i=>{Wm(i,e);const o=function(e){const t=[0,0];for(let i of e.rows)t[0]=Math.max(t[0],...i.cells.map((e=>Dt(e.xc).col))),t[1]=Math.max(t[1],i.index);return t[0]=Math.max(t[0],kp),t[1]=Math.max(t[1],$p),t}(i),n=i.sheetViews[0];return{id:i.sheetName,areGridLinesVisible:!n||n.showGridLines,name:i.sheetName,colNumber:o[0],rowNumber:o[1],cells:Ym(i,e,o,t),merges:i.merges,cols:jm(i,o[0]),rows:Xm(i,o[1]),conditionalFormats:Sm(i.cfs,e.dxfs,t),figures:Um(i),isVisible:i.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function jm(e,t){var i;const o={};for(let r=1;r<t+1;r++){const t=e.cols.find((e=>e.min<=r&&r<=e.max));let s;s=t&&t.width?t.width:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?e.sheetFormat.defaultColWidth:Fp,o[r-1]={size:(n=s,n?Math.round(n/_p*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Xm(e,t){var i;const o={};for(let r=1;r<t+1;r++){const t=e.rows.find((e=>e.index===r));let s;s=t&&t.height?t.height:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?e.sheetFormat.defaultRowHeight:Dp,o[r-1]={size:(n=s,n?Math.round(n/Np*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Ym(e,t,i,o){const n={},r=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const s=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let i of e.rows)for(let e of i.cells)n[e.xc]={content:Km(e,s,r,o),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let o of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=i[0];e++){const i=kt(e-1,o.index-1);let r=n[i];r||(r={},n[i]=r),r.style=r.style?r.style:o.styleIndex+1,r.border=r.border?r.border:t.styles[o.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[o.styleIndex].numFmtId+1}for(let o of e.cols.filter((e=>e.styleIndex)))for(let e=o.min;e<=Math.min(o.max,i[0]);e++)for(let r=1;r<=i[1];r++){const i=kt(e-1,r-1);let s=n[i];s||(s={},n[i]=s),s.style=s.style?s.style:o.styleIndex+1,s.border=s.border?s.border:t.styles[o.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[o.styleIndex].numFmtId+1}return n}function Km(e,t,i,o){let n;switch(e.type){case"sharedString":n=i[parseInt(e.value,10)];break;case"boolean":n=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":n=e.value}return n&&t[e.xc]&&(n=function(e,t,i){const o=e.display||t;e.relTarget||e.location||i.generateNotSupportedWarning(zp.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:Ze(Nt(e.location).sheetName);return He(o,n)}(t[e.xc],n,o)),e.formula&&(n=e.formula.content),n}const Qm={fillColor:"#000000",textColor:"#ffffff",bold:!0},Jm={bold:!0},ef=["thin","#000000FF"];function tf(e,t){for(const i of t.sheets)for(const t of i.tables){const o=e.sheets.find((e=>e.name===i.sheetName));o&&t.autoFilter&&(o.filterTables||(o.filterTables=[]),o.filterTables.push({range:t.ref}))}!function(e,t){var i,o,n,r;const s=cm(e.styles),a=cm(e.borders);for(let l of t.sheets)for(let t of l.tables){const c=e.sheets.find((e=>e.name===l.sheetName));if(!c)continue;const h=yi(t.ref);for(let e=0;e<t.headerRowCount;e++)of(Qm,{...h,bottom:h.top+e},c.cells,s);for(let e=0;e<t.totalsRowCount;e++)of(Jm,{...h,top:h.bottom-e},c.cells,s);(null===(i=t.style)||void 0===i?void 0:i.showFirstColumn)&&of(Jm,{...h,right:h.left},c.cells,s),(null===(o=t.style)||void 0===o?void 0:o.showLastColumn)&&of(Jm,{...h,left:h.right},c.cells,s);for(let e=h.left;e<=h.right;e++)for(let i=h.top;i<=h.bottom;i++){const o=kt(e,i),s=c.cells[o],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?ef:void 0,right:e===h.right?ef:void 0,top:i===h.top||(null===(r=t.style)||void 0===r?void 0:r.showRowStripes)||i>h.bottom-t.totalsRowCount?ef:void 0,bottom:i===h.bottom?ef:void 0},d=(null==s?void 0:s.border)?{...a[s.border],...l}:l;let u=a.findIndex((e=>nt(e,d)));-1===u&&(u=a.length,a.push(d)),s?s.border=u:c.cells[o]={border:u}}}e.styles=lm(s),e.borders=lm(a)}(e,t),function(e,t){for(let i of e){const e=t.find((e=>e.sheetName===i.name)).tables;for(let t of e){const e=t.name+"[";for(let o of Vi(yi(t.ref))){const n=kt(o.col,o.row),r=i.cells[n];if(r&&r.content&&r.content.startsWith("=")){let i;for(;-1!==(i=r.content.indexOf(e));){let o=r.content.slice(i+e.length),s=o.indexOf("]");o.startsWith("[")&&(s=o.indexOf("]",s+1),s=o.indexOf("]",s+1)),o=o.slice(0,s);const a=nf(o,t,n);r.content=r.content.slice(0,i)+a+r.content.slice(e.length+i+s+1)}}}}}}(e.sheets,t.sheets)}function of(e,t,i,o){for(let n=t.left;n<=t.right;n++)for(let r=t.top;r<=t.bottom;r++){const t=kt(n,r),s=i[t],a=(null==s?void 0:s.style)?{...o[s.style],...e}:e;let l=o.findIndex((e=>nt(e,a)));-1===l&&(l=o.length,o.push(a)),s?s.style=l:i[t]={style:l}}}function nf(e,t,i){const o=e.split(","),n=yi(t.ref),r={...n};let s=!0;if(1===o.length){const e=t.cols.findIndex((e=>e.name===o[0]));r.left=r.right=e+n.left,t.headerRowCount&&(r.top+=t.headerRowCount),t.totalsRowCount&&(r.bottom-=1)}else{switch(o[0].slice(1,o[0].length-1)){case"#All":r.top=t.headerRowCount?n.top+t.headerRowCount:n.top,r.bottom=n.bottom;break;case"#Data":r.top=t.headerRowCount?n.top+t.headerRowCount:n.top,r.bottom=t.totalsRowCount?n.bottom+1:n.bottom;break;case"#This Row":r.top=r.bottom=Dt(i).row;break;case"#Headers":r.top=r.bottom=n.top,t.headerRowCount||(s=!1);break;case"#Totals":r.top=r.bottom=n.bottom,t.totalsRowCount||(s=!1)}const e=o[1].slice(1,o[1].length-1),a=t.cols.findIndex((t=>t.name===e));r.left=r.right=a+n.left}return s?r.top!==r.bottom?Ri(r):kt(r.left,r.top):Y}function rf(e,t,i){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:i}}function sf(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;")}function af(e){return new Ep(e.map((([e,t])=>`${e}="${sf(t)}"`)).join(" "))}function lf(e){const t=(new DOMParser).parseFromString(e.toString(),"text/xml"),i=t.querySelector("parsererror");if(i){const t=i.innerHTML,o=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),r=n.slice(Math.max(o-3,0),Math.min(o+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${r}`)}return t}function cf(e,t){return df`
1389
+ />`,lp.defaultProps={position:{top:0}};const cp={ROW:Dn,COL:Fn,CELL:_n};class hp extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=M,this.HEADER_WIDTH=N,this.keyDownMapping={ENTER:()=>{const e=this.env.model.getters.getActiveCell();!e||e.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{const e=this.env.model.getters.getActiveCell();!e||e.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+S":()=>{var e,t;null===(t=(e=this.props).onSaveRequested)||void 0===t||t.call(e)},"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"ALT+=":()=>{var e;const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,i,o.cell);if(this.env.model.getters.isSingleCellOrMerge(t,i)||this.env.model.getters.isEmpty(t,i)&&n.length<=1){const i=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",o=`=SUM(${i})`;this.props.onGridComposerCellFocused(o,{start:5,end:5+i.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.env.model.getters.getNextVisibleCellPosition(e,0,0);this.env.model.selection.selectCell(t,i)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),i=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,i)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},i=this.env.model.getters.getPosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},i=this.env.model.getters.getPosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP")}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=To(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),ep("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=tp(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return"\n top: 26px;\n left: 48px;\n height: calc(100% - 41px);\n width: calc(100% - 63px);\n "}onClosePopover(){this.closeOpenedPopover(),this.focus()}focus(){var e;this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||null===(e=this.hiddenInput.el)||void 0===e||e.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}isAutoFillActive(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:N,gridOffsetY:M})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:Math.max(i+e,0),offsetY:Math.max(o+t,0)})}getClientPositionKey(e){var t,i,o;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(i=e.position)||void 0===i?void 0:i.col}-${null===(o=e.position)||void 0===o?void 0:o.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}onCellClicked(e,t,{ctrlKey:i,shiftKey:o}){i&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),o?this.env.model.selection.setAnchorCorner(e,t):i?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,r=t;vs(this.env,((e,t)=>{(e!==n&&-1!=e||t!==r&&-1!=t)&&(n=-1===e?n:e,r=-1===t?r:t,this.env.model.selection.setAnchorCorner(n,r))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const i=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition(i,e,t));const o=this.env.model.getters.getCell(i,e,t);!o||o.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.closeOpenedPopover();const t={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"}[e.key];e.shiftKey?this.env.model.selection.resizeAnchorZone(t,e.ctrlKey?"end":1):this.env.model.selection.moveAnchorCell(t,e.ctrlKey?"end":1),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];return i?(e.preventDefault(),e.stopPropagation(),void i()):void 0}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:i,top:o}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(i)?n="COL":this.env.model.getters.getActiveRows().has(o)&&(n="ROW");const{x:r,y:s,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(n,r+a,s+l)}onCellRightClicked(e,t,{x:i,y:o}){const n=this.env.model.getters.getSelectedZones();let r="CELL";ki(e,t,n[n.length-1])?this.env.model.getters.getActiveCols().has(e)?r="COL":this.env.model.getters.getActiveRows().has(t)&&(r="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(r,i,o)}toggleContextMenu(e,t,i){this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:i},this.menuState.menuItems=cp[e].getAll()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;if("inactive"!==this.env.model.getters.getEditionMode())return;e?jo(this.env):this.env.model.dispatch("COPY");const i=this.env.model.getters.getClipboardContent();t.clipboardData.setData("text/plain",i),t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t.types.indexOf("text/plain")>-1){const e=t.getData("text/plain"),i=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardContent()===e?Jo(this.env,i):en(this.env,i,e)}}closeMenu(){this.menuState.isOpen=!1,this.focus()}}hp.template="o-spreadsheet-Grid",hp.components={GridComposer:Vg,GridOverlay:jg,GridPopover:Xg,HeadersOverlay:Jg,Menu:Oo,Autofill:bs,ClientTag:Cs,Highlight:np,Popover:Ao,VerticalScrollBar:lp,HorizontalScrollBar:ap,FilterIconsOverlay:Wg};class dp{constructor(e,t,i){this.id=e,this.style=i.style,this.format=i.format,this.lazyEvaluated=t.map((e=>({...e,format:i.format||e.format})))}isFormula(){return!1}isLink(){return!1}isEmpty(){return!1}get evaluated(){return this.lazyEvaluated()}get formattedValue(){return qt(this.evaluated.value,this.evaluated.format)}get composerContent(){return this.content}get defaultAlign(){switch(this.evaluated.type){case eo.number:case eo.empty:return"right";case eo.boolean:case eo.error:return"center";case eo.text:return"left"}}get isAutoSummable(){var e;switch(this.evaluated.type){case eo.empty:case eo.text:return!0;case eo.number:return!(null===(e=this.evaluated.format)||void 0===e?void 0:e.match(X));case eo.error:case eo.boolean:return!1}}}class up extends dp{constructor(e,t={}){super(e,tt({value:"",type:eo.empty}),t),this.content=""}isEmpty(){return!0}}class gp extends dp{constructor(e,t,i={}){super(e,tt({value:t,type:eo.number}),i),this.content=qt(this.evaluated.value)}get composerContent(){var e;return(null===(e=this.format)||void 0===e?void 0:e.includes("%"))?100*this.evaluated.value+"%":super.composerContent}}class pp extends dp{constructor(e,t,i={}){super(e,tt({value:t,type:eo.boolean}),i),this.content=this.evaluated.value?"TRUE":"FALSE"}}class mp extends dp{constructor(e,t,i={}){super(e,tt({value:t,type:eo.text}),i),this.content=this.evaluated.value}}class fp extends gp{constructor(e,t,i){super(e,t,i),this.format=i.format}get composerContent(){return qt(this.evaluated.value,this.format)}}class vp extends dp{constructor(e,t,i={}){var o;const r=We(t);i={...i,style:{...i.style,textColor:(null===(o=i.style)||void 0===o?void 0:o.textColor)||R}},r.label=n(r.label),super(e,tt({value:r.label,type:eo.text}),i),this.link=r,this.content=t}isLink(){return!0}get composerContent(){return this.link.label}}class bp extends vp{constructor(e,t,i={}){super(e,t,i),this.link.url=this.withHttp(this.link.url),this.link.isExternal=!0,this.content=He(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 Sp extends vp{constructor(e,t,i={},o){super(e,t,i),this.sheetName=o,this.sheetId=je(this.link.url),this.isUrlEditable=!1}action(e){e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.model.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}get urlRepresentation(){return this.sheetName(this.sheetId)||r("Invalid sheet")}}class Cp extends dp{constructor(e,t,i,o,n){super(t,tt({value:"Loading...",type:eo.text}),n),this.buildFormulaString=e,this.compiledFormula=i,this.dependencies=o}get content(){return this.buildFormulaString(this)}isFormula(){return!0}assignEvaluation(e){this.lazyEvaluated=e.map((e=>{if(e instanceof c)return{value:e.errorType,type:eo.error,error:e};const{value:t,format:i}=e;switch(typeof t){case"number":return{value:t||0,format:i,type:eo.number};case"boolean":return{value:t,format:i,type:eo.boolean};case"string":return{value:t,format:i,type:eo.text};case"object":return{value:0,format:i,type:eo.number};default:return{value:"",type:eo.empty}}}))}}class Ep extends dp{constructor(e,t,i,o){super(e,tt({value:i.errorType,type:eo.error,error:i}),o),this.content=t}}function wp(e){return""===e?"":pi(e)?fi(e):Pe(e)?"TRUE"===e.toUpperCase():Ue(e)?me(e).value:e}Vo.add("Formula",{sequence:10,match:e=>e.startsWith("="),createCell:(e,t,i,o,n)=>{const r=bg(t),s=r.dependencies.map((e=>n.getRangeFromSheetXC(o,e)));return new Cp((e=>n.buildFormulaContent(o,e)),e,r,s,i)}}).add("Empty",{sequence:20,match:e=>""===e,createCell:(e,t,i)=>new up(e,i)}).add("NumberWithDateTimeFormat",{sequence:25,match:(e,t)=>!!t&&pi(e)&&function(e){try{return Qt(1,e),!0}catch(e){return!1}}(t),createCell:(e,t,i)=>{const o=i.format;return new fp(e,fi(t),{...i,format:o})}}).add("Number",{sequence:30,match:e=>pi(e),createCell:(e,t,i)=>(i.format||(i.format=function(e){const t=e.includes(".")?"0.00":"0",i=e.match(/[\$€]/);if(i){const o=e.match(/[\d]/),n="[$"+i.values().next().value+"]";return o.index<i.index?"#,##"+t+n:n+"#,##"+t}if(e.includes("%"))return t+"%";return}(t)),new gp(e,fi(t),i))}).add("Boolean",{sequence:40,match:e=>Pe(e),createCell:(e,t,i)=>new pp(e,"TRUE"===t.toUpperCase(),i)}).add("DateTime",{sequence:50,match:e=>Ue(e),createCell:(e,t,i)=>{const o=me(t),n=i.format||o.format;return new fp(e,o.value,{...i,format:n})}}).add("MarkdownSheetLink",{sequence:60,match:e=>qe(e),createCell:(e,t,i,o,n)=>new Sp(e,t,i,(e=>n.tryGetSheetName(e)))}).add("MarkdownLink",{sequence:70,match:e=>Be(e),createCell:(e,t,i)=>new bp(e,t,i)}).add("WebLink",{sequence:80,match:e=>{return t=e,ze.test(t);var t},createCell:(e,t,i)=>new bp(e,He(t,t),i)});class yp{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const xp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],Rp="000000",Ip={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},Tp={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",table:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",revision:"http://schemas.microsoft.com/office/spreadsheetml/2014/revision",revision3:"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3",markupCompatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006"},Ap="http://schemas.openxmlformats.org/drawingml/2006/main",Op="http://schemas.openxmlformats.org/drawingml/2006/chart",Mp={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",themes:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",pivot:"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",externalLink:"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"},Np={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",sharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",drawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"},_p="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Fp=.75,Dp=.1317,kp=8.43,$p=12.75,Lp=30,Pp=100,Up=164,Vp={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}]},zp=["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"],Bp="[Content_Types].xml";var Hp;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(Hp||(Hp={}));class Wp{constructor(){this._parsingWarnings=new Set,this._conversionWarnings=new Set}addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,i){let o=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;i&&(o+=`Only ${i.join(", ")} are currently supported.`),this._conversionWarnings.has(o)||this._conversionWarnings.add(o)}}const Gp=["thin"],qp=["general","left","center","right"],Zp=["Arial"],jp=["solid"],Xp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],Yp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},Kp={dashDot:"thin",dashDotDot:"thin",dashed:"thin",dotted:"thin",double:"thin",hair:"thin",medium:"thin",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thin",thin:"thin"},Qp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Jp={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},em={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},tm={NoIcons:void 0,"3Arrows":"arrows","3ArrowsGray":"arrows","3Symbols":"smiley","3Symbols2":"smiley","3Signs":"dots","3Flags":"dots","3TrafficLights1":"dots","3TrafficLights2":"dots","4Arrows":"arrows","4ArrowsGray":"arrows","4RedToBlack":"dots","4Rating":"smiley","4TrafficLights":"dots","5Arrows":"arrows","5ArrowsGray":"arrows","5Rating":"smiley","5Quarters":"dots","3Stars":"smiley","3Triangles":"arrows","5Boxes":"dots"},im={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},om={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},nm={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV",8:"STDEVP",9:"SUM",10:"VAR",11:"VARP",101:"AVERAGE",102:"COUNT",103:"COUNTA",104:"MAX",105:"MIN",106:"PRODUCT",107:"STDEV",108:"STDEVP",109:"SUM",110:"VAR",111:"VARP"},rm={0:"",1:"0",2:"0.00",3:"#,#00",4:"#,##0.00",9:"0%",10:"0.00%",11:void 0,12:void 0,13:void 0,14:"m/d/yyyy",15:"m/d/yyyy",16:"m/d/yyyy",17:"m/d/yyyy",18:"hh:mm:ss a",19:"hh:mm:ss a",20:"hhhh:mm:ss",21:"hhhh:mm:ss",22:"m/d/yy h:mm",37:void 0,38:void 0,39:void 0,40:void 0,45:"hhhh:mm:ss",46:"hhhh:mm:ss",47:"hhhh:mm:ss",48:void 0,49:void 0},sm={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},am={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF",16:"800000",17:"008000",18:"000080",19:"808000",20:"800080",21:"008080",22:"C0C0C0",23:"808080",24:"9999FF",25:"993366",26:"FFFFCC",27:"CCFFFF",28:"660066",29:"FF8080",30:"0066CC",31:"CCCCFF",32:"000080",33:"FF00FF",34:"FFFF00",35:"00FFFF",36:"800080",37:"800000",38:"008080",39:"0000FF",40:"00CCFF",41:"CCFFFF",42:"CCFFCC",43:"FFFF99",44:"99CCFF",45:"FF99CC",46:"CC99FF",47:"FFCC99",48:"3366FF",49:"33CCCC",50:"99CC00",51:"FFCC00",52:"FF9900",53:"FF6600",54:"666699",55:"969696",56:"003366",57:"339966",58:"003300",59:"333300",60:"993300",61:"993366",62:"333399",63:"333333",64:"000000",65:"FFFFFF"};function lm(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=Rp;else{if(!e.indexed)return;t=am[e.indexed]}var i;return t=6===(i=t).length?"#"+i+"FF":"#"+i.slice(2)+i.slice(0,2),e.tint&&(t=function(e,t){const i=St(e),o=Et(i);t<0&&(o.l=o.l*(1+t));t>0&&(o.l=o.l*(1-t)+(100-100*(1-t)));return bt(Ct(o))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function cm(e,t){const i=e.split("/"),o=t.split("/");let n="",r=0;for(let e=0;e<i.length-1;e++)i[e]===o[e]?r++:n+="../";return n+=o.slice(r).join("/"),n}function hm(e,t=0){const i={};for(let o=0;o<e.length;o++)e[o]&&(i[o+t]=e[o]);return i}function dm(e){const t=[];for(let i of Object.keys(e).map(Number))t[i]=e[i];return t}function um(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const gm=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function pm(e,t,i){var o,n,r;if(0===e)return;let s=rm[e]||(null===(o=t.find((t=>t.id===e)))||void 0===o?void 0:o.format);if(s)try{let e=s.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(n=e.match(/"/g))||void 0===n?void 0:n.length)||0;if(t/2+((null===(r=e.match(/\[/g))||void 0===r?void 0:r.length)||0)>1)throw new Error("Multiple escaped blocks in format");if(e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),e=e.replace(/\\./g,(e=>e[1])),function(e){return null!==e.match(gm)}(e)&&(e=function(e){return e=e.toLowerCase(),e=e.replace(/mmmmm|mmmm|mmm/g,"mm"),e=e.replace(/dddd|ddd/g,"dd"),e=e.replace(/am\/pm|a\/m/g,"a"),e=e.replace(/\byy\b/g,"yyyy"),e=e.replace(/hhhh/g,"hh"),e=e.replace(/\bh\b/g,"hh"),e}(e)),function(e){try{return qt(0,e),!0}catch(e){return!1}}(e))return e}catch(e){}i.generateNotSupportedWarning(Hp.NumFmtIdNotSupported,s||`nmFmtId ${e}`)}function mm(e,t){const i=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(Hp.DiagonalBorderNotSupported)}(e,t);const i={top:fm(e.top,t),bottom:fm(e.bottom,t),left:fm(e.left,t),right:fm(e.right,t)};return Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e])),i}));return hm(i,1)}function fm(e,t){if(!e)return;!function(e,t){Gp.includes(e.style)||t.generateNotSupportedWarning(Hp.BorderStyleNotSupported,e.style,Gp)}(e,t);const i=Kp[e.style];return i?[i,lm(e.color)]:void 0}function vm(e,t){return hm(e.styles.map((i=>bm({fontStyle:e.fonts[i.fontId],fillStyle:e.fills[i.fillId],alignment:i.alignment},t))),1)}function bm(e,t){var i,o,n,r,s,a,l,c,h,d,u,g;return function(e,t,i){e&&e.name&&!Zp.includes(e.name)&&i.generateNotSupportedWarning(Hp.FontNotSupported,e.name,Zp);t&&t.patternType&&!jp.includes(t.patternType)&&i.generateNotSupportedWarning(Hp.FillStyleNotSupported,t.patternType,jp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!qp.includes(e)&&t.generateNotSupportedWarning(Hp.HorizontalAlignmentNotSupported,e,qp)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(Hp.VerticalAlignmentNotSupported)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.vertical,t),{bold:null===(n=e.fontStyle)||void 0===n?void 0:n.bold,italic:null===(r=e.fontStyle)||void 0===r?void 0:r.italic,strikethrough:null===(s=e.fontStyle)||void 0===s?void 0:s.strike,underline:null===(a=e.fontStyle)||void 0===a?void 0:a.underline,align:(null===(l=e.alignment)||void 0===l?void 0:l.horizontal)?Qp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?lm(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):lm(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:lm(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:(null===(g=e.fontStyle)||void 0===g?void 0:g.size)?Cm(e.fontStyle.size):void 0}}function Sm(e,t){const i=[];for(let o of e.styles){const n=pm(o.numFmtId,e.numFmts,t);n&&(i[o.numFmtId]=n)}return hm(i,1)}function Cm(e){return Object.keys(se).map(Number).reduce(((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t))}function Em(e,t,i){const o=[];let n=1;for(let s of e){if(0===s.cfRules.length)continue;Rm(s,t,i);const e=s.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=wm(n++,s);t&&o.push(t);continue;case"iconSet":const c=ym(n++,s,i);c&&o.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Jp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Jp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(r=e.operator).slice(0,1).toUpperCase()+r.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&o.push({id:(n++).toString(),ranges:s.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:bm({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},i)}})}}var r;return o}function wm(e,t){const i=t.cfRules[0].colorScale;if(!i||i.cfvos.length!==i.colors.length||i.cfvos.length<2||i.cfvos.length>3)return;const o=[];for(let e=0;e<i.cfvos.length;e++)o.push({color:(n=lm(i.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:em[i.cfvos[e].type],value:i.cfvos[e].value});var n;const r=o[0],s=2===o.length?o[1]:o[2],a=3===o.length?o[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:r,midpoint:a,maximum:s}}}function ym(e,t,i){const o=t.cfRules[0].iconSet;if(!o)return;let n=o.cfvos,r=o.cfIcons;if(n.length<3||r&&r.length<3)return;n.length>3&&(n=[n[0],n[Math.floor(n.length/2)],n[n.length-1]]),r&&r.length>3&&(r=[r[0],r[Math.floor(r.length/2)],r[r.length-1]]);const s=[];for(let e=1;e<=2;e++){const t=em[n[e].type];if("value"===t)return;s.push({value:n[e].value||"",operator:n[e].gte?"ge":"gt",type:t})}let a={lower:r?xm(r[0].iconSet,r[0].iconId):xm(o.iconSet,0),middle:r?xm(r[1].iconSet,r[1].iconId):xm(o.iconSet,1),upper:r?xm(r[2].iconSet,r[2].iconId):xm(o.iconSet,2)};o.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(i.generateNotSupportedWarning(Hp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=ns.dots.good;break;case"middle":a[e]=ns.dots.neutral;break;case"lower":a[e]=ns.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:s[1],lowerInflectionPoint:s[0]}}}function xm(e,t){const i=tm[e];return i?0===t?ns[i].bad:1===t?ns[i].neutral:ns[i].good:""}function Rm(e,t,i){if(e.cfRules.length>1&&i.generateNotSupportedWarning(Hp.MultipleRulesCfNotSupported),Xp.includes(e.cfRules[0].type)||i.generateNotSupportedWarning(Hp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const o=t[e.cfRules[0].dxfId];o.border&&i.generateNotSupportedWarning(Hp.CfFormatBorderNotSupported),o.alignment&&i.generateNotSupportedWarning(Hp.CfFormatAlignmentNotSupported),o.numFmt&&i.generateNotSupportedWarning(Hp.CfFormatNumFmtNotSupported)}}function Im(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function Tm(e){return Math.round(Fp*e*window.devicePixelRatio*100)/100}function Am(e){return Math.round(Dp*e*100)/100}function Om(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function Mm(e,t){let i={};e.style&&(i=t.styles[e.style]);const o=function(e,t){if(e.format)return t.formats[e.format];if(e.isFormula){const t=Fu(e.content||""),i=Ou.content;if(!t.filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported)))return e.computedFormat}return}(e,t),n={};if(e.border){const i=t.borders[e.border];n.left=Om(i.left),n.right=Om(i.right),n.bottom=Om(i.bottom),n.top=Om(i.top)}const r={font:{size:(null==i?void 0:i.fontSize)||G,color:{rgb:(null==i?void 0:i.textColor)?i.textColor:"000000"},family:2,name:"Arial"},fill:(null==i?void 0:i.fillColor)?{fgColor:{rgb:i.fillColor}}:{reservedAttribute:"none"},numFmt:o?{format:o,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:i.align}};return r.font.strike=!!(null==i?void 0:i.strikethrough)||void 0,r.font.underline=!!(null==i?void 0:i.underline)||void 0,r.font.bold=!!(null==i?void 0:i.bold)||void 0,r.font.italic=!!(null==i?void 0:i.italic)||void 0,r}function Nm(e,t){const{id:i}=Fm(t.font,e.fonts),{id:o}=Fm(t.fill,e.fills),{id:n}=Fm(t.border,e.borders),r=function(e,t){if(!e)return 0;let i=sm[e.format];if(!i){const{id:o}=Fm(e,t);i=o+Up}return i}(t.numFmt,e.numFmts),s={fontId:i,fillId:o,borderId:n,numFmtId:r,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=Fm(s,e.styles);return a}function _m(e,t,i){let o,n=e.find((e=>e.path===t));return n?(o=`rId${(n.rels.length+1).toString()}`,n.rels.push({...i,id:o})):(o="rId1",e.push({path:t,rels:[{...i,id:o}]})),o}function Fm(e,t){for(let[i,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(i,10),list:t};let i=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===i&&(t.push(e),i=t.length-1),{id:i,list:t}}const Dm=[];function km(e){const t=Dm.findIndex((t=>t===e));return-1===t?(Dm.push(e),Dm.length):t+1}function $m(e){return Math.round(914400*e/96)}function Lm(e,t,i){let o,n,r=e;if(({xc:r,sheetName:o}=_t(e)),o){const e=i.sheets.findIndex((e=>e.name===o));if(e<0)throw new Error("Unable to find a sheet with the name "+o);n=e}else n=Number(t);const s=yi(r);return void 0===s.right&&(s.right=i.sheets[n].colNumber),void 0===s.bottom&&(s.bottom=i.sheets[n].rowNumber),(s.right-s.left+1)*(s.bottom-s.top+1)}function Pm(e){return Math.round(96*e/914400)}function Um(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.cols.find((e=>n>=e.min&&n<=e.max));(null==e?void 0:e.width)?o+=e.width:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?o+=t.sheetFormat.defaultColWidth:o+=kp}return o/Dp}function Vm(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?o+=e.height:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?o+=t.sheetFormat.defaultRowHeight:o+=$p}return o/Fp}function zm(e){let t=1;return e.figures.map((i=>function(e,t,i){const o=Um(e.anchors[0].col,i)+Pm(e.anchors[0].colOffset),n=Um(e.anchors[1].col,i)+Pm(e.anchors[1].colOffset),r=Vm(e.anchors[0].row,i)+Pm(e.anchors[0].rowOffset),s=Vm(e.anchors[1].row,i)+Pm(e.anchors[1].rowOffset),a=n-o,l=s-r,c=Bm(e.data);return c?{id:t,x:o,y:r,width:a,height:l,tag:"chart",data:Bm(e.data)}:void 0}(i,(t++).toString(),e))).filter(Xe)}function Bm(e){var t;const i=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let o=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&o.reverse(),{dataSets:o,dataSetsHaveTitle:!1,labelRange:i,title:e.title||"",type:e.type,background:lm({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,cumulative:e.cumulative||!1,labelsAsText:!1}}const Hm=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),Wm=new RegExp(/SUBTOTAL\(([0-9]*),/g),Gm=new RegExp(wt.source,"ig");function qm(e,t){const i=function(e){const t={};for(let i of e.rows)for(let e of i.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let o of e.rows.map((e=>e.cells)).flat())(null==o?void 0:o.formula)&&(o.formula.content=void 0===o.formula.sharedIndex||o.formula.content?"="+o.formula.content:"="+jm(o.xc,i[o.formula.sharedIndex]),o.formula.content=Zm(o.formula.content,t))}function Zm(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(Wm,((e,t)=>{const i=nm[t];return i?i+"(":e}))).replace(Hm,((e,i,o,n)=>{var r;i=Number(i)-1,n=n.replace(/\$/g,"");const s=t.externalBooks[i].sheetNames.findIndex((e=>e===o));if(-1===s)return e;const a=null===(r=t.externalBooks[i].datasets.find((e=>e.sheetId===s)))||void 0===r?void 0:r.data;if(!a)return e;const l=a&&a[n];return(Number(l)?l:`"${l}"`)||e}))}function jm(e,t){const i=kt(t.refCellXc);let o,n=t.formula.slice();do{if(o=Gm.exec(n),o){const t=kt(o[0].replace("$","")),r=kt(e),s={colFixed:o[0].startsWith("$"),rowFixed:o[0].includes("$",1)},a={col:r.col-i.col,row:r.row-i.row},l={col:s.colFixed?t.col:t.col+a.col,row:s.rowFixed?t.row:t.row+a.row};n=n.slice(0,o.index)+$t(l.col,l.row,s)+n.slice(o.index+o[0].length)}}while(o);return n}function Xm(e,t){return e.sheets.map((i=>{qm(i,e);const o=function(e){const t=[0,0];for(let i of e.rows)t[0]=Math.max(t[0],...i.cells.map((e=>kt(e.xc).col))),t[1]=Math.max(t[1],i.index);return t[0]=Math.max(t[0],Lp),t[1]=Math.max(t[1],Pp),t}(i),n=i.sheetViews[0];return{id:i.sheetName,areGridLinesVisible:!n||n.showGridLines,name:i.sheetName,colNumber:o[0],rowNumber:o[1],cells:Qm(i,e,o,t),merges:i.merges,cols:Ym(i,o[0]),rows:Km(i,o[1]),conditionalFormats:Em(i.cfs,e.dxfs,t),figures:zm(i),isVisible:i.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Ym(e,t){var i;const o={};for(let r=1;r<t+1;r++){const t=e.cols.find((e=>e.min<=r&&r<=e.max));let s;s=t&&t.width?t.width:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?e.sheetFormat.defaultColWidth:kp,o[r-1]={size:(n=s,n?Math.round(n/Dp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Km(e,t){var i;const o={};for(let r=1;r<t+1;r++){const t=e.rows.find((e=>e.index===r));let s;s=t&&t.height?t.height:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?e.sheetFormat.defaultRowHeight:$p,o[r-1]={size:(n=s,n?Math.round(n/Fp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Qm(e,t,i,o){const n={},r=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const s=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let i of e.rows)for(let e of i.cells)n[e.xc]={content:Jm(e,s,r,o),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let o of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=i[0];e++){const i=$t(e-1,o.index-1);let r=n[i];r||(r={},n[i]=r),r.style=r.style?r.style:o.styleIndex+1,r.border=r.border?r.border:t.styles[o.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[o.styleIndex].numFmtId+1}for(let o of e.cols.filter((e=>e.styleIndex)))for(let e=o.min;e<=Math.min(o.max,i[0]);e++)for(let r=1;r<=i[1];r++){const i=$t(e-1,r-1);let s=n[i];s||(s={},n[i]=s),s.style=s.style?s.style:o.styleIndex+1,s.border=s.border?s.border:t.styles[o.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[o.styleIndex].numFmtId+1}return n}function Jm(e,t,i,o){let n;switch(e.type){case"sharedString":n=i[parseInt(e.value,10)];break;case"boolean":n=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":n=e.value}return n&&t[e.xc]&&(n=function(e,t,i){const o=e.display||t;e.relTarget||e.location||i.generateNotSupportedWarning(Hp.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:Ze(_t(e.location).sheetName);return He(o,n)}(t[e.xc],n,o)),e.formula&&(n=e.formula.content),n}const ef={fillColor:"#000000",textColor:"#ffffff",bold:!0},tf={bold:!0},of=["thin","#000000FF"];function nf(e,t){for(const i of t.sheets)for(const t of i.tables){const o=e.sheets.find((e=>e.name===i.sheetName));o&&t.autoFilter&&(o.filterTables||(o.filterTables=[]),o.filterTables.push({range:t.ref}))}!function(e,t){var i,o,n,r;const s=dm(e.styles),a=dm(e.borders);for(let l of t.sheets)for(let t of l.tables){const c=e.sheets.find((e=>e.name===l.sheetName));if(!c)continue;const h=xi(t.ref);for(let e=0;e<t.headerRowCount;e++)rf(ef,{...h,bottom:h.top+e},c.cells,s);for(let e=0;e<t.totalsRowCount;e++)rf(tf,{...h,top:h.bottom-e},c.cells,s);(null===(i=t.style)||void 0===i?void 0:i.showFirstColumn)&&rf(tf,{...h,right:h.left},c.cells,s),(null===(o=t.style)||void 0===o?void 0:o.showLastColumn)&&rf(tf,{...h,left:h.right},c.cells,s);for(let e=h.left;e<=h.right;e++)for(let i=h.top;i<=h.bottom;i++){const o=$t(e,i),s=c.cells[o],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?of:void 0,right:e===h.right?of:void 0,top:i===h.top||(null===(r=t.style)||void 0===r?void 0:r.showRowStripes)||i>h.bottom-t.totalsRowCount?of:void 0,bottom:i===h.bottom?of:void 0},d=(null==s?void 0:s.border)?{...a[s.border],...l}:l;let u=a.findIndex((e=>nt(e,d)));-1===u&&(u=a.length,a.push(d)),s?s.border=u:c.cells[o]={border:u}}}e.styles=hm(s),e.borders=hm(a)}(e,t),function(e,t){for(let i of e){const e=t.find((e=>e.sheetName===i.name)).tables;for(let t of e){const e=t.name+"[";for(let o of zi(xi(t.ref))){const n=$t(o.col,o.row),r=i.cells[n];if(r&&r.content&&r.content.startsWith("=")){let i;for(;-1!==(i=r.content.indexOf(e));){let o=r.content.slice(i+e.length),s=o.indexOf("]");o.startsWith("[")&&(s=o.indexOf("]",s+1),s=o.indexOf("]",s+1)),o=o.slice(0,s);const a=sf(o,t,n);r.content=r.content.slice(0,i)+a+r.content.slice(e.length+i+s+1)}}}}}}(e.sheets,t.sheets)}function rf(e,t,i,o){for(let n=t.left;n<=t.right;n++)for(let r=t.top;r<=t.bottom;r++){const t=$t(n,r),s=i[t],a=(null==s?void 0:s.style)?{...o[s.style],...e}:e;let l=o.findIndex((e=>nt(e,a)));-1===l&&(l=o.length,o.push(a)),s?s.style=l:i[t]={style:l}}}function sf(e,t,i){const o=e.split(","),n=xi(t.ref),r={...n};let s=!0;if(1===o.length){const e=t.cols.findIndex((e=>e.name===o[0]));r.left=r.right=e+n.left,t.headerRowCount&&(r.top+=t.headerRowCount),t.totalsRowCount&&(r.bottom-=1)}else{switch(o[0].slice(1,o[0].length-1)){case"#All":r.top=t.headerRowCount?n.top+t.headerRowCount:n.top,r.bottom=n.bottom;break;case"#Data":r.top=t.headerRowCount?n.top+t.headerRowCount:n.top,r.bottom=t.totalsRowCount?n.bottom+1:n.bottom;break;case"#This Row":r.top=r.bottom=kt(i).row;break;case"#Headers":r.top=r.bottom=n.top,t.headerRowCount||(s=!1);break;case"#Totals":r.top=r.bottom=n.bottom,t.totalsRowCount||(s=!1)}const e=o[1].slice(1,o[1].length-1),a=t.cols.findIndex((t=>t.name===e));r.left=r.right=a+n.left}return s?r.top!==r.bottom?Ii(r):$t(r.left,r.top):Y}function af(e,t,i){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:i}}function lf(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;")}function cf(e){return new yp(e.map((([e,t])=>`${e}="${lf(t)}"`)).join(" "))}function hf(e){const t=(new DOMParser).parseFromString(e.toString(),"text/xml"),i=t.querySelector("parsererror");if(i){const t=i.innerHTML,o=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),r=n.slice(Math.max(o-3,0),Math.min(o+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${r}`)}return t}function df(e,t){return gf`
1389
1390
  <Override ContentType="${t}" PartName="${e}" />
1390
- `}function hf(e){return new Ep(e.join("\n"))}function df(e,...t){let i=[e[0]];for(let o=0;o<t.length;o++){const n=t[o]instanceof Ep?t[o]:sf(t[o]);i.push(n+e[o+1])}return new Ep(et(i))}function uf(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function gf(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class pf{constructor(e){this.value=e}asString(){return hm(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class mf{constructor(e,t,i){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=i,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(Xe)}mapOnElements(e,t){var i;const o=[],n=this.currentFile;let r;if(e.children){const t=null===(i=this.querySelector(e.parent,e.query))||void 0===i?void 0:i.children;r=t||[]}else r=this.querySelectorAll(e.parent,e.query);if(r)for(let e of r)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,o}catchErrorOnElement(e,t){const i=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([i,e.message].join("\n"))}extractAttr(e,t,i){const o=e.attributes[t];o||this.handleMissingValue(e,`attribute "${t}"`,i);const n=(null==o?void 0:o.value)?o.value:null==i?void 0:i.default;return void 0===n?void 0:new pf(n)}extractTextContent(e,t){var i;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===(null===(i=null==e?void 0:e.attributes["xml:space"])||void 0===i?void 0:i.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=o?n:n.trim()),n?hm(n):null==t?void 0:t.default}extractChildAttr(e,t,i,o){var n;let r;r="number"==typeof t?e.children[t]:this.querySelector(e,t),r||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,o);const s=r?null===(n=this.extractAttr(r,i,o))||void 0===n?void 0:n.asString():null==o?void 0:o.default;return void 0!==s?new pf(s):void 0}extractChildTextContent(e,t,i){if(void 0!==(null==i?void 0:i.default)&&"string"!=typeof i.default)throw new Error("extractTextContent default value should be a string");let o=this.querySelector(e,t);return o||this.handleMissingValue(e,`child <${t}>`,i),o?this.extractTextContent(o,i):null==i?void 0:i.default}handleMissingValue(e,t,i){if(null==i?void 0:i.required){if(!(null==i?void 0:i.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${i.default}`)}}extractColor(e,t,i){var o,n,r,s,a;if(!e)return i?{rgb:i}:void 0;const l=null===(o=this.extractAttr(e,"theme"))||void 0===o?void 0:o.asString();let c;if(void 0!==l){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");c=this.getThemeColor(l,t.clrScheme)}else c=null===(n=this.extractAttr(e,"rgb"))||void 0===n?void 0:n.asString();return{rgb:c,auto:null===(r=this.extractAttr(e,"auto"))||void 0===r?void 0:r.asBool(),indexed:null===(s=this.extractAttr(e,"indexed"))||void 0===s?void 0:s.asNum(),tint:null===(a=this.extractAttr(e,"tint"))||void 0===a?void 0:a.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");let t=e.target;t=t.replace("../",""),t=t.replace("./","");const i=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!i||!i.file)throw new Error("Cannot find target file");return i}querySelector(e,t){return t=this.areNamespaceIgnored?uf(t):gf(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?uf(t):gf(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}}class ff extends mf{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:yp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:yp}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class vf extends mf{constructor(e,t,i,o){super(e,t,i),this.theme=o}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var i,o,n,r,s,a,l,c,h,d,u;const g=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===g)throw new Error("Databars conditional formats are not supported.");return{type:g,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:null===(i=this.extractAttr(e,"dxfId"))||void 0===i?void 0:i.asNum(),stopIfTrue:null===(o=this.extractAttr(e,"stopIfTrue"))||void 0===o?void 0:o.asBool(),aboveAverage:null===(n=this.extractAttr(e,"aboveAverage"))||void 0===n?void 0:n.asBool(),percent:null===(r=this.extractAttr(e,"percent"))||void 0===r?void 0:r.asBool(),bottom:null===(s=this.extractAttr(e,"bottom"))||void 0===s?void 0:s.asBool(),operator:null===(a=this.extractAttr(e,"operator"))||void 0===a?void 0:a.asString(),text:null===(l=this.extractAttr(e,"text"))||void 0===l?void 0:l.asString(),timePeriod:null===(c=this.extractAttr(e,"timePeriod"))||void 0===c?void 0:c.asString(),rank:null===(h=this.extractAttr(e,"rank"))||void 0===h?void 0:h.asNum(),stdDev:null===(d=this.extractAttr(e,"stdDev"))||void 0===d?void 0:d.asNum(),equalAverage:null===(u=this.extractAttr(e,"equalAverage"))||void 0===u?void 0:u.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const i=this.querySelector(e,"colorScale");if(i)return{colors:this.mapOnElements({parent:i,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(i)}}extractCfIconSet(e){var t,i;const o=this.querySelector(e,"iconSet, x14:iconSet");if(o)return{iconSet:this.extractAttr(o,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(o,"showValue",{default:!0}).asBool(),percent:this.extractAttr(o,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(o,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(i=this.extractAttr(o,"custom"))||void 0===i?void 0:i.asBool(),cfvos:this.extractCFVos(o),cfIcons:this.extractCfIcons(o)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,i;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(i=this.extractAttr(e,"val"))||void 0===i?void 0:i.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class bf extends mf{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!tm[t])throw new Error(`Unsupported chart type ${t}`);const i=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),o=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:i,type:tm[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:em[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===o,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:cat c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=uf(e.tagName);if(wp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class Sf extends mf{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==uf(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const i=this.querySelector(t,e);if(!i)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(i,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(i,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(i,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(i,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),i=this.getTargetXmlFile(this.relationships[t]),o=new bf(i,this.xlsxFileStructure,this.warningManager).extractChart();if(!o)throw new Error("Unable to extract chart definition");return o}}class Cf extends mf{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class Ef extends mf{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,i,o,n,r;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(i=this.extractAttr(e,"showFirstColumn"))||void 0===i?void 0:i.asBool(),showLastColumn:null===(o=this.extractAttr(e,"showLastColumn"))||void 0===o?void 0:o.asBool(),showRowStripes:null===(n=this.extractAttr(e,"showRowStripes"))||void 0===n?void 0:n.asBool(),showColumnStripes:null===(r=this.extractAttr(e,"showColumnStripes"))||void 0===r?void 0:r.asBool()}}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class wf extends mf{constructor(e,t,i,o){super(e,t,i),this.theme=o}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=am(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=am(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,i=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!i)throw new Error("Cannot find corresponding workbook sheet");return i}extractConditionalFormats(){return new vf(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new Sf(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new Ef(o,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new Cf(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:Fp.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:Dp.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,i,o,n,r,s,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(i=this.extractAttr(e,"customWidth"))||void 0===i?void 0:i.asBool(),bestFit:null===(o=this.extractAttr(e,"bestFit"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),min:null===(r=this.extractAttr(e,"min",{required:!0}))||void 0===r?void 0:r.asNum(),max:null===(s=this.extractAttr(e,"max",{required:!0}))||void 0===s?void 0:s.asNum(),styleIndex:null===(a=this.extractAttr(e,"style"))||void 0===a?void 0:a.asNum()}}))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>{var t,i,o,n,r;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(i=this.extractAttr(e,"ht"))||void 0===i?void 0:i.asNum(),customHeight:null===(o=this.extractAttr(e,"customHeight"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),styleIndex:null===(r=this.extractAttr(e,"s"))||void 0===r?void 0:r.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,i,o;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(i=this.extractAttr(e,"s"))||void 0===i?void 0:i.asNum(),type:jp[null===(o=this.extractAttr(e,"t",{default:"n"}))||void 0===o?void 0:o.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,i;const o=this.querySelector(e,"f");if(o)return{content:this.extractTextContent(o),sharedIndex:null===(t=this.extractAttr(o,"si"))||void 0===t?void 0:t.asNum(),ref:null===(i=this.extractAttr(o,"ref"))||void 0===i?void 0:i.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,i,o,n;const r=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(i=this.extractAttr(e,"ref",{required:!0}))||void 0===i?void 0:i.asString(),location:null===(o=this.extractAttr(e,"location"))||void 0===o?void 0:o.asString(),display:null===(n=this.extractAttr(e,"display"))||void 0===n?void 0:n.asString(),relTarget:r?this.relationships[r].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),i={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),o=this.extractTextContent(e,{required:!0});i[t]=o}const o=[];for(let e=0;e<Object.keys(i).length;e++)i[e]?o.push(i[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),o.push(""));return o}}class yf extends mf{constructor(e,t,i){super(e.styles,e,t),this.theme=i}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,i,o,n;const r=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),s=this.extractChildAttr(e,"sz","val",{default:G.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(i=h.attributes.val)||void 0===i?void 0:i.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(o=u.attributes.val)||void 0===o?void 0:o.value),p=this.querySelector(e,"u")||void 0;return{name:r,size:s,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(n=p.attributes.val)||void 0===n?void 0:n.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const i=e.children[0];return"patternFill"===i.tagName?{patternType:null===(t=i.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(i,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(i,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(i,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,i;const o={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return o.diagonal&&(o.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),o.diagonalDown=null===(i=this.extractAttr(e,"diagonalDown"))||void 0===i?void 0:i.asBool()),o}extractSingleBorder(e,t,i){const o=this.querySelector(e,t);if(o&&o.attributes.style)return{style:this.extractAttr(o,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(o.children[0],i,"000000")}}extractAlignment(e){var t,i,o,n,r,s,a;return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"center"}).asString(),textRotation:null===(t=this.extractAttr(e,"textRotation"))||void 0===t?void 0:t.asNum(),wrapText:null===(i=this.extractAttr(e,"wrapText"))||void 0===i?void 0:i.asBool(),indent:null===(o=this.extractAttr(e,"indent"))||void 0===o?void 0:o.asNum(),relativeIndent:null===(n=this.extractAttr(e,"relativeIndent"))||void 0===n?void 0:n.asNum(),justifyLastLine:null===(r=this.extractAttr(e,"justifyLastLine"))||void 0===r?void 0:r.asBool(),shrinkToFit:null===(s=this.extractAttr(e,"shrinkToFit"))||void 0===s?void 0:s.asBool(),readingOrder:null===(a=this.extractAttr(e,"readingOrder"))||void 0===a?void 0:a.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),i=this.querySelector(e,"fill"),o=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),r=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:i?this.extractFill(i):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:r?this.extractAlignment(r):void 0,border:o?this.extractBorder(o):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class xf extends mf{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),i={};for(let e of t)i[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:i}}))}}function Rf(e,t){const i=function(e,t){const i=t[Vp],o=i.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of o){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const i=[];for(let o of e){const e=If(o,t);i.push({file:{fileName:o,xml:t[o]},rels:e?{fileName:e,xml:t[e]}:void 0})}return i}(i,t)}function If(e,t){if(e===Vp)return"_rels/.rels";let i="";const o=e.split("/");for(let e=0;e<o.length-1;e++)i+=o[e]+"/";return i+="_rels/",i+=o[o.length-1]+".rels",t[i]||(i=void 0),i}class Tf{constructor(e){this.warningManager=new Bp,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=lf(new Ep(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new ff(e.theme,e,this.warningManager).getTheme():void 0,i=e.sharedStrings?new ff(e.sharedStrings,e,this.warningManager).getSharedStrings():[],o=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((i=>new wf(i,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new xf(t,e,this.warningManager).getExternalBook())),r=new yf(e,this.warningManager,t);return{fonts:r.getFonts(),fills:r.getFills(),borders:r.getBorders(),dxfs:r.getDxfs(),numFmts:r.getNumFormats(),styles:r.getStyles(),sheets:o,sharedStrings:i,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:Rf(Ap.sheet,this.xmls),workbook:Rf(Ap.workbook,this.xmls)[0],styles:Rf(Ap.styles,this.xmls)[0],sharedStrings:Rf(Ap.sharedStrings,this.xmls)[0],theme:Rf(Ap.themes,this.xmls)[0],charts:Rf(Ap.chart,this.xmls),figures:Rf(Ap.drawing,this.xmls),tables:Rf(Ap.table,this.xmls),pivots:Rf(Ap.pivot,this.xmls),externalLinks:Rf(Ap.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(r("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Zm(e,this.warningManager),styles:mm(e,this.warningManager),formats:vm(e,this.warningManager),borders:gm(e,this.warningManager),entities:{},revisionId:K};return tf(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=rt(e.styles[t])})),t}}function Af(e){const t=hg(e);let i=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Et.test(e.value)){const t=e.value.trim();return i.includes(t)||i.push(t),`${ie}${i.indexOf(t)}${ie}`}return e.value}))),dependencies:i}}const Mf=12,Of="Sheet1";function Nf(e,t){if(!e)return $f();if(e["[Content_Types].xml"]){const i=new Tf(e);if(e=i.convertXlsx(),t)for(let e of i.warningManager.warnings.sort())console.warn(e)}return"version"in(e=Te(e))&&e.version<Mf&&(e=function(e){for(let t=_f.findIndex((t=>t.from===e.version));t<_f.length;t++)e=_f[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,i=new Ei;for(const o of e.sheets||[])for(const e of o.figures||[])t.has(e.id)&&(e.id+=i.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign($f(),e,{version:Mf}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(kf(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(kf(Of,"Sheet1"));return e}(e),e}(e),e}const _f=[{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 i=t.cells[e];i.content&&i.content.startsWith("=")&&(i.formula=Af(i.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:i,...o}=t.figures[e].data,n=[];for(let e of i)if(e.labelCell){const t=yi(e.dataRange),i=e.labelCell+":"+kt(t.right,t.bottom);n.push(i)}else n.push(e.dataRange);o.dataSetsHaveTitle=Boolean(i[0].labelCell),o.dataSets=n,t.figures[e].data=o}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const i=[],o=new RegExp(te,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,r=e.replace(o,"_");let s=1,a=r;for(;i.includes(a);)a=`${r}${s}`,s++;n.name=a,i.push(a);const l=t=>{if(void 0===t)return t;let i=t.replace(e,a),o=t;for(;o!==i;)o=i,i=o.replace(e,a);return o};for(let e in n.cells){const t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of n.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),i=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:i}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const i of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[i])||void 0===t?void 0:t.type)&&(e.rule[i].value=l(e.rule[i].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const i=t.cells[e];if(i.formula){let{text:e,dependencies:t}=i.formula;for(let[i,o]of Object.entries(t)){const t=`\\${ie}${i}\\${ie}`;e=e.replace(new RegExp(t,"g"),o)}i.content=e,delete i.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let i of e.sheets||[])for(let e in i.cells||[]){const o=i.cells[e];o.format&&(o.format=Qe(o.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}];function Ff(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const i=[],o=[],n=e=>{if("CREATE_SHEET"===e.type)i.push(e.sheetId);else if("sheetId"in e&&!i.includes(e.sheetId))return{...e,sheetId:Of};return e};for(const e of t)"REMOTE_REVISION"===e.type?o.push({...e,commands:e.commands.map(n)}):o.push(e);return o}(e,t),t=Df(t,"SORT_CELLS"),t=function(e,t){var i;const o=[],n={};for(const t of e.sheets||[])null===(i=t.figures)||void 0===i||i.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const i of e.commands){let e=i;switch(i.type){case"CREATE_CHART":n[i.id]=i.definition;break;case"UPDATE_CHART":if(!n[i.id]){console.log(`Fix chart definition: chart with id ${i.id} not found.`);continue}const t={...n[i.id],...i.definition};e={...i,definition:t},n[i.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=Df(t,"SET_DECIMAL")),t}function Df(e,t){const i=[];for(const o of e)"REMOTE_REVISION"===o.type?i.push({...o,commands:o.commands.filter((e=>e.type!==t))}):i.push(o);return i}function kf(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function $f(e="Sheet1"){return{version:Mf,sheets:[kf(Of,e)],entities:{},styles:{},formats:{},borders:{},revisionId:K,uniqueFigureIds:!0}}function Lf(e,t){return{...kf(e,t),charts:[]}}class Pf extends Eg{constructor(e,t,i,o,n,r){super(t,o,n),this.dispatch=o,this.range=i,i.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=r}import(e){}export(e){}adaptRanges(e,t){}}class Uf extends Pf{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const i=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,i)}break;case"DELETE_SHEET":const i={...this.borders};delete i[e.sheetId],this.history.update("borders",i);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,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){let t,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,i)}handleAddRows(e){let t,i;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,i)}getCellBorder(e,t,i){var o,n,r,s,a,l,c,h,d,u,g,p;const m={top:null===(r=null===(n=null===(o=this.borders[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===r?void 0:r.horizontal,bottom:null===(l=null===(a=null===(s=this.borders[e])||void 0===s?void 0:s[t])||void 0===a?void 0:a[i+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[i])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[i])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,i){const o=ke(t+1,i);for(let n=0;n<this.getters.getNumberRows(e);n++){const r=this.getCellBorder(e,t,n),s=this.getCellBorder(e,i,n);if(r&&s){const t=this.getCommonSides(r,s);for(let i of o)this.addBorder(e,i,n,t)}}}ensureRowBorderContinuity(e,t,i){const o=ke(t+1,i);for(let n=0;n<this.getters.getNumberCols(e);n++){const r=this.getCellBorder(e,n,t),s=this.getCellBorder(e,n,i);if(r&&s){const t=this.getCommonSides(r,s);for(let i of o)this.addBorder(e,n,i,t)}}}getCommonSides(e,t){const i={};for(let o of["top","bottom","left","right"])e[o]&&e[o]===t[o]&&(i[o]=e[o]);return i}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?ke(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,i,{moveFirstLeftBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfColumn(e,t,i,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfColumn(e,n,i,"vertical"),this.moveBordersOfColumn(e,n,i,"horizontal")})))}shiftBordersVertically(e,t,i,{moveFirstTopBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfRow(e,t,i,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfRow(e,n,i,"horizontal"),this.moveBordersOfRow(e,n,i,"vertical")})))}moveBordersOfRow(e,t,i,o,{destructive:n}={destructive:!0}){const r=this.borders[e];r&&this.getColumnsWithBorders(e).forEach((s=>{var a,l,c,h;const d=null===(l=null===(a=r[s])||void 0===a?void 0:a[t+i])||void 0===l?void 0:l[o],u=null===(h=null===(c=r[s])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o];this.history.update("borders",e,s,t+i,o,n?u:u||d),this.history.update("borders",e,s,t,o,void 0)}))}moveBordersOfColumn(e,t,i,o,{destructive:n}={destructive:!0}){const r=this.borders[e];r&&this.getRowsRange(e).forEach((s=>{var a,l,c,h;const d=null===(l=null===(a=r[t+i])||void 0===a?void 0:a[s])||void 0===l?void 0:l[o],u=null===(h=null===(c=r[t])||void 0===c?void 0:c[s])||void 0===h?void 0:h[o];this.history.update("borders",e,t+i,s,o,n?u:u||d),this.history.update("borders",e,t,s,o,void 0)}))}setBorder(e,t,i,o,n=!0){var r,s,a,l,c,h,d,u,g,p,m,f,v,b,S,C;!n&&(null===(l=null===(a=null===(s=null===(r=this.borders)||void 0===r?void 0:r[e])||void 0===s?void 0:s[t])||void 0===a?void 0:a[i])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,i,"vertical",null==o?void 0:o.left),!n&&(null===(u=null===(d=null===(h=null===(c=this.borders)||void 0===c?void 0:c[e])||void 0===h?void 0:h[t])||void 0===d?void 0:d[i])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,i,"horizontal",null==o?void 0:o.top),!n&&(null===(f=null===(m=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===m?void 0:m[i])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,i,"vertical",null==o?void 0:o.right),!n&&(null===(C=null===(S=null===(b=null===(v=this.borders)||void 0===v?void 0:v[e])||void 0===b?void 0:b[t])||void 0===S?void 0:S[i+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,i+1,"horizontal",null==o?void 0:o.bottom)}clearBorders(e,t){for(let i of t){for(let t=i.top;t<=i.bottom;t++){this.history.update("borders",e,i.right+1,t,"vertical",void 0);for(let o=i.left;o<=i.right;o++)this.history.update("borders",e,o,t,void 0)}for(let t=i.left;t<=i.right;t++)this.history.update("borders",e,t,i.bottom+1,"horizontal",void 0)}}addBorder(e,t,i,o){this.setBorder(e,t,i,{...this.getCellBorder(e,t,i),...o})}setBorders(e,t,i){if("clear"===i)return this.clearBorders(e,t);for(let o of t){if("h"===i||"hv"===i||"all"===i)for(let t=o.top+1;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++)this.addBorder(e,i,t,{top:Z});if("v"===i||"hv"===i||"all"===i)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left+1;i<=o.right;i++)this.addBorder(e,i,t,{left:Z});if("left"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.left,t,{left:Z});if("right"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.right+1,t,{left:Z});if("top"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.top,{top:Z});if("bottom"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.bottom+1,{top:Z})}}addBordersToMerge(e,t){const{left:i,right:o,top:n,bottom:r}=t,s=this.getCellBorder(e,i,n),a=this.getCellBorder(e,o,r);this.clearBorders(e,[t]),(null==s?void 0:s.top)&&this.setBorders(e,[{...t,bottom:n}],"top"),(null==s?void 0:s.left)&&this.setBorders(e,[{...t,right:i}],"left"),((null==a?void 0:a.bottom)||(null==s?void 0:s.bottom))&&this.setBorders(e,[{...t,top:r}],"bottom"),((null==a?void 0:a.right)||(null==s?void 0:s.right))&&this.setBorders(e,[{...t,left:o}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[i,o]of Object.entries(t.cells))if(null==o?void 0:o.border){const n=e.borders[o.border],{col:r,row:s}=Dt(i);this.setBorder(t.id,r,s,n,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,yi(e))}export(e){let t=0;const i={};function o(e){for(let[t,o]of Object.entries(i))if(xe(o)===xe(e))return parseInt(t,10);return i[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let i=0;i<t.rowNumber;i++){const n=this.getCellBorder(t.id,e,i);if(n){const r=kt(e,i),s=t.cells[r],a=o(n);s?s.border=a:t.cells[r]={border:a}}}e.borders=i}exportForExcel(e){this.export(e)}}Uf.getters=["getCellBorder"];const Vf=new RegExp(String.fromCharCode(160),"g");class zf extends Pf{constructor(){super(...arguments),this.cells={},this.createCell=function(e){const t=Uo.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i,o,n,r){const s=t.find((e=>e.match(o,n.format)));if(!s)return new gp(i,o,n);try{return s.createCell(i,o,n,r,e)}catch(e){return new Sp(i,o,e instanceof c?e:new h(e.message||oe),n)}}}(this.getters)}adaptRanges(e,t){for(const i of Object.keys(this.cells))for(const o of Object.values(this.cells[i]||{}))if(o.isFormula())for(const n of o.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",i,o.id,"dependencies",o.dependencies.indexOf(n),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,i){for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:i})}clearFormatting(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:null,format:""})}handleAddColumnsRows(e,t){let i,o;"before"===e.position?(i=ke(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=ke(e.base+1,e.base+e.quantity+1),o=e.base),t(e.sheetId,o,i)}import(e){for(let t of e.sheets)for(let i in t.cells){const o=t.cells[i],{col:n,row:r}=Dt(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(t.id,o,e.styles,e.formats);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cellId:i.id,col:n,row:r,sheetId:t.id})}}}export(e){const t={},i={};for(let o of e.sheets){const e={},n=Object.keys(this.cells[o.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:r,row:s}of n){const n=this.getters.getCell(o.id,r,s);e[kt(r,s)]={style:n.style?Qe(n.style,t):void 0,format:n.format?Qe(n.format,i):void 0,content:n.content||void 0}}o.cells=e}e.styles=t,e.formats=i}importCell(e,t,i,o){const n=t.style&&i[t.style]||void 0,r=t.format&&o[t.format]||void 0,s=this.uuidGenerator.uuidv4(),a={format:r,style:n};return this.createCell(s,(null==t?void 0:t.content)||"",a,e)}exportForExcel(e){this.export(e);for(let t of e.sheets)for(const e in t.cells){const{col:i,row:o}=Dt(e),n=this.getters.getCell(t.id,i,o),r=t.cells[e];r.value=n.evaluated.value,r.isFormula=n.isFormula(),n.format!==n.evaluated.format&&(r.computedFormat=n.evaluated.format)}}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const i=this.cells[t][e];if(i)return i}}buildFormulaContent(e,t,i){const o=i||[...t.dependencies];return et(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=o.shift();return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){return e&&e.style||{}}zoneToXC(e,t,i=[{colFixed:!1,rowFixed:!1}]){const o=kt((t=this.getters.expandZone(e,t)).left,t.top,i[0]),n=kt(t.right,t.bottom,i.length>1?i[1]:i[0]),r=this.getters.getMainCellPosition(e,t.left,t.top),s=this.getters.getMainCellPosition(e,t.right,t.bottom),a=r.col===s.col&&r.row===s.row;return o==n||a?o:o+":"+n}setStyle(e,t,i){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){const o=this.getters.getCell(e,t,n);this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:i?{...null==o?void 0:o.style,...i}:void 0})}}copyColumnStyle(e,t,i){for(let o=0;o<this.getters.getNumberRows(e);o++){const n=this.getFormat(e,t,o);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,...n})}}copyRowStyle(e,t,i){for(let o=0;o<this.getters.getNumberCols(e);o++){const n=this.getFormat(e,o,t);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,...n})}}getFormat(e,t,i){const o={},{col:n,row:r}=this.getters.getMainCellPosition(e,t,i),s=this.getters.getCell(e,n,r);return s&&(s.style&&(o.style=s.style),s.format&&(o.format=s.format)),o}updateCell(e,t,i,o){var n;const r=this.getters.getCell(e,t,i),s="content"in o||"formula"in o,a=s?(null===(n=o.content)||void 0===n?void 0:n.replace(Vf,""))||"":(null==r?void 0:r.content)||"";let l;l=void 0!==o.style?o.style||void 0:r?r.style:void 0;let c=("format"in o?o.format:r&&r.format)||undefined;if((s&&!a&&!o.formula||!s&&(!r||r.isEmpty()))&&!l&&!c)return void(r&&(this.history.update("cells",e,r.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:i,sheetId:e})));const h=(null==r?void 0:r.id)||this.uuidGenerator.uuidv4(),d=s,u={format:c,style:l},g=this.createCell(h,a,u,e);r&&!d&&g.isFormula()&&g.assignEvaluation(tt(r.evaluated)),this.history.update("cells",e,g.id,g),this.dispatch("UPDATE_CELL_POSITION",{cellId:g.id,col:t,row:i,sheetId:e})}checkCellOutOfSheet(e,t,i){if(!this.getters.tryGetSheet(e))return 27;return Di(t,i,this.getters.getSheetZone(e))?0:18}}zf.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Bf extends Pf{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=Xi.getAll();return function(i,o,n){const r=t.find((e=>e.match(o.type)));if(!r)throw new Error(`No builder for this chart: ${o.type}`);return r.createChart(o,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const i=Xi.getAll().find((e=>e.match(t.type)));if(!i)throw new Error("Unknown chart type.");return i.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,i]of Object.entries(this.charts))this.history.update("charts",t,null==i?void 0:i.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const i=this.getters.getFigures(e.sheetId);for(const o of i)if("chart"===o.tag){const i=o.id.split("??").pop(),n=`${e.sheetIdTo}??${i}`,r=null===(t=this.charts[o.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);r&&this.dispatch("CREATE_CHART",{id:n,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:r.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){var t;return null===(t=this.charts[e])||void 0===t?void 0:t.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!i)throw new Error("Chart not defined.");return i}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!i)throw new Error(`There is no chart with the given figureId: ${e}`);return i}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();i&&(e.data=i,o.push(e))}else o.push(e)}i.figures=o}}exportForExcel(e){var t;for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e)if(i&&"chart"===i.tag){const e=null===(t=this.charts[i.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&o.push({...i,data:e})}i.charts=o}}addFigure(e,t,i={x:0,y:0},o={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const i=this.getters.getFigureSheetId(e);i&&this.history.update("charts",e,this.createChart(e,t,i))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?83:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:84}}function Hf(e){return""===e?NaN:Number(e)}Bf.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class Wf extends Pf{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const i of this.cfRules[e])for(const o of i.ranges){const n=t(o);switch(n.changeType){case"REMOVE":let t=i.ranges.slice();t.splice(i.ranges.indexOf(o),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",t):this.removeConditionalFormatting(i.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",i.ranges.indexOf(o),n.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const i={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(i,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const i=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{i.add(e)}))})),Array.from(i)}getRulesByZone(e,t){const i=new Set;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,o).forEach((e=>{i.add(e.id)}))}return i}getRulesByCell(e,t,i){const o=[];for(let n of this.cfRules[e])for(let e of n.ranges)Di(t,i,e.zone)&&o.push(n);return new Set(o.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 i={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return i}addConditionalFormatting(e,t){const i=this.cfRules[t].slice(),o=i.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);o>-1?i.splice(o,1,n):i.push(n),this.history.update("cfRules",t,i)}checkValidReordering(e,t,i){if(!this.cfRules[i])return 27;const o=this.cfRules[i].findIndex((t=>t.id===e));if(-1===o)return 70;const n="up"===t?o-1:o+1;return n<0||n>=this.cfRules[i].length?70:0}checkEmptyRange(e){return e.ranges.length?0:24}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 i=>{if(t.includes(i.operator)){const t=[],o=e=>void 0===e||""===e;return e>=1&&o(i.values[0])&&t.push(50),e>=2&&o(i.values[1])&&t.push(51),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 52;case"max":return 54;case"mid":return 53;case"upperInflectionPoint":return 55;case"lowerInflectionPoint":return 56}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{fg(e.value||"")}catch(e){switch(t){case"min":return 57;case"max":return 59;case"mid":return 58;case"upperInflectionPoint":return 60;case"lowerInflectionPoint":return 61}}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,i=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(i)?47:0}checkMinBiggerThanMax(e){const t=e.minimum.value,i=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&Hf(t)>=Hf(i)?46:0}checkMidBiggerThanMax(e){var t;const i=null===(t=e.midpoint)||void 0===t?void 0:t.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&Hf(i)>=Hf(o)?48:0}checkMinBiggerThanMid(e){var t;const i=e.minimum.value,o=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&&Hf(i)>=Hf(o)?49:0}removeConditionalFormatting(e,t){const i=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==i){const e=this.cfRules[t].slice();e.splice(i,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,i){const o=this.cfRules[i].findIndex((t=>t.id===e)),n="up"===t?o-1:o+1;if(!(n<0||n>=this.cfRules[i].length)&&-1!==o&&-1!==n){const e=[...this.cfRules[i]],t=e[o];e[o]=e[n],e[n]=t,this.history.update("cfRules",i,e)}}}Wf.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Gf extends Pf{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.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:i,...o}=e,n=o;this.updateFigure(i,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[i,o]of Object.entries(t))switch(i){case"x":case"y":void 0!==o&&this.history.update("figures",e,t.id,i,Math.max(o,0));break;case"width":case"height":void 0!==o&&this.history.update("figures",e,t.id,i,o)}}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 i;return void 0===(null===(i=this.figures[e])||void 0===i?void 0:i[t])?69:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?81:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(Xe)}getFigure(e,t){var i;return null===(i=this.figures[e])||void 0===i?void 0:i[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var i;return void 0!==(null===(i=this.figures[t])||void 0===i?void 0:i[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 i=void 0;t.figures.push({...e,data:i})}}exportForExcel(e){this.export(e)}}Gf.getters=["getFigures","getFigure","getFigureSheetId"];class qf{constructor(e){this.filters=[],this.zone=e;const t=new Ei;this.id=t.uuidv4();for(const i of ke(e.left,e.right+1)){const e={...this.zone,left:i,right:i};this.filters.push(new Zf(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){var t;return null===(t=this.filters.find((t=>t.col===e)))||void 0===t?void 0:t.id}clone(){return new qf(this.zone)}}class Zf{constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}class jf extends Pf{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!Zi(...e.target))return 80;const t=Oi(...e.target),i=()=>this.getFilterTables(e.sheetId).some((e=>Fi(e.zone,t)))?77:0,o=()=>{const i=this.getters.getMergesInZone(e.sheetId,t);for(let e of i)if(Fi(t,e))return 79;return 0};return this.checkValidations(e,i,o);case"ADD_MERGE":for(let t of e.target)for(let i of this.getFilterTables(e.sheetId))if(Fi(i.zone,t))return 79}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":const i={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=Te(t);i[e.id]=e}this.history.update("tables",e.sheetIdTo,i);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=Oi(...e.target),i=this.createFilterTable(t);this.history.update("tables",e.sheetId,i.id,i);break}case"REMOVE_FILTER_TABLE":{const t={};for(const i of this.getFilterTables(e.sheetId))e.target.every((e=>!Ni(e,i.zone)))&&(t[i.id]=i);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let i of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,i)&&this.extendTableDown(t,i);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(Xe):[]}getFilter(e,t,i){var o;return null===(o=this.getFilterTable(e,t,i))||void 0===o?void 0:o.filters.find((e=>e.col===t))}getFilterId(e,t,i){var o;return null===(o=this.getFilter(e,t,i))||void 0===o?void 0:o.id}getFilterTable(e,t,i){return this.getFilterTables(e).find((e=>Di(t,i,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>ki(e.zone,t)))}doesZonesContainFilter(e,t){for(const i of t)for(const t of this.getFilterTables(e))if(Ni(i,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Ii(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o=[];for(const i of t.filters){const t=Ii(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);o.push(new Zf(i.id,t))}if(o.length<Pi(i).width){for(let e=i.left;e<=i.right;e++)o.find((t=>t.col===e))||o.push(new Zf(this.uuidGenerator.uuidv4(),{...i,left:e,right:e}));o.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Mi(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(i){if(Ri(i)!==Ri(t.zone)){const o=[];for(const i of t.filters){const t=Mi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&o.push(new Zf(i.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}else{const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i)}}}createFilterTable(e){return new qf(e)}extendTableDown(e,t){const i={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",i);for(let i=0;i<t.filters.length;i++){const o=t.filters[i],n={...o.zoneWithHeaders,bottom:o.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",i,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:i,row:o},n){var r;if(!e)return;const s=n.zone;if(!(s.bottom+1===o&&i>=s.left&&i<=s.right))return!1;for(const e of ke(s.left,s.right+1)){if(null===(r=this.getters.getCell(t,e,o))||void 0===r?void 0:r.content)return!1;if(this.getters.getFilter(t,e,o))return!1;if(this.getters.isInMerge(t,e,o))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const i=this.createFilterTable(yi(e.range));this.history.update("tables",t.id,i.id,i)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:Ri(e.zone)})}exportForExcel(e){this.export(e)}}jf.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Xf extends Pf{constructor(){super(...arguments),this.sizes={}}handle(e){var t,i;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),i={COL:t.COL.map((e=>({manualSize:void 0,computedSize:tt(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:tt(e)})))};this.history.update("sizes",e.sheetId,i);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Te(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const o={...this.sizes};delete o[e.sheetId],this.history.update("sizes",o);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);const i=Math.min(...e.elements);t=t.map(((t,o)=>"ROW"===e.dimension&&o>=i?{manualSize:t.manualSize,computedSize:tt((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const i=ot(e.position,e.base),o=t[e.base];t.splice(i,0,...Array(e.quantity).fill(o)),t=t.map(((t,i)=>"ROW"===e.dimension&&i>e.base+e.quantity?{manualSize:t.manualSize,computedSize:tt((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const i=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:tt(i)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:tt(e.size||_)});break;case"UPDATE_CELL":const n=null===(i=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[e.row];if(n&&!n.manualSize){const{sheetId:t,row:i}=e;this.history.update("sizes",t,"ROW",i,"computedSize",tt((()=>this.getRowTallestCellSize(t,i))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let i of ke(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,i);t!==this.getRowSize(e.sheetId,i)&&this.history.update("sizes",e.sheetId,"ROW",i,"computedSize",tt(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,i){var o,n,r,s;return Math.round((null===(n=null===(o=this.sizes[e])||void 0===o?void 0:o[t][i])||void 0===n?void 0:n.manualSize)||(null===(s=null===(r=this.sizes[e])||void 0===r?void 0:r[t][i])||void 0===s?void 0:s.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,i;const o={COL:[],ROW:[]};for(let t of ke(0,this.getters.getNumberCols(e)))o.COL.push(this.getHeaderSize(e,"COL",t));for(let n of ke(0,this.getters.getNumberRows(e))){let r=null===(i=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[n].manualSize;if(!r){r=this.getRowTallestCellSize(e,n)}o.ROW.push(r)}return o}getDefaultHeaderSize(e){return"COL"===e?_:F}getCellHeight(e,t,i){const o=this.getters.getMerge(e,t,i);if(o&&o.bottom!==o.top)return F;const n=this.getters.getCell(e,t,i);return(null==(r=null==n?void 0:n.style)?void 0:r.fontSize)?(s||1)*(De(r)+P)-P+2*U:F;var r,s}getRowTallestCellSize(e,t){const i=this.getters.getRowCells(e,t);let o=0;for(let t=0;t<i.length;t++){const n=this.getters.getCellById(i[t]);if(!n)continue;const{col:r,row:s}=this.getters.getCellPosition(n.id),a=this.getCellHeight(e,r,s);a>o&&a>F&&(o=a)}return o<=F?F:o}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[i,o]of Object.entries(t.rows))o.size&&(e.ROW[i]=o.size);for(let[i,o]of Object.entries(t.cols))o.size&&(e.COL[i]=o.size);const i=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:i.COL.map(((t,i)=>({manualSize:e.COL[i],computedSize:tt(t)}))),ROW:i.ROW.map(((t,i)=>({manualSize:e.ROW[i],computedSize:tt(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var i,o;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of ke(0,this.getters.getNumberRows(n.id)))(t||(null===(i=this.sizes[n.id].ROW[e])||void 0===i?void 0:i.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of ke(0,this.getters.getNumberCols(n.id)))(t||(null===(o=this.sizes[n.id].COL[e])||void 0===o?void 0:o.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}Xf.getters=["getRowSize","getColSize"];class Yf extends Pf{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),i="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=i?65:Math.min(...e.elements)<0||Math.max(...e.elements)>i?85:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.canRemoveHeaders(e.sheetId,e.dimension,e.elements)?0:8:27}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,Te(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],i=ot(e.position,e.base);t.splice(i,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}canRemoveHeaders(e,t,i){const o=this.getAllVisibleHeaders(e,t);return n=i,!o.every((e=>n.includes(e)));var n}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],i=this.hiddenHeaders[e].COL;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],i=this.hiddenHeaders[e].ROW;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getAllVisibleHeaders(e,t){return ke(0,this.hiddenHeaders[e][t].length).filter((i=>!this.hiddenHeaders[e][t][i]))}import(e){var t,i;for(let o of e.sheets){this.hiddenHeaders[o.id]={COL:[],ROW:[]};for(let e=0;e<o.rowNumber;e++)this.hiddenHeaders[o.id].ROW[e]=Boolean(null===(t=o.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<o.colNumber;e++)this.hiddenHeaders[o.id].COL[e]=Boolean(null===(i=o.cols[e])||void 0===i?void 0:i.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e=0;e<this.getters.getNumberRows(i.id);e++)(t||this.hiddenHeaders[i.id].ROW[e])&&(void 0===i.rows[e]&&(i.rows[e]={}),i.rows[e].isHidden=this.hiddenHeaders[i.id].ROW[e]);void 0===i.cols&&(i.cols={});for(let e=0;e<this.getters.getNumberCols(i.id);e++)(t||this.hiddenHeaders[i.id].COL[e])&&(void 0===i.cols[e]&&(i.cols[e]={}),i.cols[e].isHidden=this.hiddenHeaders[i.id].COL[e])}}}Yf.getters=["canRemoveHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class Kf extends Pf{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const i of Object.values(t).filter(Xe))this.addMerge(e.sheetIdTo,i.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const i=t?[t]:Object.keys(this.merges);for(const t of i)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(Xe)}getMerge(e,t,i){var o;const n=this.mergeCellMap[e],r=n?t in n&&(null===(o=n[t])||void 0===o?void 0:o[i]):void 0;return r?this.getMergeById(e,r):void 0}getMergesInZone(e,t){var i;const o=this.mergeCellMap[e];if(!o)return[];const n=new Set;for(const{col:e,row:r}of Vi(t)){const t=null===(i=o[e])||void 0===i?void 0:i[r];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(Xe)}doesIntersectMerge(e,t){const{left:i,right:o,top:n,bottom:r}=t;for(let t=n;t<=r;t++)for(let n=i;n<=o;n++)if(this.getMerge(e,n,t))return!0;return!1}doesColumnsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(o.id,t,n,i,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(o.id,n,t,n,i))return!0;return!1}expandZone(e,t){let{left:i,right:o,top:n,bottom:r}=t,s={left:i,right:o,top:n,bottom:r};for(let t in this.merges[e]){const i=this.getMergeById(e,parseInt(t));i&&Fi(i,s)&&(s=Oi(i,s))}return _i(s,t)?s:this.expandZone(e,s)}isInSameMerge(e,t,i,o,n){const r=this.getMerge(e,t,i),s=this.getMerge(e,o,n);return!(!r||!s)&&_i(r,s)}isInMerge(e,t,i){var o;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(o=n[t])||void 0===o?void 0:o[i]))}getMainCellPosition(e,t,i){if(!this.isInMerge(e,t,i))return{col:t,row:i};const o=this.getMerge(e,t,i).topLeft;return{col:o.col,row:o.row}}getBottomLeftCell(e,t,i){if(!this.isInMerge(e,t,i))return{col:t,row:i};const{bottom:o,left:n}=this.getMerge(e,t,i);return{col:n,row:o}}isMergeHidden(e,t){const i=this.getters.getHiddenColsGroups(e),o=this.getters.getHiddenRowsGroups(e);for(let e of i)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of o)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const i=this.getMerge(e,t.left,t.top);if(i)return _i(t,i);const{width:o,height:n}=Pi(t);return 1===o&&1===n}isMergeDestructive(e,t){let{left:i,right:o,top:n,bottom:r}=t;o=Oe(o,0,this.getters.getNumberCols(e)-1),r=Oe(r,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=r;t++)for(let r=i;r<=o;r++)if(r!==i||t!==n){const i=this.getters.getCell(e,r,t);if(i&&!i.isEmpty())return!0}return!1}getMergeById(e,t){var i;const o=null===(i=this.merges[e])||void 0===i?void 0:i[t];return void 0!==o?Jf(t,o):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const i of e)if(t!==i&&Fi(t,i))return 64;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<i&&e.right>=i||e.top<o&&e.bottom>=o)return 74;return 0}checkMergedContentUpdate(e){const{col:t,row:i,sheetId:o,content:n}=e;if(void 0===n)return 0;const{col:r,row:s}=this.getMainCellPosition(o,t,i);return r===t&&s===i?0:4}checkMergeExists(e){const{sheetId:t,target:i}=e;for(const e of i){const{left:i,top:o}=e,n=this.getMerge(t,i,o);if(void 0===n||!_i(e,n))return 5}return 0}addMerge(e,t){let{left:i,right:o,top:n,bottom:r}=t;o=Oe(o,0,this.getters.getNumberCols(e)-1),r=Oe(r,0,this.getters.getNumberRows(e)-1);if(kt(i,n)===kt(o,r))return;const s=this.getters.getCell(e,i,n);let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,Ri({left:i,top:n,right:o,bottom:r})));let l=new Set;for(let t=n;t<=r;t++)for(let r=i;r<=o;r++){r===i&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:r,row:t,style:s?s.style:null,content:""});const o=this.getMerge(e,r,t);o&&l.add(o.id),this.history.update("mergeCellMap",e,r,t,a)}for(let t of l){const{top:i,bottom:o,left:n,right:r}=this.getMergeById(e,t);for(let t=i;t<=o;t++)for(let i=n;i<=r;i++){const o=this.getMerge(e,i,t);o&&o.id===a||(this.history.update("mergeCellMap",e,i,t,void 0),this.dispatch("CLEAR_CELL",{sheetId:e,col:i,row:t}))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:i,top:o,bottom:n,right:r}=t,s=this.getMerge(e,i,o);if(void 0!==s&&_i(t,s)){this.history.update("merges",e,s.id,void 0);for(let t=o;t<=n;t++)for(let o=i;o<=r;o++)this.history.update("mergeCellMap",e,o,t,void 0)}}applyRangeChangeOnSheet(e,t){const i=Object.entries(this.merges[e]||{});for(const[o,n]of i)if(n){const i=n.zone,r=t(n);switch(r.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,i);break;default:const{width:t,height:n}=Pi(r.range.zone);1===t&&1===n?this.removeMerge(e,i):this.history.update("merges",e,parseInt(o,10),r.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:i,row:o}of Vi(t))this.history.update("mergeCellMap",e,i,o,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let i of t)this.addMerge(e,yi(i))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Qf(e))}}exportForExcel(e){this.export(e)}}function Qf(e){return Object.entries(e).map((([e,t])=>t?Jf(parseInt(e,10),t):void 0)).filter(Xe).map((e=>kt(e.left,e.top)+":"+kt(e.right,e.bottom)))}function Jf(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Kf.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class ev extends Pf{constructor(){super(...arguments),this.sheetIdsMapName={},this.orderedSheetIds=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":const t=this.orderedSheetIds.indexOf(e.sheetId);if("left"===e.direction){return this.orderedSheetIds.slice(0,t).map((e=>!this.isSheetVisible(e))).every((e=>e))?14:0}return this.orderedSheetIds.slice(t+1).map((e=>!this.isSheetVisible(e))).every((e=>e))?14:0;case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const i="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>i?85:e.quantity<=0?86:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return Math.min(...e.elements)<0||Math.max(...e.elements)>t?85:0}case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.direction);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){var t,i;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let o of e.sheets){const e=o.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:r,rowNumber:s}=this.getImportedSheetSize(o),a={id:o.id,name:e,numberOfCols:r,rows:Ci(s),areGridLinesVisible:void 0===o.areGridLinesVisible||o.areGridLinesVisible,isVisible:o.isVisible,panes:{xSplit:(null===(t=o.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(i=o.panes)||void 0===i?void 0:i.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(Xe).map((e=>{const t=this.sheets[e],i={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(i.panes=t.panes),i}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}getCellsInZone(e,t){return Vi(t).map((({col:t,row:i})=>this.getCell(e,t,i)))}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=Ae(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,i){return"COL"===t?i>=0&&i<this.getNumberCols(e):i>=0&&i<this.getNumberRows(e)}getRow(e,t){const i=this.getSheet(e).rows[t];if(!i)throw new Error(`Row ${i} not found.`);return i}getCell(e,t,i){var o;const n=this.tryGetSheet(e),r=null===(o=null==n?void 0:n.rows[i])||void 0===o?void 0:o.cells[t];if(void 0!==r)return this.getters.getCellById(r)}getColCells(e,t){return this.getSheet(e).rows.map((e=>e.cells[t])).filter(Xe).map((e=>this.getters.getCellById(e))).filter(Xe)}getColsZone(e,t,i){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:i}}getRowCells(e,t){var i;return Object.values(null===(i=this.getSheet(e).rows[t])||void 0===i?void 0:i.cells).filter(Xe)}getRowsZone(e,t,i){return{top:t,bottom:i,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this));let o=`${e}${t}`;for(;i.includes(o);)o=`${e}${t}`,t++;return o}getSheetSize(e){return{height:this.getNumberRows(e),width:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,i){const o={...this.getPaneDivisions(e)};"COL"===i?o.xSplit=t:"ROW"===i&&(o.ySplit=t),this.history.update("sheets",e,"panes",o)}isEmpty(e,t){return this.getCellsInZone(e,t).flat().every((e=>!e||e.isEmpty()))}updateCellPosition(e){const{sheetId:t,cellId:i,col:o,row:n}=e;i?this.setNewPosition(i,t,o,n):this.clearPosition(t,o,n)}setNewPosition(e,t,i,o){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:o,col:i,sheetId:t}),this.history.update("sheets",t,"rows",o,"cells",i,e)}clearPosition(e,t,i){var o;const n=null===(o=this.sheets[e])||void 0===o?void 0:o.rows[i].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",i,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){this.sheets[e].rows[o].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:o})}}createSheet(e,t,i,o,n){const r={id:e,name:t,numberOfCols:i,rows:Ci(o),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},s=this.orderedSheetIds.slice();s.splice(n,0,r.id);const a=this.sheets;return this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},a,{[r.id]:r})),r}moveSheet(e,t){const i=this.orderedSheetIds.slice(),o=i.findIndex((t=>t===e)),n=i.splice(o,1);let r="left"===t?this.findIndexOfPreviousVisibleSheet(o-1,i):this.findIndexOfNextVisibleSheet(o+1,i);void 0===r&&(r=i.length),i.splice(r,0,n[0]),this.history.update("orderedSheetIds",i)}findIndexOfPreviousVisibleSheet(e,t){for(;e>=0&&!this.isSheetVisible(t[e]);)e--;if(-1===e)throw new Error("There is no previous visible sheet");return e}findIndexOfNextVisibleSheet(e,t){for(;e<t.length&&!this.isSheetVisible(t[e]);)e++;if(e!==t.length-1||this.isSheetVisible(t[e-1]))return e}checkSheetName(e){const{orderedSheetIds:t,sheets:i}=this,o=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=i[e])||void 0===t?void 0:t.name.toLowerCase())===o}))?11:te.test(o)?13:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?15:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:73}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:73}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.top<e.quantity&&e.quantity<=i.bottom)return 64;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.left<e.quantity&&e.quantity<=i.right)return 64;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const i=e.name;this.history.update("sheets",e.id,"name",t.trim());const o=Object.assign({},this.sheetIdsMapName);o[t]=e.id,delete o[i],this.history.update("sheetIdsMapName",o)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const i=this.getSheet(e),o=this.getDuplicateSheetName(i.name),n=Te(i);n.id=t,n.name=o;for(let e=0;e<=n.numberOfCols;e++)for(let t=0;t<=n.rows.length;t++)n.rows[t]&&(n.rows[t].cells[e]=void 0);const r=this.orderedSheetIds.slice(),s=r.indexOf(e);r.splice(s+1,0,n.id),this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},this.sheets,{[n.id]:n}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:i}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:i,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[n.name]=n.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this)),o=r("Copy of %s",e);let n=o.toString();for(;i.includes(n);)n=`${o} (${t})`,t++;return n}deleteSheet(e){const t=e.name,i=Object.assign({},this.sheets);delete i[e.id],this.history.update("sheets",i);const o=this.orderedSheetIds.slice(),n=o.indexOf(e.id);o.splice(n,1),this.history.update("orderedSheetIds",o);const r=Object.assign({},this.sheetIdsMapName);delete r[t],this.history.update("sheetIdsMapName",r)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let i of t)this.moveCellOnColumnsDeletion(e,i);const i=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",i-t.length);const o=t.filter((t=>t<e.panes.xSplit)).length;o&&this.setPaneDivisions(e.id,e.panes.xSplit-o,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let i of $e(t))this.moveCellOnRowsDeletion(e,i[i.length-1],i[0]),i.map((t=>this.updateRowsStructureOnDeletion(t,e)));const i=t.filter((t=>t<e.panes.ySplit)).length;i&&this.setPaneDivisions(e.id,e.panes.ySplit-i,"ROW")}addColumns(e,t,i,o){const n="before"===i?t:t+1;this.moveCellsOnAddition(e,n,o,"columns");const r=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",r+o),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+o,"COL")}addRows(e,t,i,o){const n="before"===i?t:t+1;this.addEmptyRows(e,o),this.moveCellsOnAddition(e,n,o,"rows"),this.updateRowsStructureOnAddition(e,t,o),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+o,"ROW")}moveCellOnColumnsDeletion(e,t){for(let i=0;i<e.rows.length;i++){const o=e.rows[i];for(let n in o.cells){const r=Number(n),s=o.cells[n];s&&(r===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:r,row:i}),r>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:s,col:r-1,row:i}))}}}moveCellsOnAddition(e,t,i,o){const n=[];for(let r=0;r<e.rows.length;r++){const s=e.rows[r];if("rows"!==o||r>=t)for(let a in s.cells){const l=Number(a),c=s.cells[a];c&&("rows"===o||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===o?i:0),row:r+("rows"===o?i:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,i){const o=i-t+1;for(let n=0;n<e.rows.length;n++){const r=e.rows[n];if(n>=t&&n<=i)for(let t in r.cells){const i=Number(t);r.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:i,row:n})}if(n>i)for(let t in r.cells){const i=Number(t),s=r.cells[t];s&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:s,col:i,row:n-o})}}}updateRowsStructureOnDeletion(e,t){const i=[],o=t.rows.map((e=>e.cells));for(let n in t.rows)Number(n)!==e&&i.push({cells:o.shift()});this.history.update("sheets",t.id,"rows",i)}updateRowsStructureOnAddition(e,t,i){const o=[],n=e.rows.map((e=>e.cells));e.rows.forEach((()=>o.push({cells:n.shift()}))),this.history.update("sheets",e.id,"rows",o)}addEmptyRows(e,t){const i=e.rows.slice();for(let e=0;e<t;e++)i.push({cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(Dt);let i=e.rowNumber,o=e.colNumber;for(let{col:e,row:n}of t)i=Math.max(i,n+1),o=Math.max(o,e+1);return{rowNumber:i,colNumber:o}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?27:"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),"ranges"in e&&Array.isArray(e.ranges)&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),!t.every(xi))return 25;if(t.length&&"sheetId"in e){const i=this.getSheetZone(e.sheetId);return t.every((e=>ki(e,i)))?0:18}return 0}}ev.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellsInZone","getCellPosition","getColCells","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions"];class tv{constructor(e,t,i){this.index=0,this.cells=e,this.getters=t,this.direction=i}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:i,tooltip:o}=Qi.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:i,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class iv extends wg{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:Oe(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:Oe(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:44;case"AUTOFILL_AUTO":const i=this.getters.getSelectedZone();return i.top===i.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||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),i=this.autofillZone;switch(this.direction){case"down":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push(kt(o,e));const r=this.createGenerator(n);for(let t=i.top;t<=i.bottom;t++)this.computeNewCell(r,o,t,e)}break;case"up":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push(kt(o,e));const r=this.createGenerator(n);for(let t=i.bottom;t>=i.top;t--)this.computeNewCell(r,o,t,e)}break;case"left":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.right;e>=t.left;e--)n.push(kt(e,o));const r=this.createGenerator(n);for(let t=i.right;t>=i.left;t--)this.computeNewCell(r,t,o,e)}break;case"right":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.left;e<=t.right;e++)n.push(kt(e,o));const r=this.createGenerator(n);for(let t=i.left;t<=i.right;t++)this.computeNewCell(r,t,o,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const i=this.getters.getSelectedZone();if(Di(e,t,i))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,i.top-1,i.left,i.right),this.steps=i.top-t;break;case"down":this.saveZone(i.bottom+1,t,i.left,i.right),this.steps=t-i.bottom;break;case"left":this.saveZone(i.top,i.bottom,e,i.left-1),this.steps=i.left-e;break;case"right":this.saveZone(i.top,i.bottom,i.right+1,e),this.steps=e-i.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let i=e.left,o=e.bottom;if(i>0){let e=this.getters.getCell(t,i-1,o);for(;e&&!e.isEmpty();)o+=1,e=this.getters.getCell(t,i-1,o)}if(o===e.bottom&&(i=e.right,i<=this.getters.getNumberCols(t))){let e=this.getters.getCell(t,i+1,o);for(;e&&!e.isEmpty();)o+=1,e=this.getters.getCell(t,i+1,o)}o!==e.bottom&&(this.select(e.left,o-1),this.autofill(!0))}computeNewCell(e,t,i,o){const{cellData:n,tooltip:r,origin:s}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=r,o&&this.dispatch("AUTOFILL_CELL",{originCol:s.col,originRow:s.row,col:t,row:i,content:a,style:l,border:c,format:h})}getRule(e,t){const i=co.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((i=>i.condition(e,t)));return i&&i.generateRule(e,t)}createGenerator(e){const t=[],i=[],o=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=Dt(t),r=this.getters.getCell(o,e,n);i.push({col:e,row:n,cell:r,sheetId:o})}const n=i.map((e=>e.cell));for(let e of i){let i={type:"COPY_MODIFIER"};if(e&&e.cell){i=this.getRule(e.cell,n)||i}const{sheetId:o,col:r,row:s}=e,a=this.getters.getCellBorder(o,r,s)||void 0;t.push({data:{...e,border:a},rule:i})}return new tv(t,this.getters,this.direction)}saveZone(e,t,i,o){this.autofillZone={top:e,bottom:t,left:i,right:o}}getDirection(e,t){const i=this.getters.getSelectedZone(),o={up:{number:i.top-t,value:"up"},down:{number:t-i.bottom,value:"down"},left:{number:i.left-e,value:"left"},right:{number:e-i.right,value:"right"}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const n=o.up.number>0?"up":"down",r=o.left.number>0?"left":"right";return Math.abs(o[n].number)>=Math.abs(o[r].number)?o[n].value:o[r].value}autoFillMerge(e,t,i,o){const n=this.getters.getActiveSheet();if(this.getters.isInMerge(n.id,i,o)&&!this.getters.isInMerge(n.id,e,t)){const e=this.getters.getMerge(n.id,i,o);e&&this.dispatch("REMOVE_MERGE",{sheetId:n.id,target:[e]})}const r=this.getters.getMerge(n.id,e,t);(null==r?void 0:r.topLeft.col)===e&&(null==r?void 0:r.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:n.id,target:[{top:o,bottom:o+r.bottom-r.top,left:i,right:i+r.right-r.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:i}=e,{x:o,y:n,width:r,height:s}=this.getters.getVisibleRect(this.autofillZone);r>0&&s>0&&(t.strokeStyle="black",t.lineWidth=i,t.setLineDash([3]),t.strokeRect(o,n,r,s),t.setLineDash([]))}}iv.layers=[6],iv.getters=["getAutofillTooltip"];class ov extends wg{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:i}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,i.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,i){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,i):this.sumData(e,t)}sumData(e,t){const i=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,i).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return i.has("ROW")&&i.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,i){const{col:o,row:n}=Di(i.col,i.row,t)?i:{col:t.left,row:t.top},r=this.findAdjacentData(e,o,n);return r?this.getters.isSingleCellOrMerge(e,t)||Ui(Oi(r,t))?[{position:{col:o,row:n},zone:r}]:this.sumDimensions(e,Oi(r,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,i){const o=this.getters.getSheet(e),n=this.getters.getMainCellPosition(e,t,i),r=this.findSuitableZoneToSum(o,n.col,n.row);if(r)return this.getters.expandZone(e,r)}findSuitableZoneToSum(e,t,i){const o=this.getters.getCell(e.id,t,i-1),n=this.getters.getCell(e.id,t-1,i);if(this.isNumber(n)&&!this.isNumber(o))return this.findHorizontalZone(e,t,i);const r=this.findVerticalZone(e,t,i);if(this.isZoneValid(r))return r;const s=this.findHorizontalZone(e,t,i);return this.isZoneValid(s)?s:void 0}findVerticalZone(e,t,i){const o={top:0,bottom:i-1,left:t,right:t},n=this.reduceZoneStart(e,o,o.bottom);return{...o,top:n}}findHorizontalZone(e,t,i){const o={top:i,bottom:i,left:0,right:t-1},n=this.reduceZoneStart(e,o,o.right);return{...o,left:n}}reduceZoneStart(e,t,i){const o=this.getters.getCellsInZone(e.id,t),n=ke(i,-1,-1),r=n.filter((e=>{var t;return o[e]&&!(null===(t=o[e])||void 0===t?void 0:t.isAutoSummable)})),s=Math.max(...r),a=$e(n.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<s?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)===Ji.number&&!(null===(t=e.evaluated.format)||void 0===t?void 0:t.match(X))}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 i=new Set;return Ui(t)?(i.add(1===Pi(t).width?"COL":"ROW"),i):(this.lastColIsEmpty(e,t)&&i.add("ROW"),this.lastRowIsEmpty(e,t)&&i.add("COL"),0===i.size&&i.add("COL"),i)}sumDimensions(e,t,i){return[...i.has("COL")?this.sumColumns(t,e):[],...i.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:i}=e;return{position:{col:i,row:t},zone:{...e,top:t,right:i-1}}}sumColumns(e,t){const i=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,i.bottom-1)},Vi(i).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const i=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,i.right-1)},Vi(i).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const i of t){const{col:t,row:o}=i.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,i.zone)})`})}}nextEmptyRow(e,t){let i=t.bottom+1;const{left:o,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:i,top:i,left:o,right:n});)i++;return{...t,top:i,bottom:i}}nextEmptyCol(e,t){let i=t.right+1;const{top:o,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:i,right:i,top:o,bottom:n});)i++;return{...t,left:i,right:i}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}ov.getters=["getAutomaticSums"];class nv extends wg{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{Po.get(e.popoverType)}catch(e){return 71}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,type:e.popoverType}}}getCellPopover({col:e,row:t}){var i,o;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(n,this.persistentPopover.col,this.persistentPopover.row)){const e=this.getters.getMainCellPosition(n,this.persistentPopover.col,this.persistentPopover.row),t=null===(o=(i=Po.get(this.persistentPopover.type)).onOpen)||void 0===o?void 0:o.call(i,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,...this.computePopoverProps(this.persistentPopover,t.cellCorner)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport(n,e,t))return{isOpen:!1};const r=this.getters.getMainCellPosition(n,e,t),s=Po.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,r,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==s?void 0:s.isOpen)?{...s,...this.computePopoverProps(r,s.cellCorner)}:{isOpen:!1}}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverProps({col:e,row:t},i){const{width:o,height:n}=this.getters.getVisibleRect(Wi({col:e,row:t}));return{coordinates:this.computePopoverPosition({col:e,row:t},i),cellWidth:-o,cellHeight:-n}}computePopoverPosition({col:e,row:t},i){const o=this.getters.getActiveSheetId(),n=this.getters.getMerge(o,e,t);n&&(e="TopRight"===i?n.right:n.left,t="TopRight"===i?n.top:n.bottom);const{x:r,y:s,width:a,height:l}=this.getters.getVisibleRect(Wi({col:e,row:t}));switch(i){case"BottomLeft":return{x:r,y:s+l};case"TopRight":return{x:r+a,y:s}}}}nv.getters=["getCellPopover","getPersistentPopoverTypeAtPosition"],nv.modes=["normal"];class rv{constructor(e,t,i,o){this.getters=t,this.dispatch=i,this.selection=o,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,i,o){const n=this.getters.getActiveSheetId(),r=t+o-this.getters.getNumberRows(n);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(n)-1,sheetId:n,quantity:r,position:"after"});const s=e+i-this.getters.getNumberCols(n);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(n)-1,sheetId:n,quantity:s,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class sv extends rv{constructor(e,t,i,o,n){if(super(t,i,o,n),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const r=new Set(e.map((e=>e.left))),s=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===r.size&&1===s.size?function(e){return e.reduce(((e,t)=>{const i=e.length;for(let o=0;o<i;o++)if(Fi(e[o],t))return e[o]=Oi(e[o],t),e;return e[i]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>Vi(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=i.getActiveSheetId();for(let e of u){let t=[];for(let o of d)t.push({cell:i.getCell(p,o,e),border:i.getCellBorder(p,o,e)||void 0,position:{col:o,row:e,sheetId:p}});g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const i of ke(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues(p,i,e.zone.top));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const o=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(i,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(i,e[0])||o*n!=1))return 2;const{xSplit:r,ySplit:s}=this.getters.getPaneDivisions(i);for(const t of this.getPasteZones(e))if(t.left<r&&t.right>=r||t.top<s&&t.bottom>=s)return 74;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const i=this.cells.length,o=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(o,i,n,e)}pasteFromCopy(e,t){if(1===e.length){const i=this.cells.length,o=this.cells[0].length,n=this.pastedZones(e,o,i);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const i of e)for(let e=i.left;e<=i.right;e++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,o,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const i=e[0];this.pasteZone(i.left,i.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:i.left,row:i.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,i){const o=e[0],n=Math.max(1,Math.floor((o.right+1-o.left)/t)),r=Math.max(1,Math.floor((o.bottom+1-o.top)/i)),s=[];for(let e=0;e<n;e++)for(let n=0;n<r;n++){const r=o.top+n*i,a=o.left+e*t;s.push({left:a,top:r,bottom:r+i-1,right:a+t-1})}return s}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const i=[],o=t.length,n=t[0].length,r=e[e.length-1],s=r.left,a=r.top,l=Math.max(1,Math.floor((r.right+1-s)/n)),c=Math.max(1,Math.floor((r.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)i.push({left:s,top:a,right:s-1+e*n,bottom:a-1+t*o});return i}selectPastedZone(e,t,i,o){const n=o[0],r=n.left,s=n.top;if(t>1||e>1||i){const n=this.pastedZones(o,e,t),a=i?n[0]:Oi(...n);this.selection.selectZone({cell:{col:r,row:s},zone:a})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,i){const o=this.cells.length,n=this.cells[0].length,r="onlyValue"!==(null==i?void 0:i.pasteOption)&&(null==i?void 0:i.shouldPasteCF),s=this.getters.getActiveSheetId();this.addMissingDimensions(n,o,e,t);for(let a=0;a<o;a++){const o=this.cells[a];for(let l=0;l<n;l++){const n=o[l],c={col:e+l,row:t+a,sheetId:s};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,i),r&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,i,o){const{sheetId:n,col:r,row:s}=t,a=this.getters.getCell(n,r,s);if("onlyValue"!==(null==o?void 0:o.pasteOption)){const t=this.getters.getCellBorder(n,r,s),i=e.border,o={top:(null==t?void 0:t.top)||(null==i?void 0:i.top),bottom:(null==t?void 0:t.bottom)||(null==i?void 0:i.bottom),left:(null==t?void 0:t.left)||(null==i?void 0:i.left),right:(null==t?void 0:t.right)||(null==i?void 0:i.right)};this.dispatch("SET_BORDER",{sheetId:n,col:r,row:s,border:o})}if(e.cell){if("onlyFormat"===(null==o?void 0:o.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.cell.evaluated.format||e.cell.format});if("onlyValue"===(null==o?void 0:o.pasteOption)){const i=Gt(e.cell.evaluated.value);return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula()&&"COPY"===i){const t=r-e.position.col,o=s-e.position.row;a=this.getUpdatedContent(n,e.cell,t,o,i)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,i,o,n){const r=this.getters.createAdaptedRanges(t.dependencies,i,o,e);return this.getters.buildFormulaContent(e,t,r)}pasteMergeIfExist(e,t){let{sheetId:i,col:o,row:n}=e;const{col:r,row:s}=this.getters.getMainCellPosition(i,o,n);if(r===o&&s===n){const e=this.getters.getMerge(i,o,n);if(!e)return;({sheetId:i,col:o,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:i,force:!0,target:[{left:o,top:n,right:o+e.right-e.left,bottom:n+e.bottom-e.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),i=e[0],o=this.zones[0],n=[i.left-o.left,i.top-o.top];for(const e of this.copiedTables){const i=zi(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[i]});for(const o of ke(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:i.left+o,row:i.top,values:e.filtersValues[o]})}}getClipboardContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.cell,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let i of this.zones){if("COL"===t&&e<=i.right)return!0;if("ROW"===t&&e<=i.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:i}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*i;for(const e of this.zones){const{x:i,y:o,width:n,height:r}=this.getters.getVisibleRect(e);n>0&&r>0&&t.strokeRect(i,o,n,r)}}}}class av{constructor(e,t,i){this.getters=t,this.dispatch=i,this.sheetId=t.getActiveSheetId();const o=t.getSelectedFigureId();if(!o)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,o);if(!n)throw new Error(`No figure for the given id: ${o}`);this.copiedFigure={...n};const r=t.getChart(o);if(!r)throw new Error(`No chart for the given id: ${o}`);this.copiedChart=r.copyInSheetId(this.sheetId),this.operation=e}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?72:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),i={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},o=this.copiedChart.copyInSheetId(t),n=(new Ei).uuidv4();this.dispatch("CREATE_CHART",{id:n,sheetId:t,position:i,size:{height:this.copiedFigure.height,width:this.copiedFigure.width},definition:o.getDefinition()}),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedChart.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return"\t"}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class lv extends rv{constructor(e,t,i,o){super("COPY",t,i,o),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId(),o=this.getPasteZone(e);return this.getters.doesIntersectMerge(i,o)?2:0}paste(e){const t=this.values,i=this.getPasteZone(e),{left:o,top:n}=i,{width:r,height:s}=Pi(i),a=this.getters.getActiveSheetId();this.addMissingDimensions(r,s,o,n);for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)this.dispatch("UPDATE_CELL",{row:n+e,col:o+i,content:t[e][i],sheetId:a});const l={left:o,top:n,right:o+r-1,bottom:n+s-1};this.selection.selectZone({cell:{col:o,row:n},zone:l})}getClipboardContent(){return this.values.map((e=>e.join("\t"))).join("\n")}getPasteZone(e){const t=this.values.length,i=Math.max(...this.values.map((e=>e.length))),{left:o,top:n}=e[0];return{top:n,left:o,bottom:n+t-1,right:o+i-1}}}class cv extends wg{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=e.target||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:i});case"PASTE_FROM_OS_CLIPBOARD":return new lv(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}}return 0}handle(e){var t,i;switch(e.type){case"COPY":case"CUT":const o="target"in e&&e.target||this.getters.getSelectedZones();this.state=this.getClipboardState(o,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const n=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!xi(t[0])){for(const{col:t,row:i}of Vi(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:i,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(i=this.state)||void 0===i?void 0:i.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new lv(e.text,this.getters,this.dispatch,this.selection).paste(e.target),this.status="invisible";break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}default:no(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o;return o="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(i)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o,n;return"COL"===t?(o={...e,right:this.getters.getNumberCols(i)-1},n={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:this.getters.getNumberRows(i)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1}),{cut:[o],paste:[n]}}getClipboardStateForCopyCells(e,t){return new sv(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new av(t,this.getters,this.dispatch):new sv(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}cv.layers=[2],cv.getters=["getClipboardContent","isCutOperation","isPaintingFormat"];class hv extends wg{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const i=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(i),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:mt(255,0,0),colors:[]},{leadColor:mt(255,128,0),colors:[]},{leadColor:mt(128,128,0),colors:[]},{leadColor:mt(128,255,0),colors:[]},{leadColor:mt(0,255,0),colors:[]},{leadColor:mt(0,255,128),colors:[]},{leadColor:mt(0,255,255),colors:[]},{leadColor:mt(0,127,255),colors:[]},{leadColor:mt(0,0,255),colors:[]},{leadColor:mt(127,0,255),colors:[]},{leadColor:mt(128,0,128),colors:[]},{leadColor:mt(255,0,128),colors:[]}];for(const i of e.map(bt)){let e=500,o=0;t.forEach(((t,n)=>{const r=(s=i,a=t.leadColor,Math.sqrt(Math.pow(s.r-a.r,2)+Math.pow(s.g-a.g,2)+Math.pow(s.b-a.b,2)));var s,a;e>r&&(e=r,o=n)})),t[o].colors.push(i)}return t.map((e=>e.colors.sort(((e,t)=>Ct(e).s-Ct(t).s)))).flat().map(vt)}([...new Set([...new Set([...e,...this.customColors])].filter(gt).map(ut))]).filter((e=>!M.includes(e)))}getColorsFromCells(e){var t,i;const o=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&o.add(n.style.textColor),(null===(i=n.style)||void 0===i?void 0:i.fillColor)&&o.add(n.style.fillColor);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),i=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(i.push(t.style.textColor),i.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(i.push(ht(t.minimum.color)),i.push(t.midpoint?ht(t.midpoint.color):void 0),i.push(ht(t.maximum.color)))}return i.filter(Xe)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let i=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&i.add(t),e.type){case"gauge":const t=e.sectionRule.colors;i.add(t.lowerColor),i.add(t.middleColor),i.add(t.upperColor);break;case"scorecard":const o=e;i.add(o.baselineColorDown),i.add(o.baselineColorUp)}}return[...i]}tryToAddColor(e){const t=ut(e);e&&!M.includes(t)&&this.customColors.add(t)}}hv.getters=["getCustomColors"];const dv=Tu.mapping;class uv extends wg{constructor(e,t,i,o,n){super(e,t,i,o,n),this.isUpToDate=!1,this.evalContext=o.evalContext}handle(e){switch(eo.has(e.type)&&(this.isUpToDate=!1),e.type){case"UPDATE_CELL":("content"in e||"format"in e)&&(this.isUpToDate=!1);break;case"EVALUATE_CELLS":this.evaluate()}}finalize(){this.isUpToDate||this.evaluate()}evaluateFormula(e,t=this.getters.getActiveSheetId()){const i=fg(e),o=this.getCompilationParameters((()=>{})),n=[];for(let e of i.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return i.execute(n,...o).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>(null==e?void 0:e.formattedValue)||""))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>null==e?void 0:e.evaluated.value))}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){const e=this.getCompilationParameters(i),t={};for(const e of this.getAllCells())i(e);function i(i){if(!i.isFormula())return;const o=i.id,n=tt((()=>{if(e[2].__originCellXC=()=>{const t=e[2].getters.getCellPosition(o);return kt(t.col,t.row)},o in t)return null===t[o]?new d:i.evaluated;t[o]=null;try{const n=i.compiledFormula.execute(i.dependencies,...e);if(t[o]=!0,Array.isArray(n.value))throw new Error(r("This formula depends on invalid values"));return{value:n.value,format:i.format||n.format}}catch(i){return t[o]=!0,function(t){t instanceof Error||(t=new Error(t));const i=(null==t?void 0:t.errorType)||a.GenericError,o=e[2].__lastFnCalled||"";return new c(i,t.message.replace("[[FUNCTION_NAME]]",o),void 0!==t.logLevel?t.logLevel:l.error)}(i)}}));i.assignEvaluation(n)}this.isUpToDate=!0}getCompilationParameters(e){const t=Object.assign(Object.create(dv),this.evalContext,{getters:this.getters}),i=this.getters;function o(e){if(e.evaluated.type===Ji.error)throw new c(e.evaluated.value,e.evaluated.error.message,e.evaluated.error.logLevel);return e.evaluated}return[function(e,t,n,s){if(t)return{value:Ri(e.zone)};if(!xi(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(s?r("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",n.toString(),s.toString()):r("Function %s expects its parameters to be single values or single cell references, not ranges.",n.toString()));if(e.invalidSheetName)throw new Error(r("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!i.tryGetSheet(e.sheetId))throw new Error(r("Invalid sheet name"));return t=i.getCell(e.sheetId,e.zone.left,e.zone.top),!t||t.isEmpty()?{value:null,format:null==t?void 0:t.format}:o(t)}(e)},function(e){const n=e.sheetId;if(!xi(e.zone))throw new u;const r=i.getSheetZone(n),s=[],a=Ni(e.zone,r);if(!a)return s.push([]),s;for(let i=a.left;i<=a.right;i++){const n=[];for(let r=a.top;r<=a.bottom;r++){const s=t.getters.getCell(e.sheetId,i,r);n.push(s?o(s):void 0)}s.push(n)}return s},t]}}uv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues"];class gv extends wg{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=Xi.getAll();return function(i){const o=t.find((e=>e.match(i.type)));if(!o)throw new Error("No runtime builder for this chart.");return o.getChartRuntime(i,e)}}(this.getters)}handle(e){if(eo.has(e.type)||to.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const i=t.zone.left,o=t.zone.top;return this.getters.getCellComputedStyle(t.sheetId,i,o).fillColor||w}}gv.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class pv extends wg{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.rulePredicate={CellIsRule:(e,t)=>{if(e&&e.evaluated.type===Ji.error)return!1;const i=t.values.map(Cp);switch(t.operator){case"IsEmpty":return!Xe(e)||""===e.evaluated.value.toString().trim();case"IsNotEmpty":return Xe(e)&&""!==e.evaluated.value.toString().trim();case"BeginsWith":return!(!e&&""===i[0])&&(Xe(e)&&(null==e?void 0:e.evaluated.value.toString().startsWith(i[0].toString())));case"EndsWith":return!(!e&&""===i[0])&&(Xe(e)&&e.evaluated.value.toString().endsWith(i[0].toString()));case"Between":return Xe(e)&&e.evaluated.value>=i[0]&&e.evaluated.value<=i[1];case"NotBetween":return!(Xe(e)&&e.evaluated.value>=i[0]&&e.evaluated.value<=i[1]);case"ContainsText":return Xe(e)&&e.evaluated.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!Xe(e)||!e.evaluated.value||-1==e.evaluated.value.toString().indexOf(i[0].toString());case"GreaterThan":return Xe(e)&&e.evaluated.value>i[0];case"GreaterThanOrEqual":return Xe(e)&&e.evaluated.value>=i[0];case"LessThan":return Xe(e)&&e.evaluated.value<i[0];case"LessThanOrEqual":return Xe(e)&&e.evaluated.value<=i[0];case"NotEqual":return!(!Xe(e)&&""===i[0])&&(Xe(e)&&e.evaluated.value!==i[0]);case"Equal":return!e&&""===i[0]||Xe(e)&&e.evaluated.value===i[0];default:console.warn(r("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((to.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),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 i=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(i,e.originCol,e.originRow);for(const t of o)this.adaptRules(i,t,[kt(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation)}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getCellComputedStyle(e,t,i){var o;const n=this.getters.getCell(e,t,i),r=this.computedStyles[e],s=r&&(null===(o=r[t])||void 0===o?void 0:o[i]),a={...null==n?void 0:n.style,...s};return this.getters.isFilterHeader(e,t,i)&&(a.bold=!0),a}getConditionalIcon(e,t){var i;const o=this.getters.getActiveSheetId(),n=this.computedIcons[o];return n&&(null===(i=n[e])||void 0===i?void 0:i[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const i=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t).reverse())try{switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let n of o.ranges){const r=this.getters.getRangeFromSheetXC(t,n).zone;for(let n=r.top;n<=r.bottom;n++)for(let s=r.left;s<=r.right;s++){const r=this.rulePredicate[o.rule.type];let a=this.getters.getCell(t,s,n);r&&r(a,o.rule)&&(i[s]||(i[s]=[]),i[s][n]=Object.assign((null===(e=i[s])||void 0===e?void 0:e[n])||{},o.rule.style))}}}}catch(e){}}parsePoint(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getRangeValues(this.getters.getRangeFromSheetXC(o,e)).filter(this.isCellValueNumber);switch(t.type){case"value":return"max"===i?Math.max(...n):Math.min(...n);case"number":return Number(t.value);case"percentage":const e=Math.min(...n);return e+(Math.max(...n)-e)*Number(t.value)/100;case"percentile":return fi(n,Number(t.value)/100,!0);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return o instanceof Promise?null:o;default:return null}}applyIcon(e,t){const i=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===i||null===o||i>o)return;const n=this.getters.getActiveSheetId(),r=this.getters.getRangeFromSheetXC(n,e).zone,s=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=r.top;e<=r.bottom;e++)for(let l=r.left;l<=r.right;l++){const r=this.getters.getCell(n,l,e);if((null==r?void 0:r.evaluated.type)!==Ji.number)continue;const c=this.computeIcon(r.evaluated.value,o,t.upperInflectionPoint.operator,i,t.lowerInflectionPoint.operator,a);s[l]||(s[l]=[]),s[l][e]=c}}computeIcon(e,t,i,o,n,r){return"ge"===i&&e>=t||"gt"===i&&e>t?r[0]:"ge"===n&&e>=o||"gt"===n&&e>o?r[1]:r[2]}applyColorScale(e,t){var i;const o=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,r=this.parsePoint(e,t.maximum,"max");if(null===o||null===r||o>=r||n&&(o>=n||n>=r))return;const s=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(s,e).zone,l=this.computedStyles[s],c=[];t.midpoint&&n?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.midpoint.color)}),c.push({minValue:n,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(n,r,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,r,t.minimum.color,t.maximum.color)});for(let e=a.top;e<=a.bottom;e++)for(let t=a.left;t<=a.right;t++){const a=this.getters.getCell(s,t,e);if((null==a?void 0:a.evaluated.type)===Ji.number){const s=Oe(a.evaluated.value,o,r);let h;h=2===c.length&&n?s<=n?this.colorCell(s,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(s,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(s,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(i=l[t])||void 0===i?void 0:i[e])||{},l[t][e].fillColor=ht(h)}}}computeColorDiffUnits(e,t,i,o){const n=t-e;return[((i>>16)%256-(o>>16)%256)/n,((i>>8)%256-(o>>8)%256)/n,(i%256-o%256)/n]}colorCell(e,t,i,o){const[n,r,s]=o;return Math.round((i>>16)%256-n*(e-t))<<16|Math.round((i>>8)%256-r*(e-t))<<8|Math.round(i%256-s*(e-t))}adaptRules(e,t,i,o){if(0===i.length&&0===o.length)return;const n=this.getters.getConditionalFormats(e),r=n.findIndex((e=>e.id===t.id));let s=[];r>-1&&(s=n[r].ranges),s=s.concat(i);const a=$i(s,o);this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}pasteCf(e,t,i){const o=kt(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let r of n.ranges)if(Di(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,r).zone)){const r=n,s=[];"CUT"===i&&s.push(kt(e.col,e.row)),e.sheetId===t.sheetId?this.adaptRules(e.sheetId,r,[o],s):(this.adaptRules(t.sheetId,r,[o],[]),this.adaptRules(e.sheetId,r,[],s))}}isCellValueNumber(e){return"number"==typeof e}}pv.getters=["getConditionalIcon","getCellComputedStyle"];class mv extends wg{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e.sheetId,e.col,e.row))return 78;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"HIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const i of this.getters.getFilters(e.sheetIdTo)){const o=i.zoneWithHeaders;t[i.id]=this.getFilterValues(e.sheetId,o.left,o.top)}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e,t,i){let o;for(let n of this.getters.getFilterTables(e)){const r=n.zone;if(Di(t,i,r)){const n=this.intersectZoneWithViewport(e,r);o={top:i===n.top?j:void 0,bottom:i===n.bottom?j:void 0,left:t===n.left?j:void 0,right:t===n.right?j:void 0}}}const n=this.getters.getCellBorder(e,t,i),r={...o,...rt(n||{})};return Ke(r)?null:r}getFilterHeaders(e){const t=[];for(let i of this.getters.getFilterTables(e)){const o=i.zone;if(!o)continue;const n=o.top;for(let i=o.left;i<=o.right;i++)this.getters.isColHidden(e,i)||this.getters.isRowHidden(e,n)||t.push({col:i,row:n})}return t}getFilterValues(e,t,i){const o=this.getters.getFilterId(e,t,i);return o&&this.filterValues[e]&&this.filterValues[e][o]||[]}isFilterHeader(e,t,i){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===i))}isFilterActive(e,t,i){var o,n;const r=this.getters.getFilterId(e,t,i);return Boolean(r&&(null===(n=null===(o=this.filterValues[e])||void 0===o?void 0:o[r])||void 0===n?void 0:n.length))}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,"COL",t.left,t.right),right:this.getters.findVisibleHeader(e,"COL",t.right,t.left),top:this.getters.findVisibleHeader(e,"ROW",t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,"ROW",t.bottom,t.top)}}updateFilter({col:e,row:t,values:i,sheetId:o}){const n=this.getters.getFilterId(o,e,t);n&&(this.filterValues[o]||(this.filterValues[o]={}),this.filterValues[o][n]=i)}updateHiddenRows(){var e,t;const i=this.getters.getActiveSheetId(),o=this.getters.getFilters(i).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),n=new Set;for(let r of o){if(this.getters.isRowHiddenByUser(i,r.zoneWithHeaders.top))continue;if(n.has(r.zoneWithHeaders.top))continue;const o=null===(t=null===(e=this.filterValues[i])||void 0===e?void 0:e[r.id])||void 0===t?void 0:t.map(st);if(o&&r.filteredZone)for(let e=r.filteredZone.top;e<=r.filteredZone.bottom;e++){const t=this.getCellValueAsString(i,r.col,e);o.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,i){var o;const n=null===(o=this.getters.getCell(e,t,i))||void 0===o?void 0:o.formattedValue;return(null==n?void 0:n.toLowerCase())||""}exportForExcel(e){var t;for(const i of e.sheets)for(const e of i.filterTables){const o=yi(e.range),n=[],r=[];for(const e of ke(0,Pi(o).width)){const s=this.getFilterValues(i.id,o.left+e,o.top),a=this.getters.getFilter(i.id,o.left+e,o.top);if(!a)continue;const l=a.filteredZone?Vi(a.filteredZone).map((e=>{var t;return null===(t=this.getters.getCell(i.id,e.col,e.row))||void 0===t?void 0:t.formattedValue})):[];if(s.length){const t=l.filter(Ye).filter((e=>!s.includes(e)));n.push({colId:e,displayedValues:[...new Set(t)],displayBlanks:!s.includes("")&&l.some((e=>!e))})}const c={col:a.col,row:a.zoneWithHeaders.top},h=null===(t=this.getters.getCell(i.id,c.col,c.row))||void 0===t?void 0:t.formattedValue,d=this.getUniqueColNameForExcel(e,h,r);r.push(d),i.cells[kt(c.col,c.row)]={...i.cells[kt(c.col,c.row)],content:d,value:d,isFormula:!1}}e.filters=n}}getUniqueColNameForExcel(e,t,i){t||(t=`Column${e}`);let o=t,n=2;for(;i.includes(o);)o=t+String(n),n++;return o}}mv.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];var fv;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(fv||(fv={}));class vv extends wg{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch="",this.isSearchDirty=!1}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(fv.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(fv.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"EVALUATE_CELLS":case"UPDATE_CELL":case"REMOVE_FILTER_TABLE":case"UPDATE_FILTER":this.isSearchDirty=!0;break;case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"ACTIVATE_SHEET":this.refreshSearch()}}finalize(){this.isSearchDirty&&(this.refreshSearch(),this.isSearchDirty=!1)}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(fv.current)}updateRegex(){let e=Ie(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),i=[];if(this.toSearch)for(const o of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(o.id),r=this.getters.isColHidden(e,t),s=this.getters.isRowHidden(e,n);if(!r&&!s&&(o&&this.currentSearchRegex&&this.currentSearchRegex.test(this.searchOptions.searchFormulas&&o.isFormula()?o.content:String(o.evaluated.value)))){const e=this.getters.getCellPosition(o.id),t={col:e.col,row:e.row,selected:!1};i.push(t)}}return i.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 i;i=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,i=(i%t.length+t.length)%t.length,null!==this.selectedMatchIndex&&this.selectedMatchIndex===i||(this.selectedMatchIndex=i,this.selection.selectCell(t[i].col,t[i].row));for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],i=this.getters.getActiveSheetId(),o=this.getters.getCell(i,t.col,t.row),n=this.toReplace(o,i);if(o&&n){const i=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),o=n.toString().replace(i,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:o}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(fv.current)}else this.selectNextCell(fv.next)}replaceAll(e){const t=this.searchMatches.length;for(let i=0;i<t;i++)this.replace(e)}toReplace(e,t){if(e){if(this.searchOptions.searchFormulas&&e.isFormula())return e.content;if(this.searchOptions.searchFormulas||!e.isFormula())return e.evaluated.value.toString()}return null}drawGrid(e){const{ctx:t}=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,s=o?o.top:e.row,a=o?o.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:s,left:n,right:r,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}vv.layers=[3],vv.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class bv extends wg{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,i){const o=this.searchNumberFormat(e,t);if(void 0!==o){const n=function(e,t){const i=Wt(e).map((e=>"NUMBER"===e.type?{...e,format:ii(e.format,t)}:e)),o=si(i);return Ht[o]=i,o}(o,i);this.dispatch("SET_FORMATTING",{sheetId:e,target:t,format:n})}}searchNumberFormat(e,t){var i;for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++){const o=this.getters.getCell(e,n,t);if((null==o?void 0:o.evaluated.type)===Ji.number&&!(null===(i=o.evaluated.format)||void 0===i?void 0:i.match(X)))return o.evaluated.format||ei(o.evaluated.value)}}}bv.modes=["normal"];class Sv extends wg{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,i){return"COL"===t?this.isColHidden(e,i):this.isRowHidden(e,i)}getNextVisibleCellPosition(e,t,i){return{col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",i,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,i,o){if(i<=o)for(let n=i;n<=o;n++)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n;if(i>o)for(let n=i;n>=o;n--)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n}findLastVisibleColRowIndex(e,t,i){let o;for(o=i.last;o>=i.first;o--)if(!this.isHeaderHidden(e,t,o))return o;return o}findFirstVisibleColRowIndex(e,t){const i=this.getters.getNumberHeaders(e,t);for(let o=0;o<i;o++){if("COL"===t&&!this.isColHidden(e,o))return o;if("ROW"===t&&!this.isRowHidden(e,o))return o}}exportForExcel(e){for(const t of e.sheets)for(const[e,i]of Object.entries(t.rows)){const o=this.isRowHidden(t.id,Number(e));i.isHidden=o}}}Sv.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class Cv extends wg{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{height:t,width:i}=Pi(e.zone),o=t*i==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:o}}))}drawGrid(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;const r=this.getHighlights();for(let e of r.filter(((e,t)=>r.findIndex((t=>_i(t.zone,e.zone)&&t.sheetId===o))===t))){const{x:i,y:o,width:r,height:s}=this.getters.getVisibleRect(e.zone);r>0&&s>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,r-n,s-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,r-2*n,s-2*n))}}}Cv.layers=[1],Cv.getters=["getHighlights"];class Ev extends wg{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleCols()),o=this.getters.getColRowOffsetInViewport("COL",i,t),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleRows()),o=this.getters.getColRowOffsetInViewport("ROW",i,t),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,i){let o=this.getters.getColRowOffsetInViewport(e,t,i);return this.getters.isDashboard()||(o+="ROW"===e?O:N),o}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:i}=e,{width:o,height:n}=this.getters.getSheetViewDimensionWithHeaders(),r=this.getters.getActiveSheetId();t.fillStyle="#ffffff",t.fillRect(0,0,o+m,n+m);const s=this.getters.getSheetViewVisibleCols(),a=s[0],l=s[s.length-1],c=this.getters.getSheetViewVisibleRows(),h=c[0],d=c[c.length-1];if(this.getters.getGridLinesVisibility(r)&&!this.getters.isDashboard()){t.lineWidth=2*i,t.strokeStyle="#E2E3E3",t.beginPath();for(const e of s){const i={top:h,bottom:d,left:e,right:e},{x:o,width:r,height:s}=this.getters.getVisibleRect(i);t.moveTo(o+r,0),t.lineTo(o+r,Math.min(n,s+(this.getters.isDashboard()?0:O)))}for(const e of c){const i={left:a,right:l,top:e,bottom:e},{y:n,width:r,height:s}=this.getters.getVisibleRect(i);t.moveTo(0,n+s),t.lineTo(Math.min(o,r+(this.getters.isDashboard()?0:N)),n+s)}t.stroke()}}drawCellBackground(e){const{ctx:t,thinLineWidth:i}=e,o=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());t.lineWidth=o?.3*i:i;const n=o?.1*i:0;t.strokeStyle="#111";for(let e of this.boxes){let r=e.style;(r.fillColor&&"#ffffff"!==r.fillColor||e.isMerge)&&(t.fillStyle=r.fillColor||"#ffffff",o?(t.fillRect(e.x,e.y,e.width,e.height),t.strokeRect(e.x+n,e.y+n,e.width-2*n,e.height-2*n)):t.fillRect(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:i}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:n,width:r,height:s}=e;t.left&&o(t.left,i,n,i,n+s),t.top&&o(t.top,i,n,i+r,n),t.right&&o(t.right,i+r,n,i+r,n+s),t.bottom&&o(t.bottom,i,n+s,i+r,n+s)}}function o([e,o],n,r,s,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*i,t.beginPath(),t.moveTo(n,r),t.lineTo(s,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:i}=e;let o;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},r=e.content.align||"left",s=Fe(n);let a;s!==o&&(o=s,t.font=s),t.fillStyle=n.textColor||"#000";let l=e.y+e.height/2+1;if(a="left"===r?e.x+(e.image?e.image.size+2*L:P):"right"===r?e.x+e.width-P-(e.isFilterHeader?20:0):e.x+e.width/2,t.textAlign=r,e.clipRect){t.save(),t.beginPath();const{x:i,y:o,width:n,height:r}=e.clipRect;t.rect(i,o,n,r),t.clip()}const c=e.content.multiLineText.length,h=De(n);let d=l-(c*(h+P)-P)/2;for(let o of e.content.multiLineText){if(t.fillText(o,Math.round(a),Math.round(d)),n.strikethrough||n.underline){const e=Ne(t,o,n);let s=a;"right"===r?s-=e:"center"===r&&(s-=e/2),n.strikethrough&&t.fillRect(s,d+h/2,e,2.6*i),n.underline&&t.fillRect(s,d+h+1,e,1.3*i)}d+=P+h}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const i=e.image.image,o=e.image.size,n=(e.height-o)/2;if(e.image.clipIcon){t.save(),t.beginPath();const{x:i,y:o,width:n,height:r}=e.image.clipIcon;t.rect(i,o,n,r),t.clip()}t.drawImage(i,e.x+L,e.y+n,o,o),e.image.clipIcon&&t.restore()}}drawHeaders(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getSheetViewVisibleCols(),n=o[0],r=o[o.length-1],s=this.getters.getSheetViewVisibleRows(),a=s[0],l=s[s.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let i of e)for(let e of ke(i.left,i.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let i of e)for(let e of ke(i.top,i.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${q}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333";for(let e=n;e<=r;e++){const i={left:e,right:e,top:0,bottom:f-1},{x:o,width:n}=this.getters.getVisibleRect(i),r=this.getters.doesZonesContainFilter(p,[i]),s=E.has(e),a=u.has(e);t.fillStyle=s?r?I:S:a?r?A:b:r?T:v,t.fillRect(o,0,n,O)}for(let e=a;e<=l;e++){const i={top:e,bottom:e,left:0,right:m-1},{y:o,height:n}=this.getters.getVisibleRect(i),r=this.getters.doesZonesContainFilter(p,[i]),s=w.has(e),a=g.has(e);t.fillStyle=s?r?I:S:a?r?A:b:r?T:v,t.fillRect(0,o,N,n)}t.beginPath(),t.moveTo(N,0),t.lineTo(N,h),t.moveTo(0,O),t.lineTo(c,O),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of o){const i=this.getters.getColSize(p,e),o=_t(e);t.fillStyle=E.has(e)?"#fff":C;let r=this.getHeaderOffset("COL",n,e);t.fillText(o,r+i/2,13),t.moveTo(r+i,0),t.lineTo(r+i,O)}for(const e of s){const i=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let o=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,o+i/2),t.moveTo(0,o+i),t.lineTo(N,o+i)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),r=this.getters.isDashboard()?0:N,s=this.getters.isDashboard()?0:O;t.lineWidth=6*i,t.strokeStyle="#BCBCBC",t.beginPath(),o&&(t.moveTo(r+o,0),t.lineTo(r+o,s)),n&&(t.moveTo(0,s+n),t.lineTo(r,s+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),r=this.getters.getSheetViewVisibleCols(),s=r[0],a=r[r.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:s,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:N,u=this.getters.isDashboard()?0:O;t.lineWidth=6*i,t.strokeStyle="#DADFE8",t.beginPath(),o&&(t.moveTo(d+o,u),t.lineTo(d+o,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}hasContent(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getCell(i,e,t);return o&&!o.isEmpty()||this.getters.isInMerge(i,e,t)}findNextEmptyCol(e,t,i){let o=e;for(;o<t&&!this.hasContent(o+1,i);)o++;return o}findPreviousEmptyCol(e,t,i){let o=e;for(;o>t&&!this.hasContent(o-1,i);)o--;return o}computeCellAlignment(e,t){if(e.isFormula()&&this.getters.shouldShowFormulas())return"left";const{align:i}=this.getters.getCellStyle(e);return t&&e.evaluated.type===Ji.number?"center"!==i?"left":i:i||e.defaultAlign}createZoneBox(e,t,i){const{left:o,right:n}=i,r=t.left,s=t.top,a=this.getters.getCell(e,r,s),c=this.getters.shouldShowFormulas(),{x:h,y:d,width:u,height:g}=this.getters.getVisibleRect(t),p={x:h,y:d,width:u,height:g,border:this.getters.getCellBorderWithFilterBorder(e,r,s)||void 0,style:this.getters.getCellComputedStyle(e,r,s)};if(!a)return p;const m=this.getters.getConditionalIcon(r,s),f=De(p.style),v=m?2*L+f:0;m&&(p.image={type:"icon",size:f,clipIcon:{x:p.x,y:p.y,width:Math.min(v,u),height:g},image:ts[m].img}),p.isFilterHeader=this.getters.isFilterHeader(e,r,s);const b=p.isFilterHeader?19:0,S=this.getters.getCellText(a,c),C=this.getters.getTextWidth(a),E=this.getters.getCellStyle(a).wrapping||"overflow",w="wrap"===E?this.getters.getCellMultiLineText(a,u-2*P):[S],y=v+C+b,x=this.computeCellAlignment(a,y>u);p.content={multiLineText:w,width:"overflow"===E?C:u,align:x},a.evaluated.type===Ji.error&&a.evaluated.error.logLevel>l.silent&&(p.error=a.evaluated.error.message);const R=y>u||f>g;if(m||p.isFilterHeader)p.clipRect={x:p.x+v,y:p.y,width:Math.max(0,u-v-b),height:g};else if(R&&"overflow"===E){let i,a;switch(this.getters.isInMerge(e,r,s)?(i=this.getters.getMerge(e,r,s).right,a=r):(i=this.findNextEmptyCol(r,n,s),a=this.findPreviousEmptyCol(r,o,s)),x){case"left":{const e=Wi({col:i,row:s}),{x:o,y:n,width:r,height:a}=this.getters.getVisibleRect(Oi(t,e));(r<C||f>a)&&(p.clipRect={x:o,y:n,width:r,height:a});break}case"right":{const e=Wi({col:a,row:s}),{x:i,y:o,width:n,height:r}=this.getters.getVisibleRect(Oi(t,e));(n<C||f>r)&&(p.clipRect={x:i,y:o,width:n,height:r});break}case"center":{const e={...t,right:i,left:a},{x:o,y:n,width:s,height:l}=this.getters.getVisibleRect(e);(s<C||a===r||i===r||f>l)&&(p.clipRect={x:o,y:n,width:s,height:l});break}}}else"clip"!==E&&"wrap"!==E||(p.clipRect={x:p.x,y:p.y,width:u,height:g});return p}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),i=t[0],o=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),r={left:i,right:o,top:n[0],bottom:n[n.length-1]},s=this.getters.getActiveSheetId();for(const i of n)for(const o of t)this.getters.isInMerge(s,o,i)||e.push(this.createZoneBox(s,Wi({col:o,row:i}),r));for(const t of this.getters.getMerges(s))if(!this.getters.isMergeHidden(s,t)&&Fi(t,r)){const i=this.createZoneBox(s,t,r),o=this.getters.getCellBorder(s,t.right,t.bottom);i.border={...i.border,bottom:o?o.bottom:void 0,right:o?o.right:void 0},i.isMerge=!0,e.push(i)}return e}}Ev.layers=[0,7],Ev.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];const wv=[{name:r("Sum"),types:[Ji.number],compute:e=>ja.compute([e])},{name:r("Avg"),types:[Ji.number],compute:e=>rl.compute([e])},{name:r("Min"),types:[Ji.number],compute:e=>wl.compute([e])},{name:r("Max"),types:[Ji.number],compute:e=>bl.compute([e])},{name:r("Count"),types:[Ji.number,Ji.text,Ji.boolean,Ji.error],compute:e=>gl.compute([e])},{name:r("Count Numbers"),types:[Ji.number,Ji.text,Ji.boolean,Ji.error],compute:e=>ul.compute([e])}];class yv extends wg{constructor(e,t,i,o,n){super(e,t,i,o,n),this.gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]},this.selectedFigureId=null,this.sheetsData={},this.activeSheet=null,this.moveClient=o.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 27}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let i=[];switch(e.mode){case"overrideSelection":i=[t.zone];break;case"updateAnchor":i=[...this.gridSelection.zones];const o=i.findIndex((t=>_i(t,e.previousAnchor.zone)));o>=0&&(i[o]=t.zone);break;case"newAnchor":i=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,i),this.selection.resetDefaultAnchor(this,Te(this.gridSelection.anchor));const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:o,row:n}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:i,row:o}=this.getters.getNextVisibleCellPosition(t,0,0);this.selectCell(i,o),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:Te(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Te(this.gridSelection.anchor));else{const{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0);this.selectCell(t,i)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const n=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of n)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Te(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:i})}const r=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(r,e))),this.gridSelection.anchor.zone=this.getters.expandZone(r,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,Te(this.gridSelection.anchor))}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){const e=this.getters.getActiveSheetId(),{col:t,row:i}=this.gridSelection.anchor.cell,{col:o,row:n}=this.getters.getMainCellPosition(e,t,i);return this.getters.getCell(e,o,n)}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let i=t.left;i<=t.right;i++)e.add(i);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let i of this.gridSelection.zones)if(0===i.left&&i.right===this.getters.getNumberCols(t)-1)for(let t=i.top;t<=i.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getActiveCell();return e?this.getters.getCellStyle(e):{}}getSelectedZones(){return Te(this.gridSelection.zones)}getSelectedZone(){return Te(this.gridSelection.anchor.zone)}getSelection(){return Te(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getPosition(){return{col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row}}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getPosition();{const t=this.sheetsData[e];return t?{col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition(e,0,0)}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>void 0!==e)));let t=new Set,i=[];for(let o of e)t.add(o.evaluated.type),i.push(o.evaluated.value);let o={};for(let e of wv){let n;e.types.some((e=>t.has(e)))&&(n=e.compute(i)),o[e.name]=n}return o}getAggregate(){let e=0,t=0;const i=this.getters.getActiveSheetId(),o=this.gridSelection.zones.map(Vi).flat();for(const{col:n,row:r}of o){const o=this.getters.getCell(i,n,r);(null==o?void 0:o.evaluated.type)===Ji.number&&(t++,e+=o.evaluated.value)}return t<2?null:Gt(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>_i(t,e)))}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 i=[];const o="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[o]+1},((t,i)=>e[o]+i));i=i.concat(t)}return[...new Set(i)].sort()}setSelectionMixin(e,t){const{anchor:i,zones:o}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=i,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,i)=>t===i.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(o)}selectCell(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.expandZone(i,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:o,cell:{col:e,row:t}},[o])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),i=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[i]})}onColumnsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Ai(i,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Ai(n,"left",[...e.elements]);const r={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(r,[o])}onRowsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Ai(i,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Ai(n,"top",[...e.elements]);const r={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(r,[o])}onAddElements(e){const t=Ti(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(i,[t])}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 i="COL"===e.dimension,o=e.elements[0],n=e.elements[t-1],r=e.base<o,s=r&&i?t:0,a=r&&!i?t:0;this.dispatch("CUT",{target:[{left:i?o+s:0,right:i?n+s:this.getters.getNumberCols(e.sheetId)-1,top:i?0:o+a,bottom:i?this.getters.getNumberRows(e.sheetId)-1:n+a}]}),this.dispatch("PASTE",{target:[{left:i?e.base:0,right:i?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:i?0:e.base,bottom:i?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=r?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const i="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:i,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,i=e.elements[0],o=e.elements[e.elements.length-1],n=e.sheetId,r=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return r(n,i-1,i)||r(n,o,o+1)||r(n,e.base-1,e.base)?2:0}clipSelection(e,t){const i=this.getters.getNumberCols(e)-1,o=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:Oe(e.left,0,i),right:Oe(e.right,0,i),top:Oe(e.top,0,o),bottom:Oe(e.bottom,0,o)}))),anchor:{cell:{col:Oe(t.anchor.cell.col,0,i),row:Oe(t.anchor.cell.row,0,o)},zone:{left:Oe(t.anchor.zone.left,0,i),right:Oe(t.anchor.zone.right,0,i),top:Oe(t.anchor.zone.top,0,o),bottom:Oe(t.anchor.zone.bottom,0,o)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*i,t.globalCompositeOperation="multiply";for(const e of o){const{x:i,y:o,width:n,height:r}=this.getters.getVisibleRect(e);t.fillRect(i,o,n,r),t.strokeRect(i,o,n,r)}t.globalCompositeOperation="source-over";const r=this.getters.getActiveSheetId(),{col:s,row:a}=this.getPosition();let l;t.strokeStyle=E,t.lineWidth=3*i,l=this.getters.isInMerge(r,s,a)?this.getters.getMerge(r,s,a):{top:a,bottom:a,left:s,right:s};const{x:c,y:h,width:d,height:u}=this.getters.getVisibleRect(l);d>0&&u>0&&t.strokeRect(c,h,d,u)}}yv.layers=[5],yv.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getPosition","getSheetPosition","isSelected","getElementsFromSelection"];const xv=new Ei;class Rv extends wg{constructor(e,t,i,o,n,r,s){if(s&&r.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e,t,i,o,n),this.inputHasSingleRange=s,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,r),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){switch(e.type){case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange&&1===this.ranges.length)return 29;break;case"CHANGE_RANGE":if(this.inputHasSingleRange&&e.value.split(",").length>1)return 29}return 0}handleEvent(e){const t=Ri(e.anchor.zone),i=this.activeSheet,o=this.getters.getActiveSheetId(),n=this.getters.getSheetName(o);this.add([o===i?t:`${Me(n)}!${t}`])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const i=e.value.split(",").map((e=>e.trim()));this.setRange(t,i)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),o=this.getters.expandZone(e.sheetIdTo,Wi({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}}}unsubscribe(){this.unfocus()}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],id:xv.uuidv4(),xc:t}}insertNewRange(e,t){this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:(this.ranges.length+t+1).toString(),color:(dt=++dt%ct.length,ct[dt])}))))}setRange(e,t){const[,...i]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,i),i.length&&this.focus(e+i.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const i=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return i.map((e=>{const{sheetName:i}=Nt(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:i&&this.getters.getSheetIdByName(i)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:i}=Nt(t),o=this.getters.getSheetIdByName(i),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(o===n||void 0===o&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}Rv.layers=[1],Rv.getters=[];class Iv extends wg{get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e,t,i,o,n){super(e,t,i,o,n),this.state=t,this.config=o,this.inputs={},this.focusedInputId=null}allowDispatch(e){var t,i;if("FOCUS_RANGE"===e.type){const o=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(i=this.currentInput)||void 0===i?void 0:i.focusedRangeIndex)===o)return 28}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){var t;switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:Wi({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}unsubscribe(){this.unfocus()}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,i)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===i}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:i}=Nt(e);return null!==t.match(It)&&(!i||void 0!==this.getters.getSheetIdByName(i))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,i=!1){if(this.inputs[e]=new Rv(this.getters,this.state,this.dispatch,this.config,this.selection,t,i),0===t.length){const t=this.inputs[e],i={zone:Wi({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,i,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}Iv.layers=[1],Iv.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class Tv{constructor(){this.subscriptions={}}on(e,t,i){if(!i)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:i})}trigger(e,t){const i=this.subscriptions[e]||[];for(let e=0,o=i.length;e<o;e++){const o=i[e];o.callback.call(o.owner,t)}}off(e,t){const i=this.subscriptions[e];i&&(this.subscriptions[e]=i.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function Av(e,t){return{...e,definition:Er(e.definition,t)}}function Mv(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let i=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)i>t&&i--}if("ADD_COLUMNS_ROWS"===t.type){i=i>("before"===t.position?t.base-1:t.base)?i+t.quantity:i}return i>0?{...e,quantity:i}:void 0}Hn.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Av),Hn.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Av),Hn.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const i=t.sheetId;if(e.targetSheetId===i||e.sheetId===i)return;return e})),Hn.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),Hn.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var i;if(e.name===t.name)return{...e,name:(null===(i=e.name)||void 0===i?void 0:i.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),Hn.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const i=[];for(const o of e.target)for(const e of t.target)Fi(o,e)||i.push({...o});if(i.length)return{...e,target:i};return})),Hn.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Mv),Hn.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Mv),Hn.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const i of e.target)for(const e of t.target)if(Fi(e,i))return;return e}));const Ov=[{match:function(e){return"sheetId"in e},fn:Fv},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const i=Fv(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;const o=[];for(const i of e.target){const e=Yn(i,t);e&&o.push(e)}if(!o.length)return"IGNORE_COMMAND";return{...e,target:o}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const i=Fv(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const i="COL"===t.dimension?"col":"row";let o=e[i];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[i]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const i of t.target){if(!(e.col===i.left&&e.row===i.top)&&Di(e.col,e.row,i))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const i=Fv(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const i="ADD_COLUMNS_ROWS"===e.type,o=i?"base":"elements";let n=i?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const i=t.elements.sort(((e,t)=>t-e));for(let t of i)e>t&&e--;return e})).filter(Xe)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((i=>i>e?i+t.quantity:i))}if(n.length){let t=n;return i&&(t=n[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const i=[],o="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)i.push({...n,_zone:n._zone});else{const e=Yn(n._zone,t);e&&o!==n._sheetId&&i.push({...n,_zone:e})}if(!i.length)return"IGNORE_COMMAND";return{...e,ranges:i}}}];function Nv(e,t){const i=Hn.getTransformation(e.type,t.type);return i?i(e,t):function(e,t){for(const{match:i,fn:o}of Ov)if(i(e)){const i=o(e,t);if("SKIP_TRANSFORMATION"===i)continue;if("IGNORE_COMMAND"===i)return;e=i}return e}(e,t)}function _v(e,t){let i=[...e];for(const e of t)i=i.map((t=>Nv(t,e))).filter(Xe);return i}function Fv(e,t){const i="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===i?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class Dv{constructor(e,t,i,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...i],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class kv extends Error{}class $v extends Tv{constructor(e,t,i=K){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=i,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Ei,this.debouncedMove=Je(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const i=new Dv(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new kv("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(Xe))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const i=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==i?void 0:i.col)===e.col&&i.row===e.row&&i.sheetId===e.sheetId)return;const o=i?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:o,version:1,client:{...n,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:i}=e,o=new Dv(e.nextRevisionId,t,i);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:_v(i,t)})}break;case"SNAPSHOT_CREATED":{const t=new Dv(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){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Lv=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class Pv extends wg{constructor(){super(...arguments),this.availableColors=new Set(Lv),this.colors={}}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(Lv));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 kv)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const i of this.getters.getConnectedClients())if(i.id!==this.getters.getClient().id&&i.position&&i.position.sheetId===e&&this.isPositionValid(i.position)){const e=i.position;this.colors[i.id]||(this.colors[i.id]=this.chooseNewColor());const o=this.colors[i.id];t.push({...i,position:e,color:o})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:r}=e.position,s=this.getters.expandZone(o,{top:n,bottom:n,left:r,right:r}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(s);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*i,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${G+1}px ${q}`}}}Pv.getters=["getClientsToDisplay"],Pv.layers=[5];class Uv{constructor(e,t,i,o,n,r){this.getters=e,this.sheetId=t,this.boundaries=i,this.viewportWidth=o.width,this.viewportHeight=o.height,this.offsetScrollbarX=r.x,this.offsetScrollbarY=r.y,this.canScrollVertically=n.canScrollVertically,this.canScrollHorizontally=n.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const e=this.getters.findLastVisibleColRowIndex(this.sheetId,"COL",{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,"ROW",{first:this.boundaries.top,last:this.boundaries.bottom}),{end:i,size:o}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:r}=this.getters.getRowDimensions(this.sheetId,t),s=this.searchHeaderIndex("COL",i-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,s),l=this.searchHeaderIndex("ROW",n-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=i-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(_,Math.min(a,this.viewportWidth-o)),h=Math.max(h,this.viewportWidth));let d=n-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(F+5,Math.min(c,this.viewportHeight-r)),d=Math.max(d,this.viewportHeight)),{width:h,height:d}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const i=this.getters.getMainCellPosition(t,e.col,e.row),{col:o,row:n}=this.getters.getNextVisibleCellPosition(t,i.col,i.row);Di(o,this.boundaries.top,this.boundaries)&&this.adjustPositionX(o),Di(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{end:i}=this.getters.getColDimensions(t,e),o=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<i)for(let e=this.left;this.offsetX+this.offsetCorrectionX+this.viewportWidth<i&&!(e>o);e++)this.getters.isColHidden(t,e)||(this.offsetX=this.getters.getColDimensions(t,e).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX());else if(this.left>e)for(let i=this.left;i>=e&&!(i<0);i--)this.getters.isColHidden(t,i)||(this.offsetX=this.getters.getColDimensions(t,i).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX())}adjustPositionY(e){const t=this.sheetId,{end:i}=this.getters.getRowDimensions(t,e),o=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<i)for(let e=this.top;this.offsetY+this.viewportHeight+this.offsetCorrectionY<i&&!(e>o);e++)this.getters.isRowHidden(t,e)||(this.offsetY=this.getters.getRowDimensions(t,e).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY());else if(this.top>e)for(let i=this.top;i>=e&&!(i<0);i--)this.getters.isRowHidden(t,i)||(this.offsetY=this.getters.getRowDimensions(t,i).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY())}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=Ni(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.viewportWidth),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.viewportHeight)}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,i=0,o=!1){let n=0;const r=this.sheetId,s=this.getters.getNumberHeaders(r,e);for(let a=i;a<=s-1;a++){const i=o||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(r,e,a)&&!i&&(n+="COL"===e?this.getters.getColSize(r,a):this.getters.getRowSize(r,a),n>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportWidth,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.viewportWidth,this.left)),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.viewportHeight,this.top)),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}class Vv extends wg{constructor(){super(...arguments),this.viewports={},this.sheetViewWidth=1e3,this.sheetViewHeight=1e3,this.gridOffsetX=0,this.gridOffsetY=0,this.sheetsWithDirtyViewports=new Set}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){switch(e.type){case"HeadersSelected":case"AlterZoneCorner":break;case"ZonesSelected":let{col:t,row:i}=Bi(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const o=e.previousAnchor.zone,n=e.anchor.zone,{top:r,bottom:s,left:a,right:l}=this.getters.getActiveMainViewport();o.left===n.left&&o.right===n.right&&(t=a>t||t>l?a:t),o.top===n.top&&o.bottom===n.bottom&&(i=r>i||i>s?r:i)}const o=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(o)-1),i=Math.min(i,this.getters.getNumberRows(o)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:i})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:i}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(o,i).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(i);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"START_EDITION":const{col:r,row:s}=this.getters.getPosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:r,row:s})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){var e;const t=this.getters.getSheetIds();for(const i of t)(null===(e=this.viewports[i])||void 0===e?void 0:e.bottomRight)||this.resetViewports(i)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>ke(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>ke(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);let{width:n,height:r}=t.getMaxSize();return{x:this.getters.getColDimensions(e,i).start,y:this.getters.getRowDimensions(e,o).start,width:n,height:r}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:i}=this.getMainViewportRect(),o=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-o.viewportWidth+1),maxOffsetY:Math.max(0,i-o.viewportHeight+1)}}getColRowOffsetInViewport(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),r=this.getters.getSheetViewVisibleRows();if(i<t)return-this.getColRowOffsetInViewport(e,i,t);let s=0;const a="COL"===e?n:r;for(let n=t;n<i;n++)a.includes(n)&&(s+="COL"===e?this.getters.getColSize(o,n):this.getters.getRowSize(o,n));return s}isVisibleInViewport(e,t,i){return this.getSubViewports(e).some((e=>e.isVisible(t,i)))}getEdgeScrollCol(e,t,i){let o=!1,n=0,r=0;const{xSplit:s}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(o=!0,r=Ut(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,r=Ut(l-e),n=-1):s&&t<l&&e>l&&(o=!0,r=Ut(e),n="reset"),{canEdgeScroll:o,direction:n,delay:r}}getEdgeScrollRow(e,t,i){let o=!1,n=0,r=0;const{ySplit:s}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(o=!0,r=Ut(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,r=Ut(l-e),n=-1):s&&t<l&&e>l&&(o=!0,r=Ut(e),n="reset"),{canEdgeScroll:o,direction:n,delay:r}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),i=this.getSubViewports(t).map((t=>t.getRect(e))).filter(Xe);if(0===i.length)return{x:0,y:0,width:0,height:0};const o=Math.min(...i.map((e=>e.x))),n=Math.min(...i.map((e=>e.y))),r=Math.max(...i.map((e=>e.x+e.width)))-o,s=Math.max(...i.map((e=>e.y+e.height)))-n;return{x:o+this.gridOffsetX,y:n+this.gridOffsetY,width:r,height:s}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,i).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(Xe)}checkPositiveDimension(e){return e.width<0||e.height<0?67:0}checkValuesAreDifferent(e){const{height:t,width:i}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===i&&e.height===t?75:0}checkScrollingDirection({offsetX:e,offsetY:t}){const i=this.getMainInternalViewport(this.getters.getActiveSheetId());return!i.canScrollHorizontally&&e>0||!i.canScrollVertically&&t>0?68:0}getMainViewport(e){const t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const i=this.getSubViewports(e);Object.values(i).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,i=0,o=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=i,this.gridOffsetY=o,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const i=this.getters.getActiveSheetId(),{maxOffsetX:o,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(i)).forEach((i=>i.setViewportOffset(Oe(e,0,o),Oe(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),i=t-this.sheetViewHeight;return e=Math.min(e,i),e=Math.max(e,0)}getViewportOffset(e){var t,i;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(i=this.viewports[e])||void 0===i?void 0:i.bottomRight.offsetScrollbarY)||0}}resetViewports(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),r=this.getters.getColRowOffset("COL",0,t,e),s=this.getters.getColRowOffset("ROW",0,i,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:i&&t&&new Uv(this.getters,e,{left:0,right:t-1,top:0,bottom:i-1},{width:r,height:s},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:i&&new Uv(this.getters,e,{left:t,right:o-1,top:0,bottom:i-1},{width:this.sheetViewWidth-r,height:s},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Uv(this.getters,e,{left:0,right:t-1,top:i,bottom:n-1},{width:r,height:this.sheetViewHeight-s},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Uv(this.getters,e,{left:t,right:o-1,top:i,bottom:n-1},{width:this.sheetViewWidth-r,height:this.sheetViewHeight-s},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:i}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(i,e);const{anchor:o}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(o.cell.col,o.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],i=this.getters.getFigures(e),{scrollX:o,scrollY:n}=this.getActiveSheetScrollInfo(),{x:r,y:s}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of i)e.x>=r&&(e.x+e.width<=r+o||e.x>=a+o+r)||e.y>=s&&(e.y+e.height<=s+n||e.y>=l+n+s)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,i).start;return{xRatio:o/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}Vv.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class zv extends wg{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Di(e.col,e.row,e.zone))throw new Error(r("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;for(let i=t.top;i<=t.bottom;i++)for(let o=t.left;o<=t.right;o++)if(!this.getters.isInMerge(e,o,i))return 62;return 0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const i=this.getters.getMerges(e).filter((e=>Fi(e,t))),o=Pi(i[0]);let[n,r]=[o.width,o.height];return i.every((e=>{let[t,i]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&i===r}))?0:62}expand(e,t){const{left:i,right:o,top:n,bottom:r}=this.getters.expandZone(e,t);return{left:Math.max(0,i),right:Math.min(this.getters.getNumberCols(e)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,r)}}checkExpandedValues(e,t){const i=this.expand(e,t);let o;if(this.getters.doesIntersectMerge(e,i)){const{left:t,right:n,top:r,bottom:s}=i;for(let i=t;i<=n;i++)for(let t=r;t<=s;t++){const{col:n,row:r}=this.getters.getMainCellPosition(e,i,t);if(o=this.getters.getCell(e,n,r),null==o?void 0:o.formattedValue)return!0}}else for(let t of this.getters.getCellsInZone(e,i))if(null==t?void 0:t.formattedValue)return!0;return!1}getContiguousZone(e,t){let i,{top:o,bottom:n,left:r,right:s}=t,a=!1;for(;!a;)a=!0,o>0&&(i=this.checkExpandedValues(e,{left:r-1,right:s+1,top:o-1,bottom:o-1}),i&&(a=!1,o--)),r>0&&(i=this.checkExpandedValues(e,{left:r-1,right:r-1,top:o-1,bottom:n+1}),i&&(a=!1,r--)),s<this.getters.getNumberCols(e)-1&&(i=this.checkExpandedValues(e,{left:s+1,right:s+1,top:o-1,bottom:n+1}),i&&(a=!1,s++)),n<this.getters.getNumberRows(e)-1&&(i=this.checkExpandedValues(e,{left:r-1,right:s+1,top:n+1,bottom:n+1}),i&&(a=!1,n++));return{left:r,right:s,top:o,bottom:n}}hasHeader(e){if(1===e[0].length)return!1;let t=e.map((e=>e.map((e=>(null==e?void 0:e.evaluated.type)||Ji.empty))));return t[0][0]===Ji.empty&&(t=t.slice(1)),!t.some((e=>e[0]===Ji.empty))&&!!t.some((e=>e[1]!==Ji.empty&&e[0]!==e[1]))}sortZone(e,t,i,o,n){const[r,s]=this.mainCellsSteps(e,i);let a=this.getters.getMainCellPosition(e,t.col,t.row).col,l=Object.assign({},i),c=this.mainCells(e,i);!n.sortHeaders&&this.hasHeader(c)&&(l.top+=s),c=this.mainCells(e,l);const h=function(e,t,i){const o=e.map(Go);let n=o.filter((e=>e.type===Ji.empty)),r=o.filter((e=>e.type!==Ji.empty));i&&(r.push(...n.map((e=>({...e,type:Ji.number,value:0})))),n=[]);const s="descending"===t?-1:1;return r.sort(((e,t)=>{let i=Wo.indexOf(e.type)-Wo.indexOf(t.type);return 0===i&&(i=e.type===Ji.text||e.type===Ji.error?e.value.localeCompare(t.value):e.value-t.value),s*i})).concat(n)}(c[a-l.left],o,Boolean(n.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let t=0;t<u;t++)for(let i=0;i<g;i++){let o=c[t][d[i]],n=l.left+t*r,a=l.top+i*s,h={sheetId:e,col:n,row:a,content:""};if(o){let t=o.content;if(o.isFormula()){const i=a-this.getters.getCellPosition(o.id).row,n=this.getters.createAdaptedRanges(o.dependencies,0,i,e);t=this.getters.buildFormulaContent(e,o,n)}h.style=o.style,h.content=t,h.format=o.format}p.push(h)}p.forEach((e=>this.dispatch("UPDATE_CELL",e)))}mainCellsSteps(e,t){const i=this.getters.getMerge(e,t.left,t.top);return[i?i.right-i.left+1:1,i?i.bottom-i.top+1:1]}mainCells(e,t){const[i,o]=this.mainCellsSteps(e,t),n=[],r=ke(t.left,t.right+1,i),s=ke(t.top,t.bottom+1,o);for(const t of r){const i=[];n.push(i);for(const o of s)i.push(this.getters.getCell(e,t,o))}return n}}zv.getters=["getContiguousZone"];class Bv extends wg{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}Bv.getters=["shouldShowFormulas"];class Hv extends wg{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const i=this.getColMaxWidth(e.sheetId,t);0!==i&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:i,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e,{col:t,row:i}){const o=this.getters.getCell(e,t,i);let n=0;o&&(n+=this.getTextWidth(o));this.getters.getConditionalIcon(t,i)&&(n+=De(this.getters.getCellStyle(o))+2*L);if(this.getters.isFilterHeader(e,t,i)&&(n+=20),n>0&&(n+=2*V,"wrap"===this.getters.getCellStyle(o).wrapping)){const e=Wi({col:t,row:i}),o=this.getters.getColSize(this.getters.getActiveSheetId(),e.left);return Math.min(o,n)}return n}getTextWidth(e){const t=this.getters.getCellText(e,this.getters.shouldShowFormulas()),{sheetId:i,col:o,row:n}=this.getters.getCellPosition(e.id);return Ne(this.ctx,t,this.getters.getCellComputedStyle(i,o,n))}getCellText(e,t=!1){return t&&(e.isFormula()||e.evaluated.type===Ji.error)?e.content:e.formattedValue}getCellMultiLineText(e,t){const i=this.getters.getCellStyle(e),o=this.getters.getCellText(e).split(" "),n=[];let r="",s=t;for(let e of o){const o=this.splitWordToSpecificWidth(this.ctx,e,t,i),a=o.pop(),l=Ne(this.ctx,a,i);if(o.length)""!==r&&(n.push(r),r="",s=t),o.forEach((e=>{n.push(e)})),r=a,s=t-l;else{const e=""===r?a:" "+a,o=Ne(this.ctx,e,i);o<=s?(r+=e,s-=o):(n.push(r),r=a,s=t-l)}}return""!==r&&n.push(r),n}getColDimensions(e,t){const i=this.getColRowOffset("COL",0,t,e),o=this.getters.getColSize(e,t);return{start:i,size:o,end:i+(this.getters.isColHidden(e,t)?0:o)}}getRowDimensions(e,t){const i=this.getColRowOffset("ROW",0,t,e),o=this.getters.getRowSize(e,t);return{start:i,size:o,end:i+(this.getters.isRowHidden(e,t)?0:o)}}getColRowOffset(e,t,i,o=this.getters.getActiveSheetId()){if(i<t)return-this.getColRowOffset(e,i,t);let n=0;for(let r=t;r<i;r++)this.getters.isHeaderHidden(o,e,r)||(n+="COL"===e?this.getters.getColSize(o,r):this.getters.getRowSize(o,r));return n}getColMaxWidth(e,t){const i=Vi(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth(e,t)));return Math.max(0,...i)}splitWordToSpecificWidth(e,t,i,o){if(Ne(e,t,o)<=i)return[t];const n=[];let r="";for(let s of t){Ne(e,r+s,o)>i?(n.push(r),r=s):r+=s}return n.push(r),n}}Hv.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];const Wv=(new ji).add("sheet",ev).add("header visibility",Yf).add("filters",jf).add("cell",zf).add("merge",Kf).add("headerSize",Xf).add("borders",Uf).add("conditional formatting",Wf).add("figures",Gf).add("chart",Bf),Gv=(new ji).add("selection",yv).add("ui_sheet",Hv).add("header_visibility_ui",Sv).add("ui_options",Bv).add("evaluation",uv).add("evaluation_filter",mv).add("evaluation_cf",pv).add("evaluation_chart",gv).add("clipboard",cv).add("edition",xg).add("selectionInputManager",Iv).add("highlight",Cv).add("viewport",Vv).add("grid renderer",Ev).add("autofill",iv).add("find_and_replace",vv).add("sort",zv).add("automatic_sum",ov).add("format",bv).add("cell_popovers",nv).add("selection_multiuser",Pv).add("custom_colors",hv),qv=new ji;qv.add("link",{condition:e=>e.isLink(),action:(e,t)=>{e.action(t)},sequence:5}),go`
1391
+ `}function uf(e){return new yp(e.join("\n"))}function gf(e,...t){let i=[e[0]];for(let o=0;o<t.length;o++){const n=t[o]instanceof yp?t[o]:lf(t[o]);i.push(n+e[o+1])}return new yp(et(i))}function pf(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function mf(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class ff{constructor(e){this.value=e}asString(){return um(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class vf{constructor(e,t,i){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=i,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(Xe)}mapOnElements(e,t){var i;const o=[],n=this.currentFile;let r;if(e.children){const t=null===(i=this.querySelector(e.parent,e.query))||void 0===i?void 0:i.children;r=t||[]}else r=this.querySelectorAll(e.parent,e.query);if(r)for(let e of r)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,o}catchErrorOnElement(e,t){const i=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([i,e.message].join("\n"))}extractAttr(e,t,i){const o=e.attributes[t];o||this.handleMissingValue(e,`attribute "${t}"`,i);const n=(null==o?void 0:o.value)?o.value:null==i?void 0:i.default;return void 0===n?void 0:new ff(n)}extractTextContent(e,t){var i;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===(null===(i=null==e?void 0:e.attributes["xml:space"])||void 0===i?void 0:i.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=o?n:n.trim()),n?um(n):null==t?void 0:t.default}extractChildAttr(e,t,i,o){var n;let r;r="number"==typeof t?e.children[t]:this.querySelector(e,t),r||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,o);const s=r?null===(n=this.extractAttr(r,i,o))||void 0===n?void 0:n.asString():null==o?void 0:o.default;return void 0!==s?new ff(s):void 0}extractChildTextContent(e,t,i){if(void 0!==(null==i?void 0:i.default)&&"string"!=typeof i.default)throw new Error("extractTextContent default value should be a string");let o=this.querySelector(e,t);return o||this.handleMissingValue(e,`child <${t}>`,i),o?this.extractTextContent(o,i):null==i?void 0:i.default}handleMissingValue(e,t,i){if(null==i?void 0:i.required){if(!(null==i?void 0:i.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${i.default}`)}}extractColor(e,t,i){var o,n,r,s,a;if(!e)return i?{rgb:i}:void 0;const l=null===(o=this.extractAttr(e,"theme"))||void 0===o?void 0:o.asString();let c;if(void 0!==l){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");c=this.getThemeColor(l,t.clrScheme)}else c=null===(n=this.extractAttr(e,"rgb"))||void 0===n?void 0:n.asString();return{rgb:c,auto:null===(r=this.extractAttr(e,"auto"))||void 0===r?void 0:r.asBool(),indexed:null===(s=this.extractAttr(e,"indexed"))||void 0===s?void 0:s.asNum(),tint:null===(a=this.extractAttr(e,"tint"))||void 0===a?void 0:a.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");let t=e.target;t=t.replace("../",""),t=t.replace("./","");const i=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!i||!i.file)throw new Error("Cannot find target file");return i}querySelector(e,t){return t=this.areNamespaceIgnored?pf(t):mf(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?pf(t):mf(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}}class bf extends vf{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:Rp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:Rp}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class Sf extends vf{constructor(e,t,i,o){super(e,t,i),this.theme=o}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var i,o,n,r,s,a,l,c,h,d,u;const g=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===g)throw new Error("Databars conditional formats are not supported.");return{type:g,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:null===(i=this.extractAttr(e,"dxfId"))||void 0===i?void 0:i.asNum(),stopIfTrue:null===(o=this.extractAttr(e,"stopIfTrue"))||void 0===o?void 0:o.asBool(),aboveAverage:null===(n=this.extractAttr(e,"aboveAverage"))||void 0===n?void 0:n.asBool(),percent:null===(r=this.extractAttr(e,"percent"))||void 0===r?void 0:r.asBool(),bottom:null===(s=this.extractAttr(e,"bottom"))||void 0===s?void 0:s.asBool(),operator:null===(a=this.extractAttr(e,"operator"))||void 0===a?void 0:a.asString(),text:null===(l=this.extractAttr(e,"text"))||void 0===l?void 0:l.asString(),timePeriod:null===(c=this.extractAttr(e,"timePeriod"))||void 0===c?void 0:c.asString(),rank:null===(h=this.extractAttr(e,"rank"))||void 0===h?void 0:h.asNum(),stdDev:null===(d=this.extractAttr(e,"stdDev"))||void 0===d?void 0:d.asNum(),equalAverage:null===(u=this.extractAttr(e,"equalAverage"))||void 0===u?void 0:u.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const i=this.querySelector(e,"colorScale");if(i)return{colors:this.mapOnElements({parent:i,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(i)}}extractCfIconSet(e){var t,i;const o=this.querySelector(e,"iconSet, x14:iconSet");if(o)return{iconSet:this.extractAttr(o,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(o,"showValue",{default:!0}).asBool(),percent:this.extractAttr(o,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(o,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(i=this.extractAttr(o,"custom"))||void 0===i?void 0:i.asBool(),cfvos:this.extractCFVos(o),cfIcons:this.extractCfIcons(o)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,i;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(i=this.extractAttr(e,"val"))||void 0===i?void 0:i.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class Cf extends vf{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!om[t])throw new Error(`Unsupported chart type ${t}`);const i=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),o=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:i,type:om[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:im[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===o,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:cat c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=pf(e.tagName);if(xp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class Ef extends vf{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==pf(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const i=this.querySelector(t,e);if(!i)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(i,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(i,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(i,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(i,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),i=this.getTargetXmlFile(this.relationships[t]),o=new Cf(i,this.xlsxFileStructure,this.warningManager).extractChart();if(!o)throw new Error("Unable to extract chart definition");return o}}class wf extends vf{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class yf extends vf{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,i,o,n,r;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(i=this.extractAttr(e,"showFirstColumn"))||void 0===i?void 0:i.asBool(),showLastColumn:null===(o=this.extractAttr(e,"showLastColumn"))||void 0===o?void 0:o.asBool(),showRowStripes:null===(n=this.extractAttr(e,"showRowStripes"))||void 0===n?void 0:n.asBool(),showColumnStripes:null===(r=this.extractAttr(e,"showColumnStripes"))||void 0===r?void 0:r.asBool()}}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class xf extends vf{constructor(e,t,i,o){super(e,t,i),this.theme=o}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=cm(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=cm(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,i=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!i)throw new Error("Cannot find corresponding workbook sheet");return i}extractConditionalFormats(){return new Sf(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new Ef(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new yf(o,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new wf(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:kp.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:$p.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,i,o,n,r,s,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(i=this.extractAttr(e,"customWidth"))||void 0===i?void 0:i.asBool(),bestFit:null===(o=this.extractAttr(e,"bestFit"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),min:null===(r=this.extractAttr(e,"min",{required:!0}))||void 0===r?void 0:r.asNum(),max:null===(s=this.extractAttr(e,"max",{required:!0}))||void 0===s?void 0:s.asNum(),styleIndex:null===(a=this.extractAttr(e,"style"))||void 0===a?void 0:a.asNum()}}))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>{var t,i,o,n,r;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(i=this.extractAttr(e,"ht"))||void 0===i?void 0:i.asNum(),customHeight:null===(o=this.extractAttr(e,"customHeight"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),styleIndex:null===(r=this.extractAttr(e,"s"))||void 0===r?void 0:r.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,i,o;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(i=this.extractAttr(e,"s"))||void 0===i?void 0:i.asNum(),type:Yp[null===(o=this.extractAttr(e,"t",{default:"n"}))||void 0===o?void 0:o.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,i;const o=this.querySelector(e,"f");if(o)return{content:this.extractTextContent(o),sharedIndex:null===(t=this.extractAttr(o,"si"))||void 0===t?void 0:t.asNum(),ref:null===(i=this.extractAttr(o,"ref"))||void 0===i?void 0:i.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,i,o,n;const r=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(i=this.extractAttr(e,"ref",{required:!0}))||void 0===i?void 0:i.asString(),location:null===(o=this.extractAttr(e,"location"))||void 0===o?void 0:o.asString(),display:null===(n=this.extractAttr(e,"display"))||void 0===n?void 0:n.asString(),relTarget:r?this.relationships[r].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),i={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),o=this.extractTextContent(e,{required:!0});i[t]=o}const o=[];for(let e=0;e<Object.keys(i).length;e++)i[e]?o.push(i[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),o.push(""));return o}}class Rf extends vf{constructor(e,t,i){super(e.styles,e,t),this.theme=i}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,i,o,n;const r=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),s=this.extractChildAttr(e,"sz","val",{default:G.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(i=h.attributes.val)||void 0===i?void 0:i.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(o=u.attributes.val)||void 0===o?void 0:o.value),p=this.querySelector(e,"u")||void 0;return{name:r,size:s,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(n=p.attributes.val)||void 0===n?void 0:n.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const i=e.children[0];return"patternFill"===i.tagName?{patternType:null===(t=i.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(i,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(i,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(i,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,i;const o={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return o.diagonal&&(o.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),o.diagonalDown=null===(i=this.extractAttr(e,"diagonalDown"))||void 0===i?void 0:i.asBool()),o}extractSingleBorder(e,t,i){const o=this.querySelector(e,t);if(o&&o.attributes.style)return{style:this.extractAttr(o,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(o.children[0],i,"000000")}}extractAlignment(e){var t,i,o,n,r,s,a;return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"center"}).asString(),textRotation:null===(t=this.extractAttr(e,"textRotation"))||void 0===t?void 0:t.asNum(),wrapText:null===(i=this.extractAttr(e,"wrapText"))||void 0===i?void 0:i.asBool(),indent:null===(o=this.extractAttr(e,"indent"))||void 0===o?void 0:o.asNum(),relativeIndent:null===(n=this.extractAttr(e,"relativeIndent"))||void 0===n?void 0:n.asNum(),justifyLastLine:null===(r=this.extractAttr(e,"justifyLastLine"))||void 0===r?void 0:r.asBool(),shrinkToFit:null===(s=this.extractAttr(e,"shrinkToFit"))||void 0===s?void 0:s.asBool(),readingOrder:null===(a=this.extractAttr(e,"readingOrder"))||void 0===a?void 0:a.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),i=this.querySelector(e,"fill"),o=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),r=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:i?this.extractFill(i):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:r?this.extractAlignment(r):void 0,border:o?this.extractBorder(o):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class If extends vf{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),i={};for(let e of t)i[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:i}}))}}function Tf(e,t){const i=function(e,t){const i=t[Bp],o=i.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of o){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const i=[];for(let o of e){const e=Af(o,t);i.push({file:{fileName:o,xml:t[o]},rels:e?{fileName:e,xml:t[e]}:void 0})}return i}(i,t)}function Af(e,t){if(e===Bp)return"_rels/.rels";let i="";const o=e.split("/");for(let e=0;e<o.length-1;e++)i+=o[e]+"/";return i+="_rels/",i+=o[o.length-1]+".rels",t[i]||(i=void 0),i}class Of{constructor(e){this.warningManager=new Wp,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=hf(new yp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new bf(e.theme,e,this.warningManager).getTheme():void 0,i=e.sharedStrings?new bf(e.sharedStrings,e,this.warningManager).getSharedStrings():[],o=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((i=>new xf(i,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new If(t,e,this.warningManager).getExternalBook())),r=new Rf(e,this.warningManager,t);return{fonts:r.getFonts(),fills:r.getFills(),borders:r.getBorders(),dxfs:r.getDxfs(),numFmts:r.getNumFormats(),styles:r.getStyles(),sheets:o,sharedStrings:i,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:Tf(Mp.sheet,this.xmls),workbook:Tf(Mp.workbook,this.xmls)[0],styles:Tf(Mp.styles,this.xmls)[0],sharedStrings:Tf(Mp.sharedStrings,this.xmls)[0],theme:Tf(Mp.themes,this.xmls)[0],charts:Tf(Mp.chart,this.xmls),figures:Tf(Mp.drawing,this.xmls),tables:Tf(Mp.table,this.xmls),pivots:Tf(Mp.pivot,this.xmls),externalLinks:Tf(Mp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(r("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Xm(e,this.warningManager),styles:vm(e,this.warningManager),formats:Sm(e,this.warningManager),borders:mm(e,this.warningManager),entities:{},revisionId:K};return nf(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=st(e.styles[t])})),t}}function Mf(e){const t=ug(e);let i=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&wt.test(e.value)){const t=e.value.trim();return i.includes(t)||i.push(t),`${ie}${i.indexOf(t)}${ie}`}return e.value}))),dependencies:i}}const Nf=12,_f="Sheet1";function Ff(e,t){if(!e)return Pf();if(e["[Content_Types].xml"]){const i=new Of(e);if(e=i.convertXlsx(),t)for(let e of i.warningManager.warnings.sort())console.warn(e)}return"version"in(e=Te(e))&&e.version<Nf&&(e=function(e){for(let t=Df.findIndex((t=>t.from===e.version));t<Df.length;t++)e=Df[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,i=new wi;for(const o of e.sheets||[])for(const e of o.figures||[])t.has(e.id)&&(e.id+=i.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(Pf(),e,{version:Nf}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(Lf(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(Lf(_f,"Sheet1"));return e}(e),e}(e),e}const Df=[{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 i=t.cells[e];i.content&&i.content.startsWith("=")&&(i.formula=Mf(i.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:i,...o}=t.figures[e].data,n=[];for(let e of i)if(e.labelCell){const t=xi(e.dataRange),i=e.labelCell+":"+$t(t.right,t.bottom);n.push(i)}else n.push(e.dataRange);o.dataSetsHaveTitle=Boolean(i[0].labelCell),o.dataSets=n,t.figures[e].data=o}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const i=[],o=new RegExp(te,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,r=e.replace(o,"_");let s=1,a=r;for(;i.includes(a);)a=`${r}${s}`,s++;n.name=a,i.push(a);const l=t=>{if(void 0===t)return t;let i=t.replace(e,a),o=t;for(;o!==i;)o=i,i=o.replace(e,a);return o};for(let e in n.cells){const t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of n.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),i=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:i}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const i of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[i])||void 0===t?void 0:t.type)&&(e.rule[i].value=l(e.rule[i].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const i=t.cells[e];if(i.formula){let{text:e,dependencies:t}=i.formula;for(let[i,o]of Object.entries(t)){const t=`\\${ie}${i}\\${ie}`;e=e.replace(new RegExp(t,"g"),o)}i.content=e,delete i.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let i of e.sheets||[])for(let e in i.cells||[]){const o=i.cells[e];o.format&&(o.format=Qe(o.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}];function kf(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const i=[],o=[],n=e=>{if("CREATE_SHEET"===e.type)i.push(e.sheetId);else if("sheetId"in e&&!i.includes(e.sheetId))return{...e,sheetId:_f};return e};for(const e of t)"REMOTE_REVISION"===e.type?o.push({...e,commands:e.commands.map(n)}):o.push(e);return o}(e,t),t=$f(t,"SORT_CELLS"),t=function(e,t){var i;const o=[],n={};for(const t of e.sheets||[])null===(i=t.figures)||void 0===i||i.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const i of e.commands){let e=i;switch(i.type){case"CREATE_CHART":n[i.id]=i.definition;break;case"UPDATE_CHART":if(!n[i.id]){console.log(`Fix chart definition: chart with id ${i.id} not found.`);continue}const t={...n[i.id],...i.definition};e={...i,definition:t},n[i.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=$f(t,"SET_DECIMAL")),t}function $f(e,t){const i=[];for(const o of e)"REMOTE_REVISION"===o.type?i.push({...o,commands:o.commands.filter((e=>e.type!==t))}):i.push(o);return i}function Lf(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function Pf(e="Sheet1"){return{version:Nf,sheets:[Lf(_f,e)],entities:{},styles:{},formats:{},borders:{},revisionId:K,uniqueFigureIds:!0}}function Uf(e,t){return{...Lf(e,t),charts:[]}}class Vf extends yg{constructor(e,t,i,o,n,r){super(t,o,n),this.dispatch=o,this.range=i,i.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=r}import(e){}export(e){}adaptRanges(e,t){}}class zf extends Vf{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const i=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,i)}break;case"DELETE_SHEET":const i={...this.borders};delete i[e.sheetId],this.history.update("borders",i);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,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){let t,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,i)}handleAddRows(e){let t,i;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,i)}getCellBorder(e,t,i){var o,n,r,s,a,l,c,h,d,u,g,p;const m={top:null===(r=null===(n=null===(o=this.borders[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===r?void 0:r.horizontal,bottom:null===(l=null===(a=null===(s=this.borders[e])||void 0===s?void 0:s[t])||void 0===a?void 0:a[i+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[i])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[i])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,i){const o=ke(t+1,i);for(let n=0;n<this.getters.getNumberRows(e);n++){const r=this.getCellBorder(e,t,n),s=this.getCellBorder(e,i,n);if(r&&s){const t=this.getCommonSides(r,s);for(let i of o)this.addBorder(e,i,n,t)}}}ensureRowBorderContinuity(e,t,i){const o=ke(t+1,i);for(let n=0;n<this.getters.getNumberCols(e);n++){const r=this.getCellBorder(e,n,t),s=this.getCellBorder(e,n,i);if(r&&s){const t=this.getCommonSides(r,s);for(let i of o)this.addBorder(e,n,i,t)}}}getCommonSides(e,t){const i={};for(let o of["top","bottom","left","right"])e[o]&&e[o]===t[o]&&(i[o]=e[o]);return i}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?ke(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,i,{moveFirstLeftBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfColumn(e,t,i,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfColumn(e,n,i,"vertical"),this.moveBordersOfColumn(e,n,i,"horizontal")})))}shiftBordersVertically(e,t,i,{moveFirstTopBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfRow(e,t,i,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfRow(e,n,i,"horizontal"),this.moveBordersOfRow(e,n,i,"vertical")})))}moveBordersOfRow(e,t,i,o,{destructive:n}={destructive:!0}){const r=this.borders[e];r&&this.getColumnsWithBorders(e).forEach((s=>{var a,l,c,h;const d=null===(l=null===(a=r[s])||void 0===a?void 0:a[t+i])||void 0===l?void 0:l[o],u=null===(h=null===(c=r[s])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o];this.history.update("borders",e,s,t+i,o,n?u:u||d),this.history.update("borders",e,s,t,o,void 0)}))}moveBordersOfColumn(e,t,i,o,{destructive:n}={destructive:!0}){const r=this.borders[e];r&&this.getRowsRange(e).forEach((s=>{var a,l,c,h;const d=null===(l=null===(a=r[t+i])||void 0===a?void 0:a[s])||void 0===l?void 0:l[o],u=null===(h=null===(c=r[t])||void 0===c?void 0:c[s])||void 0===h?void 0:h[o];this.history.update("borders",e,t+i,s,o,n?u:u||d),this.history.update("borders",e,t,s,o,void 0)}))}setBorder(e,t,i,o,n=!0){var r,s,a,l,c,h,d,u,g,p,m,f,v,b,S,C;!n&&(null===(l=null===(a=null===(s=null===(r=this.borders)||void 0===r?void 0:r[e])||void 0===s?void 0:s[t])||void 0===a?void 0:a[i])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,i,"vertical",null==o?void 0:o.left),!n&&(null===(u=null===(d=null===(h=null===(c=this.borders)||void 0===c?void 0:c[e])||void 0===h?void 0:h[t])||void 0===d?void 0:d[i])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,i,"horizontal",null==o?void 0:o.top),!n&&(null===(f=null===(m=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===m?void 0:m[i])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,i,"vertical",null==o?void 0:o.right),!n&&(null===(C=null===(S=null===(b=null===(v=this.borders)||void 0===v?void 0:v[e])||void 0===b?void 0:b[t])||void 0===S?void 0:S[i+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,i+1,"horizontal",null==o?void 0:o.bottom)}clearBorders(e,t){for(let i of t){for(let t=i.top;t<=i.bottom;t++){this.history.update("borders",e,i.right+1,t,"vertical",void 0);for(let o=i.left;o<=i.right;o++)this.history.update("borders",e,o,t,void 0)}for(let t=i.left;t<=i.right;t++)this.history.update("borders",e,t,i.bottom+1,"horizontal",void 0)}}addBorder(e,t,i,o){this.setBorder(e,t,i,{...this.getCellBorder(e,t,i),...o})}setBorders(e,t,i){if("clear"===i)return this.clearBorders(e,t);for(let o of t){if("h"===i||"hv"===i||"all"===i)for(let t=o.top+1;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++)this.addBorder(e,i,t,{top:Z});if("v"===i||"hv"===i||"all"===i)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left+1;i<=o.right;i++)this.addBorder(e,i,t,{left:Z});if("left"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.left,t,{left:Z});if("right"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.right+1,t,{left:Z});if("top"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.top,{top:Z});if("bottom"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.bottom+1,{top:Z})}}addBordersToMerge(e,t){const{left:i,right:o,top:n,bottom:r}=t,s=this.getCellBorder(e,i,n),a=this.getCellBorder(e,o,r);this.clearBorders(e,[t]),(null==s?void 0:s.top)&&this.setBorders(e,[{...t,bottom:n}],"top"),(null==s?void 0:s.left)&&this.setBorders(e,[{...t,right:i}],"left"),((null==a?void 0:a.bottom)||(null==s?void 0:s.bottom))&&this.setBorders(e,[{...t,top:r}],"bottom"),((null==a?void 0:a.right)||(null==s?void 0:s.right))&&this.setBorders(e,[{...t,left:o}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[i,o]of Object.entries(t.cells))if(null==o?void 0:o.border){const n=e.borders[o.border],{col:r,row:s}=kt(i);this.setBorder(t.id,r,s,n,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,xi(e))}export(e){let t=0;const i={};function o(e){for(let[t,o]of Object.entries(i))if(xe(o)===xe(e))return parseInt(t,10);return i[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let i=0;i<t.rowNumber;i++){const n=this.getCellBorder(t.id,e,i);if(n){const r=$t(e,i),s=t.cells[r],a=o(n);s?s.border=a:t.cells[r]={border:a}}}e.borders=i}exportForExcel(e){this.export(e)}}zf.getters=["getCellBorder"];const Bf=new RegExp(String.fromCharCode(160),"g");class Hf extends Vf{constructor(){super(...arguments),this.cells={},this.createCell=function(e){const t=Vo.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i,o,n,r){const s=t.find((e=>e.match(o,n.format)));if(!s)return new mp(i,o,n);try{return s.createCell(i,o,n,r,e)}catch(e){return new Ep(i,o,e instanceof c?e:new h(e.message||oe),n)}}}(this.getters)}adaptRanges(e,t){for(const i of Object.keys(this.cells))for(const o of Object.values(this.cells[i]||{}))if(o.isFormula())for(const n of o.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",i,o.id,"dependencies",o.dependencies.indexOf(n),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,i){for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:i})}clearFormatting(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:null,format:""})}handleAddColumnsRows(e,t){let i,o;"before"===e.position?(i=ke(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=ke(e.base+1,e.base+e.quantity+1),o=e.base),t(e.sheetId,o,i)}import(e){for(let t of e.sheets)for(let i in t.cells){const o=t.cells[i],{col:n,row:r}=kt(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(t.id,o,e.styles,e.formats);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cellId:i.id,col:n,row:r,sheetId:t.id})}}}export(e){const t={},i={};for(let o of e.sheets){const e={},n=Object.keys(this.cells[o.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:r,row:s}of n){const n=this.getters.getCell(o.id,r,s);e[$t(r,s)]={style:n.style?Qe(n.style,t):void 0,format:n.format?Qe(n.format,i):void 0,content:n.content||void 0}}o.cells=e}e.styles=t,e.formats=i}importCell(e,t,i,o){const n=t.style&&i[t.style]||void 0,r=t.format&&o[t.format]||void 0,s=this.uuidGenerator.uuidv4(),a={format:r,style:n};return this.createCell(s,(null==t?void 0:t.content)||"",a,e)}exportForExcel(e){this.export(e);for(let t of e.sheets)for(const e in t.cells){const{col:i,row:o}=kt(e),n=this.getters.getCell(t.id,i,o),r=t.cells[e];r.value=n.evaluated.value,r.isFormula=n.isFormula(),n.format!==n.evaluated.format&&(r.computedFormat=n.evaluated.format)}}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const i=this.cells[t][e];if(i)return i}}buildFormulaContent(e,t,i){const o=i||[...t.dependencies];return et(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=o.shift();return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){return e&&e.style||{}}zoneToXC(e,t,i=[{colFixed:!1,rowFixed:!1}]){const o=$t((t=this.getters.expandZone(e,t)).left,t.top,i[0]),n=$t(t.right,t.bottom,i.length>1?i[1]:i[0]),r=this.getters.getMainCellPosition(e,t.left,t.top),s=this.getters.getMainCellPosition(e,t.right,t.bottom),a=r.col===s.col&&r.row===s.row;return o==n||a?o:o+":"+n}setStyle(e,t,i){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){const o=this.getters.getCell(e,t,n);this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:i?{...null==o?void 0:o.style,...i}:void 0})}}copyColumnStyle(e,t,i){for(let o=0;o<this.getters.getNumberRows(e);o++){const n=this.getFormat(e,t,o);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,...n})}}copyRowStyle(e,t,i){for(let o=0;o<this.getters.getNumberCols(e);o++){const n=this.getFormat(e,o,t);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,...n})}}getFormat(e,t,i){const o={},{col:n,row:r}=this.getters.getMainCellPosition(e,t,i),s=this.getters.getCell(e,n,r);return s&&(s.style&&(o.style=s.style),s.format&&(o.format=s.format)),o}updateCell(e,t,i,o){var n;const r=this.getters.getCell(e,t,i),s="content"in o||"formula"in o,a=s?(null===(n=o.content)||void 0===n?void 0:n.replace(Bf,""))||"":(null==r?void 0:r.content)||"";let l;l=void 0!==o.style?o.style||void 0:r?r.style:void 0;let c=("format"in o?o.format:r&&r.format)||undefined;if((s&&!a&&!o.formula||!s&&(!r||r.isEmpty()))&&!l&&!c)return void(r&&(this.history.update("cells",e,r.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:i,sheetId:e})));const h=(null==r?void 0:r.id)||this.uuidGenerator.uuidv4(),d=s,u={format:c,style:l},g=this.createCell(h,a,u,e);r&&!d&&g.isFormula()&&g.assignEvaluation(tt(r.evaluated)),this.history.update("cells",e,g.id,g),this.dispatch("UPDATE_CELL_POSITION",{cellId:g.id,col:t,row:i,sheetId:e})}checkCellOutOfSheet(e,t,i){if(!this.getters.tryGetSheet(e))return 27;return ki(t,i,this.getters.getSheetZone(e))?0:18}}Hf.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Wf extends Vf{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=Yi.getAll();return function(i,o,n){const r=t.find((e=>e.match(o.type)));if(!r)throw new Error(`No builder for this chart: ${o.type}`);return r.createChart(o,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const i=Yi.getAll().find((e=>e.match(t.type)));if(!i)throw new Error("Unknown chart type.");return i.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,i]of Object.entries(this.charts))this.history.update("charts",t,null==i?void 0:i.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const i=this.getters.getFigures(e.sheetId);for(const o of i)if("chart"===o.tag){const i=o.id.split("??").pop(),n=`${e.sheetIdTo}??${i}`,r=null===(t=this.charts[o.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);r&&this.dispatch("CREATE_CHART",{id:n,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:r.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){var t;return null===(t=this.charts[e])||void 0===t?void 0:t.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!i)throw new Error("Chart not defined.");return i}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!i)throw new Error(`There is no chart with the given figureId: ${e}`);return i}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();i&&(e.data=i,o.push(e))}else o.push(e)}i.figures=o}}exportForExcel(e){var t;for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e)if(i&&"chart"===i.tag){const e=null===(t=this.charts[i.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&o.push({...i,data:e})}i.charts=o}}addFigure(e,t,i={x:0,y:0},o={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const i=this.getters.getFigureSheetId(e);i&&this.history.update("charts",e,this.createChart(e,t,i))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?83:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:84}}function Gf(e){return""===e?NaN:Number(e)}Wf.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class qf extends Vf{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const i of this.cfRules[e])for(const o of i.ranges){const n=t(o);switch(n.changeType){case"REMOVE":let t=i.ranges.slice();t.splice(i.ranges.indexOf(o),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",t):this.removeConditionalFormatting(i.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",i.ranges.indexOf(o),n.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const i={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(i,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const i=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{i.add(e)}))})),Array.from(i)}getRulesByZone(e,t){const i=new Set;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,o).forEach((e=>{i.add(e.id)}))}return i}getRulesByCell(e,t,i){const o=[];for(let n of this.cfRules[e])for(let e of n.ranges)ki(t,i,e.zone)&&o.push(n);return new Set(o.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 i={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return i}addConditionalFormatting(e,t){const i=this.cfRules[t].slice(),o=i.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);o>-1?i.splice(o,1,n):i.push(n),this.history.update("cfRules",t,i)}checkValidReordering(e,t,i){if(!this.cfRules[i])return 27;const o=this.cfRules[i].findIndex((t=>t.id===e));if(-1===o)return 70;const n="up"===t?o-1:o+1;return n<0||n>=this.cfRules[i].length?70:0}checkEmptyRange(e){return e.ranges.length?0:24}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 i=>{if(t.includes(i.operator)){const t=[],o=e=>void 0===e||""===e;return e>=1&&o(i.values[0])&&t.push(50),e>=2&&o(i.values[1])&&t.push(51),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 52;case"max":return 54;case"mid":return 53;case"upperInflectionPoint":return 55;case"lowerInflectionPoint":return 56}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{bg(e.value||"")}catch(e){switch(t){case"min":return 57;case"max":return 59;case"mid":return 58;case"upperInflectionPoint":return 60;case"lowerInflectionPoint":return 61}}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,i=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(i)?47:0}checkMinBiggerThanMax(e){const t=e.minimum.value,i=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&Gf(t)>=Gf(i)?46:0}checkMidBiggerThanMax(e){var t;const i=null===(t=e.midpoint)||void 0===t?void 0:t.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&Gf(i)>=Gf(o)?48:0}checkMinBiggerThanMid(e){var t;const i=e.minimum.value,o=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&&Gf(i)>=Gf(o)?49:0}removeConditionalFormatting(e,t){const i=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==i){const e=this.cfRules[t].slice();e.splice(i,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,i){const o=this.cfRules[i].findIndex((t=>t.id===e)),n="up"===t?o-1:o+1;if(!(n<0||n>=this.cfRules[i].length)&&-1!==o&&-1!==n){const e=[...this.cfRules[i]],t=e[o];e[o]=e[n],e[n]=t,this.history.update("cfRules",i,e)}}}qf.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Zf extends Vf{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.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:i,...o}=e,n=o;this.updateFigure(i,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[i,o]of Object.entries(t))switch(i){case"x":case"y":void 0!==o&&this.history.update("figures",e,t.id,i,Math.max(o,0));break;case"width":case"height":void 0!==o&&this.history.update("figures",e,t.id,i,o)}}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 i;return void 0===(null===(i=this.figures[e])||void 0===i?void 0:i[t])?69:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?81:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(Xe)}getFigure(e,t){var i;return null===(i=this.figures[e])||void 0===i?void 0:i[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var i;return void 0!==(null===(i=this.figures[t])||void 0===i?void 0:i[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 i=void 0;t.figures.push({...e,data:i})}}exportForExcel(e){this.export(e)}}Zf.getters=["getFigures","getFigure","getFigureSheetId"];class jf{constructor(e){this.filters=[],this.zone=e;const t=new wi;this.id=t.uuidv4();for(const i of ke(e.left,e.right+1)){const e={...this.zone,left:i,right:i};this.filters.push(new Xf(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){var t;return null===(t=this.filters.find((t=>t.col===e)))||void 0===t?void 0:t.id}clone(){return new jf(this.zone)}}class Xf{constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}class Yf extends Vf{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!ji(...e.target))return 80;const t=Ni(...e.target),i=()=>this.getFilterTables(e.sheetId).some((e=>Di(e.zone,t)))?77:0,o=()=>{const i=this.getters.getMergesInZone(e.sheetId,t);for(let e of i)if(Di(t,e))return 79;return 0};return this.checkValidations(e,i,o);case"ADD_MERGE":for(let t of e.target)for(let i of this.getFilterTables(e.sheetId))if(Di(i.zone,t))return 79}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":const i={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=Te(t);i[e.id]=e}this.history.update("tables",e.sheetIdTo,i);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=Ni(...e.target),i=this.createFilterTable(t);this.history.update("tables",e.sheetId,i.id,i);break}case"REMOVE_FILTER_TABLE":{const t={};for(const i of this.getFilterTables(e.sheetId))e.target.every((e=>!_i(e,i.zone)))&&(t[i.id]=i);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let i of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,i)&&this.extendTableDown(t,i);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(Xe):[]}getFilter(e,t,i){var o;return null===(o=this.getFilterTable(e,t,i))||void 0===o?void 0:o.filters.find((e=>e.col===t))}getFilterId(e,t,i){var o;return null===(o=this.getFilter(e,t,i))||void 0===o?void 0:o.id}getFilterTable(e,t,i){return this.getFilterTables(e).find((e=>ki(t,i,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>$i(e.zone,t)))}doesZonesContainFilter(e,t){for(const i of t)for(const t of this.getFilterTables(e))if(_i(i,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Ti(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o=[];for(const i of t.filters){const t=Ti(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);o.push(new Xf(i.id,t))}if(o.length<Ui(i).width){for(let e=i.left;e<=i.right;e++)o.find((t=>t.col===e))||o.push(new Xf(this.uuidGenerator.uuidv4(),{...i,left:e,right:e}));o.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Mi(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(i){if(Ii(i)!==Ii(t.zone)){const o=[];for(const i of t.filters){const t=Mi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&o.push(new Xf(i.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}else{const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i)}}}createFilterTable(e){return new jf(e)}extendTableDown(e,t){const i={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",i);for(let i=0;i<t.filters.length;i++){const o=t.filters[i],n={...o.zoneWithHeaders,bottom:o.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",i,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:i,row:o},n){var r;if(!e)return;const s=n.zone;if(!(s.bottom+1===o&&i>=s.left&&i<=s.right))return!1;for(const e of ke(s.left,s.right+1)){if(null===(r=this.getters.getCell(t,e,o))||void 0===r?void 0:r.content)return!1;if(this.getters.getFilter(t,e,o))return!1;if(this.getters.isInMerge(t,e,o))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const i=this.createFilterTable(xi(e.range));this.history.update("tables",t.id,i.id,i)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:Ii(e.zone)})}exportForExcel(e){this.export(e)}}Yf.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Kf extends Vf{constructor(){super(...arguments),this.sizes={}}handle(e){var t,i;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),i={COL:t.COL.map((e=>({manualSize:void 0,computedSize:tt(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:tt(e)})))};this.history.update("sizes",e.sheetId,i);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Te(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const o={...this.sizes};delete o[e.sheetId],this.history.update("sizes",o);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);const i=Math.min(...e.elements);t=t.map(((t,o)=>"ROW"===e.dimension&&o>=i?{manualSize:t.manualSize,computedSize:tt((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const i=ot(e.position,e.base),o=t[e.base];t.splice(i,0,...Array(e.quantity).fill(o)),t=t.map(((t,i)=>"ROW"===e.dimension&&i>e.base+e.quantity?{manualSize:t.manualSize,computedSize:tt((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const i=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:tt(i)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:tt(e.size||_)});break;case"UPDATE_CELL":const n=null===(i=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[e.row];if(n&&!n.manualSize){const{sheetId:t,row:i}=e;this.history.update("sizes",t,"ROW",i,"computedSize",tt((()=>this.getRowTallestCellSize(t,i))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let i of ke(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,i);t!==this.getRowSize(e.sheetId,i)&&this.history.update("sizes",e.sheetId,"ROW",i,"computedSize",tt(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,i){var o,n,r,s;return Math.round((null===(n=null===(o=this.sizes[e])||void 0===o?void 0:o[t][i])||void 0===n?void 0:n.manualSize)||(null===(s=null===(r=this.sizes[e])||void 0===r?void 0:r[t][i])||void 0===s?void 0:s.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,i;const o={COL:[],ROW:[]};for(let t of ke(0,this.getters.getNumberCols(e)))o.COL.push(this.getHeaderSize(e,"COL",t));for(let n of ke(0,this.getters.getNumberRows(e))){let r=null===(i=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[n].manualSize;if(!r){r=this.getRowTallestCellSize(e,n)}o.ROW.push(r)}return o}getDefaultHeaderSize(e){return"COL"===e?_:F}getCellHeight(e,t,i){const o=this.getters.getMerge(e,t,i);if(o&&o.bottom!==o.top)return F;const n=this.getters.getCell(e,t,i);return(null==(r=null==n?void 0:n.style)?void 0:r.fontSize)?(s||1)*(De(r)+P)-P+2*U:F;var r,s}getRowTallestCellSize(e,t){const i=this.getters.getRowCells(e,t);let o=0;for(let t=0;t<i.length;t++){const n=this.getters.getCellById(i[t]);if(!n)continue;const{col:r,row:s}=this.getters.getCellPosition(n.id),a=this.getCellHeight(e,r,s);a>o&&a>F&&(o=a)}return o<=F?F:o}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[i,o]of Object.entries(t.rows))o.size&&(e.ROW[i]=o.size);for(let[i,o]of Object.entries(t.cols))o.size&&(e.COL[i]=o.size);const i=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:i.COL.map(((t,i)=>({manualSize:e.COL[i],computedSize:tt(t)}))),ROW:i.ROW.map(((t,i)=>({manualSize:e.ROW[i],computedSize:tt(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var i,o;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of ke(0,this.getters.getNumberRows(n.id)))(t||(null===(i=this.sizes[n.id].ROW[e])||void 0===i?void 0:i.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of ke(0,this.getters.getNumberCols(n.id)))(t||(null===(o=this.sizes[n.id].COL[e])||void 0===o?void 0:o.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}Kf.getters=["getRowSize","getColSize"];class Qf extends Vf{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),i="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=i?65:Math.min(...e.elements)<0||Math.max(...e.elements)>i?85:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.checkElementsIncludeAllVisibleHeaders(e.sheetId,e.dimension,e.elements)?8:0:27}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,Te(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],i=ot(e.position,e.base);t.splice(i,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}checkElementsIncludeAllVisibleHeaders(e,t,i){return rt(i,this.getAllVisibleHeaders(e,t))}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],i=this.hiddenHeaders[e].COL;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],i=this.hiddenHeaders[e].ROW;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getAllVisibleHeaders(e,t){return ke(0,this.hiddenHeaders[e][t].length).filter((i=>!this.hiddenHeaders[e][t][i]))}import(e){var t,i;for(let o of e.sheets){this.hiddenHeaders[o.id]={COL:[],ROW:[]};for(let e=0;e<o.rowNumber;e++)this.hiddenHeaders[o.id].ROW[e]=Boolean(null===(t=o.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<o.colNumber;e++)this.hiddenHeaders[o.id].COL[e]=Boolean(null===(i=o.cols[e])||void 0===i?void 0:i.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e=0;e<this.getters.getNumberRows(i.id);e++)(t||this.hiddenHeaders[i.id].ROW[e])&&(void 0===i.rows[e]&&(i.rows[e]={}),i.rows[e].isHidden=this.hiddenHeaders[i.id].ROW[e]);void 0===i.cols&&(i.cols={});for(let e=0;e<this.getters.getNumberCols(i.id);e++)(t||this.hiddenHeaders[i.id].COL[e])&&(void 0===i.cols[e]&&(i.cols[e]={}),i.cols[e].isHidden=this.hiddenHeaders[i.id].COL[e])}}}Qf.getters=["checkElementsIncludeAllVisibleHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class Jf extends Vf{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const i of Object.values(t).filter(Xe))this.addMerge(e.sheetIdTo,i.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const i=t?[t]:Object.keys(this.merges);for(const t of i)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(Xe)}getMerge(e,t,i){var o;const n=this.mergeCellMap[e],r=n?t in n&&(null===(o=n[t])||void 0===o?void 0:o[i]):void 0;return r?this.getMergeById(e,r):void 0}getMergesInZone(e,t){var i;const o=this.mergeCellMap[e];if(!o)return[];const n=new Set;for(const{col:e,row:r}of zi(t)){const t=null===(i=o[e])||void 0===i?void 0:i[r];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(Xe)}doesIntersectMerge(e,t){const{left:i,right:o,top:n,bottom:r}=t;for(let t=n;t<=r;t++)for(let n=i;n<=o;n++)if(this.getMerge(e,n,t))return!0;return!1}doesColumnsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(o.id,t,n,i,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(o.id,n,t,n,i))return!0;return!1}expandZone(e,t){let{left:i,right:o,top:n,bottom:r}=t,s={left:i,right:o,top:n,bottom:r};for(let t in this.merges[e]){const i=this.getMergeById(e,parseInt(t));i&&Di(i,s)&&(s=Ni(i,s))}return Fi(s,t)?s:this.expandZone(e,s)}isInSameMerge(e,t,i,o,n){const r=this.getMerge(e,t,i),s=this.getMerge(e,o,n);return!(!r||!s)&&Fi(r,s)}isInMerge(e,t,i){var o;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(o=n[t])||void 0===o?void 0:o[i]))}getMainCellPosition(e,t,i){if(!this.isInMerge(e,t,i))return{col:t,row:i};const o=this.getMerge(e,t,i).topLeft;return{col:o.col,row:o.row}}getBottomLeftCell(e,t,i){if(!this.isInMerge(e,t,i))return{col:t,row:i};const{bottom:o,left:n}=this.getMerge(e,t,i);return{col:n,row:o}}isMergeHidden(e,t){const i=this.getters.getHiddenColsGroups(e),o=this.getters.getHiddenRowsGroups(e);for(let e of i)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of o)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const i=this.getMerge(e,t.left,t.top);if(i)return Fi(t,i);const{width:o,height:n}=Ui(t);return 1===o&&1===n}isMergeDestructive(e,t){let{left:i,right:o,top:n,bottom:r}=t;o=Me(o,0,this.getters.getNumberCols(e)-1),r=Me(r,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=r;t++)for(let r=i;r<=o;r++)if(r!==i||t!==n){const i=this.getters.getCell(e,r,t);if(i&&!i.isEmpty())return!0}return!1}getMergeById(e,t){var i;const o=null===(i=this.merges[e])||void 0===i?void 0:i[t];return void 0!==o?tv(t,o):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const i of e)if(t!==i&&Di(t,i))return 64;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<i&&e.right>=i||e.top<o&&e.bottom>=o)return 74;return 0}checkMergedContentUpdate(e){const{col:t,row:i,sheetId:o,content:n}=e;if(void 0===n)return 0;const{col:r,row:s}=this.getMainCellPosition(o,t,i);return r===t&&s===i?0:4}checkMergeExists(e){const{sheetId:t,target:i}=e;for(const e of i){const{left:i,top:o}=e,n=this.getMerge(t,i,o);if(void 0===n||!Fi(e,n))return 5}return 0}addMerge(e,t){let{left:i,right:o,top:n,bottom:r}=t;o=Me(o,0,this.getters.getNumberCols(e)-1),r=Me(r,0,this.getters.getNumberRows(e)-1);if($t(i,n)===$t(o,r))return;const s=this.getters.getCell(e,i,n);let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,Ii({left:i,top:n,right:o,bottom:r})));let l=new Set;for(let t=n;t<=r;t++)for(let r=i;r<=o;r++){r===i&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:r,row:t,style:s?s.style:null,content:""});const o=this.getMerge(e,r,t);o&&l.add(o.id),this.history.update("mergeCellMap",e,r,t,a)}for(let t of l){const{top:i,bottom:o,left:n,right:r}=this.getMergeById(e,t);for(let t=i;t<=o;t++)for(let i=n;i<=r;i++){const o=this.getMerge(e,i,t);o&&o.id===a||(this.history.update("mergeCellMap",e,i,t,void 0),this.dispatch("CLEAR_CELL",{sheetId:e,col:i,row:t}))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:i,top:o,bottom:n,right:r}=t,s=this.getMerge(e,i,o);if(void 0!==s&&Fi(t,s)){this.history.update("merges",e,s.id,void 0);for(let t=o;t<=n;t++)for(let o=i;o<=r;o++)this.history.update("mergeCellMap",e,o,t,void 0)}}applyRangeChangeOnSheet(e,t){const i=Object.entries(this.merges[e]||{});for(const[o,n]of i)if(n){const i=n.zone,r=t(n);switch(r.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,i);break;default:const{width:t,height:n}=Ui(r.range.zone);1===t&&1===n?this.removeMerge(e,i):this.history.update("merges",e,parseInt(o,10),r.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:i,row:o}of zi(t))this.history.update("mergeCellMap",e,i,o,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let i of t)this.addMerge(e,xi(i))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...ev(e))}}exportForExcel(e){this.export(e)}}function ev(e){return Object.entries(e).map((([e,t])=>t?tv(parseInt(e,10),t):void 0)).filter(Xe).map((e=>$t(e.left,e.top)+":"+$t(e.right,e.bottom)))}function tv(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Jf.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class iv extends Vf{constructor(){super(...arguments),this.sheetIdsMapName={},this.orderedSheetIds=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":const t=this.orderedSheetIds.indexOf(e.sheetId);if("left"===e.direction){return this.orderedSheetIds.slice(0,t).map((e=>!this.isSheetVisible(e))).every((e=>e))?14:0}return this.orderedSheetIds.slice(t+1).map((e=>!this.isSheetVisible(e))).every((e=>e))?14:0;case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const i="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>i?85:e.quantity<=0?86:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return Math.min(...e.elements)<0||Math.max(...e.elements)>t?85:this.checkElementsIncludeAllNonFrozenHeaders(e.sheetId,e.dimension,e.elements)?8:0}case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.direction);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){var t,i;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let o of e.sheets){const e=o.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:r,rowNumber:s}=this.getImportedSheetSize(o),a={id:o.id,name:e,numberOfCols:r,rows:Ei(s),areGridLinesVisible:void 0===o.areGridLinesVisible||o.areGridLinesVisible,isVisible:o.isVisible,panes:{xSplit:(null===(t=o.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(i=o.panes)||void 0===i?void 0:i.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(Xe).map((e=>{const t=this.sheets[e],i={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(i.panes=t.panes),i}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}getCellsInZone(e,t){return zi(t).map((({col:t,row:i})=>this.getCell(e,t,i)))}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=Ae(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,i){return"COL"===t?i>=0&&i<this.getNumberCols(e):i>=0&&i<this.getNumberRows(e)}getRow(e,t){const i=this.getSheet(e).rows[t];if(!i)throw new Error(`Row ${i} not found.`);return i}getCell(e,t,i){var o;const n=this.tryGetSheet(e),r=null===(o=null==n?void 0:n.rows[i])||void 0===o?void 0:o.cells[t];if(void 0!==r)return this.getters.getCellById(r)}getColCells(e,t){return this.getSheet(e).rows.map((e=>e.cells[t])).filter(Xe).map((e=>this.getters.getCellById(e))).filter(Xe)}getColsZone(e,t,i){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:i}}getRowCells(e,t){var i;return Object.values(null===(i=this.getSheet(e).rows[t])||void 0===i?void 0:i.cells).filter(Xe)}getRowsZone(e,t,i){return{top:t,bottom:i,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this));let o=`${e}${t}`;for(;i.includes(o);)o=`${e}${t}`,t++;return o}getSheetSize(e){return{height:this.getNumberRows(e),width:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,i){const o={...this.getPaneDivisions(e)};"COL"===i?o.xSplit=t:"ROW"===i&&(o.ySplit=t),this.history.update("sheets",e,"panes",o)}checkElementsIncludeAllNonFrozenHeaders(e,t,i){const o=this.getters.getPaneDivisions(e),n="ROW"===t?o.ySplit:o.xSplit,r=this.getters.getNumberHeaders(e,t);if(!n)return!1;return rt(i,ke(n,r))}isEmpty(e,t){return this.getCellsInZone(e,t).flat().every((e=>!e||e.isEmpty()))}updateCellPosition(e){const{sheetId:t,cellId:i,col:o,row:n}=e;i?this.setNewPosition(i,t,o,n):this.clearPosition(t,o,n)}setNewPosition(e,t,i,o){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:o,col:i,sheetId:t}),this.history.update("sheets",t,"rows",o,"cells",i,e)}clearPosition(e,t,i){var o;const n=null===(o=this.sheets[e])||void 0===o?void 0:o.rows[i].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",i,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){this.sheets[e].rows[o].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:o})}}createSheet(e,t,i,o,n){const r={id:e,name:t,numberOfCols:i,rows:Ei(o),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},s=this.orderedSheetIds.slice();s.splice(n,0,r.id);const a=this.sheets;return this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},a,{[r.id]:r})),r}moveSheet(e,t){const i=this.orderedSheetIds.slice(),o=i.findIndex((t=>t===e)),n=i.splice(o,1);let r="left"===t?this.findIndexOfPreviousVisibleSheet(o-1,i):this.findIndexOfNextVisibleSheet(o+1,i);void 0===r&&(r=i.length),i.splice(r,0,n[0]),this.history.update("orderedSheetIds",i)}findIndexOfPreviousVisibleSheet(e,t){for(;e>=0&&!this.isSheetVisible(t[e]);)e--;if(-1===e)throw new Error("There is no previous visible sheet");return e}findIndexOfNextVisibleSheet(e,t){for(;e<t.length&&!this.isSheetVisible(t[e]);)e++;if(e!==t.length-1||this.isSheetVisible(t[e-1]))return e}checkSheetName(e){const{orderedSheetIds:t,sheets:i}=this,o=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=i[e])||void 0===t?void 0:t.name.toLowerCase())===o}))?11:te.test(o)?13:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?15:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:73}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:73}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.top<e.quantity&&e.quantity<=i.bottom)return 64;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.left<e.quantity&&e.quantity<=i.right)return 64;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const i=e.name;this.history.update("sheets",e.id,"name",t.trim());const o=Object.assign({},this.sheetIdsMapName);o[t]=e.id,delete o[i],this.history.update("sheetIdsMapName",o)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const i=this.getSheet(e),o=this.getDuplicateSheetName(i.name),n=Te(i);n.id=t,n.name=o;for(let e=0;e<=n.numberOfCols;e++)for(let t=0;t<=n.rows.length;t++)n.rows[t]&&(n.rows[t].cells[e]=void 0);const r=this.orderedSheetIds.slice(),s=r.indexOf(e);r.splice(s+1,0,n.id),this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},this.sheets,{[n.id]:n}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:i}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:i,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[n.name]=n.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this)),o=r("Copy of %s",e);let n=o.toString();for(;i.includes(n);)n=`${o} (${t})`,t++;return n}deleteSheet(e){const t=e.name,i=Object.assign({},this.sheets);delete i[e.id],this.history.update("sheets",i);const o=this.orderedSheetIds.slice(),n=o.indexOf(e.id);o.splice(n,1),this.history.update("orderedSheetIds",o);const r=Object.assign({},this.sheetIdsMapName);delete r[t],this.history.update("sheetIdsMapName",r)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let i of t)this.moveCellOnColumnsDeletion(e,i);const i=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",i-t.length);const o=t.filter((t=>t<e.panes.xSplit)).length;o&&this.setPaneDivisions(e.id,e.panes.xSplit-o,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let i of $e(t))this.moveCellOnRowsDeletion(e,i[i.length-1],i[0]),i.map((t=>this.updateRowsStructureOnDeletion(t,e)));const i=t.filter((t=>t<e.panes.ySplit)).length;i&&this.setPaneDivisions(e.id,e.panes.ySplit-i,"ROW")}addColumns(e,t,i,o){const n="before"===i?t:t+1;this.moveCellsOnAddition(e,n,o,"columns");const r=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",r+o),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+o,"COL")}addRows(e,t,i,o){const n="before"===i?t:t+1;this.addEmptyRows(e,o),this.moveCellsOnAddition(e,n,o,"rows"),this.updateRowsStructureOnAddition(e,t,o),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+o,"ROW")}moveCellOnColumnsDeletion(e,t){for(let i=0;i<e.rows.length;i++){const o=e.rows[i];for(let n in o.cells){const r=Number(n),s=o.cells[n];s&&(r===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:r,row:i}),r>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:s,col:r-1,row:i}))}}}moveCellsOnAddition(e,t,i,o){const n=[];for(let r=0;r<e.rows.length;r++){const s=e.rows[r];if("rows"!==o||r>=t)for(let a in s.cells){const l=Number(a),c=s.cells[a];c&&("rows"===o||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===o?i:0),row:r+("rows"===o?i:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,i){const o=i-t+1;for(let n=0;n<e.rows.length;n++){const r=e.rows[n];if(n>=t&&n<=i)for(let t in r.cells){const i=Number(t);r.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:i,row:n})}if(n>i)for(let t in r.cells){const i=Number(t),s=r.cells[t];s&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:s,col:i,row:n-o})}}}updateRowsStructureOnDeletion(e,t){const i=[],o=t.rows.map((e=>e.cells));for(let n in t.rows)Number(n)!==e&&i.push({cells:o.shift()});this.history.update("sheets",t.id,"rows",i)}updateRowsStructureOnAddition(e,t,i){const o=[],n=e.rows.map((e=>e.cells));e.rows.forEach((()=>o.push({cells:n.shift()}))),this.history.update("sheets",e.id,"rows",o)}addEmptyRows(e,t){const i=e.rows.slice();for(let e=0;e<t;e++)i.push({cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(kt);let i=e.rowNumber,o=e.colNumber;for(let{col:e,row:n}of t)i=Math.max(i,n+1),o=Math.max(o,e+1);return{rowNumber:i,colNumber:o}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?27:"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),"ranges"in e&&Array.isArray(e.ranges)&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),!t.every(Ri))return 25;if(t.length&&"sheetId"in e){const i=this.getSheetZone(e.sheetId);return t.every((e=>$i(e,i)))?0:18}return 0}}iv.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellsInZone","getCellPosition","getColCells","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions","checkElementsIncludeAllNonFrozenHeaders"];class ov{constructor(e,t,i){this.index=0,this.cells=e,this.getters=t,this.direction=i}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:i,tooltip:o}=Ji.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:i,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class nv extends xg{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:Me(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:Me(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:44;case"AUTOFILL_AUTO":const i=this.getters.getSelectedZone();return i.top===i.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||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),i=this.autofillZone;switch(this.direction){case"down":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push($t(o,e));const r=this.createGenerator(n);for(let t=i.top;t<=i.bottom;t++)this.computeNewCell(r,o,t,e)}break;case"up":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push($t(o,e));const r=this.createGenerator(n);for(let t=i.bottom;t>=i.top;t--)this.computeNewCell(r,o,t,e)}break;case"left":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.right;e>=t.left;e--)n.push($t(e,o));const r=this.createGenerator(n);for(let t=i.right;t>=i.left;t--)this.computeNewCell(r,t,o,e)}break;case"right":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.left;e<=t.right;e++)n.push($t(e,o));const r=this.createGenerator(n);for(let t=i.left;t<=i.right;t++)this.computeNewCell(r,t,o,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const i=this.getters.getSelectedZone();if(ki(e,t,i))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,i.top-1,i.left,i.right),this.steps=i.top-t;break;case"down":this.saveZone(i.bottom+1,t,i.left,i.right),this.steps=t-i.bottom;break;case"left":this.saveZone(i.top,i.bottom,e,i.left-1),this.steps=i.left-e;break;case"right":this.saveZone(i.top,i.bottom,i.right+1,e),this.steps=e-i.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let i=e.left,o=e.bottom;if(i>0){let e=this.getters.getCell(t,i-1,o);for(;e&&!e.isEmpty();)o+=1,e=this.getters.getCell(t,i-1,o)}if(o===e.bottom&&(i=e.right,i<=this.getters.getNumberCols(t))){let e=this.getters.getCell(t,i+1,o);for(;e&&!e.isEmpty();)o+=1,e=this.getters.getCell(t,i+1,o)}o!==e.bottom&&(this.select(e.left,o-1),this.autofill(!0))}computeNewCell(e,t,i,o){const{cellData:n,tooltip:r,origin:s}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=r,o&&this.dispatch("AUTOFILL_CELL",{originCol:s.col,originRow:s.row,col:t,row:i,content:a,style:l,border:c,format:h})}getRule(e,t){const i=ho.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((i=>i.condition(e,t)));return i&&i.generateRule(e,t)}createGenerator(e){const t=[],i=[],o=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=kt(t),r=this.getters.getCell(o,e,n);i.push({col:e,row:n,cell:r,sheetId:o})}const n=i.map((e=>e.cell));for(let e of i){let i={type:"COPY_MODIFIER"};if(e&&e.cell){i=this.getRule(e.cell,n)||i}const{sheetId:o,col:r,row:s}=e,a=this.getters.getCellBorder(o,r,s)||void 0;t.push({data:{...e,border:a},rule:i})}return new ov(t,this.getters,this.direction)}saveZone(e,t,i,o){this.autofillZone={top:e,bottom:t,left:i,right:o}}getDirection(e,t){const i=this.getters.getSelectedZone(),o={up:{number:i.top-t,value:"up"},down:{number:t-i.bottom,value:"down"},left:{number:i.left-e,value:"left"},right:{number:e-i.right,value:"right"}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const n=o.up.number>0?"up":"down",r=o.left.number>0?"left":"right";return Math.abs(o[n].number)>=Math.abs(o[r].number)?o[n].value:o[r].value}autoFillMerge(e,t,i,o){const n=this.getters.getActiveSheet();if(this.getters.isInMerge(n.id,i,o)&&!this.getters.isInMerge(n.id,e,t)){const e=this.getters.getMerge(n.id,i,o);e&&this.dispatch("REMOVE_MERGE",{sheetId:n.id,target:[e]})}const r=this.getters.getMerge(n.id,e,t);(null==r?void 0:r.topLeft.col)===e&&(null==r?void 0:r.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:n.id,target:[{top:o,bottom:o+r.bottom-r.top,left:i,right:i+r.right-r.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:i}=e,{x:o,y:n,width:r,height:s}=this.getters.getVisibleRect(this.autofillZone);r>0&&s>0&&(t.strokeStyle="black",t.lineWidth=i,t.setLineDash([3]),t.strokeRect(o,n,r,s),t.setLineDash([]))}}nv.layers=[6],nv.getters=["getAutofillTooltip"];class rv extends xg{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:i}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,i.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,i){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,i):this.sumData(e,t)}sumData(e,t){const i=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,i).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return i.has("ROW")&&i.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,i){const{col:o,row:n}=ki(i.col,i.row,t)?i:{col:t.left,row:t.top},r=this.findAdjacentData(e,o,n);return r?this.getters.isSingleCellOrMerge(e,t)||Vi(Ni(r,t))?[{position:{col:o,row:n},zone:r}]:this.sumDimensions(e,Ni(r,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,i){const o=this.getters.getSheet(e),n=this.getters.getMainCellPosition(e,t,i),r=this.findSuitableZoneToSum(o,n.col,n.row);if(r)return this.getters.expandZone(e,r)}findSuitableZoneToSum(e,t,i){const o=this.getters.getCell(e.id,t,i-1),n=this.getters.getCell(e.id,t-1,i);if(this.isNumber(n)&&!this.isNumber(o))return this.findHorizontalZone(e,t,i);const r=this.findVerticalZone(e,t,i);if(this.isZoneValid(r))return r;const s=this.findHorizontalZone(e,t,i);return this.isZoneValid(s)?s:void 0}findVerticalZone(e,t,i){const o={top:0,bottom:i-1,left:t,right:t},n=this.reduceZoneStart(e,o,o.bottom);return{...o,top:n}}findHorizontalZone(e,t,i){const o={top:i,bottom:i,left:0,right:t-1},n=this.reduceZoneStart(e,o,o.right);return{...o,left:n}}reduceZoneStart(e,t,i){const o=this.getters.getCellsInZone(e.id,t),n=ke(i,-1,-1),r=n.filter((e=>{var t;return o[e]&&!(null===(t=o[e])||void 0===t?void 0:t.isAutoSummable)})),s=Math.max(...r),a=$e(n.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<s?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)===eo.number&&!(null===(t=e.evaluated.format)||void 0===t?void 0:t.match(X))}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 i=new Set;return Vi(t)?(i.add(1===Ui(t).width?"COL":"ROW"),i):(this.lastColIsEmpty(e,t)&&i.add("ROW"),this.lastRowIsEmpty(e,t)&&i.add("COL"),0===i.size&&i.add("COL"),i)}sumDimensions(e,t,i){return[...i.has("COL")?this.sumColumns(t,e):[],...i.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:i}=e;return{position:{col:i,row:t},zone:{...e,top:t,right:i-1}}}sumColumns(e,t){const i=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,i.bottom-1)},zi(i).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const i=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,i.right-1)},zi(i).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const i of t){const{col:t,row:o}=i.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,i.zone)})`})}}nextEmptyRow(e,t){let i=t.bottom+1;const{left:o,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:i,top:i,left:o,right:n});)i++;return{...t,top:i,bottom:i}}nextEmptyCol(e,t){let i=t.right+1;const{top:o,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:i,right:i,top:o,bottom:n});)i++;return{...t,left:i,right:i}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}rv.getters=["getAutomaticSums"];class sv extends xg{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{Uo.get(e.popoverType)}catch(e){return 71}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,type:e.popoverType}}}getCellPopover({col:e,row:t}){var i,o;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(n,this.persistentPopover.col,this.persistentPopover.row)){const e=this.getters.getMainCellPosition(n,this.persistentPopover.col,this.persistentPopover.row),t=null===(o=(i=Uo.get(this.persistentPopover.type)).onOpen)||void 0===o?void 0:o.call(i,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,...this.computePopoverProps(this.persistentPopover,t.cellCorner)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport(n,e,t))return{isOpen:!1};const r=this.getters.getMainCellPosition(n,e,t),s=Uo.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,r,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==s?void 0:s.isOpen)?{...s,...this.computePopoverProps(r,s.cellCorner)}:{isOpen:!1}}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverProps({col:e,row:t},i){const{width:o,height:n}=this.getters.getVisibleRect(Gi({col:e,row:t}));return{coordinates:this.computePopoverPosition({col:e,row:t},i),cellWidth:-o,cellHeight:-n}}computePopoverPosition({col:e,row:t},i){const o=this.getters.getActiveSheetId(),n=this.getters.getMerge(o,e,t);n&&(e="TopRight"===i?n.right:n.left,t="TopRight"===i?n.top:n.bottom);const{x:r,y:s,width:a,height:l}=this.getters.getVisibleRect(Gi({col:e,row:t}));switch(i){case"BottomLeft":return{x:r,y:s+l};case"TopRight":return{x:r+a,y:s}}}}sv.getters=["getCellPopover","getPersistentPopoverTypeAtPosition"],sv.modes=["normal"];class av{constructor(e,t,i,o){this.getters=t,this.dispatch=i,this.selection=o,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,i,o){const n=this.getters.getActiveSheetId(),r=t+o-this.getters.getNumberRows(n);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(n)-1,sheetId:n,quantity:r,position:"after"});const s=e+i-this.getters.getNumberCols(n);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(n)-1,sheetId:n,quantity:s,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class lv extends av{constructor(e,t,i,o,n){if(super(t,i,o,n),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const r=new Set(e.map((e=>e.left))),s=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===r.size&&1===s.size?function(e){return e.reduce(((e,t)=>{const i=e.length;for(let o=0;o<i;o++)if(Di(e[o],t))return e[o]=Ni(e[o],t),e;return e[i]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>zi(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=i.getActiveSheetId();for(let e of u){let t=[];for(let o of d)t.push({cell:i.getCell(p,o,e),border:i.getCellBorder(p,o,e)||void 0,position:{col:o,row:e,sheetId:p}});g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const i of ke(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues(p,i,e.zone.top));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const o=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(i,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(i,e[0])||o*n!=1))return 2;const{xSplit:r,ySplit:s}=this.getters.getPaneDivisions(i);for(const t of this.getPasteZones(e))if(t.left<r&&t.right>=r||t.top<s&&t.bottom>=s)return 74;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const i=this.cells.length,o=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(o,i,n,e)}pasteFromCopy(e,t){if(1===e.length){const i=this.cells.length,o=this.cells[0].length,n=this.pastedZones(e,o,i);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const i of e)for(let e=i.left;e<=i.right;e++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,o,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const i=e[0];this.pasteZone(i.left,i.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:i.left,row:i.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,i){const o=e[0],n=Math.max(1,Math.floor((o.right+1-o.left)/t)),r=Math.max(1,Math.floor((o.bottom+1-o.top)/i)),s=[];for(let e=0;e<n;e++)for(let n=0;n<r;n++){const r=o.top+n*i,a=o.left+e*t;s.push({left:a,top:r,bottom:r+i-1,right:a+t-1})}return s}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const i=[],o=t.length,n=t[0].length,r=e[e.length-1],s=r.left,a=r.top,l=Math.max(1,Math.floor((r.right+1-s)/n)),c=Math.max(1,Math.floor((r.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)i.push({left:s,top:a,right:s-1+e*n,bottom:a-1+t*o});return i}selectPastedZone(e,t,i,o){const n=o[0],r=n.left,s=n.top;if(t>1||e>1||i){const n=this.pastedZones(o,e,t),a=i?n[0]:Ni(...n);this.selection.selectZone({cell:{col:r,row:s},zone:a})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,i){const o=this.cells.length,n=this.cells[0].length,r="onlyValue"!==(null==i?void 0:i.pasteOption)&&(null==i?void 0:i.shouldPasteCF),s=this.getters.getActiveSheetId();this.addMissingDimensions(n,o,e,t);for(let a=0;a<o;a++){const o=this.cells[a];for(let l=0;l<n;l++){const n=o[l],c={col:e+l,row:t+a,sheetId:s};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,i),r&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,i,o){const{sheetId:n,col:r,row:s}=t,a=this.getters.getCell(n,r,s);if("onlyValue"!==(null==o?void 0:o.pasteOption)){const t=this.getters.getCellBorder(n,r,s),i=e.border,o={top:(null==t?void 0:t.top)||(null==i?void 0:i.top),bottom:(null==t?void 0:t.bottom)||(null==i?void 0:i.bottom),left:(null==t?void 0:t.left)||(null==i?void 0:i.left),right:(null==t?void 0:t.right)||(null==i?void 0:i.right)};this.dispatch("SET_BORDER",{sheetId:n,col:r,row:s,border:o})}if(e.cell){if("onlyFormat"===(null==o?void 0:o.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.cell.evaluated.format||e.cell.format});if("onlyValue"===(null==o?void 0:o.pasteOption)){const i=qt(e.cell.evaluated.value);return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula()&&"COPY"===i){const t=r-e.position.col,o=s-e.position.row;a=this.getUpdatedContent(n,e.cell,t,o,i)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,i,o,n){const r=this.getters.createAdaptedRanges(t.dependencies,i,o,e);return this.getters.buildFormulaContent(e,t,r)}pasteMergeIfExist(e,t){let{sheetId:i,col:o,row:n}=e;const{col:r,row:s}=this.getters.getMainCellPosition(i,o,n);if(r===o&&s===n){const e=this.getters.getMerge(i,o,n);if(!e)return;({sheetId:i,col:o,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:i,force:!0,target:[{left:o,top:n,right:o+e.right-e.left,bottom:n+e.bottom-e.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),i=e[0],o=this.zones[0],n=[i.left-o.left,i.top-o.top];for(const e of this.copiedTables){const i=Bi(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[i]});for(const o of ke(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:i.left+o,row:i.top,values:e.filtersValues[o]})}}getClipboardContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.cell,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let i of this.zones){if("COL"===t&&e<=i.right)return!0;if("ROW"===t&&e<=i.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:i}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*i;for(const e of this.zones){const{x:i,y:o,width:n,height:r}=this.getters.getVisibleRect(e);n>0&&r>0&&t.strokeRect(i,o,n,r)}}}}class cv{constructor(e,t,i){this.getters=t,this.dispatch=i,this.sheetId=t.getActiveSheetId();const o=t.getSelectedFigureId();if(!o)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,o);if(!n)throw new Error(`No figure for the given id: ${o}`);this.copiedFigure={...n};const r=t.getChart(o);if(!r)throw new Error(`No chart for the given id: ${o}`);this.copiedChart=r.copyInSheetId(this.sheetId),this.operation=e}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?72:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),i={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},o=this.copiedChart.copyInSheetId(t),n=(new wi).uuidv4();this.dispatch("CREATE_CHART",{id:n,sheetId:t,position:i,size:{height:this.copiedFigure.height,width:this.copiedFigure.width},definition:o.getDefinition()}),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedChart.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return"\t"}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class hv extends av{constructor(e,t,i,o){super("COPY",t,i,o),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId(),o=this.getPasteZone(e);return this.getters.doesIntersectMerge(i,o)?2:0}paste(e){const t=this.values,i=this.getPasteZone(e),{left:o,top:n}=i,{width:r,height:s}=Ui(i),a=this.getters.getActiveSheetId();this.addMissingDimensions(r,s,o,n);for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)this.dispatch("UPDATE_CELL",{row:n+e,col:o+i,content:t[e][i],sheetId:a});const l={left:o,top:n,right:o+r-1,bottom:n+s-1};this.selection.selectZone({cell:{col:o,row:n},zone:l})}getClipboardContent(){return this.values.map((e=>e.join("\t"))).join("\n")}getPasteZone(e){const t=this.values.length,i=Math.max(...this.values.map((e=>e.length))),{left:o,top:n}=e[0];return{top:n,left:o,bottom:n+t-1,right:o+i-1}}}class dv extends xg{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=e.target||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:i});case"PASTE_FROM_OS_CLIPBOARD":return new hv(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}}return 0}handle(e){var t,i;switch(e.type){case"COPY":case"CUT":const o="target"in e&&e.target||this.getters.getSelectedZones();this.state=this.getClipboardState(o,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const n=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Ri(t[0])){for(const{col:t,row:i}of zi(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:i,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(i=this.state)||void 0===i?void 0:i.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new hv(e.text,this.getters,this.dispatch,this.selection).paste(e.target),this.status="invisible";break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}default:ro(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o;return o="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(i)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o,n;return"COL"===t?(o={...e,right:this.getters.getNumberCols(i)-1},n={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:this.getters.getNumberRows(i)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1}),{cut:[o],paste:[n]}}getClipboardStateForCopyCells(e,t){return new lv(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new cv(t,this.getters,this.dispatch):new lv(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}dv.layers=[2],dv.getters=["getClipboardContent","isCutOperation","isPaintingFormat"];class uv extends xg{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const i=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(i),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:ft(255,0,0),colors:[]},{leadColor:ft(255,128,0),colors:[]},{leadColor:ft(128,128,0),colors:[]},{leadColor:ft(128,255,0),colors:[]},{leadColor:ft(0,255,0),colors:[]},{leadColor:ft(0,255,128),colors:[]},{leadColor:ft(0,255,255),colors:[]},{leadColor:ft(0,127,255),colors:[]},{leadColor:ft(0,0,255),colors:[]},{leadColor:ft(127,0,255),colors:[]},{leadColor:ft(128,0,128),colors:[]},{leadColor:ft(255,0,128),colors:[]}];for(const i of e.map(St)){let e=500,o=0;t.forEach(((t,n)=>{const r=(s=i,a=t.leadColor,Math.sqrt(Math.pow(s.r-a.r,2)+Math.pow(s.g-a.g,2)+Math.pow(s.b-a.b,2)));var s,a;e>r&&(e=r,o=n)})),t[o].colors.push(i)}return t.map((e=>e.colors.sort(((e,t)=>Et(e).s-Et(t).s)))).flat().map(bt)}([...new Set([...new Set([...e,...this.customColors])].filter(pt).map(gt))]).filter((e=>!O.includes(e)))}getColorsFromCells(e){var t,i;const o=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&o.add(n.style.textColor),(null===(i=n.style)||void 0===i?void 0:i.fillColor)&&o.add(n.style.fillColor);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),i=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(i.push(t.style.textColor),i.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(i.push(dt(t.minimum.color)),i.push(t.midpoint?dt(t.midpoint.color):void 0),i.push(dt(t.maximum.color)))}return i.filter(Xe)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let i=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&i.add(t),e.type){case"gauge":const t=e.sectionRule.colors;i.add(t.lowerColor),i.add(t.middleColor),i.add(t.upperColor);break;case"scorecard":const o=e;i.add(o.baselineColorDown),i.add(o.baselineColorUp)}}return[...i]}tryToAddColor(e){const t=gt(e);e&&!O.includes(t)&&this.customColors.add(t)}}uv.getters=["getCustomColors"];const gv=Ou.mapping;class pv extends xg{constructor(e,t,i,o,n){super(e,t,i,o,n),this.isUpToDate=!1,this.evalContext=o.evalContext}handle(e){switch(to.has(e.type)&&(this.isUpToDate=!1),e.type){case"UPDATE_CELL":("content"in e||"format"in e)&&(this.isUpToDate=!1);break;case"EVALUATE_CELLS":this.evaluate()}}finalize(){this.isUpToDate||this.evaluate()}evaluateFormula(e,t=this.getters.getActiveSheetId()){const i=bg(e),o=this.getCompilationParameters((()=>{})),n=[];for(let e of i.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return i.execute(n,...o).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>(null==e?void 0:e.formattedValue)||""))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>null==e?void 0:e.evaluated.value))}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){const e=this.getCompilationParameters(i),t={};for(const e of this.getAllCells())i(e);function i(i){if(!i.isFormula())return;const o=i.id,n=tt((()=>{if(e[2].__originCellXC=()=>{const t=e[2].getters.getCellPosition(o);return $t(t.col,t.row)},o in t)return null===t[o]?new d:i.evaluated;t[o]=null;try{const n=i.compiledFormula.execute(i.dependencies,...e);if(t[o]=!0,Array.isArray(n.value))throw new Error(r("This formula depends on invalid values"));return{value:n.value,format:i.format||n.format}}catch(i){return t[o]=!0,function(t){t instanceof Error||(t=new Error(t));const i=(null==t?void 0:t.errorType)||a.GenericError,o=e[2].__lastFnCalled||"";return new c(i,t.message.replace("[[FUNCTION_NAME]]",o),void 0!==t.logLevel?t.logLevel:l.error)}(i)}}));i.assignEvaluation(n)}this.isUpToDate=!0}getCompilationParameters(e){const t=Object.assign(Object.create(gv),this.evalContext,{getters:this.getters}),i=this.getters;function o(e){if(e.evaluated.type===eo.error)throw new c(e.evaluated.value,e.evaluated.error.message,e.evaluated.error.logLevel);return e.evaluated}return[function(e,t,n,s){if(t)return{value:Ii(e.zone)};if(!Ri(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(s?r("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",n.toString(),s.toString()):r("Function %s expects its parameters to be single values or single cell references, not ranges.",n.toString()));if(e.invalidSheetName)throw new Error(r("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!i.tryGetSheet(e.sheetId))throw new Error(r("Invalid sheet name"));return t=i.getCell(e.sheetId,e.zone.left,e.zone.top),!t||t.isEmpty()?{value:null,format:null==t?void 0:t.format}:o(t)}(e)},function(e){const n=e.sheetId;if(!Ri(e.zone))throw new u;const r=i.getSheetZone(n),s=[],a=_i(e.zone,r);if(!a)return s.push([]),s;for(let i=a.left;i<=a.right;i++){const n=[];for(let r=a.top;r<=a.bottom;r++){const s=t.getters.getCell(e.sheetId,i,r);n.push(s?o(s):void 0)}s.push(n)}return s},t]}}pv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues"];class mv extends xg{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=Yi.getAll();return function(i){const o=t.find((e=>e.match(i.type)));if(!o)throw new Error("No runtime builder for this chart.");return o.getChartRuntime(i,e)}}(this.getters)}handle(e){if(to.has(e.type)||io.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const i=t.zone.left,o=t.zone.top;return this.getters.getCellComputedStyle(t.sheetId,i,o).fillColor||w}}mv.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class fv extends xg{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.rulePredicate={CellIsRule:(e,t)=>{if(e&&e.evaluated.type===eo.error)return!1;const i=t.values.map(wp);switch(t.operator){case"IsEmpty":return!Xe(e)||""===e.evaluated.value.toString().trim();case"IsNotEmpty":return Xe(e)&&""!==e.evaluated.value.toString().trim();case"BeginsWith":return!(!e&&""===i[0])&&(Xe(e)&&(null==e?void 0:e.evaluated.value.toString().startsWith(i[0].toString())));case"EndsWith":return!(!e&&""===i[0])&&(Xe(e)&&e.evaluated.value.toString().endsWith(i[0].toString()));case"Between":return Xe(e)&&e.evaluated.value>=i[0]&&e.evaluated.value<=i[1];case"NotBetween":return!(Xe(e)&&e.evaluated.value>=i[0]&&e.evaluated.value<=i[1]);case"ContainsText":return Xe(e)&&e.evaluated.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!Xe(e)||!e.evaluated.value||-1==e.evaluated.value.toString().indexOf(i[0].toString());case"GreaterThan":return Xe(e)&&e.evaluated.value>i[0];case"GreaterThanOrEqual":return Xe(e)&&e.evaluated.value>=i[0];case"LessThan":return Xe(e)&&e.evaluated.value<i[0];case"LessThanOrEqual":return Xe(e)&&e.evaluated.value<=i[0];case"NotEqual":return!(!Xe(e)&&""===i[0])&&(Xe(e)&&e.evaluated.value!==i[0]);case"Equal":return!e&&""===i[0]||Xe(e)&&e.evaluated.value===i[0];default:console.warn(r("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((io.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),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 i=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(i,e.originCol,e.originRow);for(const t of o)this.adaptRules(i,t,[$t(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation)}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getCellComputedStyle(e,t,i){var o;const n=this.getters.getCell(e,t,i),r=this.computedStyles[e],s=r&&(null===(o=r[t])||void 0===o?void 0:o[i]),a={...null==n?void 0:n.style,...s};return this.getters.isFilterHeader(e,t,i)&&(a.bold=!0),a}getConditionalIcon(e,t){var i;const o=this.getters.getActiveSheetId(),n=this.computedIcons[o];return n&&(null===(i=n[e])||void 0===i?void 0:i[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const i=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t).reverse())try{switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let n of o.ranges){const r=this.getters.getRangeFromSheetXC(t,n).zone;for(let n=r.top;n<=r.bottom;n++)for(let s=r.left;s<=r.right;s++){const r=this.rulePredicate[o.rule.type];let a=this.getters.getCell(t,s,n);r&&r(a,o.rule)&&(i[s]||(i[s]=[]),i[s][n]=Object.assign((null===(e=i[s])||void 0===e?void 0:e[n])||{},o.rule.style))}}}}catch(e){}}parsePoint(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getRangeValues(this.getters.getRangeFromSheetXC(o,e)).filter(this.isCellValueNumber);switch(t.type){case"value":return"max"===i?Math.max(...n):Math.min(...n);case"number":return Number(t.value);case"percentage":const e=Math.min(...n);return e+(Math.max(...n)-e)*Number(t.value)/100;case"percentile":return vi(n,Number(t.value)/100,!0);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return o instanceof Promise?null:o;default:return null}}applyIcon(e,t){const i=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===i||null===o||i>o)return;const n=this.getters.getActiveSheetId(),r=this.getters.getRangeFromSheetXC(n,e).zone,s=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=r.top;e<=r.bottom;e++)for(let l=r.left;l<=r.right;l++){const r=this.getters.getCell(n,l,e);if((null==r?void 0:r.evaluated.type)!==eo.number)continue;const c=this.computeIcon(r.evaluated.value,o,t.upperInflectionPoint.operator,i,t.lowerInflectionPoint.operator,a);s[l]||(s[l]=[]),s[l][e]=c}}computeIcon(e,t,i,o,n,r){return"ge"===i&&e>=t||"gt"===i&&e>t?r[0]:"ge"===n&&e>=o||"gt"===n&&e>o?r[1]:r[2]}applyColorScale(e,t){var i;const o=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,r=this.parsePoint(e,t.maximum,"max");if(null===o||null===r||o>=r||n&&(o>=n||n>=r))return;const s=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(s,e).zone,l=this.computedStyles[s],c=[];t.midpoint&&n?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.midpoint.color)}),c.push({minValue:n,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(n,r,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,r,t.minimum.color,t.maximum.color)});for(let e=a.top;e<=a.bottom;e++)for(let t=a.left;t<=a.right;t++){const a=this.getters.getCell(s,t,e);if((null==a?void 0:a.evaluated.type)===eo.number){const s=Me(a.evaluated.value,o,r);let h;h=2===c.length&&n?s<=n?this.colorCell(s,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(s,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(s,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(i=l[t])||void 0===i?void 0:i[e])||{},l[t][e].fillColor=dt(h)}}}computeColorDiffUnits(e,t,i,o){const n=t-e;return[((i>>16)%256-(o>>16)%256)/n,((i>>8)%256-(o>>8)%256)/n,(i%256-o%256)/n]}colorCell(e,t,i,o){const[n,r,s]=o;return Math.round((i>>16)%256-n*(e-t))<<16|Math.round((i>>8)%256-r*(e-t))<<8|Math.round(i%256-s*(e-t))}adaptRules(e,t,i,o){if(0===i.length&&0===o.length)return;const n=this.getters.getConditionalFormats(e),r=n.findIndex((e=>e.id===t.id));let s=[];r>-1&&(s=n[r].ranges),s=s.concat(i);const a=Li(s,o);this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}pasteCf(e,t,i){const o=$t(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let r of n.ranges)if(ki(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,r).zone)){const r=n,s=[];"CUT"===i&&s.push($t(e.col,e.row)),e.sheetId===t.sheetId?this.adaptRules(e.sheetId,r,[o],s):(this.adaptRules(t.sheetId,r,[o],[]),this.adaptRules(e.sheetId,r,[],s))}}isCellValueNumber(e){return"number"==typeof e}}fv.getters=["getConditionalIcon","getCellComputedStyle"];class vv extends xg{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e.sheetId,e.col,e.row))return 78;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const i of this.getters.getFilters(e.sheetIdTo)){const o=i.zoneWithHeaders;t[i.id]=this.getFilterValues(e.sheetId,o.left,o.top)}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e,t,i){let o;for(let n of this.getters.getFilterTables(e)){const r=n.zone;if(ki(t,i,r)){const n=this.intersectZoneWithViewport(e,r);o={top:i===n.top?j:void 0,bottom:i===n.bottom?j:void 0,left:t===n.left?j:void 0,right:t===n.right?j:void 0}}}const n=this.getters.getCellBorder(e,t,i),r={...o,...st(n||{})};return Ke(r)?null:r}getFilterHeaders(e){const t=[];for(let i of this.getters.getFilterTables(e)){const o=i.zone;if(!o)continue;const n=o.top;for(let i=o.left;i<=o.right;i++)this.getters.isColHidden(e,i)||this.getters.isRowHidden(e,n)||t.push({col:i,row:n})}return t}getFilterValues(e,t,i){const o=this.getters.getFilterId(e,t,i);return o&&this.filterValues[e]&&this.filterValues[e][o]||[]}isFilterHeader(e,t,i){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===i))}isFilterActive(e,t,i){var o,n;const r=this.getters.getFilterId(e,t,i);return Boolean(r&&(null===(n=null===(o=this.filterValues[e])||void 0===o?void 0:o[r])||void 0===n?void 0:n.length))}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,"COL",t.left,t.right),right:this.getters.findVisibleHeader(e,"COL",t.right,t.left),top:this.getters.findVisibleHeader(e,"ROW",t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,"ROW",t.bottom,t.top)}}updateFilter({col:e,row:t,values:i,sheetId:o}){const n=this.getters.getFilterId(o,e,t);n&&(this.filterValues[o]||(this.filterValues[o]={}),this.filterValues[o][n]=i)}updateHiddenRows(){var e,t;const i=this.getters.getActiveSheetId(),o=this.getters.getFilters(i).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),n=new Set;for(let r of o){if(this.getters.isRowHiddenByUser(i,r.zoneWithHeaders.top))continue;if(n.has(r.zoneWithHeaders.top))continue;const o=null===(t=null===(e=this.filterValues[i])||void 0===e?void 0:e[r.id])||void 0===t?void 0:t.map(at);if(o&&r.filteredZone)for(let e=r.filteredZone.top;e<=r.filteredZone.bottom;e++){const t=this.getCellValueAsString(i,r.col,e);o.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,i){var o;const n=null===(o=this.getters.getCell(e,t,i))||void 0===o?void 0:o.formattedValue;return(null==n?void 0:n.toLowerCase())||""}exportForExcel(e){var t;for(const i of e.sheets)for(const e of i.filterTables){const o=xi(e.range),n=[],r=[];for(const e of ke(0,Ui(o).width)){const s=this.getFilterValues(i.id,o.left+e,o.top),a=this.getters.getFilter(i.id,o.left+e,o.top);if(!a)continue;const l=a.filteredZone?zi(a.filteredZone).map((e=>{var t;return null===(t=this.getters.getCell(i.id,e.col,e.row))||void 0===t?void 0:t.formattedValue})):[];if(s.length){const t=l.filter(Ye).filter((e=>!s.includes(e)));n.push({colId:e,displayedValues:[...new Set(t)],displayBlanks:!s.includes("")&&l.some((e=>!e))})}const c={col:a.col,row:a.zoneWithHeaders.top},h=null===(t=this.getters.getCell(i.id,c.col,c.row))||void 0===t?void 0:t.formattedValue,d=this.getUniqueColNameForExcel(e,h,r);r.push(d),i.cells[$t(c.col,c.row)]={...i.cells[$t(c.col,c.row)],content:d,value:d,isFormula:!1}}e.filters=n}}getUniqueColNameForExcel(e,t,i){t||(t=`Column${e}`);let o=t,n=2;for(;i.includes(o);)o=t+String(n),n++;return o}}vv.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];var bv;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(bv||(bv={}));class Sv extends xg{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch="",this.isSearchDirty=!1}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(bv.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(bv.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"EVALUATE_CELLS":case"UPDATE_CELL":case"REMOVE_FILTER_TABLE":case"UPDATE_FILTER":this.isSearchDirty=!0;break;case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"ACTIVATE_SHEET":this.refreshSearch()}}finalize(){this.isSearchDirty&&(this.refreshSearch(),this.isSearchDirty=!1)}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(bv.current)}updateRegex(){let e=Ie(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),i=[];if(this.toSearch)for(const o of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(o.id),r=this.getters.isColHidden(e,t),s=this.getters.isRowHidden(e,n);if(!r&&!s&&(o&&this.currentSearchRegex&&this.currentSearchRegex.test(this.searchOptions.searchFormulas&&o.isFormula()?o.content:String(o.evaluated.value)))){const e=this.getters.getCellPosition(o.id),t={col:e.col,row:e.row,selected:!1};i.push(t)}}return i.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 i;i=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,i=(i%t.length+t.length)%t.length,null!==this.selectedMatchIndex&&this.selectedMatchIndex===i||(this.selectedMatchIndex=i,this.selection.selectCell(t[i].col,t[i].row));for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],i=this.getters.getActiveSheetId(),o=this.getters.getCell(i,t.col,t.row),n=this.toReplace(o,i);if(o&&n){const i=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),o=n.toString().replace(i,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:o}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(bv.current)}else this.selectNextCell(bv.next)}replaceAll(e){const t=this.searchMatches.length;for(let i=0;i<t;i++)this.replace(e)}toReplace(e,t){if(e){if(this.searchOptions.searchFormulas&&e.isFormula())return e.content;if(this.searchOptions.searchFormulas||!e.isFormula())return e.evaluated.value.toString()}return null}drawGrid(e){const{ctx:t}=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,s=o?o.top:e.row,a=o?o.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:s,left:n,right:r,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}Sv.layers=[3],Sv.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class Cv extends xg{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,i){const o=this.searchNumberFormat(e,t);if(void 0!==o){const n=function(e,t){const i=Gt(e).map((e=>"NUMBER"===e.type?{...e,format:oi(e.format,t)}:e)),o=ai(i);return Wt[o]=i,o}(o,i);this.dispatch("SET_FORMATTING",{sheetId:e,target:t,format:n})}}searchNumberFormat(e,t){var i;for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++){const o=this.getters.getCell(e,n,t);if((null==o?void 0:o.evaluated.type)===eo.number&&!(null===(i=o.evaluated.format)||void 0===i?void 0:i.match(X)))return o.evaluated.format||ti(o.evaluated.value)}}}Cv.modes=["normal"];class Ev extends xg{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,i){return"COL"===t?this.isColHidden(e,i):this.isRowHidden(e,i)}getNextVisibleCellPosition(e,t,i){return{col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",i,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,i,o){if(i<=o)for(let n=i;n<=o;n++)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n;if(i>o)for(let n=i;n>=o;n--)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n}findLastVisibleColRowIndex(e,t,i){let o;for(o=i.last;o>=i.first;o--)if(!this.isHeaderHidden(e,t,o))return o;return o}findFirstVisibleColRowIndex(e,t){const i=this.getters.getNumberHeaders(e,t);for(let o=0;o<i;o++){if("COL"===t&&!this.isColHidden(e,o))return o;if("ROW"===t&&!this.isRowHidden(e,o))return o}}exportForExcel(e){for(const t of e.sheets)for(const[e,i]of Object.entries(t.rows)){const o=this.isRowHidden(t.id,Number(e));i.isHidden=o}}}Ev.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class wv extends xg{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{height:t,width:i}=Ui(e.zone),o=t*i==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:o}}))}drawGrid(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;const r=this.getHighlights();for(let e of r.filter(((e,t)=>r.findIndex((t=>Fi(t.zone,e.zone)&&t.sheetId===o))===t))){const{x:i,y:o,width:r,height:s}=this.getters.getVisibleRect(e.zone);r>0&&s>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,r-n,s-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,r-2*n,s-2*n))}}}wv.layers=[1],wv.getters=["getHighlights"];class yv extends xg{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleCols()),o=this.getters.getColRowOffsetInViewport("COL",i,t),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleRows()),o=this.getters.getColRowOffsetInViewport("ROW",i,t),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,i){let o=this.getters.getColRowOffsetInViewport(e,t,i);return this.getters.isDashboard()||(o+="ROW"===e?M:N),o}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:i}=e,{width:o,height:n}=this.getters.getSheetViewDimensionWithHeaders(),r=this.getters.getActiveSheetId();t.fillStyle="#ffffff",t.fillRect(0,0,o+m,n+m);const s=this.getters.getSheetViewVisibleCols(),a=s[0],l=s[s.length-1],c=this.getters.getSheetViewVisibleRows(),h=c[0],d=c[c.length-1];if(this.getters.getGridLinesVisibility(r)&&!this.getters.isDashboard()){t.lineWidth=2*i,t.strokeStyle="#E2E3E3",t.beginPath();for(const e of s){const i={top:h,bottom:d,left:e,right:e},{x:o,width:r,height:s}=this.getters.getVisibleRect(i);t.moveTo(o+r,0),t.lineTo(o+r,Math.min(n,s+(this.getters.isDashboard()?0:M)))}for(const e of c){const i={left:a,right:l,top:e,bottom:e},{y:n,width:r,height:s}=this.getters.getVisibleRect(i);t.moveTo(0,n+s),t.lineTo(Math.min(o,r+(this.getters.isDashboard()?0:N)),n+s)}t.stroke()}}drawCellBackground(e){const{ctx:t,thinLineWidth:i}=e,o=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());t.lineWidth=o?.3*i:i;const n=o?.1*i:0;t.strokeStyle="#111";for(let e of this.boxes){let r=e.style;(r.fillColor&&"#ffffff"!==r.fillColor||e.isMerge)&&(t.fillStyle=r.fillColor||"#ffffff",o?(t.fillRect(e.x,e.y,e.width,e.height),t.strokeRect(e.x+n,e.y+n,e.width-2*n,e.height-2*n)):t.fillRect(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:i}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:n,width:r,height:s}=e;t.left&&o(t.left,i,n,i,n+s),t.top&&o(t.top,i,n,i+r,n),t.right&&o(t.right,i+r,n,i+r,n+s),t.bottom&&o(t.bottom,i,n+s,i+r,n+s)}}function o([e,o],n,r,s,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*i,t.beginPath(),t.moveTo(n,r),t.lineTo(s,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:i}=e;let o;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},r=e.content.align||"left",s=Fe(n);let a;s!==o&&(o=s,t.font=s),t.fillStyle=n.textColor||"#000";let l=e.y+e.height/2+1;if(a="left"===r?e.x+(e.image?e.image.size+2*L:P):"right"===r?e.x+e.width-P-(e.isFilterHeader?20:0):e.x+e.width/2,t.textAlign=r,e.clipRect){t.save(),t.beginPath();const{x:i,y:o,width:n,height:r}=e.clipRect;t.rect(i,o,n,r),t.clip()}const c=e.content.multiLineText.length,h=De(n);let d=l-(c*(h+P)-P)/2;for(let o of e.content.multiLineText){if(t.fillText(o,Math.round(a),Math.round(d)),n.strikethrough||n.underline){const e=Ne(t,o,n);let s=a;"right"===r?s-=e:"center"===r&&(s-=e/2),n.strikethrough&&t.fillRect(s,d+h/2,e,2.6*i),n.underline&&t.fillRect(s,d+h+1,e,1.3*i)}d+=P+h}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const i=e.image.image,o=e.image.size,n=(e.height-o)/2;if(e.image.clipIcon){t.save(),t.beginPath();const{x:i,y:o,width:n,height:r}=e.image.clipIcon;t.rect(i,o,n,r),t.clip()}t.drawImage(i,e.x+L,e.y+n,o,o),e.image.clipIcon&&t.restore()}}drawHeaders(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getSheetViewVisibleCols(),n=o[0],r=o[o.length-1],s=this.getters.getSheetViewVisibleRows(),a=s[0],l=s[s.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let i of e)for(let e of ke(i.left,i.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let i of e)for(let e of ke(i.top,i.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${q}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333";for(let e=n;e<=r;e++){const i={left:e,right:e,top:0,bottom:f-1},{x:o,width:n}=this.getters.getVisibleRect(i),r=this.getters.doesZonesContainFilter(p,[i]),s=E.has(e),a=u.has(e);t.fillStyle=s?r?I:S:a?r?A:b:r?T:v,t.fillRect(o,0,n,M)}for(let e=a;e<=l;e++){const i={top:e,bottom:e,left:0,right:m-1},{y:o,height:n}=this.getters.getVisibleRect(i),r=this.getters.doesZonesContainFilter(p,[i]),s=w.has(e),a=g.has(e);t.fillStyle=s?r?I:S:a?r?A:b:r?T:v,t.fillRect(0,o,N,n)}t.beginPath(),t.moveTo(N,0),t.lineTo(N,h),t.moveTo(0,M),t.lineTo(c,M),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of o){const i=this.getters.getColSize(p,e),o=Ft(e);t.fillStyle=E.has(e)?"#fff":C;let r=this.getHeaderOffset("COL",n,e);t.fillText(o,r+i/2,13),t.moveTo(r+i,0),t.lineTo(r+i,M)}for(const e of s){const i=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let o=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,o+i/2),t.moveTo(0,o+i),t.lineTo(N,o+i)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),r=this.getters.isDashboard()?0:N,s=this.getters.isDashboard()?0:M;t.lineWidth=6*i,t.strokeStyle="#BCBCBC",t.beginPath(),o&&(t.moveTo(r+o,0),t.lineTo(r+o,s)),n&&(t.moveTo(0,s+n),t.lineTo(r,s+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),r=this.getters.getSheetViewVisibleCols(),s=r[0],a=r[r.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:s,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:N,u=this.getters.isDashboard()?0:M;t.lineWidth=6*i,t.strokeStyle="#DADFE8",t.beginPath(),o&&(t.moveTo(d+o,u),t.lineTo(d+o,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}hasContent(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getCell(i,e,t);return o&&!o.isEmpty()||this.getters.isInMerge(i,e,t)}findNextEmptyCol(e,t,i){let o=e;for(;o<t&&!this.hasContent(o+1,i);)o++;return o}findPreviousEmptyCol(e,t,i){let o=e;for(;o>t&&!this.hasContent(o-1,i);)o--;return o}computeCellAlignment(e,t){if(e.isFormula()&&this.getters.shouldShowFormulas())return"left";const{align:i}=this.getters.getCellStyle(e);return t&&e.evaluated.type===eo.number?"center"!==i?"left":i:i||e.defaultAlign}createZoneBox(e,t,i){const{left:o,right:n}=i,r=t.left,s=t.top,a=this.getters.getCell(e,r,s),c=this.getters.shouldShowFormulas(),{x:h,y:d,width:u,height:g}=this.getters.getVisibleRect(t),p={x:h,y:d,width:u,height:g,border:this.getters.getCellBorderWithFilterBorder(e,r,s)||void 0,style:this.getters.getCellComputedStyle(e,r,s)};if(!a)return p;const m=this.getters.getConditionalIcon(r,s),f=De(p.style),v=m?2*L+f:0;m&&(p.image={type:"icon",size:f,clipIcon:{x:p.x,y:p.y,width:Math.min(v,u),height:g},image:os[m].img}),p.isFilterHeader=this.getters.isFilterHeader(e,r,s);const b=p.isFilterHeader?19:0,S=this.getters.getCellText(a,c),C=this.getters.getTextWidth(a),E=this.getters.getCellStyle(a).wrapping||"overflow",w="wrap"===E?this.getters.getCellMultiLineText(a,u-2*P):[S],y=v+C+b,x=this.computeCellAlignment(a,y>u);p.content={multiLineText:w,width:"overflow"===E?C:u,align:x},a.evaluated.type===eo.error&&a.evaluated.error.logLevel>l.silent&&(p.error=a.evaluated.error.message);const R=y>u||f>g;if(m||p.isFilterHeader)p.clipRect={x:p.x+v,y:p.y,width:Math.max(0,u-v-b),height:g};else if(R&&"overflow"===E){let i,a;switch(this.getters.isInMerge(e,r,s)?(i=this.getters.getMerge(e,r,s).right,a=r):(i=this.findNextEmptyCol(r,n,s),a=this.findPreviousEmptyCol(r,o,s)),x){case"left":{const e=Gi({col:i,row:s}),{x:o,y:n,width:r,height:a}=this.getters.getVisibleRect(Ni(t,e));(r<C||f>a)&&(p.clipRect={x:o,y:n,width:r,height:a});break}case"right":{const e=Gi({col:a,row:s}),{x:i,y:o,width:n,height:r}=this.getters.getVisibleRect(Ni(t,e));(n<C||f>r)&&(p.clipRect={x:i,y:o,width:n,height:r});break}case"center":{const e={...t,right:i,left:a},{x:o,y:n,width:s,height:l}=this.getters.getVisibleRect(e);(s<C||a===r||i===r||f>l)&&(p.clipRect={x:o,y:n,width:s,height:l});break}}}else"clip"!==E&&"wrap"!==E||(p.clipRect={x:p.x,y:p.y,width:u,height:g});return p}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),i=t[0],o=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),r={left:i,right:o,top:n[0],bottom:n[n.length-1]},s=this.getters.getActiveSheetId();for(const i of n)for(const o of t)this.getters.isInMerge(s,o,i)||e.push(this.createZoneBox(s,Gi({col:o,row:i}),r));for(const t of this.getters.getMerges(s))if(!this.getters.isMergeHidden(s,t)&&Di(t,r)){const i=this.createZoneBox(s,t,r),o=this.getters.getCellBorder(s,t.right,t.bottom);i.border={...i.border,bottom:o?o.bottom:void 0,right:o?o.right:void 0},i.isMerge=!0,e.push(i)}return e}}yv.layers=[0,7],yv.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];const xv=[{name:r("Sum"),types:[eo.number],compute:e=>Ya.compute([e])},{name:r("Avg"),types:[eo.number],compute:e=>al.compute([e])},{name:r("Min"),types:[eo.number],compute:e=>xl.compute([e])},{name:r("Max"),types:[eo.number],compute:e=>Cl.compute([e])},{name:r("Count"),types:[eo.number,eo.text,eo.boolean,eo.error],compute:e=>ml.compute([e])},{name:r("Count Numbers"),types:[eo.number,eo.text,eo.boolean,eo.error],compute:e=>pl.compute([e])}];class Rv extends xg{constructor(e,t,i,o,n){super(e,t,i,o,n),this.gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]},this.selectedFigureId=null,this.sheetsData={},this.activeSheet=null,this.moveClient=o.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 27}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let i=[];switch(e.mode){case"overrideSelection":i=[t.zone];break;case"updateAnchor":i=[...this.gridSelection.zones];const o=i.findIndex((t=>Fi(t,e.previousAnchor.zone)));o>=0&&(i[o]=t.zone);break;case"newAnchor":i=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,i),this.selection.resetDefaultAnchor(this,Te(this.gridSelection.anchor));const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:o,row:n}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:i,row:o}=this.getters.getNextVisibleCellPosition(t,0,0);this.selectCell(i,o),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:Te(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Te(this.gridSelection.anchor));else{const{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0);this.selectCell(t,i)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const n=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of n)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Te(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:i})}const r=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(r,e))),this.gridSelection.anchor.zone=this.getters.expandZone(r,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,Te(this.gridSelection.anchor))}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){const e=this.getters.getActiveSheetId(),{col:t,row:i}=this.gridSelection.anchor.cell,{col:o,row:n}=this.getters.getMainCellPosition(e,t,i);return this.getters.getCell(e,o,n)}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let i=t.left;i<=t.right;i++)e.add(i);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let i of this.gridSelection.zones)if(0===i.left&&i.right===this.getters.getNumberCols(t)-1)for(let t=i.top;t<=i.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getActiveCell();return e?this.getters.getCellStyle(e):{}}getSelectedZones(){return Te(this.gridSelection.zones)}getSelectedZone(){return Te(this.gridSelection.anchor.zone)}getSelection(){return Te(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getPosition(){return{col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row}}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getPosition();{const t=this.sheetsData[e];return t?{col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition(e,0,0)}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>void 0!==e)));let t=new Set,i=[];for(let o of e)t.add(o.evaluated.type),i.push(o.evaluated.value);let o={};for(let e of xv){let n;e.types.some((e=>t.has(e)))&&(n=e.compute(i)),o[e.name]=n}return o}getAggregate(){let e=0,t=0;const i=this.getters.getActiveSheetId(),o=this.gridSelection.zones.map(zi).flat();for(const{col:n,row:r}of o){const o=this.getters.getCell(i,n,r);(null==o?void 0:o.evaluated.type)===eo.number&&(t++,e+=o.evaluated.value)}return t<2?null:qt(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Fi(t,e)))}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 i=[];const o="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[o]+1},((t,i)=>e[o]+i));i=i.concat(t)}return[...new Set(i)].sort()}setSelectionMixin(e,t){const{anchor:i,zones:o}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=i,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,i)=>t===i.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(o)}selectCell(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.expandZone(i,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:o,cell:{col:e,row:t}},[o])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),i=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[i]})}onColumnsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Oi(i,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Oi(n,"left",[...e.elements]);const r={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(r,[o])}onRowsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Oi(i,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Oi(n,"top",[...e.elements]);const r={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(r,[o])}onAddElements(e){const t=Ai(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(i,[t])}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 i="COL"===e.dimension,o=e.elements[0],n=e.elements[t-1],r=e.base<o,s=r&&i?t:0,a=r&&!i?t:0;this.dispatch("CUT",{target:[{left:i?o+s:0,right:i?n+s:this.getters.getNumberCols(e.sheetId)-1,top:i?0:o+a,bottom:i?this.getters.getNumberRows(e.sheetId)-1:n+a}]}),this.dispatch("PASTE",{target:[{left:i?e.base:0,right:i?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:i?0:e.base,bottom:i?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=r?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const i="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:i,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,i=e.elements[0],o=e.elements[e.elements.length-1],n=e.sheetId,r=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return r(n,i-1,i)||r(n,o,o+1)||r(n,e.base-1,e.base)?2:0}clipSelection(e,t){const i=this.getters.getNumberCols(e)-1,o=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:Me(e.left,0,i),right:Me(e.right,0,i),top:Me(e.top,0,o),bottom:Me(e.bottom,0,o)}))),anchor:{cell:{col:Me(t.anchor.cell.col,0,i),row:Me(t.anchor.cell.row,0,o)},zone:{left:Me(t.anchor.zone.left,0,i),right:Me(t.anchor.zone.right,0,i),top:Me(t.anchor.zone.top,0,o),bottom:Me(t.anchor.zone.bottom,0,o)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*i,t.globalCompositeOperation="multiply";for(const e of o){const{x:i,y:o,width:n,height:r}=this.getters.getVisibleRect(e);t.fillRect(i,o,n,r),t.strokeRect(i,o,n,r)}t.globalCompositeOperation="source-over";const r=this.getters.getActiveSheetId(),{col:s,row:a}=this.getPosition();let l;t.strokeStyle=E,t.lineWidth=3*i,l=this.getters.isInMerge(r,s,a)?this.getters.getMerge(r,s,a):{top:a,bottom:a,left:s,right:s};const{x:c,y:h,width:d,height:u}=this.getters.getVisibleRect(l);d>0&&u>0&&t.strokeRect(c,h,d,u)}}Rv.layers=[5],Rv.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getPosition","getSheetPosition","isSelected","getElementsFromSelection"];const Iv=new wi;class Tv extends xg{constructor(e,t,i,o,n,r,s){if(s&&r.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e,t,i,o,n),this.inputHasSingleRange=s,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,r),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){switch(e.type){case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange&&1===this.ranges.length)return 29;break;case"CHANGE_RANGE":if(this.inputHasSingleRange&&e.value.split(",").length>1)return 29}return 0}handleEvent(e){const t=Ii(e.anchor.zone),i=this.activeSheet,o=this.getters.getActiveSheetId(),n=this.getters.getSheetName(o);this.add([o===i?t:`${Oe(n)}!${t}`])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const i=e.value.split(",").map((e=>e.trim()));this.setRange(t,i)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),o=this.getters.expandZone(e.sheetIdTo,Gi({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}}}unsubscribe(){this.unfocus()}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],id:Iv.uuidv4(),xc:t}}insertNewRange(e,t){this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:(this.ranges.length+t+1).toString(),color:(ut=++ut%ht.length,ht[ut])}))))}setRange(e,t){const[,...i]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,i),i.length&&this.focus(e+i.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const i=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return i.map((e=>{const{sheetName:i}=_t(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:i&&this.getters.getSheetIdByName(i)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:i}=_t(t),o=this.getters.getSheetIdByName(i),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(o===n||void 0===o&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}Tv.layers=[1],Tv.getters=[];class Av extends xg{get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e,t,i,o,n){super(e,t,i,o,n),this.state=t,this.config=o,this.inputs={},this.focusedInputId=null}allowDispatch(e){var t,i;if("FOCUS_RANGE"===e.type){const o=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(i=this.currentInput)||void 0===i?void 0:i.focusedRangeIndex)===o)return 28}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){var t;switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:Gi({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}unsubscribe(){this.unfocus()}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,i)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===i}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:i}=_t(e);return null!==t.match(Tt)&&(!i||void 0!==this.getters.getSheetIdByName(i))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,i=!1){if(this.inputs[e]=new Tv(this.getters,this.state,this.dispatch,this.config,this.selection,t,i),0===t.length){const t=this.inputs[e],i={zone:Gi({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,i,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}Av.layers=[1],Av.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class Ov{constructor(){this.subscriptions={}}on(e,t,i){if(!i)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:i})}trigger(e,t){const i=this.subscriptions[e]||[];for(let e=0,o=i.length;e<o;e++){const o=i[e];o.callback.call(o.owner,t)}}off(e,t){const i=this.subscriptions[e];i&&(this.subscriptions[e]=i.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function Mv(e,t){return{...e,definition:yr(e.definition,t)}}function Nv(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let i=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)i>t&&i--}if("ADD_COLUMNS_ROWS"===t.type){i=i>("before"===t.position?t.base-1:t.base)?i+t.quantity:i}return i>0?{...e,quantity:i}:void 0}Gn.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Mv),Gn.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Mv),Gn.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const i=t.sheetId;if(e.targetSheetId===i||e.sheetId===i)return;return e})),Gn.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),Gn.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var i;if(e.name===t.name)return{...e,name:(null===(i=e.name)||void 0===i?void 0:i.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),Gn.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const i=[];for(const o of e.target)for(const e of t.target)Di(o,e)||i.push({...o});if(i.length)return{...e,target:i};return})),Gn.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Nv),Gn.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Nv),Gn.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const i of e.target)for(const e of t.target)if(Di(e,i))return;return e}));const _v=[{match:function(e){return"sheetId"in e},fn:kv},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const i=kv(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;const o=[];for(const i of e.target){const e=Qn(i,t);e&&o.push(e)}if(!o.length)return"IGNORE_COMMAND";return{...e,target:o}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const i=kv(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const i="COL"===t.dimension?"col":"row";let o=e[i];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[i]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const i of t.target){if(!(e.col===i.left&&e.row===i.top)&&ki(e.col,e.row,i))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const i=kv(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const i="ADD_COLUMNS_ROWS"===e.type,o=i?"base":"elements";let n=i?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const i=t.elements.sort(((e,t)=>t-e));for(let t of i)e>t&&e--;return e})).filter(Xe)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((i=>i>e?i+t.quantity:i))}if(n.length){let t=n;return i&&(t=n[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const i=[],o="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)i.push({...n,_zone:n._zone});else{const e=Qn(n._zone,t);e&&o!==n._sheetId&&i.push({...n,_zone:e})}if(!i.length)return"IGNORE_COMMAND";return{...e,ranges:i}}}];function Fv(e,t){const i=Gn.getTransformation(e.type,t.type);return i?i(e,t):function(e,t){for(const{match:i,fn:o}of _v)if(i(e)){const i=o(e,t);if("SKIP_TRANSFORMATION"===i)continue;if("IGNORE_COMMAND"===i)return;e=i}return e}(e,t)}function Dv(e,t){let i=[...e];for(const e of t)i=i.map((t=>Fv(t,e))).filter(Xe);return i}function kv(e,t){const i="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===i?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class $v{constructor(e,t,i,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...i],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Lv extends Error{}class Pv extends Ov{constructor(e,t,i=K){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=i,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new wi,this.debouncedMove=Je(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const i=new $v(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new Lv("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(Xe))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const i=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==i?void 0:i.col)===e.col&&i.row===e.row&&i.sheetId===e.sheetId)return;const o=i?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:o,version:1,client:{...n,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:i}=e,o=new $v(e.nextRevisionId,t,i);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:Dv(i,t)})}break;case"SNAPSHOT_CREATED":{const t=new $v(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){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Uv=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class Vv extends xg{constructor(){super(...arguments),this.availableColors=new Set(Uv),this.colors={}}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(Uv));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 Lv)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const i of this.getters.getConnectedClients())if(i.id!==this.getters.getClient().id&&i.position&&i.position.sheetId===e&&this.isPositionValid(i.position)){const e=i.position;this.colors[i.id]||(this.colors[i.id]=this.chooseNewColor());const o=this.colors[i.id];t.push({...i,position:e,color:o})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:r}=e.position,s=this.getters.expandZone(o,{top:n,bottom:n,left:r,right:r}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(s);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*i,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${G+1}px ${q}`}}}Vv.getters=["getClientsToDisplay"],Vv.layers=[5];class zv{constructor(e,t,i,o,n,r){this.getters=e,this.sheetId=t,this.boundaries=i,this.viewportWidth=o.width,this.viewportHeight=o.height,this.offsetScrollbarX=r.x,this.offsetScrollbarY=r.y,this.canScrollVertically=n.canScrollVertically,this.canScrollHorizontally=n.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const e=this.getters.findLastVisibleColRowIndex(this.sheetId,"COL",{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,"ROW",{first:this.boundaries.top,last:this.boundaries.bottom}),{end:i,size:o}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:r}=this.getters.getRowDimensions(this.sheetId,t),s=this.searchHeaderIndex("COL",i-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,s),l=this.searchHeaderIndex("ROW",n-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=i-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(_,Math.min(a,this.viewportWidth-o)),h=Math.max(h,this.viewportWidth));let d=n-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(F+5,Math.min(c,this.viewportHeight-r)),d=Math.max(d,this.viewportHeight)),{width:h,height:d}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const i=this.getters.getMainCellPosition(t,e.col,e.row),{col:o,row:n}=this.getters.getNextVisibleCellPosition(t,i.col,i.row);ki(o,this.boundaries.top,this.boundaries)&&this.adjustPositionX(o),ki(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{end:i}=this.getters.getColDimensions(t,e),o=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<i)for(let e=this.left;this.offsetX+this.offsetCorrectionX+this.viewportWidth<i&&!(e>o);e++)this.getters.isColHidden(t,e)||(this.offsetX=this.getters.getColDimensions(t,e).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX());else if(this.left>e)for(let i=this.left;i>=e&&!(i<0);i--)this.getters.isColHidden(t,i)||(this.offsetX=this.getters.getColDimensions(t,i).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX())}adjustPositionY(e){const t=this.sheetId,{end:i}=this.getters.getRowDimensions(t,e),o=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<i)for(let e=this.top;this.offsetY+this.viewportHeight+this.offsetCorrectionY<i&&!(e>o);e++)this.getters.isRowHidden(t,e)||(this.offsetY=this.getters.getRowDimensions(t,e).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY());else if(this.top>e)for(let i=this.top;i>=e&&!(i<0);i--)this.getters.isRowHidden(t,i)||(this.offsetY=this.getters.getRowDimensions(t,i).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY())}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=_i(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.viewportWidth),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.viewportHeight)}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,i=0,o=!1){let n=0;const r=this.sheetId,s=this.getters.getNumberHeaders(r,e);for(let a=i;a<=s-1;a++){const i=o||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(r,e,a)&&!i&&(n+="COL"===e?this.getters.getColSize(r,a):this.getters.getRowSize(r,a),n>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportWidth,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.viewportWidth,this.left)),-1===this.left&&(this.left=this.boundaries.left),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.viewportHeight,this.top)),-1===this.top&&(this.top=this.boundaries.top),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}class Bv extends xg{constructor(){super(...arguments),this.viewports={},this.sheetViewWidth=1e3,this.sheetViewHeight=1e3,this.gridOffsetX=0,this.gridOffsetY=0,this.sheetsWithDirtyViewports=new Set}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){switch(e.type){case"HeadersSelected":case"AlterZoneCorner":break;case"ZonesSelected":let{col:t,row:i}=Hi(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const o=e.previousAnchor.zone,n=e.anchor.zone,{top:r,bottom:s,left:a,right:l}=this.getters.getActiveMainViewport();o.left===n.left&&o.right===n.right&&(t=a>t||t>l?a:t),o.top===n.top&&o.bottom===n.bottom&&(i=r>i||i>s?r:i)}const o=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(o)-1),i=Math.min(i,this.getters.getNumberRows(o)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:i})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:i}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(o,i).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(i);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"START_EDITION":const{col:r,row:s}=this.getters.getPosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:r,row:s})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){var e;const t=this.getters.getSheetIds();for(const i of t)(null===(e=this.viewports[i])||void 0===e?void 0:e.bottomRight)||this.resetViewports(i)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>ke(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>ke(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);let{width:n,height:r}=t.getMaxSize();return{x:this.getters.getColDimensions(e,i).start,y:this.getters.getRowDimensions(e,o).start,width:n,height:r}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:i}=this.getMainViewportRect(),o=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-o.viewportWidth+1),maxOffsetY:Math.max(0,i-o.viewportHeight+1)}}getColRowOffsetInViewport(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),r=this.getters.getSheetViewVisibleRows();if(i<t)return-this.getColRowOffsetInViewport(e,i,t);let s=0;const a="COL"===e?n:r;for(let n=t;n<i;n++)a.includes(n)&&(s+="COL"===e?this.getters.getColSize(o,n):this.getters.getRowSize(o,n));return s}isVisibleInViewport(e,t,i){return this.getSubViewports(e).some((e=>e.isVisible(t,i)))}getEdgeScrollCol(e,t,i){let o=!1,n=0,r=0;const{xSplit:s}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(o=!0,r=Vt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,r=Vt(l-e),n=-1):s&&t<l&&e>l&&(o=!0,r=Vt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:r}}getEdgeScrollRow(e,t,i){let o=!1,n=0,r=0;const{ySplit:s}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(o=!0,r=Vt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,r=Vt(l-e),n=-1):s&&t<l&&e>l&&(o=!0,r=Vt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:r}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),i=this.getSubViewports(t).map((t=>t.getRect(e))).filter(Xe);if(0===i.length)return{x:0,y:0,width:0,height:0};const o=Math.min(...i.map((e=>e.x))),n=Math.min(...i.map((e=>e.y))),r=Math.max(...i.map((e=>e.x+e.width)))-o,s=Math.max(...i.map((e=>e.y+e.height)))-n;return{x:o+this.gridOffsetX,y:n+this.gridOffsetY,width:r,height:s}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,i).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(Xe)}checkPositiveDimension(e){return e.width<0||e.height<0?67:0}checkValuesAreDifferent(e){const{height:t,width:i}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===i&&e.height===t?75:0}checkScrollingDirection({offsetX:e,offsetY:t}){const i=this.getMainInternalViewport(this.getters.getActiveSheetId());return!i.canScrollHorizontally&&e>0||!i.canScrollVertically&&t>0?68:0}getMainViewport(e){const t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const i=this.getSubViewports(e);Object.values(i).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,i=0,o=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=i,this.gridOffsetY=o,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const i=this.getters.getActiveSheetId(),{maxOffsetX:o,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(i)).forEach((i=>i.setViewportOffset(Me(e,0,o),Me(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),i=t-this.sheetViewHeight;return e=Math.min(e,i),e=Math.max(e,0)}getViewportOffset(e){var t,i;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(i=this.viewports[e])||void 0===i?void 0:i.bottomRight.offsetScrollbarY)||0}}resetViewports(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),r=this.getters.getColRowOffset("COL",0,t,e),s=this.getters.getColRowOffset("ROW",0,i,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:i&&t&&new zv(this.getters,e,{left:0,right:t-1,top:0,bottom:i-1},{width:r,height:s},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:i&&new zv(this.getters,e,{left:t,right:o-1,top:0,bottom:i-1},{width:this.sheetViewWidth-r,height:s},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new zv(this.getters,e,{left:0,right:t-1,top:i,bottom:n-1},{width:r,height:this.sheetViewHeight-s},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new zv(this.getters,e,{left:t,right:o-1,top:i,bottom:n-1},{width:this.sheetViewWidth-r,height:this.sheetViewHeight-s},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:i}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(i,e);const{anchor:o}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(o.cell.col,o.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],i=this.getters.getFigures(e),{scrollX:o,scrollY:n}=this.getActiveSheetScrollInfo(),{x:r,y:s}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of i)e.x>=r&&(e.x+e.width<=r+o||e.x>=a+o+r)||e.y>=s&&(e.y+e.height<=s+n||e.y>=l+n+s)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,i).start;return{xRatio:o/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}Bv.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class Hv extends xg{allowDispatch(e){if("SORT_CELLS"===e.type){if(!ki(e.col,e.row,e.zone))throw new Error(r("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;for(let i=t.top;i<=t.bottom;i++)for(let o=t.left;o<=t.right;o++)if(!this.getters.isInMerge(e,o,i))return 62;return 0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const i=this.getters.getMerges(e).filter((e=>Di(e,t))),o=Ui(i[0]);let[n,r]=[o.width,o.height];return i.every((e=>{let[t,i]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&i===r}))?0:62}expand(e,t){const{left:i,right:o,top:n,bottom:r}=this.getters.expandZone(e,t);return{left:Math.max(0,i),right:Math.min(this.getters.getNumberCols(e)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,r)}}checkExpandedValues(e,t){const i=this.expand(e,t);let o;if(this.getters.doesIntersectMerge(e,i)){const{left:t,right:n,top:r,bottom:s}=i;for(let i=t;i<=n;i++)for(let t=r;t<=s;t++){const{col:n,row:r}=this.getters.getMainCellPosition(e,i,t);if(o=this.getters.getCell(e,n,r),null==o?void 0:o.formattedValue)return!0}}else for(let t of this.getters.getCellsInZone(e,i))if(null==t?void 0:t.formattedValue)return!0;return!1}getContiguousZone(e,t){let i,{top:o,bottom:n,left:r,right:s}=t,a=!1;for(;!a;)a=!0,o>0&&(i=this.checkExpandedValues(e,{left:r-1,right:s+1,top:o-1,bottom:o-1}),i&&(a=!1,o--)),r>0&&(i=this.checkExpandedValues(e,{left:r-1,right:r-1,top:o-1,bottom:n+1}),i&&(a=!1,r--)),s<this.getters.getNumberCols(e)-1&&(i=this.checkExpandedValues(e,{left:s+1,right:s+1,top:o-1,bottom:n+1}),i&&(a=!1,s++)),n<this.getters.getNumberRows(e)-1&&(i=this.checkExpandedValues(e,{left:r-1,right:s+1,top:n+1,bottom:n+1}),i&&(a=!1,n++));return{left:r,right:s,top:o,bottom:n}}hasHeader(e){if(1===e[0].length)return!1;let t=e.map((e=>e.map((e=>(null==e?void 0:e.evaluated.type)||eo.empty))));return t[0][0]===eo.empty&&(t=t.slice(1)),!t.some((e=>e[0]===eo.empty))&&!!t.some((e=>e[1]!==eo.empty&&e[0]!==e[1]))}sortZone(e,t,i,o,n){const[r,s]=this.mainCellsSteps(e,i);let a=this.getters.getMainCellPosition(e,t.col,t.row).col,l=Object.assign({},i),c=this.mainCells(e,i);!n.sortHeaders&&this.hasHeader(c)&&(l.top+=s),c=this.mainCells(e,l);const h=function(e,t,i){const o=e.map(qo);let n=o.filter((e=>e.type===eo.empty)),r=o.filter((e=>e.type!==eo.empty));i&&(r.push(...n.map((e=>({...e,type:eo.number,value:0})))),n=[]);const s="descending"===t?-1:1;return r.sort(((e,t)=>{let i=Go.indexOf(e.type)-Go.indexOf(t.type);return 0===i&&(i=e.type===eo.text||e.type===eo.error?e.value.localeCompare(t.value):e.value-t.value),s*i})).concat(n)}(c[a-l.left],o,Boolean(n.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let t=0;t<u;t++)for(let i=0;i<g;i++){let o=c[t][d[i]],n=l.left+t*r,a=l.top+i*s,h={sheetId:e,col:n,row:a,content:""};if(o){let t=o.content;if(o.isFormula()){const i=a-this.getters.getCellPosition(o.id).row,n=this.getters.createAdaptedRanges(o.dependencies,0,i,e);t=this.getters.buildFormulaContent(e,o,n)}h.style=o.style,h.content=t,h.format=o.format}p.push(h)}p.forEach((e=>this.dispatch("UPDATE_CELL",e)))}mainCellsSteps(e,t){const i=this.getters.getMerge(e,t.left,t.top);return[i?i.right-i.left+1:1,i?i.bottom-i.top+1:1]}mainCells(e,t){const[i,o]=this.mainCellsSteps(e,t),n=[],r=ke(t.left,t.right+1,i),s=ke(t.top,t.bottom+1,o);for(const t of r){const i=[];n.push(i);for(const o of s)i.push(this.getters.getCell(e,t,o))}return n}}Hv.getters=["getContiguousZone"];class Wv extends xg{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}Wv.getters=["shouldShowFormulas"];class Gv extends xg{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const i=this.getColMaxWidth(e.sheetId,t);0!==i&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:i,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e,{col:t,row:i}){const o=this.getters.getCell(e,t,i);let n=0;o&&(n+=this.getTextWidth(o));this.getters.getConditionalIcon(t,i)&&(n+=De(this.getters.getCellStyle(o))+2*L);if(this.getters.isFilterHeader(e,t,i)&&(n+=20),n>0&&(n+=2*V,"wrap"===this.getters.getCellStyle(o).wrapping)){const e=Gi({col:t,row:i}),o=this.getters.getColSize(this.getters.getActiveSheetId(),e.left);return Math.min(o,n)}return n}getTextWidth(e){const t=this.getters.getCellText(e,this.getters.shouldShowFormulas()),{sheetId:i,col:o,row:n}=this.getters.getCellPosition(e.id);return Ne(this.ctx,t,this.getters.getCellComputedStyle(i,o,n))}getCellText(e,t=!1){return t&&(e.isFormula()||e.evaluated.type===eo.error)?e.content:e.formattedValue}getCellMultiLineText(e,t){const i=this.getters.getCellStyle(e),o=this.getters.getCellText(e).split(" "),n=[];let r="",s=t;for(let e of o){const o=this.splitWordToSpecificWidth(this.ctx,e,t,i),a=o.pop(),l=Ne(this.ctx,a,i);if(o.length)""!==r&&(n.push(r),r="",s=t),o.forEach((e=>{n.push(e)})),r=a,s=t-l;else{const e=""===r?a:" "+a,o=Ne(this.ctx,e,i);o<=s?(r+=e,s-=o):(n.push(r),r=a,s=t-l)}}return""!==r&&n.push(r),n}getColDimensions(e,t){const i=this.getColRowOffset("COL",0,t,e),o=this.getters.getColSize(e,t);return{start:i,size:o,end:i+(this.getters.isColHidden(e,t)?0:o)}}getRowDimensions(e,t){const i=this.getColRowOffset("ROW",0,t,e),o=this.getters.getRowSize(e,t);return{start:i,size:o,end:i+(this.getters.isRowHidden(e,t)?0:o)}}getColRowOffset(e,t,i,o=this.getters.getActiveSheetId()){if(i<t)return-this.getColRowOffset(e,i,t);let n=0;for(let r=t;r<i;r++)this.getters.isHeaderHidden(o,e,r)||(n+="COL"===e?this.getters.getColSize(o,r):this.getters.getRowSize(o,r));return n}getColMaxWidth(e,t){const i=zi(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth(e,t)));return Math.max(0,...i)}splitWordToSpecificWidth(e,t,i,o){if(Ne(e,t,o)<=i)return[t];const n=[];let r="";for(let s of t){Ne(e,r+s,o)>i?(n.push(r),r=s):r+=s}return n.push(r),n}}Gv.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];const qv=(new Xi).add("sheet",iv).add("header visibility",Qf).add("filters",Yf).add("cell",Hf).add("merge",Jf).add("headerSize",Kf).add("borders",zf).add("conditional formatting",qf).add("figures",Zf).add("chart",Wf),Zv=(new Xi).add("selection",Rv).add("ui_sheet",Gv).add("header_visibility_ui",Ev).add("ui_options",Wv).add("evaluation",pv).add("evaluation_filter",vv).add("evaluation_cf",fv).add("evaluation_chart",mv).add("clipboard",dv).add("edition",Ig).add("selectionInputManager",Av).add("highlight",wv).add("viewport",Bv).add("grid renderer",yv).add("autofill",nv).add("find_and_replace",Sv).add("sort",Hv).add("automatic_sum",rv).add("format",Cv).add("cell_popovers",sv).add("selection_multiuser",Vv).add("custom_colors",uv),jv=new Xi;jv.add("link",{condition:e=>e.isLink(),action:(e,t)=>{e.action(t)},sequence:5}),po`
1391
1392
  .o-spreadsheet-bottom-bar {
1392
1393
  background-color: ${f};
1393
1394
  padding-left: ${N}px;
@@ -1476,12 +1477,12 @@
1476
1477
  opacity: 0;
1477
1478
  }
1478
1479
  }
1479
- `;class Zv extends t.Component{constructor(){super(...arguments),this.bottomBarRef=t.useRef("bottomBar"),this.menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]}),this.selectedStatisticFn=""}setup(){t.onMounted((()=>this.focusSheet())),t.onPatched((()=>this.focusSheet()))}focusSheet(){const e=this.bottomBarRef.el.querySelector(`[data-id="${this.env.model.getters.getActiveSheetId()}"]`);e&&e.scrollIntoView&&e.scrollIntoView()}addSheet(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSheetIds().findIndex((t=>t===e))+1,i=this.env.model.uuidGenerator.uuidv4(),o=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:i,position:t,name:o}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:i})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>this.env.model.getters.getSheet(e)))}listSheets(e){const t=new Do,i=this.env.model.getters.getActiveSheetId();let o=0;for(const e of this.env.model.getters.getSheetIds()){const n=this.env.model.getters.getSheet(e);t.add(e,{name:n.name,sequence:o,isReadonlyAllowed:!0,textColor:n.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:e})}}),o++}const n=e.currentTarget,{top:r,left:s}=n.getBoundingClientRect();this.openContextMenu(s,r,t)}activateSheet(e){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:e})}onDblClick(e){Fn(this.env,e)}openContextMenu(e,t,i,o){this.menuState.isOpen=!0,this.menuState.menuItems=i.getAll(),this.menuState.position={x:e,y:t},this.menuState.menuId=o}onIconClick(e,t){if(this.env.model.getters.getActiveSheetId()!==e&&this.activateSheet(e),t.closedMenuId===e)this.menuState.isOpen=!1,this.menuState.menuId=void 0;else{const i=t.currentTarget.parentElement,{top:o,left:n}=i.getBoundingClientRect();this.openContextMenu(n,o,Dn,e)}}onContextMenu(e,t){this.env.model.getters.getActiveSheetId()!==e&&this.activateSheet(e);const i=t.currentTarget,{top:o,left:n}=i.getBoundingClientRect();this.openContextMenu(n,o,Dn,e)}getSelectedStatistic(){const e=this.env.model.getters.getStatisticFnResults();if(!Object.values(e).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(e)[0]),this.getComposedFnName(this.selectedStatisticFn,e[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new Do;let i=0;for(let[e,o]of Object.entries(this.env.model.getters.getStatisticFnResults()))t.add(e,{name:this.getComposedFnName(e,o),sequence:i,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),i++;const o=e.currentTarget,{top:n,left:r,width:s}=o.getBoundingClientRect();this.openContextMenu(r+s,n,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?Gt(t):"__")}}Zv.template="o-spreadsheet-BottomBar",Zv.components={Menu:Ao},go`
1480
+ `;class Xv extends t.Component{constructor(){super(...arguments),this.bottomBarRef=t.useRef("bottomBar"),this.menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]}),this.selectedStatisticFn=""}setup(){t.onMounted((()=>this.focusSheet())),t.onPatched((()=>this.focusSheet()))}focusSheet(){const e=this.bottomBarRef.el.querySelector(`[data-id="${this.env.model.getters.getActiveSheetId()}"]`);e&&e.scrollIntoView&&e.scrollIntoView()}addSheet(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSheetIds().findIndex((t=>t===e))+1,i=this.env.model.uuidGenerator.uuidv4(),o=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:i,position:t,name:o}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:i})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>this.env.model.getters.getSheet(e)))}listSheets(e){const t=new ko,i=this.env.model.getters.getActiveSheetId();let o=0;for(const e of this.env.model.getters.getSheetIds()){const n=this.env.model.getters.getSheet(e);t.add(e,{name:n.name,sequence:o,isReadonlyAllowed:!0,textColor:n.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:e})}}),o++}const n=e.currentTarget,{top:r,left:s}=n.getBoundingClientRect();this.openContextMenu(s,r,t)}activateSheet(e){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:e})}onDblClick(e){kn(this.env,e)}openContextMenu(e,t,i,o){this.menuState.isOpen=!0,this.menuState.menuItems=i.getAll(),this.menuState.position={x:e,y:t},this.menuState.menuId=o}onIconClick(e,t){if(this.env.model.getters.getActiveSheetId()!==e&&this.activateSheet(e),t.closedMenuId===e)this.menuState.isOpen=!1,this.menuState.menuId=void 0;else{const i=t.currentTarget.parentElement,{top:o,left:n}=i.getBoundingClientRect();this.openContextMenu(n,o,$n,e)}}onContextMenu(e,t){this.env.model.getters.getActiveSheetId()!==e&&this.activateSheet(e);const i=t.currentTarget,{top:o,left:n}=i.getBoundingClientRect();this.openContextMenu(n,o,$n,e)}getSelectedStatistic(){const e=this.env.model.getters.getStatisticFnResults();if(!Object.values(e).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(e)[0]),this.getComposedFnName(this.selectedStatisticFn,e[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new ko;let i=0;for(let[e,o]of Object.entries(this.env.model.getters.getStatisticFnResults()))t.add(e,{name:this.getComposedFnName(e,o),sequence:i,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),i++;const o=e.currentTarget,{top:n,left:r,width:s}=o.getBoundingClientRect();this.openContextMenu(r+s,n,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?qt(t):"__")}}Xv.template="o-spreadsheet-BottomBar",Xv.components={Menu:Oo},po`
1480
1481
  .o-dashboard-clickable-cell {
1481
1482
  position: absolute;
1482
1483
  cursor: pointer;
1483
1484
  }
1484
- `;class jv extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=Io(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),Qg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=Jg(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:i}=this.env.model.getters.getColDimensions(e,t);return`\n max-width: ${i}px;\n `}get gridOverlayDimensions(){return"\n height: 100%;\n width: 100%\n "}getCellClickableStyle(e){return`\n top: ${e.y}px;\n left: ${e.x}px;\n width: ${e.width}px;\n height: ${e.height}px;\n `}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const i of this.env.model.getters.getSheetViewVisibleCols())for(const o of this.env.model.getters.getSheetViewVisibleRows()){const n=this.env.model.getters.getCell(t,i,o);if(n){const r=this.getClickableAction(n);if(!r)continue;let s;s=this.env.model.getters.isInMerge(t,i,o)?this.env.model.getters.getMerge(t,i,o):Wi({col:i,row:o});const a=this.env.model.getters.getVisibleRect(s);e.push({coordinates:a,cell:n,action:r})}}return e}getClickableAction(e){for(const t of qv.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.action;return!1}selectClickableCell(e){const{cell:t,action:i}=e;i(t,this.env)}onClosePopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}}jv.template="o-spreadsheet-SpreadsheetDashboard",jv.components={GridOverlay:qg,GridPopover:Zg,Popover:To,VerticalScrollBar:sp,HorizontalScrollBar:rp,FilterIconsOverlay:Bg},go`
1485
+ `;class Yv extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=To(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),ep("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=tp(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:i}=this.env.model.getters.getColDimensions(e,t);return`\n max-width: ${i}px;\n `}get gridOverlayDimensions(){return"\n height: 100%;\n width: 100%\n "}getCellClickableStyle(e){return`\n top: ${e.y}px;\n left: ${e.x}px;\n width: ${e.width}px;\n height: ${e.height}px;\n `}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const i of this.env.model.getters.getSheetViewVisibleCols())for(const o of this.env.model.getters.getSheetViewVisibleRows()){const n=this.env.model.getters.getCell(t,i,o);if(n){const r=this.getClickableAction(n);if(!r)continue;let s;s=this.env.model.getters.isInMerge(t,i,o)?this.env.model.getters.getMerge(t,i,o):Gi({col:i,row:o});const a=this.env.model.getters.getVisibleRect(s);e.push({coordinates:a,cell:n,action:r})}}return e}getClickableAction(e){for(const t of jv.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.action;return!1}selectClickableCell(e){const{cell:t,action:i}=e;i(t,this.env)}onClosePopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}}Yv.template="o-spreadsheet-SpreadsheetDashboard",Yv.components={GridOverlay:jg,GridPopover:Xg,Popover:Ao,VerticalScrollBar:lp,HorizontalScrollBar:ap,FilterIconsOverlay:Wg},po`
1485
1486
  .o-sidePanel {
1486
1487
  display: flex;
1487
1488
  flex-direction: column;
@@ -1724,7 +1725,7 @@
1724
1725
  }
1725
1726
  }
1726
1727
  }
1727
- `;class Xv extends t.Component{setup(){this.state=t.useState({panel:as.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=as.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}Xv.template="o-spreadsheet-SidePanel";const Yv={MergeIsDestructive:r("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:r("You can't merge cells inside of an existing filter.")};const Kv=[{name:"automatic",text:Pn.Automatic},{name:"number",text:Pn.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:Pn.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:Pn.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:Pn.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:Pn.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:Pn.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:Pn.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:Pn.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],Qv=[{name:"custom_currency",text:Pn.CustomCurrency,sidePanel:"CustomCurrency"}];go`
1728
+ `;class Kv extends t.Component{setup(){this.state=t.useState({panel:cs.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=cs.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}Kv.template="o-spreadsheet-SidePanel";const Qv={MergeIsDestructive:r("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:r("You can't merge cells inside of an existing filter.")};const Jv=[{name:"automatic",text:Vn.Automatic},{name:"number",text:Vn.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:Vn.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:Vn.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:Vn.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:Vn.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:Vn.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:Vn.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:Vn.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],eb=[{name:"custom_currency",text:Vn.CustomCurrency,sidePanel:"CustomCurrency"}];po`
1728
1729
  .o-spreadsheet-topbar {
1729
1730
  background-color: white;
1730
1731
  line-height: 1.2;
@@ -1918,7 +1919,7 @@
1918
1919
  }
1919
1920
  }
1920
1921
  }
1921
- `;class Jv extends t.Component{constructor(){super(...arguments),this.DEFAULT_FONT_SIZE=G,this.commonFormats=Kv,this.customFormats=Qv,this.currentFormatName="automatic",this.fontSizes=re,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="#ffffff",this.textColor="#000000",this.menus=[],this.composerStyle="\n line-height: 34px;\n padding-left: 8px;\n height: 34px;\n background-color: white;\n "}get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}setup(){t.useExternalListener(window,"click",this.onClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return ls.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onClick(e){this.openedEl&&xo(this.openedEl,e)||this.closeMenus()}toogleStyle(e){nn(this.env,{[e]:!this.style[e]})}toogleFormat(e){const t=Kv.find((t=>t.name===e)),i=t&&t.value||"";on(this.env,i)}toggleAlign(e){nn(this.env,{align:e})}onMenuMouseOver(e,t){this.isSelectingMenu&&this.toggleContextMenu(e,t)}toggleDropdownTool(e,t){const i=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=i?"":e,this.openedEl=i?null:t.target}toggleContextMenu(e,t){this.closeMenus();const{left:i,top:o,height:n}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:i,y:o+n},this.state.menuState.menuItems=wo(e,this.env),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target,this.env.model.dispatch("STOP_EDITION")}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId();this.inMerge=!1;const{top:i,left:o,right:n,bottom:r}=this.env.model.getters.getSelectedZone(),{xSplit:s,ySplit:a}=this.env.model.getters.getPaneDivisions(t);if(this.cannotMerge=e.length>1||i===r&&o===n||o<s&&s<=n||i<a&&a<=r,!this.cannotMerge){const{col:i,row:o}=this.env.model.getters.getPosition(),n=this.env.model.getters.expandZone(t,{left:i,right:i,top:o,bottom:o});this.inMerge=_i(e[0],n)}this.undoTool=this.env.model.getters.canUndo(),this.redoTool=this.env.model.getters.canRedo(),this.paintFormatTool=this.env.model.getters.isPaintingFormat();const l=this.env.model.getters.getActiveCell();if(l&&l.format){const e=this.commonFormats.find((e=>e.value===l.format));this.currentFormatName=e?e.name:""}else this.currentFormatName="automatic";this.style={...this.env.model.getters.getCurrentStyle()},this.style.align=this.style.align||(null==l?void 0:l.defaultAlign),this.fillColor=this.style.fillColor||"#ffffff",this.textColor=this.style.textColor||"#000000",this.menus=Bn.getAll()}getMenuName(e){return yo(e,this.env)}toggleMerge(){if(this.cannotMerge)return;const e=this.env.model.getters.getSelectedZones(),t=[e[e.length-1]],i=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:i,target:t}):function(e,t,i){const o=e.model.dispatch("ADD_MERGE",{sheetId:t,target:i});o.isCancelledBecause(79)?e.raiseError(Yv.MergeInFilter):o.isCancelledBecause(3)&&e.askConfirmation(Yv.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:i,force:!0})}))}(this.env,i,t)}setColor(e,t){nn(this.env,{[e]:t})}setBorder(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:e})}setFormat(e){const t=e.target.dataset.format;if(t)return void this.toogleFormat(t);const i=e.target.dataset.custom;i&&this.openCustomFormatSidePanel(i)}openCustomFormatSidePanel(e){const t=Qv.find((t=>t.name===e)),i=t&&t.sidePanel||"";this.env.openSidePanel(i)}setDecimal(e){this.env.model.dispatch("SET_DECIMAL",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),step:e})}paintFormat(){this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.env.model.getters.getSelectedZones()})}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setSize(e){const t=parseFloat(e.target.dataset.size);nn(this.env,{fontSize:t})}doAction(e){e(this.env),this.closeMenus()}undo(){this.env.model.dispatch("REQUEST_UNDO")}redo(){this.env.model.dispatch("REQUEST_REDO")}get selectionContainsFilter(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();return this.env.model.getters.doesZonesContainFilter(e,t)}get cannotCreateFilter(){return!Zi(...this.env.model.getters.getSelectedZones())}createFilter(){if(this.cannotCreateFilter)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();Xo(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}Jv.template="o-spreadsheet-TopBar",Jv.components={ColorPicker:Hr,Menu:Ao,Composer:$g},go`
1922
+ `;class tb extends t.Component{constructor(){super(...arguments),this.DEFAULT_FONT_SIZE=G,this.commonFormats=Jv,this.customFormats=eb,this.currentFormatName="automatic",this.fontSizes=re,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="#ffffff",this.textColor="#000000",this.menus=[],this.composerStyle="\n line-height: 34px;\n padding-left: 8px;\n height: 34px;\n background-color: white;\n "}get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}setup(){t.useExternalListener(window,"click",this.onClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return hs.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onClick(e){this.openedEl&&Ro(this.openedEl,e)||this.closeMenus()}toogleStyle(e){rn(this.env,{[e]:!this.style[e]})}toogleFormat(e){const t=Jv.find((t=>t.name===e)),i=t&&t.value||"";nn(this.env,i)}toggleAlign(e){rn(this.env,{align:e})}onMenuMouseOver(e,t){this.isSelectingMenu&&this.toggleContextMenu(e,t)}toggleDropdownTool(e,t){const i=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=i?"":e,this.openedEl=i?null:t.target}toggleContextMenu(e,t){this.closeMenus();const{left:i,top:o,height:n}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:i,y:o+n},this.state.menuState.menuItems=yo(e,this.env),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target,this.env.model.dispatch("STOP_EDITION")}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId();this.inMerge=!1;const{top:i,left:o,right:n,bottom:r}=this.env.model.getters.getSelectedZone(),{xSplit:s,ySplit:a}=this.env.model.getters.getPaneDivisions(t);if(this.cannotMerge=e.length>1||i===r&&o===n||o<s&&s<=n||i<a&&a<=r,!this.cannotMerge){const{col:i,row:o}=this.env.model.getters.getPosition(),n=this.env.model.getters.expandZone(t,{left:i,right:i,top:o,bottom:o});this.inMerge=Fi(e[0],n)}this.undoTool=this.env.model.getters.canUndo(),this.redoTool=this.env.model.getters.canRedo(),this.paintFormatTool=this.env.model.getters.isPaintingFormat();const l=this.env.model.getters.getActiveCell();if(l&&l.format){const e=this.commonFormats.find((e=>e.value===l.format));this.currentFormatName=e?e.name:""}else this.currentFormatName="automatic";this.style={...this.env.model.getters.getCurrentStyle()},this.style.align=this.style.align||(null==l?void 0:l.defaultAlign),this.fillColor=this.style.fillColor||"#ffffff",this.textColor=this.style.textColor||"#000000",this.menus=Wn.getAll()}getMenuName(e){return xo(e,this.env)}toggleMerge(){if(this.cannotMerge)return;const e=this.env.model.getters.getSelectedZones(),t=[e[e.length-1]],i=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:i,target:t}):function(e,t,i){const o=e.model.dispatch("ADD_MERGE",{sheetId:t,target:i});o.isCancelledBecause(79)?e.raiseError(Qv.MergeInFilter):o.isCancelledBecause(3)&&e.askConfirmation(Qv.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:i,force:!0})}))}(this.env,i,t)}setColor(e,t){rn(this.env,{[e]:t})}setBorder(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:e})}setFormat(e){const t=e.target.dataset.format;if(t)return void this.toogleFormat(t);const i=e.target.dataset.custom;i&&this.openCustomFormatSidePanel(i)}openCustomFormatSidePanel(e){const t=eb.find((t=>t.name===e)),i=t&&t.sidePanel||"";this.env.openSidePanel(i)}setDecimal(e){this.env.model.dispatch("SET_DECIMAL",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),step:e})}paintFormat(){this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.env.model.getters.getSelectedZones()})}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setSize(e){const t=parseFloat(e.target.dataset.size);rn(this.env,{fontSize:t})}doAction(e){e(this.env),this.closeMenus()}undo(){this.env.model.dispatch("REQUEST_UNDO")}redo(){this.env.model.dispatch("REQUEST_REDO")}get selectionContainsFilter(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();return this.env.model.getters.doesZonesContainFilter(e,t)}get cannotCreateFilter(){return!ji(...this.env.model.getters.getSelectedZones())}createFilter(){if(this.cannotCreateFilter)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();Yo(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}tb.template="o-spreadsheet-TopBar",tb.components={ColorPicker:Gr,Menu:Oo,Composer:Pg},po`
1922
1923
  .o-spreadsheet {
1923
1924
  position: relative;
1924
1925
  display: grid;
@@ -1963,7 +1964,7 @@
1963
1964
  height: ${15}px;
1964
1965
  vertical-align: sub;
1965
1966
  }
1966
- `,go`
1967
+ `,po`
1967
1968
  .o-grid {
1968
1969
  position: relative;
1969
1970
  overflow: hidden;
@@ -1992,23 +1993,23 @@
1992
1993
  outline: none;
1993
1994
  }
1994
1995
  }
1995
- `;class eb extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){var e,i;null===(i=(e=this.props).exposeSpreadsheet)||void 0===i||i.call(e,this),this.model=this.props.model,this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},t.useSubEnv({model:this.model,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:eb._t,clipboard:navigator.clipboard}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:r("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.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()}save(){var e,t;null===(t=(e=this.props).onContentSaved)||void 0===t||t.call(e,this.model.exportData())}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}eb.template="o-spreadsheet-Spreadsheet",eb.components={TopBar:Jv,Grid:lp,BottomBar:Zv,SidePanel:Xv,SpreadsheetDashboard:jv},eb._t=e=>e;class tb{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))}}function ib(e){return Bo.get(e.type)(e)}function ob(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class nb{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 i of this.operations){if(i.id===e)return e;if(i.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 i=this.buildTransformation.with(e.data),{before:o,operation:n,after:r}=this.locateOperation(t);this.operations=[...o,n,e,...r.map((e=>e.transformed(i)))]}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 nb(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:i}=this.locateOperation(e);this.operations=t.concat([i])}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 rb{constructor(e,t){this.id=e,this.data=t}transformed(e){return new sb(this.id,tt((()=>e(this.data))))}}class sb{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new sb(this.id,this.lazyData.map(e))}}class ab{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new ab(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new ab(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new ab(function*(e,t){let i=!0;for(const o of e)i||(yield o),o.operation.id===t&&(i=!1)}(this.operations,e))}}class lb{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 ab(Le(this._execution(e),this._execution(e)))}revertedExecution(e){return new ab(Le(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const o=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);o&&this.branchingOperationIds.set(n,o),this.insertBranchAfter(e,n),this.transform(n,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const o=this.buildTransformation.without(i.data),n=t.fork(i.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(o);const r=this.nextBranch(n);r&&this.rebaseUp(r)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const o=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(o&&n)if(e.getFirstOperationAmong(i,o)===o){const r=this.addToNextBranch(e,n,o,t,i);this.updateNextWith(n,r,i)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,i,o,n){let r=o;return n===i?(r=this.getTransformedOperation(e,i,o),t.prepend(r)):t.contains(n)?(r=this.getTransformedOperation(e,i,o),t.insert(r,n)):t.append(o),r}getTransformedOperation(e,t,i){const o=e.getOperation(t),n=this.buildTransformation.without(o.data);return i.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:o,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!o||!n)return;const r=this.buildTransformation.with(n.data),s=e.fork(i);s.transform(r),o.cutAfter(i),o.appendBranch(s);const a=t.transformed(r);this.insertPrevious(o,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{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 i=!!t;const o=e.getOperations();for(let n=o.length-1;n>=0;n--){const r=o[n];r.id===t&&(i=!1),i||(yield{operation:r,branch:e,isCancelled:!this.shouldExecute(e,r)})}const n=this.previousBranch(e);yield*n?this._revertedExecution(n):[]}*_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 cb{constructor(e,t,i,o,n){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=o,this.buildTransformation=n,this.HEAD_BRANCH=new nb(this.buildTransformation),this.tree=new lb(n,this.HEAD_BRANCH);const r=new rb(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,r),this.HEAD_OPERATION=r}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new rb(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,i),this.HEAD_BRANCH=o,this.HEAD_OPERATION=i}insert(e,t,i){const o=new rb(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,i),this.fastForward()}undo(e,t,i){const{branch:o,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}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:i,isCancelled:o}of e)o||this.revertOperation(i.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:i,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function hb(e,t,i){return new cb(e,(e=>{const o=e.commands.slice(),{changes:n}=t((()=>{for(const e of o)i(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){db(t.changes[e],"before")}}([e])),(e=>new Dv(e,"empty",[],[])),{with:e=>t=>new Dv(t.id,t.clientId,_v(t.commands,e.commands)),without:e=>t=>new Dv(t.id,t.clientId,_v(t.commands,e.commands.map(ib).flat()))})}function db(e,t){let i=e.root,o=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===i[o]){const n=e.path[t+1];i[o]=ob(n)}i=i[o]}void 0===e[t]?delete i[o]:i[o]=e[t]}class ub extends t.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 gb{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const r=$e(n);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let s=n,a="NONE";for(let e of r){const r=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=r&&r<=n.zone[i]){const e=Math.min(n.zone[i],l)-r+1;a="RESIZE",s=this.createAdaptedRange(s,o,a,-e)}else if(n.zone[t]>=r&&n.zone[i]<=l)a="REMOVE",s=n.clone({...this.getInvalidRange()});else if(n.zone[t]<=l&&n.zone[i]>=l){const e=l-n.zone[t]+1;a="RESIZE",s=this.createAdaptedRange(s,o,a,-e),s=this.createAdaptedRange(s,o,"MOVE",-(n.zone[t]-r))}else r<n.zone[t]&&(a="MOVE",s=this.createAdaptedRange(s,o,a,-(l-r+1)))}return"NONE"!==a?{changeType:a,range:s}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(n.zone[t]<=e.base&&e.base<n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:i})}}),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 i=void 0,o=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:o,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!ki(i.zone,t))return{changeType:"NONE"};const o=e.targetSheetId,n=e.col-t.left,r=e.row-t.top,s=this.createAdaptedRange(i,"both","MOVE",[n,r]),a=e.sheetId!==o||s.prefixSheet;return{changeType:"MOVE",range:s.clone({sheetId:o,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||xi(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,o){const n=zi(e.unboundedZone,t,i,o);return e.clone({zone:n})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,o){const n=e.map((e=>vi.fromRange(e,this.getters)));return n.map((e=>{if(!xi(e.zone))return e;const n=e.prefixSheet?e.sheetId:o,r={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return(e=e.clone({sheetId:n,zone:r})).orderZone(),e}))}getRangeFromSheetXC(e,t){if(!It.test(t))return new vi({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,o=t,n=!1;t.includes("!")&&(({xc:o,sheetName:i}=Nt(t)),i&&(n=!0));const r=wi(o),s=vi.getRangeParts(o,r),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e,c=new vi({prefixSheet:n,zone:r,sheetId:l,invalidSheetName:a,parts:s},this.getters.getSheetSize);return c.orderZone(),c}getSelectionRangeString(e,t){const i=vi.fromRange(e,this.getters),o=this.getters.expandZone(i.sheetId,i.zone),n=i.clone({zone:{...o,bottom:i.isFullCol?void 0:o.bottom,right:i.isFullRow?void 0:o.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return Y;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return Y;if(e.zone.left<0||e.zone.top<0)return Y;const i=vi.fromRange(e,this.getters);let o=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,n="";if(o&&(n=i.invalidSheetName?i.invalidSheetName:Me(this.getters.getSheetName(i.sheetId))),o&&!n)return Y;let r=this.getRangePartString(i,0);return i.parts&&2===i.parts.length&&(i.zone.top!==i.zone.bottom||i.zone.left!==i.zone.right||i.parts[0].rowFixed||i.parts[0].colFixed||i.parts[1].rowFixed||i.parts[1].colFixed)&&(r+=":",r+=this.getRangePartString(i,1)),`${o?n+"!":""}${r}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new vi(t,this.getters.getSheetSize)}getRangePartString(e,t){const i=e.parts&&e.parts[t].colFixed?"$":"",o=_t(0===t?e.zone.left:e.zone.right),n=e.parts&&e.parts[t].rowFixed?"$":"",r=String(0===t?e.zone.top+1:e.zone.bottom+1);let s="";return s=e.isFullCol?0===t&&e.unboundedZone.hasHeader?i+o+n+r:i+o:e.isFullRow?0===t&&e.unboundedZone.hasHeader?i+o+n+r:n+r:i+o+n+r,s}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:Y}}}gb.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class pb{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var i,o,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&(null===(n=(o=this.mainSubscription.callbacks).release)||void 0===n||n.call(o)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t,i,o,n;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(null===(n=null===(i=this.mainSubscription)||void 0===i?void 0:(o=i.callbacks).release)||void 0===n||n.call(o),this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class mb{constructor(e){this.getters=e,this.stream=new pb,this.anchor={cell:{col:0,row:0},zone:Wi({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){const t=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(t,e.zone)},this.processEvent({type:"ZonesSelected",anchor:e,mode:"overrideSelection"})}selectCell(e,t){const i=Wi({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new ro(82);const{col:i,row:o}=this.getNextAvailablePosition(e,t);return this.selectCell(i,o)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:o,row:n}=this.anchor.cell,r={left:Math.min(o,e),top:Math.min(n,t),right:Math.max(o,e),bottom:Math.max(n,t)},s={zone:this.getters.expandZone(i,r),cell:{col:o,row:n}};return this.processEvent({type:"AlterZoneCorner",mode:"updateAnchor",anchor:s})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition(i,e,t));const o=this.getters.expandZone(i,Wi({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:o,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new ro(82);const i=this.getters.getActiveSheetId(),o=this.anchor,{col:n,row:r}=o.cell,{left:s,right:a,top:l,bottom:c}=o.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return ro.Success;let g=o.zone;const p=e=>{e=Hi(e);const{left:t,right:o,top:n,bottom:r}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(i)-1,r)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:s,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,s+(v-1),f);g=s+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:s,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:s,bottom:c,right:a}):null}if(g=g?Hi(g):g,g&&!_i(g,o.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:r}}})}g=p(Oi({top:r,bottom:r,left:n,right:n},Hi({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,s,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:n,row:r}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberRows(i)-1;let n={left:e,right:e,top:0,bottom:o};const r=this.getters.findFirstVisibleColRowIndex(i,"ROW");let s,a;switch(t){case"overrideSelection":case"newAnchor":s=e,a=r;break;case"updateAnchor":({col:s,row:a}=this.anchor.cell),n=Oi(n,{left:s,right:s,top:r,bottom:o})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:s,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberCols(i)-1;let n={top:e,bottom:e,left:0,right:o};const r=this.getters.findFirstVisibleColRowIndex(i,"COL");let s,a;switch(t){case"overrideSelection":case"newAnchor":s=r,a=e;break;case"updateAnchor":({col:s,row:a}=this.anchor.cell),n=Oi(n,{left:r,right:o,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:s,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor,i=e=>{for(const t of ke(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of ke(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};if(_i(this.anchor.zone,this.getters.getSheetZone(e)))return this.selectZone({...t,zone:Wi(t.cell)});let o=!1,n=!1,r=t.zone;do{n=n||o,o=!1;const e=i(r);_i(r,e)||(o=!0,r=e)}while(o);return n?this.selectZone({...t,zone:r}):this.selectAll()}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}processEvent(e){const t={...e,previousAnchor:Te(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new ro(i):(this.anchor=t.anchor,this.stream.send(t),ro.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!Di(t.col,t.row,i))return 16;const{left:o,right:n,top:r,bottom:s}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",o,n);return void 0===this.getters.findVisibleHeader(a,"ROW",r,s)||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(n("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:o}=this.anchor.cell,n=this.deltaToTarget({col:i,row:o},e,t);return{col:this.getNextAvailableCol(n[0],i,o),row:this.getNextAvailableRow(n[1],i,o)}}getNextAvailableCol(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(o,t,i,e,i)))}getNextAvailableRow(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,n,(e=>this.getters.isInSameMerge(o,t,i,t,e)))}getNextAvailableHeader(e,t,i,o,n){const r=this.getters.getActiveSheetId();if(0===e)return i;const s=Math.sign(e);let a=i+e;for(;n(a);)a+=s;for(;this.getters.isHeaderHidden(r,t,a);)a+=s;return a<0||a>this.getters.getNumberHeaders(r,t)-1?this.getters.isHeaderHidden(r,t,i)?this.getNextAvailableHeader(-s,t,i,o,n):i:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:o,top:n,bottom:r}=t.zone,{col:s,row:a}=t.cell;return{col:this.getters.isColHidden(e,s)&&this.getters.findVisibleHeader(e,"COL",i,o)||s,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",n,r)||a}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const o=this.anchor.zone;switch(e){case"down":case"up":i=i===o.top?o.bottom:o.top;break;case"left":case"right":t=t===o.right?o.left:o.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const o=this.getters.getActiveSheet();let n=e;const r=this.getNextCellPosition(e,t,i);let s=this.isCellEmpty(n,o.id)||this.isCellEmpty(r,o.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,i);if(n.col===e.col&&n.row===e.row)break;const r=this.isCellEmpty(e,o.id);if("endOfCluster"===s&&r)break;if("nextCluster"===s&&!r){n=e;break}n=e}return"cols"===t?n.col:n.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const o=this.getters.getMainCellPosition(i,e,t),n=this.getters.getCell(i,o.col,o.row);return!n||n.isEmpty()}getNextCellPosition(e,t,i){const o="cols"===t?"col":"row",n={...e},r="cols"===t?this.getNextAvailableCol(i,n.col,n.row):this.getNextAvailableRow(i,n.col,n.row);return n[o]=r,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}}class fb{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(),[i,...o]=e;let n=i,r=o[o.length-1];for(let e=0;e<=o.length-2;e++){const t=o[e];if(void 0===n[t]){const i=o[e+1];n[t]=ob(i)}n=n[t]}n[r]!==t&&(this.changes.push({root:i,path:o,before:n[r],after:t}),void 0===t?delete n[r]:n[r]=t)}}const vb=17781237,bb=88853993;function Sb(e,t,i){const o=[["xmlns:r",Op],["xmlns:a",Ip],["xmlns:c",Tp]],n=Cb({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let r=df``;e.data.title&&(r=df`
1996
+ `;class ib extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){var e,i;null===(i=(e=this.props).exposeSpreadsheet)||void 0===i||i.call(e,this),this.model=this.props.model,this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},t.useSubEnv({model:this.model,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:ib._t,clipboard:navigator.clipboard}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:r("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.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()}save(){var e,t;null===(t=(e=this.props).onContentSaved)||void 0===t||t.call(e,this.model.exportData())}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}ib.template="o-spreadsheet-Spreadsheet",ib.components={TopBar:tb,Grid:hp,BottomBar:Xv,SidePanel:Kv,SpreadsheetDashboard:Yv},ib._t=e=>e;class ob{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))}}function nb(e){return Ho.get(e.type)(e)}function rb(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class sb{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 i of this.operations){if(i.id===e)return e;if(i.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 i=this.buildTransformation.with(e.data),{before:o,operation:n,after:r}=this.locateOperation(t);this.operations=[...o,n,e,...r.map((e=>e.transformed(i)))]}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 sb(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:i}=this.locateOperation(e);this.operations=t.concat([i])}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 ab{constructor(e,t){this.id=e,this.data=t}transformed(e){return new lb(this.id,tt((()=>e(this.data))))}}class lb{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new lb(this.id,this.lazyData.map(e))}}class cb{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new cb(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new cb(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new cb(function*(e,t){let i=!0;for(const o of e)i||(yield o),o.operation.id===t&&(i=!1)}(this.operations,e))}}class hb{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 cb(Le(this._execution(e),this._execution(e)))}revertedExecution(e){return new cb(Le(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const o=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);o&&this.branchingOperationIds.set(n,o),this.insertBranchAfter(e,n),this.transform(n,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const o=this.buildTransformation.without(i.data),n=t.fork(i.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(o);const r=this.nextBranch(n);r&&this.rebaseUp(r)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const o=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(o&&n)if(e.getFirstOperationAmong(i,o)===o){const r=this.addToNextBranch(e,n,o,t,i);this.updateNextWith(n,r,i)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,i,o,n){let r=o;return n===i?(r=this.getTransformedOperation(e,i,o),t.prepend(r)):t.contains(n)?(r=this.getTransformedOperation(e,i,o),t.insert(r,n)):t.append(o),r}getTransformedOperation(e,t,i){const o=e.getOperation(t),n=this.buildTransformation.without(o.data);return i.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:o,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!o||!n)return;const r=this.buildTransformation.with(n.data),s=e.fork(i);s.transform(r),o.cutAfter(i),o.appendBranch(s);const a=t.transformed(r);this.insertPrevious(o,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{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 i=!!t;const o=e.getOperations();for(let n=o.length-1;n>=0;n--){const r=o[n];r.id===t&&(i=!1),i||(yield{operation:r,branch:e,isCancelled:!this.shouldExecute(e,r)})}const n=this.previousBranch(e);yield*n?this._revertedExecution(n):[]}*_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 db{constructor(e,t,i,o,n){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=o,this.buildTransformation=n,this.HEAD_BRANCH=new sb(this.buildTransformation),this.tree=new hb(n,this.HEAD_BRANCH);const r=new ab(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,r),this.HEAD_OPERATION=r}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new ab(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,i),this.HEAD_BRANCH=o,this.HEAD_OPERATION=i}insert(e,t,i){const o=new ab(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,i),this.fastForward()}undo(e,t,i){const{branch:o,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}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:i,isCancelled:o}of e)o||this.revertOperation(i.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:i,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function ub(e,t,i){return new db(e,(e=>{const o=e.commands.slice(),{changes:n}=t((()=>{for(const e of o)i(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){gb(t.changes[e],"before")}}([e])),(e=>new $v(e,"empty",[],[])),{with:e=>t=>new $v(t.id,t.clientId,Dv(t.commands,e.commands)),without:e=>t=>new $v(t.id,t.clientId,Dv(t.commands,e.commands.map(nb).flat()))})}function gb(e,t){let i=e.root,o=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===i[o]){const n=e.path[t+1];i[o]=rb(n)}i=i[o]}void 0===e[t]?delete i[o]:i[o]=e[t]}class pb extends t.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 mb{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const r=$e(n);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let s=n,a="NONE";for(let e of r){const r=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=r&&r<=n.zone[i]){const e=Math.min(n.zone[i],l)-r+1;a="RESIZE",s=this.createAdaptedRange(s,o,a,-e)}else if(n.zone[t]>=r&&n.zone[i]<=l)a="REMOVE",s=n.clone({...this.getInvalidRange()});else if(n.zone[t]<=l&&n.zone[i]>=l){const e=l-n.zone[t]+1;a="RESIZE",s=this.createAdaptedRange(s,o,a,-e),s=this.createAdaptedRange(s,o,"MOVE",-(n.zone[t]-r))}else r<n.zone[t]&&(a="MOVE",s=this.createAdaptedRange(s,o,a,-(l-r+1)))}return"NONE"!==a?{changeType:a,range:s}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(n.zone[t]<=e.base&&e.base<n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:i})}}),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 i=void 0,o=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:o,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!$i(i.zone,t))return{changeType:"NONE"};const o=e.targetSheetId,n=e.col-t.left,r=e.row-t.top,s=this.createAdaptedRange(i,"both","MOVE",[n,r]),a=e.sheetId!==o||s.prefixSheet;return{changeType:"MOVE",range:s.clone({sheetId:o,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||Ri(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,o){const n=Bi(e.unboundedZone,t,i,o);return e.clone({zone:n})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,o){const n=e.map((e=>bi.fromRange(e,this.getters)));return n.map((e=>{if(!Ri(e.zone))return e;const n=e.prefixSheet?e.sheetId:o,r={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return(e=e.clone({sheetId:n,zone:r})).orderZone(),e}))}getRangeFromSheetXC(e,t){if(!Tt.test(t))return new bi({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,o=t,n=!1;t.includes("!")&&(({xc:o,sheetName:i}=_t(t)),i&&(n=!0));const r=yi(o),s=bi.getRangeParts(o,r),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e,c=new bi({prefixSheet:n,zone:r,sheetId:l,invalidSheetName:a,parts:s},this.getters.getSheetSize);return c.orderZone(),c}getSelectionRangeString(e,t){const i=bi.fromRange(e,this.getters),o=this.getters.expandZone(i.sheetId,i.zone),n=i.clone({zone:{...o,bottom:i.isFullCol?void 0:o.bottom,right:i.isFullRow?void 0:o.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return Y;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return Y;if(e.zone.left<0||e.zone.top<0)return Y;const i=bi.fromRange(e,this.getters);let o=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,n="";if(o&&(n=i.invalidSheetName?i.invalidSheetName:Oe(this.getters.getSheetName(i.sheetId))),o&&!n)return Y;let r=this.getRangePartString(i,0);return i.parts&&2===i.parts.length&&(i.zone.top!==i.zone.bottom||i.zone.left!==i.zone.right||i.parts[0].rowFixed||i.parts[0].colFixed||i.parts[1].rowFixed||i.parts[1].colFixed)&&(r+=":",r+=this.getRangePartString(i,1)),`${o?n+"!":""}${r}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new bi(t,this.getters.getSheetSize)}getRangePartString(e,t){const i=e.parts&&e.parts[t].colFixed?"$":"",o=Ft(0===t?e.zone.left:e.zone.right),n=e.parts&&e.parts[t].rowFixed?"$":"",r=String(0===t?e.zone.top+1:e.zone.bottom+1);let s="";return s=e.isFullCol?0===t&&e.unboundedZone.hasHeader?i+o+n+r:i+o:e.isFullRow?0===t&&e.unboundedZone.hasHeader?i+o+n+r:n+r:i+o+n+r,s}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:Y}}}mb.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class fb{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var i,o,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&(null===(n=(o=this.mainSubscription.callbacks).release)||void 0===n||n.call(o)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t,i,o,n;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(null===(n=null===(i=this.mainSubscription)||void 0===i?void 0:(o=i.callbacks).release)||void 0===n||n.call(o),this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class vb{constructor(e){this.getters=e,this.stream=new fb,this.anchor={cell:{col:0,row:0},zone:Gi({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){const t=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(t,e.zone)},this.processEvent({type:"ZonesSelected",anchor:e,mode:"overrideSelection"})}selectCell(e,t){const i=Gi({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new so(82);const{col:i,row:o}=this.getNextAvailablePosition(e,t);return this.selectCell(i,o)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:o,row:n}=this.anchor.cell,r={left:Math.min(o,e),top:Math.min(n,t),right:Math.max(o,e),bottom:Math.max(n,t)},s={zone:this.getters.expandZone(i,r),cell:{col:o,row:n}};return this.processEvent({type:"AlterZoneCorner",mode:"updateAnchor",anchor:s})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition(i,e,t));const o=this.getters.expandZone(i,Gi({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:o,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new so(82);const i=this.getters.getActiveSheetId(),o=this.anchor,{col:n,row:r}=o.cell,{left:s,right:a,top:l,bottom:c}=o.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return so.Success;let g=o.zone;const p=e=>{e=Wi(e);const{left:t,right:o,top:n,bottom:r}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(i)-1,r)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:s,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,s+(v-1),f);g=s+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:s,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:s,bottom:c,right:a}):null}if(g=g?Wi(g):g,g&&!Fi(g,o.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:r}}})}g=p(Ni({top:r,bottom:r,left:n,right:n},Wi({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,s,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:n,row:r}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberRows(i)-1;let n={left:e,right:e,top:0,bottom:o};const r=this.getters.findFirstVisibleColRowIndex(i,"ROW");let s,a;switch(t){case"overrideSelection":case"newAnchor":s=e,a=r;break;case"updateAnchor":({col:s,row:a}=this.anchor.cell),n=Ni(n,{left:s,right:s,top:r,bottom:o})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:s,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberCols(i)-1;let n={top:e,bottom:e,left:0,right:o};const r=this.getters.findFirstVisibleColRowIndex(i,"COL");let s,a;switch(t){case"overrideSelection":case"newAnchor":s=r,a=e;break;case"updateAnchor":({col:s,row:a}=this.anchor.cell),n=Ni(n,{left:r,right:o,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:s,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor,i=e=>{for(const t of ke(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of ke(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};if(Fi(this.anchor.zone,this.getters.getSheetZone(e)))return this.selectZone({...t,zone:Gi(t.cell)});let o=!1,n=!1,r=t.zone;do{n=n||o,o=!1;const e=i(r);Fi(r,e)||(o=!0,r=e)}while(o);return n?this.selectZone({...t,zone:r}):this.selectAll()}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}processEvent(e){const t={...e,previousAnchor:Te(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new so(i):(this.anchor=t.anchor,this.stream.send(t),so.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!ki(t.col,t.row,i))return 16;const{left:o,right:n,top:r,bottom:s}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",o,n);return void 0===this.getters.findVisibleHeader(a,"ROW",r,s)||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(n("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:o}=this.anchor.cell,n=this.deltaToTarget({col:i,row:o},e,t);return{col:this.getNextAvailableCol(n[0],i,o),row:this.getNextAvailableRow(n[1],i,o)}}getNextAvailableCol(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(o,t,i,e,i)))}getNextAvailableRow(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,n,(e=>this.getters.isInSameMerge(o,t,i,t,e)))}getNextAvailableHeader(e,t,i,o,n){const r=this.getters.getActiveSheetId();if(0===e)return i;const s=Math.sign(e);let a=i+e;for(;n(a);)a+=s;for(;this.getters.isHeaderHidden(r,t,a);)a+=s;return a<0||a>this.getters.getNumberHeaders(r,t)-1?this.getters.isHeaderHidden(r,t,i)?this.getNextAvailableHeader(-s,t,i,o,n):i:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:o,top:n,bottom:r}=t.zone,{col:s,row:a}=t.cell;return{col:this.getters.isColHidden(e,s)&&this.getters.findVisibleHeader(e,"COL",i,o)||s,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",n,r)||a}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const o=this.anchor.zone;switch(e){case"down":case"up":i=i===o.top?o.bottom:o.top;break;case"left":case"right":t=t===o.right?o.left:o.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const o=this.getters.getActiveSheet();let n=e;const r=this.getNextCellPosition(e,t,i);let s=this.isCellEmpty(n,o.id)||this.isCellEmpty(r,o.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,i);if(n.col===e.col&&n.row===e.row)break;const r=this.isCellEmpty(e,o.id);if("endOfCluster"===s&&r)break;if("nextCluster"===s&&!r){n=e;break}n=e}return"cols"===t?n.col:n.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const o=this.getters.getMainCellPosition(i,e,t),n=this.getters.getCell(i,o.col,o.row);return!n||n.isEmpty()}getNextCellPosition(e,t,i){const o="cols"===t?"col":"row",n={...e},r="cols"===t?this.getNextAvailableCol(i,n.col,n.row):this.getNextAvailableRow(i,n.col,n.row);return n[o]=r,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}}class bb{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(),[i,...o]=e;let n=i,r=o[o.length-1];for(let e=0;e<=o.length-2;e++){const t=o[e];if(void 0===n[t]){const i=o[e+1];n[t]=rb(i)}n=n[t]}n[r]!==t&&(this.changes.push({root:i,path:o,before:n[r],after:t}),void 0===t?delete n[r]:n[r]=t)}}const Sb=17781237,Cb=88853993;function Eb(e,t,i){const o=[["xmlns:r",_p],["xmlns:a",Ap],["xmlns:c",Op]],n=wb({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let r=gf``;e.data.title&&(r=gf`
1996
1997
  <c:title>
1997
- ${wb(e.data.title,e.data.fontColor)}
1998
+ ${xb(e.data.title,e.data.fontColor)}
1998
1999
  <c:overlay val="0" />
1999
2000
  </c:title>
2000
- `);let s=df``;switch(e.data.type){case"bar":s=function(e){const t=new sr,i=[];for(const[o,n]of Object.entries(e.dataSets)){const r=Xn(t.next()),s=Cb({backgroundColor:r,line:{color:r}});i.push(df`
2001
+ `);let s=gf``;switch(e.data.type){case"bar":s=function(e){const t=new lr,i=[];for(const[o,n]of Object.entries(e.dataSets)){const r=Kn(t.next()),s=wb({backgroundColor:r,line:{color:r}});i.push(gf`
2001
2002
  <c:ser>
2002
2003
  <c:idx val="${o}"/>
2003
2004
  <c:order val="${o}"/>
2004
- ${n.label?df`<c:tx>${Ib(n.label)}</c:tx>`:""}
2005
+ ${n.label?gf`<c:tx>${Ab(n.label)}</c:tx>`:""}
2005
2006
  ${s}
2006
- ${e.labelRange?df`<c:cat>${Ib(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2007
+ ${e.labelRange?gf`<c:cat>${Ab(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2007
2008
  <c:val> <!-- x-coordinate values -->
2008
- ${Tb(n.range)}
2009
+ ${Ob(n.range)}
2009
2010
  </c:val>
2010
2011
  </c:ser>
2011
- `)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",r=e.stacked?100:-20;return df`
2012
+ `)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",r=e.stacked?100:-20;return gf`
2012
2013
  <c:barChart>
2013
2014
  <c:barDir val="col"/>
2014
2015
  <c:grouping val="${n}"/>
@@ -2016,13 +2017,13 @@
2016
2017
  <c:gapWidth val="70"/>
2017
2018
  <!-- each data marker in the series does not have a different color -->
2018
2019
  <c:varyColors val="0"/>
2019
- ${hf(i)}
2020
- <c:axId val="${vb}" />
2021
- <c:axId val="${bb}" />
2020
+ ${uf(i)}
2021
+ <c:axId val="${Sb}" />
2022
+ <c:axId val="${Cb}" />
2022
2023
  </c:barChart>
2023
- ${Rb("b","c:catAx",vb,bb,{fontColor:e.fontColor})}
2024
- ${Rb(o,"c:valAx",bb,vb,{fontColor:e.fontColor})}
2025
- `}(e.data);break;case"line":s=function(e){const t=new sr,i=[];for(const[o,n]of Object.entries(e.dataSets)){const r=Cb({line:{width:2.5,style:"solid",color:Xn(t.next())}});i.push(df`
2024
+ ${Tb("b","c:catAx",Sb,Cb,{fontColor:e.fontColor})}
2025
+ ${Tb(o,"c:valAx",Cb,Sb,{fontColor:e.fontColor})}
2026
+ `}(e.data);break;case"line":s=function(e){const t=new lr,i=[];for(const[o,n]of Object.entries(e.dataSets)){const r=wb({line:{width:2.5,style:"solid",color:Kn(t.next())}});i.push(gf`
2026
2027
  <c:ser>
2027
2028
  <c:idx val="${o}"/>
2028
2029
  <c:order val="${o}"/>
@@ -2031,50 +2032,50 @@
2031
2032
  <c:symbol val="circle" />
2032
2033
  <c:size val="5"/>
2033
2034
  </c:marker>
2034
- ${n.label?df`<c:tx>${Ib(n.label)}</c:tx>`:""}
2035
+ ${n.label?gf`<c:tx>${Ab(n.label)}</c:tx>`:""}
2035
2036
  ${r}
2036
- ${e.labelRange?df`<c:cat>${Ib(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2037
+ ${e.labelRange?gf`<c:cat>${Ab(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2037
2038
  <c:val> <!-- x-coordinate values -->
2038
- ${Tb(n.range)}
2039
+ ${Ob(n.range)}
2039
2040
  </c:val>
2040
2041
  </c:ser>
2041
- `)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return df`
2042
+ `)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return gf`
2042
2043
  <c:lineChart>
2043
2044
  <c:grouping val="${n}"/>
2044
2045
  <!-- each data marker in the series does not have a different color -->
2045
2046
  <c:varyColors val="0"/>
2046
- ${hf(i)}
2047
- <c:axId val="${vb}" />
2048
- <c:axId val="${bb}" />
2047
+ ${uf(i)}
2048
+ <c:axId val="${Sb}" />
2049
+ <c:axId val="${Cb}" />
2049
2050
  </c:lineChart>
2050
- ${Rb("b","c:catAx",vb,bb,{fontColor:e.fontColor})}
2051
- ${Rb(o,"c:valAx",bb,vb,{fontColor:e.fontColor})}
2052
- `}(e.data);break;case"pie":s=function(e,t,i,{holeSize:o}={holeSize:50}){const n=new sr,r=Math.max(...e.dataSets.map((e=>km(e.range,t,i)))),s=ke(0,r).map((()=>Xn(n.next()))),a=[];for(const[o,n]of Object.entries(e.dataSets).reverse()){const r=km(n.range,t,i),l=[];for(const e of ke(0,r)){const t=Cb({backgroundColor:s[e],line:{color:"FFFFFF",width:1.5}});l.push(df`
2051
+ ${Tb("b","c:catAx",Sb,Cb,{fontColor:e.fontColor})}
2052
+ ${Tb(o,"c:valAx",Cb,Sb,{fontColor:e.fontColor})}
2053
+ `}(e.data);break;case"pie":s=function(e,t,i,{holeSize:o}={holeSize:50}){const n=new lr,r=Math.max(...e.dataSets.map((e=>Lm(e.range,t,i)))),s=ke(0,r).map((()=>Kn(n.next()))),a=[];for(const[o,n]of Object.entries(e.dataSets).reverse()){const r=Lm(n.range,t,i),l=[];for(const e of ke(0,r)){const t=wb({backgroundColor:s[e],line:{color:"FFFFFF",width:1.5}});l.push(gf`
2053
2054
  <c:dPt>
2054
2055
  <c:idx val="${e}"/>
2055
2056
  ${t}
2056
2057
  </c:dPt>
2057
- `)}a.push(df`
2058
+ `)}a.push(gf`
2058
2059
  <c:ser>
2059
2060
  <c:idx val="${o}"/>
2060
2061
  <c:order val="${o}"/>
2061
- ${n.label?df`<c:tx>${Ib(n.label)}</c:tx>`:""}
2062
- ${hf(l)}
2063
- ${xb({showLeaderLines:!0})}
2064
- ${e.labelRange?df`<c:cat>${Ib(e.labelRange)}</c:cat>`:""}
2062
+ ${n.label?gf`<c:tx>${Ab(n.label)}</c:tx>`:""}
2063
+ ${uf(l)}
2064
+ ${Ib({showLeaderLines:!0})}
2065
+ ${e.labelRange?gf`<c:cat>${Ab(e.labelRange)}</c:cat>`:""}
2065
2066
  <c:val>
2066
- ${Tb(n.range)}
2067
+ ${Ob(n.range)}
2067
2068
  </c:val>
2068
2069
  </c:ser>
2069
- `)}return df`
2070
+ `)}return gf`
2070
2071
  <c:doughnutChart>
2071
2072
  <c:varyColors val="1" />
2072
2073
  <c:holeSize val="${o}" />
2073
- ${xb()}
2074
- ${hf(a)}
2074
+ ${Ib()}
2075
+ ${uf(a)}
2075
2076
  </c:doughnutChart>
2076
- `}(e.data,t,i,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=df`
2077
- <c:chartSpace ${af(o)}>
2077
+ `}(e.data,t,i,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=gf`
2078
+ <c:chartSpace ${cf(o)}>
2078
2079
  <c:roundedCorners val="0" />
2079
2080
  <!-- <manualLayout/> to manually position the chart in the figure container -->
2080
2081
  ${n}
@@ -2085,32 +2086,32 @@
2085
2086
  <!-- how the chart element is placed on the chart -->
2086
2087
  <c:layout />
2087
2088
  ${s}
2088
- ${Cb({backgroundColor:e.data.backgroundColor})}
2089
+ ${wb({backgroundColor:e.data.backgroundColor})}
2089
2090
  </c:plotArea>
2090
- ${function(e,t){return df`
2091
+ ${function(e,t){return gf`
2091
2092
  <c:legend>
2092
2093
  <c:legendPos val="${e}"/>
2093
2094
  <c:overlay val="0"/>
2094
- ${yb(10,t)}
2095
+ ${Rb(10,t)}
2095
2096
  </c:legend>
2096
2097
  `}(a,l)}
2097
2098
  </c:chart>
2098
2099
  </c:chartSpace>
2099
- `;return lf(c)}function Cb(e){return df`
2100
+ `;return hf(c)}function wb(e){return gf`
2100
2101
  <c:spPr>
2101
- ${e.backgroundColor?Eb(e.backgroundColor):""}
2102
- ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",Dm(e.width)]);const i=e.style?df`<a:prstDash val="${e.style}"/>`:"";return df`
2103
- <a:ln ${af(t)}>
2104
- ${Eb(e.color)}
2102
+ ${e.backgroundColor?yb(e.backgroundColor):""}
2103
+ ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",$m(e.width)]);const i=e.style?gf`<a:prstDash val="${e.style}"/>`:"";return gf`
2104
+ <a:ln ${cf(t)}>
2105
+ ${yb(e.color)}
2105
2106
  ${i}
2106
2107
  </a:ln>
2107
2108
  `}(e.line):""}
2108
2109
  </c:spPr>
2109
- `}function Eb(e){return df`
2110
+ `}function yb(e){return gf`
2110
2111
  <a:solidFill>
2111
2112
  <a:srgbClr val="${e}"/>
2112
2113
  </a:solidFill>
2113
- `}function wb(e,t="000000",i=22){return df`
2114
+ `}function xb(e,t="000000",i=22){return gf`
2114
2115
  <c:tx>
2115
2116
  <c:rich>
2116
2117
  <a:bodyPr />
@@ -2118,7 +2119,7 @@
2118
2119
  <a:p>
2119
2120
  <a:pPr lvl="0">
2120
2121
  <a:defRPr b="0">
2121
- ${Eb(t)}
2122
+ ${yb(t)}
2122
2123
  <a:latin typeface="+mn-lt"/>
2123
2124
  </a:defRPr>
2124
2125
  </a:pPr>
@@ -2129,20 +2130,20 @@
2129
2130
  </a:p>
2130
2131
  </c:rich>
2131
2132
  </c:tx>
2132
- `}function yb(e=12,t="000000",i=!1,o=!1){return df`
2133
+ `}function Rb(e=12,t="000000",i=!1,o=!1){return gf`
2133
2134
  <c:txPr>
2134
2135
  <a:bodyPr/>
2135
2136
  <a:lstStyle/>
2136
2137
  <a:p>
2137
2138
  <a:pPr lvl="0">
2138
- <a:defRPr ${af([["b",i?"1":"0"],["i",o?"1":"0"],["sz",100*e]])}>
2139
- ${Eb(t)}
2139
+ <a:defRPr ${cf([["b",i?"1":"0"],["i",o?"1":"0"],["sz",100*e]])}>
2140
+ ${yb(t)}
2140
2141
  <a:latin typeface="+mn-lt"/>
2141
2142
  </a:defRPr>
2142
2143
  </a:pPr>
2143
2144
  </a:p>
2144
2145
  </c:txPr>
2145
- `}function xb({showLeaderLines:e}={showLeaderLines:!1}){return df`
2146
+ `}function Ib({showLeaderLines:e}={showLeaderLines:!1}){return gf`
2146
2147
  <dLbls>
2147
2148
  <c:showLegendKey val="0"/>
2148
2149
  <c:showVal val="0"/>
@@ -2152,7 +2153,7 @@
2152
2153
  <c:showBubbleSize val="0"/>
2153
2154
  <c:showLeaderLines val="${e?"1":"0"}"/>
2154
2155
  </dLbls>
2155
- `}function Rb(e,t,i,o,{fontColor:n}){return df`
2156
+ `}function Tb(e,t,i,o,{fontColor:n}){return gf`
2156
2157
  <${t}>
2157
2158
  <c:axId val="${i}"/>
2158
2159
  <c:crossAx val="${o}"/> <!-- reference to the other axe of the chart -->
@@ -2161,58 +2162,58 @@
2161
2162
  <c:orientation val="minMax" />
2162
2163
  </c:scaling>
2163
2164
  <c:axPos val="${e}" />
2164
- ${function(e="B7B7B7"){return df`
2165
+ ${function(e="B7B7B7"){return gf`
2165
2166
  <c:majorGridlines>
2166
- ${Cb({line:{color:e}})}
2167
+ ${wb({line:{color:e}})}
2167
2168
  </c:majorGridlines>
2168
2169
  `}()}
2169
2170
  <c:majorTickMark val="out" />
2170
2171
  <c:minorTickMark val="none" />
2171
2172
  <c:numFmt formatCode="General" sourceLinked="1" />
2172
2173
  <c:title>
2173
- ${wb("")}
2174
+ ${xb("")}
2174
2175
  </c:title>
2175
- ${yb(10,n)}
2176
+ ${Rb(10,n)}
2176
2177
  </${t}>
2177
2178
  <!-- <tickLblPos/> omitted -->
2178
- `}function Ib(e){return df`
2179
+ `}function Ab(e){return gf`
2179
2180
  <c:strRef>
2180
2181
  <c:f>${e}</c:f>
2181
2182
  </c:strRef>
2182
- `}function Tb(e){return df`
2183
+ `}function Ob(e){return gf`
2183
2184
  <c:numRef>
2184
2185
  <c:f>${e}</c:f>
2185
2186
  <c:numCache />
2186
2187
  </c:numRef>
2187
- `}function Ab(e){const t=e.content,i=Tu.content,o=[];let n=df``;if(Nu(t).filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported))){let i=df``;const r=Ob(t);return e.value===a.CircularDependency&&(o.push(["t","str"]),i=df`<v>${e.value}</v>`),n=df`
2188
+ `}function Mb(e){const t=e.content,i=Ou.content,o=[];let n=gf``;if(Fu(t).filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported))){let i=gf``;const r=_b(t);return e.value===a.CircularDependency&&(o.push(["t","str"]),i=gf`<v>${e.value}</v>`),n=gf`
2188
2189
  <f>
2189
2190
  ${r}
2190
2191
  </f>
2191
2192
  ${i}
2192
- `,{attrs:o,node:n}}{const t=e.value,i=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);return o.push(["t",i]),n=df`<v>${t}</v>`,{attrs:o,node:n}}}function Mb(e,t,i=!1){let o=e;const n=[];if(!i&&["TRUE","FALSE"].includes(o.trim()))o="TRUE"===o?"1":"0",n.push(["t","b"]);else if(i||!gi(o)){const{id:i}=Nm(e,t);o=i.toString(),n.push(["t","s"])}return{attrs:n,node:df`<v>${o}</v>`}}function Ob(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Ju(e)}catch(t){return e}return t=tg(t,"STRING",Nb),t=tg(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),i=e.args,o=Pp[t];if(o){const n=Tu.content[t].args.filter((e=>!e.optional)),r=n.length-e.args.length;if(r)for(let t=e.args.length;t<n.length;t++){const e=o[t-r];i.push({type:e.type,value:e.value})}}return{...e,args:i}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:Up.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?ig(t):e}function Nb(e){const t=e.value.replace(new RegExp('"',"g"),""),i=me(t);if(i){let o=[];return(t.match(ue)||t.match(ge))&&o.push("yyyy-mm-dd"),t.match(pe)&&o.push("hh:mm:ss"),{...e,value:Gt(i.value,o.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function _b(e,t){const i=[];for(const o of t)switch(o.rule.type){case"CellIsRule":i.push(Fb(o,o.rule,e));break;case"ColorScaleRule":i.push(Db(o,o.rule));break;case"IconSetRule":i.push(kb(o,o.rule));break;default:console.warn(`Conditional formatting ${o.rule.type} not implemented`)}return i}function Fb(e,t,i){const o=$b(e),n=xm(t.operator);o.push(...function(e){const t=xm(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",n]);const r=function(e,t){const i=e[0].split(":")[0],o=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${o[0]}",${i})))`];case"NotContains":return[`ISERROR(SEARCH("${o[0]}",${i}))`];case"BeginsWith":return[`LEFT(${i},LEN("${o[0]}"))="${o[0]}"`];case"EndsWith":return[`RIGHT(${i},LEN("${o[0]}"))="${o[0]}"`];case"IsEmpty":return[`LEN(TRIM(${i}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${i}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[o[0]];case"Between":case"NotBetween":return[o[0],o[1]]}}(e.ranges,t).map((e=>df`<formula>${e}</formula>`)),s={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};t.style.fillColor&&(s.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=Nm(s,i);return o.push(["dxfId",a]),df`
2193
+ `,{attrs:o,node:n}}{const t=e.value,i=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);return o.push(["t",i]),n=gf`<v>${t}</v>`,{attrs:o,node:n}}}function Nb(e,t,i=!1){let o=e;const n=[];if(!i&&["TRUE","FALSE"].includes(o.trim()))o="TRUE"===o?"1":"0",n.push(["t","b"]);else if(i||!pi(o)){const{id:i}=Fm(e,t);o=i.toString(),n.push(["t","s"])}return{attrs:n,node:gf`<v>${o}</v>`}}function _b(e){let t;"="===e[0]&&(e=e.slice(1));try{t=tg(e)}catch(t){return e}return t=og(t,"STRING",Fb),t=og(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),i=e.args,o=Vp[t];if(o){const n=Ou.content[t].args.filter((e=>!e.optional)),r=n.length-e.args.length;if(r)for(let t=e.args.length;t<n.length;t++){const e=o[t-r];i.push({type:e.type,value:e.value})}}return{...e,args:i}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:zp.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?ng(t):e}function Fb(e){const t=e.value.replace(new RegExp('"',"g"),""),i=me(t);if(i){let o=[];return(t.match(ue)||t.match(ge))&&o.push("yyyy-mm-dd"),t.match(pe)&&o.push("hh:mm:ss"),{...e,value:qt(i.value,o.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function Db(e,t){const i=[];for(const o of t)switch(o.rule.type){case"CellIsRule":i.push(kb(o,o.rule,e));break;case"ColorScaleRule":i.push($b(o,o.rule));break;case"IconSetRule":i.push(Lb(o,o.rule));break;default:console.warn(`Conditional formatting ${o.rule.type} not implemented`)}return i}function kb(e,t,i){const o=Pb(e),n=Im(t.operator);o.push(...function(e){const t=Im(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",n]);const r=function(e,t){const i=e[0].split(":")[0],o=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${o[0]}",${i})))`];case"NotContains":return[`ISERROR(SEARCH("${o[0]}",${i}))`];case"BeginsWith":return[`LEFT(${i},LEN("${o[0]}"))="${o[0]}"`];case"EndsWith":return[`RIGHT(${i},LEN("${o[0]}"))="${o[0]}"`];case"IsEmpty":return[`LEN(TRIM(${i}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${i}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[o[0]];case"Between":case"NotBetween":return[o[0],o[1]]}}(e.ranges,t).map((e=>gf`<formula>${e}</formula>`)),s={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};t.style.fillColor&&(s.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=Fm(s,i);return o.push(["dxfId",a]),gf`
2193
2194
  <conditionalFormatting sqref="${e.ranges.join(" ")}">
2194
- <cfRule ${af(o)}>
2195
- ${hf(r)}
2195
+ <cfRule ${cf(o)}>
2196
+ ${uf(r)}
2196
2197
  </cfRule>
2197
2198
  </conditionalFormatting>
2198
- `}function Db(e,t){const i=$b(e);i.push(["type","colorScale"]);const o=[];for(const n of e.ranges){const e=[],r=[];let s=!0;for(let i of["minimum","midpoint","maximum"]){const o=t[i];o&&("formula"!==o.type?(e.push(Pb(o,i)),r.push([["rgb",Xn(ht(o.color))]])):s=!1)}if(!s){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>df`<cfvo ${af(e)}/>`)),l=r.map((e=>df`<color ${af(e)}/>`));o.push(df`
2199
+ `}function $b(e,t){const i=Pb(e);i.push(["type","colorScale"]);const o=[];for(const n of e.ranges){const e=[],r=[];let s=!0;for(let i of["minimum","midpoint","maximum"]){const o=t[i];o&&("formula"!==o.type?(e.push(Vb(o,i)),r.push([["rgb",Kn(dt(o.color))]])):s=!1)}if(!s){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>gf`<cfvo ${cf(e)}/>`)),l=r.map((e=>gf`<color ${cf(e)}/>`));o.push(gf`
2199
2200
  <conditionalFormatting sqref="${n}">
2200
- <cfRule ${af(i)}>
2201
+ <cfRule ${cf(i)}>
2201
2202
  <colorScale>
2202
- ${hf(a)}
2203
- ${hf(l)}
2203
+ ${uf(a)}
2204
+ ${uf(l)}
2204
2205
  </colorScale>
2205
2206
  </cfRule>
2206
2207
  </conditionalFormatting>
2207
- `)}return hf(o)}function kb(e,t){const i=$b(e);i.push(["type","iconSet"]);const o=[];for(const n of e.ranges){const e=[[["type","percent"],["val",0]]];let r=!0;for(let i of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[i].type){r=!1;continue}const o=t[i];e.push([...Pb(o,i),["gte","ge"===o.operator?"1":"0"]])}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const s=e.map((e=>df`<cfvo ${af(e)} />`));o.push(df`
2208
+ `)}return uf(o)}function Lb(e,t){const i=Pb(e);i.push(["type","iconSet"]);const o=[];for(const n of e.ranges){const e=[[["type","percent"],["val",0]]];let r=!0;for(let i of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[i].type){r=!1;continue}const o=t[i];e.push([...Vb(o,i),["gte","ge"===o.operator?"1":"0"]])}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const s=e.map((e=>gf`<cfvo ${cf(e)} />`));o.push(gf`
2208
2209
  <conditionalFormatting sqref="${n}">
2209
- <cfRule ${af(i)}>
2210
- <iconSet iconSet="${Lb(t.icons)}">
2211
- ${hf(s)}
2210
+ <cfRule ${cf(i)}>
2211
+ <iconSet iconSet="${Ub(t.icons)}">
2212
+ ${uf(s)}
2212
2213
  </iconSet>
2213
2214
  </cfRule>
2214
2215
  </conditionalFormatting>
2215
- `)}return hf(o)}function $b(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function Lb(e){return xp[Object.keys(xp).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function Pb(e,t){const i=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),o=[["type",i]];if("min"!==i&&"max"!==i){let t=e.value;if("formula"===i)try{t=Ob(e.value)}catch(i){t=e.value}o.push(["val",t])}return o}function Ub(e,t,i){const o=[["xmlns:xdr",Rp.drawing],["xmlns:r",Op],["xmlns:a",Ip],["xmlns:c",Tp]],n=[];for(const[o,r]of Object.entries(i)){const{from:i,to:s}=Vb(r,t),a=Fm(r.id),l=[["id",a],["name",`Chart ${a}`],["title","Chart"]];n.push(df`
2216
+ `)}return uf(o)}function Pb(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function Ub(e){return Ip[Object.keys(Ip).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function Vb(e,t){const i=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),o=[["type",i]];if("min"!==i&&"max"!==i){let t=e.value;if("formula"===i)try{t=_b(e.value)}catch(i){t=e.value}o.push(["val",t])}return o}function zb(e,t,i){const o=[["xmlns:xdr",Tp.drawing],["xmlns:r",_p],["xmlns:a",Ap],["xmlns:c",Op]],n=[];for(const[o,r]of Object.entries(i)){const{from:i,to:s}=Bb(r,t),a=km(r.id),l=[["id",a],["name",`Chart ${a}`],["title","Chart"]];n.push(gf`
2216
2217
  <xdr:twoCellAnchor>
2217
2218
  <xdr:from>
2218
2219
  <xdr:col>${i.col}</xdr:col>
@@ -2228,7 +2229,7 @@
2228
2229
  </xdr:to>
2229
2230
  <xdr:graphicFrame>
2230
2231
  <xdr:nvGraphicFramePr>
2231
- <xdr:cNvPr ${af(l)} />
2232
+ <xdr:cNvPr ${cf(l)} />
2232
2233
  <xdr:cNvGraphicFramePr />
2233
2234
  </xdr:nvGraphicFramePr>
2234
2235
  <xdr:xfrm>
@@ -2236,80 +2237,80 @@
2236
2237
  <a:ext cx="0" cy="0"/>
2237
2238
  </xdr:xfrm>
2238
2239
  <a:graphic>
2239
- <a:graphicData uri="${Tp}">
2240
+ <a:graphicData uri="${Op}">
2240
2241
  <c:chart r:id="${e[o]}" />
2241
2242
  </a:graphicData>
2242
2243
  </a:graphic>
2243
2244
  </xdr:graphicFrame>
2244
2245
  <xdr:clientData fLocksWithSheet="0"/>
2245
2246
  </xdr:twoCellAnchor>
2246
- `)}return lf(df`
2247
- <xdr:wsDr ${af(o)}>
2248
- ${hf(n)}
2247
+ `)}return hf(gf`
2248
+ <xdr:wsDr ${cf(o)}>
2249
+ ${uf(n)}
2249
2250
  </xdr:wsDr>
2250
- `)}function Vb(e,t){const{x:i,y:o,height:n,width:r}=e,s=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=zb(s,i),{index:h,offset:d}=zb(s,i+r),{index:u,offset:g}=zb(a,o),{index:p,offset:m}=zb(a,o+n);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function zb(e,t){let i=0;for(const[o,n]of Object.entries(e)){if(i<=t&&t<i+n.size)return{index:parseInt(o),offset:Dm(t-i+H)};i+=n.size}return{index:e.length-1,offset:Dm(t-i+H)}}function Bb(e){return Ke(e)?df``:df`
2251
+ `)}function Bb(e,t){const{x:i,y:o,height:n,width:r}=e,s=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=Hb(s,i),{index:h,offset:d}=Hb(s,i+r),{index:u,offset:g}=Hb(a,o),{index:p,offset:m}=Hb(a,o+n);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function Hb(e,t){let i=0;for(const[o,n]of Object.entries(e)){if(i<=t&&t<i+n.size)return{index:parseInt(o),offset:$m(t-i+H)};i+=n.size}return{index:e.length-1,offset:$m(t-i+H)}}function Wb(e){return Ke(e)?gf``:gf`
2251
2252
  <font>
2252
- ${e.bold?df`<b />`:""}
2253
- ${e.italic?df`<i />`:""}
2254
- ${e.underline?df`<u />`:""}
2255
- ${e.strike?df`<strike />`:""}
2256
- ${e.size?df`<sz val="${e.size}" />`:""}
2257
- ${e.color&&e.color.rgb?df`<color rgb="${Xn(e.color.rgb)}" />`:""}
2258
- ${e.name?df`<name val="${e.name}" />`:""}
2253
+ ${e.bold?gf`<b />`:""}
2254
+ ${e.italic?gf`<i />`:""}
2255
+ ${e.underline?gf`<u />`:""}
2256
+ ${e.strike?gf`<strike />`:""}
2257
+ ${e.size?gf`<sz val="${e.size}" />`:""}
2258
+ ${e.color&&e.color.rgb?gf`<color rgb="${Kn(e.color.rgb)}" />`:""}
2259
+ ${e.name?gf`<name val="${e.name}" />`:""}
2259
2260
  </font>
2260
- `}function Hb(e){return e?af([["style",e.style],["color",Xn(e.color.rgb)]]):df``}const Wb=df`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function Gb(e,t,i){const o=df`
2261
- <table ${af([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",Rp.table],["xmlns:xr",Rp.revision],["xmlns:xr3",Rp.revision3],["xmlns:mc",Rp.markupCompatibility]])}>
2262
- ${function(e){const t=[["ref",e.range]];return df`
2263
- <autoFilter ${af(t)}>
2264
- ${hf(function(e){const t=[];for(const i of e.filters){const e=df`
2265
- <filterColumn ${af([["colId",i.colId]])}>
2266
- ${qb(i)}
2261
+ `}function Gb(e){return e?cf([["style",e.style],["color",Kn(e.color.rgb)]]):gf``}const qb=gf`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function Zb(e,t,i){const o=gf`
2262
+ <table ${cf([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",Tp.table],["xmlns:xr",Tp.revision],["xmlns:xr3",Tp.revision3],["xmlns:mc",Tp.markupCompatibility]])}>
2263
+ ${function(e){const t=[["ref",e.range]];return gf`
2264
+ <autoFilter ${cf(t)}>
2265
+ ${uf(function(e){const t=[];for(const i of e.filters){const e=gf`
2266
+ <filterColumn ${cf([["colId",i.colId]])}>
2267
+ ${jb(i)}
2267
2268
  </filterColumn>
2268
2269
  `;t.push(e)}return t}(e))}
2269
2270
  </autoFilter>
2270
2271
  `}(e)}
2271
- ${function(e,t){var i;const o=yi(e.range),n=[];for(const e of ke(0,Pi(o).width)){const r=kt(o.left+e,o.top),s=[["id",e+1],["name",(null===(i=t.cells[r])||void 0===i?void 0:i.content)||`col${e}`]];n.push(df`<tableColumn ${af(s)}/>`)}return df`
2272
- <tableColumns ${af([["count",n.length]])}>
2273
- ${hf(n)}
2272
+ ${function(e,t){var i;const o=xi(e.range),n=[];for(const e of ke(0,Ui(o).width)){const r=$t(o.left+e,o.top),s=[["id",e+1],["name",(null===(i=t.cells[r])||void 0===i?void 0:i.content)||`col${e}`]];n.push(gf`<tableColumn ${cf(s)}/>`)}return gf`
2273
+ <tableColumns ${cf([["count",n.length]])}>
2274
+ ${uf(n)}
2274
2275
  </tableColumns>
2275
2276
  `}(e,i)}
2276
- ${Wb}
2277
+ ${qb}
2277
2278
  </table>
2278
- `;return lf(o)}function qb(e){const t=e.displayedValues.map((e=>df`<filter ${af([["val",e]])}/>`));return df`
2279
- <filters ${af(e.displayBlanks?[["blank",1]]:[])}>
2280
- ${hf(t)}
2279
+ `;return hf(o)}function jb(e){const t=e.displayedValues.map((e=>gf`<filter ${cf([["val",e]])}/>`));return gf`
2280
+ <filters ${cf(e.displayBlanks?[["blank",1]]:[])}>
2281
+ ${uf(t)}
2281
2282
  </filters>
2282
- `}function Zb(e){if(!Object.values(e).length)return df``;const t=[];for(let[i,o]of Object.entries(e)){const e=[["min",parseInt(i)+1],["max",parseInt(i)+1],["width",Im(o.size||_)],["customWidth",1],["hidden",o.isHidden?1:0]];t.push(df`
2283
- <col ${af(e)}/>
2284
- `)}return df`
2283
+ `}function Xb(e){if(!Object.values(e).length)return gf``;const t=[];for(let[i,o]of Object.entries(e)){const e=[["min",parseInt(i)+1],["max",parseInt(i)+1],["width",Am(o.size||_)],["customWidth",1],["hidden",o.isHidden?1:0]];t.push(gf`
2284
+ <col ${cf(e)}/>
2285
+ `)}return gf`
2285
2286
  <cols>
2286
- ${hf(t)}
2287
+ ${uf(t)}
2287
2288
  </cols>
2288
- `}function jb(e,t,i){const o=[];for(let n=0;n<i.rowNumber;n++){const r=[["r",n+1]],s=i.rows[n]||{};r.push(["ht",Rm(s.size||F)],["customHeight",1],["hidden",s.isHidden?1:0]);const a=[];for(let o=0;o<i.colNumber;o++){const r=kt(o,n),s=i.cells[r];if(s){const l=[["r",r]],c=Mm(e,Am(s,t));l.push(["s",c]);let h=[],d=df``;if(s.isFormula)({attrs:h,node:d}=Ab(s));else if(s.content&&Be(s.content)){const{label:t}=We(s.content);({attrs:h,node:d}=Mb(t,e.sharedStrings))}else if(s.content&&""!==s.content){const t=Xb(o,n,i);({attrs:h,node:d}=Mb(s.content,e.sharedStrings,t))}l.push(...h),a.push(df`
2289
- <c ${af(l)}>
2289
+ `}function Yb(e,t,i){const o=[];for(let n=0;n<i.rowNumber;n++){const r=[["r",n+1]],s=i.rows[n]||{};r.push(["ht",Tm(s.size||F)],["customHeight",1],["hidden",s.isHidden?1:0]);const a=[];for(let o=0;o<i.colNumber;o++){const r=$t(o,n),s=i.cells[r];if(s){const l=[["r",r]],c=Nm(e,Mm(s,t));l.push(["s",c]);let h=[],d=gf``;if(s.isFormula)({attrs:h,node:d}=Mb(s));else if(s.content&&Be(s.content)){const{label:t}=We(s.content);({attrs:h,node:d}=Nb(t,e.sharedStrings))}else if(s.content&&""!==s.content){const t=Kb(o,n,i);({attrs:h,node:d}=Nb(s.content,e.sharedStrings,t))}l.push(...h),a.push(gf`
2290
+ <c ${cf(l)}>
2290
2291
  ${d}
2291
2292
  </c>
2292
- `)}}(a.length||s.size!==F||s.isHidden)&&o.push(df`
2293
- <row ${af(r)}>
2294
- ${hf(a)}
2293
+ `)}}(a.length||s.size!==F||s.isHidden)&&o.push(gf`
2294
+ <row ${cf(r)}>
2295
+ ${uf(a)}
2295
2296
  </row>
2296
- `)}return df`
2297
+ `)}return gf`
2297
2298
  <sheetData>
2298
- ${hf(o)}
2299
+ ${uf(o)}
2299
2300
  </sheetData>
2300
- `}function Xb(e,t,i){return i.filterTables.some((i=>{const o=yi(i.range),n={...o,bottom:o.top};return Di(e,t,n)}))}function Yb(e,t,i){var o;const n=t.sheets[i].cells,r=[];for(const s in n){const a=null===(o=n[s])||void 0===o?void 0:o.content;if(a&&Be(a)){const{label:o,url:n}=We(a);if(qe(a)){const e=je(n),i=t.sheets.find((t=>t.id===e)),a=i?`${i.name}!A1`:Y;r.push(df`
2301
+ `}function Kb(e,t,i){return i.filterTables.some((i=>{const o=xi(i.range),n={...o,bottom:o.top};return ki(e,t,n)}))}function Qb(e,t,i){var o;const n=t.sheets[i].cells,r=[];for(const s in n){const a=null===(o=n[s])||void 0===o?void 0:o.content;if(a&&Be(a)){const{label:o,url:n}=We(a);if(qe(a)){const e=je(n),i=t.sheets.find((t=>t.id===e)),a=i?`${i.name}!A1`:Y;r.push(gf`
2301
2302
  <hyperlink display="${o}" location="${a}" ref="${s}"/>
2302
- `)}else{const t=Om(e.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:n,type:Mp.hyperlink,targetMode:"External"});r.push(df`
2303
+ `)}else{const t=_m(e.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:n,type:Np.hyperlink,targetMode:"External"});r.push(gf`
2303
2304
  <hyperlink r:id="${t}" ref="${s}"/>
2304
- `)}}}return r.length?df`
2305
+ `)}}}return r.length?gf`
2305
2306
  <hyperlinks>
2306
- ${hf(r)}
2307
+ ${uf(r)}
2307
2308
  </hyperlinks>
2308
- `:df``}function Kb(e){if(e.length){const t=e.map((e=>df`<mergeCell ref="${e}" />`));return df`
2309
+ `:gf``}function Jb(e){if(e.length){const t=e.map((e=>gf`<mergeCell ref="${e}" />`));return gf`
2309
2310
  <mergeCells count="${e.length}">
2310
- ${hf(t)}
2311
+ ${uf(t)}
2311
2312
  </mergeCells>
2312
- `}return df``}function Qb(e){const t=e.panes;let i=df``;if(t&&(t.xSplit||t.ySplit)){const e=kt(t.xSplit,t.ySplit),o=t.xSplit?df`xSplit="${t.xSplit}"`:"",n=t.ySplit?df`ySplit="${t.ySplit}"`:"",r=t.xSplit?df`<selection pane="topRight"/>`:"",s=t.ySplit?df`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?df`<selection pane="bottomRight"/>`:"";i=df`
2313
+ `}return gf``}function eS(e){const t=e.panes;let i=gf``;if(t&&(t.xSplit||t.ySplit)){const e=$t(t.xSplit,t.ySplit),o=t.xSplit?gf`xSplit="${t.xSplit}"`:"",n=t.ySplit?gf`ySplit="${t.ySplit}"`:"",r=t.xSplit?gf`<selection pane="topRight"/>`:"",s=t.ySplit?gf`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?gf`<selection pane="bottomRight"/>`:"";i=gf`
2313
2314
  <pane
2314
2315
  ${o}
2315
2316
  ${n}
@@ -2319,123 +2320,123 @@
2319
2320
  ${r}
2320
2321
  ${s}
2321
2322
  ${a}
2322
- `}return df`
2323
+ `}return gf`
2323
2324
  <sheetViews>
2324
2325
  <sheetView showGridLines="${e.areGridLinesVisible?1:0}" workbookViewId="0">
2325
2326
  ${i}
2326
2327
  </sheetView>
2327
2328
  </sheetViews>
2328
- `}function Jb(e){const t=[],i={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:G,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const i=[["xmlns",Rp.workbook],["xmlns:r",Op]],o=[];for(const[i,n]of Object.entries(e.sheets)){const e=[["state",n.isVisible?"visible":"hidden"],["name",n.name],["sheetId",parseInt(i)+1],["r:id",`rId${parseInt(i)+1}`]];o.push(df`
2329
- <sheet ${af(e)} />
2330
- `),Om(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Mp.sheet,target:`worksheets/sheet${i}.xml`})}return rf(lf(df`
2331
- <workbook ${af(i)}>
2329
+ `}function tS(e){const t=[],i={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:G,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const i=[["xmlns",Tp.workbook],["xmlns:r",_p]],o=[];for(const[i,n]of Object.entries(e.sheets)){const e=[["state",n.isVisible?"visible":"hidden"],["name",n.name],["sheetId",parseInt(i)+1],["r:id",`rId${parseInt(i)+1}`]];o.push(gf`
2330
+ <sheet ${cf(e)} />
2331
+ `),_m(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Np.sheet,target:`worksheets/sheet${i}.xml`})}return af(hf(gf`
2332
+ <workbook ${cf(i)}>
2332
2333
  <sheets>
2333
- ${hf(o)}
2334
+ ${uf(o)}
2334
2335
  </sheets>
2335
2336
  </workbook>
2336
- `),"xl/workbook.xml","workbook")}(e,i)),t.push(...function(e,t){const i=[];let o=1;for(const[n,r]of Object.entries(e.sheets)){const s=[["xmlns",Rp.worksheet],["xmlns:r",Op]],a=[["defaultRowHeight",Rm(F)],["defaultColWidth",Im(_)]],l=eS(r,n,o,t,i);o+=r.filterTables.length;let c=df``;const h=r.charts;if(h.length){const o=[];for(const r of h){const s=Fm(r.id),a=Om(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../charts/chart${s}.xml`,type:Mp.chart});o.push(a),i.push(rf(Sb(r,n,e),`xl/charts/chart${s}.xml`,"chart"))}const s=Om(t.relsFiles,`xl/worksheets/_rels/sheet${n}.xml.rels`,{target:`../drawings/drawing${n}.xml`,type:Mp.drawing});i.push(rf(Ub(o,r,h),`xl/drawings/drawing${n}.xml`,"drawing")),c=df`<drawing r:id="${s}" />`}const d=df`
2337
- <worksheet ${af(s)}>
2338
- ${Qb(r)}
2339
- <sheetFormatPr ${af(a)} />
2340
- ${Zb(r.cols)}
2341
- ${jb(t,e,r)}
2342
- ${Kb(r.merges)}
2343
- ${hf(_b(t.dxfs,r.conditionalFormats))}
2344
- ${Yb(t,e,n)}
2337
+ `),"xl/workbook.xml","workbook")}(e,i)),t.push(...function(e,t){const i=[];let o=1;for(const[n,r]of Object.entries(e.sheets)){const s=[["xmlns",Tp.worksheet],["xmlns:r",_p]],a=[["defaultRowHeight",Tm(F)],["defaultColWidth",Am(_)]],l=iS(r,n,o,t,i);o+=r.filterTables.length;let c=gf``;const h=r.charts;if(h.length){const o=[];for(const r of h){const s=km(r.id),a=_m(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../charts/chart${s}.xml`,type:Np.chart});o.push(a),i.push(af(Eb(r,n,e),`xl/charts/chart${s}.xml`,"chart"))}const s=_m(t.relsFiles,`xl/worksheets/_rels/sheet${n}.xml.rels`,{target:`../drawings/drawing${n}.xml`,type:Np.drawing});i.push(af(zb(o,r,h),`xl/drawings/drawing${n}.xml`,"drawing")),c=gf`<drawing r:id="${s}" />`}const d=gf`
2338
+ <worksheet ${cf(s)}>
2339
+ ${eS(r)}
2340
+ <sheetFormatPr ${cf(a)} />
2341
+ ${Xb(r.cols)}
2342
+ ${Yb(t,e,r)}
2343
+ ${Jb(r.merges)}
2344
+ ${uf(Db(t.dxfs,r.conditionalFormats))}
2345
+ ${Qb(t,e,n)}
2345
2346
  ${c}
2346
2347
  ${l}
2347
2348
  </worksheet>
2348
- `;i.push(rf(lf(d),`xl/worksheets/sheet${n}.xml`,"sheet"))}return Om(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Mp.sharedStrings,target:"sharedStrings.xml"}),Om(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Mp.styles,target:"styles.xml"}),i}(e,i)),t.push(function(e){const t=df`
2349
- <styleSheet ${af([["xmlns",Rp.styleSheet],["xmlns:r",Op]])}>
2350
- ${function(e){const t=[];for(let[i,o]of Object.entries(e)){const e=[["numFmtId",parseInt(i)+Lp],["formatCode",o.format]];t.push(df`
2351
- <numFmt ${af(e)}/>
2352
- `)}return df`
2349
+ `;i.push(af(hf(d),`xl/worksheets/sheet${n}.xml`,"sheet"))}return _m(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Np.sharedStrings,target:"sharedStrings.xml"}),_m(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Np.styles,target:"styles.xml"}),i}(e,i)),t.push(function(e){const t=gf`
2350
+ <styleSheet ${cf([["xmlns",Tp.styleSheet],["xmlns:r",_p]])}>
2351
+ ${function(e){const t=[];for(let[i,o]of Object.entries(e)){const e=[["numFmtId",parseInt(i)+Up],["formatCode",o.format]];t.push(gf`
2352
+ <numFmt ${cf(e)}/>
2353
+ `)}return gf`
2353
2354
  <numFmts count="${e.length}">
2354
- ${hf(t)}
2355
+ ${uf(t)}
2355
2356
  </numFmts>
2356
2357
  `}(e.numFmts)}
2357
- ${i=e.fonts,df`
2358
+ ${i=e.fonts,gf`
2358
2359
  <fonts count="${i.length}">
2359
- ${hf(Object.values(i).map(Bb))}
2360
+ ${uf(Object.values(i).map(Wb))}
2360
2361
  </fonts>
2361
2362
  `}
2362
- ${function(e){const t=[];for(let i of Object.values(e))void 0!==i.reservedAttribute?t.push(df`
2363
+ ${function(e){const t=[];for(let i of Object.values(e))void 0!==i.reservedAttribute?t.push(gf`
2363
2364
  <fill>
2364
2365
  <patternFill patternType="${i.reservedAttribute}" />
2365
2366
  </fill>
2366
- `):t.push(df`
2367
+ `):t.push(gf`
2367
2368
  <fill>
2368
2369
  <patternFill patternType="solid">
2369
- <fgColor rgb="${Xn(i.fgColor.rgb)}" />
2370
+ <fgColor rgb="${Kn(i.fgColor.rgb)}" />
2370
2371
  <bgColor indexed="64" />
2371
2372
  </patternFill>
2372
2373
  </fill>
2373
- `);return df`
2374
+ `);return gf`
2374
2375
  <fills count="${e.length}">
2375
- ${hf(t)}
2376
+ ${uf(t)}
2376
2377
  </fills>
2377
2378
  `}(e.fills)}
2378
- ${function(e){const t=[];for(let i of Object.values(e))t.push(df`
2379
+ ${function(e){const t=[];for(let i of Object.values(e))t.push(gf`
2379
2380
  <border>
2380
- <left ${Hb(i.left)} />
2381
- <right ${Hb(i.right)} />
2382
- <top ${Hb(i.top)} />
2383
- <bottom ${Hb(i.bottom)} />
2384
- <diagonal ${Hb(i.diagonal)} />
2381
+ <left ${Gb(i.left)} />
2382
+ <right ${Gb(i.right)} />
2383
+ <top ${Gb(i.top)} />
2384
+ <bottom ${Gb(i.bottom)} />
2385
+ <diagonal ${Gb(i.diagonal)} />
2385
2386
  </border>
2386
- `);return df`
2387
+ `);return gf`
2387
2388
  <borders count="${e.length}">
2388
- ${hf(t)}
2389
+ ${uf(t)}
2389
2390
  </borders>
2390
2391
  `}(e.borders)}
2391
- ${function(e){const t=[];for(let i of e){const e=[["numFmtId",i.numFmtId],["fillId",i.fillId],["fontId",i.fontId],["borderId",i.borderId]],o=[];i.alignment&&i.alignment.vertical&&o.push(["vertical",i.alignment.vertical]),i.alignment&&i.alignment.horizontal&&o.push(["horizontal",i.alignment.horizontal]),t.push(df`
2392
- <xf ${af(e)}>
2393
- ${o?df`<alignment ${af(o)} />`:""}
2392
+ ${function(e){const t=[];for(let i of e){const e=[["numFmtId",i.numFmtId],["fillId",i.fillId],["fontId",i.fontId],["borderId",i.borderId]],o=[];i.alignment&&i.alignment.vertical&&o.push(["vertical",i.alignment.vertical]),i.alignment&&i.alignment.horizontal&&o.push(["horizontal",i.alignment.horizontal]),t.push(gf`
2393
+ <xf ${cf(e)}>
2394
+ ${o?gf`<alignment ${cf(o)} />`:""}
2394
2395
  </xf>
2395
- `)}return df`
2396
+ `)}return gf`
2396
2397
  <cellXfs count="${e.length}">
2397
- ${hf(t)}
2398
+ ${uf(t)}
2398
2399
  </cellXfs>
2399
2400
  `}(e.styles)}
2400
- ${function(e){const t=[];for(const i of e){let e=df``;i.font&&(e=Bb(i.font));let o=df``;i.fill&&(o=df`
2401
+ ${function(e){const t=[];for(const i of e){let e=gf``;i.font&&(e=Wb(i.font));let o=gf``;i.fill&&(o=gf`
2401
2402
  <fill>
2402
2403
  <patternFill>
2403
- <bgColor rgb="${Xn(i.fill.fgColor.rgb)}" />
2404
+ <bgColor rgb="${Kn(i.fill.fgColor.rgb)}" />
2404
2405
  </patternFill>
2405
2406
  </fill>
2406
- `),t.push(df`
2407
+ `),t.push(gf`
2407
2408
  <dxf>
2408
2409
  ${e}
2409
2410
  ${o}
2410
2411
  </dxf>
2411
- `)}return df`
2412
+ `)}return gf`
2412
2413
  <dxfs count="${e.length}">
2413
- ${hf(t)}
2414
+ ${uf(t)}
2414
2415
  </dxfs>
2415
2416
  `}(e.dxfs)}
2416
2417
  </styleSheet>
2417
- `;var i;return rf(lf(t),"xl/styles.xml","styles")}(i)),t.push(function(e){const t=[["xmlns",Rp.sst],["count",e.length],["uniqueCount",e.length]],i=e.map((e=>df`<si><t>${e}</t></si>`));return rf(lf(df`
2418
- <sst ${af(t)}>
2419
- ${hf(i)}
2418
+ `;var i;return af(hf(t),"xl/styles.xml","styles")}(i)),t.push(function(e){const t=[["xmlns",Tp.sst],["count",e.length],["uniqueCount",e.length]],i=e.map((e=>gf`<si><t>${e}</t></si>`));return af(hf(gf`
2419
+ <sst ${cf(t)}>
2420
+ ${uf(i)}
2420
2421
  </sst>
2421
- `),"xl/sharedStrings.xml","sharedStrings")}(i.sharedStrings)),t.push(...function(e){const t=[];for(const i of e){const e=[];for(const t of i.rels){const i=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&i.push(["TargetMode",t.targetMode]),e.push(df`
2422
- <Relationship ${af(i)} />
2423
- `)}const o=df`
2424
- <Relationships xmlns="${Rp.Relationships}">
2425
- ${hf(e)}
2422
+ `),"xl/sharedStrings.xml","sharedStrings")}(i.sharedStrings)),t.push(...function(e){const t=[];for(const i of e){const e=[];for(const t of i.rels){const i=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&i.push(["TargetMode",t.targetMode]),e.push(gf`
2423
+ <Relationship ${cf(i)} />
2424
+ `)}const o=gf`
2425
+ <Relationships xmlns="${Tp.Relationships}">
2426
+ ${uf(e)}
2426
2427
  </Relationships>
2427
- `;t.push(rf(lf(o),i.path))}return t}(i.relsFiles)),t.push(function(e){const t=[];for(const i of e)i.contentType&&t.push(cf("/"+i.path,Ap[i.contentType]));return rf(lf(df`
2428
- <Types xmlns="${Rp.Types}">
2428
+ `;t.push(af(hf(o),i.path))}return t}(i.relsFiles)),t.push(function(e){const t=[];for(const i of e)i.contentType&&t.push(df("/"+i.path,Mp[i.contentType]));return af(hf(gf`
2429
+ <Types xmlns="${Tp.Types}">
2429
2430
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
2430
2431
  <Default Extension="xml" ContentType="application/xml" />
2431
- ${hf(t)}
2432
+ ${uf(t)}
2432
2433
  </Types>
2433
- `),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",Mp.document],["Target","xl/workbook.xml"]];return rf(lf(df`
2434
- <Relationships xmlns="${Rp.Relationships}">
2435
- <Relationship ${af(e)} />
2434
+ `),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",Np.document],["Target","xl/workbook.xml"]];return af(hf(gf`
2435
+ <Relationships xmlns="${Tp.Relationships}">
2436
+ <Relationship ${cf(e)} />
2436
2437
  </Relationships>
2437
- `),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function eS(e,t,i,o,n){let r=i;if(!e.filterTables.length)return new Ep("");const s=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const i=Om(o.relsFiles,s,{target:`../tables/table${r}.xml`,type:Mp.table});n.push(rf(Gb(t,r,e),`xl/tables/table${r}.xml`,"table")),a.push(df`<tablePart r:id="${i}" />`),r++}return df`
2438
+ `),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function iS(e,t,i,o,n){let r=i;if(!e.filterTables.length)return new yp("");const s=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const i=_m(o.relsFiles,s,{target:`../tables/table${r}.xml`,type:Np.table});n.push(af(Zb(t,r,e),`xl/tables/table${r}.xml`,"table")),a.push(gf`<tablePart r:id="${i}" />`),r++}return gf`
2438
2439
  <tableParts count="${e.filterTables.length}">
2439
- ${hf(a)}
2440
+ ${uf(a)}
2440
2441
  </tableParts>
2441
- `}var tS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(tS||(tS={}));const iS={},oS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:N,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},nS={autofillModifiersRegistry:Qi,autofillRulesRegistry:co,cellMenuRegistry:On,colMenuRegistry:Nn,linkMenuRegistry:ko,functionRegistry:Tu,uiPluginRegistry:Gv,corePluginRegistry:Wv,rowMenuRegistry:_n,sidePanelRegistry:as,figureRegistry:zo,sheetMenuRegistry:Dn,chartSidePanelComponentRegistry:Qr,chartComponentRegistry:Yi,chartRegistry:Xi,topbarMenuRegistry:Bn,topbarComponentRegistry:ls,clickableCellRegistry:qv,otRegistry:Hn,inverseCommandRegistry:Bo,cellRegistry:Uo,cellPopoverRegistry:Po},rS={LinkCell:mp},sS={args:Es,toBoolean:_s,toJsDate:Fs,toNumber:Ts,toString:Ms,toXC:kt,toZone:yi,toCartesian:Dt,numberToLetters:_t,createFullMenuItem:_o,UuidGenerator:Ei,formatValue:Gt,computeTextWidth:Ne,isMarkdownLink:Be,parseMarkdownLink:We,markdownLink:He,createEmptyWorkbookData:$f,createEmptySheet:kf,createEmptyExcelSheet:Lf,getDefaultChartJsRuntime:fr,chartFontColor:ar,getMenuChildren:wo,ChartColors:sr,EvaluationError:c,CellErrorLevel:l,getFillingMode:Sr,rgbaToHex:vt,colorToRGBA:bt,positionToZone:Wi},aS={ChartPanel:Jr,ChartFigure:gs,ChartJsComponent:Ki,Grid:lp,GridOverlay:qg,ScorecardChart:hs,LineConfigPanel:jr,LineBarPieDesignPanel:Wr,BarConfigPanel:Zn,LineBarPieConfigPanel:qn,GaugeChartConfigPanel:qr,GaugeChartDesignPanel:Zr,ScorecardChartConfigPanel:Yr,ScorecardChartDesignPanel:Kr};e.AbstractChart=jn,e.CorePlugin=Pf,e.DATETIME_FORMAT=X,e.DispatchResult=ro,e.EvaluationError=c,e.Model=class extends Tv{constructor(e={},i={},o=[],n=new Ei,r=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={type:e,...t};let o=this.status;if(this.getters.isReadonly()&&(n=i,!io.has(n.type)))return new ro(66);var n;if(!this.session.canApplyOptimisticUpdate())return new ro(63);switch(o){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:o,commands:n}=this.state.recordChanges((()=>{no(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(n,o),this.status=0,this.trigger("update");break;case 1:if(no(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i)}else this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(no(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return ro.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={type:e,...t},o=this.status;this.status=2;const n=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(n,i),this.status=o,ro.Success},o=Ff(e,o);const s=Nf(e,r);this.state=new fb,this.uuidGenerator=n,this.config=this.setupConfig(i),this.session=this.setupSession(s.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new ub(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new gb(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new mb(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of Wv.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of Gv.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(o),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}this.uiPlugins.push(t),this.handlers.push(t);const i=e.layers.map((e=>[t,e]));this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const i=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new $v(hb(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},i=e.transportService||new tb;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new ro(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Te(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=$f();for(let t of this.handlers)t instanceof Pf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Te(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...$f(),sheets:[Lf(Of,"Sheet1")]};for(let t of this.handlers)t instanceof Eg&&t.exportForExcel(e);return e=Te(e),Jb(e)}},e.Registry=ji,e.Revision=Dv,e.SPREADSHEET_DIMENSIONS=oS,e.Spreadsheet=eb,e.UIPlugin=wg,e.__info__=iS,e.addFunction=function(e,t){Tu.add(e,t)},e.astToFormula=ig,e.cellTypes=rS,e.compile=fg,e.components=aS,e.convertAstNodes=tg,e.coreTypes=oo,e.findCellInNewZone=Bi,e.functionCache=mg,e.helpers=sS,e.invalidateEvaluationCommands=eo,e.load=Nf,e.parse=Ju,e.readonlyAllowedCommands=io,e.registries=nS,e.setTranslationMethod=function(e){i=e},e.tokenize=Nu,Object.defineProperty(e,"__esModule",{value:!0}),iS.version="16.0.16",iS.date="2023-08-07T09:01:50.801Z",iS.hash="2b5ecd8"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2442
+ `}var oS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(oS||(oS={}));const nS={},rS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:M,HEADER_WIDTH:N,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},sS={autofillModifiersRegistry:Ji,autofillRulesRegistry:ho,cellMenuRegistry:_n,colMenuRegistry:Fn,linkMenuRegistry:$o,functionRegistry:Ou,uiPluginRegistry:Zv,corePluginRegistry:qv,rowMenuRegistry:Dn,sidePanelRegistry:cs,figureRegistry:Bo,sheetMenuRegistry:$n,chartSidePanelComponentRegistry:es,chartComponentRegistry:Ki,chartRegistry:Yi,topbarMenuRegistry:Wn,topbarComponentRegistry:hs,clickableCellRegistry:jv,otRegistry:Gn,inverseCommandRegistry:Ho,cellRegistry:Vo,cellPopoverRegistry:Uo},aS={LinkCell:vp},lS={args:ys,toBoolean:Ds,toJsDate:ks,toNumber:Os,toString:Ns,toXC:$t,toZone:xi,toCartesian:kt,numberToLetters:Ft,createFullMenuItem:Fo,UuidGenerator:wi,formatValue:qt,computeTextWidth:Ne,isMarkdownLink:Be,parseMarkdownLink:We,markdownLink:He,createEmptyWorkbookData:Pf,createEmptySheet:Lf,createEmptyExcelSheet:Uf,getDefaultChartJsRuntime:br,chartFontColor:cr,getMenuChildren:yo,ChartColors:lr,EvaluationError:c,CellErrorLevel:l,getFillingMode:Er,rgbaToHex:bt,colorToRGBA:St,positionToZone:Gi},cS={ChartPanel:ts,ChartFigure:ms,ChartJsComponent:Qi,Grid:hp,GridOverlay:jg,ScorecardChart:us,LineConfigPanel:Yr,LineBarPieDesignPanel:qr,BarConfigPanel:Xn,LineBarPieConfigPanel:jn,GaugeChartConfigPanel:jr,GaugeChartDesignPanel:Xr,ScorecardChartConfigPanel:Qr,ScorecardChartDesignPanel:Jr};e.AbstractChart=Yn,e.CorePlugin=Vf,e.DATETIME_FORMAT=X,e.DispatchResult=so,e.EvaluationError=c,e.Model=class extends Ov{constructor(e={},i={},o=[],n=new wi,r=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={type:e,...t};let o=this.status;if(this.getters.isReadonly()&&(n=i,!oo.has(n.type)))return new so(66);var n;if(!this.session.canApplyOptimisticUpdate())return new so(63);switch(o){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:o,commands:n}=this.state.recordChanges((()=>{ro(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(n,o),this.status=0,this.trigger("update");break;case 1:if(ro(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i)}else this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(ro(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return so.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={type:e,...t},o=this.status;this.status=2;const n=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(n,i),this.status=o,so.Success},o=kf(e,o);const s=Ff(e,r);this.state=new bb,this.uuidGenerator=n,this.config=this.setupConfig(i),this.session=this.setupSession(s.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new pb(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new mb(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new vb(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of qv.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of Zv.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(o),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}this.uiPlugins.push(t),this.handlers.push(t);const i=e.layers.map((e=>[t,e]));this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const i=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Pv(ub(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},i=e.transportService||new ob;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new so(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Te(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Pf();for(let t of this.handlers)t instanceof Vf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Te(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Pf(),sheets:[Uf(_f,"Sheet1")]};for(let t of this.handlers)t instanceof yg&&t.exportForExcel(e);return e=Te(e),tS(e)}},e.Registry=Xi,e.Revision=$v,e.SPREADSHEET_DIMENSIONS=rS,e.Spreadsheet=ib,e.UIPlugin=xg,e.__info__=nS,e.addFunction=function(e,t){Ou.add(e,t)},e.astToFormula=ng,e.cellTypes=aS,e.compile=bg,e.components=cS,e.convertAstNodes=og,e.coreTypes=no,e.findCellInNewZone=Hi,e.functionCache=vg,e.helpers=lS,e.invalidateEvaluationCommands=to,e.load=Ff,e.parse=tg,e.readonlyAllowedCommands=oo,e.registries=sS,e.setTranslationMethod=function(e){i=e},e.tokenize=Fu,Object.defineProperty(e,"__esModule",{value:!0}),nS.version="16.0.18",nS.date="2023-09-12T11:42:03.083Z",nS.hash="41fd4fa"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);